Hi,

This is the series Chaoyi asked for in [1]. On a ROCK 5B+ (RK3588)
started from EDK2 the firmware leaves one VOP2 window scanning out of
its framebuffer, and the VOP MMU faults on it: first when the default
DMA domain is installed with an empty page table and, with the fbdev
client on, again when the VOP is moved to the private domain of the
DRM driver.

Patch 1 makes rockchip-iommu report the reserved regions from the
devicetree, so the core maps them 1:1 in the default domain. Patch 2
lets a VOP2 node carry memory-region. Patch 3 gives the same regions a
1:1 mapping in the DRM domain and keeps them out of the drm_mm.

Tested on v7.4-rc5 on the ROCK 5B+, with this node added to the board
DTS by hand (not part of the series):

  reserved-memory {
    fw_fb: framebuffer@e6810000 {
      reg = <0x0 0xe6810000 0x0 0x00e10000>;
      iommu-addresses = <&vop 0x0 0xe6810000 0x0 0x00e10000>;
    };
  };

  &vop {
    memory-region = <&fw_fb>;
  };

Boots with rk_iommu errors in the log:

                              fbdev client off   fbdev client on
  v7.4-rc5                    3 of 3             2 of 2
  series, no node             2 of 2             2 of 2
  series, node                0 of 4             0 of 4

The two "series" rows are the same kernel image with a different DTB.
With the client off the errors are the two "Enable stall request timed
out" lines at 0.2 s. With the client on the same two lines come back
when the compositor starts, in all four boots, and there are one to
three page faults on the firmware buffer (0xe6810000 and up), at 0.4 s
and in two of the four boots again at that point. With the node, the
VOP group lists the region 0xe6810000-0xe761ffff as direct in
reserved_regions and the log has no rk_iommu line at all.

I watched one boot with the series, the node and the client on: the
TV shows the firmware logo, then the kernel console, then the desktop,
and never loses the signal.

Robin, on the points you raised in [2]:

 - rk_iommu_probe() does not touch the hardware. For the default
   domain the page table is first loaded from the runtime resume, when
   the VOP resumes through the device link, and by then the core has
   already created the direct mappings. rk_iommu_enable() still does a
   force reset first, with the window running; I have not changed
   that.
 - The switch to the DRM domain is different: it happens with the VOP
   active, so rk_iommu_attach_device() turns paging off, resets and
   loads the new table. Patch 3 has the region mapped in that table
   before the attach. The logs above show no fault across it, but the
   reset with a live window is still there.
 - The IOMMU starts runtime suspended and I found nothing that resumes
   it before the consumer link exists. On suspend the driver turns
   paging off, which for a 1:1 region addresses the same memory, and
   on resume it loads the same table again.

What this does not cover, and where I would like your opinion:

 - Patch 1 uses of_iommu_get_resv_regions() directly, not
   iommu_dma_get_resv_regions(), so that patch 3 can read the regions
   on 32-bit ARM, where IOMMU_DMA is not there. On 32-bit ARM the core
   maps nothing (the default domain is the identity domain) and the
   ARM DMA mapping installed for the VOP is empty, so until the DRM
   attach nothing is mapped there. Compile-tested only on 32-bit ARM.
 - The region is reported as direct, so the core keeps it as a
   required direct mapping for the life of the device. Is that
   acceptable for a buffer that is only needed until the first frame?
 - The IOVA space is 32 bits. A buffer above 4 GiB cannot be mapped
   1:1; patch 3 skips it with a warning, patch 1 does not check.
 - Patch 3 calls iommu_get_resv_regions() from a DRM driver, which no
   other driver does. Should this be a helper in the iommu core?
 - The mapping and the hole in the IOVA space stay until the domain is
   freed, because the driver does not know when the old buffer is read
   for the last time.
 - The power domain of the VOP is switched off as unused when the DRM
   driver binds late, as a module. The picture is lost then, whatever
   is mapped. I saw that on v7.4-rc4; not retested with the series.
 - Nothing in mainline writes the node. The address depends on the
   mode the firmware picked, so the firmware has to add it, the way
   the exynos7870 boards describe theirs for the decon.
 - VOP1 resets itself and turns its windows off at bind, so I left
   rockchip-vop.yaml alone. Not tested on VOP1 hardware.

dt_binding_check is clean for rockchip-vop2.yaml (dtschema 2026.9),
and so is CHECK_DTBS for the board DTB with the node added.

The patches were written with Claude (Anthropic). I ran the boots
above on my board and checked the logs.

[1] 
https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Francesco Saverio Pavone (3):
  iommu/rockchip: Report the reserved regions from the devicetree
  dt-bindings: display: vop2: Allow memory-region
  drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain

 .../display/rockchip/rockchip-vop2.yaml       |   6 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   | 121 ++++++++++++++++++
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h   |   2 +
 drivers/iommu/rockchip-iommu.c                |   2 +
 4 files changed, 131 insertions(+)


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.54.0

Reply via email to