All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Use a dedicated workqueue for VM rebinds
@ 2026-10-19 23:01 Jia Yao
  2026-10-19 23:10 ` ✓ CI.KUnit: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jia Yao @ 2026-10-19 23:01 UTC (permalink / raw)
  To: intel-xe; +Cc: Thomas Hellström, Matthew Brost, Jia Yao

VM rebind workers may block while handling HMM faults or waiting for VM
fences. Running them on ordered_wq can stall user-fence notifications
and VM TLB timeout work queued behind them, preventing forward progress.

Move rebind workers to a dedicated ordered workqueue. This keeps rebinds
serialized across VMs while allowing fence-related work to run
independently.

Signed-off-by: Jia Yao <jia.yao@intel.com>
---
 drivers/gpu/drm/xe/xe_device.c       | 12 +++++++++++-
 drivers/gpu/drm/xe/xe_device_types.h |  5 ++++-
 drivers/gpu/drm/xe/xe_vm.c           |  2 +-
 drivers/gpu/drm/xe/xe_vm.h           |  2 +-
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index db0b883322ef..f1dd4b7842a9 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -385,6 +385,9 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy)
 	if (xe->preempt_fence_wq)
 		destroy_workqueue(xe->preempt_fence_wq);
 
+	if (xe->rebind_wq)
+		destroy_workqueue(xe->rebind_wq);
+
 	if (xe->ordered_wq)
 		destroy_workqueue(xe->ordered_wq);
 
@@ -515,9 +518,16 @@ int xe_device_init_early(struct xe_device *xe)
 	xe->preempt_fence_wq = alloc_ordered_workqueue("xe-preempt-fence-wq",
 						       WQ_MEM_RECLAIM);
 	xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0);
+	/*
+	 * Rebinding can block in HMM or wait for VM fences. Keep it off the
+	 * queue serving user-fence notifications and VM TLB fence timeouts,
+	 * which must be able to make progress while a rebind is waiting.
+	 * Preserve serialization between rebind workers on different VMs.
+	 */
+	xe->rebind_wq = alloc_ordered_workqueue("xe-rebind-wq", 0);
 	xe->unordered_wq = alloc_workqueue("xe-unordered-wq", WQ_PERCPU, 0);
 	xe->destroy_wq = alloc_workqueue("xe-destroy-wq", WQ_PERCPU | WQ_MEM_RECLAIM, 0);
-	if (!xe->ordered_wq || !xe->unordered_wq ||
+	if (!xe->ordered_wq || !xe->rebind_wq || !xe->unordered_wq ||
 	    !xe->preempt_fence_wq || !xe->destroy_wq) {
 		/*
 		 * Cleanup done in xe_device_destroy via
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 5553415afeaf..705c487e3c6f 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -387,9 +387,12 @@ struct xe_device {
 	/** @preempt_fence_wq: used to serialize preempt fences */
 	struct workqueue_struct *preempt_fence_wq;
 
-	/** @ordered_wq: used to serialize compute mode resume */
+	/** @ordered_wq: ordered user-fence and VM TLB timeout work */
 	struct workqueue_struct *ordered_wq;
 
+	/** @rebind_wq: serializes compute mode rebinds and resume */
+	struct workqueue_struct *rebind_wq;
+
 	/** @unordered_wq: used to serialize unordered work */
 	struct workqueue_struct *unordered_wq;
 
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index e7f421a43516..88b4f6b19fdd 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -501,7 +501,7 @@ static bool vm_suspend_rebind_worker(struct xe_vm *vm)
  */
 void xe_vm_resume_rebind_worker(struct xe_vm *vm)
 {
-	queue_work(vm->xe->ordered_wq, &vm->preempt.rebind_work);
+	xe_vm_queue_rebind_worker(vm);
 }
 
 static void preempt_rebind_work_func(struct work_struct *w)
diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
index 06138c3c4315..25c8760e2392 100644
--- a/drivers/gpu/drm/xe/xe_vm.h
+++ b/drivers/gpu/drm/xe/xe_vm.h
@@ -259,7 +259,7 @@ int xe_vm_validate_protected(struct xe_vm *vm);
 static inline void xe_vm_queue_rebind_worker(struct xe_vm *vm)
 {
 	xe_assert(vm->xe, xe_vm_in_preempt_fence_mode(vm));
-	queue_work(vm->xe->ordered_wq, &vm->preempt.rebind_work);
+	queue_work(vm->xe->rebind_wq, &vm->preempt.rebind_work);
 }
 
 /**
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-21  5:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 23:01 [PATCH] drm/xe: Use a dedicated workqueue for VM rebinds Jia Yao
2026-10-19 23:10 ` ✓ CI.KUnit: success for " Patchwork
2026-10-20  0:01 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-20  3:05 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-10-20 16:34 ` [PATCH] " Matthew Brost
2026-10-21  5:04   ` Yao, Jia

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.