habanalabs: naming refactor of user interrupt flow
authorOfir Bitton <obitton@habana.ai>
Tue, 28 Jun 2022 18:05:28 +0000 (21:05 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Tue, 12 Jul 2022 06:09:28 +0000 (09:09 +0300)
Current naming convention can be misleading. Hence renaming some
variables and defines in order to be more explicit.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/command_submission.c
drivers/misc/habanalabs/common/habanalabs.h
drivers/misc/habanalabs/common/irq.c
drivers/misc/habanalabs/gaudi2/gaudi2.c
include/uapi/misc/habanalabs.h

index e91ca31d4930ff572a135a32cbb778363eb07aa7..275dcb69a40e91b52299944a26e2572fe559880e 100644 (file)
@@ -1080,7 +1080,7 @@ void hl_release_pending_user_interrupts(struct hl_device *hdev)
                wake_pending_user_interrupt_threads(interrupt);
        }
 
-       interrupt = &hdev->common_user_interrupt;
+       interrupt = &hdev->common_user_cq_interrupt;
        wake_pending_user_interrupt_threads(interrupt);
 }
 
@@ -3373,8 +3373,8 @@ static int hl_interrupt_wait_ioctl(struct hl_fpriv *hpriv, void *data)
                int_idx = interrupt_id - first_interrupt + prop->user_dec_intr_count;
                interrupt = &hdev->user_interrupt[int_idx];
 
-       } else if (interrupt_id == HL_COMMON_USER_INTERRUPT_ID) {
-               interrupt = &hdev->common_user_interrupt;
+       } else if (interrupt_id == HL_COMMON_USER_CQ_INTERRUPT_ID) {
+               interrupt = &hdev->common_user_cq_interrupt;
        } else {
                dev_err(hdev->dev, "invalid user interrupt %u", interrupt_id);
                return -EINVAL;
index 8c38c2c1b1dce179e2cd21fdddc8a3b7577a8a8b..9b2451f3619a7421cb5336bb1396fd112d8fccc9 100644 (file)
@@ -76,7 +76,7 @@ struct hl_fpriv;
 
 #define HL_INVALID_QUEUE               UINT_MAX
 
-#define HL_COMMON_USER_INTERRUPT_ID    0xFFF
+#define HL_COMMON_USER_CQ_INTERRUPT_ID 0xFFF
 
 #define HL_STATE_DUMP_HIST_LEN         5
 
@@ -2952,8 +2952,8 @@ struct hl_reset_info {
  * @user_interrupt: array of hl_user_interrupt. upon the corresponding user
  *                  interrupt, driver will monitor the list of fences
  *                  registered to this interrupt.
- * @common_user_interrupt: common user interrupt for all user interrupts.
- *                         upon any user interrupt, driver will monitor the
+ * @common_user_cq_interrupt: common user CQ interrupt for all user CQ interrupts.
+ *                         upon any user CQ interrupt, driver will monitor the
  *                         list of fences registered to this common structure.
  * @shadow_cs_queue: pointer to a shadow queue that holds pointers to
  *                   outstanding command submissions.
@@ -3118,7 +3118,7 @@ struct hl_device {
        enum hl_asic_type               asic_type;
        struct hl_cq                    *completion_queue;
        struct hl_user_interrupt        *user_interrupt;
-       struct hl_user_interrupt        common_user_interrupt;
+       struct hl_user_interrupt        common_user_cq_interrupt;
        struct hl_cs                    **shadow_cs_queue;
        struct workqueue_struct         **cq_wq;
        struct workqueue_struct         *eq_wq;
index c1088377d1deafa33dc7e134f05694d21688ead9..fd8f2bd9020e5258b9f6507b351c2155ebb34ecc 100644 (file)
@@ -269,7 +269,7 @@ static int handle_registration_node(struct hl_device *hdev, struct hl_user_pendi
        return 0;
 }
 
-static void handle_user_cq(struct hl_device *hdev, struct hl_user_interrupt *user_cq)
+static void handle_user_interrupt(struct hl_device *hdev, struct hl_user_interrupt *intr)
 {
        struct hl_user_pending_interrupt *pend, *temp_pend;
        struct list_head *ts_reg_free_list_head = NULL;
@@ -291,8 +291,8 @@ static void handle_user_cq(struct hl_device *hdev, struct hl_user_interrupt *use
        if (!job)
                return;
 
-       spin_lock(&user_cq->wait_list_lock);
-       list_for_each_entry_safe(pend, temp_pend, &user_cq->wait_list_head, wait_list_node) {
+       spin_lock(&intr->wait_list_lock);
+       list_for_each_entry_safe(pend, temp_pend, &intr->wait_list_head, wait_list_node) {
                if ((pend->cq_kernel_addr && *(pend->cq_kernel_addr) >= pend->cq_target_value) ||
                                !pend->cq_kernel_addr) {
                        if (pend->ts_reg_info.buf) {
@@ -309,7 +309,7 @@ static void handle_user_cq(struct hl_device *hdev, struct hl_user_interrupt *use
                        }
                }
        }
-       spin_unlock(&user_cq->wait_list_lock);
+       spin_unlock(&intr->wait_list_lock);
 
        if (ts_reg_free_list_head) {
                INIT_WORK(&job->free_obj, hl_ts_free_objects);
@@ -339,10 +339,10 @@ irqreturn_t hl_irq_handler_user_interrupt(int irq, void *arg)
         */
        if (!user_int->is_decoder)
                /* Handle user cq interrupts registered on all interrupts */
-               handle_user_cq(hdev, &hdev->common_user_interrupt);
+               handle_user_interrupt(hdev, &hdev->common_user_cq_interrupt);
 
        /* Handle user cq or decoder interrupts registered on this specific irq */
-       handle_user_cq(hdev, user_int);
+       handle_user_interrupt(hdev, user_int);
 
        return IRQ_HANDLED;
 }
index 93373290e894754bb02d3a5cf99a4d7229bb585c..8f012076363d29c92557217869fe0c6398ea9889 100644 (file)
@@ -2891,9 +2891,9 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev)
        struct asic_fixed_properties *prop = &hdev->asic_prop;
        int i, j, k;
 
-       /* Initialize common user interrupt */
-       HL_USR_INTR_STRUCT_INIT(hdev->common_user_interrupt, hdev, HL_COMMON_USER_INTERRUPT_ID,
-                               false);
+       /* Initialize common user CQ interrupt */
+       HL_USR_INTR_STRUCT_INIT(hdev->common_user_cq_interrupt, hdev,
+                               HL_COMMON_USER_CQ_INTERRUPT_ID, false);
 
        /* User interrupts structure holds both decoder and user interrupts from various engines.
         * We first initialize the decoder interrupts and then we add the user interrupts.
index 77b89c537ee8bb16992de30ec2fc1db9f15f2a64..4ee24a3a13e9c9541d790996e44cbb022ed73cde 100644 (file)
@@ -1442,6 +1442,7 @@ union hl_cs_args {
 
 #define HL_WAIT_CS_FLAGS_INTERRUPT             0x2
 #define HL_WAIT_CS_FLAGS_INTERRUPT_MASK                0xFFF00000
+#define HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT      0xFFF00000
 #define HL_WAIT_CS_FLAGS_MULTI_CS              0x4
 #define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ   0x10
 #define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT    0x20
@@ -1491,8 +1492,10 @@ struct hl_wait_cs_in {
 
        /* HL_WAIT_CS_FLAGS_*
         * If HL_WAIT_CS_FLAGS_INTERRUPT is set, this field should include
-        * interrupt id according to HL_WAIT_CS_FLAGS_INTERRUPT_MASK, in order
-        * not to specify an interrupt id ,set mask to all 1s.
+        * interrupt id according to HL_WAIT_CS_FLAGS_INTERRUPT_MASK
+        *
+        * in order to wait for any CQ interrupt, set interrupt value to
+        * HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT.
         */
        __u32 flags;