* [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset
@ 2026-04-08 19:12 Adrián Larumbe
2026-04-08 19:12 ` [PATCH v2 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Adrián Larumbe @ 2026-04-08 19:12 UTC (permalink / raw)
To: linux-kernel
Cc: dri-devel, Steven Price, Boris Brezillon, kernel,
Adrián Larumbe, Liviu Dudau, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
In the event of an sm_step_remap() that leads to a partial unmap of a
transparent huge page, the new locked region required by an extended unmap
might not be a superset of the original one. Then, if it leaves a portion
of the initially requested one out, the ensuing map will trigger a warning.
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Fixes: 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index fa8b31df85c9..bd41c892beb7 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -1709,6 +1709,25 @@ static int panthor_vm_lock_region(struct panthor_vm *vm, u64 start, u64 size)
start + size <= vm->locked_region.start + vm->locked_region.size)
return 0;
+ /* sm_step_remap() may need a locked region that isn't a strict superset
+ * of the original one because of having to extend unmap boundaries beyond
+ * it to deal with partial unmaps of transparent huge pages. What we want
+ * in those cases is to lock the union of both regions. The new region must
+ * always overlap with the original one, because the upper and lower unmap
+ * boundaries in a remap operation can only shift up or down respectively,
+ * but never otherwise.
+ */
+ if (vm->locked_region.size) {
+ u64 end = max(vm->locked_region.start + vm->locked_region.size,
+ start + size);
+
+ drm_WARN_ON_ONCE(&vm->ptdev->base, (start + size <= vm->locked_region.start) ||
+ (start >= vm->locked_region.start + vm->locked_region.size));
+
+ start = min(start, vm->locked_region.start);
+ size = end - start;
+ }
+
mutex_lock(&ptdev->mmu->as.slots_lock);
if (vm->as.id >= 0 && size) {
/* Lock the region that needs to be updated */
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] drm/panthor: Fix outdated function documentation
2026-04-08 19:12 [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Adrián Larumbe
@ 2026-04-08 19:12 ` Adrián Larumbe
2026-04-09 8:56 ` Liviu Dudau
2026-04-09 9:15 ` Steven Price
2026-04-09 8:55 ` [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Liviu Dudau
2026-04-09 9:15 ` Steven Price
2 siblings, 2 replies; 6+ messages in thread
From: Adrián Larumbe @ 2026-04-08 19:12 UTC (permalink / raw)
To: linux-kernel
Cc: dri-devel, Steven Price, Boris Brezillon, kernel,
Adrián Larumbe, Liviu Dudau, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
'vm' is no longer allowed to be NULL.
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/gpu/drm/panthor/panthor_gem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
index 69cef05b6ef7..13295d7a593d 100644
--- a/drivers/gpu/drm/panthor/panthor_gem.c
+++ b/drivers/gpu/drm/panthor/panthor_gem.c
@@ -1264,7 +1264,7 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)
/**
* panthor_kernel_bo_create() - Create and map a GEM object to a VM
* @ptdev: Device.
- * @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped.
+ * @vm: VM to map the GEM to.
* @size: Size of the buffer object.
* @bo_flags: Combination of drm_panthor_bo_flags flags.
* @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset
2026-04-08 19:12 [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Adrián Larumbe
2026-04-08 19:12 ` [PATCH v2 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
@ 2026-04-09 8:55 ` Liviu Dudau
2026-04-09 9:15 ` Steven Price
2 siblings, 0 replies; 6+ messages in thread
From: Liviu Dudau @ 2026-04-09 8:55 UTC (permalink / raw)
To: Adrián Larumbe
Cc: linux-kernel, dri-devel, Steven Price, Boris Brezillon, kernel,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter
On Wed, Apr 08, 2026 at 08:12:23PM +0100, Adrián Larumbe wrote:
> In the event of an sm_step_remap() that leads to a partial unmap of a
> transparent huge page, the new locked region required by an extended unmap
> might not be a superset of the original one. Then, if it leaves a portion
> of the initially requested one out, the ensuing map will trigger a warning.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> Fixes: 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages")
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Best regards,
Liviu
> ---
> drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index fa8b31df85c9..bd41c892beb7 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -1709,6 +1709,25 @@ static int panthor_vm_lock_region(struct panthor_vm *vm, u64 start, u64 size)
> start + size <= vm->locked_region.start + vm->locked_region.size)
> return 0;
>
> + /* sm_step_remap() may need a locked region that isn't a strict superset
> + * of the original one because of having to extend unmap boundaries beyond
> + * it to deal with partial unmaps of transparent huge pages. What we want
> + * in those cases is to lock the union of both regions. The new region must
> + * always overlap with the original one, because the upper and lower unmap
> + * boundaries in a remap operation can only shift up or down respectively,
> + * but never otherwise.
> + */
> + if (vm->locked_region.size) {
> + u64 end = max(vm->locked_region.start + vm->locked_region.size,
> + start + size);
> +
> + drm_WARN_ON_ONCE(&vm->ptdev->base, (start + size <= vm->locked_region.start) ||
> + (start >= vm->locked_region.start + vm->locked_region.size));
> +
> + start = min(start, vm->locked_region.start);
> + size = end - start;
> + }
> +
> mutex_lock(&ptdev->mmu->as.slots_lock);
> if (vm->as.id >= 0 && size) {
> /* Lock the region that needs to be updated */
> --
> 2.53.0
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] drm/panthor: Fix outdated function documentation
2026-04-08 19:12 ` [PATCH v2 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
@ 2026-04-09 8:56 ` Liviu Dudau
2026-04-09 9:15 ` Steven Price
1 sibling, 0 replies; 6+ messages in thread
From: Liviu Dudau @ 2026-04-09 8:56 UTC (permalink / raw)
To: Adrián Larumbe
Cc: linux-kernel, dri-devel, Steven Price, Boris Brezillon, kernel,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter
On Wed, Apr 08, 2026 at 08:12:24PM +0100, Adrián Larumbe wrote:
> 'vm' is no longer allowed to be NULL.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Best regards,
Liviu
> ---
> drivers/gpu/drm/panthor/panthor_gem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> index 69cef05b6ef7..13295d7a593d 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -1264,7 +1264,7 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)
> /**
> * panthor_kernel_bo_create() - Create and map a GEM object to a VM
> * @ptdev: Device.
> - * @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped.
> + * @vm: VM to map the GEM to.
> * @size: Size of the buffer object.
> * @bo_flags: Combination of drm_panthor_bo_flags flags.
> * @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those
> --
> 2.53.0
>
--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset
2026-04-08 19:12 [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Adrián Larumbe
2026-04-08 19:12 ` [PATCH v2 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
2026-04-09 8:55 ` [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Liviu Dudau
@ 2026-04-09 9:15 ` Steven Price
2 siblings, 0 replies; 6+ messages in thread
From: Steven Price @ 2026-04-09 9:15 UTC (permalink / raw)
To: Adrián Larumbe, linux-kernel
Cc: dri-devel, Boris Brezillon, kernel, Liviu Dudau,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter
On 08/04/2026 20:12, Adrián Larumbe wrote:
> In the event of an sm_step_remap() that leads to a partial unmap of a
> transparent huge page, the new locked region required by an extended unmap
> might not be a superset of the original one. Then, if it leaves a portion
> of the initially requested one out, the ensuing map will trigger a warning.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> Fixes: 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages")
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Although I'm starting to wonder if we should split this into an "initial
lock" and an "expand lock" function. Still as a minimal fix this is good.
Thanks,
Steve
> ---
> drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index fa8b31df85c9..bd41c892beb7 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -1709,6 +1709,25 @@ static int panthor_vm_lock_region(struct panthor_vm *vm, u64 start, u64 size)
> start + size <= vm->locked_region.start + vm->locked_region.size)
> return 0;
>
> + /* sm_step_remap() may need a locked region that isn't a strict superset
> + * of the original one because of having to extend unmap boundaries beyond
> + * it to deal with partial unmaps of transparent huge pages. What we want
> + * in those cases is to lock the union of both regions. The new region must
> + * always overlap with the original one, because the upper and lower unmap
> + * boundaries in a remap operation can only shift up or down respectively,
> + * but never otherwise.
> + */
> + if (vm->locked_region.size) {
> + u64 end = max(vm->locked_region.start + vm->locked_region.size,
> + start + size);
> +
> + drm_WARN_ON_ONCE(&vm->ptdev->base, (start + size <= vm->locked_region.start) ||
> + (start >= vm->locked_region.start + vm->locked_region.size));
> +
> + start = min(start, vm->locked_region.start);
> + size = end - start;
> + }
> +
> mutex_lock(&ptdev->mmu->as.slots_lock);
> if (vm->as.id >= 0 && size) {
> /* Lock the region that needs to be updated */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] drm/panthor: Fix outdated function documentation
2026-04-08 19:12 ` [PATCH v2 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
2026-04-09 8:56 ` Liviu Dudau
@ 2026-04-09 9:15 ` Steven Price
1 sibling, 0 replies; 6+ messages in thread
From: Steven Price @ 2026-04-09 9:15 UTC (permalink / raw)
To: Adrián Larumbe, linux-kernel
Cc: dri-devel, Boris Brezillon, kernel, Liviu Dudau,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter
On 08/04/2026 20:12, Adrián Larumbe wrote:
> 'vm' is no longer allowed to be NULL.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
And for completeness:
Fixes: 8a1cc07578bf ("drm/panthor: Add GEM logical block")
Thanks,
Steve
> ---
> drivers/gpu/drm/panthor/panthor_gem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> index 69cef05b6ef7..13295d7a593d 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -1264,7 +1264,7 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)
> /**
> * panthor_kernel_bo_create() - Create and map a GEM object to a VM
> * @ptdev: Device.
> - * @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped.
> + * @vm: VM to map the GEM to.
> * @size: Size of the buffer object.
> * @bo_flags: Combination of drm_panthor_bo_flags flags.
> * @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-04-09 9:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 19:12 [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Adrián Larumbe
2026-04-08 19:12 ` [PATCH v2 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
2026-04-09 8:56 ` Liviu Dudau
2026-04-09 9:15 ` Steven Price
2026-04-09 8:55 ` [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Liviu Dudau
2026-04-09 9:15 ` Steven Price
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox