habanalabs: add cdev index data member
PATCH 1/5 habanalabs: add cdev index data member
From: Omer Shpigelman <[email protected]>
Instead of recalculating the cdev index, store it in a dedicated data member. This data member is intended to be passed to other drivers using the auxiliary bus infra and hence this new data member is necessary in case that the calculation is changed in the future.
--- drivers/misc/habanalabs/common/device.c | 10 ++++++---- drivers/misc/habanalabs/common/habanalabs.h | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-)
drivers/misc/habanalabs/common/device.c +6 -4
@@ -1730,7 +1730,9 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)char *name;bool add_cdev_sysfs_on_err = false; - name =kasprintf (GFP_KERNEL ,"hl%d" , hdev->id /2 ); + hdev->cdev_idx = hdev->id /2 ; + + name =kasprintf (GFP_KERNEL ,"hl%d" , hdev->cdev_idx);if (!name) { rc = -ENOMEM ; goto out_disabled;
@@ -1745,7 +1747,7 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)if (rc) goto out_disabled; - name =kasprintf (GFP_KERNEL ,"hl_controlD%d" , hdev->id /2 ); + name =kasprintf (GFP_KERNEL ,"hl_controlD%d" , hdev->cdev_idx);if (!name) { rc = -ENOMEM ; goto free_dev;
@@ -2023,10 +2025,10 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)if (hdev->pdev)dev_err (&hdev->pdev->dev,"Failed to initialize hl%d. Device is NOT usable !\n" , - hdev->id /2 ); + hdev->cdev_idx);else pr_err ("Failed to initialize hl%d. Device is NOT usable !\n" , - hdev->id /2 ); + hdev->cdev_idx);return rc; }
drivers/misc/habanalabs/common/habanalabs.h +3 -1
@@ -3129,7 +3129,8 @@ struct hl_reset_info {* @edma_binning: contains mask of edma engines that is received from the f/w which * indicates which edma engines are binned-out * @id: device minor. -* @id_control: minor of the control device +* @id_control: minor of the control device. +* @cdev_idx: char device index. Used for setting its name. * @cpu_pci_msb_addr: 50-bit extension bits for the device CPU's 40-bit * addresses. * @is_in_dram_scrub: true if dram scrub operation is on going.
@@ -3289,6 +3290,7 @@ struct hl_device {u32 edma_binning;u16 id;u16 id_control; +u16 cdev_idx;u16 cpu_pci_msb_addr;u8 is_in_dram_scrub;u8 disabled;
Signature · 1 line
2.25.1
PATCH 2/5 habanalabs: select FW_LOADER in Kconfig
The driver is loading firmware to the device and we use the firmware loading functions from the FW_LOADER module.
--- drivers/misc/habanalabs/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/misc/habanalabs/Kconfig +1 -0
@@ -10,6 +10,7 @@ config HABANA_AI select HWMON select DMA_SHARED_BUFFER select CRC32 + select FW_LOADER help Enables PCIe card driver for Habana's AI Processors (AIP) that are designed to accelerate Deep Learning inference and training workloads.
Signature · 1 line
2.25.1
PATCH 3/5 habanalabs: if map page fails don't try to unmap it
In reply to Oded GabbayFrom: Dafna Hirschfeld <[email protected]>
The original code tried to unmap a page that was not mapped as part of the map page error path.
--- drivers/misc/habanalabs/common/mmu/mmu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/habanalabs/common/mmu/mmu.c +2 -0
@@ -403,6 +403,8 @@ int hl_mmu_map_contiguous(struct hl_ctx *ctx, u64 virt_addr,dev_err (hdev->dev,"Map failed for va 0x%llx to pa 0x%llx\n" , curr_va, curr_pa); +/* last mapping failed so don't try to unmap it - reduce off by page_size */ + off -= page_size; goto unmap; } }
Signature · 1 line
2.25.1
PATCH 4/5 habanalabs: fix calculation of DRAM base address in PCIe BAR
In reply to Oded GabbayFrom: Tomer Tayar <[email protected]>
The calculation of the device DRAM base address before setting the relevant PCIe BAR to point at it, has an assumption that this BAR is used to access only the DRAM, and thus the covered DRAM size is a power of 2.
In future ASICs it is not necessarily true, so need to update the calculation to support also a non-power-of-2 size.
--- drivers/misc/habanalabs/common/device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/misc/habanalabs/common/device.c +5 -1
@@ -42,7 +42,11 @@ static uint64_t hl_set_dram_bar(struct hl_device *hdev, u64 addr)struct asic_fixed_properties *prop = &hdev->asic_prop;u64 bar_base_addr; - bar_base_addr = addr & ~(prop->dram_pci_bar_size -0x1ull ); +if (is_power_of_2 (prop->dram_pci_bar_size)) + bar_base_addr = addr & ~(prop->dram_pci_bar_size -0x1ull ); +else + bar_base_addr =DIV_ROUND_DOWN_ULL (addr, prop->dram_pci_bar_size) * + prop->dram_pci_bar_size;return hdev->asic_funcs->set_dram_bar_base (hdev, bar_base_addr); }
Signature · 1 line
2.25.1
PATCH 5/5 habanalabs/gaudi2: assigning PQFs for ARC f/w in PDMA
In reply to Oded GabbayFrom: Rajarama Manjukody Bhat <[email protected]>
Assigning 3 PQFs in PDMA1 and 2 PQFs in PDMA0 for ARC firmware usage.
--- drivers/misc/habanalabs/gaudi2/gaudi2.c | 13 +++++++++---- drivers/misc/habanalabs/gaudi2/gaudi2_masks.h | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-)
drivers/misc/habanalabs/gaudi2/gaudi2.c +9 -4
@@ -4175,11 +4175,15 @@ static void gaudi2_init_qman_common(struct hl_device *hdev, u32 reg_base,WREG32 (reg_base +QM_GLBL_CFG2_OFFSET ,0 );/* Enable the QMAN channel. -* PDMA1 QMAN configuration is different, as we do not allow user to -* access CP2/3, it is reserved for the ARC usage. +* PDMA QMAN configuration is different, as we do not allow user to +* access some of the CPs. +* PDMA0: CP2/3 are reserved for the ARC usage. +* PDMA1: CP1/2/3 are reserved for the ARC usage. */ if (reg_base == gaudi2_qm_blocks_bases[GAUDI2_QUEUE_ID_PDMA_1_0 ])WREG32 (reg_base +QM_GLBL_CFG0_OFFSET ,PDMA1_QMAN_ENABLE ); +else if (reg_base == gaudi2_qm_blocks_bases[GAUDI2_QUEUE_ID_PDMA_0_0 ]) +WREG32 (reg_base +QM_GLBL_CFG0_OFFSET ,PDMA0_QMAN_ENABLE );else WREG32 (reg_base +QM_GLBL_CFG0_OFFSET ,QMAN_ENABLE ); }
@@ -5580,10 +5584,11 @@ static bool gaudi2_is_queue_enabled(struct hl_device *hdev, u32 hw_queue_id)u64 hw_test_cap_bit =0 ;switch (hw_queue_id) { - case GAUDI2_QUEUE_ID_PDMA_0_0 ... GAUDI2_QUEUE_ID_PDMA_1_1: +case GAUDI2_QUEUE_ID_PDMA_0_0 : +case GAUDI2_QUEUE_ID_PDMA_0_1 : +case GAUDI2_QUEUE_ID_PDMA_1_0 : hw_cap_mask =HW_CAP_PDMA_MASK ;break ; - case GAUDI2_QUEUE_ID_DCORE0_EDMA_0_0...GAUDI2_QUEUE_ID_DCORE0_EDMA_1_3: hw_test_cap_bit =HW_CAP_EDMA_SHIFT + ((hw_queue_id -GAUDI2_QUEUE_ID_DCORE0_EDMA_0_0 ) >>2 );
drivers/misc/habanalabs/gaudi2/gaudi2_masks.h +7 -1
@@ -51,12 +51,18 @@ (0x1F << PDMA0_QM_GLBL_CFG0_CP_EN_SHIFT) | \ (0x1 << PDMA0_QM_GLBL_CFG0_ARC_CQF_EN_SHIFT)) -#define PDMA1_QMAN_ENABLE \ +#define PDMA0_QMAN_ENABLE \ ((0x3 << PDMA0_QM_GLBL_CFG0_PQF_EN_SHIFT) | \ (0x1F << PDMA0_QM_GLBL_CFG0_CQF_EN_SHIFT) | \ (0x1F << PDMA0_QM_GLBL_CFG0_CP_EN_SHIFT) | \ (0x1 << PDMA0_QM_GLBL_CFG0_ARC_CQF_EN_SHIFT)) +#define PDMA1_QMAN_ENABLE \ + ((0x1 << PDMA0_QM_GLBL_CFG0_PQF_EN_SHIFT) | \ + (0x1F << PDMA0_QM_GLBL_CFG0_CQF_EN_SHIFT) | \ + (0x1F << PDMA0_QM_GLBL_CFG0_CP_EN_SHIFT) | \ + (0x1 << PDMA0_QM_GLBL_CFG0_ARC_CQF_EN_SHIFT)) +/* QM_IDLE_MASK is valid for all engines QM idle check */ #define QM_IDLE_MASK (DCORE0_EDMA0_QM_GLBL_STS0_PQF_IDLE_MASK | \ DCORE0_EDMA0_QM_GLBL_STS0_CQF_IDLE_MASK | \
Signature · 1 line
2.25.1