From 0a34d7a34ab82ee2185385bea16f1028d4036b87 Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Tue, 17 Nov 2026 08:20:45 -0600 Subject: patch: replace hand-written diff with git format-patch output (PR #399 provenance); note Rockchip PR --- ...kvdec-RGA-clocks-at-the-mpp-advanced-rate.patch | 68 ++++++++++++++++++++++ ...rk3328-pin-VPU-decode-and-RGA-clock-rates.patch | 64 -------------------- README.md | 2 +- persistence.md | 2 +- 4 files changed, 70 insertions(+), 66 deletions(-) create mode 100644 0001-arm64-dts-rockchip-pin-RK3328-rkvdec-RGA-clocks-at-the-mpp-advanced-rate.patch delete mode 100644 0001-arm64-dts-rockchip-rk3328-pin-VPU-decode-and-RGA-clock-rates.patch diff --git a/0001-arm64-dts-rockchip-pin-RK3328-rkvdec-RGA-clocks-at-the-mpp-advanced-rate.patch b/0001-arm64-dts-rockchip-pin-RK3328-rkvdec-RGA-clocks-at-the-mpp-advanced-rate.patch new file mode 100644 index 0000000..19c0d00 --- /dev/null +++ b/0001-arm64-dts-rockchip-pin-RK3328-rkvdec-RGA-clocks-at-the-mpp-advanced-rate.patch @@ -0,0 +1,68 @@ +From 06532e55c4984fa40919d492afe996f6bfc77a51 Mon Sep 17 00:00:00 2001 +From: Nick Moore +Date: Tue, 17 Nov 2026 08:19:07 -0600 +Subject: [PATCH] arm64: dts: rockchip: pin RK3328 rkvdec/RGA clocks at the mpp + advanced rate + +The rk3328.dtsi CRU assigned-clock-rates boot the video decoder +interfaces at 100 MHz (ACLK_RKVDEC_PRE, SCLK_VDEC_CABAC, +SCLK_VDEC_CORE) and the RGA at 100 MHz. On the Rockchip 6.12 BSP (rkr) +mpp stack the rkvdec auto-frequency path never fires on RK3328: +/proc/mpp_service/rkvdec/{aclk,clk_core,clk_cabac,clk_hevc_cabac} +report real_rate_hz of 0, idle and under full load, so the driver's +rockchip,normal-rates (300 MHz) and rockchip,advanced-rates (400 MHz) +are never applied and decode runs at the 100 MHz boot pin - 33.8 fps +4K HEVC vs 70.2 fps with the clocks at 400 MHz (117% of the 60 fps +datasheet spec, RK3328 datasheet v1.4). + +Fix by assigning the clocks on the consumer nodes at the advanced +rate. Consumer-node assignments execute at device probe, after the CRU +has raised CPLL to 1.2 GHz, so the rate resolves exactly (1200/3) and +CCF selects the CPLL parent. The venc (H.264 encoder) side is left +alone: the venc driver self-manages its clocks (runtime-resume -> +300 MHz default, idle -> 50 MHz reduce rate) via working CCF writes. + +Measured on Rock Pi E (RK3328, kernel 6.12.81-rkr12, 2160p50 HEVC +11.6 Mbps test stream): + + clocks decode 4K HEVC dec->RGA->null + boot pins (100/50 MHz) 33.79 fps 31.55 fps + decoder + RGA @ 400 MHz 70.21 fps 40.84 fps + +RGA note: the clk_rga mux can rest on GPLL (reset default), leaving it +at 491.52/3 = 163.84 MHz even after a divider change. Assigning +SCLK_RGA at boot forces the CPLL parent; measured dec->RGA->null went +31.4 -> 40.8 fps. + +Signed-off-by: Nick Moore +--- + arch/arm64/boot/dts/rockchip/rk3328.dtsi | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3328.dtsi b/arch/arm64/boot/dts/rockchip/rk3328.dtsi +index ccbbd5f..4ff019e 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3328.dtsi ++++ b/arch/arm64/boot/dts/rockchip/rk3328.dtsi +@@ -1066,6 +1066,10 @@ + operating-points-v2 = <&rkvdec_opp_table>; + #cooling-cells = <2>; + devfreq = <&dmc>; ++ assigned-clocks = <&cru ACLK_RKVDEC_PRE>, <&cru SCLK_VDEC_CORE>, ++ <&cru SCLK_VDEC_CABAC>; ++ assigned-clock-rates = <400000000>, <400000000>, ++ <400000000>; + status = "disabled"; + + vcodec_power_model: vcodec_power_model { +@@ -1215,6 +1219,8 @@ + interrupts = ; + clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA>; + clock-names = "aclk_rga", "hclk_rga", "clk_rga"; ++ assigned-clocks = <&cru ACLK_RGA_PRE>, <&cru SCLK_RGA>; ++ assigned-clock-rates = <400000000>, <400000000>; + status = "disabled"; + }; + +-- +2.56.1 + diff --git a/0001-arm64-dts-rockchip-rk3328-pin-VPU-decode-and-RGA-clock-rates.patch b/0001-arm64-dts-rockchip-rk3328-pin-VPU-decode-and-RGA-clock-rates.patch deleted file mode 100644 index f05915b..0000000 --- a/0001-arm64-dts-rockchip-rk3328-pin-VPU-decode-and-RGA-clock-rates.patch +++ /dev/null @@ -1,64 +0,0 @@ -From: Nick Moore -Subject: [PATCH] arm64: dts: rockchip: pin RK3328 rkvdec/RGA clocks at the - mpp advanced rate - -The rk3328.dtsi CRU assigned-clock-rates boot the video decoder -interfaces at 100 MHz (ACLK_RKVDEC_PRE, SCLK_VDEC_CABAC, -SCLK_VDEC_CORE) and the RGA at 100 MHz. On the Rockchip 6.12 BSP (rkr) -mpp stack the rkvdec auto-frequency path never fires on RK3328: -/proc/mpp_service/rkvdec/{aclk,clk_core,clk_cabac,clk_hevc_cabac} -report real_rate_hz of 0, idle and under full load, so the driver's -rockchip,normal-rates (300 MHz) and rockchip,advanced-rates (400 MHz) -are never applied and decode runs at the 100 MHz boot pin — 33.8 fps -4K HEVC vs 70.2 fps with the clocks at 400 MHz (117% of the 60 fps -datasheet spec, RK3328 datasheet v1.4). - -Fix by assigning the clocks on the consumer nodes at the advanced -rate. Consumer-node assignments execute at device probe, after the CRU -has raised CPLL to 1.2 GHz, so the rate resolves exactly (1200/3) and -CCF selects the CPLL parent. The venc (H.264 encoder) side is left -alone: the venc driver self-manages its clocks (runtime-resume -> -300 MHz default, idle -> 50 MHz reduce rate) via working CCF writes. - -Measured on Rock Pi E (RK3328, kernel 6.12.81-rkr12, 2160p50 HEVC -11.6 Mbps test stream): - - clocks decode 4K HEVC dec->RGA->null - boot pins (100/50 MHz) 33.79 fps 31.55 fps - decoder + RGA @ 400 MHz 70.21 fps 40.84 fps - -RGA note: the clk_rga mux can rest on GPLL (reset default), leaving it -at 491.52/3 = 163.84 MHz even after a divider change. Assigning -SCLK_RGA at boot forces the CPLL parent; measured dec->RGA->null went -31.4 -> 40.8 fps. - -Signed-off-by: Nick Moore ---- - arch/arm64/boot/dts/rockchip/rk3328.dtsi | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/arch/arm64/boot/dts/rockchip/rk3328.dtsi b/arch/arm64/boot/dts/rockchip/rk3328.dtsi -index a1a1a1a..b2b2b2b 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3328.dtsi -+++ b/arch/arm64/boot/dts/rockchip/rk3328.dtsi -@@ -1066,6 +1066,9 @@ - operating-points-v2 = <&rkvdec_opp_table>; - #cooling-cells = <2>; - devfreq = <&dmc>; -+ assigned-clocks = <&cru ACLK_RKVDEC_PRE>, <&cru SCLK_VDEC_CORE>, -+ <&cru SCLK_VDEC_CABAC>; -+ assigned-clock-rates = <400000000>, <400000000>, -+ <400000000>; - status = "disabled"; - - vcodec_power_model: vcodec_power_model { -@@ -1216,4 +1216,6 @@ - clocks = <&cru ACLK_RGA>, <&cru HCLK_RGA>, <&cru SCLK_RGA>; - clock-names = "aclk_rga", "hclk_rga", "clk_rga"; -+ assigned-clocks = <&cru ACLK_RGA_PRE>, <&cru SCLK_RGA>; -+ assigned-clock-rates = <400000000>, <400000000>; - status = "disabled"; - }; --- -2.47.1 - diff --git a/README.md b/README.md index a900d20..558140e 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Full story: [blog.md](blog.md). Persistence options: **Option A — rebuild the DTB only** (recommended): ```sh -git am 0001-arm64-dts-rockchip-rk3328-pin-VPU-decode-and-RGA-clock-rates.patch +git am 0001-arm64-dts-rockchip-pin-RK3328-rkvdec-RGA-clocks-at-the-mpp-advanced-rate.patch make ARCH=arm64 dtbs # rk3328 dtb rebuilds in seconds # deploy rk3328-.dtb the way your image does, reboot ``` diff --git a/persistence.md b/persistence.md index 7912cb7..db63130 100644 --- a/persistence.md +++ b/persistence.md @@ -6,7 +6,7 @@ survive reboots, three independent ways — pick one (or stack them). | Layer | Mechanism | Needs kernel rebuild? | Covers | |---|---|---|---| -| 1 (recommended) | DTS patch [`0001-*.patch`](0001-arm64-dts-rockchip-rk3328-pin-VPU-decode-and-RGA-clock-rates.patch) | DTB only | boot-time, self-maintaining, upstreamable | +| 1 (recommended) | DTS patch [`0001-*.patch`](0001-arm64-dts-rockchip-pin-RK3328-rkvdec-RGA-clocks-at-the-mpp-advanced-rate.patch) | DTB only | boot-time, self-maintaining, upstreamable | | 2 | boot pin: [`vpu-clocks.initd`](scripts/vpu-clocks.initd) / [`.service`](scripts/vpu-clocks.service) | no | boot-time | | 3 | watchdog: [`vpu-clock-watchdog.sh`](scripts/vpu-clock-watchdog.sh) + units | no | runtime, re-asserts on drift | -- cgit v1.3