habanalabs: notify before f/w loading
PATCH 1/5 habanalabs: notify before f/w loading
An information print notifying on starting to load the f/w was removed by mistake when moving to the new dynamic f/w loading mechanism.
Restore that print as the F/W loading usually takes between 10 to 20 seconds and this print helps the user know the status of the driver load.
--- drivers/misc/habanalabs/common/firmware_if.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/habanalabs/common/firmware_if.c +3 -0
@@ -1951,6 +1951,9 @@ static int hl_fw_dynamic_init_cpu(struct hl_device *hdev,struct cpu_dyn_regs *dyn_regs;int rc; +dev_info (hdev->dev, +"Loading firmware to device, may take some time...\n" ); + dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_RST_STATE,
Signature · 1 line
2.25.1
PATCH 2/5 habanalabs/gaudi: send hard reset cause to preboot
From: Koby Elbaz <[email protected]>
LKD should provide hard reset cause to preboot prior to loading any FW components (in case needed).
Current implementation is based on the new FW 'COMMS' protocol In cased 'COMMS' is disabled - reset cause won't be sent. Currently, only 2 reset causes are shared: HEARTBEAT & TDR.
Sending the reset cause will provide the missing watchdog info that the firmware needs to provide to the BMC.
--- .../habanalabs/common/command_submission.c | 2 +- drivers/misc/habanalabs/common/device.c | 18 ++- drivers/misc/habanalabs/common/firmware_if.c | 127 +++++++++++++++++- drivers/misc/habanalabs/common/habanalabs.h | 7 + .../misc/habanalabs/common/habanalabs_drv.c | 2 + .../habanalabs/include/common/hl_boot_if.h | 60 ++++++++- 6 files changed, 208 insertions(+), 8 deletions(-)
drivers/misc/habanalabs/common/command_submission.c +1 -1
@@ -614,7 +614,7 @@ static void cs_timedout(struct work_struct *work)cs_put (cs);if (hdev->reset_on_lockup) -hl_device_reset (hdev,0 ); +hl_device_reset (hdev,HL_RESET_TDR );else hdev->needs_reset = true; }
drivers/misc/habanalabs/common/device.c +15 -3
@@ -900,6 +900,19 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)if (rc)return 0 ; +/* +* 'reset cause' is being updated here, because getting here +* means that it's the 1st time and the last time we're here +* ('in_reset' makes sure of it). This makes sure that +* 'reset_cause' will continue holding its 1st recorded reason! +*/ +if (flags &HL_RESET_HEARTBEAT ) + hdev->curr_reset_cause =HL_RESET_CAUSE_HEARTBEAT ; +else if (flags &HL_RESET_TDR ) + hdev->curr_reset_cause =HL_RESET_CAUSE_TDR ; +else + hdev->curr_reset_cause =HL_RESET_CAUSE_UNKNOWN ; +/* * if reset is due to heartbeat, device CPU is no responsive in * which case no point sending PCI disable message to it
@@ -943,9 +956,8 @@ int hl_device_reset(struct hl_device *hdev, u32 flags) hdev->process_kill_trial_cnt =0 ;/* -* Because the reset function can't run from interrupt or -* from heartbeat work, we need to call the reset function -* from a dedicated work +* Because the reset function can't run from heartbeat work, +* we need to call the reset function from a dedicated work. */ queue_delayed_work (hdev->device_reset_work.wq, &hdev->device_reset_work.reset_work,0 );
drivers/misc/habanalabs/common/firmware_if.c +126 -1
157 lines not on this page · raw message
drivers/misc/habanalabs/common/habanalabs.h +7 -0
@@ -115,10 +115,14 @@ enum hl_mmu_page_table_location {* * - HL_RESET_HEARTBEAT * Set if reset is due to heartbeat +* +* - HL_RESET_TDR +* Set if reset is due to TDR */ #define HL_RESET_HARD (1 << 0)#define HL_RESET_FROM_RESET_THREAD (1 << 1)#define HL_RESET_HEARTBEAT (1 << 2) +#define HL_RESET_TDR (1 << 3)#define HL_MAX_SOBS_PER_MONITOR 8
@@ -2163,6 +2167,8 @@ struct hl_mmu_funcs {* @device_fini_pending: true if device_fini was called and might be * waiting for the reset thread to finish * @supports_staged_submission: true if staged submissions are supported +* @curr_reset_cause: saves an enumerated reset cause when a hard reset is +* triggered, and cleared after it is shared with preboot. */ struct hl_device {struct pci_dev *pdev;
@@ -2273,6 +2279,7 @@ struct hl_device {u8 process_kill_trial_cnt;u8 device_fini_pending;u8 supports_staged_submission; +u8 curr_reset_cause;/* Parameters for bring-up */ u64 nic_ports_mask;
drivers/misc/habanalabs/common/habanalabs_drv.c +2 -0
@@ -330,6 +330,8 @@ int create_hdev(struct hl_device **dev, struct pci_dev *pdev,set_driver_behavior_per_device (hdev); + hdev->curr_reset_cause =HL_RESET_CAUSE_UNKNOWN ; +if (timeout_locked) hdev->timeout_jiffies =msecs_to_jiffies (timeout_locked *1000 );else
drivers/misc/habanalabs/include/common/hl_boot_if.h +57 -3
90 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 3/5 habanalabs: check if asic secured with asic type
In reply to Oded GabbayFrom: Ohad Sharabi <[email protected]>
Fix issue in which the input to the function is_asic_secured was device PCI_IDS number instead of the asic_type enumeration.
--- drivers/misc/habanalabs/common/habanalabs_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/common/habanalabs_drv.c +1 -1
@@ -309,7 +309,7 @@ int create_hdev(struct hl_device **dev, struct pci_dev *pdev,if (pdev) hdev->asic_prop.fw_security_disabled = - !is_asic_secured (pdev->device); + !is_asic_secured (hdev->asic_type);else hdev->asic_prop.fw_security_disabled = true;
Signature · 1 line
2.25.1
PATCH 4/5 habanalabs/gaudi: read GIC sts after FW is loaded
In reply to Oded GabbayFrom: Koby Elbaz <[email protected]>
Reading of GIC privileged status will be done after F/W is loaded, because privileged GIC capability is only available with the correct ARMCP version, and after it's loaded.
Such versions necessarily support COMMS, so GIC alternatives (SP regs) will be read directly from dynamic regs.
As well, initiation of DMA QMANs will occur after F/W is loaded since it depends on GIC configuration.
In case F/W isn't loaded there's no problem since either way there won't be any GIC IRQ handling.
--- drivers/misc/habanalabs/common/firmware_if.c | 16 ++--- drivers/misc/habanalabs/gaudi/gaudi.c | 59 +++++++++++++------ .../habanalabs/include/common/hl_boot_if.h | 10 +++- 3 files changed, 57 insertions(+), 28 deletions(-)
drivers/misc/habanalabs/common/firmware_if.c +9 -7
@@ -1123,9 +1123,6 @@ static void hl_fw_preboot_update_state(struct hl_device *hdev)if (cpu_boot_dev_sts0 &CPU_BOOT_DEV_STS0_FW_HARD_RST_EN ) prop->hard_reset_done_by_fw = true; - -if (cpu_boot_dev_sts0 &CPU_BOOT_DEV_STS0_GIC_PRIVILEGED_EN ) - prop->gic_interrupts_enable = false; }else { prop->fw_cpu_boot_dev_sts0_valid =0 ; }
@@ -1143,11 +1140,8 @@ static void hl_fw_preboot_update_state(struct hl_device *hdev)dev_dbg (hdev->dev,"Firmware preboot hard-reset is %s\n" , prop->hard_reset_done_by_fw ?"enabled" :"disabled" ); -dev_info (hdev->dev,"firmware-level security is %s\n" , +dev_dbg (hdev->dev,"firmware-level security is %s\n" , prop->fw_security_disabled ?"disabled" :"enabled" ); - -dev_info (hdev->dev,"GIC controller is %s\n" , - prop->gic_interrupts_enable ?"enabled" :"disabled" ); }static int hl_fw_static_read_preboot_status (struct hl_device *hdev)
@@ -1971,9 +1965,17 @@ static void hl_fw_linux_update_state(struct hl_device *hdev, CPU_BOOT_DEV_STS0_FW_HARD_RST_EN) prop->hard_reset_done_by_fw = true; +if (prop->fw_app_cpu_boot_dev_sts0 & +CPU_BOOT_DEV_STS0_GIC_PRIVILEGED_EN ) + prop->gic_interrupts_enable = false; +dev_dbg (hdev->dev,"Firmware application CPU status0 %#x\n" , prop->fw_app_cpu_boot_dev_sts0); + +dev_dbg (hdev->dev,"GIC controller is %s\n" , + prop->gic_interrupts_enable ? +"enabled" :"disabled" ); }if (prop->fw_cpu_boot_dev_sts1_valid) {
drivers/misc/habanalabs/gaudi/gaudi.c +40 -19
187 lines not on this page · raw message
drivers/misc/habanalabs/include/common/hl_boot_if.h +8 -2
@@ -195,7 +195,7 @@* previleged entity. FW sets this status * bit for host. If this bit is set then * GIC can not be accessed from host. -* Initialized in: preboot +* Initialized in: armcpd * * CPU_BOOT_DEV_STS0_ENABLED Device status register enabled. * This is a main indication that the
@@ -299,7 +299,13 @@ struct cpu_dyn_regs {__le32 hw_state;__le32 kmd_msg_to_cpu;__le32 cpu_cmd_status_to_host; -__le32 reserved1[32 ];/* reserve for future use */ +__le32 gic_host_irq_ctrl; +__le32 gic_tpc_qm_irq_ctrl; +__le32 gic_mme_qm_irq_ctrl; +__le32 gic_dma_qm_irq_ctrl; +__le32 gic_nic_qm_irq_ctrl; +__le32 gic_dma_core_irq_ctrl; +__le32 reserved1[26 ];/* reserve for future use */ };/* TODO: remove the desc magic after the code is updated to use message */
Signature · 1 line
2.25.1
PATCH 5/5 habanalabs/gaudi: do not move HBM bar if iATU done by FW
In reply to Oded GabbayFrom: Ofir Bitton <[email protected]>
As iATU configuration is done by FW, driver should not try and move HBM bar.
--- drivers/misc/habanalabs/gaudi/gaudi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/misc/habanalabs/gaudi/gaudi.c +20 -0
@@ -580,6 +580,9 @@ static u64 gaudi_set_hbm_bar_base(struct hl_device *hdev, u64 addr)if ((gaudi) && (gaudi->hbm_bar_cur_addr == addr))return old_addr; +if (hdev->asic_prop.iatu_done_by_fw) +return U64_MAX ; +/* Inbound Region 2 - Bar 4 - Point to HBM */ pci_region.mode =PCI_BAR_MATCH_MODE ; pci_region.bar =HBM_BAR_ID ;
@@ -3974,10 +3977,27 @@ static void gaudi_pre_hw_init(struct hl_device *hdev)static int gaudi_hw_init (struct hl_device *hdev) { +struct gaudi_device *gaudi = hdev->asic_specific;int rc;gaudi_pre_hw_init (hdev); +/* If iATU is done by FW, the HBM bar ALWAYS points to DRAM_PHYS_BASE. +* So we set it here and if anyone tries to move it later to +* a different address, there will be an error +*/ +if (hdev->asic_prop.iatu_done_by_fw) + gaudi->hbm_bar_cur_addr =DRAM_PHYS_BASE ; + +/* +* Before pushing u-boot/linux to device, need to set the hbm bar to +* base address of dram +*/ +if (gaudi_set_hbm_bar_base (hdev,DRAM_PHYS_BASE ) ==U64_MAX ) { +dev_err (hdev->dev, +"failed to map HBM bar to DRAM base address\n" ); +return -EIO ; + } rc =gaudi_init_cpu (hdev);if (rc) {
Signature · 1 line
2.25.1