Restore 72h DSDS + Wi-Fi standby battery optimizations across all targets

- Fix Combined EPS/IMSI (cs_attach=1) false 4G-only IMS activation in
  ims_qrtr.h, close idle QRTR sockets, bound child/baseband retries, and
  deduplicate state.env writes in bananarchy-imsd.c
- Skip inactive DHCP/connectivity IMS notifications in 40-bananarchy-ims.sh
  and add capped exponential registration backoff (5s-300s) plus
  openCtlSocket() rebind guard in bananarchy-vowifi
- Sync CPU scaling_governor and idempotent screenoff/screenon policy across
  bananarchy-display-power-sync, locker.so, and bananarchy-power-policy.sh
  (standby.mode + rat_timer.pid), and gate noisy change events when dark in
  30-bananarchy-network-status.sh
- Fix bananarchy-dsds --sig-hysteresis QMI NAS wire opcodes to 0x0045
  (1-byte sub bind) and 0x0050 (RSSI/RSCP/RSRP/LTE report threshold config)
- Remove static 200 mA regulator-system-load on PM8909 l11 across all 6
  DTS files and recompile all 5 shipping DTBs
- Extend test-imsd-volte.py, test-standby-power-policy.py, check-rebuild.sh,
  BATTERY-OPTIMIZATION-ANALYSIS.md (Section 24), AGENTS.md, and Unreleased
  CHANGELOG.md notes + rebuilt image SHA-256 checksums (--mkinitfs)
This commit is contained in:
Luxferre committed 2026-11-21 11:05:22 +02:00
1 parent c40ec932de
commit c9eb28b891
42 files changed
+751 -91

No files matched your search

+21
View File
@@ -1613,3 +1613,24 @@ standby baseline (`<= 20.8 mA` on the 1,500 mAh cell) without re-enabling
`scripts/check-rebuild.sh` zero-regression checks.
- Physical 24h and 72h unplugged discharge measurements (without and with a
microSD card installed) remain to be measured against the rebuilt image.
## 24. Post-IMS/SMP Standby Audit & ~72h DSDS + Wi-Fi ON Restoration (2026-11-21)
After integrating the `a1120` 4-core SMP/cpufreq patch (`0013`), IMS/VoLTE/VoWiFi stack, and Dual-SIM mobile data fixes, an end-to-end audit identified five regressions pulling DSDS + Wi-Fi standby far below the 72-hour (`<= 20.8 mA` average on the `1,500 mAh` battery) budget:
1. **IMS false 4G-only detection, QRTR wakeups, and `bananarchy-vowifi` poll storm**:
- `ims_qmi_nas_get_serving()` in `src/bananarchy-daemons/ims_qrtr.h` inspected `n_rad` (`1`) and `rad[0] == 0x08` (LTE) without inspecting `cs_attach` (`srv[1]`) or registration/PS-attach state. Standard LTE+CSFB cells using Combined EPS/IMSI attach report a single `0x08` LTE radio with `cs_attach == 1`, causing `bananarchy-imsd` in `volte_mode=auto` / `vowifi_mode=auto` to falsely latch `NETWORK_4G_ONLY=1`, start `QMI_IMSDCM`, and block GSM Wi-Fi standby RAT parking (`WIFI_STANDBY_RAT=gsm`).
- Additionally, `bananarchy-imsd` held its `AF_QIPCRTR` socket open even when completely idle, looped indefinitely on a `2,000 ms` `poll()` timeout, re-wrote `state.env` unconditionally, and probed NAS QRTR on `wlan0` / `epdg` events even when `auto` was inactive and Wi-Fi was parked; `40-bananarchy-ims.sh` also invoked `bananarchy-imsctl` on every `dhcp4-change` / `dhcp6-change` / `connectivity-change` even when IMS was inactive; and `bananarchy_vowifi.cpp` leaked/rebound its Unix control socket and retried SIP/IKEv2 registration on a `1,500 ms` / `10 s` loop.
- **Fix**: Updated `ims_qmi_nas_get_serving()` to treat `cs_attach == 1` as CS-capable and require registered PS-only LTE (`reg_state == 1 && ps_attach == 1 && has_lte && !has_cs`, or explicit `pref_lte_only`); added `close_qrtr()`, `ims_state_equal()`, `is_wifi_rat_parked()`, bounded child/baseband retries (`500 ms` x4 / `3,000 ms` x3, otherwise `poll(..., -1)`), `40-bananarchy-ims.sh` inactive-event early exit, and `5 s` -> `300 s` exponential backoff in `bananarchy_vowifi.cpp`.
2. **Unsynchronized / non-idempotent display power sync (`bananarchy-display-power-sync`, `locker.so`, `bananarchy-power-policy.sh`)**:
- Under `0013` 4-core SMP (`1.267 GHz`), `bananarchy-display-power-sync` never synced CPU `scaling_governor` or triggered `bananarchy-power-policy.sh screenoff|screenon`, while `locker_plugin.cpp` blanked/woke the backlight without calling `bananarchy-power-policy.sh`. Meanwhile, `bananarchy-power-policy.sh` lacked `screenoff` / `screenon` idempotency and could spawn duplicate `arm_rat_park_timer()` subshells.
- **Fix**: Added `CPU_GOV_PATH`, `sync_cpu_governor()`, and `sync_standby_policy()` to `bananarchy-display-power-sync` across flip and non-flip paths (preserving `powersave` and idempotent `screenoff` through closed-flip cover-display wakes); wired `locker_plugin.cpp` `blankScreenBacklight()` / `wakeScreenBacklight()` to `/usr/bin/bananarchy-power-policy.sh`; and made `screenoff()`, `screenon()`, and `arm_rat_park_timer()` idempotent via `$RUNDIR/standby.mode` and `$RUNDIR/rat_timer.pid`.
3. **Broken QMI NAS signal hysteresis opcodes in `bananarchy-dsds.c`**:
- Disassembly of `qmi_client_nas_config_signal_info` in `rootfs/usr/lib/libqmi-glib.so.5.12.0` confirmed that `apply_sig_hysteresis()` sent wrong message IDs `0x006F` (with 4-byte sub) and `0x004F` (`GET_SIGNAL_INFO`) + wrong TLV `0x13` (`LTE_SNR`) instead of `0x0045` (`QMI_NAS_BIND_SUBSCRIPTION`, 1-byte TLV `0x01`) and `0x0050` (`QMI_NAS_CONFIG_SIGNAL_INFO`) with TLVs `0x10` (`RSSI`), `0x18` (`RSCP`), `0x16` (`RSRP` 16-bit LE), and `0x17` (`lte_report` `rate=0`, `avg=5 s` dark / `1 s` wake).
- **Fix**: Corrected `apply_sig_hysteresis()` to use `0x0045` + `0x0050` with all four threshold/report TLVs and added `BANANARCHY_DSDS_SIG_MOCK_SOCK` for host wire-level testing.
4. **Static `200 mA` `l11` regulator load on microSD in DTS/DTBs**:
- All 6 DTS files still set static `regulator-system-load = <0x30d40>;` (`200 mA`) on PM8909 `l11` (`sdhci@7864000` `vmmc-supply`), preventing LPM when a microSD card is inserted.
- **Fix**: Removed `regulator-system-load = <0x30d40>;` from all 6 DTS files (keeping `regulator-allow-set-load;`), recompiled all 5 shipping DTBs, and guarded against regression in `scripts/check-rebuild.sh`.
5. **Dark-screen NetworkManager status spawner (`30-bananarchy-network-status.sh`)**:
- Every `dhcp4-change`, `dhcp6-change`, `dns-change`, or `connectivity-change` event spawned `su user -s /bin/sh -c /usr/bin/bananarchy-network-event.sh` even when dark.
- **Fix**: Gated noisy change events in `30-bananarchy-network-status.sh` behind `is_screen_dark()` while keeping `up`/`down`/`vpn-*` transitions unconditional.