summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLizhi Hou <lizhi.hou@amd.com>2026-09-11 09:39:07 -0700
committerLizhi Hou <lizhi.hou@amd.com>2026-09-17 09:04:48 -0700
commit5eee433b5c97821979e7de58476dc245ee168d89 (patch)
treec2e2a278f24b0faa102c1cdc68cb5be009603174
parent217da5aaf95e7c5a73b314095b709c40525c6b46 (diff)
downloadlinux-next-5eee433b5c97821979e7de58476dc245ee168d89.tar.gz
linux-next-5eee433b5c97821979e7de58476dc245ee168d89.zip
accel/amdxdna: Fully initialize map structure before registering notifier
The map structure is currently only partially initialized when the notifier is registered. Although holding mmap_write_lock() prevents the notifier callback from running before the remaining initialization is complete, the ordering can be confusing during code review. Fully initialize the map structure before registering the notifier so that the structure is completely constructed before it is published. Reviewed-by: Max Zhen <max.zhen@amd.com> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com> Link: https://patch.msgid.link/20260911163907.1193852-1-lizhi.hou@amd.com
-rw-r--r--drivers/accel/amdxdna/amdxdna_gem.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index 5a1a2ee261b7..e861db6f9369 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -415,6 +415,15 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
goto free_map;
}
+ mapp->range.notifier = &mapp->notifier;
+ mapp->range.start = vma->vm_start;
+ mapp->range.end = vma->vm_end;
+ mapp->range.default_flags = HMM_PFN_REQ_FAULT;
+ mapp->abo = abo;
+ kref_init(&mapp->refcnt);
+
+ INIT_WORK(&mapp->hmm_unreg_work, amdxdna_hmm_unreg_work);
+
ret = mmu_interval_notifier_insert_locked(&mapp->notifier,
current->mm,
addr,
@@ -425,15 +434,6 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
goto free_pfns;
}
- mapp->range.notifier = &mapp->notifier;
- mapp->range.start = vma->vm_start;
- mapp->range.end = vma->vm_end;
- mapp->range.default_flags = HMM_PFN_REQ_FAULT;
- mapp->abo = abo;
- kref_init(&mapp->refcnt);
-
- INIT_WORK(&mapp->hmm_unreg_work, amdxdna_hmm_unreg_work);
-
down_write(&xdna->notifier_lock);
if (list_empty(&abo->mem.umap_list))
abo->mem.uva = addr;