Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: igt-dev@lists.freedesktop.org,
	Petri Latvala <adrinael@adrinael.net>,
	Arkadiusz Hiler <arek@hiler.eu>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>,
	Bhanuprakash Modem <bhanuprakash.modem@gmail.com>,
	Steven Price <steven.price@arm.com>,
	Liviu Dudau <liviu.dudau@arm.com>,
	Daniel Almeida <daniel.almeida@collabora.com>,
	kernel@collabora.com
Subject: Re: [PATCH 2/2] tests/panthor: Add VM_BIND tests for partial huge page unmaps
Date: Thu, 27 Nov 2025 09:53:16 +0100	[thread overview]
Message-ID: <20251127095316.2ce78f74@fedora> (raw)
In-Reply-To: <20251127030145.585641-2-adrian.larumbe@collabora.com>

On Thu, 27 Nov 2025 03:01:44 +0000
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:

> Kernel commit 33729a5fc0ca ("iommu/io-pgtable-arm: Remove split on unmap
> behavior") made it illegal to perform partial unmaps of memory regions
> backed by huge (> 2MiB) pages. A workaround was written specifically for
> Panthor, but in order to test it, multiple scenarios and corner cases
> had to be considered.

Maybe add a link to the kernel fix addressing the problem in your v2.

> 
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> ---
>  tests/panthor/meson.build              |   1 +
>  tests/panthor/panthor_hugepage_unmap.c | 210 +++++++++++++++++++++++++
>  2 files changed, 211 insertions(+)
>  create mode 100644 tests/panthor/panthor_hugepage_unmap.c
> 
> diff --git a/tests/panthor/meson.build b/tests/panthor/meson.build
> index 42a46e9934a9..78341b720912 100644
> --- a/tests/panthor/meson.build
> +++ b/tests/panthor/meson.build
> @@ -3,6 +3,7 @@ panthor_progs = [
>  	'panthor_group',
>  	'panthor_query',
>  	'panthor_vm',
> +        'panthor_hugepage_unmap',

I believe those belong in panthor_vm.c (they are about testing some
VM_BIND corner cases). With this addressed, the patch is

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

>  ]
>  
>  foreach prog : panthor_progs
> diff --git a/tests/panthor/panthor_hugepage_unmap.c b/tests/panthor/panthor_hugepage_unmap.c
> new file mode 100644
> index 000000000000..1c712fb0d4f7
> --- /dev/null
> +++ b/tests/panthor/panthor_hugepage_unmap.c
> @@ -0,0 +1,210 @@
> +// SPDX-License-Identifier: MIT
> +// SPDX-FileCopyrightText: Copyright (C) 2025 Collabora Ltd.
> +
> +#include "igt.h"
> +#include "igt_core.h"
> +#include "igt_panthor.h"
> +#include "panthor_drm.h"
> +
> +igt_main {
> +	int fd;
> +
> +	igt_fixture {
> +		fd = drm_open_driver(DRIVER_PANTHOR);
> +	}
> +
> +	igt_describe("Requested unmapping is identical to existing huge page mapping");
> +	igt_subtest("vm_unbind_identical_hugepage_single") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_2M;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Requested unmapping is identical to existing huge page mapping, but only a subset of the object's pages are mapped in the VM");
> +	igt_subtest("vm_unbind_identical_hugepage_single") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_4M;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Requested unmapping is identical to existing multiple huge page mapping");
> +	igt_subtest("vm_unbind_identical_hugepage_multiple") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_1M * 6;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Requested unmapping is identical to existing huge page mapping, but only part of the BO is mapped");
> +	igt_subtest("vm_unbind_identical_hugepage_offset") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_1M * 6;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind_offset(fd, vm_id, bo.handle, 0x200000,
> +					   SZ_4M, SZ_2M, DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Requested unmapping is left aligned subset of an existing huge page mapping");
> +	igt_subtest("vm_unbind_hugepage_leftaligned") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_4M;
> +		uint64_t unmap_size = SZ_8K;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000, unmap_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Requested unmapping is right aligned subset of an existing huge page mapping");
> +	igt_subtest("vm_unbind_hugepage_rightaligned") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_4M;
> +		uint64_t unmap_size = SZ_8K;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000 + bo_size - unmap_size, unmap_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Requested unmapping is a superset of existing huge page mapping");
> +	igt_subtest("vm_unbind_hugepage_superset") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_2M;
> +		uint64_t unmap_size = SZ_1M * 5;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x100000, unmap_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Requested unmapping is a subset of an existing mapping");
> +	igt_subtest("vm_unbind_hugepage_subset") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_4M;
> +		uint64_t unmap_size = SZ_8K;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000 + SZ_1M, unmap_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000 + SZ_2M + SZ_4K, unmap_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_describe("Perform successive unmaps over the remnants of an original multi huge page mapping");
> +	igt_subtest("vm_unbind_hugepage_successive") {
> +		uint32_t vm_id;
> +		struct panthor_bo bo;
> +		uint64_t bo_size = SZ_1M * 6;
> +
> +		igt_panthor_vm_create(fd, &vm_id, 0);
> +		igt_assert(vm_id != 0);
> +
> +		igt_panthor_bo_create(fd, &bo, bo_size, 0, 0);
> +		igt_panthor_vm_bind(fd, vm_id, bo.handle, 0x200000, bo_size,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_MAP, 0);
> +
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x3fc000, 0x208000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x3fc000, 0x208000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000, 0x4000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x401000, 0x4000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x4fb000, 0xA000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x3fb000, 0xA000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x3fc000, 0x4000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +		igt_panthor_vm_bind(fd, vm_id, 0, 0x200000, 0x1000,
> +				    DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP, 0);
> +
> +		igt_panthor_vm_destroy(fd, vm_id, 0);
> +	}
> +
> +	igt_fixture {
> +		drm_close_driver(fd);
> +	}
> +}


  reply	other threads:[~2025-11-27  8:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27  3:01 [PATCH 1/2] panthor: Allow specifying offset when mapping a BO against a VM Adrián Larumbe
2025-11-27  3:01 ` [PATCH 2/2] tests/panthor: Add VM_BIND tests for partial huge page unmaps Adrián Larumbe
2025-11-27  8:53   ` Boris Brezillon [this message]
2025-11-27 12:13   ` Kamil Konieczny
2025-11-27  4:20 ` ✓ i915.CI.BAT: success for series starting with [1/2] panthor: Allow specifying offset when mapping a BO against a VM Patchwork
2025-11-27  4:32 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-27  5:24 ` ✗ Xe.CI.Full: failure " Patchwork
2025-11-27  8:00 ` ✗ i915.CI.Full: " Patchwork
2025-11-27  8:48 ` [PATCH 1/2] " Boris Brezillon

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=20251127095316.2ce78f74@fedora \
    --to=boris.brezillon@collabora.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=adrinael@adrinael.net \
    --cc=arek@hiler.eu \
    --cc=bhanuprakash.modem@gmail.com \
    --cc=daniel.almeida@collabora.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=juhapekka.heikkila@gmail.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=kernel@collabora.com \
    --cc=liviu.dudau@arm.com \
    --cc=steven.price@arm.com \
    /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