From: Stuart Summers <stuart.summers@intel.com>
Cc: michal.wajdeczko@intel.com, ilia.levi@intel.com,
x.wang@intel.com, rodrigo.vivi@intel.com,
intel-xe@lists.freedesktop.org,
alan.previn.teres.alexis@intel.com,
Stuart Summers <stuart.summers@intel.com>
Subject: [PATCH 11/12] drm/xe: Enable per-queue ufence wake in ioctl and wake function
Date: Fri, 5 Jun 2026 23:21:18 +0000 [thread overview]
Message-ID: <20260605232108.674580-25-stuart.summers@intel.com> (raw)
In-Reply-To: <20260605232108.674580-14-stuart.summers@intel.com>
Hook up the per-exec-queue user fence wait queue infrastructure
introduced in the previous patches:
- xe_wait_user_fence_wake(): if a specific user exec queue is supplied
(non-NULL, still alive), wake only that queue's ufence_wq. If no
queue is supplied (default MSI-X vector), broadcast to xe->ufence_wq
and every queue in ufence_list so no waiter is missed. Kernel queues
always use the default MSI-X vector and pass NULL, so any non-NULL @q
here is guaranteed to be a user queue.
- xe_wait_user_fence_ioctl(): add and remove the wait entry on the
per-queue ufence_wq when a queue is provided, falling back to the
device-level ufence_wq otherwise.
Signed-off-by: Stuart Summers <stuart.summers@intel.com>
Assisted-by: Copilot:claude-sonnet-4.6
---
drivers/gpu/drm/xe/xe_wait_user_fence.c | 44 +++++++++++++++++++------
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c b/drivers/gpu/drm/xe/xe_wait_user_fence.c
index 7c9d52b50580..1c14d89dff43 100644
--- a/drivers/gpu/drm/xe/xe_wait_user_fence.c
+++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c
@@ -57,15 +57,39 @@ static int do_compare(u64 addr, u64 value, u64 mask, u16 op)
/**
* xe_wait_user_fence_wake() - Wake user fence waiters
* @xe: the xe device
- * @q: exec queue (reserved; per-queue wake-up is enabled in a later patch)
+ * @q: exec queue whose user fence wait queue to wake, or NULL
*
- * Wakes all user fence waiters on the device-level wait queue.
- * Per-exec-queue and ufence_list broadcast support are introduced in
- * subsequent patches once the full infrastructure is in place.
+ * If @q is non-NULL and still alive (a reference can be taken), wakes
+ * only that queue's per-queue wait queue. Kernel queues always use the
+ * default MSI-X vector, which passes NULL here, so any non-NULL @q is
+ * always a user queue.
+ *
+ * If @q is NULL (default MSI-X vector or sync path), wakes the device-level
+ * wait queue and every per-exec-queue wait queue in ufence_list to ensure
+ * no waiter is missed.
*/
void xe_wait_user_fence_wake(struct xe_device *xe, struct xe_exec_queue *q)
{
- wake_up_all(&xe->ufence_wq);
+ /*
+ * Take a reference on the queue to guard against it being freed
+ * concurrently. xe_exec_queue_get_unless_zero() handles a NULL @q,
+ * so callers that don't specify a queue fall through to the broadcast.
+ */
+ q = xe_exec_queue_get_unless_zero(q);
+ if (q) {
+ wake_up_all(&q->ufence_wq);
+ xe_exec_queue_put(q);
+ } else {
+ struct xe_exec_queue *iter;
+ unsigned long flags;
+
+ wake_up_all(&xe->ufence_wq);
+
+ spin_lock_irqsave(&xe->ufence_list_lock, flags);
+ list_for_each_entry(iter, &xe->ufence_list, ufence_link)
+ wake_up_all(&iter->ufence_wq);
+ spin_unlock_irqrestore(&xe->ufence_list_lock, flags);
+ }
}
static long to_jiffies_timeout(struct xe_device *xe,
@@ -122,9 +146,9 @@ static long to_jiffies_timeout(struct xe_device *xe,
* performed as (@addr & @mask) OP @value, where OP is one of the
* %DRM_XE_UFENCE_WAIT_OP_* operators.
*
- * If an exec queue ID is provided, the wait is aborted early if the
- * queue enters a reset state. The device-level wait queue is used for
- * wakeups in all cases.
+ * If an exec queue ID is provided, the wait is scoped to that queue's
+ * per-queue wait queue and the wait is aborted early if the queue enters
+ * a reset state. Otherwise the device-level wait queue is used.
*
* On return, @timeout is updated to reflect the remaining time (or zero
* on expiry), unless %DRM_XE_UFENCE_WAIT_FLAG_ABSTIME is set.
@@ -170,7 +194,7 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, void *data,
start = ktime_get();
- add_wait_queue(&xe->ufence_wq, &w_wait);
+ add_wait_queue(q ? &q->ufence_wq : &xe->ufence_wq, &w_wait);
for (;;) {
err = do_compare(addr, args->value, args->mask, args->op);
if (err <= 0)
@@ -203,7 +227,7 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, void *data,
timeout = wait_woken(&w_wait, TASK_INTERRUPTIBLE, timeout);
}
- remove_wait_queue(&xe->ufence_wq, &w_wait);
+ remove_wait_queue(q ? &q->ufence_wq : &xe->ufence_wq, &w_wait);
if (!(args->flags & DRM_XE_UFENCE_WAIT_FLAG_ABSTIME)) {
args->timeout -= ktime_to_ns(ktime_sub(ktime_get(), start));
--
2.43.0
next prev parent reply other threads:[~2026-06-05 23:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 23:21 [PATCH 00/12] Enable per exec queue MSI-X vector assignment Stuart Summers
2026-06-05 23:21 ` [PATCH 01/12] drm/xe: Add kerneldoc to xe_wait_user_fence_ioctl() Stuart Summers
2026-06-05 23:21 ` [PATCH 02/12] drm/xe: Handle NULL in xe_exec_queue_get_unless_zero() Stuart Summers
2026-06-05 23:21 ` [PATCH 03/12] drm/xe: Cap MSI-X vector count to XE_MSIX_MAX_VECS Stuart Summers
2026-06-05 23:21 ` [PATCH 04/12] drm/xe: Assign dedicated MSI-X vectors to exec queues Stuart Summers
2026-06-05 23:21 ` [PATCH 05/12] drm/xe: Add configfs max_msix_vecs attribute Stuart Summers
2026-06-05 23:21 ` [PATCH 06/12] drm/xe: Change MSI-X assignment failure to drm_dbg Stuart Summers
2026-06-06 10:57 ` Michal Wajdeczko
2026-06-08 20:30 ` Summers, Stuart
2026-06-09 19:54 ` Summers, Stuart
2026-06-05 23:21 ` [PATCH 07/12] drm/xe: Remove memirq status and source checks for engine interrupts Stuart Summers
2026-06-06 11:18 ` Michal Wajdeczko
2026-06-09 19:38 ` Summers, Stuart
2026-06-09 21:29 ` Michal Wajdeczko
2026-06-09 22:12 ` Summers, Stuart
2026-06-05 23:21 ` [PATCH 08/12] drm/xe: Add per-exec-queue user fence wait queue Stuart Summers
2026-06-05 23:21 ` [PATCH 09/12] drm/xe: Track all exec queues in a device-level ufence list Stuart Summers
2026-06-05 23:21 ` [PATCH 10/12] drm/xe: Hook up per queue thread wake to the unique MSI-X vector allocation Stuart Summers
2026-06-05 23:21 ` Stuart Summers [this message]
2026-06-05 23:21 ` [PATCH 12/12] drm/xe/memirq: Enable compute walker post-sync interrupt Stuart Summers
2026-06-05 23:47 ` ✗ CI.checkpatch: warning for Enable per exec queue MSI-X vector assignment Patchwork
2026-06-05 23:49 ` ✓ CI.KUnit: success " Patchwork
2026-06-06 0:43 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-06 13:27 ` ✓ Xe.CI.FULL: " Patchwork
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=20260605232108.674580-25-stuart.summers@intel.com \
--to=stuart.summers@intel.com \
--cc=alan.previn.teres.alexis@intel.com \
--cc=ilia.levi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=x.wang@intel.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