arm64: allwinner: h616: Support Video Engine
Subsystems (5)
Chen-Yu Tsai
maintainerv2 cover arm64: allwinner: h616: Support Video Engine
Hi folks,
This is v2 of my Allwinner H616 Cedrus series. The series is ready to be merged.
Changes since v1:
- Fixed IOMMU ports on H616 (patch 7)
- Updated comment about VP9 on H616
This series adds support for the Cedar video engine found in the Allwinner H616 SoC. On the way, it also fixes some issues with the DT representation for the Allwinner H6 SoC.
Patch 1 fixes the video engine's number of IOMMU endpoints on the H6 in the DT binding.
Patch 2 fixes the video engine's number of SRAM regions on the H6 in the DT binding.
Patch 3 adds a new compatible for the H616's video engine.
Patch 4 adds the new compatible for the H616's video engine to the cedrus driver.
Patch 5 adds the video engine's missing SRAM region to the H6 dtsi.
Patch 6 adds the video engine's missing IOMMU endpoint to the H6 dtsi.
Patch 7 adds a device node for the video engine to the H616 dtsi.
Patches 1-4 should go through the media tree, while patches 5-7 will go through the soc tree via the sunxi tree.
Please have a look.
Thanks
ChenYu
Chen-Yu Tsai (6):
dt-bindings: media: sun4i-a10-video-engine: Fix IOMMU count for H6
dt-bindings: media: sun4i-a10-video-engine: Fix SRAM count for H6
dt-bindings: media: sun4i-a10-video-engine: Add H616 compatible
drivers: staging: media: sunxi: cedrus: add H616 variant
arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video
engine
arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
Jernej Skrabec (1):
arm64: dts: allwinner: sun50i-h616: Add video engine
.../allwinner,sun4i-a10-video-engine.yaml | 45 ++++++++++++++++++- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 4 +- .../arm64/boot/dts/allwinner/sun50i-h616.dtsi | 12 +++++ drivers/staging/media/sunxi/cedrus/cedrus.c | 4 ++ 4 files changed, 61 insertions(+), 4 deletions(-)
Signature · 1 line
2.47.3
Chen-Yu Tsai
maintainerPATCH v2 1/7 dt-bindings: media: sun4i-a10-video-engine: Fix IOMMU count for H6
On the H6 SoC, the Video Engine has two memory ports, thus two IOMMU connections. The secondary one that is missing is likely used for reading reference frames. The newer H616 is the same. On the other hand, the D1 only has one memory port.
Add the missing IOMMU connection for the Video Engine.
--- .../allwinner,sun4i-a10-video-engine.yaml | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml +20 -1
@@ -55,7 +55,10 @@ properties: description: Phandle to the device SRAM iommus: - maxItems: 1 + minItems: 1 + items: + - description: VE port on IOMMU + - description: VE_R port on IOMMU memory-region: maxItems: 1
@@ -82,6 +85,22 @@ required: - resets - allwinner,sram +allOf: + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun50i-h6-video-engine + then: + properties: + iommus: + minItems: 2 + else: + properties: + iommus: + maxItems: 1 + additionalProperties: false examples:
Signature · 1 line
2.47.3
Chen-Yu Tsai
maintainerPATCH v2 2/7 dt-bindings: media: sun4i-a10-video-engine: Fix SRAM count for H6
In reply to Chen-Yu TsaiOn the H6, the SRAM C region includes an alias of part of the VE SRAM used by the video engine. This region should also be claimed so that no access happens through the alias window.
Add a second SRAM region phandle to the video engine for the H6.
--- .../allwinner,sun4i-a10-video-engine.yaml | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml +20 -1
@@ -48,11 +48,15 @@ properties: allwinner,sram: $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 1 items: - items: - description: phandle to SRAM - description: register value for device - description: Phandle to the device SRAM + - items: + - description: phandle to SRAM alias + - description: register value for device + description: Phandle to the device SRAM(s) iommus: minItems: 1
@@ -101,6 +105,21 @@ allOf: iommus: maxItems: 1 + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun50i-h6-video-engine + then: + properties: + allwinner,sram: + minItems: 2 + else: + properties: + allwinner,sram: + maxItems: 1 + additionalProperties: false examples:
Signature · 1 line
2.47.3
Chen-Yu Tsai
maintainerPATCH v2 3/7 dt-bindings: media: sun4i-a10-video-engine: Add H616 compatible
In reply to Chen-Yu TsaiThe H616 contains a video engine similar to past SoCs.
Add a new compatible for it.
--- .../bindings/media/allwinner,sun4i-a10-video-engine.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml +3 -0
@@ -24,6 +24,7 @@ properties: - allwinner,sun50i-a64-video-engine - allwinner,sun50i-h5-video-engine - allwinner,sun50i-h6-video-engine + - allwinner,sun50i-h616-video-engine reg: maxItems: 1
@@ -96,6 +97,7 @@ allOf: contains: enum: - allwinner,sun50i-h6-video-engine + - allwinner,sun50i-h616-video-engine then: properties: iommus:
@@ -111,6 +113,7 @@ allOf: contains: enum: - allwinner,sun50i-h6-video-engine + - allwinner,sun50i-h616-video-engine then: properties: allwinner,sram:
Signature · 1 line
2.47.3
Chen-Yu Tsai
maintainerPATCH v2 5/7 arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine
In reply to Chen-Yu TsaiThe SRAM C region contains a partial alias to the VE SRAM already referenced by the video engine. To avoid access through this alias window, the region should also be claimed by the video engine.
Add a reference to the SRAM C region to the video engine node.
--- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1 -1
@@ -205,7 +205,7 @@ video-codec@1c0e000 { clock-names = "ahb", "mod", "ram"; resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; - allwinner,sram = <&ve_sram 1>; + allwinner,sram = <&ve_sram 1>, <&de2_sram 1>; iommus = <&iommu 3>; };
Signature · 1 line
2.47.3
Chen-Yu Tsai
maintainerPATCH v2 4/7 drivers: staging: media: sunxi: cedrus: add H616 variant
In reply to Chen-Yu TsaiThe Allwinner H616 SoC has a video engine hardware block like the one found on previous generations such as the H6. In addition to the currently supported features of the H6, it also includes a VP9 decoder. Support for VP9 will be added separately.
Add the compatible for the H616 variant, using the H6 variant data.
---
Changes since v1:
- Updated commit message on VP9 decoder status
--- drivers/staging/media/sunxi/cedrus/cedrus.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/media/sunxi/cedrus/cedrus.c +4 -0
@@ -696,6 +696,10 @@ static const struct of_device_id cedrus_dt_match[] = { .compatible = "allwinner,sun50i-h6-video-engine", .data = &sun50i_h6_cedrus_variant, }, + { + .compatible = "allwinner,sun50i-h616-video-engine", + .data = &sun50i_h6_cedrus_variant, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, cedrus_dt_match);
Signature · 1 line
2.47.3
Chen-Yu Tsai
maintainerPATCH v2 6/7 arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
In reply to Chen-Yu TsaiThe video engine on the H6 actually has two IOMMU ports. The one already listed is simply named "VE" in the user manual. The missing one is named "VE_R" and is probably either read-only or used for reference frames. Either way, it should be listed.
Add a reference to the "VE_R" IOMMU port to the video engine node.
--- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1 -1
@@ -206,7 +206,7 @@ video-codec@1c0e000 { resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; allwinner,sram = <&ve_sram 1>, <&de2_sram 1>; - iommus = <&iommu 3>; + iommus = <&iommu 3>, <&iommu 1>; }; gpu: gpu@1800000 {
Signature · 1 line
2.47.3
Chen-Yu Tsai
maintainerPATCH v2 7/7 arm64: dts: allwinner: sun50i-h616: Add video engine
In reply to Chen-Yu TsaiFrom: Jernej Skrabec <[email protected]>
The H616 SoC has a video engine, and two SRAM regions needed by it.
Add the video engine to the dtsi file.
---
Changes since v1:
- Corrected second IOMMU port
--- arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +12 -0
@@ -175,6 +175,18 @@ crypto: crypto@1904000 { resets = <&ccu RST_BUS_CE>; }; + video-codec@1c0e000 { + compatible = "allwinner,sun50i-h616-video-engine"; + reg = <0x01c0e000 0x2000>; + clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>, + <&ccu CLK_MBUS_VE>; + clock-names = "ahb", "mod", "ram"; + resets = <&ccu RST_BUS_VE>; + interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>; + iommus = <&iommu 3>, <&iommu 2>; + allwinner,sram = <&ve_sram 1>, <&sram_c 1>; + }; + syscon: syscon@3000000 { compatible = "allwinner,sun50i-h616-system-control"; reg = <0x03000000 0x1000>;
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH v2 6/7] arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
In reply to Chen-Yu TsaiThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The sun50i-iommu driver fails to properly detach domains from the hardware due to an unbalanced refcount, leading to a use-after-free of the domain structure.
- [High] The sun50i-iommu driver assigns a separate IOMMU group/domain per device despite the hardware only supporting a single global translation table, causing devices to overwrite each other's page tables. --
--- Patch [6]: [PATCH v2 6/7] arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine --- commit 8a79dfe07f469620b0b60592b02052d1c198fe97
Author: Chen-Yu Tsai <[email protected]>
arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
This commit adds a missing IOMMU port ("VE_R") to the video engine node in the sun50i-h6 device tree.
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi video-codec@1c0e000 { · line 209
Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1
-1@@ -206,7 +206,7 @@ video-codec@1c0e000 { resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; allwinner,sram = <&ve_sram 1>, <&de2_sram 1>; - iommus = <&iommu 3>; + iommus = <&iommu 3>, <&iommu 1>;
[Severity: High]
This is a pre-existing issue, but does adding a second IOMMU trigger a use-after-free during device unbind?
Looking at the sun50i-iommu driver, sun50i_iommu_domain_alloc_paging() sets the domain refcount to 1:
drivers/iommu/sun50i-iommu.c:sun50i_iommu_domain_alloc_paging() {
...
refcount_set(&sun50i_domain->refcnt, 1);
...
}Later, when a device is detached, sun50i_iommu_identity_attach() decrements it:
drivers/iommu/sun50i-iommu.c:sun50i_iommu_identity_attach() {
...
sun50i_domain = to_sun50i_domain(iommu->domain);
if (refcount_dec_and_test(&sun50i_domain->refcnt))
sun50i_iommu_detach_domain(iommu, sun50i_domain);
...
}Because the reference count drops from 2 to 1 here, it fails to reach 0 and bypasses the domain detachment. This leaves iommu->domain as a dangling pointer which is later freed by sun50i_iommu_domain_free(). Could this cause a kernel panic on a subsequent IOMMU page fault interrupt since it dereferences the freed pointer?
[Severity: High]
This isn't a bug introduced by this patch, but does adding another IOMMU reference here break DMA due to a single global translation table?
The sun50i-iommu driver assigns a separate IOMMU group per device:
drivers/iommu/sun50i-iommu.c:
static const struct iommu_ops sun50i_iommu_ops = {
...
.device_group = generic_single_device_group,
...
};Since the hardware only supports a single global translation table (IOMMU_TTB_REG), placing every device into its own independent group and domain means multiple devices will repeatedly overwrite the shared IOMMU's domain on probe. Will enabling this second IOMMU port overwrite previously configured translation tables and corrupt memory for other devices?
Quoted 3 lines
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +0
-0}; gpu: gpu@1800000 {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
AI reviewRe: [PATCH v2 5/7] arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine
In reply to Chen-Yu TsaiThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Adding a second phandle to the `allwinner,sram` property has no effect at runtime because the…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Adding a second phandle to the allwinner,sram property has no effect at runtime because the sunxi_sram driver infrastructure hardcodes parsing to only the first index. --
--- Patch [5]: [PATCH v2 5/7] arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine --- commit 8b2bcf328faa458d85d11e3cef06ddda86e2e10e
Author: Chen-Yu Tsai <[email protected]>
arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine
This commit adds a reference to the SRAM C region in the video engine node to prevent access through a partial alias window.
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi video-codec@1c0e000 { · line 208
Quoted 9 lines
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1
-1@@ -205,7 +205,7 @@ video-codec@1c0e000 { clock-names = "ahb", "mod", "ram"; resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; - allwinner,sram = <&ve_sram 1>; + allwinner,sram = <&ve_sram 1>, <&de2_sram 1>;
[Severity: Medium]
Will the second phandle be silently ignored during runtime?
Looking at the cedrus driver, it calls sunxi_sram_claim() during probe. However, the underlying infrastructure appears to hardcode index 0 when parsing this property:
drivers/soc/sunxi/sunxi_sram.c:sunxi_sram_of_parse() {
...
ret = of_parse_phandle_with_fixed_args(node, "allwinner,sram", 1, 0,
&args);
...
}Does the driver infrastructure need to be updated to parse multiple indices before this device tree addition takes effect?
Quoted 2 lines
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +0
-0iommus = <&iommu 3>; };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH v2 7/7] arm64: dts: allwinner: sun50i-h616: Add video engine
In reply to Chen-Yu TsaiThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] The video-codec node references a non-existent label 've_sram', causing a Device Tree Compiler…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] The video-codec node references a non-existent label 've_sram', causing a Device Tree Compiler (DTC) build failure.
- [Low] The allwinner,sram property incorrectly references the generic mmio-sram parent controller node (&sram_c) instead of an sram-section child node. --
--- Patch [7]: [PATCH v2 7/7] arm64: dts: allwinner: sun50i-h616: Add video engine --- commit f351af2797d5cc85ad73122a961f9b9e63f82153
Author: Jernej Skrabec <[email protected]>
arm64: dts: allwinner: sun50i-h616: Add video engine
This commit adds the video engine node to the sun50i-h616 device tree file. It defines the required memory regions, clocks, resets, interrupts, and SRAM nodes needed by the engine.
Quoted 3 lines
arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +0
-0
[ ... ]
Quoted 4 lines
arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +0
-0@@ -175,6 +175,18 @@ crypto: crypto@1904000 { resets = <&ccu RST_BUS_CE>; };
arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi crypto: crypto@1904000 { · line 187
Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +10
-0+ video-codec@1c0e000 { + compatible = "allwinner,sun50i-h616-video-engine"; + reg = <0x01c0e000 0x2000>; + clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>, + <&ccu CLK_MBUS_VE>; + clock-names = "ahb", "mod", "ram"; + resets = <&ccu RST_BUS_VE>; + interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>; + iommus = <&iommu 3>, <&iommu 2>; + allwinner,sram = <&ve_sram 1>, <&sram_c 1>;
[Severity: Low]
Is the ve_sram label defined elsewhere? The Device Tree Compiler (DTC) will fail to build because of this unresolved reference. It appears the sram_c1 node and its ve_sram child section might be missing.
[Severity: Low]
Does the second phandle correctly reference an sram-section child node? Referencing &sram_c here points to the generic mmio-sram parent controller node, which lacks #sram-cells. This violates the bindings and triggers a dt-validate schema failure.
Quoted 2 lines
arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +2
-0+ }; +
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Chen-Yu Tsai
maintainerRe: [PATCH v2 5/7] arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine
In reply to [email protected]Quoted 27 lines · On Sat, Jul 11, 2026 at 10:08 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Adding a second phandle to theallwinner,sramproperty has no effect at runtime because thesunxi_sramdriver infrastructure hardcodes parsing to only the first index. ----- Patch [5]: [PATCH v2 5/7] arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine --- commit
8b2bcf328faa458d85d11e3cef06ddda86e2e10e
Author: Chen-Yu Tsai <[email protected]>arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine
This commit adds a reference to the SRAM C region in the video engine node to prevent access through a partial alias window.
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi video-codec@1c0e000 { · line 208
Quoted 9 lines
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +1
-1@@ -205,7 +205,7 @@ video-codec@1c0e000 { clock-names = "ahb", "mod", "ram"; resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; - allwinner,sram = <&ve_sram 1>; + allwinner,sram = <&ve_sram 1>, <&de2_sram 1>;[Severity: Medium]
Will the second phandle be silently ignored during runtime?
Quoted 8 lines
Looking at the cedrus driver, it calls
sunxi_sram_claim()during probe. However, the underlying infrastructure appears to hardcode index 0 when parsing this property:drivers/soc/sunxi/sunxi_sram.c:sunxi_sram_of_parse() { ... ret = of_parse_phandle_with_fixed_args(node, "allwinner,sram", 1, 0, &args);
Yeah, no. Sashiko's context needs to be updated. This was changed in commit be99eb936b4f ("soc: sunxi: sram: Support claiming multiple regions per device") in v7.2-rc1.
Quoted 11 lines
... }Does the driver infrastructure need to be updated to parse multiple indices before this device tree addition takes effect?
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi video-codec@1c0e000 { · line 210
Quoted 2 lines
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +0
-0iommus = <&iommu 3>; };--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v2 7/7] arm64: dts: allwinner: sun50i-h616: Add video engine
In reply to Chen-Yu TsaiHi,
Quoted 9 lines · Chen-Yu Tsai
From: Jernej Skrabec <[email protected]>
The H616 SoC has a video engine, and two SRAM regions needed by it.
Add the video engine to the dtsi file.
Signed-off-by Jernej Skrabec <[email protected]>[[email protected]: Add VE SRAM region and commit message]Signed-off-by Chen-Yu Tsai <[email protected]>
Checked against the binding and the manual: clocks, regs, interrupts and reset matches. Also test-built the DTB: that worked fine, not sure what Sashiko was complaining about.
Thanks,
Andre
Quoted 30 lines
---
Changes since v1:
- Corrected second IOMMU port--- arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +12
-0@@ -175,6 +175,18 @@ crypto: crypto@1904000 { resets = <&ccu RST_BUS_CE>; }; + video-codec@1c0e000 { + compatible = "allwinner,sun50i-h616-video-engine"; + reg = <0x01c0e000 0x2000>; + clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>, + <&ccu CLK_MBUS_VE>; + clock-names = "ahb", "mod", "ram"; + resets = <&ccu RST_BUS_VE>; + interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>; + iommus = <&iommu 3>, <&iommu 2>; + allwinner,sram = <&ve_sram 1>, <&sram_c 1>; + }; + syscon: syscon@3000000 { compatible = "allwinner,sun50i-h616-system-control"; reg = <0x03000000 0x1000>;