From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: tejas.upadhyay@intel.com, paulo.r.zanoni@intel.com,
maarten.lankhorst@linux.intel.com
Subject: [PATCH] drm/xe: Prime userptr notifier lock with reclaim
Date: Fri, 26 Jul 2024 14:53:22 -0700 [thread overview]
Message-ID: <20240726215322.2108865-1-matthew.brost@intel.com> (raw)
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
next reply other threads:[~2024-07-26 21:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 21:53 Matthew Brost [this message]
2024-07-26 22:00 ` ✓ CI.Patch_applied: success for drm/xe: Prime userptr notifier lock with reclaim 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
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=20240726215322.2108865-1-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=paulo.r.zanoni@intel.com \
--cc=tejas.upadhyay@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox