]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
accel/habanalabs: add an EQ size ASIC property
authorTomer Tayar <ttayar@habana.ai>
Wed, 13 Mar 2024 09:45:45 +0000 (11:45 +0200)
committerOfir Bitton <obitton@habana.ai>
Sun, 23 Jun 2024 06:53:04 +0000 (09:53 +0300)
Future supported ASICs might use the dynamic EQ mechanism with the
firmware, and in that case the EQ size won't be equal to the default
HL_EQ_SIZE_IN_BYTES value.
Add an ASIC property to enable overriding this value.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Ofir Bitton <obitton@habana.ai>
Signed-off-by: Ofir Bitton <obitton@habana.ai>
drivers/accel/habanalabs/common/habanalabs.h
drivers/accel/habanalabs/common/irq.c

index 5e9f54ca336a3c1b358d98aa4e29f2123f80efca..8d0df685e62714be21fb956b18b757274808addc 100644 (file)
@@ -651,6 +651,8 @@ struct hl_hints_range {
  * @hbw_flush_reg: register to read to generate HBW flush. value of 0 means HBW flush is
  *                 not supported.
  * @reserved_fw_mem_size: size of dram memory reserved for FW.
+ * @fw_event_queue_size: queue size for events from CPU-CP.
+ *                       A value of 0 means using the default HL_EQ_SIZE_IN_BYTES value.
  * @collective_first_sob: first sync object available for collective use
  * @collective_first_mon: first monitor available for collective use
  * @sync_stream_first_sob: first sync object available for sync stream use
@@ -782,6 +784,7 @@ struct asic_fixed_properties {
        u32                             glbl_err_max_cause_num;
        u32                             hbw_flush_reg;
        u32                             reserved_fw_mem_size;
+       u32                             fw_event_queue_size;
        u16                             collective_first_sob;
        u16                             collective_first_mon;
        u16                             sync_stream_first_sob;
@@ -1229,6 +1232,7 @@ struct hl_user_pending_interrupt {
  * @hdev: pointer to the device structure
  * @kernel_address: holds the queue's kernel virtual address
  * @bus_address: holds the queue's DMA address
+ * @size: the event queue size
  * @ci: ci inside the queue
  * @prev_eqe_index: the index of the previous event queue entry. The index of
  *                  the current entry's index must be +1 of the previous one.
@@ -1240,6 +1244,7 @@ struct hl_eq {
        struct hl_device        *hdev;
        void                    *kernel_address;
        dma_addr_t              bus_address;
+       u32                     size;
        u32                     ci;
        u32                     prev_eqe_index;
        bool                    check_eqe_index;
index 978b7f4d5eebeebfb10bc32d238bae34bcd0f8f7..2caf2df4de08bec0296ce1a6e171a21e7d9a0326 100644 (file)
@@ -652,14 +652,16 @@ void hl_cq_reset(struct hl_device *hdev, struct hl_cq *q)
  */
 int hl_eq_init(struct hl_device *hdev, struct hl_eq *q)
 {
+       u32 size = hdev->asic_prop.fw_event_queue_size ? : HL_EQ_SIZE_IN_BYTES;
        void *p;
 
-       p = hl_cpu_accessible_dma_pool_alloc(hdev, HL_EQ_SIZE_IN_BYTES, &q->bus_address);
+       p = hl_cpu_accessible_dma_pool_alloc(hdev, size, &q->bus_address);
        if (!p)
                return -ENOMEM;
 
        q->hdev = hdev;
        q->kernel_address = p;
+       q->size = size;
        q->ci = 0;
        q->prev_eqe_index = 0;
 
@@ -678,7 +680,7 @@ void hl_eq_fini(struct hl_device *hdev, struct hl_eq *q)
 {
        flush_workqueue(hdev->eq_wq);
 
-       hl_cpu_accessible_dma_pool_free(hdev, HL_EQ_SIZE_IN_BYTES, q->kernel_address);
+       hl_cpu_accessible_dma_pool_free(hdev, q->size, q->kernel_address);
 }
 
 void hl_eq_reset(struct hl_device *hdev, struct hl_eq *q)
@@ -693,5 +695,5 @@ void hl_eq_reset(struct hl_device *hdev, struct hl_eq *q)
         * when the device is operational again
         */
 
-       memset(q->kernel_address, 0, HL_EQ_SIZE_IN_BYTES);
+       memset(q->kernel_address, 0, q->size);
 }