Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Prime userptr notifier lock with reclaim
@ 2024-07-26 21:53 Matthew Brost
  2024-07-26 22:00 ` ✓ CI.Patch_applied: success for " Patchwork
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Matthew Brost @ 2024-07-26 21:53 UTC (permalink / raw)
  To: intel-xe; +Cc: tejas.upadhyay, paulo.r.zanoni, maarten.lankhorst

The userptr notifier lock is in the path of reclaim as it is taken in a
MMU notifier which is in the path of reclaim. Prime lockdep with this
annotation making it clear memory allocations are not allowed under the
userptr notifier lock.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_vm.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 12d43c35978c..b500cb862342 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -1374,6 +1374,18 @@ static void xe_vm_free_scratch(struct xe_vm *vm)
 	}
 }
 
+static void xe_vm_userptr_notifier_lock_init(struct xe_vm *vm)
+{
+	init_rwsem(&vm->userptr.notifier_lock);
+
+	if (!IS_ENABLED(CONFIG_LOCKDEP))
+		return;
+
+	fs_reclaim_acquire(GFP_KERNEL);
+	might_lock(&vm->userptr.notifier_lock);
+	fs_reclaim_release(GFP_KERNEL);
+}
+
 struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
 {
 	struct drm_gem_object *vm_resv_obj;
@@ -1399,7 +1411,7 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags)
 
 	INIT_LIST_HEAD(&vm->userptr.repin_list);
 	INIT_LIST_HEAD(&vm->userptr.invalidated);
-	init_rwsem(&vm->userptr.notifier_lock);
+	xe_vm_userptr_notifier_lock_init(vm);
 	spin_lock_init(&vm->userptr.invalidated_lock);
 
 	INIT_WORK(&vm->destroy_work, vm_destroy_work_func);
-- 
2.34.1


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

end of thread, other threads:[~2024-07-27 10:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26 21:53 [PATCH] drm/xe: Prime userptr notifier lock with reclaim Matthew Brost
2024-07-26 22:00 ` ✓ CI.Patch_applied: success for " Patchwork
2024-07-26 22:00 ` ✓ CI.checkpatch: " Patchwork
2024-07-26 22:02 ` ✓ CI.KUnit: " Patchwork
2024-07-26 22:17 ` ✓ CI.Build: " Patchwork
2024-07-26 22:20 ` ✓ CI.Hooks: " Patchwork
2024-07-26 22:21 ` ✓ CI.checksparse: " Patchwork
2024-07-26 22:49 ` ✓ CI.BAT: " Patchwork
2024-07-27 10:08 ` ✓ CI.FULL: " Patchwork

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