[PATCH] drm/xe: Prime userptr notifier lock with reclaim
Matthew Brost
matthew.brost at intel.com
Fri Jul 26 21:53:22 UTC 2024
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 at 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
More information about the Intel-xe
mailing list