diff --git a/AGENTS.md b/AGENTS.md index 6e0265f08..e8360dde0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -175,6 +175,8 @@ Each entry gives the gotcha, then the reason or the fix. Details are in the link ### Suspend and modem - **On the 9a, NFC must not poll through s2idle.** A suspend with neard polling reset the palmtop (2026-10-27); with polling stopped, 35 s2idle cycles with RTC wakes that day all woke (`7.3.0-rc6-omamobile-tegu-s2mpg15-m1`). The cause isn't known: nxp-nci has no PM callbacks, but neither does the 7 Pro's st-nci, so the controller's interrupt or the I2C bus during the freeze are the next suspects. A sleep hook on the palmtop, `omamobile-tegu-nfc` (not in the repository yet; it comes with tegu's device package), stops neard's poll loop before a systemd sleep and restarts it after; a sleep written straight to `/sys/power/state` (`rtcwake -m mem`) skips the hook, so stop polling by hand first. Without [linux-omarchy-mobile#131](https://github.com/derekross/linux-omarchy-mobile/pull/131) the ST54L also doesn't answer on I2C after a wake (`Error -6 on I2C send`, also after the driver's retry), or after about 2-3 s of idle at any time, until neard powers it off and on ([#132](https://github.com/derekross/omarchy-mobile/issues/132)): nxp-nci never turned its NFC mode on, as ST's HAL does after init. With #131 (the results below on `core.c` blob `77fc35b61da5`, #131's first version; the merged version, `c96704ddd480`, re-run for six power-ons and polling at 3 s and 30 s; the release, `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, is the same as without the fix), NFC polls after 3 s to 3 minutes of idle and polled again after two RTC-woken s2idle cycles (2026-10-29): one with a hook that stops polling and powers the adapter off, and one without that hook, for which it isn't recorded whether polling was stopped, so whether NFC comes back after a wake with the stop-poll hook alone rests on that one cycle and needs a re-run with the hook's log. No power-off hook is needed for NFC; the stop-poll rule above stands on its 35 of 35. [tegu MODEM-PLAN](device/tegu/MODEM-PLAN.md) "Suspend with the modem on" +- **On the 9a, sleep tests are attended, and the direct freeze path is still not used.** Three sleeps have never woken (not from the RTC alarm, not from the power key; Power + Volume Up to reset, nothing in pstore): two direct `rtcwake -m freeze` runs (2026-10-28, 2026-10-29) and one 30-minute `systemctl suspend` with `tegu-mif-sleep` loaded (2026-10-30, cable out); 35 short and seven longer systemd sleeps woke (two 30-minute and four 240 s ones on 2026-10-29, a cable-in 30-minute one with the module on 2026-10-30; the afternoon's cable-out run with the module makes eight). No single factor explains it, so keep sleep tests attended, keep `power-ab` on `--suspend systemd` (the sleep hooks run that way), and don't load `tegu-mif-sleep` at boot until the hang is understood. The shell's the shell's auto-sleep (the `omamobile-sleep` toggle, systemd path, no module) woke every time while it was on, and the two no-wakes without the module were both direct freezes; the toggle is off on the palmtop since the 2026-10-30 shell reinstall (the package ships it off), so turning it on is the owner's call. [tegu SLEEP-PLAN](device/tegu/SLEEP-PLAN.md) S1 +- **On the 9a, a sleep can end badly in two ways: UFS fails to come back and the root filesystem goes read-only, or the SoC hangs and leaves the USB bus.** The first seen once on 2026-10-30 (`link startup failed 1`, `Host init failed 1` x5, `ufshcd_wl_resume failed`, then `I/O error, dev sda` and ext4 `emergency_ro`; `spm_lvl` 5). The palmtop woke on its alarm but nothing on disk could be read: `systemctl suspend`/`reboot` did nothing, the power key could not light the screen, SSH kept answering from memory. A dark palmtop that ignores the power key may therefore be awake with dead storage, not asleep. After every s2idle, `dmesg | grep -E "link startup failed|Host init failed|I/O error"` first; if it matches, `echo b > /proc/sysrq-trigger` (binaries won't load), then check the ext4 recovery on the next boot. [tegu SLEEP-PLAN](device/tegu/SLEEP-PLAN.md) S1 - **UFS must be at `spm_lvl` 5 in system suspend.** At the core default 3, UFS failed its first hibern8 exit on resume and needed a host reset (it recovered, no I/O errors); at 5 the first real s2idle freeze resumed clean. gs201 now defaults to 5 in the kernel (S3a, `a7e5e1d95`), so a suspend test only checks that `spm_lvl` reads 5; on a kernel without that commit, `echo 5` first. [SUSPEND-PLAN](device/cheetah/SUSPEND-PLAN.md) S1-S3 - **Only s2idle, never `deep`.** The firmware advertises PSCI SYSTEM_SUSPEND, so mainline offers `deep`, but Linux has no gs201 SoC sleep sequence (SYS_SLEEP), and the phone wouldn't wake. `mem_sleep_default=s2idle` in the bootargs and device-cheetah's `sleep.conf` drop-in keep it on s2idle. [SUSPEND-PLAN](device/cheetah/SUSPEND-PLAN.md) §1, §5 - **Some unattended RTC cycles wake early on the PMIC interrupt** (2 of 20 in S4, 4 of 31 in S5c, at 13-16 s instead of 30 s). Which PMIC event it is hasn't been read yet; count it, don't treat it as a failed cycle. [SUSPEND-PLAN](device/cheetah/SUSPEND-PLAN.md) S4, S5c diff --git a/device/tegu/NOTES.md b/device/tegu/NOTES.md index 050ed27e6..8569aa47c 100644 --- a/device/tegu/NOTES.md +++ b/device/tegu/NOTES.md @@ -35,6 +35,38 @@ resets) and are in [MODEM-PLAN](MODEM-PLAN.md) under "G3, twenty-fourth to thirty-fourth tries" and "The CP link hang". Not a GNSS matter: if a boot with nothing but Bluetooth starting resets again at that time, start here. +## 2026-10-29: the s2idle drain is the SoC floor, not the CPUs or the radios + +- Cable out, screen off: 311 mA awake, 302 mA asleep (two 30-minute + `systemctl suspend` rounds through `power-ab --suspend systemd`). The CPUs + sleep (timekeeping suspended for the whole of a 60 s test, one deep-state + entry per CPU); Bluetooth, NFC and Wi-Fi cost nothing measurable at idle. + What stays on is MIF, the buses and the always-on rails: there is no + system idle state in our kernel. `tegu-mif-sleep.ko` (MIF 421 MHz in + sleep) saves about 60-75 mA by the coulomb counter; a hand unit loaded it + at boot for one night and was disabled the next day (below). + Details and method in [SLEEP-PLAN](SLEEP-PLAN.md) S1. +- `rtcwake -m freeze` written straight to `/sys/power/state` failed to wake + again (the second time in two days); every `systemctl suspend` after + `rtcwake -m no` had woken up to then. The next day showed the entry + path isn't the whole story (the 2026-10-30 bullet). +- 2026-10-30: the cable-out `power-ab --suspend systemd` run with the + module loaded never woke from its 30-minute sleep (not from the RTC, not + from the power key; reset by hand), so the hand unit that loaded the + module at boot is disabled. The same day a cable-in 30-minute systemd + sleep with the module, its alarm logged as armed, woke on the alarm to + the second, and the afternoon's repeat of the cable-out run with the + module loaded by hand woke too: 273 mA awake with the screen off, 260 mA + asleep, about 40 mA under the figure without the module. Three sleeps + have never woken (two direct freezes, one systemd sleep with the module) + and no single factor explains them, so sleep tests stay attended and the + module stays off at boot; the shell's auto-sleep toggle is off on the + palmtop since the 2026-10-30 shell reinstall, and unattended sleep stays + off until the hangs below are understood. +- The 2026-10-27 "140 mA asleep" figure doesn't hold up against 2026-10-28 + (434-445 mA cable out, as-is) and tonight; treat about 300 mA cable out + as the baseline. + ## 2026-10-28, evening: USB-C host mode through TCPM Kernel `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty` (the diff --git a/device/tegu/SLEEP-PLAN.md b/device/tegu/SLEEP-PLAN.md index 168d7f129..0df3ee52d 100644 --- a/device/tegu/SLEEP-PLAN.md +++ b/device/tegu/SLEEP-PLAN.md @@ -1,8 +1,18 @@ # Pixel 9a sleep: why s2idle drains so much -Status (2026-10-29): s2idle works (RTC and power-key wakes; NFC and Wi-Fi -have their own notes in NOTES and AGENTS), but the drain in sleep is high. +Status (2026-10-31): s2idle usually works (RTC and power-key wakes; ten of +ten 30-second cycles on 10-31 with the console kept through the freeze), +but not always: four sleeps have never woken (two direct freezes, one +30-minute systemd sleep with `tegu-mif-sleep` loaded, and the sixth +30-second cycle of a boot on 10-30, which left the USB bus and needed a +forced restart), and one more woke with UFS dead (`link startup failed` x5, +then I/O errors and `emergency_ro`, 10-30 afternoon). The drain in sleep is +high. Sleep tests are attended and unattended sleep stays off. The shell's auto-sleep (the `omamobile-sleep` toggle) is +off on the palmtop since the 2026-10-30 shell reinstall (the package ships +it off), so it doesn't sleep unattended at present; while it was on, its +systemd-path sleeps without the module all woke, and turning it back on is +the owner's call. This plan gathers what's measured, an audit from stock's device tree and a read-only snapshot of the palmtop, the candidates ranked, and a measurement runbook. @@ -25,7 +35,9 @@ merge): The figures are from the 2026-10-27 and 10-28 NOTES entries (). -- **s2idle with the cable out: about 140 mA** (59 minutes, 2026-10-27). +- **s2idle with the cable out: about 300 mA** (302 mA over two 30-minute + sleeps on 2026-10-29, S1 below; the 140 mA read on 2026-10-27 didn't + hold up and is retired there). - **MIF in sleep** (cable in, buck off, Bluetooth blocked, 600 s RTC-woken freezes): 371-373 mA at MIF 2028 MHz, 314 mA at 421 MHz, so lowering MIF for sleep saves about 57 mA. With the cable in, the USB link keeps the @@ -58,6 +70,27 @@ The figures are from the 2026-10-27 and 10-28 NOTES entries S5300's GNSS supplies stay up through sleep, with the modem off too. In stock's DT they carry `channel-mux-selection` (subsys GPS): the GNSS core switches them itself. Off unless the modem's GNSS runs. +2b. **What S2 can and cannot change, now that GNSS works (read from the + running DTB, 2026-10-30 night).** The four rails are declared with + labels (`gnss_core: ldo9s`, `gnss_rf: ldo10s`, `gnss_aux: ldo11s`, + `udfps_3v3: ldo15s`) and **no consumer anywhere in the device tree**: + nothing names them as a supply, which is why they need + `regulator-always-on` to stay up at all. So removing that property does + not move the cost to the user of the rail, it simply lets the regulator + core's unused-rail cleanup turn all four off about 30 s after late init. + That is still a valid one-boot measurement, and it is what S2 asks for, + but it is not a shippable policy: GNSS needs its three rails for a + session (the Kepler RF front end cannot calibrate without them, which is + why they are on as stock has them), and the fingerprint sensor needs + LDO15S for an operation. Now that a GNSS session works end to end, the + policy S2 should lead to is a consumer rather than an absence: the GNSS + path claiming its three rails when a session starts and dropping them + when it ends, and the fingerprint path doing the same around an + operation, so the drain is paid only while something uses the hardware. + That needs a supply property on the consumer's node and driver support + on both paths, neither of which exists upstream yet, so the order is: + measure with S2 to learn the number, then decide whether the number + justifies the driver work. 3. **Fingerprint rail always on.** `udfps-3v3` (LDO15S) is also `regulator-always-on` in the bring-up DTB. The sensor only needs it while an operation runs. @@ -151,17 +184,292 @@ tools/phone-ssh 'power-ab --detach --unplug 180 --phase 1800 --rounds 2 --suspen `--suspend systemd` arms the RTC with `rtcwake -m no` and runs `systemctl suspend`, so the NFC sleep hook runs (a freeze written to -`/sys/power/state` would skip it). Phase A is awake with the screen off, +`/sys/power/state` would skip it). On the 9a always pass it: `power-ab`'s +default, `--suspend rtcwake`, is a direct freeze, the path that fails to +wake (the S1 result below), and a detached cable-out run is the worst place +for one. Phase A is awake with the screen off, phase B is the 30-minute sleep, two rounds. The 9a's gauge has no `charge_counter`, so the figure is the `charge_now` column of the CSV (column 7, `charge_now_uah`): the gauge's model-corrected remaining -charge, coarser than a coulomb counter, hence the long phases. Repeat with -`tegu-mif-sleep` loaded (the module commit above, built against the running -kernel). Expect about 140 mA, then less. Stop: the palmtop doesn't come +charge, coarser than a coulomb counter, hence the long phases. Repeat, +attended, with `tegu-mif-sleep` loaded (the module commit above, built +against the running kernel): that is the configuration that once didn't +wake. Expect about 300 mA, then less. Stop: the palmtop doesn't come back on the cable within 5 minutes of the end (power key). Rollback: `rmmod tegu-mif-sleep` (the module changes nothing while awake: it sets the rate at suspend-prepare and puts the old one back at resume), or a reboot. +**S1 result (2026-10-29, `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, +device-tegu 0.2.0).** The baseline ran as written (cable out, screen off, +Wi-Fi kept, modem not started, two 30-minute `systemctl suspend` rounds +through `power-ab --suspend systemd`), then the pieces were pulled apart +with the cable in. + +- **Cable out: 311 mA awake with the screen off, 302 mA asleep** (phase A + 3434 samples of `current_now`; phase B 302.5 mAh of `charge_now` over + 3604 s, two rounds, both woken by the RTC through the PMIC, `success` 2). + Sleep saves nothing over the awake screen-off state. The 140 mA of + 2026-10-27 is the outlier: a cable-out A/B on 2026-10-28 + (`logs/tegu-morning-20261028/sleep-ab-20261028b.log`) already read 434 + and 445 mA asleep as-is and 374 and 389 mA with MIF at 421 MHz. +- **The CPUs do sleep.** A 60 s `systemctl suspend` with the cable in ran + with `Timekeeping suspended for 60.059 seconds` and each cluster's deep + state entered once in s2idle (`cpuidle/state1/s2idle/usage` +1 per CPU), + so no interrupt keeps the cores up. What stays on is everything below + them: MIF and the buses at full rate, and the always-on rails. Google's + kernel has a system idle state (SICD) for this; ours has none. +- **The radios cost nothing at idle** (cable in, buck off through + `CHG_CNFG_00` 0x00 under a dead-man restore, screen off, 45 s means of + `current_now`): baseline 351 mA, Bluetooth off 355, NFC driver unbound + 356, Wi-Fi link down 360. All within noise. +- **MIF at 421 MHz in sleep saves about 60-75 mA.** Cable in, buck off, + 240 s `systemctl suspend` sleeps measured by the gauge's coulomb counter + (`QH`, register 0x4d of the fuel gauge at 0x36 on bus 24; 2.5 mAh per + count, checked against 60 s of `current_now`): as-is 12 counts, 446 mA; + with `tegu-mif-sleep.ko` 10 counts, 371 mA (one count is 37 mA at this + length). This matches the 2026-10-28 figure (57 mA). The module loads, + unloads and wakes cleanly; the palmtop now loads it at boot from a hand + unit, `/etc/systemd/system/tegu-mif-sleep.service` + (`insmod /var/lib/omamobile-tegu/tegu-mif-sleep.ko`, the module built + from `adbca4c88a21` above against this release), until the policy is in + the kernel or the device package. Rollback: `systemctl disable --now + tegu-mif-sleep; rmmod tegu_mif_sleep` (nothing changes while awake), and + the module must be rebuilt for every kernel push. Cable-in figures sit about + 140 mA above cable-out ones (the USB link keeps the SoC busy). +- **Sleeps that never wake, three so far, and no single cause.** Not + woken by the RTC alarm, nor by the power key, and reset by hand with + Power + Volume Up: a direct `rtcwake -m freeze` of 10 min on 2026-10-28 + (MIF as it was, after two 421 MHz sleeps that woke); a direct freeze of + 240 s on the night of 2026-10-29 (NFC blocked, polling already stopped); + and on 2026-10-30 a `systemctl suspend` of 30 min, cable out, through + `power-ab --suspend systemd` with `tegu-mif-sleep` loaded (the A phase + ran at about 300 mA, the B freeze was logged, nothing after; the owner's + 65-minute timer ran out with the palmtop dark). Woke: 35 short systemd + cycles on 2026-10-27, two 30-minute and four 240 s systemd sleeps on + 2026-10-29 (one of the four with the module), two 10-minute direct + freezes with the module on 2026-10-28. So neither the entry method nor + the module alone explains it. Until it is understood: every sleep test + is attended, the cable-out run's sleep phase is kept to what the owner + can watch, `power-ab` still runs with `--suspend systemd` (the sleep + hooks run that way), and the hand unit that loaded `tegu-mif-sleep` at + boot is disabled (2026-10-30). Nothing in pstore for any of the three: a + held power key is a pin reset, and the console log doesn't survive it. + The cheap test ran the same morning: a cable-in 30-minute `systemctl + suspend` with the module loaded, the RTC alarm logged as armed before + (`alarm_IRQ: yes`, 1800 s ahead), woke on the alarm to the second + (`PM: Triggering wakeup from IRQ 56`, the PMIC's RTC; `suspend_stats` + success 1). The same afternoon the cable-out run was repeated with the + module loaded by hand (`power-ab --suspend systemd`, one round, the + owner away for an hour) and woke on its alarm: awake with the screen off + 273 mA (1715 samples), asleep 259.7 mA (130.0 mAh of `charge_now` over + 1802 s). Against the previous day's 302 mA asleep without the module + that is about 40 mA saved, in line with the cable-in coulomb-counter + figure given the gauge's coarseness. So neither the module, nor the + 30-minute systemd sleep, nor the cable being out reproduces the no-wake + on its own; the three failures' common factor is still open, and sleeps + stay attended. One more observation the same afternoon, cable in, module + still loaded from the drain run: during a forced 10-minute systemd sleep + the owner's tap and power-key press did not wake the palmtop; the kernel + came up once at about 112 s (`Timekeeping suspended for 112.557 seconds`) + and went straight back to s2idle until the RTC alarm woke it at 10 + minutes (IRQ 56). The power key woke s2idle on 10-27 without the module, + so the next cheap test is a sleep without the module and a power-key + press, then the same with the module: if the key wakes only without it, + the module is in the no-wake story after all (a key wake that doesn't + register would look exactly like an RTC alarm that doesn't). +- **Found the same afternoon: UFS failed to come back from an s2idle, and + that is what a "no-wake" looks like from outside.** The forced 10-minute + systemd sleep above (cable in, module loaded) did wake on its RTC alarm + at uptime 10801 s, but the UFS link did not come back: the console in + pstore shows `exynos-ufshc 13200000.ufs: link startup failed 1` and + `ufshcd_host_reset_and_restore: Host init failed 1` five times in a row, + then `ufshcd_wl_resume failed: 1`, `PM: failed to resume async: error 1`, + and from the first write after resume `I/O error, dev sda` with + `hostbyte=0x07`, `EXT4-fs … failed to convert unwritten extents … + potential data loss`, and the root filesystem went `emergency_ro`. The + palmtop answered SSH for a while from what was already in memory, but + nothing on disk could be read: `systemctl suspend` and `systemctl + reboot` did nothing, `coredumpctl` and `df` returned EIO, the power key + reached the kernel (its interrupt count rose) and the shell could not + light the screen. A sysrq `b` reset brought it back with a clean ext4 + journal recovery (`spm_lvl` was 5 throughout, `rpm_lvl` 3). So a + palmtop that "never wakes" and whose power key does nothing may have + woken with its storage dead, which the three no-wake records cannot + distinguish from a missed alarm: none of them had a console. UFS resume + was qualified on 32 of 32 cycles with the reset held in suspend (kernel + #83) and on the S1 sleeps; this is the first failure, 1 of about 50 + systemd-path resumes. Rule until understood: after every s2idle on the + 9a, `dmesg | grep -E "link startup failed|Host init failed|I/O error"` + before anything else, and reboot at once if it matches; unattended + sleep stays off. Next: the UFS resume path with the kmsg stream, and the + question whether the three dark no-wakes left ext4 recovery lines in + their next boot's journal (`journalctl -b -N -k | grep EXT4`). +- **2026-10-30 night, s2idle with the cable in, 20 cycles asked for, 6 + taken, 1 hang.** Attended RTC-woken 30-second cycles on the daily boot + (release `7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`, the + modem never loaded in that boot, NFC's sleep hook in place, `spm_lvl` 5, + `rpm_lvl` 3), each checked for `link startup failed`, `Host init failed`, + `I/O error` and `ufshcd_err_handler` before the next one, and for a + writable root. Cycles 1-5: all woke, all four counters zero, one suspend + entry and one exit each, root writable, the wake each time the RTC with + the power key and Wi-Fi's host-wake disarmed again on resume (`wake + disabled for irq 59`, `irq 73`). `/sys/power/suspend_stats` read + `success=5` with every failure counter zero. The sixth cycle of the same + boot did not come back, and this time the palmtop left the USB bus + entirely (no gadget, the laptop's interface gone), so it is not the dead- + storage shape of the 10-30 afternoon (which kept answering SSH from + memory): the SoC itself is hung or down, and nothing can be read until a + forced restart. Waiting on that to read the console from pstore. +- **What the forced restart left, and how the cycles slept (for the + rule).** After the sixth-cycle hang of 10-30 and the morning's forced + restart, `/sys/fs/pstore` held nothing from the hung boot: the kept + console (`console-1030-205427.txt`) has that boot's bootloader log and + then the next boot's, with no kernel lines from the hang, because printk + had suspended the consoles at the freeze (below). Every 30-second cycle, + that night and this morning, entered sleep the systemd way: `rtcwake -m + no -s 30` to arm the alarm, then `systemctl suspend`, so the sleep hooks + (NFC's poll stop, Wi-Fi's) ran each time; none was a direct write to + `/sys/power/state`. +- **2026-10-31 morning: ten of ten cycles clean, and the console now + survives the freeze.** The reason every earlier hang left no kernel + evidence is that printk suspends the consoles at the freeze ("Suspending + console(s) (use no_console_suspend to debug)"), so nothing reached + ramoops after that line. It does not need a boot argument: + `/sys/module/printk/parameters/console_suspend` is writable, and `echo N` + into it keeps the console alive through s2idle. With that set, ten + 30-second RTC-woken cycles on the daily boot all woke with the storage + counters, the ACPM timeout count and the watchdog count at zero, + `suspend_stats` reading `success=10 fail=0`, and the kernel log streamed + to the laptop for the whole run (10086 lines, + `logs/tegu-review-20261029/runners/13b-20261031-0807-kmsg.txt`, not + committed), with all ten entry and exit pairs in it and each wake showing + the power key and Wi-Fi host-wake disarmed again (irq 59 and irq 73). + So the next hang will leave its last words, which is the one thing the + 10-30 night could not give. +- **Read back from the afternoon's own console (2026-10-30 night, offline): + the failing suspend was the third of its boot, not a late one.** The + console holds nine suspend entries (387.7 s, 4746.9 s, 10798.6 s, then + 14328.9 s onwards once the filesystem was already read-only), and the + third one, at 10798.6 s, is the one whose resume failed at 10799.8 s. The + 25 seconds before it contain nothing but PAM and audit lines from an SSH + login: no ACPM timeout, no thermal error, no UFS warning. (An earlier + note of mine tied that failure to the ACPM timeouts; those are from a + different boot, the 18:31 console of the same day, and the link is + withdrawn. The ACPM slot leak found while reading that path is real and + is linux-omarchy-mobile#152, but it is a separate defect.) So the + afternoon failure was the third sleep of its boot at about 3 hours of + uptime, and tonight's hang the sixth of its boot at about 10 minutes: + neither "the Nth sleep" nor "a long boot" fits both, and what they share + is only that neither was the first sleep of its boot. +- **The failing resume compared with the two clean ones in the same + console (2026-10-30 night, offline).** Lined up on their suspend entry, + the three resumes of that boot differ in one step: + + | | clean (387.7 s) | clean (4746.9 s) | failed (10798.6 s) | + | --- | --- | --- | --- | + | `wl resume begins` | +0.754 | +0.741 | +0.717 | + | `dme-set attr-id 0x4021` | +0.803 | +0.800 | never | + | `Power mode changed to FAST series_B G_4 L_2` | +0.859 | +0.866 | never | + | `link startup failed 1` | - | - | +1.198, then +1.655, +2.143, +2.622, +3.058 | + | `reset_and_restore` | 0 | 0 | 1 | + + So the failure is not in the hibern8 exit or in the device's power mode: + it is link startup itself, which never got as far as the first DME set. + Each attempt took about 430-490 ms, the UIC command timeout, and five of + them in a row exhausted `ufshcd_host_reset_and_restore()`. In the clean + resumes the whole link came up in 50 to 90 ms with the DME set and the + power-mode change present. The wake-interrupt disarm of irq 73 (Wi-Fi's + host wake, on the 154e0000 controller) lands either side of the DME set + in the clean runs, so its ordering against the UFS resume is not the + difference. + + What that points at for the next run: the link-startup path on resume, + which at `spm_lvl` 5 is a full re-init, so the PHY power-on and the + release of the device reset line (`HCI_GPIO_OUT`, asserted in + `gs101_ufs_suspend()`) rather than anything in hibern8. Worth reading + next to the one-sample caveat: this is a single failure against two clean + resumes in that boot and five clean cycles tonight. +- **A hypothesis for that link startup, from comparing the driver with + Google's (offline).** Both drivers pulse the device reset in the + controller-enable notifier before link startup, with the same 5 us, so + that is not the difference. What our gs201 and zumapro descriptions carry + and Google's does not express the same way is idle clock gating: + `EXYNOS_UFS_OPT_CLKSTOP_PRE_CHANGE | EXYNOS_UFS_OPT_UNGATE_POST_CHANGE`, + and the driver's own comment says zumapro's CMU gates really stop the host + clocks, so the clock-stop registers can only be written with the gates + open. A resume at `spm_lvl` 5 is a full re-init: if the core's clock + gating lands anywhere inside it, the DME commands that link startup sends + would time out exactly as the failing console shows, with no first DME + set and no power-mode change. That is a hypothesis, not a finding: the + ordering in `exynos_ufs_setup_clocks()` is meant to prevent it. + The test, as a runbook step (attended, cable in, modem never loaded in + the boot, console kept through the freeze; risk: low): + + ```sh + # S3. UFS idle clock gating off for a run of cycles + tools/phone-ssh 'echo N > /sys/module/printk/parameters/console_suspend' + tools/phone-ssh 'u=/sys/devices/platform/soc/13200000.ufs; cat $u/clkgate_enable; echo 0 > $u/clkgate_enable; cat $u/clkgate_enable' + # Expect: 1 then 0 + # ten cycles, each: rtcwake -m no -s 30; systemctl suspend; after the wake: + tools/phone-ssh 'dmesg | grep -cE "link startup failed|Host init failed|I/O error|ufshcd_err_handler"; cat /sys/power/suspend_stats/success' + # Expect: 0, and success counting up by one per cycle + # Stop: any count above 0, or no SSH 120 s after the alarm (forced restart, read pstore and the kept console) + # Rollback: echo 1 > clkgate_enable, or a reboot (the setting does not persist) + ``` + + One failure in about 50 resumes means a clean run of ten proves nothing + by itself, so run it both ways and count. + + **S3 result, 2026-10-31 (`7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`):** + clock gating off (`clkgate_enable` 0), console kept, modem never loaded + that boot, ten 30-second RTC cycles: ten of ten woke, `suspend_stats` + success 10 and fail 0, no UFS error-handler, link-startup or I/O lines, + no ACPM timeouts. With gating on, 10-31's earlier run was also ten of ten, + so this does not yet separate the two; the count both ways goes on until + one side fails. +- **What the five clean cycles rule out, and what they don't.** Five in a + row with the storage counters at zero says the UFS resume path is not + broken per se; the afternoon failure and this hang are both the sixth or + later sleep of a long-running boot (the afternoon one at uptime 10801 s, + this one after five sleeps), so the first guess was the number of sleeps + in a boot; the console read below retires that guess, since the afternoon + failure was only the third sleep of its boot. The + three dark no-wakes left no ext4 recovery line in their next boot's + journal (checked tonight across 25 boots: no boot recovered a journal), + so they were not the dead-storage shape either, which fits a hang like + tonight's. +- A later note on the method: `power-ab`'s CSV columns are + `voltage_uv,current_ua,current_avg_ua,charge_counter_uah,charge_now_uah`; + the gauge's `current_avg` is a long filter and says little about a + 30-minute window, so read `charge_now` (or `QH`) across the sleep. + +**S1 method, cable in (the steps the measurements above used; S2 reuses +them).** Each goes into the runbook before it runs; the charger write ran +tonight before it was written here, which is not the order the plan asks +for. + +```sh +# 1. Buck off: the palmtop runs on its battery with USB data up (risk low; charger in, battery above 30 %). +# First the dead-man that puts the buck back. For awake measurements a monotonic timer is enough: +tools/phone-ssh 'systemd-run --unit=x-buck-restore --on-active=600 /usr/bin/i2cset -f -y 24 0x69 0xbc 0x05' +# For sleeps, monotonic timers don't run in suspend, so use the wall clock, and have the script restore on EXIT too: +tools/phone-ssh 'systemd-run --unit=x-buck-cal --on-calendar="$(date -d "+25 min" "+%Y-%m-%d %H:%M:%S")" /usr/bin/i2cset -f -y 24 0x69 0xbc 0x05' +tools/phone-ssh 'i2cset -f -y 24 0x69 0xbc 0x00; sleep 3; i2cget -f -y 24 0x69 0xbc; cat /sys/class/power_supply/max77779-battery/current_now' +# Expect: 0x00, current_now negative (discharging, about -350 mA screen off). Stop: current_now stays positive +# (the buck is still on: don't measure), or the dead-man refuses to arm. Rollback: the write of 0x05 below. +# 2. Measure. Awake: 45 s means of current_now. Asleep: the gauge's coulomb counter across the sleep, +tools/phone-ssh 'i2cget -f -y 24 0x36 0x4d w' # QH, 2.5 mAh per count; mA = counts * 2.5 * 3600 / seconds +# (checked 2026-10-29: 3 counts in 60 s at a 357 mA mean of current_now; one count is 37 mA over 240 s). +# The sleep itself: rtcwake -m no -s 240; systemctl suspend. Never rtcwake -m freeze (the result above). +# 3. Buck back on, then the read-back: +tools/phone-ssh 'i2cset -f -y 24 0x69 0xbc 0x05; systemctl stop x-buck-restore.timer x-buck-cal.timer 2>/dev/null; sleep 3; i2cget -f -y 24 0x69 0xbc; cat /sys/class/power_supply/max77779-battery/status' +# Expect: 0x05 and current_now positive again (status reads Unknown on this driver). Stop: 0x05 doesn't read +# back: write it again; if it still doesn't, replug the charger (the chip's power-on default is 0x05). +``` + +Next: S2 (the four rails), attended. The cable-out number with the module +is in (260 mA, S1 result); any further run with the module is attended too. + **S2. Rails (risk low).** As S1 with the three GNSS rails and `udfps-3v3` not always-on: the running DTB with `regulator-always-on` removed from LDO9S-11S and LDO15S, nothing else (the S2 commit above). Not in or around @@ -207,5 +515,28 @@ step 2 in reverse). ## Not known yet +- Why a boot's sixth or later s2idle hangs or loses its storage while the + first five are clean (2026-10-30 night, above). Next: the cycles again + from a fresh boot with the kmsg stream to the laptop, counting sleeps, + and the console from the forced restart of tonight's hang. +- Which PMIC event ends an early RTC cycle, and now how to read it. The + record says it has never been read; the driver names the register. In + `rtc-s5m.c`, `s5m_check_pending_alarm_interrupt()` reads + `S2MPG14_PMIC_STATUS2` on zumapro (`S2MPG12_PMIC_STATUS2` on gs201) and + takes the alarm from `RTCA0E`, bit 2 (`RTCA1E`, bit 1, is the second + alarm). So after a cycle that woke early, that register says whether the + alarm fired at all, and its other bits name what else the PMIC latched. + Reading PMIC registers from userspace is allowed (the rule that forbids + it is about the PMU), through that chip's regmap in debugfs, and a single + register rather than a whole dump (lesson from the amplifier regmap). Is + `STATUS2` cleared on read, so that a userspace read could take the alarm + away from the RTC driver? Not by the driver's own account: in the + S2MPG14 regmap only `INT1` to `INT5` are marked precious ("clear on + read"), and `STATUS2` is listed as volatile ("RTC alarm flag") and not + precious, so it is a level flag that a read does not change, and regmap's + debugfs refuses precious registers anyway. + kernel #149 is the same readback for gs101's S2MPG10, which this tree + gets wrong today; zumapro's and gs201's cases are already right, so that + PR doesn't change what the 9a or the 7 Pro report. - What the GNSS and fingerprint rails cost in sleep (S2). - What MIF in sleep saves with the cable out (S1).