[PATCH 09/12] drm/panthor: Don't pre-allocate VMAs or page tables when preparing a full VM unmap
From: Boris Brezillon
Date: Tue Aug 04 2026 - 06:41:39 EST
In the cleanup path, we unmap the full VA range to make sure things are
clean before the VM is released. I'd rather not fail on memory
allocation in that path, so let's make sure
panthor_vm_pgtable_prepare_unmap_op_ctx() doesn't allocate VMAs or
page tables when the unmap range matches the VM virtual address range.
Signed-off-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
---
drivers/gpu/drm/panthor/panthor_mmu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index 1264c3ffa832..2ad8b15de0da 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -1484,6 +1484,10 @@ static int panthor_as_prepare_unmap_op_ctx(struct panthor_as_op_ctx *op_ctx,
op_ctx->va.addr = va;
op_ctx->flags = DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP;
+ /* Unmap on the whole VM range don't need new VMAs or page tables. */
+ if (va == as->base.mm_start && size == as->base.mm_range)
+ return 0;
+
/* Pre-allocate L3 page tables to account for the split-2M-block
* situation on unmap.
*/
--
2.55.0