[PATCH v3 07/14] drm/panfrost: Don't WARN for a heap folio a neighbouring chunk filled
From: Arun Iyengar via B4 Relay
Date: Fri Nov 13 2026 - 05:42:16 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
panfrost_mmu_map_fault_addr() fills the page array of a heap BO a whole
folio at a time and warns when a page of the folio is already filled in.
With 16K or 64K pages, the THP mount panfrost uses can return folios
larger than the 2 MB fault chunk (up to 32 MB and 128 MB). The first
fault in such a folio fills the entries of the neighbouring chunks too,
and every later fault in those chunks WARNs, although dropping the extra
folio reference, as it does, is all it has to do.
Warn only for a folio that fits in the chunk: only an earlier fault in
the same chunk can have filled its pages, which is a bug.
Not reproduced: with 4K pages, as here, a folio never crosses a chunk.
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 e1c4e57d0..2cf67d932 100644
--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
+++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
@@ -711,11 +711,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