drm/msm: fix msm_gem_vma_new() allocations for managed GPUVMs
PATCH 1/1 drm/msm: fix msm_gem_vma_new() allocations for managed GPUVMs
Since commit 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()") MSM driver fails to init, failing with "[drm:msm_gpu_init] *ERROR* could not allocate memptrs: -22" errors. The mentioned commit reworked the function, but didn't take into account that op_map is initialized at the top of the function, while ranges might change if GPUVM is managed by the kernel.
Move op_mode initialization after finalizing all addresses and right before the drm_gpuva_init_from_op() call.
--- drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/msm_gem_vma.c +7 -6
@@ -368,12 +368,6 @@ struct drm_gpuva * msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, u64 offset, u64 range_start, u64 range_end) { - struct drm_gpuva_op_map op_map = { - .va.addr = range_start, - .va.range = range_end - range_start, - .gem.obj = obj, - .gem.offset = offset, - }; struct msm_gem_vm *vm = to_msm_vm(gpuvm);struct drm_gpuvm_bo *vm_bo;struct msm_gem_vma *vma;
@@ -402,6 +396,13 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,if (obj)GEM_WARN_ON ((range_end - range_start) > obj->size); +struct drm_gpuva_op_map op_map = { + .va.addr = range_start, + .va.range = range_end - range_start, + .gem.obj = obj, + .gem.offset = offset, + }; +drm_gpuva_init_from_op (&vma->base, &op_map); vma->mapped = false;
---
base-commit: 0f4c93f7eb861acab537dbe94441817a270537bf
change-id: 20250823-msm-fix-gpuvm-init-520d87ebcf26
Best regards,
Signature · 2 lines
With best wishes Dmitry
Quoted 37 lines · Dmitry Baryshkov
Since commit
3309323241fb("drm/gpuvm: Killdrm_gpuva_init()") MSM driver fails to init, failing with "[drm:msm_gpu_init] *ERROR* could not allocate memptrs: -22" errors. The mentioned commit reworked the function, but didn't take into account thatop_mapis initialized at the top of the function, while ranges might change if GPUVM is managed by the kernel.Move
op_modeinitialization after finalizing all addresses and right before thedrm_gpuva_init_from_op()call.Reported-by Danct12 <[email protected]>Fixes 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()")Suggested-by Rob Clark <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)drivers/gpu/drm/msm/msm_gem_vma.c +0
-6@@ -368,12 +368,6 @@ struct drm_gpuva * msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, u64 offset, u64 range_start, u64 range_end) { - struct drm_gpuva_op_map op_map = { - .va.addr = range_start, - .va.range = range_end - range_start, - .gem.obj = obj, - .gem.offset = offset, - }; struct msm_gem_vm *vm = to_msm_vm(gpuvm);struct drm_gpuvm_bo *vm_bo;struct msm_gem_vma *vma;
drivers/gpu/drm/msm/msm_gem_vma.c msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, · line 404
Quoted 9 lines
drivers/gpu/drm/msm/msm_gem_vma.c +6
-0@@ -402,6 +396,13 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,if (obj)GEM_WARN_ON ((range_end - range_start) > obj->size); +struct drm_gpuva_op_map op_map = { + .va.addr = range_start, + .va.range = range_end - range_start, + .gem.obj = obj, + .gem.offset = offset, + };
Thanks,
Quoted 14 lines
drivers/gpu/drm/msm/msm_gem_vma.c +1
-1+drm_gpuva_init_from_op (&vma->base, &op_map); vma->mapped = false; ---base-commit:
0f4c93f7eb861acab537dbe94441817a270537bf
change-id: 20250823-msm-fix-gpuvm-init-520d87ebcf26Best regards,
--
With best wishes
Dmitry
Quoted 22 lines · Rob Clark
Quoted 11 lines · Dmitry Baryshkov
Since commit
3309323241fb("drm/gpuvm: Killdrm_gpuva_init()") MSM driver fails to init, failing with "[drm:msm_gpu_init] *ERROR* could not allocate memptrs: -22" errors. The mentioned commit reworked the function, but didn't take into account thatop_mapis initialized at the top of the function, while ranges might change if GPUVM is managed by the kernel.Move
op_modeinitialization after finalizing all addresses and right before thedrm_gpuva_init_from_op()call.Quoted 8 lines
Reported-by Danct12 <[email protected]>Fixes 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()")Suggested-by Rob Clark <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
Quoted 3 lines
Thanks,
Reviewed-by Rob Clark <[email protected]>
I'll also need Acked-by to merge through drm-misc-next, where the offending commit is.
Signature · 2 lines
With best wishes Dmitry
Rob Clark
Acked-byQuoted 24 lines · Dmitry Baryshkov
Quoted 22 lines · Rob Clark
Quoted 19 lines · Dmitry Baryshkov
Since commit
3309323241fb("drm/gpuvm: Killdrm_gpuva_init()") MSM driver fails to init, failing with "[drm:msm_gpu_init] *ERROR* could not allocate memptrs: -22" errors. The mentioned commit reworked the function, but didn't take into account thatop_mapis initialized at the top of the function, while ranges might change if GPUVM is managed by the kernel.Move
op_modeinitialization after finalizing all addresses and right before thedrm_gpuva_init_from_op()call.Reported-by Danct12 <[email protected]>Fixes 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()")Suggested-by Rob Clark <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
Quoted 7 lines
Quoted 3 lines
Thanks,
Reviewed-by Rob Clark <[email protected]>I'll also need Acked-by to merge through drm-misc-next, where the offending commit is.
Quoted 4 lines
--
With best wishes
Dmitry
Dmitry Baryshkov
AppliedQuoted 8 lines · Dmitry Baryshkov
Since commit
3309323241fb("drm/gpuvm: Killdrm_gpuva_init()") MSM driver fails to init, failing with "[drm:msm_gpu_init] *ERROR* could not allocate memptrs: -22" errors. The mentioned commit reworked the function, but didn't take into account thatop_mapis initialized at the top of the function, while ranges might change if GPUVM is managed by the kernel.[...]
Applied to drm-misc-next, thanks!
[1/1] drm/msm: fix msm_gem_vma_new() allocations for managed GPUVMs
commit: efe927b9702643a1d80472664c2642f0304cb608
Best regards,
Signature · 2 lines
With best wishes Dmitry
Quoted 36 lines · On Sat, 23 Aug 2025 03:12:00 +0300 Dmitry Baryshkov…
Since commit
3309323241fb("drm/gpuvm: Killdrm_gpuva_init()") MSM driver fails to init, failing with "[drm:msm_gpu_init] *ERROR* could not allocate memptrs: -22" errors. The mentioned commit reworked the function, but didn't take into account thatop_mapis initialized at the top of the function, while ranges might change if GPUVM is managed by the kernel.Move
op_modeinitialization after finalizing all addresses and right before thedrm_gpuva_init_from_op()call.Reported-by Danct12 <[email protected]>Fixes 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()")Suggested-by Rob Clark <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)drivers/gpu/drm/msm/msm_gem_vma.c +0
-6@@ -368,12 +368,6 @@ struct drm_gpuva * msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, u64 offset, u64 range_start, u64 range_end) { - struct drm_gpuva_op_map op_map = { - .va.addr = range_start, - .va.range = range_end - range_start, - .gem.obj = obj, - .gem.offset = offset, - }; struct msm_gem_vm *vm = to_msm_vm(gpuvm);struct drm_gpuvm_bo *vm_bo;struct msm_gem_vma *vma;
drivers/gpu/drm/msm/msm_gem_vma.c msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, · line 404
Quoted 9 lines
drivers/gpu/drm/msm/msm_gem_vma.c +6
-0@@ -402,6 +396,13 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,if (obj)GEM_WARN_ON ((range_end - range_start) > obj->size); +struct drm_gpuva_op_map op_map = { + .va.addr = range_start, + .va.range = range_end - range_start, + .gem.obj = obj, + .gem.offset = offset, + };
OOC, are we now allowed to declare local variables in the middle of a code block in kernel code? I must admit that's not something I tried doing recently, but I've had gcc warnings in the past because of that.
Quoted 10 lines
drivers/gpu/drm/msm/msm_gem_vma.c +1
-1+drm_gpuva_init_from_op (&vma->base, &op_map); vma->mapped = false; ---base-commit:
0f4c93f7eb861acab537dbe94441817a270537bf
change-id: 20250823-msm-fix-gpuvm-init-520d87ebcf26Best regards,
Quoted 43 lines · Boris Brezillon
Quoted 39 lines · On Sat, 23 Aug 2025 03:12:00 +0300 Dmitry Baryshkov…
Since commit
3309323241fb("drm/gpuvm: Killdrm_gpuva_init()") MSM driver fails to init, failing with "[drm:msm_gpu_init] *ERROR* could not allocate memptrs: -22" errors. The mentioned commit reworked the function, but didn't take into account thatop_mapis initialized at the top of the function, while ranges might change if GPUVM is managed by the kernel.Move
op_modeinitialization after finalizing all addresses and right before thedrm_gpuva_init_from_op()call.Reported-by Danct12 <[email protected]>Fixes 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()")Suggested-by Rob Clark <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)drivers/gpu/drm/msm/msm_gem_vma.c +0
-6@@ -368,12 +368,6 @@ struct drm_gpuva * msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, u64 offset, u64 range_start, u64 range_end) { - struct drm_gpuva_op_map op_map = { - .va.addr = range_start, - .va.range = range_end - range_start, - .gem.obj = obj, - .gem.offset = offset, - }; struct msm_gem_vm *vm = to_msm_vm(gpuvm);struct drm_gpuvm_bo *vm_bo;struct msm_gem_vma *vma;@@ -402,6 +396,13 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,if (obj)GEM_WARN_ON ((range_end - range_start) > obj->size);
Quoted 10 lines
drivers/gpu/drm/msm/msm_gem_vma.c msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, · line 404
Quoted 6 lines
drivers/gpu/drm/msm/msm_gem_vma.c +6
-0+struct drm_gpuva_op_map op_map = { + .va.addr = range_start, + .va.range = range_end - range_start, + .gem.obj = obj, + .gem.offset = offset, + };OOC, are we now allowed to declare local variables in the middle of a code block in kernel code? I must admit that's not something I tried doing recently, but I've had gcc warnings in the past because of that.
yes.. I try not to go overboard with it, but this is a case where it seems like the cleanest solution
BR,
-R
Quoted 11 lines
Quoted 10 lines
drivers/gpu/drm/msm/msm_gem_vma.c +1
-1+drm_gpuva_init_from_op (&vma->base, &op_map); vma->mapped = false; ---base-commit:
0f4c93f7eb861acab537dbe94441817a270537bf
change-id: 20250823-msm-fix-gpuvm-init-520d87ebcf26Best regards,