From: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: oded.gabbay@gmail.com, quic_jhugo@quicinc.com, "Wachowski,
Karol" <karol.wachowski@intel.com>,
Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Subject: [PATCH 03/12] accel/ivpu: Create priority based command queues
Date: Wed, 8 May 2024 15:21:00 +0200 [thread overview]
Message-ID: <20240508132106.2387464-4-jacek.lawrynowicz@linux.intel.com> (raw)
In-Reply-To: <20240508132106.2387464-1-jacek.lawrynowicz@linux.intel.com>
From: "Wachowski, Karol" <karol.wachowski@intel.com>
Create multiple command queues per engine with different priorities.
The cmdqs are created on-demand and they support 4 priority levels.
These priorities will later be used by the HWS (hardware scheduler).
Signed-off-by: Wachowski, Karol <karol.wachowski@intel.com>
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
---
drivers/accel/ivpu/ivpu_drv.h | 8 +++--
drivers/accel/ivpu/ivpu_job.c | 61 +++++++++++++++++++++++------------
2 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/drivers/accel/ivpu/ivpu_drv.h b/drivers/accel/ivpu/ivpu_drv.h
index a3993c93403a..2277718b31f7 100644
--- a/drivers/accel/ivpu/ivpu_drv.h
+++ b/drivers/accel/ivpu/ivpu_drv.h
@@ -39,7 +39,11 @@
#define IVPU_MIN_DB 1
#define IVPU_MAX_DB 255
-#define IVPU_NUM_ENGINES 2
+#define IVPU_NUM_ENGINES 2
+#define IVPU_NUM_PRIORITIES 4
+#define IVPU_NUM_CMDQS_PER_CTX (IVPU_NUM_ENGINES * IVPU_NUM_PRIORITIES)
+
+#define IVPU_CMDQ_INDEX(engine, priority) ((engine) * IVPU_NUM_PRIORITIES + (priority))
#define IVPU_PLATFORM_SILICON 0
#define IVPU_PLATFORM_SIMICS 2
@@ -149,7 +153,7 @@ struct ivpu_file_priv {
struct kref ref;
struct ivpu_device *vdev;
struct mutex lock; /* Protects cmdq */
- struct ivpu_cmdq *cmdq[IVPU_NUM_ENGINES];
+ struct ivpu_cmdq *cmdq[IVPU_NUM_CMDQS_PER_CTX];
struct ivpu_mmu_context ctx;
bool has_mmu_faults;
bool bound;
diff --git a/drivers/accel/ivpu/ivpu_job.c b/drivers/accel/ivpu/ivpu_job.c
index a49bc9105ed0..b56035de1a59 100644
--- a/drivers/accel/ivpu/ivpu_job.c
+++ b/drivers/accel/ivpu/ivpu_job.c
@@ -79,10 +79,12 @@ static void ivpu_cmdq_free(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *c
kfree(cmdq);
}
-static struct ivpu_cmdq *ivpu_cmdq_acquire(struct ivpu_file_priv *file_priv, u16 engine)
+static struct ivpu_cmdq *ivpu_cmdq_acquire(struct ivpu_file_priv *file_priv, u16 engine,
+ u8 priority)
{
+ int cmdq_idx = IVPU_CMDQ_INDEX(engine, priority);
+ struct ivpu_cmdq *cmdq = file_priv->cmdq[cmdq_idx];
struct ivpu_device *vdev = file_priv->vdev;
- struct ivpu_cmdq *cmdq = file_priv->cmdq[engine];
int ret;
lockdep_assert_held(&file_priv->lock);
@@ -91,7 +93,7 @@ static struct ivpu_cmdq *ivpu_cmdq_acquire(struct ivpu_file_priv *file_priv, u16
cmdq = ivpu_cmdq_alloc(file_priv, engine);
if (!cmdq)
return NULL;
- file_priv->cmdq[engine] = cmdq;
+ file_priv->cmdq[cmdq_idx] = cmdq;
}
if (cmdq->db_registered)
@@ -107,14 +109,15 @@ static struct ivpu_cmdq *ivpu_cmdq_acquire(struct ivpu_file_priv *file_priv, u16
return cmdq;
}
-static void ivpu_cmdq_release_locked(struct ivpu_file_priv *file_priv, u16 engine)
+static void ivpu_cmdq_release_locked(struct ivpu_file_priv *file_priv, u16 engine, u8 priority)
{
- struct ivpu_cmdq *cmdq = file_priv->cmdq[engine];
+ int cmdq_idx = IVPU_CMDQ_INDEX(engine, priority);
+ struct ivpu_cmdq *cmdq = file_priv->cmdq[cmdq_idx];
lockdep_assert_held(&file_priv->lock);
if (cmdq) {
- file_priv->cmdq[engine] = NULL;
+ file_priv->cmdq[cmdq_idx] = NULL;
if (cmdq->db_registered)
ivpu_jsm_unregister_db(file_priv->vdev, cmdq->db_id);
@@ -124,12 +127,14 @@ static void ivpu_cmdq_release_locked(struct ivpu_file_priv *file_priv, u16 engin
void ivpu_cmdq_release_all_locked(struct ivpu_file_priv *file_priv)
{
- int i;
+ u16 engine;
+ u8 priority;
lockdep_assert_held(&file_priv->lock);
- for (i = 0; i < IVPU_NUM_ENGINES; i++)
- ivpu_cmdq_release_locked(file_priv, i);
+ for (engine = 0; engine < IVPU_NUM_ENGINES; engine++)
+ for (priority = 0; priority < IVPU_NUM_PRIORITIES; priority++)
+ ivpu_cmdq_release_locked(file_priv, engine, priority);
}
/*
@@ -138,9 +143,10 @@ void ivpu_cmdq_release_all_locked(struct ivpu_file_priv *file_priv)
* and FW loses job queue state. The next time job queue is used it
* will be registered again.
*/
-static void ivpu_cmdq_reset_locked(struct ivpu_file_priv *file_priv, u16 engine)
+static void ivpu_cmdq_reset_locked(struct ivpu_file_priv *file_priv, u16 engine, u8 priority)
{
- struct ivpu_cmdq *cmdq = file_priv->cmdq[engine];
+ int cmdq_idx = IVPU_CMDQ_INDEX(engine, priority);
+ struct ivpu_cmdq *cmdq = file_priv->cmdq[cmdq_idx];
lockdep_assert_held(&file_priv->lock);
@@ -154,12 +160,14 @@ static void ivpu_cmdq_reset_locked(struct ivpu_file_priv *file_priv, u16 engine)
static void ivpu_cmdq_reset_all(struct ivpu_file_priv *file_priv)
{
- int i;
+ u16 engine;
+ u8 priority;
mutex_lock(&file_priv->lock);
- for (i = 0; i < IVPU_NUM_ENGINES; i++)
- ivpu_cmdq_reset_locked(file_priv, i);
+ for (engine = 0; engine < IVPU_NUM_ENGINES; engine++)
+ for (priority = 0; priority < IVPU_NUM_PRIORITIES; priority++)
+ ivpu_cmdq_reset_locked(file_priv, engine, priority);
mutex_unlock(&file_priv->lock);
}
@@ -328,7 +336,7 @@ void ivpu_jobs_abort_all(struct ivpu_device *vdev)
ivpu_job_signal_and_destroy(vdev, id, DRM_IVPU_JOB_STATUS_ABORTED);
}
-static int ivpu_job_submit(struct ivpu_job *job)
+static int ivpu_job_submit(struct ivpu_job *job, u8 priority)
{
struct ivpu_file_priv *file_priv = job->file_priv;
struct ivpu_device *vdev = job->vdev;
@@ -342,10 +350,10 @@ static int ivpu_job_submit(struct ivpu_job *job)
mutex_lock(&file_priv->lock);
- cmdq = ivpu_cmdq_acquire(job->file_priv, job->engine_idx);
+ cmdq = ivpu_cmdq_acquire(job->file_priv, job->engine_idx, priority);
if (!cmdq) {
- ivpu_warn_ratelimited(vdev, "Failed get job queue, ctx %d engine %d\n",
- file_priv->ctx.id, job->engine_idx);
+ ivpu_warn_ratelimited(vdev, "Failed to get job queue, ctx %d engine %d prio %d\n",
+ file_priv->ctx.id, job->engine_idx, priority);
ret = -EINVAL;
goto err_unlock_file_priv;
}
@@ -375,8 +383,8 @@ static int ivpu_job_submit(struct ivpu_job *job)
ivpu_cmdq_ring_db(vdev, cmdq);
}
- ivpu_dbg(vdev, JOB, "Job submitted: id %3u ctx %2d engine %d addr 0x%llx next %d\n",
- job->job_id, file_priv->ctx.id, job->engine_idx,
+ ivpu_dbg(vdev, JOB, "Job submitted: id %3u ctx %2d engine %d prio %d addr 0x%llx next %d\n",
+ job->job_id, file_priv->ctx.id, job->engine_idx, priority,
job->cmd_buf_vpu_addr, cmdq->jobq->header.tail);
xa_unlock(&vdev->submitted_jobs_xa);
@@ -464,6 +472,14 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
return ret;
}
+static inline u8 ivpu_job_to_hws_priority(struct ivpu_file_priv *file_priv, u8 priority)
+{
+ if (priority == DRM_IVPU_JOB_PRIORITY_DEFAULT)
+ return DRM_IVPU_JOB_PRIORITY_NORMAL;
+
+ return priority - 1;
+}
+
int ivpu_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
{
struct ivpu_file_priv *file_priv = file->driver_priv;
@@ -472,6 +488,7 @@ int ivpu_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
struct ivpu_job *job;
u32 *buf_handles;
int idx, ret;
+ u8 priority;
if (params->engine > DRM_IVPU_ENGINE_COPY)
return -EINVAL;
@@ -525,8 +542,10 @@ int ivpu_submit_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
goto err_destroy_job;
}
+ priority = ivpu_job_to_hws_priority(file_priv, params->priority);
+
down_read(&vdev->pm->reset_lock);
- ret = ivpu_job_submit(job);
+ ret = ivpu_job_submit(job, priority);
up_read(&vdev->pm->reset_lock);
if (ret)
goto err_signal_fence;
--
2.43.2
next prev parent reply other threads:[~2024-05-08 13:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-08 13:20 [PATCH 00/12] accel/ivpu: Changes for 6.10 Jacek Lawrynowicz
2024-05-08 13:20 ` [PATCH 01/12] accel/ivpu: Update VPU FW API headers Jacek Lawrynowicz
2024-05-10 16:27 ` Jeffrey Hugo
2024-05-08 13:20 ` [PATCH 02/12] accel/ivpu: Add sched_mode module param Jacek Lawrynowicz
2024-05-10 16:30 ` Jeffrey Hugo
2024-05-13 10:08 ` Jacek Lawrynowicz
2024-05-08 13:21 ` Jacek Lawrynowicz [this message]
2024-05-10 16:32 ` [PATCH 03/12] accel/ivpu: Create priority based command queues Jeffrey Hugo
2024-05-08 13:21 ` [PATCH 04/12] accel/ivpu: Implement support for preemption buffers Jacek Lawrynowicz
2024-05-10 16:36 ` Jeffrey Hugo
2024-05-08 13:21 ` [PATCH 05/12] accel/ivpu: Add HWS JSM messages Jacek Lawrynowicz
2024-05-10 16:38 ` Jeffrey Hugo
2024-05-08 13:21 ` [PATCH 06/12] accel/ivpu: Implement support for hardware scheduler Jacek Lawrynowicz
2024-05-10 16:41 ` Jeffrey Hugo
2024-05-13 10:10 ` Jacek Lawrynowicz
2024-05-08 13:21 ` [PATCH 07/12] accel/ivpu: Add resume engine support Jacek Lawrynowicz
2024-05-10 16:42 ` Jeffrey Hugo
2024-05-13 10:11 ` Jacek Lawrynowicz
2024-05-08 13:21 ` [PATCH 08/12] accel/ivpu: Add NPU profiling support Jacek Lawrynowicz
2024-05-10 16:46 ` Jeffrey Hugo
2024-05-13 10:12 ` Jacek Lawrynowicz
2024-05-08 13:21 ` [PATCH 09/12] accel/ivpu: Add force snoop module parameter Jacek Lawrynowicz
2024-05-10 16:47 ` Jeffrey Hugo
2024-05-08 13:28 ` [PATCH 10/12] accel/ivpu: Configure fw logging using debugfs Jacek Lawrynowicz
2024-05-08 13:29 ` [PATCH 11/12] accel/ivpu: Increase reset counter when warm boot fails Jacek Lawrynowicz
2024-05-10 16:49 ` Jeffrey Hugo
2024-05-08 13:29 ` [PATCH 12/12] accel/ivpu: Share NPU busy time in sysfs Jacek Lawrynowicz
2024-05-10 16:55 ` Jeffrey Hugo
2024-05-13 10:22 ` Jacek Lawrynowicz
2024-05-13 10:45 ` Tvrtko Ursulin
2024-05-13 11:39 ` Jacek Lawrynowicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240508132106.2387464-4-jacek.lawrynowicz@linux.intel.com \
--to=jacek.lawrynowicz@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=karol.wachowski@intel.com \
--cc=oded.gabbay@gmail.com \
--cc=quic_jhugo@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).