[0/2] iommu/sun50i: Don't report TLB prefetch walks as page faults

Message ID 20261110-sun50i-iommu-prefetch-v1-0-43428e792ef6@gmail.com (mailing list archive)
Headers
Series iommu/sun50i: Don't report TLB prefetch walks as page faults |

Message

Arun Iyengar via B4 Relay Nov. 10, 2026, 6:05 a.m. UTC
On an H616 with a display scanning out, the IOMMU reports page faults
with master -1 at the IOVA right after the end of the framebuffer: once
at the first fbcon frame, and then once per frame for a while after
each TLB flush, e.g. while a video decoder frees its buffers. They are
failed walks of the TLB prefetcher, which the hardware flags with bit 31
of the page table interrupt registers and no master bit. Patch 1 stops
reporting them. Patch 2 makes the remaining fault messages say which
walk failed and what the interrupt register held.

Tested on an Orange Pi Zero2 (H616) with HDMI forced on at 1024x768 and
three 4K H.264 decodes through cedrus, on 7.3 kernels with and without
the patches:
- without: 214 "Page fault ... (master -1, dir rd)" lines;
- with: none, no "Page fault" line at all, and no decode errors or
  timeouts.
Since the patched kernel prints every fault that is not a masterless
prefetch walk, this also shows that the hardware sets bit 31 for these
walks.

These patches were developed with Claude (Anthropic) as a coding
assistant. It investigated the problem and wrote the code and the commit
messages; I reviewed them, and they were tested on an Orange Pi Zero2
(H616) as described above.

---
Arun Iyengar (2):
      iommu/sun50i: Don't report TLB prefetches of unmapped pages as faults
      iommu/sun50i: Print the page table level and status of a fault

 drivers/iommu/sun50i-iommu.c | 50 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 39 insertions(+), 11 deletions(-)
---
base-commit: 2cf4be57b301ed2d7af82e70cff5dfd96894d8de
change-id: 20261110-sun50i-iommu-prefetch-85cc9ecff559

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>
  

Comments

Jernej Skrabec Nov. 10, 2026, 4:04 p.m. UTC | #1
Dne torek, 10. november 2026 ob 07:05:16 Srednjeevropski standardni čas je Arun Iyengar via B4 Relay napisal(a):
> On an H616 with a display scanning out, the IOMMU reports page faults
> with master -1 at the IOVA right after the end of the framebuffer: once
> at the first fbcon frame, and then once per frame for a while after
> each TLB flush, e.g. while a video decoder frees its buffers. They are
> failed walks of the TLB prefetcher, which the hardware flags with bit 31
> of the page table interrupt registers and no master bit. Patch 1 stops
> reporting them. Patch 2 makes the remaining fault messages say which
> walk failed and what the interrupt register held.
> 
> Tested on an Orange Pi Zero2 (H616) with HDMI forced on at 1024x768 and
> three 4K H.264 decodes through cedrus, on 7.3 kernels with and without
> the patches:
> - without: 214 "Page fault ... (master -1, dir rd)" lines;
> - with: none, no "Page fault" line at all, and no decode errors or
>   timeouts.
> Since the patched kernel prints every fault that is not a masterless
> prefetch walk, this also shows that the hardware sets bit 31 for these
> walks.

First off, display engine isn't in merged yet. Second, I don't observe any
such issues with my wip H616 code.

I think it's best to wait until driver is merged and can be retested and
merged then, if needed.

Best regards,
Jernej

> 
> These patches were developed with Claude (Anthropic) as a coding
> assistant. It investigated the problem and wrote the code and the commit
> messages; I reviewed them, and they were tested on an Orange Pi Zero2
> (H616) as described above.
> 
> ---
> Arun Iyengar (2):
>       iommu/sun50i: Don't report TLB prefetches of unmapped pages as faults
>       iommu/sun50i: Print the page table level and status of a fault
> 
>  drivers/iommu/sun50i-iommu.c | 50 ++++++++++++++++++++++++++++++++++----------
>  1 file changed, 39 insertions(+), 11 deletions(-)
> ---
> base-commit: 2cf4be57b301ed2d7af82e70cff5dfd96894d8de
> change-id: 20261110-sun50i-iommu-prefetch-85cc9ecff559
> 
> Best regards,
> --  
> Arun Iyengar <aiyengar1990@gmail.com>
> 
> 
>
  
Arun Iyengar Nov. 12, 2026, 8:04 a.m. UTC | #2
Hi Jernej,

On Tue, Nov 10, 2026, Jernej Skrabec wrote:
> First off, display engine isn't in merged yet. Second, I don't observe any
> such issues with my wip H616 code.
>
> I think it's best to wait until driver is merged and can be retested and
> merged then, if needed.

Agreed, thanks. In mainline the only H616 IOMMU master today is the video
engine, and the faults I saw came from the display scanning out a
framebuffer through the IOMMU, with the out-of-tree DE33 code I use. I'll
drop this series for now and retest once the display driver is merged.

Out of curiosity: does your WIP code map the framebuffer through the IOMMU?
In the boots where fbcon takes over the display, the fbcon buffer
(1024x768, 3 MiB) is the first IOVA allocation, so it ends right below
the top 1 MiB, which stays unmapped, and the prefetch walk for the page
after it fails.

Best regards,
Arun

On Tue, Nov 10, 2026 at 8:04 AM Jernej Škrabec <jernej.skrabec@gmail.com> wrote:
>
> Dne torek, 10. november 2026 ob 07:05:16 Srednjeevropski standardni čas je Arun Iyengar via B4 Relay napisal(a):
> > On an H616 with a display scanning out, the IOMMU reports page faults
> > with master -1 at the IOVA right after the end of the framebuffer: once
> > at the first fbcon frame, and then once per frame for a while after
> > each TLB flush, e.g. while a video decoder frees its buffers. They are
> > failed walks of the TLB prefetcher, which the hardware flags with bit 31
> > of the page table interrupt registers and no master bit. Patch 1 stops
> > reporting them. Patch 2 makes the remaining fault messages say which
> > walk failed and what the interrupt register held.
> >
> > Tested on an Orange Pi Zero2 (H616) with HDMI forced on at 1024x768 and
> > three 4K H.264 decodes through cedrus, on 7.3 kernels with and without
> > the patches:
> > - without: 214 "Page fault ... (master -1, dir rd)" lines;
> > - with: none, no "Page fault" line at all, and no decode errors or
> >   timeouts.
> > Since the patched kernel prints every fault that is not a masterless
> > prefetch walk, this also shows that the hardware sets bit 31 for these
> > walks.
>
> First off, display engine isn't in merged yet. Second, I don't observe any
> such issues with my wip H616 code.
>
> I think it's best to wait until driver is merged and can be retested and
> merged then, if needed.
>
> Best regards,
> Jernej
>
> >
> > These patches were developed with Claude (Anthropic) as a coding
> > assistant. It investigated the problem and wrote the code and the commit
> > messages; I reviewed them, and they were tested on an Orange Pi Zero2
> > (H616) as described above.
> >
> > ---
> > Arun Iyengar (2):
> >       iommu/sun50i: Don't report TLB prefetches of unmapped pages as faults
> >       iommu/sun50i: Print the page table level and status of a fault
> >
> >  drivers/iommu/sun50i-iommu.c | 50 ++++++++++++++++++++++++++++++++++----------
> >  1 file changed, 39 insertions(+), 11 deletions(-)
> > ---
> > base-commit: 2cf4be57b301ed2d7af82e70cff5dfd96894d8de
> > change-id: 20261110-sun50i-iommu-prefetch-85cc9ecff559
> >
> > Best regards,
> > --
> > Arun Iyengar <aiyengar1990@gmail.com>
> >
> >
> >
>
>
>
>