Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Hold VM reference in preempt rebind worker
@ 2026-11-30 10:28 Tejas Upadhyay
  2026-11-30 10:36 ` ✗ CI.checkpatch: warning for " Patchwork
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tejas Upadhyay @ 2026-11-30 10:28 UTC (permalink / raw)
  To: intel-xe; +Cc: matthew.brost, Tejas Upadhyay

vm_destroy_work_func() runs on a WQ_MEM_RECLAIM workqueue and currently
flushes vm->preempt.rebind_work, which is queued on the non-reclaim
rebind_wq. This triggers a workqueue flush dependency warning:

  workqueue: WQ_MEM_RECLAIM xe-destroy-wq:vm_destroy_work_func [xe] is flushing !WQ_MEM_RECLAIM xe-ordered-wq:preempt_rebind_work_func [xe]
  WARNING: kernel/workqueue.c:3921 at check_flush_dependency.part.0+0xd9/0x110

Take a VM reference when queuing vm->preempt.rebind_work and drop it
when preempt_rebind_work_func() exits. Since the VM cannot be destroyed
while rebind_work is pending or running, drop the redundant flush_work()
from vm_destroy_work_func().

Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
---
 drivers/gpu/drm/xe/xe_vm.c | 11 +++++------
 drivers/gpu/drm/xe/xe_vm.h |  5 +++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index ab138d495f3f..547d2c2980a7 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -586,14 +586,14 @@ static void preempt_rebind_work_func(struct work_struct *w)
 	if (xe_vm_is_closed_or_banned(vm)) {
 		up_write(&vm->lock);
 		trace_xe_vm_rebind_worker_exit(vm);
-		return;
+		goto out_put_vm;
 	}
 
 	if (!try_wait_for_completion(&vm->xe->pm_block) && vm_suspend_rebind_worker(vm)) {
 		up_write(&vm->lock);
 		/* We don't actually block but don't make progress. */
 		xe_pm_might_block_on_suspend();
-		return;
+		goto out_put_vm;
 	}
 
 	if (xe_vm_userptr_check_repin(vm)) {
@@ -669,7 +669,7 @@ static void preempt_rebind_work_func(struct work_struct *w)
 		free_preempt_fences(&preempt_fences);
 		xe_vm_queue_rebind_worker(vm);
 		trace_xe_vm_rebind_worker_exit(vm);
-		return;
+		goto out_put_vm;
 	}
 
 	xe_vm_rebind_worker_reset_inject(vm);
@@ -683,6 +683,8 @@ static void preempt_rebind_work_func(struct work_struct *w)
 	free_preempt_fences(&preempt_fences);
 
 	trace_xe_vm_rebind_worker_exit(vm);
+out_put_vm:
+	xe_vm_put(vm);
 }
 
 /**
@@ -2109,9 +2111,6 @@ static void vm_destroy_work_func(struct work_struct *w)
 	/* xe_vm_close_and_put was not called? */
 	xe_assert(xe, !vm->size);
 
-	if (xe_vm_in_preempt_fence_mode(vm))
-		flush_work(&vm->preempt.rebind_work);
-
 	mutex_destroy(&vm->snap_mutex);
 
 	if (vm->flags & XE_VM_FLAG_LR_MODE)
diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
index ed590bad892c..1917deca4679 100644
--- a/drivers/gpu/drm/xe/xe_vm.h
+++ b/drivers/gpu/drm/xe/xe_vm.h
@@ -262,8 +262,9 @@ 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_node(dev_to_node(vm->xe->drm.dev), vm->xe->rebind_wq,
-			&vm->preempt.rebind_work);
+	if (queue_work_node(dev_to_node(vm->xe->drm.dev), vm->xe->rebind_wq,
+			    &vm->preempt.rebind_work))
+		xe_vm_get(vm);
 }
 
 /**
-- 
2.52.0


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

end of thread, other threads:[~2026-11-30 22:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 10:28 [PATCH] drm/xe: Hold VM reference in preempt rebind worker Tejas Upadhyay
2026-11-30 10:36 ` ✗ CI.checkpatch: warning for " Patchwork
2026-11-30 10:38 ` ✓ CI.KUnit: success " Patchwork
2026-11-30 10:45 ` [PATCH] " sashiko-bot
2026-11-30 11:26 ` ✗ Xe.CI.BAT: failure for " Patchwork
2026-11-30 15:45 ` ✗ Xe.CI.FULL: " Patchwork
2026-11-30 22:37 ` [PATCH] " Matthew Brost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox