* [RFC PATCH 1/3] iommu/rockchip: Report the reserved regions from the devicetree
2026-12-04 6:24 [RFC PATCH 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
@ 2026-12-04 6:24 ` Francesco Saverio Pavone
2026-12-04 6:32 ` Chaoyi Chen
2026-12-04 6:24 ` [RFC PATCH 2/3] dt-bindings: display: vop2: Allow memory-region Francesco Saverio Pavone
2026-12-04 6:24 ` [RFC PATCH 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain Francesco Saverio Pavone
2 siblings, 1 reply; 5+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 6:24 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Robin Murphy, Sandy Huang,
Heiko Stuebner, Andy Yan, Chaoyi Chen
Cc: Damon Ding, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jiaxing Hu, iommu, dri-devel, devicetree,
linux-rockchip, linux-arm-kernel
The driver has no .get_resv_regions callback, so a reserved-memory node
that lists a device in "iommu-addresses" is ignored: the region is
neither kept out of the IOVA allocator nor mapped 1:1 in the default
domain.
This matters for the VOP when the bootloader leaves a window scanning
out of its own framebuffer. On RK3588 the default DMA domain is
installed on the VOP MMU as soon as the MMU is resumed, with an empty
page table, and the running scanout faults. On a ROCK 5B+ started from
EDK2 this shows as
rk_iommu fdd97e00.iommu: Enable stall request timed out, status: 0x00001d
rk_iommu fdd97e00.iommu: Enable stall request timed out, status: 0x00030b
Use of_iommu_get_resv_regions() as the callback, so that the core maps
such a region before the MMU is enabled: the probe does not touch the
hardware, and the page table is first loaded from the runtime resume.
The driver is devicetree only, and calling the OF helper directly,
instead of going through iommu_dma_get_resv_regions(), lets a consumer
read the regions on 32-bit ARM too, where IOMMU_DMA is not available.
The default domain is not a DMA domain there, so the core maps nothing
and this patch alone changes nothing on 32-bit ARM.
The IOVA space of the driver is 32 bits wide, so a region above 4 GiB
cannot be mapped 1:1. Nothing checks for that here.
Signed-off-by: Francesco Saverio Pavone <pavone.lawyer@gmail.com>
---
drivers/iommu/rockchip-iommu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 1fa3110b142ad..757532a86975c 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -20,6 +20,7 @@
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/of.h>
+#include <linux/of_iommu.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
@@ -1204,6 +1205,7 @@ static const struct iommu_ops rk_iommu_ops = {
.probe_device = rk_iommu_probe_device,
.release_device = rk_iommu_release_device,
.device_group = generic_single_device_group,
+ .get_resv_regions = of_iommu_get_resv_regions,
.of_xlate = rk_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
.attach_dev = rk_iommu_attach_device,
--
2.54.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply related [flat|nested] 5+ messages in thread* [RFC PATCH 2/3] dt-bindings: display: vop2: Allow memory-region
2026-12-04 6:24 [RFC PATCH 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
2026-12-04 6:24 ` [RFC PATCH 1/3] iommu/rockchip: Report the reserved regions from the devicetree Francesco Saverio Pavone
@ 2026-12-04 6:24 ` Francesco Saverio Pavone
2026-12-04 6:24 ` [RFC PATCH 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain Francesco Saverio Pavone
2 siblings, 0 replies; 5+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 6:24 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Robin Murphy, Sandy Huang,
Heiko Stuebner, Andy Yan, Chaoyi Chen
Cc: Damon Ding, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jiaxing Hu, iommu, dri-devel, devicetree,
linux-rockchip, linux-arm-kernel
A bootloader that shows a splash screen can leave a VOP2 window
scanning out of its own framebuffer when it starts the kernel.
Describing that buffer as a reserved-memory node with
"iommu-addresses", and pointing the VOP2 at it with "memory-region", is
the generic way to keep it mapped 1:1 behind the IOMMU until the kernel
has taken the display over.
The binding sets additionalProperties to false, so allow the property.
Signed-off-by: Francesco Saverio Pavone <pavone.lawyer@gmail.com>
---
.../devicetree/bindings/display/rockchip/rockchip-vop2.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop2.yaml b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop2.yaml
index 93da1fb9adc47..be75c5ee7042e 100644
--- a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop2.yaml
+++ b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop2.yaml
@@ -120,6 +120,12 @@ properties:
iommus:
maxItems: 1
+ memory-region:
+ maxItems: 1
+ description:
+ Phandle to a node describing a reserved framebuffer memory region.
+ For example, the splash memory region set up by the bootloader.
+
power-domains:
maxItems: 1
--
2.54.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply related [flat|nested] 5+ messages in thread* [RFC PATCH 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-04 6:24 [RFC PATCH 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
2026-12-04 6:24 ` [RFC PATCH 1/3] iommu/rockchip: Report the reserved regions from the devicetree Francesco Saverio Pavone
2026-12-04 6:24 ` [RFC PATCH 2/3] dt-bindings: display: vop2: Allow memory-region Francesco Saverio Pavone
@ 2026-12-04 6:24 ` Francesco Saverio Pavone
2 siblings, 0 replies; 5+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 6:24 UTC (permalink / raw)
To: Joerg Roedel, Will Deacon, Robin Murphy, Sandy Huang,
Heiko Stuebner, Andy Yan, Chaoyi Chen
Cc: Damon Ding, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Jiaxing Hu, iommu, dri-devel, devicetree,
linux-rockchip, linux-arm-kernel
The driver allocates its own IOMMU domain and attaches a VOP to it on
the first CRTC enable. If the bootloader left a window scanning out of
its own framebuffer, that buffer has no mapping in the new domain, and
the VOP reads it until the first new frame is latched. On a ROCK 5B+
started from EDK2, with the buffer mapped in the default domain only,
this shows at the first modeset as
rk_iommu fdd97e00.iommu: Page fault at 0x00000000e6810400 of type read
and the two "Enable stall request timed out" lines come back later,
when the compositor takes over.
When the devicetree describes the buffer as a reserved region of the
VOP ("memory-region" with "iommu-addresses"), the iommu core maps it
1:1 in the default domain. Collect the direct-mapped regions of every
VOP when it is bound, then give them the same mapping in the DRM domain
before any device is attached, and reserve the range in the drm_mm so
that no GEM object is given those addresses.
A region that does not fit in the aperture of the domain is skipped
with a warning. The mappings are kept until the domain is freed: the
driver does not know when the last read of the old buffer happens.
Signed-off-by: Francesco Saverio Pavone <pavone.lawyer@gmail.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 121 ++++++++++++++++++++
drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +
2 files changed, 123 insertions(+)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index ba417f7e9e474..aed22787c05e2 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -88,6 +88,121 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
iommu_detach_device(private->domain, dev);
}
+struct rockchip_drm_resv {
+ struct list_head list;
+ struct drm_mm_node node;
+ int prot;
+};
+
+/*
+ * Remember the direct-mapped reserved regions of a VOP. The iommu core maps
+ * them 1:1 in the default domain of the device; rockchip_drm_init_iommu()
+ * gives them the same mapping in the DRM domain.
+ */
+static void rockchip_drm_collect_resv_regions(struct drm_device *drm_dev,
+ struct device *dev)
+{
+ struct rockchip_drm_private *private = drm_dev->dev_private;
+ struct iommu_resv_region *region;
+ struct rockchip_drm_resv *resv;
+ LIST_HEAD(regions);
+
+ iommu_get_resv_regions(dev, ®ions);
+
+ list_for_each_entry(region, ®ions, list) {
+ if (region->type != IOMMU_RESV_DIRECT &&
+ region->type != IOMMU_RESV_DIRECT_RELAXABLE)
+ continue;
+
+ resv = devm_kzalloc_obj(drm_dev->dev, *resv);
+ if (!resv)
+ break;
+
+ resv->node.start = region->start;
+ resv->node.size = region->length;
+ resv->prot = region->prot;
+ list_add_tail(&resv->list, &private->resv_list);
+ }
+
+ iommu_put_resv_regions(dev, ®ions);
+}
+
+static void rockchip_drm_unmap_resv_regions(struct rockchip_drm_private *private)
+{
+ struct rockchip_drm_resv *resv;
+
+ list_for_each_entry(resv, &private->resv_list, list) {
+ if (!drm_mm_node_allocated(&resv->node))
+ continue;
+
+ iommu_unmap(private->domain, resv->node.start, resv->node.size);
+ drm_mm_remove_node(&resv->node);
+ }
+}
+
+/*
+ * Map the reserved regions of the VOPs 1:1 in the DRM domain and keep their
+ * addresses away from the GEM objects, so that a scanout left running by the
+ * bootloader keeps working when a VOP is moved over to this domain. The VOP
+ * reads the old buffer until the first new frame is latched, so the mappings
+ * stay for as long as the domain does.
+ */
+static void rockchip_drm_map_resv_regions(struct drm_device *drm_dev)
+{
+ struct rockchip_drm_private *private = drm_dev->dev_private;
+ struct iommu_domain_geometry *geometry = &private->domain->geometry;
+ unsigned long pgsz = 1UL << __ffs(private->domain->pgsize_bitmap);
+ struct rockchip_drm_resv *resv, *other;
+ u64 start, end;
+ int ret;
+
+ list_for_each_entry(resv, &private->resv_list, list) {
+ /* Same rounding as the direct mappings of the iommu core. */
+ start = ALIGN(resv->node.start, pgsz);
+ end = ALIGN(resv->node.start + resv->node.size, pgsz);
+ if (start >= end)
+ continue;
+
+ /* Two VOPs may point at the same region. */
+ ret = 0;
+ list_for_each_entry(other, &private->resv_list, list) {
+ if (other == resv)
+ break;
+ if (drm_mm_node_allocated(&other->node) &&
+ other->node.start == start &&
+ other->node.size == end - start)
+ ret = -EEXIST;
+ }
+ if (ret)
+ continue;
+
+ if (start < geometry->aperture_start ||
+ end - 1 > geometry->aperture_end) {
+ drm_warn(drm_dev,
+ "reserved region [%#llx-%#llx] is outside the IOMMU aperture\n",
+ start, end - 1);
+ continue;
+ }
+
+ resv->node.start = start;
+ resv->node.size = end - start;
+ ret = drm_mm_reserve_node(&private->mm, &resv->node);
+ if (ret) {
+ drm_warn(drm_dev, "cannot reserve [%#llx-%#llx]: %d\n",
+ start, end - 1, ret);
+ continue;
+ }
+
+ ret = iommu_map(private->domain, start, start, end - start,
+ resv->prot, GFP_KERNEL);
+ if (ret) {
+ drm_warn(drm_dev, "cannot map [%#llx-%#llx]: %d\n",
+ start, end - 1, ret);
+ drm_mm_remove_node(&resv->node);
+ }
+ }
+}
+
void rockchip_drm_dma_init_device(struct drm_device *drm_dev,
struct device *dev)
{
@@ -100,6 +215,9 @@ void rockchip_drm_dma_init_device(struct drm_device *drm_dev,
if (!IS_ERR(private->iommu_dev))
drm_dev_set_dma_dev(drm_dev, private->iommu_dev);
+
+ if (device_iommu_mapped(dev))
+ rockchip_drm_collect_resv_regions(drm_dev, dev);
}
static int rockchip_drm_init_iommu(struct drm_device *drm_dev)
@@ -127,6 +245,7 @@ static int rockchip_drm_init_iommu(struct drm_device *drm_dev)
start, end);
drm_mm_init(&private->mm, start, end - start + 1);
mutex_init(&private->mm_lock);
+ rockchip_drm_map_resv_regions(drm_dev);
return 0;
}
@@ -138,6 +257,7 @@ static void rockchip_iommu_cleanup(struct drm_device *drm_dev)
if (!private->domain)
return;
+ rockchip_drm_unmap_resv_regions(private);
drm_mm_takedown(&private->mm);
iommu_domain_free(private->domain);
}
@@ -170,6 +290,7 @@ static int rockchip_drm_bind(struct device *dev)
}
drm_dev->dev_private = private;
+ INIT_LIST_HEAD(&private->resv_list);
ret = drmm_mode_config_init(drm_dev);
if (ret)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index 4705dc6b8bd7d..f107342527c6d 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -67,12 +67,14 @@ struct rockchip_crtc_state {
* @crtc: array of enabled CRTCs, used to map from "pipe" to drm_crtc.
* @num_pipe: number of pipes for this device.
* @mm_lock: protect drm_mm on multi-threads.
+ * @resv_list: reserved regions of the VOPs, mapped 1:1 in @domain.
*/
struct rockchip_drm_private {
struct iommu_domain *domain;
struct device *iommu_dev;
struct mutex mm_lock;
struct drm_mm mm;
+ struct list_head resv_list;
};
struct rockchip_encoder {
--
2.54.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply related [flat|nested] 5+ messages in thread