Skip to contentSkip to conversation

media: qcom: Don't fail probe when the IOVA range is already reserved

PATCH In review Kel Modderman 2 participants 5 messages Dec 4 – Dec 5

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover media: qcom: Don't fail probe when the IOVA range is already reserved

Since v7.3.4 Iris doesn't probe on the Radxa Dragon Q6A (QCS6490):

qcom-iris aa00000.video-codec: probe with driver qcom-iris failed with error -12

The board's firmware device tree already reserves IOVA 0 to 0x25800000 for the video codec, with a reserved-memory node that has only "iommu-addresses". dma-iommu keeps that range out of the allocator, so the reservation added by "media: iris: Fix iova allocation from restrict region" can't get it and the probe fails. Venus got the same reservation in that series, so it gets the same change.

I tested the Iris patch on the Dragon Q6A, on v7.3.5 stable with the patch built as a module: Iris probes again, H.264, HEVC and VP9 decode with ffmpeg and in Kodi, and there are no SMMU faults. The venus patch is compile-tested only.

Both patches, their changelogs and the debugging behind them come from Claude Code (Claude Opus 5.5). I asked it to look into the probe failure, test a fix on the board and draft the patches. It found the stable backport and the device tree node from the probe error and the IOMMU group's reserved regions. I reviewed both patches and ran the tests above.

Kel Modderman (2):
media: iris: Skip the IOVA reservation when the range is already
reserved
media: venus: Skip the IOVA reservation when the range is already
reserved

 drivers/media/platform/qcom/iris/iris_probe.c | 26 +++++++++++++++++++
 drivers/media/platform/qcom/venus/core.c      | 26 +++++++++++++++++++
 2 files changed, 52 insertions(+)

base-commit: fd568e1139cc43b39fad1108463d1f7681d82ce2

Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/2 media: iris: Skip the IOVA reservation when the range is already reserved

iris_reserve_iova_region() allocates IOVA 0 to 0x25800000 with dma_iova_try_alloc() and fails the probe if it can't. A device tree can already reserve that range for the video codec with an "iommu-addresses" reserved-memory node, as the firmware device tree of the Radxa Dragon Q6A does. dma-iommu then keeps the range out of the IOVA allocator, so dma_iova_try_alloc() fails and Iris does not probe:

qcom-iris aa00000.video-codec: probe with driver qcom-iris failed with error -12

The range can't be used for DMA mappings either way, so skip the reservation when an IOMMU_RESV_RESERVED region already covers it.

Claude Code (Claude Opus 5.5) found the cause, and wrote this change and its changelog, after being asked why Iris stopped probing on the board after a stable update. I reviewed the change and tested it on a Radxa Dragon Q6A with v7.3.5 stable: Iris probes again, and H.264, HEVC and VP9 decode with no SMMU faults.

Fixes 200473c198b2 ("media: iris: Fix iova allocation from restrict region")
---
 drivers/media/platform/qcom/iris/iris_probe.c | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/media/platform/qcom/iris/iris_probe.c +26 -0
index 41dec90f3e2..65fd5e993ab 100644
@@ -5,6 +5,7 @@
 
 #include <linux/clk.h>
 #include <linux/interconnect.h>
+#include <linux/iommu.h>
 #include <linux/module.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_opp.h>
@@ -158,6 +159,26 @@ static void iris_unreserve_iova_region(struct device *dev, struct dma_iova_state
 		dma_iova_free(dev, &iova_state[i]);
 }
 
+static bool iris_iova_region_reserved(struct device *dev, unsigned long start,
+				      unsigned long size)
+{
+	struct iommu_resv_region *region;
+	LIST_HEAD(resv_regions);
+	bool reserved = false;
+
+	iommu_get_resv_regions(dev, &resv_regions);
+	list_for_each_entry(region, &resv_regions, list) {
+		if (region->type == IOMMU_RESV_RESERVED && region->start <= start &&
+		    region->start + region->length >= start + size) {
+			reserved = true;
+			break;
+		}
+	}
+	iommu_put_resv_regions(dev, &resv_regions);
+
+	return reserved;
+}
+
 static int iris_reserve_iova_region(struct device *dev, struct dma_iova_state **iova_state,
 				    unsigned long start, unsigned long size)
 {
@@ -171,6 +192,11 @@ static int iris_reserve_iova_region(struct device *dev, struct dma_iova_state **
 	if (!state)
 		return ret;
 
+	if (iris_iova_region_reserved(dev, start, size)) {
+		*iova_state = state;
+		return 0;
+	}
+
 	end = start + size;
 	rem = end - max(start, PAGE_SIZE);
 	dev->bus_dma_limit = end - 1;
Signature · 1 line
2.55.0
#4 lore raw

PATCH 2/2 media: venus: Skip the IOVA reservation when the range is already reserved

In reply to Kel Modderman

venus_reserve_iova_region() has the same problem as Iris: when the device tree already reserves IOVA 0 to 0x25800000 for the video codec with an "iommu-addresses" reserved-memory node, dma_iova_try_alloc() can't get the range and the probe fails with -ENOMEM.

Skip the reservation when an IOMMU_RESV_RESERVED region already covers it, as for Iris.

Claude Code (Claude Opus 5.5) wrote this change and its changelog together with the Iris one. It is compile-tested only.

Fixes 953439251b59 ("media: venus: Fix iova allocation from restrict region")
---
 drivers/media/platform/qcom/venus/core.c | 26 ++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/media/platform/qcom/venus/core.c +26 -0
index 7087af32060..07d216e8c05 100644
@@ -7,6 +7,7 @@
 #include <linux/interconnect.h>
 #include <linux/io.h>
 #include <linux/ioctl.h>
+#include <linux/iommu.h>
 #include <linux/delay.h>
 #include <linux/devcoredump.h>
 #include <linux/list.h>
@@ -385,6 +386,26 @@ static void venus_unreserve_iova_region(struct device *dev, struct dma_iova_stat
 		dma_iova_free(dev, &state[i]);
 }
 
+static bool venus_iova_region_reserved(struct device *dev, unsigned long start,
+				       unsigned long size)
+{
+	struct iommu_resv_region *region;
+	LIST_HEAD(resv_regions);
+	bool reserved = false;
+
+	iommu_get_resv_regions(dev, &resv_regions);
+	list_for_each_entry(region, &resv_regions, list) {
+		if (region->type == IOMMU_RESV_RESERVED && region->start <= start &&
+		    region->start + region->length >= start + size) {
+			reserved = true;
+			break;
+		}
+	}
+	iommu_put_resv_regions(dev, &resv_regions);
+
+	return reserved;
+}
+
 static int venus_reserve_iova_region(struct device *dev, struct dma_iova_state **iova_state,
 				     unsigned long start, unsigned long size)
 {
@@ -398,6 +419,11 @@ static int venus_reserve_iova_region(struct device *dev, struct dma_iova_state *
 	if (!state)
 		return ret;
 
+	if (venus_iova_region_reserved(dev, start, size)) {
+		*iova_state = state;
+		return 0;
+	}
+
 	end = start + size;
 	rem = end - max(start, PAGE_SIZE);
 	dev->bus_dma_limit = end - 1;
Signature · 1 line
2.55.0
maintainer
#2 lore raw

Re: [PATCH 1/2] media: iris: Skip the IOVA reservation when the range is already reserved

In reply to Kel Modderman
Quoted 2 lines · Kel Modderman

"iommu-addresses" reserved-memory node, as the firmware device tree of the Radxa Dragon Q6A does.

Not in upstream.

grep iommu-addresses * -r

arch/arm64/boot/dts/exynos/exynos7870-on7xelte.dts: iommu-addresses = <&decon 0x67000000 (1080 * 1920 * 4)>;
arch/arm64/boot/dts/exynos/exynos7870-a2corelte.dts: iommu-addresses = <&decon 0x67000000 (540 * 960 * 4)>;
arch/arm64/boot/dts/exynos/exynos7870-j6lte.dts: iommu-addresses = <&decon 0x67000000 (720 * 1480 * 4)>;
drivers/iommu/of_iommu.c: maps = of_get_property(it.node, "iommu-addresses", &size);

#( 12/05/26@12:08 )( deckard@sagittarius-a ):~/Development/qualcomm/[email protected]✗✗✗
git show HEAD~9
commit fd568e1139cc43b39fad1108463d1f7681d82ce2 (media-committers/next, media-committers/HEAD, bod-media-committers/next, bod-media-committers/HEAD)

Author: Nihal Kumar Gupta <[email protected]>
Date:   Thu Dec 3 21:51:50 2026 +0530

media: qcom: camss: Add Glymur-specific resources

Fix your downstream DTS

---
bod

#3 lore raw

Re: [PATCH 1/2] media: iris: Skip the IOVA reservation when the range is already reserved

Cheers Bryan,

Thank you. I understand your position; and mine is that the upstream device tree, when configured outside of the manufacturers firmware, leaves me without a working display for now. I'll try to nudge radxa on the device tree issue and hope for the best.

Thanks, Kel

Quoted 32 lines · Bryan O'Donoghue
Quoted 2 lines · Kel Modderman

"iommu-addresses" reserved-memory node, as the firmware device tree of the Radxa Dragon Q6A does.

Not in upstream.

grep iommu-addresses * -r

arch/arm64/boot/dts/exynos/exynos7870-on7xelte.dts: iommu-addresses =
<&decon 0x67000000 (1080 * 1920 * 4)>;
arch/arm64/boot/dts/exynos/exynos7870-a2corelte.dts: iommu-addresses =
<&decon 0x67000000 (540 * 960 * 4)>;
arch/arm64/boot/dts/exynos/exynos7870-j6lte.dts: iommu-addresses =
<&decon 0x67000000 (720 * 1480 * 4)>;
drivers/iommu/of_iommu.c: maps = of_get_property(it.node,
"iommu-addresses", &size);

#( 12/05/26@12:08 )( deckard@sagittarius-a ):~/Development/qualcomm/[email protected]✗✗✗
git show HEAD~9
commit fd568e1139cc43b39fad1108463d1f7681d82ce2 (media-committers/next, media-committers/HEAD, bod-media-committers/next, bod-media-committers/HEAD)

Author: Nihal Kumar Gupta <[email protected]>
Date:   Thu Dec 3 21:51:50 2026 +0530

media: qcom: camss: Add Glymur-specific resources

Fix your downstream DTS

---
bod