diff options
author | Omer Shpigelman <oshpigelman@habana.ai> | 2020-03-01 19:59:39 +0200 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2020-05-17 12:06:22 +0300 |
commit | 1fa185c6560cd15c1bf8840e7d157a29429279eb (patch) | |
tree | 4963f26ad91ddc78880bcafbf58bc28f33a04d19 /drivers/misc/habanalabs/device.c | |
parent | 76cedc739d7aac461ae303ca0e8b3a81e6ae00aa (diff) | |
download | linux-1fa185c6560cd15c1bf8840e7d157a29429279eb.tar.gz linux-1fa185c6560cd15c1bf8840e7d157a29429279eb.tar.bz2 linux-1fa185c6560cd15c1bf8840e7d157a29429279eb.zip |
habanalabs: re-factor H/W queues initialization
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.
Signed-off-by: Omer Shpigelman <oshpigelman@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Diffstat (limited to 'drivers/misc/habanalabs/device.c')
-rw-r--r-- | drivers/misc/habanalabs/device.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c index aef4de36b7aa..c89157dafa33 100644 --- a/drivers/misc/habanalabs/device.c +++ b/drivers/misc/habanalabs/device.c @@ -1062,7 +1062,7 @@ out_err: */ 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"); |