Commit d6a66d59 authored by Ofir Bitton's avatar Ofir Bitton Committed by Oded Gabbay

habanalabs: add support for common decoder interrupts

User application should be able to get notification for any decoder
completion. Hence, we introduce a new interface in which a user
can wait for all current decoder pending interrupts.
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 1a6609cd
...@@ -1082,6 +1082,9 @@ void hl_release_pending_user_interrupts(struct hl_device *hdev) ...@@ -1082,6 +1082,9 @@ void hl_release_pending_user_interrupts(struct hl_device *hdev)
interrupt = &hdev->common_user_cq_interrupt; interrupt = &hdev->common_user_cq_interrupt;
wake_pending_user_interrupt_threads(interrupt); wake_pending_user_interrupt_threads(interrupt);
interrupt = &hdev->common_decoder_interrupt;
wake_pending_user_interrupt_threads(interrupt);
} }
static void job_wq_completion(struct work_struct *work) static void job_wq_completion(struct work_struct *work)
...@@ -3375,6 +3378,8 @@ static int hl_interrupt_wait_ioctl(struct hl_fpriv *hpriv, void *data) ...@@ -3375,6 +3378,8 @@ static int hl_interrupt_wait_ioctl(struct hl_fpriv *hpriv, void *data)
} else if (interrupt_id == HL_COMMON_USER_CQ_INTERRUPT_ID) { } else if (interrupt_id == HL_COMMON_USER_CQ_INTERRUPT_ID) {
interrupt = &hdev->common_user_cq_interrupt; interrupt = &hdev->common_user_cq_interrupt;
} else if (interrupt_id == HL_COMMON_DEC_INTERRUPT_ID) {
interrupt = &hdev->common_decoder_interrupt;
} else { } else {
dev_err(hdev->dev, "invalid user interrupt %u", interrupt_id); dev_err(hdev->dev, "invalid user interrupt %u", interrupt_id);
return -EINVAL; return -EINVAL;
......
...@@ -77,6 +77,7 @@ struct hl_fpriv; ...@@ -77,6 +77,7 @@ struct hl_fpriv;
#define HL_INVALID_QUEUE UINT_MAX #define HL_INVALID_QUEUE UINT_MAX
#define HL_COMMON_USER_CQ_INTERRUPT_ID 0xFFF #define HL_COMMON_USER_CQ_INTERRUPT_ID 0xFFF
#define HL_COMMON_DEC_INTERRUPT_ID 0xFFE
#define HL_STATE_DUMP_HIST_LEN 5 #define HL_STATE_DUMP_HIST_LEN 5
...@@ -2955,6 +2956,7 @@ struct hl_reset_info { ...@@ -2955,6 +2956,7 @@ struct hl_reset_info {
* @common_user_cq_interrupt: common user CQ interrupt for all user CQ interrupts. * @common_user_cq_interrupt: common user CQ interrupt for all user CQ interrupts.
* upon any user CQ interrupt, driver will monitor the * upon any user CQ interrupt, driver will monitor the
* list of fences registered to this common structure. * list of fences registered to this common structure.
* @common_decoder_interrupt: common decoder interrupt for all user decoder interrupts.
* @shadow_cs_queue: pointer to a shadow queue that holds pointers to * @shadow_cs_queue: pointer to a shadow queue that holds pointers to
* outstanding command submissions. * outstanding command submissions.
* @cq_wq: work queues of completion queues for executing work in process * @cq_wq: work queues of completion queues for executing work in process
...@@ -3119,6 +3121,7 @@ struct hl_device { ...@@ -3119,6 +3121,7 @@ struct hl_device {
struct hl_cq *completion_queue; struct hl_cq *completion_queue;
struct hl_user_interrupt *user_interrupt; struct hl_user_interrupt *user_interrupt;
struct hl_user_interrupt common_user_cq_interrupt; struct hl_user_interrupt common_user_cq_interrupt;
struct hl_user_interrupt common_decoder_interrupt;
struct hl_cs **shadow_cs_queue; struct hl_cs **shadow_cs_queue;
struct workqueue_struct **cq_wq; struct workqueue_struct **cq_wq;
struct workqueue_struct *eq_wq; struct workqueue_struct *eq_wq;
......
...@@ -333,12 +333,9 @@ irqreturn_t hl_irq_handler_user_interrupt(int irq, void *arg) ...@@ -333,12 +333,9 @@ 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 the interrupt is not a decoder interrupt, it means the interrupt if (user_int->is_decoder)
* belongs to a user cq. In that case, before handling it, we need to handle the common handle_user_interrupt(hdev, &hdev->common_decoder_interrupt);
* user cq else
*/
if (!user_int->is_decoder)
/* Handle user cq interrupts registered on all interrupts */
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 or decoder interrupts registered on this specific irq */
......
...@@ -2895,6 +2895,10 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev) ...@@ -2895,6 +2895,10 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev)
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, false);
/* Initialize common decoder interrupt */
HL_USR_INTR_STRUCT_INIT(hdev->common_decoder_interrupt, hdev,
HL_COMMON_DEC_INTERRUPT_ID, true);
/* 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.
* The only limitation is that the last decoder interrupt id must be smaller * The only limitation is that the last decoder interrupt id must be smaller
......
...@@ -1443,6 +1443,7 @@ union hl_cs_args { ...@@ -1443,6 +1443,7 @@ union hl_cs_args {
#define HL_WAIT_CS_FLAGS_INTERRUPT 0x2 #define HL_WAIT_CS_FLAGS_INTERRUPT 0x2
#define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000 #define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000
#define HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT 0xFFF00000 #define HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT 0xFFF00000
#define HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT 0xFFE00000
#define HL_WAIT_CS_FLAGS_MULTI_CS 0x4 #define HL_WAIT_CS_FLAGS_MULTI_CS 0x4
#define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x10 #define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x10
#define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x20 #define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x20
...@@ -1496,6 +1497,9 @@ struct hl_wait_cs_in { ...@@ -1496,6 +1497,9 @@ struct hl_wait_cs_in {
* *
* in order to wait for any CQ interrupt, set interrupt value to * in order to wait for any CQ interrupt, set interrupt value to
* HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT. * HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT.
*
* in order to wait for any decoder interrupt, set interrupt value to
* HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT.
*/ */
__u32 flags; __u32 flags;
......
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