[PATCH v4 08/17] drm/panfrost: Don't WARN for a heap folio a neighbouring chunk filled

From: Arun Iyengar via B4 Relay

Date: Thu Nov 26 2026 - 04:37:50 EST


From: Arun Iyengar <aiyengar1990@xxxxxxxxx>

With 16K or 64K pages, a THP folio can be larger than the 2 MB heap
chunk, and the first fault in it fills the page array of neighbouring
chunks too. Every later fault there WARNs, although dropping the extra
folio reference is all it has to do. Warn only for a folio that fits
in the chunk. Not reproduced (4K pages here).

Fixes: b49c35ba0ce1 ("drm/panfrost: Fix a page leak in panfrost_mmu_map_fault_addr() when THP is on")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/sashiko-outbox-210837@xxxxxxxxxx/
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/gpu/drm/panfrost/panfrost_mmu.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
index 9edf66f6e..92a4d2963 100644
--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
+++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
@@ -703,11 +703,13 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
pages[pg++] = folio_page(folio, i);
}

- /* We always fill the page array at a folio granularity so
- * there's no valid reason for a folio range to be partially
- * populated.
+ /* We always fill the page array at a folio granularity, so a
+ * folio is already owned only if it is larger than the chunk
+ * and the fault of a neighbouring chunk filled it.
*/
- if (drm_WARN_ON(&pfdev->base, already_owned)) {
+ if (already_owned) {
+ drm_WARN_ON(&pfdev->base,
+ folio_nr_pages(folio) <= NUM_FAULT_PAGES);
folio_put(folio);
} else {
got_start = min(got_start, first);

--
2.55.0