Commit 9a7d530a authored by Ofir Bitton's avatar Ofir Bitton Committed by Oded Gabbay

habanalabs: refactor user interrupt type

In order to support more user interrupt types in the future, we
enumerate the user interrupt type instead of using a boolean.
Signed-off-by: default avatarOfir Bitton <obitton@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 12d3ea01
...@@ -1083,20 +1083,25 @@ struct hl_cq { ...@@ -1083,20 +1083,25 @@ struct hl_cq {
atomic_t free_slots_cnt; atomic_t free_slots_cnt;
}; };
enum hl_user_interrupt_type {
HL_USR_INTERRUPT_CQ = 0,
HL_USR_INTERRUPT_DECODER,
};
/** /**
* struct hl_user_interrupt - holds user interrupt information * struct hl_user_interrupt - holds user interrupt information
* @hdev: pointer to the device structure * @hdev: pointer to the device structure
* @type: user interrupt type
* @wait_list_head: head to the list of user threads pending on this interrupt * @wait_list_head: head to the list of user threads pending on this interrupt
* @wait_list_lock: protects wait_list_head * @wait_list_lock: protects wait_list_head
* @interrupt_id: msix interrupt id * @interrupt_id: msix interrupt id
* @is_decoder: whether this entry represents a decoder interrupt
*/ */
struct hl_user_interrupt { struct hl_user_interrupt {
struct hl_device *hdev; struct hl_device *hdev;
struct list_head wait_list_head; enum hl_user_interrupt_type type;
spinlock_t wait_list_lock; struct list_head wait_list_head;
u32 interrupt_id; spinlock_t wait_list_lock;
bool is_decoder; u32 interrupt_id;
}; };
/** /**
...@@ -2691,11 +2696,11 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val); ...@@ -2691,11 +2696,11 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val);
p->size = sz; \ p->size = sz; \
}) })
#define HL_USR_INTR_STRUCT_INIT(usr_intr, hdev, intr_id, decoder) \ #define HL_USR_INTR_STRUCT_INIT(usr_intr, hdev, intr_id, intr_type) \
({ \ ({ \
usr_intr.hdev = hdev; \ usr_intr.hdev = hdev; \
usr_intr.interrupt_id = intr_id; \ usr_intr.interrupt_id = intr_id; \
usr_intr.is_decoder = decoder; \ usr_intr.type = intr_type; \
INIT_LIST_HEAD(&usr_intr.wait_list_head); \ INIT_LIST_HEAD(&usr_intr.wait_list_head); \
spin_lock_init(&usr_intr.wait_list_lock); \ spin_lock_init(&usr_intr.wait_list_lock); \
}) })
......
...@@ -333,13 +333,22 @@ irqreturn_t hl_irq_handler_user_interrupt(int irq, void *arg) ...@@ -333,13 +333,22 @@ irqreturn_t hl_irq_handler_user_interrupt(int irq, void *arg)
struct hl_user_interrupt *user_int = arg; struct hl_user_interrupt *user_int = arg;
struct hl_device *hdev = user_int->hdev; struct hl_device *hdev = user_int->hdev;
if (user_int->is_decoder) switch (user_int->type) {
handle_user_interrupt(hdev, &hdev->common_decoder_interrupt); case HL_USR_INTERRUPT_CQ:
else
handle_user_interrupt(hdev, &hdev->common_user_cq_interrupt); handle_user_interrupt(hdev, &hdev->common_user_cq_interrupt);
/* Handle user cq or decoder interrupts registered on this specific irq */ /* Handle user cq interrupt registered on this specific irq */
handle_user_interrupt(hdev, user_int); handle_user_interrupt(hdev, user_int);
break;
case HL_USR_INTERRUPT_DECODER:
handle_user_interrupt(hdev, &hdev->common_decoder_interrupt);
/* Handle decoder interrupt registered on this specific irq */
handle_user_interrupt(hdev, user_int);
break;
default:
break;
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -2966,11 +2966,11 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev) ...@@ -2966,11 +2966,11 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev)
/* Initialize common user CQ interrupt */ /* Initialize common user CQ interrupt */
HL_USR_INTR_STRUCT_INIT(hdev->common_user_cq_interrupt, hdev, HL_USR_INTR_STRUCT_INIT(hdev->common_user_cq_interrupt, hdev,
HL_COMMON_USER_CQ_INTERRUPT_ID, false); HL_COMMON_USER_CQ_INTERRUPT_ID, HL_USR_INTERRUPT_CQ);
/* Initialize common decoder interrupt */ /* Initialize common decoder interrupt */
HL_USR_INTR_STRUCT_INIT(hdev->common_decoder_interrupt, hdev, HL_USR_INTR_STRUCT_INIT(hdev->common_decoder_interrupt, hdev,
HL_COMMON_DEC_INTERRUPT_ID, true); HL_COMMON_DEC_INTERRUPT_ID, HL_USR_INTERRUPT_DECODER);
/* User interrupts structure holds both decoder and user interrupts from various engines. /* 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. * We first initialize the decoder interrupts and then we add the user interrupts.
...@@ -2983,10 +2983,11 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev) ...@@ -2983,10 +2983,11 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev)
*/ */
for (i = GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM, j = 0 ; i <= GAUDI2_IRQ_NUM_SHARED_DEC1_NRM; for (i = GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM, j = 0 ; i <= GAUDI2_IRQ_NUM_SHARED_DEC1_NRM;
i += 2, j++) i += 2, j++)
HL_USR_INTR_STRUCT_INIT(hdev->user_interrupt[j], hdev, i, true); HL_USR_INTR_STRUCT_INIT(hdev->user_interrupt[j], hdev, i,
HL_USR_INTERRUPT_DECODER);
for (i = GAUDI2_IRQ_NUM_USER_FIRST, k = 0 ; k < prop->user_interrupt_count; i++, j++, k++) for (i = GAUDI2_IRQ_NUM_USER_FIRST, k = 0 ; k < prop->user_interrupt_count; i++, j++, k++)
HL_USR_INTR_STRUCT_INIT(hdev->user_interrupt[j], hdev, i, false); HL_USR_INTR_STRUCT_INIT(hdev->user_interrupt[j], hdev, i, HL_USR_INTERRUPT_CQ);
} }
static inline int gaudi2_get_non_zero_random_int(void) static inline int gaudi2_get_non_zero_random_int(void)
......
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