mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Adrián Larumbe" <adrian.larumbe@collabora.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
	 Steven Price <steven.price@arm.com>,
	Liviu Dudau <liviu.dudau@arm.com>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,
	 Heiko Stuebner <heiko@sntech.de>,
	Grant Likely <grant.likely@linaro.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>
Subject: [PATCH v3 3/4] drm/panthor: Have prepare_unmap_op_ctx receive a whole vm_bind op
Date: Mon, 29 Jun 2026 21:17:07 +0100	[thread overview]
Message-ID: <20260629-vm_bind_checks-v3-3-85e6740f6c2e@collabora.com> (raw)
In-Reply-To: <20260629-vm_bind_checks-v3-0-85e6740f6c2e@collabora.com>

This change was already enforced for panthor_vm_prepare_map_op_ctx. In a
future commit, access to the drm_panthor_vm_bind_op flags will be needed
inside panthor_vm_prepare_unmap_op_ctx, so rather than expanding the
parameter list, simply pass the operation struct instead.

Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
---
 drivers/gpu/drm/panthor/panthor_mmu.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index 48aa23573cd6..77fdad4e5166 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -1416,24 +1416,24 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
 
 static int panthor_vm_prepare_unmap_op_ctx(struct panthor_vm_op_ctx *op_ctx,
 					   struct panthor_vm *vm,
-					   u64 va, u64 size)
+					   const struct drm_panthor_vm_bind_op *op)
 {
 	u32 pt_count = 0;
 	int ret;
 
 	memset(op_ctx, 0, sizeof(*op_ctx));
-	op_ctx->va.range = size;
-	op_ctx->va.addr = va;
+	op_ctx->va.range = op->size;
+	op_ctx->va.addr = op->va;
 	op_ctx->flags = DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP;
 
 	/* Pre-allocate L3 page tables to account for the split-2M-block
 	 * situation on unmap.
 	 */
-	if (va != ALIGN(va, SZ_2M))
+	if (op->va != ALIGN(op->va, SZ_2M))
 		pt_count++;
 
-	if (va + size != ALIGN(va + size, SZ_2M) &&
-	    ALIGN(va + size, SZ_2M) != ALIGN(va, SZ_2M))
+	if (op->va + op->size != ALIGN(op->va + op->size, SZ_2M) &&
+	    ALIGN(op->va + op->size, SZ_2M) != ALIGN(op->va, SZ_2M))
 		pt_count++;
 
 	ret = panthor_vm_op_ctx_prealloc_vmas(op_ctx);
@@ -3012,7 +3012,7 @@ panthor_vm_bind_prepare_op_ctx(struct drm_file *file,
 		if (op->bo_handle || op->bo_offset)
 			return -EINVAL;
 
-		return panthor_vm_prepare_unmap_op_ctx(op_ctx, vm, op->va, op->size);
+		return panthor_vm_prepare_unmap_op_ctx(op_ctx, vm, op);
 
 	case DRM_PANTHOR_VM_BIND_OP_TYPE_SYNC_ONLY:
 		if (op->flags & ~DRM_PANTHOR_VM_BIND_OP_TYPE_MASK)
@@ -3232,10 +3232,14 @@ int panthor_vm_map_bo_range(struct panthor_vm *vm, struct panthor_gem_object *bo
  */
 int panthor_vm_unmap_range(struct panthor_vm *vm, u64 va, u64 size)
 {
+	struct drm_panthor_vm_bind_op op = {
+		.size = size,
+		.va = va,
+	};
 	struct panthor_vm_op_ctx op_ctx;
 	int ret;
 
-	ret = panthor_vm_prepare_unmap_op_ctx(&op_ctx, vm, va, size);
+	ret = panthor_vm_prepare_unmap_op_ctx(&op_ctx, vm, &op);
 	if (ret)
 		return ret;
 

-- 
2.54.0


  parent reply	other threads:[~2026-06-29 20:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 20:17 [PATCH v3 0/4] Add vm_bind param check to ensure no overlap with kbo AS carveout Adrián Larumbe
2026-06-29 20:17 ` [PATCH v3 1/4] drm/panthor: Add vm_bind region with kbo range overlap check Adrián Larumbe
2026-07-03 14:00   ` Steven Price
2026-06-29 20:17 ` [PATCH v3 2/4] drm/panthor: Fix comment to reflect actual struct field name Adrián Larumbe
2026-06-29 20:17 ` Adrián Larumbe [this message]
2026-06-29 20:17 ` [PATCH v3 4/4] drm/panthor: Check for sparse binding range overflow Adrián Larumbe
2026-06-30  8:23   ` Boris Brezillon
2026-06-30 13:01     ` Adrián Larumbe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260629-vm_bind_checks-v3-3-85e6740f6c2e@collabora.com \
    --to=adrian.larumbe@collabora.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=grant.likely@linaro.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome