From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 06/11] drm/panfrost: Give back the pages of a heap chunk that failed to map
Date: Thu, 12 Nov 2026 09:12:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-210837@kernel.org> (raw)
In-Reply-To: <20261112-panfrost-long-jobs-v2-6-a06830da3d99@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/panfrost: false drm_WARN_ON() in
panfrost_mmu_map_fault_addr()
--
commit 455071c10d7f5d95d3ce18757e41ef79db6b9400
Author: Arun Iyengar <aiyengar1990@gmail.com>
drm/panfrost: Give back the pages of a heap chunk that failed to map
This commit releases the shmem folios read during a heap BO fault and
clears their entries in bo->base.pages if mapping the 2 MB fault chunk
fails.
> diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> index 35fb86b6b3242..6847359374e53 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
[ ... ]
> @@ -670,17 +696,23 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
> mapping = bo->base.base.filp->f_mapping;
> mapping_set_unevictable(mapping);
>
> + /* The page array range whose folio references this fault takes. */
> + got_start = page_offset;
> + got_end = page_offset;
> +
> for (pgoff_t pg = page_offset; pg < page_offset + NUM_FAULT_PAGES;) {
> bool already_owned = false;
> struct folio *folio;
> + pgoff_t first;
>
> folio = shmem_read_folio(mapping, pg);
> if (IS_ERR(folio)) {
> ret = PTR_ERR(folio);
> - goto err_unlock;
> + goto err_put_chunk;
> }
>
> pg &= ~(folio_nr_pages(folio) - 1);
> + first = pg;
> for (u32 i = 0; i < folio_nr_pages(folio) && pg < nr_pages; i++) {
> if (pages[pg])
> already_owned = true;
> @@ -692,14 +724,18 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
> * there's no valid reason for a folio range to be partially
> * populated.
> */
> - if (drm_WARN_ON(&pfdev->base, already_owned))
> + if (drm_WARN_ON(&pfdev->base, already_owned)) {
> folio_put(folio);
> + } else {
> + got_start = min(got_start, first);
> + got_end = max(got_end, pg);
> + }
> }
[Severity: Medium]
Should drm_WARN_ON() be removed when already_owned is true for a folio
larger than 2 MB?
When shmem returns a folio larger than the 2 MB fault chunk (such as a
PMD-sized or multi-megabyte THP folio on 16K or 64K page kernels), the
first chunk fault populates pages[] for the entire folio across
neighbouring 2 MB chunks, while only mapping the sg_table for the faulting
2 MB chunk. The new else branch relies on already_owned being true when
those neighbouring 2 MB chunks later fault so that [got_start, got_end)
does not claim their shared folio, but keeping drm_WARN_ON(&pfdev->base,
already_owned) in the condition triggers a warning on every normal fault
of those neighbouring chunks.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112-panfrost-long-jobs-v2-0-a06830da3d99@gmail.com?part=6
next prev parent reply other threads:[~2026-11-12 9:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 8:48 [PATCH v2 00/11] drm/panfrost: Resume long jobs instead of resetting, and mapping error path fixes Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 01/11] drm/panfrost: Power the GPU up for a reset queued from the MMU code Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 9:09 ` sashiko-bot
2026-11-12 8:48 ` [PATCH v2 02/11] drm/panfrost: Refuse to sync the CPU caches of a heap BO Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 03/11] drm/panfrost: Don't take a reference on a mapping that is being freed Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 04/11] drm/panfrost: Don't WARN when a GEM mapping cannot get its pages Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 05/11] drm/panfrost: Unwind a failed GPU mapping without dropping " Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 06/11] drm/panfrost: Give back the pages of a heap chunk that failed to map Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 9:12 ` sashiko-bot [this message]
2026-11-12 8:48 ` [PATCH v2 07/11] drm/panfrost: Don't signal a job cancelled from _NEXT at a reset as done Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 08/11] drm/panfrost: Don't cancel a job that completed during a reset Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 09/11] drm/panfrost: Wait for the soft-stopped slots with the live slot status Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 8:48 ` [PATCH v2 10/11] drm/panfrost: Soft-stop and resume a job that outlives the timeout Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
2026-11-12 9:36 ` sashiko-bot
2026-11-12 8:48 ` [PATCH v2 11/11] drm/panfrost: Name the BOs around an unhandled page fault Arun Iyengar
2026-11-12 8:48 ` Arun Iyengar via B4 Relay
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=sashiko-outbox-210837@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aiyengar1990@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.