Commit 273190d4 authored by Omer Shpigelman's avatar Omer Shpigelman Committed by Oded Gabbay

habanalabs: add cdev index data member

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.
Signed-off-by: default avatarOmer Shpigelman <oshpigelman@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 78da23cb
...@@ -1730,7 +1730,9 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass) ...@@ -1730,7 +1730,9 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)
char *name; char *name;
bool add_cdev_sysfs_on_err = false; 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) { if (!name) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_disabled; goto out_disabled;
...@@ -1745,7 +1747,7 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass) ...@@ -1745,7 +1747,7 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)
if (rc) if (rc)
goto out_disabled; 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) { if (!name) {
rc = -ENOMEM; rc = -ENOMEM;
goto free_dev; goto free_dev;
...@@ -2023,10 +2025,10 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass) ...@@ -2023,10 +2025,10 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)
if (hdev->pdev) if (hdev->pdev)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"Failed to initialize hl%d. Device is NOT usable !\n", "Failed to initialize hl%d. Device is NOT usable !\n",
hdev->id / 2); hdev->cdev_idx);
else else
pr_err("Failed to initialize hl%d. Device is NOT usable !\n", pr_err("Failed to initialize hl%d. Device is NOT usable !\n",
hdev->id / 2); hdev->cdev_idx);
return rc; return rc;
} }
......
...@@ -3129,7 +3129,8 @@ struct hl_reset_info { ...@@ -3129,7 +3129,8 @@ struct hl_reset_info {
* @edma_binning: contains mask of edma engines that is received from the f/w which * @edma_binning: contains mask of edma engines that is received from the f/w which
* indicates which edma engines are binned-out * indicates which edma engines are binned-out
* @id: device minor. * @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 * @cpu_pci_msb_addr: 50-bit extension bits for the device CPU's 40-bit
* addresses. * addresses.
* @is_in_dram_scrub: true if dram scrub operation is on going. * @is_in_dram_scrub: true if dram scrub operation is on going.
...@@ -3289,6 +3290,7 @@ struct hl_device { ...@@ -3289,6 +3290,7 @@ struct hl_device {
u32 edma_binning; u32 edma_binning;
u16 id; u16 id;
u16 id_control; u16 id_control;
u16 cdev_idx;
u16 cpu_pci_msb_addr; u16 cpu_pci_msb_addr;
u8 is_in_dram_scrub; u8 is_in_dram_scrub;
u8 disabled; u8 disabled;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment