Commit 4b09901c authored by Bharat Jauhari's avatar Bharat Jauhari Committed by Oded Gabbay

habanalabs: enable dram scramble before linux f/w

In current code, for dynamic f/w loading flow, DRAM scrambling is
enabled post Linux fit image is loaded to the card. This can cause the
device CPU to go into reset state.

The correct sequence should be:
1. Load boot fit image
2. Enable scrambling
3. Load Linux fit image

This commit aligns the DRAM scrambling enabling with the static f/w load
flow.
Signed-off-by: default avatarBharat Jauhari <bjauhari@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 358526be
...@@ -2149,6 +2149,11 @@ static int hl_fw_dynamic_init_cpu(struct hl_device *hdev, ...@@ -2149,6 +2149,11 @@ static int hl_fw_dynamic_init_cpu(struct hl_device *hdev,
if (rc) if (rc)
goto protocol_err; goto protocol_err;
/* Enable DRAM scrambling before Linux boot and after successful
* UBoot
*/
hdev->asic_funcs->init_cpu_scrambler_dram(hdev);
if (!(hdev->fw_components & FW_TYPE_LINUX)) { if (!(hdev->fw_components & FW_TYPE_LINUX)) {
dev_info(hdev->dev, "Skip loading Linux F/W\n"); dev_info(hdev->dev, "Skip loading Linux F/W\n");
return 0; return 0;
...@@ -2295,6 +2300,11 @@ static int hl_fw_static_init_cpu(struct hl_device *hdev, ...@@ -2295,6 +2300,11 @@ static int hl_fw_static_init_cpu(struct hl_device *hdev,
goto out; goto out;
} }
/* Enable DRAM scrambling before Linux boot and after successful
* UBoot
*/
hdev->asic_funcs->init_cpu_scrambler_dram(hdev);
if (!(hdev->fw_components & FW_TYPE_LINUX)) { if (!(hdev->fw_components & FW_TYPE_LINUX)) {
dev_info(hdev->dev, "Skip loading Linux F/W\n"); dev_info(hdev->dev, "Skip loading Linux F/W\n");
goto out; goto out;
......
...@@ -1092,7 +1092,8 @@ struct fw_load_mgr { ...@@ -1092,7 +1092,8 @@ struct fw_load_mgr {
* @get_msi_info: Retrieve asic-specific MSI ID of the f/w async event * @get_msi_info: Retrieve asic-specific MSI ID of the f/w async event
* @map_pll_idx_to_fw_idx: convert driver specific per asic PLL index to * @map_pll_idx_to_fw_idx: convert driver specific per asic PLL index to
* generic f/w compatible PLL Indexes * generic f/w compatible PLL Indexes
*@init_firmware_loader: initialize data for FW loader. * @init_firmware_loader: initialize data for FW loader.
* @init_cpu_scrambler_dram: Enable CPU specific DRAM scrambling
*/ */
struct hl_asic_funcs { struct hl_asic_funcs {
int (*early_init)(struct hl_device *hdev); int (*early_init)(struct hl_device *hdev);
...@@ -1217,6 +1218,7 @@ struct hl_asic_funcs { ...@@ -1217,6 +1218,7 @@ struct hl_asic_funcs {
void (*get_msi_info)(__le32 *table); void (*get_msi_info)(__le32 *table);
int (*map_pll_idx_to_fw_idx)(u32 pll_idx); int (*map_pll_idx_to_fw_idx)(u32 pll_idx);
void (*init_firmware_loader)(struct hl_device *hdev); void (*init_firmware_loader)(struct hl_device *hdev);
void (*init_cpu_scrambler_dram)(struct hl_device *hdev);
}; };
......
...@@ -3804,9 +3804,6 @@ static int gaudi_load_firmware_to_device(struct hl_device *hdev) ...@@ -3804,9 +3804,6 @@ static int gaudi_load_firmware_to_device(struct hl_device *hdev)
{ {
void __iomem *dst; void __iomem *dst;
/* HBM scrambler must be initialized before pushing F/W to HBM */
gaudi_init_scrambler_hbm(hdev);
dst = hdev->pcie_bar[HBM_BAR_ID] + LINUX_FW_OFFSET; dst = hdev->pcie_bar[HBM_BAR_ID] + LINUX_FW_OFFSET;
return hl_fw_load_fw_to_device(hdev, GAUDI_LINUX_FW_FILE, dst, 0, 0); return hl_fw_load_fw_to_device(hdev, GAUDI_LINUX_FW_FILE, dst, 0, 0);
...@@ -8949,6 +8946,7 @@ static const struct hl_asic_funcs gaudi_funcs = { ...@@ -8949,6 +8946,7 @@ static const struct hl_asic_funcs gaudi_funcs = {
.enable_events_from_fw = gaudi_enable_events_from_fw, .enable_events_from_fw = gaudi_enable_events_from_fw,
.map_pll_idx_to_fw_idx = gaudi_map_pll_idx_to_fw_idx, .map_pll_idx_to_fw_idx = gaudi_map_pll_idx_to_fw_idx,
.init_firmware_loader = gaudi_init_firmware_loader, .init_firmware_loader = gaudi_init_firmware_loader,
.init_cpu_scrambler_dram = gaudi_init_scrambler_hbm
}; };
/** /**
......
...@@ -5402,6 +5402,11 @@ static int goya_get_eeprom_data(struct hl_device *hdev, void *data, ...@@ -5402,6 +5402,11 @@ static int goya_get_eeprom_data(struct hl_device *hdev, void *data,
return hl_fw_get_eeprom_data(hdev, data, max_size); return hl_fw_get_eeprom_data(hdev, data, max_size);
} }
static void goya_cpu_init_scrambler_dram(struct hl_device *hdev)
{
}
static int goya_ctx_init(struct hl_ctx *ctx) static int goya_ctx_init(struct hl_ctx *ctx)
{ {
if (ctx->asid != HL_KERNEL_ASID_ID) if (ctx->asid != HL_KERNEL_ASID_ID)
...@@ -5601,7 +5606,8 @@ static const struct hl_asic_funcs goya_funcs = { ...@@ -5601,7 +5606,8 @@ static const struct hl_asic_funcs goya_funcs = {
.hw_block_mmap = goya_block_mmap, .hw_block_mmap = goya_block_mmap,
.enable_events_from_fw = goya_enable_events_from_fw, .enable_events_from_fw = goya_enable_events_from_fw,
.map_pll_idx_to_fw_idx = goya_map_pll_idx_to_fw_idx, .map_pll_idx_to_fw_idx = goya_map_pll_idx_to_fw_idx,
.init_firmware_loader = goya_init_firmware_loader .init_firmware_loader = goya_init_firmware_loader,
.init_cpu_scrambler_dram = goya_cpu_init_scrambler_dram
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment