8157eda85f
G-A2 from DRIVER-MANAGER-MIGRATION-PLAN v4.8: thermald was
silently failing to switch governors because cpufreqd provided
no 'cpufreq' scheme. thermald writes /scheme/cpufreq/governor
(thermald/src/main.rs:38, :348-358); cpufreqd only wrote
/scheme/cpufreq/state via fs::write - the path was a stub.
Fix: cpufreqd now registers the 'cpufreq' scheme at startup via
redox-scheme::scheme::register_sync_scheme, exposing a real
Linux-compatible interface.
Path surface (read-write where noted):
- /scheme/cpufreq/governor (rw - global default)
- /scheme/cpufreq/cpu<N>/scaling_governor (rw - per-CPU override)
- /scheme/cpufreq/cpu<N>/scaling_cur_freq (ro)
- /scheme/cpufreq/cpu<N>/scaling_min_freq (ro)
- /scheme/cpufreq/cpu<N>/scaling_max_freq (ro)
- /scheme/cpufreq/cpu<N>/cpuinfo_min_freq (ro)
- /scheme/cpufreq/cpu<N>/cpuinfo_max_freq (ro)
- /scheme/cpufreq/cpu<N>/scaling_available_governors (ro)
- /scheme/cpufreq/cpu<N>/cpuinfo_cur_freq (ro - alias)
- /scheme/cpufreq/control/governor (rw - alias, thermald fallback)
- /scheme/cpufreq/state (ro - existing key=value)
Implementation:
- scheme.rs (NEW, 639 lines): SchemeSync impl, path parsing,
per-CPU vs global governor resolution, atomic-rename
persistence of last governor.
- main.rs: governor -> Arc<Mutex<Governor>>, cpus ->
Arc<Mutex<Vec<CpuInfo>>>, spawn scheme server, removed the
fs::write('/scheme/cpufreq/state') stub line, added
Governor::as_str()/from_name(), 4 pre-existing clippy
collapsible_if warnings fixed.
- Cargo.toml: added redox-scheme, libredox, syscall (redox_syscall)
path deps with [patch.crates-io] per local AGENTS.md rules.
Lock ordering documented inline: governor -> overrides -> cpus.
Main loop snapshots governor+overrides before locking cpus so
the scheme server can never deadlock against it.
Linux-compat extras added (real functionality, not stubs):
scaling_available_governors (root + per-CPU), cpuinfo_cur_freq
alias, control/governor alias, getdents on all directories.
Per-CPU override behavior matches Linux: writing global governor
clears all per-CPU overrides; writing cpu<N>/scaling_governor
sets a per-CPU override. Main loop honors overrides via
effective_governor() each tick.
state format: now emits lowercase governor names (governor=ondemand)
instead of the old {:?} (governor=Ondemand). This matches
redbear-power's lowercase expectations.
Tests: 21 new (governor name parsing case-insensitive + rejection
of invalid, Arc<Mutex> round-trip, global-write-clears-overrides,
path parsing for cpu0/scaling_governor/governor/control/governor,
unknown-CPU/leaf rejection, per-CPU override fallback, frequency
helpers, state format backward compat, integration test). All pass.
Compile: cargo check --target x86_64-unknown-redox - zero new
warnings (only pre-existing libredox FFI warnings).
Constraints per local/AGENTS.md:
- No new branches (work on 0.3.1)
- No new Cat-2 dependencies (redox-scheme is already a path-dep)
- No stubs, no todo!/unimplemented!
- Cat 1 in-house recipe - source IS the durable location
Closes v5.1 of the v5.x work program. Closes G-A2 from v4.8.