Skip to content

Commit efe927b

Browse files
committed
drm/msm: fix msm_gem_vma_new() allocations for managed GPUVMs
Since commit 3309323 ("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: 3309323 ("drm/gpuvm: Kill drm_gpuva_init()") Suggested-by: Rob Clark <robin.clark@oss.qualcomm.com> Reviewed-by: Rob Clark <robin.clark@oss.qualcomm.com> Acked-by: Rob Clark <robin.clark@oss.qualcomm.com> Link: https://lore.kernel.org/r/20250823-msm-fix-gpuvm-init-v1-1-e199cd5b1983@oss.qualcomm.com Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
1 parent b6f11f1 commit efe927b

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

drivers/gpu/drm/msm/msm_gem_vma.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,6 @@ struct drm_gpuva *
371371
msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,
372372
u64 offset, u64 range_start, u64 range_end)
373373
{
374-
struct drm_gpuva_op_map op_map = {
375-
.va.addr = range_start,
376-
.va.range = range_end - range_start,
377-
.gem.obj = obj,
378-
.gem.offset = offset,
379-
};
380374
struct msm_gem_vm *vm = to_msm_vm(gpuvm);
381375
struct drm_gpuvm_bo *vm_bo;
382376
struct msm_gem_vma *vma;
@@ -405,6 +399,13 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,
405399
if (obj)
406400
GEM_WARN_ON((range_end - range_start) > obj->size);
407401

402+
struct drm_gpuva_op_map op_map = {
403+
.va.addr = range_start,
404+
.va.range = range_end - range_start,
405+
.gem.obj = obj,
406+
.gem.offset = offset,
407+
};
408+
408409
drm_gpuva_init_from_op(&vma->base, &op_map);
409410
vma->mapped = false;
410411

0 commit comments

Comments
 (0)