-
Notifications
You must be signed in to change notification settings - Fork 126
feat(cpufreq): RK3588 ondemand CPU DVFS with voltage calibration #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
a44de89
a93e784
43f401c
be43d32
ce32bc5
555b6ba
414672a
406c1ee
861e6a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # RK3588 CPU DVFS (cpufreq) | ||
|
|
||
| Feature-gated ondemand CPU frequency/voltage scaling for the Orange Pi 5 Plus | ||
| (RK3588). It is off by default in the generic and QEMU builds — the | ||
| `ax-driver/rk3588-cpufreq` feature compiles the driver to no-ops there — and is | ||
| enabled on the Orange Pi board build. | ||
|
|
||
| ## What it does | ||
|
|
||
| The RK3588 CPU clock is a voltage-coupled PVTPLL. An **ondemand** governor scales | ||
| each of the three CPU clusters (A55 little `cpu0-3`, two A76 big pairs `cpu4-5` / | ||
| `cpu6-7`) between OPPs by pairing an SCMI PVTPLL ring target with a PMIC rail | ||
| voltage: | ||
|
|
||
| - **A76** uses the full voltage lever — its RK8602/RK8603 rails read back over I2C, | ||
| so every voltage write is confirmed and the SCMI clock rate is read back before an | ||
| OPP is committed. | ||
| - **A55** is **ring-only**: its RK806 rail cannot be read back (a MISO hardware | ||
| limit), so it stays on the boot-confirmed 675 mV rail and scales only its SCMI | ||
| ring. 675 mV over-volts every A55 ring ≤ 1008 MHz, so it can never undervolt. | ||
|
|
||
| It is **fail-safe**: if either PMIC bus does not come up at boot, `GOV_READY` stays | ||
| `false` and every cluster is left on its boot OPP (no scaling). | ||
|
|
||
| ## Enable and build | ||
|
|
||
| The feature is enabled in both Orange Pi 5 Plus build configs: | ||
|
|
||
| - `test-suit/starryos/board-orangepi-5-plus/build-aarch64-unknown-none-softfloat.toml` | ||
| — the config the **board CI runner** actually builds, so the standard board | ||
| test entry compiles, boots and runs the governor on real hardware: | ||
|
|
||
| ```bash | ||
| cargo xtask starry test board --board orangepi-5-plus | ||
| ``` | ||
|
|
||
| Every case there boots this kernel; a governor-induced boot panic/hang trips the | ||
| cases' `panic` fail-regex, so the board CI regression-guards the feature. | ||
| - `os/StarryOS/configs/board/orangepi-5-plus.toml` — the general board build | ||
| template (for a full-board `max_cpu_num` build outside CI). | ||
|
|
||
| To enable it in a custom build, add `"ax-driver/rk3588-cpufreq"` to that config's | ||
| `features` list. | ||
|
|
||
| ## Observable verification | ||
|
|
||
| At boot (early init, before the console handoff) the driver logs the rail bring-up | ||
| and governor arming to the serial console: | ||
|
|
||
| ``` | ||
| cpufreq: A55 rail boot voltage = <uV> uV | ||
| cpufreq: A55 <before>-><after>, A76 <before>-><after> MHz | ||
| cpufreq: ondemand governor armed (both PMIC buses up) | ||
| ``` | ||
|
|
||
| Under load, per-cluster OPP transitions are logged | ||
| (`gov: A76b0 peak=<n>% opp <i>-><j> = <mhz> MHz @ <mv> mV`), and the delivered | ||
| frequency can be read exactly with `cpuprobe`'s `mhz_pmc` (the PMU cycle counter is | ||
| enabled at boot): a busy cluster climbs toward its top OPP, an idle cluster sheds | ||
| back down one step at a time. The companion `apps/starry/sysbench-board` harness | ||
| (PR #1658) drives an all-core load and captures these numbers against a Linux | ||
| baseline. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,6 +136,12 @@ rockchip-soc = [ | |
| "dep:rdif-reset", | ||
| "dep:rockchip-soc", | ||
| ] | ||
| # RK3588 fixed-OPP-at-boot CPU DVFS (voltage-free rung): raises the CPU cluster | ||
| # clocks via the SCMI seam at probe time. Board-only policy; keep it opt-in. | ||
| rk3588-cpufreq = [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个 feature 会无条件编译
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 阻塞(交付/测试覆盖):这里定义的 |
||
| "rockchip-soc", | ||
| "dep:arm-scmi-rs", | ||
| ] | ||
| rockchip-pm = ["rockchip-soc", "dep:rdif-power", "dep:rockchip-pm"] | ||
| list-pci-devices = ["pci"] | ||
| pci-list-devices = ["list-pci-devices"] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 feature 会无条件编译
cpufreq.rs,而该文件包含 AArch64 的mrsinline asm;在普通 x86_64 宿主执行cargo test -p ax-driver --features rk3588-cpufreq会以invalid instruction mnemonic 'mrs'失败。既然这是公开且标称 board-only 的 feature,请将 AArch64 实现/re-export 用cfg(target_arch = "aarch64")约束并提供宿主 stub/测试,或以等价方式保证该 feature 的宿主检查可编译;否则新增功能无法通过该 crate 的常规测试路径。