All of lore.kernel.org
 help / color / mirror / Atom feed
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 09/12] drm/xe: Track all exec queues in a device-level ufence list
Date: Fri,  5 Jun 2026 23:21:16 +0000	[thread overview]
Message-ID: <20260605232108.674580-23-stuart.summers@intel.com> (raw)
In-Reply-To: <20260605232108.674580-14-stuart.summers@intel.com>

Add ufence_link to struct xe_exec_queue and maintain a device-level
ufence_list (protected by ufence_list_lock) so the default MSI-X vector
handler can reach every queue's per-queue wait queue.

As mentioned in a prior patch that adds the per queue wait queue,
we can't guarantee userspace will pass something appropriate in
the wait user fence ioctl. And in fact I have found cases in IGT
where it does not - basically it issues a VM bind without a bind
exec queue and then adds a non-bind queue to the wait user fence
call. Of course I'd argue this is a test bug, but also we want
to avoid any large regressions from the UAPI perspective, so
this ufence list is used to walk through all potential per exec queue
wait queues users might have pending to make sure we wake all of
them up if we get an MSI-X interrupt in without a corresponding
exec queue.

Note that actually hooking up the wait user fence piece of this
is deferred to a later patch.

Signed-off-by: Stuart Summers <stuart.summers@intel.com>
Assisted-by: Copilot:claude-sonnet-4.6
---
 drivers/gpu/drm/xe/xe_device.c           |  2 ++
 drivers/gpu/drm/xe/xe_device_types.h     |  6 ++++++
 drivers/gpu/drm/xe/xe_exec_queue.c       | 12 ++++++++++++
 drivers/gpu/drm/xe/xe_exec_queue_types.h |  3 +++
 4 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 51e3a2dd7b22..a0fabeabc9d7 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -549,6 +549,8 @@ int xe_device_init_early(struct xe_device *xe)
 	xe_validation_device_init(&xe->val);
 
 	init_waitqueue_head(&xe->ufence_wq);
+	spin_lock_init(&xe->ufence_list_lock);
+	INIT_LIST_HEAD(&xe->ufence_list);
 
 	init_rwsem(&xe->usm.lock);
 
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index ff15de34fd17..bf421d8cd0b1 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -351,6 +351,12 @@ struct xe_device {
 	/** @ufence_wq: user fence wait queue */
 	wait_queue_head_t ufence_wq;
 
+	/** @ufence_list_lock: protects @ufence_list */
+	spinlock_t ufence_list_lock;
+
+	/** @ufence_list: list of all exec queues for default-vector ufence wake */
+	struct list_head ufence_list;
+
 	/** @preempt_fence_wq: used to serialize preempt fences */
 	struct workqueue_struct *preempt_fence_wq;
 
diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c
index aa49400b67ba..31597aac3025 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue.c
+++ b/drivers/gpu/drm/xe/xe_exec_queue.c
@@ -169,8 +169,14 @@ static void exec_queue_msix_fini(struct xe_exec_queue *q)
 
 static void __xe_exec_queue_free(struct xe_exec_queue *q)
 {
+	struct xe_device *xe = gt_to_xe(q->gt);
+	unsigned long irq_flags;
 	int i;
 
+	spin_lock_irqsave(&xe->ufence_list_lock, irq_flags);
+	list_del_init(&q->ufence_link);
+	spin_unlock_irqrestore(&xe->ufence_list_lock, irq_flags);
+
 	for (i = 0; i < XE_EXEC_QUEUE_TLB_INVAL_COUNT; ++i)
 		if (q->tlb_inval[i].dep_scheduler)
 			xe_dep_scheduler_fini(q->tlb_inval[i].dep_scheduler);
@@ -236,6 +242,7 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,
 {
 	struct xe_exec_queue *q;
 	struct xe_gt *gt = hwe->gt;
+	unsigned long irq_flags;
 	int err;
 
 	/* only kernel queues can be permanent */
@@ -260,7 +267,12 @@ static struct xe_exec_queue *__xe_exec_queue_alloc(struct xe_device *xe,
 	INIT_LIST_HEAD(&q->multi_gt_link);
 	INIT_LIST_HEAD(&q->hw_engine_group_link);
 	INIT_LIST_HEAD(&q->pxp.link);
+	INIT_LIST_HEAD(&q->ufence_link);
 	init_waitqueue_head(&q->ufence_wq);
+
+	spin_lock_irqsave(&xe->ufence_list_lock, irq_flags);
+	list_add(&q->ufence_link, &xe->ufence_list);
+	spin_unlock_irqrestore(&xe->ufence_list_lock, irq_flags);
 	spin_lock_init(&q->multi_queue.lock);
 	spin_lock_init(&q->lrc_lookup_lock);
 	q->multi_queue.priority = XE_MULTI_QUEUE_PRIORITY_NORMAL;
diff --git a/drivers/gpu/drm/xe/xe_exec_queue_types.h b/drivers/gpu/drm/xe/xe_exec_queue_types.h
index edd2ecc8a27c..1cd2dc055b81 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue_types.h
+++ b/drivers/gpu/drm/xe/xe_exec_queue_types.h
@@ -234,6 +234,9 @@ struct xe_exec_queue {
 	/** @ufence_wq: per-queue user fence wait queue */
 	wait_queue_head_t ufence_wq;
 
+	/** @ufence_link: link into xe_device.ufence_list for default-vector wake */
+	struct list_head ufence_link;
+
 	/** @ufence_syncobj: User fence syncobj */
 	struct drm_syncobj *ufence_syncobj;
 
-- 
2.43.0


  parent reply	other threads:[~2026-06-05 23:21 UTC|newest]

Thread overview: 20+ 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-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-05 23:21 ` [PATCH 08/12] drm/xe: Add per-exec-queue user fence wait queue Stuart Summers
2026-06-05 23:21 ` Stuart Summers [this message]
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 ` [PATCH 11/12] drm/xe: Enable per-queue ufence wake in ioctl and wake function Stuart Summers
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-23-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.