Fix SPM sleep im_wait failure, defer lid-closed touch wake, and harden powerd

This commit is contained in:
Luxferre committed 2026-11-29 09:36:07 +02:00
1 parent a015ef64ef
commit efc5c0a548
13 files changed
+277 -25

No files matched your search

+5 -5
View File
@@ -32,7 +32,7 @@ Built into `7.3.5-geminux` via [kernel/configs/geminux-mt6797x.config](kernel/co
- Guards pending `rx_work` and unread RX GPDs in `mt6797_ccci_suspend()`, restores/restarts RX `SO` rings in `mt6797_ccci_resume()`, and raises `pm_wakeup_event()` to `3000 ms` on CLDMA/CCIF interrupts.
- **Panfrost VGPU / LDO / MFGPLL suspend rail-off (`0014`)**: Once all four GPU core domains are runtime-suspended, `panfrost_device_suspend()` releases OPP/regulator references alongside `mt->vgpu` (shutting off external `rt5735_vgpu`), clears `MT6797_GPULDO_EN` (`0x1ff -> 0`), and parks `mfg-sel` on `clk26m` to power off `MFGPLL`, restoring in vendor LDO → `vgpu` → `clk_set_rate` → OPP order on resume.
- **CCCI MD1 cold-boot & flight-mode gating (`0014`)**: `mt6797_ccci_power_off()` and cold-boot `stage=0` re-gate `INFRA_CG0_MD_MASK`/`INFRA_CG1_MD_MASK`, set `C2K_LTE_LS_ISO_BIT` and `MD1_EXT_BUCK_ISO_BIT`, clear `MDPLL1` 26 MHz clock bits, and ensure `SPM_MD1_PWR_CON` is powered down so Airplane Mode leaks zero modem power.
- **SPM, Hall lid, PMIC IRQ & fuel-gauge hardening (`0008`, `0011`, `0012`, `0013`)**: Bounds `spm_enter()` PCM rollovers, clears `mtk-eint` debounce across wakeups, debounces Hall `SW_LID` (`1 ms`) / keypad (`10 ms`), reconciles `gemini-lid` on `PM_POST_SUSPEND`, moves `mt6397_irq_suspend`/`resume` to `LATE_SYSTEM_SLEEP_PM_OPS`, adds `WAKE_PCM_WDT` + a `5000 ms` `cntp` safety backstop, and stabilizes `mt6351-fuel-gauge` + `bq25890` zero-current OCV/taper calibration.
- **SPM, Hall lid, PMIC IRQ & fuel-gauge hardening (`0008`, `0011`, `0012`, `0013`, `0015`)**: Bounds `spm_enter()` PCM rollovers, clears `mtk-eint` debounce across wakeups, debounces Hall `SW_LID` (`1 ms`) / keypad (`10 ms`), reconciles `gemini-lid` on `PM_POST_SUSPEND`, moves `mt6397_irq_suspend`/`resume` to `LATE_SYSTEM_SLEEP_PM_OPS`, adds `WAKE_PCM_WDT` + a `5000 ms` `cntp` safety backstop, disables `s.sleep.im_wait` by default (`sleep_im_wait=0`, preventing `-ETIMEDOUT` aborts before `PCM_KICK_L`), defers `SSD2092` touch MCU wake while lid-inhibited until `input->open()`, triggers cold-boot `pm_runtime_autosuspend()` on Panfrost, and stabilizes `mt6351-fuel-gauge` + `bq25890` zero-current OCV/taper calibration.
## Zero-poll userspace daemons
@@ -40,10 +40,10 @@ Built into `7.3.5-geminux` via [kernel/configs/geminux-mt6797x.config](kernel/co
Starts `after modules geminux-hwinit geminux-ccci` and waits in `epoll_wait()` over `/dev/input/event*` (`SW_LID`, `KEY_POWER`, `mtk-pmic-keys` `KEY_ESC`), filtered `KOBJECT_UEVENT` netlink (`input`, `power_supply`, `drm`), `/run/geminux/powerd.sock`, and a lazy `timerfd`:
- **USB/AC policy (`inhibit_ac_lid`)**: Locks and blanks (`bl_power=4` + `DPMSModeOff`) without unloading CONSYS or invoking `/sys/power/state`, keeping `bq25890`'s `40 s` watchdog fed without `-EBUSY` thrash.
- **Battery `mem` & standby backoff**: Enters `mem` suspend whenever `md1/stage == 0` or `allow_md1=Y` (falling back to `low_power_standby` for active MD1 only if `allow_md1=N`). Before suspending, it reaps any in-flight `radio_worker_pid`, unloads CONSYS, and ensures `md1/stage == 0` when Airplane Mode is enabled; transient `-EBUSY` results trigger exponential retries (`3s -> 10s -> 30s -> 60s`) and immediate `SIGCHLD` re-arming when `radio_worker_pid` completes.
- **USB/AC policy (`inhibit_ac_lid`)**: Refreshes AC/HDMI state directly on `SW_LID` close; locks and blanks (`bl_power=4` + `DPMSModeOff`) without unloading CONSYS or invoking `/sys/power/state`, keeping `bq25890`'s `40 s` watchdog fed without `-EBUSY` thrash.
- **Battery `mem` & standby backoff**: Enters `mem` suspend whenever `md1/stage == 0` or `allow_md1=Y` (falling back to `low_power_standby` for active MD1 only if `allow_md1=N`). Before suspending, it reaps any in-flight `radio_worker_pid`, unloads CONSYS, and ensures `md1/stage == 0` when Airplane Mode is enabled; transient `-EBUSY` failures or short `< 5 s` non-modem sleep cycles trigger exponential retries (`3s -> 10s -> 30s -> 60s`), `SIGCHLD` re-arms immediately when `radio_worker_pid` completes, and `last_errno` / `last_sleep_ms` are reported in `powerd` status.
- **Wakeup filtering & modem-wake grace**: Polls post-resume input events (`90 ms`) BEFORE onlining secondary CPUs and checks `/sys/module/mt6797_spm_sleep/parameters/last_wake_r12`:
- Internal `600 s` PCM timer rollovers (`quiet_timer_resleep`) keep `cpu1..7` offline and re-enter `mem` sleep after `300 ms` without waking Xorg or reloading CONSYS.
- Internal `600 s` PCM timer rollovers (`quiet_timer_resleep`) and any spurious `EV_KEY`/`EV_ABS` while `SW_LID` remains closed keep `cpu1..7` offline and re-enter `mem` sleep after `300 ms` without waking Xorg or reloading CONSYS.
- Modem wakes (`CCIF0`/`MD1_WDT`/`CLDMA`) grant a `3500 ms` closed-lid grace window so `ModemManager`/`geminux-modem-ctl`/`geminux-imsd` can assert `inhibit add call`; once the call ends (`inhibit del`), suspend re-arms after `1000 ms`.
- Only `closed -> open` lid transitions, genuine user input, or AC attach wake the session.
- **X11 DPMS blank/wake & lock sync**: Blanking sets `brightness=0`, `bl_power=4`, and `DPMSModeOff`; unblanking calls `DPMSForceLevel(..., DPMSModeOn)` + `XResetScreenSaver()` in a `500 ms` timeout-capped privilege-dropped child; pre-suspend locking waits up to `1800 ms` for `geminux-lock` to publish `_GEMINUX_LOCK_READY`.
@@ -83,7 +83,7 @@ geminux-power-audit
geminux-power-audit --json
```
Look for `"spm_pmic_modes":"Y"`, `"spm_allow_md1":"Y"`, incrementing `"suspend_success"` and `"gpu_rail_suspends"`, `"vgpu_state":"disabled"`, `"last_failed_dev":"none"`, and standby current draw (`current_ua`) after a closed-lid battery sleep window. If you ever need to test cellular fallback without MD1 `mem` suspend, disable `allow_md1` at runtime:
Look for `"spm_pmic_modes":"Y"`, `"spm_allow_md1":"Y"`, `"spm_sleep_im_wait":"N"`, incrementing `"suspend_success"` and `"gpu_rail_suspends"`, `"vgpu_state":"disabled"`, `"last_failed_dev":"none"`, `"last_failed_errno":"0"`, and standby current draw (`current_ua`) after a closed-lid battery sleep window. If you ever need to test cellular fallback without MD1 `mem` suspend, disable `allow_md1` at runtime:
```sh
echo 0 | doas tee /sys/module/mt6797_spm_sleep/parameters/allow_md1