Re: [PATCH v7 2/6] drm/panthor: Pass vm_bind_op to vm_prepare_map_op_ctx
From: Boris Brezillon
Date: Wed Apr 15 2026 - 09:12:44 EST
On Wed, 15 Apr 2026 12:28:46 +0100
Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx> wrote:
> Instead of passing its constituent elements, pass the whole struct to
> simplify the function prototype.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx>
Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
> ---
> drivers/gpu/drm/panthor/panthor_mmu.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index 01577be88933..d9e2f8afb8fb 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -1275,9 +1275,7 @@ static int panthor_vm_op_ctx_prealloc_pts(struct panthor_vm_op_ctx *op_ctx)
> static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
> struct panthor_vm *vm,
> struct panthor_gem_object *bo,
> - u64 offset,
> - u64 size, u64 va,
> - u32 flags)
> + const struct drm_panthor_vm_bind_op *op)
> {
> struct drm_gpuvm_bo *preallocated_vm_bo;
> struct sg_table *sgt = NULL;
> @@ -1286,12 +1284,12 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
> if (!bo)
> return -EINVAL;
>
> - if ((flags & ~PANTHOR_VM_BIND_OP_MAP_FLAGS) ||
> - (flags & DRM_PANTHOR_VM_BIND_OP_TYPE_MASK) != DRM_PANTHOR_VM_BIND_OP_TYPE_MAP)
> + if ((op->flags & ~PANTHOR_VM_BIND_OP_MAP_FLAGS) ||
> + (op->flags & DRM_PANTHOR_VM_BIND_OP_TYPE_MASK) != DRM_PANTHOR_VM_BIND_OP_TYPE_MAP)
> return -EINVAL;
>
> /* Make sure the VA and size are in-bounds. */
> - if (size > bo->base.size || offset > bo->base.size - size)
> + if (op->size > bo->base.size || op->bo_offset > bo->base.size - op->size)
> return -EINVAL;
>
> /* If the BO has an exclusive VM attached, it can't be mapped to other VMs. */
> @@ -1299,7 +1297,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
> bo->exclusive_vm_root_gem != panthor_vm_root_gem(vm))
> return -EINVAL;
>
> - panthor_vm_init_op_ctx(op_ctx, size, va, flags);
> + panthor_vm_init_op_ctx(op_ctx, op->size, op->va, op->flags);
>
> ret = panthor_vm_op_ctx_prealloc_vmas(op_ctx);
> if (ret)
> @@ -1328,7 +1326,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
> }
>
> op_ctx->map.vm_bo = drm_gpuvm_bo_obtain_prealloc(preallocated_vm_bo);
> - op_ctx->map.bo_offset = offset;
> + op_ctx->map.bo_offset = op->bo_offset;
>
> ret = panthor_vm_op_ctx_prealloc_pts(op_ctx);
> if (ret)
> @@ -2849,10 +2847,7 @@ panthor_vm_bind_prepare_op_ctx(struct drm_file *file,
> gem = drm_gem_object_lookup(file, op->bo_handle);
> ret = panthor_vm_prepare_map_op_ctx(op_ctx, vm,
> gem ? to_panthor_bo(gem) : NULL,
> - op->bo_offset,
> - op->size,
> - op->va,
> - op->flags);
> + op);
> drm_gem_object_put(gem);
> return ret;
>
> @@ -3048,10 +3043,16 @@ int panthor_vm_bind_exec_sync_op(struct drm_file *file,
> int panthor_vm_map_bo_range(struct panthor_vm *vm, struct panthor_gem_object *bo,
> u64 offset, u64 size, u64 va, u32 flags)
> {
> + struct drm_panthor_vm_bind_op op = {
You could even make it const here, but I think you're adjusting some
fields after the initialization in one of the following patches.
> + .bo_offset = offset,
> + .size = size,
> + .va = va,
> + .flags = flags,
> + };
> struct panthor_vm_op_ctx op_ctx;
> int ret;
>
> - ret = panthor_vm_prepare_map_op_ctx(&op_ctx, vm, bo, offset, size, va, flags);
> + ret = panthor_vm_prepare_map_op_ctx(&op_ctx, vm, bo, &op);
> if (ret)
> return ret;
>