habanalabs: don't wait for ASIC CPU after reset
Subsystems (2)
PATCH 1/6 habanalabs: don't wait for ASIC CPU after reset
Upon reset of the ASIC, the driver would have waited for the CPU to come out of reset before finishing the reset process. This was done for the purpose of making the CPU available to answer FLR requests. However, when a VM shuts down, the driver isn't removed so a reset never happens. Therefore, remove this waiting period as we don't need it.
--- drivers/misc/habanalabs/goya/goya.c | 24 ------------------------ drivers/misc/habanalabs/goya/goyaP.h | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-)
drivers/misc/habanalabs/goya/goya.c +0 -24
@@ -2684,30 +2684,6 @@ static void goya_hw_fini(struct hl_device *hdev, bool hard_reset)HW_CAP_MMU |HW_CAP_TPC_MBIST | HW_CAP_GOLDEN | HW_CAP_TPC);memset (goya->events_stat,0 ,sizeof (goya->events_stat)); - -if (!hdev->pldm) { -int rc; -/* In case we are running inside VM and the VM is -* shutting down, we need to make sure CPU boot-loader -* is running before we can continue the VM shutdown. -* That is because the VM will send an FLR signal that -* we must answer -*/ -dev_info (hdev->dev, -"Going to wait up to %ds for CPU boot loader\n" , -GOYA_CPU_TIMEOUT_USEC /1000 /1000 ); - - rc =hl_poll_timeout ( - hdev, - mmPSOC_GLOBAL_CONF_WARM_REBOOT, - status, - (status ==CPU_BOOT_STATUS_DRAM_RDY ), -10000 , -GOYA_CPU_TIMEOUT_USEC ); -if (rc) -dev_err (hdev->dev, -"failed to wait for CPU boot loader\n" ); - } }int goya_suspend (struct hl_device *hdev)
drivers/misc/habanalabs/goya/goyaP.h +1 -1
@@ -45,7 +45,7 @@#define CORESIGHT_TIMEOUT_USEC 100000/* 100 ms */ -#define GOYA_CPU_TIMEOUT_USEC 10000000/* 10s */ +#define GOYA_CPU_TIMEOUT_USEC 15000000/* 15s */ #define TPC_ENABLED_MASK 0xFF
Signature · 1 line
2.17.1
PATCH 2/6 habanalabs: remove stop-on-error flag from DMA
From: Omer Shpigelman <[email protected]>
Stop-on-error mode in DMA is useful as it stops the transaction immediately upon error e.g. page fault.
But it may cause the next command submission to fail as is leaves the DMA in unstable state.
Therefore we remove the stop-on-error configuration from the DMA. Stop-on-err is still available for debug.
--- .../ABI/testing/debugfs-driver-habanalabs | 7 +++ drivers/misc/habanalabs/debugfs.c | 55 +++++++++++++++++++ drivers/misc/habanalabs/goya/goya.c | 6 +- drivers/misc/habanalabs/habanalabs.h | 2 + .../include/goya/asic_reg/goya_masks.h | 3 +- 5 files changed, 70 insertions(+), 3 deletions(-)
Documentation/ABI/testing/debugfs-driver-habanalabs +7 -0
@@ -150,3 +150,10 @@ KernelVersion: 5.1 Contact: [email protected] Description: Displays a list with information about all the active virtual address mappings per ASID + +What: /sys/kernel/debug/habanalabs/hl<n>/stop_on_err +Date: Mar 2020 +KernelVersion: 5.6 +Contact: [email protected] +Description: Sets the stop-on_error option for the device engines. Value of + "0" is for disable, otherwise enable.
drivers/misc/habanalabs/debugfs.c +55 -0
73 lines not on this page · raw message
drivers/misc/habanalabs/goya/goya.c +5 -1
@@ -800,6 +800,7 @@ static void goya_init_dma_qman(struct hl_device *hdev, int dma_id,u32 so_base_lo, so_base_hi;u32 gic_base_lo, gic_base_hi;u32 reg_off = dma_id * (mmDMA_QM_1_PQ_PI - mmDMA_QM_0_PQ_PI); +u32 dma_err_cfg =QMAN_DMA_ERR_MSG_EN ; mtr_base_lo =lower_32_bits (CFG_BASE + mmSYNC_MNGR_MON_PAY_ADDRL_0); mtr_base_hi =upper_32_bits (CFG_BASE + mmSYNC_MNGR_MON_PAY_ADDRL_0);
@@ -836,7 +837,10 @@ static void goya_init_dma_qman(struct hl_device *hdev, int dma_id,else WREG32 (mmDMA_QM_0_GLBL_PROT + reg_off,QMAN_DMA_FULLY_TRUSTED ); -WREG32 (mmDMA_QM_0_GLBL_ERR_CFG + reg_off,QMAN_DMA_ERR_MSG_EN ); +if (hdev->stop_on_err) + dma_err_cfg |=1 <<DMA_QM_0_GLBL_ERR_CFG_DMA_STOP_ON_ERR_SHIFT ; + +WREG32 (mmDMA_QM_0_GLBL_ERR_CFG + reg_off, dma_err_cfg);WREG32 (mmDMA_QM_0_GLBL_CFG0 + reg_off,QMAN_DMA_ENABLE ); }
drivers/misc/habanalabs/habanalabs.h +2 -0
@@ -1300,6 +1300,7 @@ struct hl_device_idle_busy_ts {* @in_debug: is device under debug. This, together with fpriv_list, enforces * that only a single user is configuring the debug infrastructure. * @cdev_sysfs_created: were char devices and sysfs nodes created. +* @stop_on_err: true if engines should stop on error. */ struct hl_device {struct pci_dev *pdev;
@@ -1380,6 +1381,7 @@ struct hl_device {u8 dma_mask;u8 in_debug;u8 cdev_sysfs_created; +u8 stop_on_err;/* Parameters for bring-up */ u8 mmu_enable;
drivers/misc/habanalabs/include/goya/asic_reg/goya_masks.h +1 -2
@@ -55,8 +55,7 @@ (1 << DMA_QM_0_GLBL_ERR_CFG_DMA_ERR_MSG_EN_SHIFT) | \ (1 << DMA_QM_0_GLBL_ERR_CFG_PQF_STOP_ON_ERR_SHIFT) | \ (1 << DMA_QM_0_GLBL_ERR_CFG_CQF_STOP_ON_ERR_SHIFT) | \ - (1 << DMA_QM_0_GLBL_ERR_CFG_CP_STOP_ON_ERR_SHIFT) | \ - (1 << DMA_QM_0_GLBL_ERR_CFG_DMA_STOP_ON_ERR_SHIFT)) + (1 << DMA_QM_0_GLBL_ERR_CFG_CP_STOP_ON_ERR_SHIFT))#define QMAN_MME_ENABLE (\ (1 << MME_QM_GLBL_CFG0_PQF_EN_SHIFT) | \
Signature · 1 line
2.17.1
PATCH 3/6 habanalabs: re-factor H/W queues initialization
In reply to Oded GabbayFrom: Omer Shpigelman <[email protected]>
We want to remove the following restrictions/assumptions in our driver:
1. The H/W queue index is also the completion queue index.
2. The H/W queue index is also the IRQ number of the completion queue.
3. All queues of the same type have consecutive indexes.
Therefore we add the support for H/W queues of the same type with nonconsecutive indexes and completion queue index and IRQ number different than the H/W queue index.
--- drivers/misc/habanalabs/device.c | 17 +++++++++-------- drivers/misc/habanalabs/goya/goya.c | 9 ++++++++- drivers/misc/habanalabs/goya/goyaP.h | 1 + drivers/misc/habanalabs/habanalabs.h | 6 ++++++ drivers/misc/habanalabs/hw_queue.c | 10 +++++----- 5 files changed, 29 insertions(+), 14 deletions(-)
drivers/misc/habanalabs/device.c +9 -8
@@ -1062,7 +1062,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,*/ int hl_device_init (struct hl_device *hdev,struct class *hclass) { -int i, rc, cq_ready_cnt; +int i, rc, cq_cnt, cq_ready_cnt;char *name;bool add_cdev_sysfs_on_err = false;
@@ -1120,14 +1120,16 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass) goto sw_fini; } + cq_cnt = hdev->asic_prop.completion_queues_count; +/* * Initialize the completion queues. Must be done before hw_init, * because there the addresses of the completion queues are being * passed as arguments to request_irq */ - hdev->completion_queue = -kcalloc (hdev->asic_prop.completion_queues_count, -sizeof (*hdev->completion_queue),GFP_KERNEL ); + hdev->completion_queue =kcalloc (cq_cnt, +sizeof (*hdev->completion_queue), +GFP_KERNEL );if (!hdev->completion_queue) {dev_err (hdev->dev,"failed to allocate completion queues\n" );
@@ -1135,10 +1137,9 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass) goto hw_queues_destroy; } -for (i =0 , cq_ready_cnt =0 ; - i < hdev->asic_prop.completion_queues_count; - i++, cq_ready_cnt++) { - rc =hl_cq_init (hdev, &hdev->completion_queue[i], i); +for (i =0 , cq_ready_cnt =0 ; i < cq_cnt ; i++, cq_ready_cnt++) { + rc =hl_cq_init (hdev, &hdev->completion_queue[i], + hdev->asic_funcs->get_queue_id_for_cq (hdev, i));if (rc) {dev_err (hdev->dev,"failed to initialize completion queue\n" );
drivers/misc/habanalabs/goya/goya.c +8 -1
@@ -890,6 +890,7 @@ void goya_init_dma_qmans(struct hl_device *hdev) q = &hdev->kernel_queues[0 ];for (i =0 ; i <NUMBER_OF_EXT_HW_QUEUES ; i++, q++) { + q->cq_id = q->msi_vec = i;goya_init_dma_qman (hdev, i, q->bus_address);goya_init_dma_ch (hdev, i); }
@@ -5273,6 +5274,11 @@ static enum hl_device_hw_state goya_get_hw_state(struct hl_device *hdev)return RREG32 (mmHW_STATE); } +u32 goya_get_queue_id_for_cq (struct hl_device *hdev,u32 cq_idx) +{ +return cq_idx; +} +static const struct hl_asic_funcs goya_funcs = { .early_init = goya_early_init, .early_fini = goya_early_fini,
@@ -5332,7 +5338,8 @@ static const struct hl_asic_funcs goya_funcs = { .rreg = hl_rreg, .wreg = hl_wreg, .halt_coresight = goya_halt_coresight, - .get_clk_rate = goya_get_clk_rate + .get_clk_rate = goya_get_clk_rate, + .get_queue_id_for_cq = goya_get_queue_id_for_cq };/*
drivers/misc/habanalabs/goya/goyaP.h +1 -0
@@ -234,5 +234,6 @@ void goya_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size,void goya_mmu_remove_device_cpu_mappings (struct hl_device *hdev);int goya_get_clk_rate (struct hl_device *hdev,u32 *cur_clk,u32 *max_clk); +u32 goya_get_queue_id_for_cq (struct hl_device *hdev,u32 cq_idx);#endif /* GOYAP_H_ */
drivers/misc/habanalabs/habanalabs.h +6 -0
@@ -365,6 +365,8 @@ struct hl_cs_job;* @pi: holds the queue's pi value. * @ci: holds the queue's ci value, AS CALCULATED BY THE DRIVER (not real ci). * @hw_queue_id: the id of the H/W queue. +* @cq_id: the id for the corresponding CQ for this H/W queue. +* @msi_vec: the IRQ number of the H/W queue. * @int_queue_len: length of internal queue (number of entries). * @valid: is the queue valid (we have array of 32 queues, not all of them * exists).
@@ -377,6 +379,8 @@ struct hl_hw_queue {u32 pi;u32 ci;u32 hw_queue_id; +u32 cq_id; +u32 msi_vec;u16 int_queue_len;u8 valid; };
@@ -534,6 +538,7 @@ enum hl_pll_frequency {* @wreg: Write a register. Needed for simulator support. * @halt_coresight: stop the ETF and ETR traces. * @get_clk_rate: Retrieve the ASIC current and maximum clock rate in MHz +* @get_queue_id_for_cq: Get the H/W queue id related to the given CQ index. */ struct hl_asic_funcs {int (*early_init)(struct hl_device *hdev);
@@ -620,6 +625,7 @@ struct hl_asic_funcs {void (*wreg)(struct hl_device *hdev,u32 reg,u32 val);void (*halt_coresight)(struct hl_device *hdev);int (*get_clk_rate)(struct hl_device *hdev,u32 *cur_clk,u32 *max_clk); +u32 (*get_queue_id_for_cq)(struct hl_device *hdev,u32 cq_idx); };
drivers/misc/habanalabs/hw_queue.c +5 -5
@@ -111,7 +111,7 @@ static int ext_queue_sanity_checks(struct hl_device *hdev, bool reserve_cq_entry) {atomic_t *free_slots = - &hdev->completion_queue[q->hw_queue_id].free_slots_cnt; + &hdev->completion_queue[q->cq_id].free_slots_cnt;int free_slots_cnt;/* Check we have enough space in the queue */
@@ -194,7 +194,7 @@ static int hw_queue_sanity_checks(struct hl_device *hdev, struct hl_hw_queue *q, int num_of_entries) {atomic_t *free_slots = - &hdev->completion_queue[q->hw_queue_id].free_slots_cnt; + &hdev->completion_queue[q->cq_id].free_slots_cnt;/* * Check we have enough space in the completion queue.
@@ -308,13 +308,13 @@ static void ext_queue_schedule_job(struct hl_cs_job *job)* No need to check if CQ is full because it was already * checked in ext_queue_sanity_checks */ - cq = &hdev->completion_queue[q->hw_queue_id]; + cq = &hdev->completion_queue[q->cq_id]; cq_addr = cq->bus_address + cq->pi *sizeof (struct hl_cq_entry ); hdev->asic_funcs->add_end_of_cb_packets (hdev, cb->kernel_address, len, cq_addr,le32_to_cpu (cq_pkt.data), - q->hw_queue_id); + q->msi_vec); q->shadow_queue[hl_pi_2_offset (q->pi)] = job;
@@ -401,7 +401,7 @@ static void hw_queue_schedule_job(struct hl_cs_job *job)* No need to check if CQ is full because it was already * checked in hw_queue_sanity_checks */ - cq = &hdev->completion_queue[q->hw_queue_id]; + cq = &hdev->completion_queue[q->cq_id]; cq->pi =hl_cq_inc_ptr (cq->pi);ext_and_hw_queue_submit_bd (hdev, q, ctl, len, ptr);
Signature · 1 line
2.17.1
PATCH 5/6 habanalabs: print warning when reset is requested
In reply to Oded GabbayWhen the system administrator asks the driver to soft or hard reset the device through sysfs, the driver should display a warning in the kernel log to explain why it suddenly resets the device.
--- drivers/misc/habanalabs/sysfs.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/misc/habanalabs/sysfs.c +4 -0
@@ -183,6 +183,8 @@ static ssize_t soft_reset_store(struct device *dev, goto out; } +dev_warn (hdev->dev,"Soft-Reset requested through sysfs\n" ); +hl_device_reset (hdev, false, false); out:
@@ -204,6 +206,8 @@ static ssize_t hard_reset_store(struct device *dev, goto out; } +dev_warn (hdev->dev,"Hard-Reset requested through sysfs\n" ); +hl_device_reset (hdev, true, false); out:
Signature · 1 line
2.17.1
PATCH 6/6 habanalabs: increase timeout during reset
In reply to Oded GabbayWhen doing training, the DL framework (e.g. tensorflow) performs hundreds of thousands of memory allocations and mappings. In case the driver needs to perform hard-reset during training, the driver kills the application and unmaps all those memory allocations. Unfortunately, because of that large amount of mappings, the driver isn't able to do that in the current timeout (5 seconds). Therefore, increase the timeout significantly to 30 seconds to avoid situation where the driver resets the device with active mappings, which sometime can cause a kernel bug.
BTW, it doesn't mean we will spend all the 30 seconds because the reset thread checks every one second if the unmap operation is done.
--- drivers/misc/habanalabs/habanalabs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/habanalabs.h +1 -1
@@ -23,7 +23,7 @@#define HL_MMAP_CB_MASK (0x8000000000000000ull >> PAGE_SHIFT) -#define HL_PENDING_RESET_PER_SEC 5 +#define HL_PENDING_RESET_PER_SEC 30#define HL_DEVICE_TIMEOUT_USEC 1000000/* 1 s */
Signature · 1 line
2.17.1
PATCH 4/6 habanalabs: unify and improve device cpu init
In reply to Oded GabbayMove the code of device CPU initialization from being ASIC-Dependent to common code. In addition, add support for the new error reporting feature of the firmware boot code.
--- drivers/misc/habanalabs/firmware_if.c | 188 ++++++++++++++++++- drivers/misc/habanalabs/goya/goya.c | 116 ++---------- drivers/misc/habanalabs/goya/goyaP.h | 5 - drivers/misc/habanalabs/habanalabs.h | 21 ++- drivers/misc/habanalabs/include/hl_boot_if.h | 3 +- 5 files changed, 220 insertions(+), 113 deletions(-)
drivers/misc/habanalabs/firmware_if.c +186 -2
@@ -6,20 +6,21 @@*/ #include "habanalabs.h" +#include "include/hl_boot_if.h" #include <linux/firmware.h> #include <linux/genalloc.h> #include <linux/io-64-nonatomic-lo-hi.h> /** -* hl_fw_push_fw_to_device() - Push FW code to device. +* hl_fw_load_fw_to_device() - Load F/W code to device's memory. * @hdev: pointer to hl_device structure. * * Copy fw code from firmware file to device memory. * * Return: 0 on success, non-zero for failure. */ -int hl_fw_push_fw_to_device (struct hl_device *hdev,const char *fw_name, +int hl_fw_load_fw_to_device (struct hl_device *hdev,const char *fw_name,void __iomem *dst) {const struct firmware *fw;
@@ -286,3 +287,186 @@ int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size)return rc; } + +static void fw_read_errors (struct hl_device *hdev,u32 boot_err0_reg) +{ +u32 err_val; + +/* Some of the firmware status codes are deprecated in newer f/w +* versions. In those versions, the errors are reported +* in different registers. Therefore, we need to check those +* registers and print the exact errors. Moreover, there +* may be multiple errors, so we need to report on each error +* separately. Some of the error codes might indicate a state +* that is not an error per-se, but it is an error in production +* environment +*/ + err_val =RREG32 (boot_err0_reg); +if (!(err_val &CPU_BOOT_ERR0_ENABLED )) +return ; + +if (err_val &CPU_BOOT_ERR0_DRAM_INIT_FAIL ) +dev_err (hdev->dev, +"Device boot error - DRAM initialization failed\n" ); +if (err_val &CPU_BOOT_ERR0_FIT_CORRUPTED ) +dev_err (hdev->dev,"Device boot error - FIT image corrupted\n" ); +if (err_val &CPU_BOOT_ERR0_TS_INIT_FAIL ) +dev_err (hdev->dev, +"Device boot error - Thermal Sensor initialization failed\n" ); +if (err_val &CPU_BOOT_ERR0_DRAM_SKIPPED ) +dev_warn (hdev->dev, +"Device boot warning - Skipped DRAM initialization\n" ); +if (err_val &CPU_BOOT_ERR0_BMC_WAIT_SKIPPED ) +dev_warn (hdev->dev, +"Device boot error - Skipped waiting for BMC\n" ); +if (err_val &CPU_BOOT_ERR0_NIC_DATA_NOT_RDY ) +dev_err (hdev->dev, +"Device boot error - Serdes data from BMC not available\n" ); +if (err_val &CPU_BOOT_ERR0_NIC_FW_FAIL ) +dev_err (hdev->dev, +"Device boot error - NIC F/W initialization failed\n" ); +} + +int hl_fw_init_cpu (struct hl_device *hdev,u32 cpu_boot_status_reg, +u32 msg_to_cpu_reg,u32 boot_err0_reg,bool skip_bmc, +u32 cpu_timeout) +{ +u32 status; +int rc; + +dev_info (hdev->dev,"Going to wait for device boot (up to %lds)\n" , + cpu_timeout /USEC_PER_SEC ); + +/* Make sure CPU boot-loader is running */ + rc =hl_poll_timeout ( + hdev, + cpu_boot_status_reg, + status, + (status ==CPU_BOOT_STATUS_DRAM_RDY ) || + (status ==CPU_BOOT_STATUS_NIC_FW_RDY ) || + (status ==CPU_BOOT_STATUS_READY_TO_BOOT ) || + (status ==CPU_BOOT_STATUS_SRAM_AVAIL ), +10000 , + cpu_timeout); + +/* Read U-Boot, preboot versions now in case we will later fail */ + hdev->asic_funcs->read_device_fw_version (hdev,FW_COMP_UBOOT ); + hdev->asic_funcs->read_device_fw_version (hdev,FW_COMP_PREBOOT ); + +/* Some of the status codes below are deprecated in newer f/w +* versions but we keep them here for backward compatibility +*/ +if (rc) { +switch (status) { +case CPU_BOOT_STATUS_NA : +dev_err (hdev->dev, +"Device boot error - BTL did NOT run\n" ); +break ; +case CPU_BOOT_STATUS_IN_WFE : +dev_err (hdev->dev, +"Device boot error - Stuck inside WFE loop\n" ); +break ; +case CPU_BOOT_STATUS_IN_BTL : +dev_err (hdev->dev, +"Device boot error - Stuck in BTL\n" ); +break ; +case CPU_BOOT_STATUS_IN_PREBOOT : +dev_err (hdev->dev, +"Device boot error - Stuck in Preboot\n" ); +break ; +case CPU_BOOT_STATUS_IN_SPL : +dev_err (hdev->dev, +"Device boot error - Stuck in SPL\n" ); +break ; +case CPU_BOOT_STATUS_IN_UBOOT : +dev_err (hdev->dev, +"Device boot error - Stuck in u-boot\n" ); +break ; +case CPU_BOOT_STATUS_DRAM_INIT_FAIL : +dev_err (hdev->dev, +"Device boot error - DRAM initialization failed\n" ); +break ; +case CPU_BOOT_STATUS_UBOOT_NOT_READY : +dev_err (hdev->dev, +"Device boot error - u-boot stopped by user\n" ); +break ; +case CPU_BOOT_STATUS_TS_INIT_FAIL : +dev_err (hdev->dev, +"Device boot error - Thermal Sensor initialization failed\n" ); +break ; +default : +dev_err (hdev->dev, +"Device boot error - Invalid status code\n" ); +break ; + } + + rc = -EIO ; + goto out; + } + +if (!hdev->fw_loading) { +dev_info (hdev->dev,"Skip loading FW\n" ); + goto out; + } + +if (status ==CPU_BOOT_STATUS_SRAM_AVAIL ) + goto out; + +dev_info (hdev->dev, +"Loading firmware to device, may take some time...\n" ); + + rc = hdev->asic_funcs->load_firmware_to_device (hdev); +if (rc) + goto out; + +if (skip_bmc) { +WREG32 (msg_to_cpu_reg,KMD_MSG_SKIP_BMC ); + + rc =hl_poll_timeout ( + hdev, + cpu_boot_status_reg, + status, + (status ==CPU_BOOT_STATUS_BMC_WAITING_SKIPPED ), +10000 , + cpu_timeout); + +if (rc) { +dev_err (hdev->dev, +"Failed to get ACK on skipping BMC, %d\n" , + status); +WREG32 (msg_to_cpu_reg,KMD_MSG_NA ); + rc = -EIO ; + goto out; + } + } + +WREG32 (msg_to_cpu_reg,KMD_MSG_FIT_RDY ); + + rc =hl_poll_timeout ( + hdev, + cpu_boot_status_reg, + status, + (status ==CPU_BOOT_STATUS_SRAM_AVAIL ), +10000 , + cpu_timeout); + +if (rc) { +if (status ==CPU_BOOT_STATUS_FIT_CORRUPTED ) +dev_err (hdev->dev, +"Device reports FIT image is corrupted\n" ); +else +dev_err (hdev->dev, +"Device failed to load, %d\n" , status); + +WREG32 (msg_to_cpu_reg,KMD_MSG_NA ); + rc = -EIO ; + goto out; + } + +dev_info (hdev->dev,"Successfully loaded firmware to device\n" ); + +out: +fw_read_errors (hdev, boot_err0_reg); + +return rc; +}
drivers/misc/habanalabs/goya/goya.c +12 -104
170 lines not on this page · raw message
drivers/misc/habanalabs/goya/goyaP.h +0 -5
@@ -149,11 +149,6 @@#define HW_CAP_GOLDEN 0x00000400#define HW_CAP_TPC 0x00000800 -enum goya_fw_component { -FW_COMP_UBOOT , -FW_COMP_PREBOOT -}; -struct goya_device {/* TODO: remove hw_queues_lock after moving to scheduler code */ spinlock_t hw_queues_lock;
drivers/misc/habanalabs/habanalabs.h +20 -1
@@ -75,6 +75,16 @@ struct pgt_info {struct hl_device ;struct hl_fpriv ; +/** +* enum hl_fw_component - F/W components to read version through registers. +* @FW_COMP_UBOOT: u-boot. +* @FW_COMP_PREBOOT: preboot. +*/ +enum hl_fw_component { +FW_COMP_UBOOT , +FW_COMP_PREBOOT +}; +/** * enum hl_queue_type - Supported QUEUE types. * @QUEUE_TYPE_NA: queue is not available.
@@ -539,6 +549,9 @@ enum hl_pll_frequency {* @halt_coresight: stop the ETF and ETR traces. * @get_clk_rate: Retrieve the ASIC current and maximum clock rate in MHz * @get_queue_id_for_cq: Get the H/W queue id related to the given CQ index. +* @read_device_fw_version: read the device's firmware versions that are +* contained in registers +* @load_firmware_to_device: load the firmware to the device's memory */ struct hl_asic_funcs {int (*early_init)(struct hl_device *hdev);
@@ -626,6 +639,9 @@ struct hl_asic_funcs {void (*halt_coresight)(struct hl_device *hdev);int (*get_clk_rate)(struct hl_device *hdev,u32 *cur_clk,u32 *max_clk);u32 (*get_queue_id_for_cq)(struct hl_device *hdev,u32 cq_idx); +void (*read_device_fw_version)(struct hl_device *hdev, +enum hl_fw_component fwc); +int (*load_firmware_to_device)(struct hl_device *hdev); };
@@ -1591,7 +1607,7 @@ int hl_mmu_unmap(struct hl_ctx *ctx, u64 virt_addr, u32 page_size,void hl_mmu_swap_out (struct hl_ctx *ctx);void hl_mmu_swap_in (struct hl_ctx *ctx); -int hl_fw_push_fw_to_device (struct hl_device *hdev,const char *fw_name, +int hl_fw_load_fw_to_device (struct hl_device *hdev,const char *fw_name,void __iomem *dst);int hl_fw_send_pci_access_msg (struct hl_device *hdev,u32 opcode); int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
@@ -1604,6 +1620,9 @@ void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size,int hl_fw_send_heartbeat (struct hl_device *hdev);int hl_fw_armcp_info_get (struct hl_device *hdev);int hl_fw_get_eeprom_data (struct hl_device *hdev,void *data,size_t max_size); +int hl_fw_init_cpu (struct hl_device *hdev,u32 cpu_boot_status_reg, +u32 msg_to_cpu_reg,u32 boot_err0_reg,bool skip_bmc, +u32 cpu_timeout);int hl_pci_bars_map (struct hl_device *hdev,const char *const name[3 ],bool is_wc[3 ]);
drivers/misc/habanalabs/include/hl_boot_if.h +2 -1
@@ -42,7 +42,8 @@ enum cpu_boot_status {enum kmd_msg {KMD_MSG_NA =0 ,KMD_MSG_GOTO_WFE , -KMD_MSG_FIT_RDY +KMD_MSG_FIT_RDY , +KMD_MSG_SKIP_BMC , };#endif /* HL_BOOT_IF_H */
Signature · 1 line
2.17.1
Quoted 7 lines · Oded Gabbay
Upon reset of the ASIC, the driver would have waited for the CPU to come out of reset before finishing the reset process. This was done for the purpose of making the CPU available to answer FLR requests. However, when a VM shuts down, the driver isn't removed so a reset never happens. Therefore, remove this waiting period as we don't need it.
Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 4/6] habanalabs: unify and improve device cpu init
In reply to Oded GabbayQuoted 5 lines · Oded Gabbay
Move the code of device CPU initialization from being ASIC-Dependent to common code. In addition, add support for the new error reporting feature of the firmware boot code.
Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 5/6] habanalabs: print warning when reset is requested
In reply to Oded GabbayQuoted 5 lines · Oded Gabbay
When the system administrator asks the driver to soft or hard reset the device through sysfs, the driver should display a warning in the kernel log to explain why it suddenly resets the device.
Signed-off-by Oded Gabbay <[email protected]>
RE: [PATCH 6/6] habanalabs: increase timeout during reset
In reply to Oded GabbayQuoted 9 lines · Oded Gabbay
When doing training, the DL framework (e.g. tensorflow) performs hundreds of thousands of memory allocations and mappings. In case the driver needs to perform hard-reset during training, the driver kills the application and unmaps all those memory allocations. Unfortunately, because of that large amount of mappings, the driver isn't able to do that in the current timeout (5 seconds). Therefore, increase the timeout significantly to 30 seconds to avoid situation where the driver resets the device with active mappings, which sometime can cause a kernel bug.
Quoted 4 lines
BTW, it doesn't mean we will spend all the 30 seconds because the reset thread checks every one second if the unmap operation is done.
Signed-off-by Oded Gabbay <[email protected]>