diff --git a/AGENTS.md b/AGENTS.md index 92ddde9..0747357 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,7 +38,7 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7` - `./scripts/build-dmenu.sh` — rebuilds only `dmenu.so`, `stest`, `dmenu_path`, and `dmenu_run`. - `./scripts/build-games.sh` — builds standalone X11 games and emulators in `src/games/` (`snake`, `tetris`, `scoundrel`, `gambatte` / `gbemu`, `remedy` / `j2me`). - `./scripts/build-fcitx5-t9.sh` — builds `src/fcitx5-t9` (`libt9.so` / `t9.so`). -- `./scripts/build-kernel-audio.sh` — builds `6.12.1-msm8916` Adreno 304 `drm/msm`, QDSP6 audio, torch LED, camera `.ko` modules, device `.dtb` files, and the `zImage` kernel image from `patches/kernel/config-bananarchy-msm8909.armv7` (exported as `overlay/rootfs/boot/vmlinuz`, `config`, `System.map`). The resolved `.config` is written back to the config file so the module build and the shipped kernel never drift. **Never change `CONFIG_PREEMPT*`, `CONFIG_PM_SLEEP`/`CONFIG_SUSPEND`, `CONFIG_SMP`, `CONFIG_MODVERSIONS` or `CONFIG_MODULE_UNLOAD` in that config without also rebuilding every module from the pmaports kernel package**: vermagic and `struct dev_pm_info` layout must match the untouched package modules. +- `./scripts/build-kernel-audio.sh` — builds `6.12.1-msm8916` Adreno 304 `drm/msm`, QDSP6 audio, torch LED, camera `.ko` modules, device `.dtb` files, and the `zImage` kernel image from `patches/kernel/config-bananarchy-msm8909.armv7` (exported as `overlay/rootfs/boot/vmlinuz`, `config`, `System.map`). The resolved `.config` is written back to the config file so the module build and the shipped kernel never drift. **Never change `CONFIG_PREEMPT*`, `CONFIG_PM_SLEEP`/`CONFIG_SUSPEND`, `CONFIG_SMP`, `CONFIG_MODVERSIONS`, `CONFIG_MODULE_UNLOAD`, `CONFIG_ENERGY_MODEL`, `CONFIG_PERF_EVENTS`, `CONFIG_FUNCTION_GRAPH_TRACER` or `CONFIG_HZ` in that config without also rebuilding every module from the pmaports kernel package**: vermagic, `struct dev_pm_info` / `struct device` / `struct task_struct` layouts, and the `HZ` macro compiled into module inlines must match the untouched package modules. `CONFIG_SCHED_HRTICK` and `CONFIG_CPU_IDLE_GOV_TEO` are ABI-safe but effectively no-ops on this 2-core, 2-idle-state target. See `BATTERY-OPTIMIZATION-ANALYSIS.md` §14 for the full cost/benefit analysis. - `./scripts/build-xlibre.sh` — builds Xlibre `Xorg`, `libglamoregl.so`, `libglx.so`, and `modesetting`/`libinput`/`fbdev` DDX drivers. - `./scripts/build-bantam.sh` — fetches and cross-compiles the `bantam` AI agent. - `./scripts/generate-artwork.py` — regenerates wallpapers, splashes, and icons from `artwork/icon-large.png`. @@ -62,7 +62,7 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7` - **Documentation**: keep `README.md`, `MANUAL.md`, `SDK.md`, and `CHANGELOG.md` synchronized with any new user-facing features, SDK functions, or keybindings, and do not leave third-party `.md` files inside `src/` or `edl/`. - **Artifact sources**: `prebuilt/` is the single source of truth for compiled artifacts and `scripts/rootfs-packages.txt` for the `armv7` package set. Never edit `overlay/rootfs/` copies of binaries by hand; run `./scripts/sync-prebuilt-overlay.sh` after changing `prebuilt/`. - **Package hygiene**: keep `scripts/rootfs-packages.txt` free of Rust-based top-level packages (use C `sudo`, never `sudo-rs`) and Wayland-purpose packages; `libwpe` and the `wayland-libs-*` shared libraries stay because GTK3/WebKitGTK link them directly, but no Wayland compositor, backend, or viewer is shipped. `scripts/check-rebuild.sh` enforces this. -- **Power management**: idle blanking is `dwm`'s native evdev timer (`src/sxmo-dwm/dwm.c`) plus `bananarchy-idle-blank.sh`; the timeout lives in `~/.config/sxmo/idle_blank_timeout` (default 300 s, `0` = off), is edited via **Config -> Screen blank** / `bananarchy-idle-timeout.sh`, and is reloaded on `SIGUSR1`. `~/.cache/sxmo/sxmo.noidle` and `SXMO_UNLOCK_IDLE_TIME` still override it. `bananarchy-screen-wake.sh` (called from the ring and notification hooks) wakes the panel for calls/SMS and resets the timer; locking or closing the lid blanks immediately. Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert until a full custom kernel module tree is shipped. Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only. +- **Power management**: idle blanking is `dwm`'s native evdev timer (`src/sxmo-dwm/dwm.c`) plus `bananarchy-idle-blank.sh`; the timeout lives in `~/.config/sxmo/idle_blank_timeout` (default 300 s, `0` = off), is edited via **Config -> Screen blank** / `bananarchy-idle-timeout.sh`, and is reloaded on `SIGUSR1`. `~/.cache/sxmo/sxmo.noidle` and `SXMO_UNLOCK_IDLE_TIME` still override it. `bananarchy-screen-wake.sh` (called from the ring and notification hooks) wakes the panel for calls/SMS and resets the timer; locking or closing the lid blanks immediately. Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert because `CONFIG_SUSPEND` is off. A full custom module tree rebuild is deliberately **not** planned: this firmware has no PSCI `SYSTEM_SUSPEND`, so `CONFIG_SUSPEND` would only give s2idle (`freeze`), not `mem` / DDR self-refresh, for <1 mA of saving (see `BATTERY-OPTIMIZATION-ANALYSIS.md` §14). Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only. - **Image residue**: `rebuild-image.sh` strips `/var/cache/apk`, all `apk.log*` files, and unused gettext locale trees before `mke2fs` and aborts the build if any apk cache/log remains; never add an `apk` call after that guard. - **No on-device compiler**: `scripts/rootfs-packages.txt` ships no `gcc`/`g++`/`musl-dev`/`make` and no Janet runtime (`janet`, `janet-dev`, `jpm`); cross-compile native code with `scripts/build-*.sh`. On-device development uses the Yabasic FFI SDK (`neoui.yab` / `neonet.yab`), which requires `yabasic`, `libffi`, `libneoui.so`, and `libcurl.so.4` — never remove those. `scripts/check-rebuild.sh` guards both sides. - **Core tools**: `curl`, `bc`, `ed`, `rlwrap`, `mandoc`, `nano`, `less`, and `frotz` are pinned core tools asserted by `scripts/check-rebuild.sh`. Perl, Lua, optional Tcl extensions, and the `sqlite` CLI are excluded, while `tcl`, `python3`, `bash`, `luajit`, `gawk`, `jq`, `gojq`, and `quickjs` remain as hard runtime dependencies. diff --git a/BATTERY-OPTIMIZATION-ANALYSIS.md b/BATTERY-OPTIMIZATION-ANALYSIS.md index d9cbcb0..7ae12b8 100644 --- a/BATTERY-OPTIMIZATION-ANALYSIS.md +++ b/BATTERY-OPTIMIZATION-ANALYSIS.md @@ -429,3 +429,243 @@ U1's idle blanking is now a user-facing setting: **Config -> Screen blank** SMS/notifications wake immediately via `bananarchy-screen-wake.sh`, which also resets `dwm`'s idle timer. This keeps the panel off for long idle periods (battery) without delaying call/SMS visibility. + +--- + +## 14. Remaining kernel headroom and the full-module-tree question (live re-measurement) + +This section answers two questions with fresh on-device data: what kernel-side +optimizations are still unimplemented after `ad3461b` / `0dbb37f` / `22d629f` / +`da68bb8`, and whether rebuilding the *entire* pmaports kernel module tree is +worth doing to unlock them. + +### 14.1 Session, limits, and state + +- Host clock 2026-11-07 18:03-18:46 EET; phone `Bananarchy Linux a1107`, + `Linux nokia-argon 6.12.1-msm8916 #1 SMP PREEMPT`, freshly rebooted (uptime + 12-22 min during the windows), reachable at `172.16.42.1` over USB RNDIS. +- **Charging throughout**: `pm8916-lbc-chgr/online=1`, + `constant_charge_current=540000`, `pm8916-bms-vm/status=Charging`, capacity + `85 -> 87`, `voltage_now` 4.198 -> 4.309 V. There is no `current_now`, no + coulomb counter, `voltage_ocv` is empty, `hwmon6` exposes only `in0_input`, + `/proc/config.gz` is absent, and the SPMI `regmap` debugfs `registers` files + are read-only and return `XX`. The charger's + `CONSTANT_CHARGE_CURRENT` setter clamps to `PM8916_LBC_CHGR_MIN_CURRENT` + (90 mA) and always writes `CHG_EN`, so charging cannot be disabled from + userspace. **No discharge current was measurable**; every mA figure below is + a structural estimate, exactly as in section 1. +- Wi-Fi associated to `OffOurStreets_`; both SIMs registered on the network + (`SLOT1_REG_STATE=registered / lte / -67 dBm`, + `SLOT2_REG_STATE=registered / gsm / -66 dBm`), so DSDS RF was active during + the measurement. Caveat: `mmcli -L` reported `No modems were found` in this + session even though QMI NAS showed both SIMs registered; the ModemManager + modem object was absent. That is a separate functional issue and does not + remove the modem RF drain. +- Idle windows ran with the panel forced dark (`brightness=0`, `bl_power=4`, + DPMS `Off`) via `bananarchy-idle-blank.sh off`. +- **Session incident**: at ~22 min uptime the phone stopped responding (blank + panel, USB RNDIS gone from the host, no fastboot/EDL/ADB) and needed a hard + power-key reset. `pstore` was empty and the post-reset `dmesg` shows no panic + or oops; after the reset the phone booted normally with the screen on, Wi-Fi + connected and all services started. No kernel image, module, DTB, cmdline or + config was changed in this session — every probe was a read-only + sysfs/debugfs/`/proc` read plus `bananarchy-idle-blank.sh off/on` round-trips. + The cause is unknown; it is another reason not to swap the kernel/module ABI + on a device whose wake path is this fragile. +- **Post-reset fuel-gauge transient (new kernel-side finding)**: for the first + ~3.5 min after a hard reset the VM-BMS reports `voltage_now=19199723` uV + (19.2 V), `health=Over voltage`, `status=Full`, `capacity=100`, while + `voltage_ocv` is a sane 4.267 V. The cause is an uninitialised FIFO sample of + `0xffff`: `pm8916_bms_vm_fifo_update_done_irq()` accepts any raw value + `> 8000`, and `0xffff * 292.969 uV = 19.2 V`. It settles to 4.32 V / `Good` / + 96% once the first real 30 s FIFO sample arrives. This is a correctness bug + in `pm8916_bms_vm.c`, fixable with a source-only sanity clamp (no config or + ABI change); it is listed in 14.7. + +### 14.2 What the idle application processor actually does now + +60-second window, screen off, Wi-Fi up, both SIMs registered: + +| Signal | Rate | +|---|---| +| `arch_mem_timer` (broadcast timer, GIC 39) | 20.70 /s | +| `arch_timer` (GIC 20) | 15.08 /s | +| Total timer IRQs | **35.78 /s** | +| `IPI3` function call | 8.40 /s | +| `IPI1` timer broadcast | 1.78 /s | +| `IPI2` rescheduling | 0.85 /s | +| `wcn36xx_rx` | 2.43 /s | +| `mmc0` | 2.20 /s | +| `smd-edge` | 0.35 /s | +| `wcn36xx_tx` | 0.08 /s | +| `pm8916_vm_bms` | 0.02 /s | +| `cpu-sleep-0` (SPC) entries, cpu0 / cpu1 | 19.4 /s, 10.1 /s (**29.5 /s**) | +| CPU idle (`/proc/stat`) | 98.08% overall, 99.22% cpu0, 96.93% cpu1 | + +Runtime PM / clocks / regulators at the same moment: + +- `78b9000.spi`, `1c00000.gpu`, `7824900.sdhci`, `7864900.sdhci` all + `status=suspended`; GPU devfreq `simple_ondemand`, 409.6 MHz, 100 ms poll. +- `pm_genpd_summary`: `mx`, `mx_ao`, `cx`, all GDSCs `off-0`; `cx_ao` `on` + (cpu0); `1c00000.gpu`, `4080000.remoteproc` (modem), `a204000.remoteproc` + (WCNSS) all `suspended`. +- 21 clocks have a nonzero enable count. The always-on ones are structural: + `bimc_ddr_clk_src` 768 MHz (DDR **not** in self-refresh), `a53pll` 1094.4 MHz, + `gcc_mss_q6_bimc_axi_clk` 768 MHz (modem bus), `gcc_usb_hs_system_clk` + 80 MHz + `gcc_usb_hs_ahb_clk` 100 MHz (USB RNDIS), `sleep-clk` 32.768 kHz, + and `gcc_blsp1_uart1_apps_clk` 3.686 MHz (the `console=ttyMSM0` serial + console). Regulators with `use > 0` are `s2`, `l5`, `l6`, `l7`, `l8`, `l13`, + `l17` (audio codec, SDHCI, USB PHY, panel supplies) — no orphaned rail. +- All four LEDs are off with `none` / `mmc0` / `mmc1` triggers; no periodic + LED trigger exists. +- With the panel dark, userspace is nearly silent: 19.5 voluntary context + switches/s total, of which `rcu_preempt` 9.8/s, `kcompactd0` 2.1/s, a few + kworkers ~4/s. `Xorg` drops from 43.5/s (screen on) to ~0/s. Nine + `hrtimer_wakeup` entries were armed at any instant, with 0.5-2.5 s periods. + +In short: the userspace work from U1-U14 has already removed essentially all +userspace wakeups. What remains is kernel-internal tick/hrtimer/RCU activity +plus a handful of peripheral IRQs, on an AP that is already ~98% idle with +every runtime-PM domain collapsed. + +### 14.3 Decisive finding: `mem` suspend is impossible on this platform + +Enabling `CONFIG_SUSPEND` would **not** give suspend-to-RAM here: + +- `arch/arm/boot/dts/qcom/qcom-msm8916-smp.dtsi` explicitly sets + `psci { status = "disabled"; }` and replaces the PSCI idle state with + `qcom,idle-state-spc`. The live device tree has **no `/proc/device-tree/psci` + node**, no `/sys/firmware/psci`, `dmesg` says + `qcom_scm: convention: smc legacy`, and the cpuidle driver is `qcom_spm`. +- The only `suspend_set_ops()` caller reachable on ARM DT platforms is + `drivers/firmware/psci/psci.c`, and it only registers when PSCI 1.0 + `SYSTEM_SUSPEND` is available. `arch/arm/mach-qcom/` has no suspend ops. + `valid_state(PM_SUSPEND_MEM)` in `kernel/power/suspend.c` returns false + without `suspend_ops`, so writing `mem` to `/sys/power/state` degrades to + `mem_sleep_current = s2idle` at best and is rejected otherwise. +- Consequence: `CONFIG_SUSPEND=y` yields **only `freeze` (s2idle)**. s2idle + calls `tick_freeze()` -> `timekeeping_suspend()` and freezes tasks, so the + ~36 timer IRQs/s stop, but there is **no RPM-assisted SoC power collapse and + no DDR self-refresh**. `bimc_ddr_clk_src` stays at 768 MHz. That is the one + saving that could plausibly have been worth tens of mA, and it is gated by + firmware (lk2nd would have to implement PSCI `SYSTEM_SUSPEND`), not by the + kernel config. + +### 14.4 Full module tree rebuild: feasibility (it is clean) + +The rebuild itself turned out to be much less risky than assumed in section 11: + +- pmaports `v26.06` `device/testing/linux-postmarketos-qcom-msm8916/APKBUILD` + (`6.12.1-r5`) uses the **same** `msm8916-mainline/linux` `v6.12.1-msm8916` + tarball that `scripts/build-kernel-audio.sh` already caches. Its `prepare()` + is `default_prepare` plus `cp config-...armv7 .config` — **no patches at + all**. There are no pmaports-only driver fixes to lose. +- Our `config-bananarchy-msm8909.armv7` differs from + `config-postmarketos-qcom-msm8916.armv7` in ~248 lines, almost entirely the + GCC/binutils version stamp, `CONFIG_MODULE_COMPRESS_ALL=y`, and + `CONFIG_NFT_REDIR=m` for our `nft_redir.ko`. +- The package tree is **579 `.ko.zst` files / 11 MB**. Our config already has + `CONFIG_MODULE_COMPRESS_ZSTD=y`, `CONFIG_MODULE_COMPRESS_ALL=y` and + `CONFIG_MODULE_DECOMPRESS=y`, so `make modules_install INSTALL_MOD_STRIP=1` + reproduces the exact on-disk layout, and `rebuild-image.sh` already runs + `depmod -b "$ROOTFS" 6.12.1-msm8916`. `scripts/sync-prebuilt-overlay.sh` + would mirror a `prebuilt/kernel-6.12.1-msm8916/lib/modules/...` tree into the + overlay without changes. + +So the mechanical part is a bounded build-script change plus ~11 MB of +artifacts. The reason not to do it is the benefit, not the mechanics. + +### 14.5 Full module tree rebuild: benefit (it is not real) + +Quantify the only thing s2idle adds on top of the current state: + +- Eliminating all 29.5 SPC entries/s. Entry+exit latency of + `qcom,idle-state-spc` is 130/150 us; even at a pessimistic 75 mA during each + transition, that is ~0.3-0.5 mA of AP transition overhead. Removing every + timer IRQ, IPI and Wi-Fi/eMMC IRQ wakeup is the same order of magnitude + (<1 mA combined). +- `dpm_suspend()` would run every driver's system-sleep callback. Most of what + those would power down is already runtime-suspended (SPI, GPU, SDHCI, + remoteprocs, panel via DPMS). `wcn36xx_suspend()` would add ARP/NS/GTK + offload and `enable_irq_wake(wcn->rx_irq)` is already set at probe, so Wi-Fi + wake would work, but it only removes 2.43 RX IRQs/s. +- The dominant DSDS + Wi-Fi drain is untouched: two registered SIMs' RF, the + WCNSS/Pronto firmware, the modem bus clock, and DDR in active mode. None of + these are configurable from the kernel. Reaching 24 h on 1500 mAh needs + `<= 62.5 mA` average; a plausible current draw in this mode is ~80-120 mA, + so ~20-55 mA has to come from the modem/Wi-Fi side, not from <1 mA of AP + wakeup overhead. + +The remaining config-level items (K6/K7/K13/K14) do not change that verdict: + +- `CONFIG_HZ=100` changes the `HZ` macro compiled into module inlines + (`include/linux/jiffies.h`), so it is **not** ABI-safe either. +- `CONFIG_ENERGY_MODEL=y` inserts `em_pd` into `struct device` + (`include/linux/device.h`) and `CONFIG_PERF_EVENTS` / + `CONFIG_FUNCTION_GRAPH_TRACER` change `struct task_struct` — all module-visible. + ARM32 has no EAS, so `ENERGY_MODEL` buys nothing anyway. +- `CONFIG_RCU_LAZY` depends on `RCU_NOCB_CPU` and requires `rcu_nocbs=all`; + on 2 cores that adds always-running `rcuo` kthreads and trades away the idle + saving (already withdrawn as C17/K14). +- `CONFIG_PREEMPT_VOLUNTARY` / `CONFIG_HZ=100` also work against the project's + `< 2 ms` UI wakeup latency target. +- `CONFIG_SCHED_HRTICK` off and `CONFIG_CPU_IDLE_GOV_TEO=y` are genuinely + ABI-safe (the former only touches the private `kernel/sched/sched.h`), but + with no CFS bandwidth quotas and only two cpuidle states they are effectively + no-ops. + +### 14.6 Verdict + +**Do not rebuild the entire kernel module tree.** It is technically feasible, +but the only feature it unlocks is s2idle, which on this firmware cannot do +`mem`, cannot reach DDR self-refresh, and can save less than ~1 mA of AP +transition overhead against a ~20-55 mA deficit. It would reintroduce exactly +the class of risk that produced the unbootable `ad3461b` image (vermagic + +`struct dev_pm_info`), activate untested system-sleep callbacks for the panel, +DRM, Wi-Fi and modem remoteprocs, and conflict with the low-latency design +goal — for no measurable gain in DSDS + Wi-Fi runtime. pmaports deliberately +ships `# CONFIG_SUSPEND is not set` for this kernel. + +Deep standby therefore stays shipped disabled (`/etc/bananarchy-no-deep-standby`) +and inert, and the known-good module ABI stays untouched. If PSCI +`SYSTEM_SUSPEND` ever appears in lk2nd for MSM8909, revisit K1: that is the +change that would make a full rebuild worthwhile. + +### 14.7 Remaining kernel-level items, individually + +| Item | Expected gain | ABI / design risk | Verdict | +|---|---|---|---| +| K1 `CONFIG_SUSPEND` + wakelocks + autosleep | <1 mA (s2idle only, no `mem`) | vermagic + `struct dev_pm_info`; untested driver sleep callbacks | Declined (see 14.3-14.6) | +| K6 `HZ=100`, `PREEMPT_VOLUNTARY`, no hrtick, TEO | <1 mA, mostly duplicate of K1 | `HZ` macro in module inlines; vermagic; latency regression | Declined | +| K7 disable ftrace/perf/kprobes/BPF-JIT/debug | ~0 when unused | `struct task_struct` layout for perf/ftrace | Declined | +| K8 remove `earlycon console=ttyMSM0` | gates one 3.686 MHz UART clock, ~0.1-1 mA | none (cmdline only), but removes the serial debug lifeline | Optional, deliberately kept | +| K9 unused input/LED classes | 0 (no LED trigger active, all LEDs off) | none | No-op, declined | +| K13 `ZRAM_DEF_COMP_LZ4` | 0 (userspace already sets `lz4`) | changes the `zram` module default | No-op, declined | +| K14 `ENERGY_MODEL` / `RCU_LAZY` | 0 | `struct device` / needs `rcu_nocbs=all` | Declined | +| K2/K3/K4/K5/K10 (DT + patch 0006) | already landed | none | Done in `ad3461b` | +| K12 panel partial updates | deferred (display corruption risk) | none | Still deferred | +| New: `wcn36xx` `listen_interval` 3 -> 5+ | cuts ~1 Wi-Fi RX IRQ/s | none (source patch), but delays inbound Wi-Fi data | Marginal, declined | +| New: `commit=` on the rootfs mount | cuts ~2 eMMC IRQs/s | userspace, not kernel; risks data loss on sudden power cut | Out of scope, noted | +| New: VM-BMS FIFO sanity clamp | 0 power, fixes a 19.2 V / `Over voltage` misreport for ~3.5 min after hard reset | none (source-only patch to `pm8916_bms_vm.c`) | Worth fixing; no rebuild needed | + +### 14.8 Where the 24 h actually has to come from + +With the display now dark after 5 minutes and userspace quiet, the kernel is +no longer the bottleneck. The remaining budget has to be attacked at the modem +and Wi-Fi layers: + +1. **Modem idle power**: LTE eDRX / PSM via `AT+CEDRXS` / `AT+CPSMS` on + `/dev/wwan0at0` (or the QMI NAS equivalents). Two continuously registered + SIMs on LTE + GSM are the largest single drain; PSM/eDRX is the standard + way to cut it by an order of magnitude while staying reachable. This is a + modem-firmware configuration, not a kernel config option. +2. **DSDS policy**: parking the second SIM (or reducing its polling) when idle + trades DSDS availability for a large RF saving. +3. **Wi-Fi DTIM / listen interval**: AP-side DTIM and `wcn36xx` + `listen_interval` tuning can cut the 2.43 RX IRQs/s, at the cost of inbound + data latency. +4. **DDR self-refresh**: requires `mem` suspend, which needs PSCI + `SYSTEM_SUSPEND` in lk2nd. Until then `bimc_ddr_clk_src` stays at 768 MHz + and no kernel-side change can fix it. + +None of these four are unlocked by rebuilding the module tree. diff --git a/CHANGELOG.md b/CHANGELOG.md index e4fdafd..56a4757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,51 @@ Release versions follow the `
` format (where `2026` is `a`, --- +## Unreleased — kernel power headroom analysis (no runtime change) + +A second live measurement pass on the connected `nokia-argon` (screen off, +Wi-Fi up, both SIMs registered) quantified what is left after the battery +pass, and settled the "rebuild the entire kernel module tree" question: + +- **Idle AP is already quiet**: 98.08% CPU idle, both cores in + standalone power collapse, all genpd domains off, SPI/GPU/SDHCI and both + remoteprocs runtime-suspended. Remaining activity is ~35.8 timer IRQs/s, + ~29.5 SPC entries/s, 8.4 function-call IPIs/s, 2.4 Wi-Fi RX IRQs/s and + 2.2 eMMC IRQs/s. With the panel dark, userspace produces only 19.5 context + switches/s, mostly kernel threads. +- **`mem` suspend is impossible on this firmware**: no PSCI node in the live + device tree, `qcom_scm: convention: smc legacy`, cpuidle driver `qcom_spm`, + and no `platform_suspend_ops` for MSM8916. `CONFIG_SUSPEND` would give only + `freeze` (s2idle) — no RPM power collapse, no DDR self-refresh. +- **Full module tree rebuild declined**: pmaports `6.12.1-r5` applies no + kernel patches and ships 579 `.ko.zst` files / 11 MB from the same tarball + we already build, so the rebuild is mechanically clean. But s2idle would + save <1 mA of AP transition overhead against the ~20-55 mA needed for 24 h + in DSDS + Wi-Fi, while reintroducing the ABI and untested driver-sleep risks + of the unbootable `ad3461b` image. The known-good pmaports module ABI stays. +- **Additional ABI-breaking config options documented**: `CONFIG_ENERGY_MODEL` + (`struct device`), `CONFIG_PERF_EVENTS` / `CONFIG_FUNCTION_GRAPH_TRACER` + (`struct task_struct`), and `CONFIG_HZ` (the `HZ` macro compiled into module + inlines). `CONFIG_RCU_LAZY` needs `rcu_nocbs=all`, which is counterproductive + on 2 cores. `CONFIG_SCHED_HRTICK` and `CONFIG_CPU_IDLE_GOV_TEO` are safe but + no-ops here. +- **Where the remaining runtime has to come from**: modem LTE eDRX/PSM via + `AT+CEDRXS` / `AT+CPSMS`, DSDS policy, Wi-Fi DTIM/listen interval, and DDR + self-refresh (which needs PSCI `SYSTEM_SUSPEND` in lk2nd) — none of which a + module tree rebuild unlocks. +- **Live-session observations**: the phone needed one hard power-key reset at + ~22 min uptime (blank panel, USB RNDIS gone; `pstore` empty, no panic in the + post-reset `dmesg`, no kernel/module/cmdline change made in this session), and + the VM-BMS briefly reports 19.2 V / `Over voltage` after a hard reset because + an uninitialised `0xffff` FIFO sample passes the driver's `> 8000` filter. A + source-only sanity clamp is noted as worth fixing in + `BATTERY-OPTIMIZATION-ANALYSIS.md` §14.7; it needs no module tree rebuild. + +See `BATTERY-OPTIMIZATION-ANALYSIS.md` §14 for the full data and verdict. +No kernel image, module, DTB or userspace artifact changed in this pass. + +--- + ## Unreleased — configurable 5-minute screen blank, instant lock/wake - **Configurable idle blanking**: added **Config -> Screen blank** (`Off`, 30 s, diff --git a/MANUAL.md b/MANUAL.md index 847980c..a96fa66 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -101,7 +101,7 @@ sudo dd if=./images/bananarchy-nokia-argon.img of=/dev/sdX bs=4M status=progress | **Slider close / open** | `SW_LID` (`lid:on` / `lid:off`) | **Close**: close open menu, turn off keypad backlight, and lock phone with passcode (`xlocker`); **Open**: restore screen and keypad backlight and show passcode lock screen | > **Screen blanking, idle blanking, deep standby, passcode locking (`xlocker`), waking, and brightness persistence**: -> While unlocked (and with the lid open), the display blanks automatically after the configured **Screen blank** timeout — **5 minutes by default** — via `dwm`'s own evdev input timer and `bananarchy-idle-blank.sh`. Change it in **Config -> Screen blank** (`Off`, 30 s, 1/5/10/30 min), which writes `~/.config/sxmo/idle_blank_timeout`; `bananarchy-idle-timeout.sh get|label|set ` does the same from the shell, and `SXMO_UNLOCK_IDLE_TIME` or `~/.cache/sxmo/sxmo.noidle` still override/disable it. Closing the slider/lid or locking from the **Power** menu blanks the panel **immediately** (both `Lock` and `Lock (Screen off)` now use `xlocker screenoff`), and an incoming call or SMS/notification turns it back on **immediately** via `bananarchy-screen-wake.sh`, which also resets `dwm`'s idle timer so it cannot blank again right away. Any keypad, lid or power key also restores the display without engaging the passcode locker. X11 screensaver timeouts stay at `0 0 0`; DPMS is driven by the backlight state. Optional **deep standby** is currently **unavailable**: the shipped kernel keeps the pmaports module ABI and has no sleep states in `/sys/power/state`. It stays disabled via `/etc/bananarchy-no-deep-standby`; enabling it requires a full custom kernel module tree (see `BATTERY-OPTIMIZATION-ANALYSIS.md`). Active calls, SSH sessions and VPN/tether connections would block suspension. Locking the phone (`Power -> Lock`, `Power -> Lock (Screen off)`, `2x End / Power`, or closing the physical slider) activates the fullscreen `240x320` **Passcode Locker (`xlocker` / `locker.so`)**, which verifies your numeric system password (`147147` by default, checked against `/etc/shadow` via `/usr/bin/bananarchy-verify-passcode`). While locked, there is no keypad, softkey, slider, or power-button bypass (`dmenu`, `xdrawer`, terminal spawning, and desktop shortcuts are blocked, and only incoming calls can temporarily overlay `xcallscreen`). Screen and keypad brightness levels configured in **XDrawer** or **Config -> Brightness** are persisted in `~/.config/sxmo/brightness` and `/tmp/sxmo_saved_brightness` and restored on every wake. +> While unlocked (and with the lid open), the display blanks automatically after the configured **Screen blank** timeout — **5 minutes by default** — via `dwm`'s own evdev input timer and `bananarchy-idle-blank.sh`. Change it in **Config -> Screen blank** (`Off`, 30 s, 1/5/10/30 min), which writes `~/.config/sxmo/idle_blank_timeout`; `bananarchy-idle-timeout.sh get|label|set ` does the same from the shell, and `SXMO_UNLOCK_IDLE_TIME` or `~/.cache/sxmo/sxmo.noidle` still override/disable it. Closing the slider/lid or locking from the **Power** menu blanks the panel **immediately** (both `Lock` and `Lock (Screen off)` now use `xlocker screenoff`), and an incoming call or SMS/notification turns it back on **immediately** via `bananarchy-screen-wake.sh`, which also resets `dwm`'s idle timer so it cannot blank again right away. Any keypad, lid or power key also restores the display without engaging the passcode locker. X11 screensaver timeouts stay at `0 0 0`; DPMS is driven by the backlight state. Optional **deep standby** is currently **unavailable**: the shipped kernel keeps the pmaports module ABI and has no sleep states in `/sys/power/state`. It stays disabled via `/etc/bananarchy-no-deep-standby`. Even a full custom kernel module tree would not help here: this firmware has no PSCI `SYSTEM_SUSPEND`, so only s2idle (`freeze`) would be possible, without DDR self-refresh, and the saving would be under 1 mA (see `BATTERY-OPTIMIZATION-ANALYSIS.md`). Active calls, SSH sessions and VPN/tether connections would block suspension. Locking the phone (`Power -> Lock`, `Power -> Lock (Screen off)`, `2x End / Power`, or closing the physical slider) activates the fullscreen `240x320` **Passcode Locker (`xlocker` / `locker.so`)**, which verifies your numeric system password (`147147` by default, checked against `/etc/shadow` via `/usr/bin/bananarchy-verify-passcode`). While locked, there is no keypad, softkey, slider, or power-button bypass (`dmenu`, `xdrawer`, terminal spawning, and desktop shortcuts are blocked, and only incoming calls can temporarily overlay `xcallscreen`). Screen and keypad brightness levels configured in **XDrawer** or **Config -> Brightness** are persisted in `~/.config/sxmo/brightness` and `/tmp/sxmo_saved_brightness` and restored on every wake. #### 3.1.1 Window tiling modes and switching combos By default, `dwm` uses the **vertical bottom-stack (`bstack`, `TTT`)** layout so multiple `st` terminals stack **vertically (one under another)** to preserve full line width on the `240x320` portrait screen. diff --git a/README.md b/README.md index 6ccdedf..49adade 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ## Key features ### System and hardware support -- **Mainline Linux 6.12 kernel**: custom patches and out-of-tree drivers for Qualcomm **Adreno 304 (`FD304`, 96 KB GMEM)** 3D GPU acceleration (`drm/msm` + `qcom-iommu`), Qualcomm QDSP6/Q6Voice audio routing, Dual-SIM modem control, the rear 2MP GalaxyCore `GC2395` / `GC2385` / `GC2365` camera (`/dev/video0`), the `SY7807` flashlight LED (`white:torch`), physical keypad/slider events, and clean PM8909 poweroff. The kernel image is built from `config-bananarchy-msm8909.armv7` with the known-good pmaports module ABI, and ships with idle-blanking power management; see `BATTERY-OPTIMIZATION-ANALYSIS.md`. +- **Mainline Linux 6.12 kernel**: custom patches and out-of-tree drivers for Qualcomm **Adreno 304 (`FD304`, 96 KB GMEM)** 3D GPU acceleration (`drm/msm` + `qcom-iommu`), Qualcomm QDSP6/Q6Voice audio routing, Dual-SIM modem control, the rear 2MP GalaxyCore `GC2395` / `GC2385` / `GC2365` camera (`/dev/video0`), the `SY7807` flashlight LED (`white:torch`), physical keypad/slider events, and clean PM8909 poweroff. The kernel image is built from `config-bananarchy-msm8909.armv7` with the known-good pmaports module ABI, and ships with idle-blanking power management; `BATTERY-OPTIMIZATION-ANALYSIS.md` records the measured idle state and explains why suspend-to-RAM is unavailable on this firmware (PSCI `SYSTEM_SUSPEND` missing) and why a full custom module tree rebuild is not worthwhile. - **Alpine Linux Edge base**: full access to the Alpine package ecosystem with `< 95 MB` idle RAM usage on 512 MB devices and full local root access out of the box. - **Pure X11 graphical stack with GPU acceleration**: cross-compiled **Xlibre** (`X11Libre/xserver`) display server offloading 2D/3D screen rendering to the **Adreno 304 GPU** via **Glamor, DRI3, GLX, and Mesa Freedreno (`FD304`, OpenGL 3.1 / OpenGL ES 3.0)** over `panel-mipi-dbi` KMSRO, paired with a customized **Sxmo (`sxmo-de-dwm`)** window manager (`240x320` vertical stack layout, native `ParentRelative` desktop clock and softkey bar without Conky overhead, `< 2 ms` slider/key wake latency, and zero Wayland overhead).