summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHonglei Huang <honghuan@amd.com>2026-09-05 21:31:37 +0800
committerMatthew Brost <matthew.brost@intel.com>2026-09-07 22:43:55 -0700
commitca76137442edcafc089f19d189a55dc8d42ff7b8 (patch)
tree9febea6e42a394a60e081bf597fb29626fb27371
parentfcc2431d2213dc4d04250c4f1ae87d9c3ae0d455 (diff)
downloadlinux-next-ca76137442edcafc089f19d189a55dc8d42ff7b8.tar.gz
linux-next-ca76137442edcafc089f19d189a55dc8d42ff7b8.zip
drm/gpusvm: move dma_addr allocation before the notifier lock
The dma_addr allocation was in a lazy allocation flow, it needs unlock and goto map_pages. The allocation only needs npages, so just do it before taking the lock. Drop the map_pages label and the relock flow, so the sequence becomes fault, allocate, then lock, validate, map and unlock. No functional change intended. Reviewed-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Honglei Huang <honghuan@amd.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20260905133142.3628027-2-honghuan@amd.com
-rw-r--r--drivers/gpu/drm/drm_gpusvm.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
index a93eee7ddb9e..b507de539e67 100644
--- a/drivers/gpu/drm/drm_gpusvm.c
+++ b/drivers/gpu/drm/drm_gpusvm.c
@@ -1516,10 +1516,18 @@ retry:
if (err)
goto err_free;
+ if (!svm_pages->dma_addr) {
+ svm_pages->dma_addr =
+ kvzalloc_objs(*svm_pages->dma_addr, npages);
+ if (!svm_pages->dma_addr) {
+ err = -ENOMEM;
+ goto err_free;
+ }
+ }
+
*state = (struct dma_iova_state){};
svm_pages->state_offset = 0;
-map_pages:
/*
* Perform all dma mappings under the notifier lock to not
* access freed pages. A notifier will either block on
@@ -1540,18 +1548,6 @@ map_pages:
goto retry;
}
- if (!svm_pages->dma_addr) {
- /* Unlock and restart mapping to allocate memory. */
- drm_gpusvm_notifier_unlock(gpusvm);
- svm_pages->dma_addr =
- kvzalloc_objs(*svm_pages->dma_addr, npages);
- if (!svm_pages->dma_addr) {
- err = -ENOMEM;
- goto err_free;
- }
- goto map_pages;
- }
-
zdd = NULL;
pagemap = NULL;
num_dma_mapped = 0;