habanalabs: ignore device unusable status
PATCH 1/4 habanalabs: ignore device unusable status
Some users might want to implement their own policy of when the device is unusable so we need to ignore this status in the driver and continue loading as normal.
--- drivers/misc/habanalabs/common/firmware_if.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/misc/habanalabs/common/firmware_if.c +3 -3
@@ -441,9 +441,9 @@ static int fw_read_errors(struct hl_device *hdev, u32 boot_err0_reg, }if (err_val &CPU_BOOT_ERR0_DEVICE_UNUSABLE_FAIL ) { -dev_err (hdev->dev, -"Device boot error - device unusable\n" ); - err_exists = true; +/* Ignore this bit, don't prevent driver loading */ +dev_dbg (hdev->dev,"device unusable status is set\n" ); + err_val &= ~CPU_BOOT_ERR0_DEVICE_UNUSABLE_FAIL ; } security_val =RREG32 (cpu_security_boot_status_reg);
Signature · 1 line
2.25.1
PATCH 2/4 habanalabs: add missing space after casting
From: Omer Shpigelman <[email protected]>
Change casting code according to kernel coding style.
--- drivers/misc/habanalabs/common/habanalabs_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/common/habanalabs_ioctl.c +1 -1
@@ -95,7 +95,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args) hw_ip.first_available_interrupt_id = prop->first_available_user_msix_interrupt;return copy_to_user (out, &hw_ip, -min ((size_t )size,sizeof (hw_ip))) ? -EFAULT :0 ; +min ((size_t ) size,sizeof (hw_ip))) ? -EFAULT :0 ; } static int hw_events_info(struct hl_device *hdev, bool aggregate,
Signature · 1 line
2.25.1
PATCH 3/4 habanalabs: better error print for pin failure
In reply to Oded GabbayPrint the user given pointer and error code on failure to get user pages for easier debugging.
--- drivers/misc/habanalabs/common/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/habanalabs/common/memory.c +2 -1
@@ -1612,7 +1612,8 @@ static int get_user_memory(struct hl_device *hdev, u64 addr, u64 size,if (rc != npages) {dev_err (hdev->dev, -"Failed to map host memory, user ptr probably wrong\n" ); +"Failed (%d) to pin host memory with user ptr 0x%llx\n" , + rc, addr);if (rc <0 ) goto destroy_pages; npages = rc;
Signature · 1 line
2.25.1
PATCH 4/4 habanalabs: set dma mask from fw once fw done iatu config
In reply to Oded GabbayFrom: Ohad Sharabi <[email protected]>
When setting "DMA mask from FW" we are reading PSOC_GLOBAL_CONF register which is allowed only once FW has done it's iATU configuration.
--- drivers/misc/habanalabs/common/pci/pci.c | 10 ++++++---- drivers/misc/habanalabs/gaudi/gaudi.c | 4 +--- drivers/misc/habanalabs/goya/goya.c | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-)
drivers/misc/habanalabs/common/pci/pci.c +6 -4
@@ -421,6 +421,12 @@ int hl_pci_init(struct hl_device *hdev) goto unmap_pci_bars; } +/* Driver must sleep in order for FW to finish the iATU configuration */ +if (hdev->asic_prop.iatu_done_by_fw) { +usleep_range (2000 ,3000 ); + hdev->asic_funcs->set_dma_mask_from_fw (hdev); + } + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (hdev->dma_mask));if (rc) {
@@ -430,10 +436,6 @@ int hl_pci_init(struct hl_device *hdev) goto unmap_pci_bars; } -/* Driver must sleep in order for FW to finish the iATU configuration */ -if (hdev->asic_prop.iatu_done_by_fw) -usleep_range (2000 ,3000 ); -return 0 ; unmap_pci_bars:
drivers/misc/habanalabs/gaudi/gaudi.c +1 -3
@@ -600,10 +600,8 @@ static int gaudi_init_iatu(struct hl_device *hdev)struct hl_outbound_pci_region outbound_region;int rc; -if (hdev->asic_prop.iatu_done_by_fw) { - hdev->asic_funcs->set_dma_mask_from_fw (hdev); +if (hdev->asic_prop.iatu_done_by_fw)return 0 ; - }/* Inbound Region 0 - Bar 0 - Point to SRAM + CFG */ inbound_region.mode =PCI_BAR_MATCH_MODE ;
drivers/misc/habanalabs/goya/goya.c +1 -3
@@ -532,10 +532,8 @@ static int goya_init_iatu(struct hl_device *hdev)struct hl_outbound_pci_region outbound_region;int rc; -if (hdev->asic_prop.iatu_done_by_fw) { - hdev->asic_funcs->set_dma_mask_from_fw (hdev); +if (hdev->asic_prop.iatu_done_by_fw)return 0 ; - }/* Inbound Region 0 - Bar 0 - Point to SRAM and CFG */ inbound_region.mode =PCI_BAR_MATCH_MODE ;
Signature · 1 line
2.25.1