public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/panthor: Extend VM locked region for remap case to be a superset
@ 2026-04-03 17:21 Adrián Larumbe
  2026-04-03 17:21 ` [PATCH 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Adrián Larumbe @ 2026-04-03 17:21 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")
---
 drivers/gpu/drm/panthor/panthor_mmu.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index fa8b31df85c9..2b96359d3b94 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -1709,6 +1709,19 @@ 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.
+	 */
+	if (vm->locked_region.size) {
+		u64 end = start + size;
+
+		start = min(start, vm->locked_region.start);
+		size = max(vm->locked_region.start +
+			   vm->locked_region.size, end) - start;
+	}
+
 	mutex_lock(&ptdev->mmu->as.slots_lock);
 	if (vm->as.id >= 0 && size) {
 		/* Lock the region that needs to be updated */

base-commit: fb42964e2a76f68a5fb581d382b5d2be2d5bda9b
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-07 11:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03 17:21 [PATCH 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Adrián Larumbe
2026-04-03 17:21 ` [PATCH 2/2] drm/panthor: Fix outdated function documentation Adrián Larumbe
2026-04-07  6:55   ` Boris Brezillon
2026-04-07  6:54 ` [PATCH 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Boris Brezillon
2026-04-07 10:24 ` Liviu Dudau
2026-04-07 10:43   ` Boris Brezillon
2026-04-07 11:07     ` Liviu Dudau
2026-04-07 11:33       ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox