[PATCH 3/5] accel/rocket: Add per-task flags and interrupt mask to UAPI and kernel

Ross Cawston posted 5 patches 1 month, 2 weeks ago
[PATCH 3/5] accel/rocket: Add per-task flags and interrupt mask to UAPI and kernel
Posted by Ross Cawston 1 month, 2 weeks ago
Add two new fields to struct drm_rocket_task (UAPI) and struct rocket_task
(kernel):

- u32 int_mask: which block completion interrupt(s) should signal task done
- u32 flags: currently only ROCKET_TASK_SKIP_CNA_CORE

In rocket_copy_tasks():
- copy the new fields
- default int_mask to DPU_0 | DPU_1 when userspace passes zero (backward compatible)

No functional change yet - old userspace continues to work unchanged.

Signed-off-by: Ross Cawston <ross@r-sc.ca>
---
 drivers/accel/rocket/rocket_job.c |  8 ++++++++
 drivers/accel/rocket/rocket_job.h |  2 ++
 include/uapi/drm/rocket_accel.h   | 25 +++++++++++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index 369b60805d5f..34898084cc56 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -96,6 +96,14 @@ rocket_copy_tasks(struct drm_device *dev,
 
 		rjob->tasks[i].regcmd = task.regcmd;
 		rjob->tasks[i].regcmd_count = task.regcmd_count;
+		rjob->tasks[i].int_mask = task.int_mask;
+		rjob->tasks[i].flags = task.flags;
+
+		/* Default to DPU completion if no mask specified */
+		if (!rjob->tasks[i].int_mask) {
+			rjob->tasks[i].int_mask = PC_INTERRUPT_MASK_DPU_0 |
+									PC_INTERRUPT_MASK_DPU_1;
+		}
 	}
 
 	return 0;
diff --git a/drivers/accel/rocket/rocket_job.h b/drivers/accel/rocket/rocket_job.h
index 4ae00feec3b9..6931dfed8615 100644
--- a/drivers/accel/rocket/rocket_job.h
+++ b/drivers/accel/rocket/rocket_job.h
@@ -13,6 +13,8 @@
 struct rocket_task {
 	u64 regcmd;
 	u32 regcmd_count;
+	u32 int_mask;
+	u32 flags;
 };
 
 struct rocket_job {
diff --git a/include/uapi/drm/rocket_accel.h b/include/uapi/drm/rocket_accel.h
index d0685e372b79..ae0d8e48afcd 100644
--- a/include/uapi/drm/rocket_accel.h
+++ b/include/uapi/drm/rocket_accel.h
@@ -90,6 +90,11 @@ struct drm_rocket_fini_bo {
 	__u32 reserved;
 };
 
+/**
+ * Flags for drm_rocket_task.flags
+ */
+#define ROCKET_TASK_SKIP_CNA_CORE		0x1
+
 /**
  * struct drm_rocket_task - A task to be run on the NPU
  *
@@ -106,6 +111,26 @@ struct drm_rocket_task {
 	 * buffer
 	 */
 	__u32 regcmd_count;
+
+	/**
+	 * Input: Interrupt mask specifying which block completion signals
+	 * that this task is done. Uses PC_INTERRUPT_MASK_* bits.
+	 *
+	 * For conv/DPU tasks: DPU_0 | DPU_1 (0x0300)
+	 * For PPU tasks:      PPU_0 | PPU_1 (0x0C00)
+	 *
+	 * If zero, defaults to DPU_0 | DPU_1 for backwards compatibility.
+	 */
+	__u32 int_mask;
+
+	/**
+	 * Input: Task flags.
+	 *
+	 * ROCKET_TASK_SKIP_CNA_CORE: Skip CNA and Core S_POINTER MMIO
+	 * writes for this task. Used for standalone DPU element-wise
+	 * and PPU pooling tasks that don't use CNA/Core.
+	 */
+	__u32 flags;
 };
 
 /**

-- 
2.52.0