* [PATCH V1] accel/amdxdna: Use vma->vm_mm consistently in amdxdna_hmm_register()
@ 2026-11-06 20:35 Lizhi Hou
2026-11-06 20:45 ` Max Zhen
0 siblings, 1 reply; 2+ messages in thread
From: Lizhi Hou @ 2026-11-06 20:35 UTC (permalink / raw)
To: ogabbay, quic_jhugo, dri-devel, mario.limonciello,
karol.wachowski, max.zhen
Cc: Lizhi Hou, linux-kernel, sonal.santan
amdxdna_hmm_register() keys the umap list lookup and the interval
notifier insertion on current->mm, while amdxdna_hmm_unregister() and
amdxdna_mark_mapp_invalid() match the same list entries against
vma->vm_mm. The two are identical for the ->mmap() callback, so this is
not a functional change, but the inconsistency makes the code harder to
follow.
Use vma->vm_mm in both places. It is the mm whose mmap_lock is held
across ->mmap(), which is what mmu_interval_notifier_insert_locked()
asserts on, and it is the mm the teardown paths look the mapping up by.
Assisted-by: LLM
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
drivers/accel/amdxdna/amdxdna_gem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index 09e48c794e1b..92125bc753c7 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -443,7 +443,7 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
down_read(&xdna->notifier_lock);
list_for_each_entry(mapp, &abo->mem.umap_list, node) {
- if (compare_range(mapp, current->mm, addr, addr + len)) {
+ if (compare_range(mapp, vma->vm_mm, addr, addr + len)) {
up_read(&xdna->notifier_lock);
return 0;
}
@@ -477,7 +477,7 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
kref_init(&mapp->refcnt);
ret = mmu_interval_notifier_insert_locked(&mapp->notifier,
- current->mm,
+ vma->vm_mm,
addr,
len,
&amdxdna_hmm_ops);
base-commit: d2a8cee91bfa8616f713c7c8f539a81e8e3554ea
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH V1] accel/amdxdna: Use vma->vm_mm consistently in amdxdna_hmm_register()
2026-11-06 20:35 [PATCH V1] accel/amdxdna: Use vma->vm_mm consistently in amdxdna_hmm_register() Lizhi Hou
@ 2026-11-06 20:45 ` Max Zhen
0 siblings, 0 replies; 2+ messages in thread
From: Max Zhen @ 2026-11-06 20:45 UTC (permalink / raw)
To: Lizhi Hou, ogabbay, quic_jhugo, dri-devel, mario.limonciello,
karol.wachowski
Cc: linux-kernel, sonal.santan
On 11/6/2026 Fri 12:35, Lizhi Hou wrote:
> amdxdna_hmm_register() keys the umap list lookup and the interval
> notifier insertion on current->mm, while amdxdna_hmm_unregister() and
> amdxdna_mark_mapp_invalid() match the same list entries against
> vma->vm_mm. The two are identical for the ->mmap() callback, so this is
> not a functional change, but the inconsistency makes the code harder to
> follow.
>
> Use vma->vm_mm in both places. It is the mm whose mmap_lock is held
> across ->mmap(), which is what mmu_interval_notifier_insert_locked()
> asserts on, and it is the mm the teardown paths look the mapping up by.
>
> Assisted-by: LLM
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Max Zhen <max.zhen@amd.com>
> ---
> drivers/accel/amdxdna/amdxdna_gem.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index 09e48c794e1b..92125bc753c7 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -443,7 +443,7 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
>
> down_read(&xdna->notifier_lock);
> list_for_each_entry(mapp, &abo->mem.umap_list, node) {
> - if (compare_range(mapp, current->mm, addr, addr + len)) {
> + if (compare_range(mapp, vma->vm_mm, addr, addr + len)) {
> up_read(&xdna->notifier_lock);
> return 0;
> }
> @@ -477,7 +477,7 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
> kref_init(&mapp->refcnt);
>
> ret = mmu_interval_notifier_insert_locked(&mapp->notifier,
> - current->mm,
> + vma->vm_mm,
> addr,
> len,
> &amdxdna_hmm_ops);
>
> base-commit: d2a8cee91bfa8616f713c7c8f539a81e8e3554ea
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-06 20:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 20:35 [PATCH V1] accel/amdxdna: Use vma->vm_mm consistently in amdxdna_hmm_register() Lizhi Hou
2026-11-06 20:45 ` Max Zhen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®