* [RFC PATCH v2 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU
@ 2026-12-04 10:27 Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 1/3] iommu/rockchip: Report the reserved regions from the devicetree Francesco Saverio Pavone
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 10:27 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
Hi,
This series keeps the framebuffer that the firmware leaves on screen
mapped while the kernel takes the display over. Patch 1 makes
rockchip-iommu report the reserved regions from the devicetree. Patch 2
lets a VOP2 node carry memory-region. Patch 3 maps the same regions
1:1 in the DRM driver's IOMMU domain. Tested on a ROCK 5B+ (RK3588)
started from EDK2.
Changes since v1:
Patch 1:
- Drop a direct region that does not fit in the 32-bit IOVA space,
clip a reserved region that crosses 4 GiB and drop one above it.
A dropped region is reported with a ratelimited warning
(sashiko [2]).
I did not add range checks to map/unmap/iova_to_phys: iommu-dma
allocates below aperture_end, the DRM drm_mm covers only the
aperture, and the core direct mappings now only see regions below
4 GiB.
- Shorter commit message (Chaoyi [1]).
Patch 2:
- Commit message reworded, it overstated how long the mapping lasts.
The binding text is unchanged.
Patch 3:
- Keep IOMMU_RESV_RESERVED ranges out of the drm_mm without mapping
them (sashiko [3]).
- Round in one helper, with the smallest page of the domain, like the
iommu core. A direct range is mapped as the core maps it, so the
head page of an unaligned region is not mapped. Every range is kept
out of the drm_mm rounded out (Chaoyi [4]).
- Merge overlapping ranges, so the union is kept out of the drm_mm
and each direct page is mapped once (Chaoyi [4]).
- A direct range that overlaps one with a different prot is not
mapped, with a warning; its hole stays reserved.
- Drop the comment above the collect function and shorten the commit
message (Chaoyi [4]).
Test, on v7.4-rc5 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>;
};
With the node, v2 had no rk_iommu line in 2 of 2 boots with the fbdev
client off and 3 of 3 with it on. The VOP group lists
0xe6810000-0xe761ffff as direct in reserved_regions, and there are no
warnings. I watched one boot with
the client on: firmware logo, console, desktop, no lost picture. The
rows without the node were not rerun. In v1 they had errors in every
boot: v7.4-rc5 3 of 3 and 2 of 2, series without the node 2 of 2 and
2 of 2.
Not tested:
- No devicetree exercised the new paths at run time (reserved-only
region, region above 4 GiB, unaligned, overlapping). I checked the
merge and rounding logic with a small userspace test and by reading
the code.
- 32-bit ARM is compile-tested only, with clang.
- No 16K or 64K page build.
- VOP1: only the VOP2 binding allows memory-region, so nothing is
collected for VOP1.
Limits kept from v1:
- The direct region stays required for the life of the device.
- The mapping stays until the domain is freed.
- A late bind as a module loses the power domain of the VOP.
- Nothing in mainline writes the node.
The questions for Robin in v1 [5] still stand, except the 4 GiB one,
which patch 1 now handles.
Checks: W=1 builds of rockchip-iommu and drivers/gpu/drm/rockchip are
clean at each commit, on arm64 and on 32-bit ARM. dt_binding_check was
not rerun, the binding text is unchanged from v1.
The patches and this letter were written with Claude (Anthropic). I
ran the boots on my board and checked the logs.
Thanks for the review.
[1] https://lore.kernel.org/all/e725f663-43ab-4011-8635-f59eb016d148@rock-chips.com/
[2] https://lore.kernel.org/all/sashiko-outbox-249243@kernel.org/
[3] https://lore.kernel.org/all/sashiko-outbox-249247@kernel.org/
[4] https://lore.kernel.org/all/2e35a072-45ff-4438-a5d9-cd67cf8d1424@rock-chips.com/
[5] https://lore.kernel.org/all/cover.1796334467.git.pavone.lawyer@gmail.com/
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 | 227 ++++++++++++++++++
drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 6 +
drivers/iommu/rockchip-iommu.c | 32 +++
4 files changed, 271 insertions(+)
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.54.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC PATCH v2 1/3] iommu/rockchip: Report the reserved regions from the devicetree
2026-12-04 10:27 [RFC PATCH v2 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
@ 2026-12-04 10:27 ` Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 2/3] dt-bindings: display: vop2: Allow memory-region Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain Francesco Saverio Pavone
2 siblings, 0 replies; 10+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 10:27 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 the iommu core ignores
a reserved-memory node that lists a device in "iommu-addresses". A
bootloader framebuffer that the VOP still scans out is then not mapped
in the default domain, and the VOP MMU faults on it.
Report the regions with of_iommu_get_resv_regions(). It is called
directly, not through iommu_dma_get_resv_regions(), so that the DRM
driver can read the regions on 32-bit ARM too.
The IOVA space is 32 bits wide and the page table index would wrap a
higher address. So drop a direct region that does not fit, with a
warning, clip a reserved one that crosses 4 GiB and drop one above it.
Signed-off-by: Francesco Saverio Pavone <pavone.lawyer@gmail.com>
---
drivers/iommu/rockchip-iommu.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 1fa3110b142ad..2df71a3e62e2e 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>
@@ -1198,12 +1199,43 @@ static int rk_iommu_of_xlate(struct device *dev,
return 0;
}
+static void rk_iommu_get_resv_regions(struct device *dev,
+ struct list_head *head)
+{
+ struct iommu_resv_region *region, *next;
+ LIST_HEAD(regions);
+ LIST_HEAD(drop);
+
+ of_iommu_get_resv_regions(dev, ®ions);
+
+ /* The IOVA is 32 bits wide, see rk_iova_dte_index() */
+ list_for_each_entry_safe(region, next, ®ions, list) {
+ if (region->start <= DMA_BIT_MASK(32) &&
+ region->length - 1 <= DMA_BIT_MASK(32) - region->start)
+ continue;
+
+ if (region->type == IOMMU_RESV_RESERVED &&
+ region->start <= DMA_BIT_MASK(32)) {
+ region->length = DMA_BIT_MASK(32) - region->start + 1;
+ continue;
+ }
+
+ dev_warn_ratelimited(dev, "ignoring reserved region %pa+%#zx beyond 4 GiB\n",
+ ®ion->start, region->length);
+ list_move_tail(®ion->list, &drop);
+ }
+
+ iommu_put_resv_regions(dev, &drop);
+ list_splice_tail(®ions, head);
+}
+
static const struct iommu_ops rk_iommu_ops = {
.identity_domain = &rk_identity_domain,
.domain_alloc_paging = rk_iommu_domain_alloc_paging,
.probe_device = rk_iommu_probe_device,
.release_device = rk_iommu_release_device,
.device_group = generic_single_device_group,
+ .get_resv_regions = rk_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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH v2 2/3] dt-bindings: display: vop2: Allow memory-region
2026-12-04 10:27 [RFC PATCH v2 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 1/3] iommu/rockchip: Report the reserved regions from the devicetree Francesco Saverio Pavone
@ 2026-12-04 10:27 ` Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain Francesco Saverio Pavone
2 siblings, 0 replies; 10+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 10:27 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 have it mapped 1:1 behind the IOMMU, so that the
scanout keeps working while the kernel takes 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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-04 10:27 [RFC PATCH v2 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 1/3] iommu/rockchip: Report the reserved regions from the devicetree Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 2/3] dt-bindings: display: vop2: Allow memory-region Francesco Saverio Pavone
@ 2026-12-04 10:27 ` Francesco Saverio Pavone
2026-12-04 12:00 ` Robin Murphy
2 siblings, 1 reply; 10+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 10:27 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 attaches the VOPs to its own IOMMU domain. A framebuffer
left scanning out by the bootloader has no mapping there, and the VOP
faults on it until the first new frame is latched.
Collect the reserved regions of each VOP at bind. Before any VOP is
attached, merge overlapping regions, keep the result out of the drm_mm,
rounded out to whole IOMMU pages, so that no GEM object gets those
addresses, and map the direct ones 1:1 in the DRM domain, with the same
rounding as the iommu core.
A direct region outside the aperture, or overlapping one with a
different prot, is not mapped, with a warning. The mappings stay until
the domain is freed, because the driver does not know when the old
buffer is read for the last time.
Signed-off-by: Francesco Saverio Pavone <pavone.lawyer@gmail.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 227 ++++++++++++++++++++
drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 6 +
2 files changed, 233 insertions(+)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index ba417f7e9e474..95eebd2d3e060 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/of_graph.h>
#include <linux/of_platform.h>
+#include <linux/overflow.h>
#include <linux/component.h>
#include <linux/console.h>
#include <linux/iommu.h>
@@ -88,6 +89,224 @@ 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;
+ u64 start;
+ u64 length;
+ int prot;
+ bool direct;
+};
+
+/* A merged range, kept out of the drm_mm or mapped 1:1 */
+struct rockchip_drm_range {
+ struct list_head list;
+ struct drm_mm_node node;
+ u64 start;
+ u64 end;
+ int prot;
+ bool mapped;
+};
+
+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 &&
+ region->type != IOMMU_RESV_RESERVED)
+ continue;
+
+ resv = devm_kzalloc_obj(drm_dev->dev, *resv);
+ if (!resv) {
+ drm_warn(drm_dev, "cannot record the reserved regions of %s\n",
+ dev_name(dev));
+ break;
+ }
+
+ resv->start = region->start;
+ resv->length = region->length;
+ resv->prot = region->prot;
+ resv->direct = region->type != IOMMU_RESV_RESERVED;
+ list_add_tail(&resv->list, &private->resv_list);
+ }
+
+ iommu_put_resv_regions(dev, ®ions);
+}
+
+/*
+ * The range kept out of the drm_mm is rounded out, so that no partly
+ * reserved page is handed out. The range mapped for a direct region is
+ * rounded like iommu_create_device_direct_mappings() does, so that it gets
+ * the same mapping as in the default domain; it may be empty.
+ */
+static int rockchip_drm_resv_range(const struct rockchip_drm_resv *resv,
+ u64 pgsz, u64 *start, u64 *end,
+ u64 *map_start)
+{
+ u64 end_excl;
+
+ if (check_add_overflow(resv->start, resv->length, &end_excl))
+ return -EOVERFLOW;
+
+ *start = ALIGN_DOWN(resv->start, pgsz);
+ *end = ALIGN(end_excl, pgsz);
+ if (*end < end_excl)
+ return -EOVERFLOW;
+ if (*start >= *end)
+ return -EINVAL;
+
+ *map_start = ALIGN(resv->start, pgsz);
+
+ return 0;
+}
+
+/*
+ * Add [start, end) to a sorted list of disjoint ranges, merging it with the
+ * ranges of the same prot that it overlaps or touches. An overlap with a
+ * range of another prot is refused.
+ */
+static int rockchip_drm_add_range(struct list_head *head, u64 start, u64 end,
+ int prot)
+{
+ struct rockchip_drm_range *range, *tmp, *new;
+ struct list_head *pos = head;
+
+ list_for_each_entry(range, head, list)
+ if (range->prot != prot && range->start < end &&
+ start < range->end)
+ return -EBUSY;
+
+ new = kzalloc_obj(*new);
+ if (!new)
+ return -ENOMEM;
+
+ list_for_each_entry_safe(range, tmp, head, list) {
+ if (range->end < start ||
+ (range->end == start && range->prot != prot)) {
+ pos = &range->list;
+ continue;
+ }
+ if (range->start > end ||
+ (range->start == end && range->prot != prot))
+ break;
+
+ start = min(start, range->start);
+ end = max(end, range->end);
+ list_del(&range->list);
+ kfree(range);
+ }
+
+ new->start = start;
+ new->end = end;
+ new->prot = prot;
+ list_add(&new->list, pos);
+
+ return 0;
+}
+
+static void rockchip_drm_unmap_resv_regions(struct rockchip_drm_private *private)
+{
+ struct rockchip_drm_range *range, *tmp;
+
+ list_for_each_entry_safe(range, tmp, &private->resv_maps, list) {
+ if (range->mapped)
+ iommu_unmap(private->domain, range->start,
+ range->end - range->start);
+ list_del(&range->list);
+ kfree(range);
+ }
+
+ list_for_each_entry_safe(range, tmp, &private->resv_holes, list) {
+ if (drm_mm_node_allocated(&range->node))
+ drm_mm_remove_node(&range->node);
+ list_del(&range->list);
+ kfree(range);
+ }
+}
+
+/*
+ * Keep the reserved regions of the VOPs out of the drm_mm, and map the
+ * direct ones 1:1, for as long as the domain exists.
+ */
+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;
+ u64 pgsz = 1ULL << __ffs(private->domain->pgsize_bitmap);
+ struct rockchip_drm_range *range;
+ struct rockchip_drm_resv *resv;
+ u64 start, end, map_start;
+ int ret;
+
+ list_for_each_entry(resv, &private->resv_list, list) {
+ ret = rockchip_drm_resv_range(resv, pgsz, &start, &end,
+ &map_start);
+ if (!ret)
+ ret = rockchip_drm_add_range(&private->resv_holes,
+ start, end, 0);
+ if (ret) {
+ drm_warn(drm_dev, "ignoring reserved region %#llx+%#llx: %d\n",
+ resv->start, resv->length, ret);
+ continue;
+ }
+
+ if (!resv->direct || map_start >= end)
+ continue;
+
+ ret = rockchip_drm_add_range(&private->resv_maps, map_start,
+ end, resv->prot);
+ if (ret)
+ drm_warn(drm_dev, "reserved region %#llx+%#llx not mapped: %d\n",
+ resv->start, resv->length, ret);
+ }
+
+ list_for_each_entry(range, &private->resv_holes, list) {
+ start = max(range->start, geometry->aperture_start);
+ end = min(range->end - 1, geometry->aperture_end);
+ if (start > end)
+ continue;
+
+ range->node.start = start;
+ range->node.size = end - start + 1;
+ ret = drm_mm_reserve_node(&private->mm, &range->node);
+ if (ret)
+ drm_warn(drm_dev, "cannot reserve [%#llx-%#llx]: %d\n",
+ start, end, ret);
+ }
+
+ list_for_each_entry(range, &private->resv_maps, list) {
+ start = range->start;
+ end = range->end;
+ 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;
+ }
+ if (end - start > SIZE_MAX) {
+ drm_warn(drm_dev, "reserved region [%#llx-%#llx] is too large to map\n",
+ start, end - 1);
+ continue;
+ }
+
+ ret = iommu_map(private->domain, start, start, end - start,
+ range->prot, GFP_KERNEL);
+ if (ret)
+ drm_warn(drm_dev, "cannot map [%#llx-%#llx]: %d\n",
+ start, end - 1, ret);
+ else
+ range->mapped = true;
+ }
+}
+
void rockchip_drm_dma_init_device(struct drm_device *drm_dev,
struct device *dev)
{
@@ -100,6 +319,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 +349,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 +361,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 +394,9 @@ static int rockchip_drm_bind(struct device *dev)
}
drm_dev->dev_private = private;
+ INIT_LIST_HEAD(&private->resv_list);
+ INIT_LIST_HEAD(&private->resv_holes);
+ INIT_LIST_HEAD(&private->resv_maps);
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..42e0c0de93006 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -67,12 +67,18 @@ 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, as reported by the IOMMU.
+ * @resv_holes: merged reserved ranges, kept out of @mm.
+ * @resv_maps: merged direct ranges, 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 list_head resv_holes;
+ struct list_head resv_maps;
};
struct rockchip_encoder {
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-04 10:27 ` [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain Francesco Saverio Pavone
@ 2026-12-04 12:00 ` Robin Murphy
2026-12-04 15:32 ` Francesco Saverio Pavone
0 siblings, 1 reply; 10+ messages in thread
From: Robin Murphy @ 2026-12-04 12:00 UTC (permalink / raw)
To: Francesco Saverio Pavone, Joerg Roedel, Will Deacon, 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
On 2026-12-04 10:27 am, Francesco Saverio Pavone wrote:
> The driver attaches the VOPs to its own IOMMU domain. A framebuffer
> left scanning out by the bootloader has no mapping there, and the VOP
> faults on it until the first new frame is latched.
>
> Collect the reserved regions of each VOP at bind. Before any VOP is
> attached, merge overlapping regions, keep the result out of the drm_mm,
> rounded out to whole IOMMU pages, so that no GEM object gets those
> addresses, and map the direct ones 1:1 in the DRM domain, with the same
> rounding as the iommu core.
>
> A direct region outside the aperture, or overlapping one with a
> different prot, is not mapped, with a warning. The mappings stay until
> the domain is freed, because the driver does not know when the old
> buffer is read for the last time.
Surely a bootsplash screen should be described by a simple-framebuffer
device, and that the standard DRM mechanisms used to take over from that?
If you reach the point of creating private abstractions of entire IOMMU
API concepts inside a DRM driver, you should probably stop and think
"Why aren't other drivers doing this?"
Thanks,
Robin.
> Signed-off-by: Francesco Saverio Pavone <pavone.lawyer@gmail.com>
> ---
> drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 227 ++++++++++++++++++++
> drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 6 +
> 2 files changed, 233 insertions(+)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index ba417f7e9e474..95eebd2d3e060 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -13,6 +13,7 @@
> #include <linux/module.h>
> #include <linux/of_graph.h>
> #include <linux/of_platform.h>
> +#include <linux/overflow.h>
> #include <linux/component.h>
> #include <linux/console.h>
> #include <linux/iommu.h>
> @@ -88,6 +89,224 @@ 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;
> + u64 start;
> + u64 length;
> + int prot;
> + bool direct;
> +};
> +
> +/* A merged range, kept out of the drm_mm or mapped 1:1 */
> +struct rockchip_drm_range {
> + struct list_head list;
> + struct drm_mm_node node;
> + u64 start;
> + u64 end;
> + int prot;
> + bool mapped;
> +};
> +
> +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 &&
> + region->type != IOMMU_RESV_RESERVED)
> + continue;
> +
> + resv = devm_kzalloc_obj(drm_dev->dev, *resv);
> + if (!resv) {
> + drm_warn(drm_dev, "cannot record the reserved regions of %s\n",
> + dev_name(dev));
> + break;
> + }
> +
> + resv->start = region->start;
> + resv->length = region->length;
> + resv->prot = region->prot;
> + resv->direct = region->type != IOMMU_RESV_RESERVED;
> + list_add_tail(&resv->list, &private->resv_list);
> + }
> +
> + iommu_put_resv_regions(dev, ®ions);
> +}
> +
> +/*
> + * The range kept out of the drm_mm is rounded out, so that no partly
> + * reserved page is handed out. The range mapped for a direct region is
> + * rounded like iommu_create_device_direct_mappings() does, so that it gets
> + * the same mapping as in the default domain; it may be empty.
> + */
> +static int rockchip_drm_resv_range(const struct rockchip_drm_resv *resv,
> + u64 pgsz, u64 *start, u64 *end,
> + u64 *map_start)
> +{
> + u64 end_excl;
> +
> + if (check_add_overflow(resv->start, resv->length, &end_excl))
> + return -EOVERFLOW;
> +
> + *start = ALIGN_DOWN(resv->start, pgsz);
> + *end = ALIGN(end_excl, pgsz);
> + if (*end < end_excl)
> + return -EOVERFLOW;
> + if (*start >= *end)
> + return -EINVAL;
> +
> + *map_start = ALIGN(resv->start, pgsz);
> +
> + return 0;
> +}
> +
> +/*
> + * Add [start, end) to a sorted list of disjoint ranges, merging it with the
> + * ranges of the same prot that it overlaps or touches. An overlap with a
> + * range of another prot is refused.
> + */
> +static int rockchip_drm_add_range(struct list_head *head, u64 start, u64 end,
> + int prot)
> +{
> + struct rockchip_drm_range *range, *tmp, *new;
> + struct list_head *pos = head;
> +
> + list_for_each_entry(range, head, list)
> + if (range->prot != prot && range->start < end &&
> + start < range->end)
> + return -EBUSY;
> +
> + new = kzalloc_obj(*new);
> + if (!new)
> + return -ENOMEM;
> +
> + list_for_each_entry_safe(range, tmp, head, list) {
> + if (range->end < start ||
> + (range->end == start && range->prot != prot)) {
> + pos = &range->list;
> + continue;
> + }
> + if (range->start > end ||
> + (range->start == end && range->prot != prot))
> + break;
> +
> + start = min(start, range->start);
> + end = max(end, range->end);
> + list_del(&range->list);
> + kfree(range);
> + }
> +
> + new->start = start;
> + new->end = end;
> + new->prot = prot;
> + list_add(&new->list, pos);
> +
> + return 0;
> +}
> +
> +static void rockchip_drm_unmap_resv_regions(struct rockchip_drm_private *private)
> +{
> + struct rockchip_drm_range *range, *tmp;
> +
> + list_for_each_entry_safe(range, tmp, &private->resv_maps, list) {
> + if (range->mapped)
> + iommu_unmap(private->domain, range->start,
> + range->end - range->start);
> + list_del(&range->list);
> + kfree(range);
> + }
> +
> + list_for_each_entry_safe(range, tmp, &private->resv_holes, list) {
> + if (drm_mm_node_allocated(&range->node))
> + drm_mm_remove_node(&range->node);
> + list_del(&range->list);
> + kfree(range);
> + }
> +}
> +
> +/*
> + * Keep the reserved regions of the VOPs out of the drm_mm, and map the
> + * direct ones 1:1, for as long as the domain exists.
> + */
> +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;
> + u64 pgsz = 1ULL << __ffs(private->domain->pgsize_bitmap);
> + struct rockchip_drm_range *range;
> + struct rockchip_drm_resv *resv;
> + u64 start, end, map_start;
> + int ret;
> +
> + list_for_each_entry(resv, &private->resv_list, list) {
> + ret = rockchip_drm_resv_range(resv, pgsz, &start, &end,
> + &map_start);
> + if (!ret)
> + ret = rockchip_drm_add_range(&private->resv_holes,
> + start, end, 0);
> + if (ret) {
> + drm_warn(drm_dev, "ignoring reserved region %#llx+%#llx: %d\n",
> + resv->start, resv->length, ret);
> + continue;
> + }
> +
> + if (!resv->direct || map_start >= end)
> + continue;
> +
> + ret = rockchip_drm_add_range(&private->resv_maps, map_start,
> + end, resv->prot);
> + if (ret)
> + drm_warn(drm_dev, "reserved region %#llx+%#llx not mapped: %d\n",
> + resv->start, resv->length, ret);
> + }
> +
> + list_for_each_entry(range, &private->resv_holes, list) {
> + start = max(range->start, geometry->aperture_start);
> + end = min(range->end - 1, geometry->aperture_end);
> + if (start > end)
> + continue;
> +
> + range->node.start = start;
> + range->node.size = end - start + 1;
> + ret = drm_mm_reserve_node(&private->mm, &range->node);
> + if (ret)
> + drm_warn(drm_dev, "cannot reserve [%#llx-%#llx]: %d\n",
> + start, end, ret);
> + }
> +
> + list_for_each_entry(range, &private->resv_maps, list) {
> + start = range->start;
> + end = range->end;
> + 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;
> + }
> + if (end - start > SIZE_MAX) {
> + drm_warn(drm_dev, "reserved region [%#llx-%#llx] is too large to map\n",
> + start, end - 1);
> + continue;
> + }
> +
> + ret = iommu_map(private->domain, start, start, end - start,
> + range->prot, GFP_KERNEL);
> + if (ret)
> + drm_warn(drm_dev, "cannot map [%#llx-%#llx]: %d\n",
> + start, end - 1, ret);
> + else
> + range->mapped = true;
> + }
> +}
> +
> void rockchip_drm_dma_init_device(struct drm_device *drm_dev,
> struct device *dev)
> {
> @@ -100,6 +319,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 +349,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 +361,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 +394,9 @@ static int rockchip_drm_bind(struct device *dev)
> }
>
> drm_dev->dev_private = private;
> + INIT_LIST_HEAD(&private->resv_list);
> + INIT_LIST_HEAD(&private->resv_holes);
> + INIT_LIST_HEAD(&private->resv_maps);
>
> 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..42e0c0de93006 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> @@ -67,12 +67,18 @@ 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, as reported by the IOMMU.
> + * @resv_holes: merged reserved ranges, kept out of @mm.
> + * @resv_maps: merged direct ranges, 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 list_head resv_holes;
> + struct list_head resv_maps;
> };
>
> struct rockchip_encoder {
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-04 12:00 ` Robin Murphy
@ 2026-12-04 15:32 ` Francesco Saverio Pavone
2026-12-04 17:14 ` Robin Murphy
0 siblings, 1 reply; 10+ messages in thread
From: Francesco Saverio Pavone @ 2026-12-04 15:32 UTC (permalink / raw)
To: Robin Murphy
Cc: Joerg Roedel, Will Deacon, Sandy Huang, Heiko Stuebner, Andy Yan,
Chaoyi Chen, 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
Hi Robin,
On 2026-12-04 12:00, Robin Murphy wrote:
> If you reach the point of creating private abstractions of entire
> IOMMU API concepts inside a DRM driver, you should probably stop and
> think "Why aren't other drivers doing this?"
Thank you. That was blunt, and it was right. I went and looked: no
driver outside drivers/iommu walks the reserved regions the way my
patch does.
I am withdrawing the series.
The driver already does the standard takeover. I think the real gap
is smaller: the VOP2 is not stopped before it is attached to the
IOMMU domain, while the older VOP driver resets itself first. I will
look at that instead, and only send something if it removes the
faults on my board.
Thanks,
Francesco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-04 15:32 ` Francesco Saverio Pavone
@ 2026-12-04 17:14 ` Robin Murphy
2026-12-05 2:19 ` Chaoyi Chen
0 siblings, 1 reply; 10+ messages in thread
From: Robin Murphy @ 2026-12-04 17:14 UTC (permalink / raw)
To: Francesco Saverio Pavone
Cc: Joerg Roedel, Will Deacon, Sandy Huang, Heiko Stuebner, Andy Yan,
Chaoyi Chen, 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
On 04/12/2026 3:32 pm, Francesco Saverio Pavone wrote:
> Hi Robin,
>
> On 2026-12-04 12:00, Robin Murphy wrote:
>> If you reach the point of creating private abstractions of entire
>> IOMMU API concepts inside a DRM driver, you should probably stop and
>> think "Why aren't other drivers doing this?"
>
> Thank you. That was blunt, and it was right. I went and looked: no
> driver outside drivers/iommu walks the reserved regions the way my
> patch does.
Heh, sometimes it's hard to see the wood for the trees when you're
working backwards from one very specific symptom of a larger issue.
> I am withdrawing the series.
>
> The driver already does the standard takeover. I think the real gap
> is smaller: the VOP2 is not stopped before it is attached to the
> IOMMU domain, while the older VOP driver resets itself first. I will
> look at that instead, and only send something if it removes the
> faults on my board.
I don't doubt that both the IOMMU driver and the VOP drivers might need
a bit of smoothing out to make this properly work, it's just one of
those scenarios where I'm almost certain that taking a step back to do
things the "right" way will end up being easier.
And that's not to say that this "minimal glitch" approach of pre-mapping
the initial framebuffer prior to attaching the domain (and ideally
unmapping it again as soon as we're sure it's out of use) isn't still
potentially worth exploring, just that I'd hope we could pull the
relevant config straight out of the VOP registers, or at worst add a
DRM-appropriate way to query any existing sysfb aperture. But yeah, if
just stopping the thing for the duration of driver registration is good
enough for now, even simpler!
Cheers,
Robin.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-04 17:14 ` Robin Murphy
@ 2026-12-05 2:19 ` Chaoyi Chen
2026-12-05 4:06 ` Sebastian Reichel
0 siblings, 1 reply; 10+ messages in thread
From: Chaoyi Chen @ 2026-12-05 2:19 UTC (permalink / raw)
To: Robin Murphy, Francesco Saverio Pavone
Cc: Joerg Roedel, Will Deacon, Sandy Huang, Heiko Stuebner, Andy Yan,
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
Hi,
On 12/5/2026 1:14 AM, Robin Murphy wrote:
> On 04/12/2026 3:32 pm, Francesco Saverio Pavone wrote:
>> Hi Robin,
>>
>> On 2026-12-04 12:00, Robin Murphy wrote:
>>> If you reach the point of creating private abstractions of entire
>>> IOMMU API concepts inside a DRM driver, you should probably stop and
>>> think "Why aren't other drivers doing this?"
>>
>> Thank you. That was blunt, and it was right. I went and looked: no
>> driver outside drivers/iommu walks the reserved regions the way my
>> patch does.
>
> Heh, sometimes it's hard to see the wood for the trees when you're working backwards from one very specific symptom of a larger issue.
>
>> I am withdrawing the series.
>>
>> The driver already does the standard takeover. I think the real gap
>> is smaller: the VOP2 is not stopped before it is attached to the
>> IOMMU domain, while the older VOP driver resets itself first. I will
>> look at that instead, and only send something if it removes the
>> faults on my board.
>
> I don't doubt that both the IOMMU driver and the VOP drivers might need a bit of smoothing out to make this properly work, it's just one of those scenarios where I'm almost certain that taking a step back to do things the "right" way will end up being easier.
>
> And that's not to say that this "minimal glitch" approach of pre-mapping the initial framebuffer prior to attaching the domain (and ideally unmapping it again as soon as we're sure it's out of use) isn't still potentially worth exploring, just that I'd hope we could pull the relevant config straight out of the VOP registers, or at worst add a DRM-appropriate way to query any existing sysfb aperture. But yeah, if just stopping the thing for the duration of driver registration is good enough for now, even simpler!
>
Yes, this depends largely on what we are trying to achieve.
If we merely want to eliminate the IOMMU warnings, then resetting the
hardware before attach, or stopping the DMA, would easily accomplish that.
But if we want the display to remain completely continuous throughout the
entire boot process and to transition smoothly from IOMMU disabled to
IOMMU enabled, then it may require more effort.
I saw some interesting examples:
- Exynos uses a default domain.
- Msm mdp4/mdp5 disable display before attaching IOMMU.
- i915 wraps the reserved region as a GEM object (DRM framebuffer)
and displays it.
If we adopt an i915-style takeover, perhaps we need to do the following:
{
rockchip_gem_alloc_object() /* alloc object */
drm_mm_reserve_node() /* optional? reserve old iova */
iommu_map_sgtable() /* map old iova to new GEM */
/* copy old fb data to new GEM */
}
/* Now iova is in private domain */
rockchip_drm_dma_attach_device() /* IOMMU take over! */
/* after userspace take over */
{
iommu_unmap();
drm_mm_remove_node();
drm_gem_object_put();
}
This looks more like something done in the DRM world.
Robin, what do you think of this? Thank you.
> Cheers,
> Robin.
--
Best,
Chaoyi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-05 2:19 ` Chaoyi Chen
@ 2026-12-05 4:06 ` Sebastian Reichel
2026-12-05 4:40 ` Chaoyi Chen
0 siblings, 1 reply; 10+ messages in thread
From: Sebastian Reichel @ 2026-12-05 4:06 UTC (permalink / raw)
To: Chaoyi Chen
Cc: Robin Murphy, Francesco Saverio Pavone, Joerg Roedel, Will Deacon,
Sandy Huang, Heiko Stuebner, Andy Yan, 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
[-- Attachment #1: Type: text/plain, Size: 3592 bytes --]
Hi,
On Sat, Dec 05, 2026 at 10:19:07AM +0800, Chaoyi Chen wrote:
> Hi,
>
> On 12/5/2026 1:14 AM, Robin Murphy wrote:
> > On 04/12/2026 3:32 pm, Francesco Saverio Pavone wrote:
> >> Hi Robin,
> >>
> >> On 2026-12-04 12:00, Robin Murphy wrote:
> >>> If you reach the point of creating private abstractions of entire
> >>> IOMMU API concepts inside a DRM driver, you should probably stop and
> >>> think "Why aren't other drivers doing this?"
> >>
> >> Thank you. That was blunt, and it was right. I went and looked: no
> >> driver outside drivers/iommu walks the reserved regions the way my
> >> patch does.
> >
> > Heh, sometimes it's hard to see the wood for the trees when you're working backwards from one very specific symptom of a larger issue.
> >
> >> I am withdrawing the series.
> >>
> >> The driver already does the standard takeover. I think the real gap
> >> is smaller: the VOP2 is not stopped before it is attached to the
> >> IOMMU domain, while the older VOP driver resets itself first. I will
> >> look at that instead, and only send something if it removes the
> >> faults on my board.
> >
> > I don't doubt that both the IOMMU driver and the VOP drivers might need a bit of smoothing out to make this properly work, it's just one of those scenarios where I'm almost certain that taking a step back to do things the "right" way will end up being easier.
> >
> > And that's not to say that this "minimal glitch" approach of pre-mapping the initial framebuffer prior to attaching the domain (and ideally unmapping it again as soon as we're sure it's out of use) isn't still potentially worth exploring, just that I'd hope we could pull the relevant config straight out of the VOP registers, or at worst add a DRM-appropriate way to query any existing sysfb aperture. But yeah, if just stopping the thing for the duration of driver registration is good enough for now, even simpler!
> >
>
> Yes, this depends largely on what we are trying to achieve.
>
> If we merely want to eliminate the IOMMU warnings, then resetting the
> hardware before attach, or stopping the DMA, would easily accomplish that.
>
> But if we want the display to remain completely continuous throughout the
> entire boot process and to transition smoothly from IOMMU disabled to
> IOMMU enabled, then it may require more effort.
>
> I saw some interesting examples:
>
> - Exynos uses a default domain.
> - Msm mdp4/mdp5 disable display before attaching IOMMU.
> - i915 wraps the reserved region as a GEM object (DRM framebuffer)
> and displays it.
>
> If we adopt an i915-style takeover, perhaps we need to do the following:
>
> {
> rockchip_gem_alloc_object() /* alloc object */
> drm_mm_reserve_node() /* optional? reserve old iova */
> iommu_map_sgtable() /* map old iova to new GEM */
> /* copy old fb data to new GEM */
> }
>
> /* Now iova is in private domain */
>
> rockchip_drm_dma_attach_device() /* IOMMU take over! */
>
> /* after userspace take over */
> {
> iommu_unmap();
> drm_mm_remove_node();
> drm_gem_object_put();
> }
>
> This looks more like something done in the DRM world.
> Robin, what do you think of this? Thank you.
FYI there is some ongoing work for generic DRM helpers regarding DRM
state readout from prior boot stages (I haven't found the time to
look at this closer myself, so not sure how much they help with the
IOMMU specifically):
https://lore.kernel.org/dri-devel/20261127-drm-state-readout-v10-0-0259582d45a8@kernel.org/
Greetings,
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain
2026-12-05 4:06 ` Sebastian Reichel
@ 2026-12-05 4:40 ` Chaoyi Chen
0 siblings, 0 replies; 10+ messages in thread
From: Chaoyi Chen @ 2026-12-05 4:40 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Robin Murphy, Francesco Saverio Pavone, Joerg Roedel, Will Deacon,
Sandy Huang, Heiko Stuebner, Andy Yan, 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
Hi Sebastian,
On 12/5/2026 12:06 PM, Sebastian Reichel wrote:
> Hi,
>
> On Sat, Dec 05, 2026 at 10:19:07AM +0800, Chaoyi Chen wrote:
>> Hi,
>>
>> On 12/5/2026 1:14 AM, Robin Murphy wrote:
>>> On 04/12/2026 3:32 pm, Francesco Saverio Pavone wrote:
>>>> Hi Robin,
>>>>
>>>> On 2026-12-04 12:00, Robin Murphy wrote:
>>>>> If you reach the point of creating private abstractions of entire
>>>>> IOMMU API concepts inside a DRM driver, you should probably stop and
>>>>> think "Why aren't other drivers doing this?"
>>>>
>>>> Thank you. That was blunt, and it was right. I went and looked: no
>>>> driver outside drivers/iommu walks the reserved regions the way my
>>>> patch does.
>>>
>>> Heh, sometimes it's hard to see the wood for the trees when you're working backwards from one very specific symptom of a larger issue.
>>>
>>>> I am withdrawing the series.
>>>>
>>>> The driver already does the standard takeover. I think the real gap
>>>> is smaller: the VOP2 is not stopped before it is attached to the
>>>> IOMMU domain, while the older VOP driver resets itself first. I will
>>>> look at that instead, and only send something if it removes the
>>>> faults on my board.
>>>
>>> I don't doubt that both the IOMMU driver and the VOP drivers might need a bit of smoothing out to make this properly work, it's just one of those scenarios where I'm almost certain that taking a step back to do things the "right" way will end up being easier.
>>>
>>> And that's not to say that this "minimal glitch" approach of pre-mapping the initial framebuffer prior to attaching the domain (and ideally unmapping it again as soon as we're sure it's out of use) isn't still potentially worth exploring, just that I'd hope we could pull the relevant config straight out of the VOP registers, or at worst add a DRM-appropriate way to query any existing sysfb aperture. But yeah, if just stopping the thing for the duration of driver registration is good enough for now, even simpler!
>>>
>>
>> Yes, this depends largely on what we are trying to achieve.
>>
>> If we merely want to eliminate the IOMMU warnings, then resetting the
>> hardware before attach, or stopping the DMA, would easily accomplish that.
>>
>> But if we want the display to remain completely continuous throughout the
>> entire boot process and to transition smoothly from IOMMU disabled to
>> IOMMU enabled, then it may require more effort.
>>
>> I saw some interesting examples:
>>
>> - Exynos uses a default domain.
>> - Msm mdp4/mdp5 disable display before attaching IOMMU.
>> - i915 wraps the reserved region as a GEM object (DRM framebuffer)
>> and displays it.
>>
>> If we adopt an i915-style takeover, perhaps we need to do the following:
>>
>> {
>> rockchip_gem_alloc_object() /* alloc object */
>> drm_mm_reserve_node() /* optional? reserve old iova */
>> iommu_map_sgtable() /* map old iova to new GEM */
>> /* copy old fb data to new GEM */
>> }
>>
>> /* Now iova is in private domain */
>>
>> rockchip_drm_dma_attach_device() /* IOMMU take over! */
>>
>> /* after userspace take over */
>> {
>> iommu_unmap();
>> drm_mm_remove_node();
>> drm_gem_object_put();
>> }
>>
>> This looks more like something done in the DRM world.
>> Robin, what do you think of this? Thank you.
>
> FYI there is some ongoing work for generic DRM helpers regarding DRM
> state readout from prior boot stages (I haven't found the time to
> look at this closer myself, so not sure how much they help with the
> IOMMU specifically):
>
> https://lore.kernel.org/dri-devel/20261127-drm-state-readout-v10-0-0259582d45a8@kernel.org/
>
Yes, I noticed this series earlier, but I think its benefit for the
IOMMU is limited.
It is intended to establish the initial state by reading hardware
registers. In my view, this can help us maintain resources such as
clocks and power domains during the boot process, and without needing
to repeatedly perform enable and similar operations on the PHY.
And once the IOMMU operations described above are justified, the two
could perhaps be combined in some way.
> Greetings,
>
> -- Sebastian
--
Best,
Chaoyi
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-05 4:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 10:27 [RFC PATCH v2 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 1/3] iommu/rockchip: Report the reserved regions from the devicetree Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 2/3] dt-bindings: display: vop2: Allow memory-region Francesco Saverio Pavone
2026-12-04 10:27 ` [RFC PATCH v2 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain Francesco Saverio Pavone
2026-12-04 12:00 ` Robin Murphy
2026-12-04 15:32 ` Francesco Saverio Pavone
2026-12-04 17:14 ` Robin Murphy
2026-12-05 2:19 ` Chaoyi Chen
2026-12-05 4:06 ` Sebastian Reichel
2026-12-05 4:40 ` Chaoyi Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox