accel/habanalabs: add missing tpc interrupt info
Oded Gabbay
maintainerPATCH 2/6 accel/habanalabs: add pci health check during heartbeat
In reply to Oded GabbayFrom: Ofir Bitton <[email protected]>
Currently upon a heartbeat failure, we don't know if the failure is due to firmware hang or due to a bad PCI link. Hence, we are reading a PCI config space register with a known value (vendor ID) so we will know which of the two possibilities caused the heartbeat failure.
--- drivers/accel/habanalabs/common/device.c | 15 ++++++++++++++- drivers/accel/habanalabs/common/habanalabs.h | 2 ++ drivers/accel/habanalabs/common/habanalabs_drv.c | 2 -- 3 files changed, 16 insertions(+), 3 deletions(-)
drivers/accel/habanalabs/common/device.c +14 -1
@@ -981,6 +981,18 @@ static void device_early_fini(struct hl_device *hdev) hdev->asic_funcs->early_fini (hdev); } +static bool is_pci_link_healthy (struct hl_device *hdev) +{ +u16 vendor_id; + +if (!hdev->pdev) +return false; + +pci_read_config_word (hdev->pdev,PCI_VENDOR_ID , &vendor_id); + +return (vendor_id ==PCI_VENDOR_ID_HABANALABS ); +} +static void hl_device_heartbeat (struct work_struct *work) { struct hl_device *hdev = container_of(work, struct hl_device,
@@ -995,7 +1007,8 @@ static void hl_device_heartbeat(struct work_struct *work) goto reschedule;if (hl_device_operational (hdev,NULL )) -dev_err (hdev->dev,"Device heartbeat failed!\n" ); +dev_err (hdev->dev,"Device heartbeat failed! PCI link is %s\n" , +is_pci_link_healthy (hdev) ?"healthy" :"broken" ); info.err_type =HL_INFO_FW_HEARTBEAT_ERR ; info.event_mask = &event_mask;
drivers/accel/habanalabs/common/habanalabs.h +2 -0
@@ -36,6 +36,8 @@struct hl_device ;struct hl_fpriv ; +#define PCI_VENDOR_ID_HABANALABS 0x1da3 +/* Use upper bits of mmap offset to store habana driver specific information. * bits[63:59] - Encode mmap type * bits[45:0] - mmap offset value
drivers/accel/habanalabs/common/habanalabs_drv.c +0 -2
@@ -54,8 +54,6 @@ module_param(boot_error_status_mask, ulong, 0444);MODULE_PARM_DESC (boot_error_status_mask,"Mask of the error status during device CPU boot (If bitX is cleared then error X is masked. Default all 1's)" ); -#define PCI_VENDOR_ID_HABANALABS 0x1da3 -#define PCI_IDS_GOYA 0x0001#define PCI_IDS_GAUDI 0x1000#define PCI_IDS_GAUDI_SEC 0x1010
Signature · 1 line
2.40.1
Oded Gabbay
maintainerPATCH 1/6 accel/habanalabs: add missing tpc interrupt info
From: Dafna Hirschfeld <[email protected]>
For some reason the last possible tpc interrupt cause in gaudi2_tpc_interrupts_cause is missing from the code.
--- drivers/accel/habanalabs/gaudi2/gaudi2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/accel/habanalabs/gaudi2/gaudi2.c +2 -1
@@ -63,7 +63,7 @@#define GAUDI2_NUM_OF_CPU_SEI_ERR_CAUSE 3#define GAUDI2_NUM_OF_QM_SEI_ERR_CAUSE 2#define GAUDI2_NUM_OF_ROT_ERR_CAUSE 22 -#define GAUDI2_NUM_OF_TPC_INTR_CAUSE 30 +#define GAUDI2_NUM_OF_TPC_INTR_CAUSE 31#define GAUDI2_NUM_OF_DEC_ERR_CAUSE 25#define GAUDI2_NUM_OF_MME_ERR_CAUSE 16#define GAUDI2_NUM_OF_MME_SBTE_ERR_CAUSE 5
@@ -891,6 +891,7 @@ static const char * const gaudi2_tpc_interrupts_cause[GAUDI2_NUM_OF_TPC_INTR_CAU"invalid_lock_access" ,"LD_L protection violation" ,"ST_L protection violation" , + "D$ L0CS mismatch", }; static const char * const guadi2_mme_error_cause[GAUDI2_NUM_OF_MME_ERR_CAUSE] = {
Signature · 1 line
2.40.1
Oded Gabbay
maintainerPATCH 4/6 accel/habanalabs: poll for device status update following WFE cmd
From: Koby Elbaz <[email protected]>
Currently, we rely on COMMS protocol's ack to verify that WFE command has been acknowledged by the FW. However, this does not guarantee that the device status has been updated.
Although unlikely, this could trigger a race since the driver expects the device to be halted at that stage, but it might not be. Therefore, we increase WFE's robustness by polling on the status register that will be updated once the device is actually halted.
--- drivers/accel/habanalabs/common/firmware_if.c | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-)
drivers/accel/habanalabs/common/firmware_if.c +23 -5
@@ -1368,8 +1368,10 @@ void hl_fw_ask_hard_reset_without_linux(struct hl_device *hdev)void hl_fw_ask_halt_machine_without_linux (struct hl_device *hdev) { -struct static_fw_load_mgr *static_loader = - &hdev->fw_loader.static_loader; +struct fw_load_mgr *fw_loader = &hdev->fw_loader; +u32 status, cpu_boot_status_reg, cpu_timeout; +struct static_fw_load_mgr *static_loader; +struct pre_fw_load_props *pre_fw_load;int rc;if (hdev->device_cpu_is_halted)
@@ -1377,12 +1379,28 @@ void hl_fw_ask_halt_machine_without_linux(struct hl_device *hdev)/* Stop device CPU to make sure nothing bad happens */ if (hdev->asic_prop.dynamic_fw_load) { + pre_fw_load = &fw_loader->pre_fw_load; + cpu_timeout = fw_loader->cpu_timeout; + cpu_boot_status_reg = pre_fw_load->cpu_boot_status_reg; + rc =hl_fw_dynamic_send_protocol_cmd (hdev, &hdev->fw_loader, -COMMS_GOTO_WFE ,0 , false, - hdev->fw_loader.cpu_timeout); -if (rc) +COMMS_GOTO_WFE ,0 , false, cpu_timeout); +if (rc) {dev_err (hdev->dev,"Failed sending COMMS_GOTO_WFE\n" ); + }else { + rc =hl_poll_timeout ( + hdev, + cpu_boot_status_reg, + status, + status ==CPU_BOOT_STATUS_IN_WFE , + hdev->fw_poll_interval_usec, + cpu_timeout); +if (rc) +dev_err (hdev->dev,"Current status=%u. Timed-out updating to WFE\n" , + status); + } }else { + static_loader = &hdev->fw_loader.static_loader;WREG32 (static_loader->kmd_msg_to_cpu_reg,KMD_MSG_GOTO_WFE );msleep (static_loader->cpu_reset_wait_msec);
Signature · 1 line
2.40.1
Oded Gabbay
maintainerPATCH 3/6 accel/habanalabs: expose debugfs files later
In reply to Oded GabbayFrom: Tomer Tayar <[email protected]>
Currently the debugfs root folder and files for a device are created at an early step, before the device initialization and before the char device and sysfs files are exposed to user.
As there is no real reason not to do it together with the device creation, postpone it to be done right afterwards.
The initialization of the debugfs entry structure is left in its current position because it is used before creating the files.
--- drivers/accel/habanalabs/common/debugfs.c | 37 +++++++----- drivers/accel/habanalabs/common/device.c | 62 +++++++++++--------- drivers/accel/habanalabs/common/habanalabs.h | 6 +- 3 files changed, 61 insertions(+), 44 deletions(-)
drivers/accel/habanalabs/common/debugfs.c +23 -14
@@ -1756,17 +1756,15 @@ static void add_files_to_device(struct hl_device *hdev, struct hl_dbg_device_ent } } -void hl_debugfs_add_device (struct hl_device *hdev) +int hl_debugfs_device_init (struct hl_device *hdev) {struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;int count =ARRAY_SIZE (hl_debugfs_list); dev_entry->hdev = hdev; - dev_entry->entry_arr =kmalloc_array (count, -sizeof (struct hl_debugfs_entry ), -GFP_KERNEL ); + dev_entry->entry_arr =kmalloc_array (count,sizeof (struct hl_debugfs_entry ),GFP_KERNEL );if (!dev_entry->entry_arr) -return ; +return -ENOMEM ; dev_entry->data_dma_blob_desc.size =0 ; dev_entry->data_dma_blob_desc.data =NULL ;
@@ -1787,21 +1785,14 @@ void hl_debugfs_add_device(struct hl_device *hdev)spin_lock_init (&dev_entry->userptr_spinlock);mutex_init (&dev_entry->ctx_mem_hash_mutex); - dev_entry->root =debugfs_create_dir (dev_name (hdev->dev), - hl_debug_root); - -add_files_to_device (hdev, dev_entry, dev_entry->root); -if (!hdev->asic_prop.fw_security_enabled) -add_secured_nodes (dev_entry, dev_entry->root); +return 0 ; } -void hl_debugfs_remove_device (struct hl_device *hdev) +void hl_debugfs_device_fini (struct hl_device *hdev) {struct hl_dbg_device_entry *entry = &hdev->hl_debugfs;int i; -debugfs_remove_recursive (entry->root); -mutex_destroy (&entry->ctx_mem_hash_mutex);mutex_destroy (&entry->file_mutex);
@@ -1814,6 +1805,24 @@ void hl_debugfs_remove_device(struct hl_device *hdev)kfree (entry->entry_arr); } +void hl_debugfs_add_device (struct hl_device *hdev) +{ +struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; + + dev_entry->root =debugfs_create_dir (dev_name (hdev->dev), hl_debug_root); + +add_files_to_device (hdev, dev_entry, dev_entry->root); +if (!hdev->asic_prop.fw_security_enabled) +add_secured_nodes (dev_entry, dev_entry->root); +} + +void hl_debugfs_remove_device (struct hl_device *hdev) +{ +struct hl_dbg_device_entry *entry = &hdev->hl_debugfs; + +debugfs_remove_recursive (entry->root); +} +void hl_debugfs_add_file (struct hl_fpriv *hpriv) {struct hl_dbg_device_entry *dev_entry = &hpriv->hdev->hl_debugfs;
drivers/accel/habanalabs/common/device.c +34 -28
140 lines not on this page · raw message
drivers/accel/habanalabs/common/habanalabs.h +4 -2
@@ -3292,7 +3292,7 @@ struct hl_reset_info {* @in_debug: whether the device is in a state where the profiling/tracing infrastructure * can be used. This indication is needed because in some ASICs we need to do * specific operations to enable that infrastructure. -* @cdev_sysfs_created: were char devices and sysfs nodes created. +* @cdev_sysfs_debugfs_created: were char devices and sysfs/debugfs files created. * @stop_on_err: true if engines should stop on error. * @supports_sync_stream: is sync stream supported. * @sync_stream_queue_idx: helper index for sync stream queues initialization.
@@ -3459,7 +3459,7 @@ struct hl_device {u8 init_done;u8 device_cpu_disabled;u8 in_debug; -u8 cdev_sysfs_created; +u8 cdev_sysfs_debugfs_created;u8 stop_on_err;u8 supports_sync_stream;u8 sync_stream_queue_idx;
@@ -3978,6 +3978,8 @@ void hl_handle_fw_err(struct hl_device *hdev, struct hl_info_fw_err_info *info);void hl_debugfs_init (void );void hl_debugfs_fini (void ); +int hl_debugfs_device_init (struct hl_device *hdev); +void hl_debugfs_device_fini (struct hl_device *hdev);void hl_debugfs_add_device (struct hl_device *hdev);void hl_debugfs_remove_device (struct hl_device *hdev);void hl_debugfs_add_file (struct hl_fpriv *hpriv);
Signature · 1 line
2.40.1
Oded Gabbay
maintainerPATCH 5/6 accel/habanalabs: fix a static warning - 'dubious: x & !y'
In reply to Oded GabbayFrom: Koby Elbaz <[email protected]>
Use a straight forward approach to get a conditional result.
--- drivers/accel/habanalabs/gaudi2/gaudi2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/accel/habanalabs/gaudi2/gaudi2.c +3 -3
@@ -4527,7 +4527,7 @@ static int gaudi2_set_tpc_engine_mode(struct hl_device *hdev, u32 engine_id, u32 reg_base = gaudi2_tpc_cfg_blocks_bases[tpc_id]; reg_addr = reg_base +TPC_CFG_STALL_OFFSET ; reg_val =FIELD_PREP (DCORE0_TPC0_CFG_TPC_STALL_V_MASK , - !!(engine_command ==HL_ENGINE_STALL )); + (engine_command ==HL_ENGINE_STALL ) ?1 :0 );WREG32 (reg_addr, reg_val);if (engine_command ==HL_ENGINE_RESUME ) {
@@ -4551,7 +4551,7 @@ static int gaudi2_set_mme_engine_mode(struct hl_device *hdev, u32 engine_id, u32 reg_base = gaudi2_mme_ctrl_lo_blocks_bases[mme_id]; reg_addr = reg_base +MME_CTRL_LO_QM_STALL_OFFSET ; reg_val =FIELD_PREP (DCORE0_MME_CTRL_LO_QM_STALL_V_MASK , - !!(engine_command ==HL_ENGINE_STALL )); + (engine_command ==HL_ENGINE_STALL ) ?1 :0 );WREG32 (reg_addr, reg_val);return 0 ;
@@ -4572,7 +4572,7 @@ static int gaudi2_set_edma_engine_mode(struct hl_device *hdev, u32 engine_id, u3 reg_base = gaudi2_dma_core_blocks_bases[edma_id]; reg_addr = reg_base +EDMA_CORE_CFG_STALL_OFFSET ; reg_val =FIELD_PREP (DCORE0_EDMA0_CORE_CFG_1_HALT_MASK , - !!(engine_command ==HL_ENGINE_STALL )); + (engine_command ==HL_ENGINE_STALL ) ?1 :0 );WREG32 (reg_addr, reg_val);if (engine_command ==HL_ENGINE_STALL ) {
Signature · 1 line
2.40.1
Oded Gabbay
maintainerPATCH 6/6 accel/habanalabs: always fetch pci addr_dec error info
In reply to Oded GabbayFrom: Ofir Bitton <[email protected]>
Due to missing indication of address decode source (LBW/HBW bus), we should always try and fetch extended information.
--- drivers/accel/habanalabs/gaudi2/gaudi2.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/accel/habanalabs/gaudi2/gaudi2.c +6 -8
@@ -8892,14 +8892,12 @@ static int gaudi2_print_pcie_addr_dec_info(struct hl_device *hdev, u16 event_typ "err cause: %s", gaudi2_pcie_addr_dec_error_cause[i]); error_count++; -switch (intr_cause_data &BIT_ULL (i)) { -case PCIE_WRAP_PCIE_IC_SEI_INTR_IND_AXI_LBW_ERR_INTR_MASK : -hl_check_for_glbl_errors (hdev); -break ; -case PCIE_WRAP_PCIE_IC_SEI_INTR_IND_BAD_ACCESS_INTR_MASK : -gaudi2_print_pcie_mstr_rr_mstr_if_razwi_info (hdev, event_mask); -break ; - } +/* +* Always check for LBW and HBW additional info as the indication itself is +* sometimes missing +*/ +hl_check_for_glbl_errors (hdev); +gaudi2_print_pcie_mstr_rr_mstr_if_razwi_info (hdev, event_mask); }return error_count;
Signature · 1 line
2.40.1