drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
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.
Reported-by: Danct12 <danct12@disroot.org>
Fixes: 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()")
Suggested-by: Rob Clark <robin.clark@oss.qualcomm.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c
index 3f440bc1f7106f3b0091f037611d0b433e5e2c18..6df6b7c0984da57fe64de41fa54f7dea0a324c74 100644
--- a/drivers/gpu/drm/msm/msm_gem_vma.c
+++ b/drivers/gpu/drm/msm/msm_gem_vma.c
@@ -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,
--
With best wishes
Dmitry
On Sat, 23 Aug 2025 03:12:00 +0300 Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> wrote: > 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. > > Reported-by: Danct12 <danct12@disroot.org> > Fixes: 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()") > Suggested-by: Rob Clark <robin.clark@oss.qualcomm.com> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > --- > drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c > index 3f440bc1f7106f3b0091f037611d0b433e5e2c18..6df6b7c0984da57fe64de41fa54f7dea0a324c74 100644 > --- a/drivers/gpu/drm/msm/msm_gem_vma.c > +++ b/drivers/gpu/drm/msm/msm_gem_vma.c > @@ -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, > + }; 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. > + > 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,
On Mon, Aug 25, 2025 at 12:09 AM Boris Brezillon <boris.brezillon@collabora.com> wrote: > > On Sat, 23 Aug 2025 03:12:00 +0300 > Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> wrote: > > > 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. > > > > Reported-by: Danct12 <danct12@disroot.org> > > Fixes: 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()") > > Suggested-by: Rob Clark <robin.clark@oss.qualcomm.com> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > > --- > > drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c > > index 3f440bc1f7106f3b0091f037611d0b433e5e2c18..6df6b7c0984da57fe64de41fa54f7dea0a324c74 100644 > > --- a/drivers/gpu/drm/msm/msm_gem_vma.c > > +++ b/drivers/gpu/drm/msm/msm_gem_vma.c > > @@ -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, > > + }; > > 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 > > + > > 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, >
On Sat, 23 Aug 2025 03:12:00 +0300, Dmitry Baryshkov wrote: > 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. > > [...] Applied to drm-misc-next, thanks! [1/1] drm/msm: fix msm_gem_vma_new() allocations for managed GPUVMs commit: efe927b9702643a1d80472664c2642f0304cb608 Best regards, -- With best wishes Dmitry
On Fri, Aug 22, 2025 at 5:12 PM Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> wrote: > > 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. > > Reported-by: Danct12 <danct12@disroot.org> > Fixes: 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()") > Suggested-by: Rob Clark <robin.clark@oss.qualcomm.com> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > --- > drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c > index 3f440bc1f7106f3b0091f037611d0b433e5e2c18..6df6b7c0984da57fe64de41fa54f7dea0a324c74 100644 > --- a/drivers/gpu/drm/msm/msm_gem_vma.c > +++ b/drivers/gpu/drm/msm/msm_gem_vma.c > @@ -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, > + }; Thanks, Reviewed-by: Rob Clark <rob.clark@oss.qualcomm.com> > + > 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, > -- > With best wishes > Dmitry >
On Fri, Aug 22, 2025 at 05:14:02PM -0700, Rob Clark wrote: > On Fri, Aug 22, 2025 at 5:12 PM Dmitry Baryshkov > <dmitry.baryshkov@oss.qualcomm.com> wrote: > > > > 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. > > > > Reported-by: Danct12 <danct12@disroot.org> > > Fixes: 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()") > > Suggested-by: Rob Clark <robin.clark@oss.qualcomm.com> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > > --- > > drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > Thanks, > > Reviewed-by: Rob Clark <rob.clark@oss.qualcomm.com> I'll also need Acked-by to merge through drm-misc-next, where the offending commit is. -- With best wishes Dmitry
On Sat, Aug 23, 2025 at 6:50 AM Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> wrote: > > On Fri, Aug 22, 2025 at 05:14:02PM -0700, Rob Clark wrote: > > On Fri, Aug 22, 2025 at 5:12 PM Dmitry Baryshkov > > <dmitry.baryshkov@oss.qualcomm.com> wrote: > > > > > > 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. > > > > > > Reported-by: Danct12 <danct12@disroot.org> > > > Fixes: 3309323241fb ("drm/gpuvm: Kill drm_gpuva_init()") > > > Suggested-by: Rob Clark <robin.clark@oss.qualcomm.com> > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> > > > --- > > > drivers/gpu/drm/msm/msm_gem_vma.c | 13 +++++++------ > > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > > > > Thanks, > > > > Reviewed-by: Rob Clark <rob.clark@oss.qualcomm.com> > > I'll also need Acked-by to merge through drm-misc-next, where the > offending commit is. > Acked-by: Rob Clark <rob.clark@oss.qualcomm.com> > > -- > With best wishes > Dmitry
© 2016 - 2025 Red Hat, Inc.