diff --git a/device/husky/MODEM-PLAN.md b/device/husky/MODEM-PLAN.md new file mode 100644 index 000000000..309283d4a --- /dev/null +++ b/device/husky/MODEM-PLAN.md @@ -0,0 +1,447 @@ + +# Pixel 8 Pro modem plan (husky, Samsung S5300) + +Status (2026-11-08): on hold. Stages S1 to S5e have been run; none of them +hung, oopsed or raised a UFS error (S5c stopped on its own current abort, +see below). No modem step and no power-line step has been run since S5e +ended at 2026-11-07 21:21 UTC (23:21 here), and I take none on the 8 Pro +until derekross answers the question on omarchy-mobile#472 +(https://github.com/derekross/omarchy-mobile/pull/472#issuecomment-6711065625; +see "Current state: on hold" below). + +I asked that question on 2026-11-07 at 18:04 UTC and wrote that I would not +run the first hardware step until I heard back. I then ran S3 (19:14:50 UTC) +and after it S4, S5a, S5b, S5c, S5d and S5e, all before any answer. That was +my mistake: I should have waited. S1 and S2 (18:47 and 18:52 UTC) came after +the question too, but they only read: S1 reads the PMU register (the module +probes with `allow_hw=0`) and S2 reads the eleven modem lines as the +bootloader left them, with no direction or level change. + +Times: this file gives Athens time (EET, UTC+2) unless a time is marked UTC. +Subtract 2 h for UTC. +This file is the record of S1 to S5e: what each step does, its gates, its +stop conditions, the dated result with the kernel release, and what the +result does not prove. + +[V] = read in source, stock DT or my captures on the phone. [I] = inferred; +each [I] names the step that would settle it. + +Stock references are Google's tree `kernel/google-modules/radio/samsung/s5300`, +branch `android-gs-shusky-6.1-android16` (the stock CPIF, `modem_ctrl_s5100.c`, +`s5300` node). The line numbers below are the ones derekross checked in that +tree on omarchy-mobile#514; my own copy was the `soc-gs` tree, where the same +functions sit at different lines (`gpio_power_off_cp()` at 874, for example). +The PCIe side is `pcie-gs201-cp` from W4HO's stack in +linux-omarchy-mobile#187. + +## Test kernels + +All steps ran from slot B on a test kernel built from my husky e1 branch +plus the #187 stack and the husky device tree, with the modem nodes +disabled unless the step enables them. + +| Set | `uname -r` | Used for | +| --- | --- | --- | +| images-plain, images-s1, images-s2 | `7.3.0-rc6-omamobile-push1-gc5b6ae8f4dc2` | boot 1 (plain), S1, S2, S3 (images-s1 again) | +| images-s4 | `7.3.0-rc6-omamobile-push1-g6a203e4b8a67` | S4, S5a to S5e | + +Between stages the phone went back to the normal NFC set (release +`...ge98a7`), so a test boot is never the running system for long. +Where a log did not print `uname -r` itself, the table says which image set +was flashed; the lines below say so for each stage. + +## Safety (all stages) + +Gates, all of which must hold before any stage: + +- First of all: `tools/nv-backup --check` matches the 2026-11-01 backup for + `efs`, `efs_backup`, `modem_userdata`, `persist` and `modem_a`/`modem_b` + (read-only; `devinfo` is expected to differ). I did not run this before + S1 to S5e. I ran it afterwards, on 2026-11-08, and every partition matched + (see "Current state"). From now on it is the first gate of every stage. +- I am at the phone with the USB cable in. The charger is in too, except in + S5d and S5e, which are battery-only on purpose: a current reading cannot be + taken with a charger feeding the rail. The battery was at 92 % and each run + lasted a few minutes. On this phone 92 % is "full": the charger chip + finishes at 4350 mV and the gauge stays at 92 %, even after 12 hours plugged + in (`BATTERY-NOTES.md` section 10a, #452). +- Nothing armed or fed a watchdog during S3 to S5. Every step was attended, + with the buttons as the way back. On the 8 Pro a hung kernel needs Power + + Volume Up held for 15 to 30 s; the power button alone is not enough. +- Battery 50 % or more; battery temperature under 40 C at the start; SoC at + or under 62 C (idle SoC is about 53 C). A `THERMAL-PAUSE` file blocks the + step. +- A current backup of the images and the config is on the desktop + (`backup-pre-s3-20261107`, five slot-B images as flashed, `/etc` and user + config, SHA256). +- Retry count read in fastboot: 3 after `set_active b`. Every boot of a + flashed slot B spends a retry (devinfo byte 0x35 went 06 to 04 at the + first flash), and at 0 GrapheneOS wipes userdata, so I count boots and + never run more than two boots of one flash. +- No process holds `/dev/umts_boot0`; no cbd, rfsd or ModemManager runs; no + suspend. +- Each hardware step (S3, S5a, S5b, S5c, S5d, S5e) needs my explicit go in + that turn. + +Never, in any stage: cbd, rfsd, any firmware or ROM image, +`IOCTL_POWER_ON` or the boot ioctls (they write CP DRAM and there is no way +back), writes to `umts_boot0`, `allow_poweroff=1`, the `cp_on`, `cp_off` +and `atu` debugfs files, the SIM, stock slot A (its first boot can wipe +userdata), and the `efs`, `efs_backup`, `modem_userdata`, `persist`, +`modem_a` and `modem_b` partitions (read-only checks only). + +General stop rules: a hang, USB loss, an oops or an rcu stall; any UFS +counter going up or a `ufshcd_err_handler started` line that does not +recover in seconds; a pin or line reading different from what the previous +log said; battery temperature over 45 C. Never reboot with the modem lines +high: `gpio_off` first, reboot only after an all-0 read. A phone that ends +with a dead screen is not woken or rebooted; I run the dead-screen kit +first. The kit is a read-only script for a phone whose screen is off while ssh +still answers (touch and power key dead): it records while I touch and press +power in a 12 s window, and only then do I wake the screen +(`omamobile-remote wake`) and read the uptime, the DRM state and +`hyprctl monitors -j`, and ask whether the panel is lit; the case is +linux-omarchy-mobile#215. + +## S1: PCIe controller and PHY loaded, no hardware access (2026-11-07 20:47) + +What it does: boots the test kernel with `pcie_0` and its PHY enabled in the +device tree and runs `modprobe pcie-gs201-cp` with `allow_hw=0`. The module +probes and registers; it does not touch the link. + +Gates: the general ones; boot 1 of the flash checked first (plain boot up, +Wi-Fi and NFC working, no modem module loaded, 7 fixed regulators, the modem +pins at their baseline: gph1-2 an output at 0, gph1-1 and gph1-7 inputs at +0). + +Stop: the general rules; any modem pin changing. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-gc5b6ae8f4dc2`: PASS. Probe +rc 0, PMU 0x3ec4 = 0xc0 (the same as on the 9a), PHY 0/0, link 0, IRQ +counts 0, pins unchanged. + +Does not prove: that the PHY or the link work (nothing was read from them); +anything about the modem. + +## S2: modem node enabled, driver not loaded (2026-11-07 20:52) + +What it does: the same kernel with the `modem` node enabled in the device +tree. No cpif module loaded. Reads the seven AP2CP and four CP2AP lines. + +Gates and stop: as S1. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-gc5b6ae8f4dc2` (image set +images-s2; I did not copy `uname -r` into the S2 log, the set shares the +S1 build): PASS. All 7 AP2CP and 4 CP2AP lines read 0, pins equal baseline, +PMU 0xc0, clean shutdown. After it the phone went back to the NFC set. + +Does not prove: anything beyond "the node enabled changes nothing on the +pins before a driver loads". + +## S3: one PCIe link attempt with the modem off (2026-11-07 21:15, my go) + +What it does: `allow_hw=1`, PHY trace every 100 ms, exactly one +`link_up 1` try. The stock module tries three times; for this step I +rebuilt the module with `CP_LINK_TRIES` 3 to 1 (same vermagic, test only, +not committed; the original module stayed on the phone as +`/root/pcie-gs201-cp.ko.tries3`). The modem is off, so no endpoint is +expected. + +Gates: the general ones, plus the backup above, plus a review of the S1/S2 +evidence. SoC had peaked at 62 C during backups and builds, so the step +waited for every zone at 62 C or less. + +Stop: a hang; an oops; no progress in the PHY trace. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-gc5b6ae8f4dc2` (image set +images-s1, flashed again for this step; the kernel is in the S3 dmesg log): +no hang. Trace: PMU bit 0 set (SMC), first PMA read, PLL on, PMA and PCS +tables, external PLL lock 1, PLL lock 1, CDR lock 1, offset calibration +done 1, PMU bit 10 set, DBI ID 0xa5a5144d; then `no L0, LTSSM 0x0` and +`link_up 1: -110` (no endpoint). After: PMU 0x3ec4 = 0x4c1, PHY 1/0, link +0, `link_down` rc 0, 53 C, no oops, Wi-Fi up. The PCIe "active" pinctrl +state changed the function of gph0-0 (PERST, now output 0), gph0-1 +(CLKREQ), gpa0-1 (output 0 to input), gpa0-2 (input to output 0), gpa6-5 +and gpa7-0; all DAT 0; gph1-1, gph1-2 and gph1-7 untouched. +It also answered one open question: HSI1 and its PHY/controller are +reachable with only the PMU 0x3ec4 bit 0 SMC before the first access (stock +source does the same). + +Does not prove: that the PCIe link works. The AP side starts, the link +itself has never been tested, because the modem was off. Not settled: who +powers the modem, what gpa0-1 drives, the S2MPU windows for CP memory. + +## S4: cpif loaded, modem stays OFFLINE (2026-11-07 22:10) + +What it does: flashes the S4 set (cpif enabled, overlay `modem-s4-cpif`), +then `modprobe pcie-gs201-cp` (`allow_hw=0`), `modprobe shm_ipc`, +`modprobe cpif`. cpif probe sets the seven AP2CP lines as outputs at 0. +No power-on, no link, no firmware. + +Gates: the general ones, plus before the load: gph1-2 an output at 0, the +six other lines inputs at DAT 0 with PUD 0x1 (pull-down); UFS stats all 0 +and no `ufshcd_err_handler started`; no modem module, no `umts` node; 56 C. + +Stop: the general rules; any `poweron`, `link up` or phone_state line in +dmesg (the two `link up` lines at boot are the Wi-Fi's HSI2 link). + +Result [V], kernel `7.3.0-rc6-omamobile-push1-g6a203e4b8a67`: PASS. All +seven AP2CP lines are outputs at 0 (CON 0x1), the CP2AP inputs unchanged, +`modem_state` OFFLINE, PMU 0xc0, PHY 0/0, link 0, UFS counters 0 before and +60 s after, no oops, Wi-Fi up, 57 C. `shm_ipc` mapped the three reserved +regions (`cp-rmem@ea400000`, `cp-msi@f6200000`, `cp-rmem1@e8000000`) with +no fault. The probe log matches stock's values: `mif_off_during_volte:1`, +`num_iodevs:54`, `link_attrs:0x000037c8`, `PCIe Channel Number:0`, +`s5300 is created`. `cpif_probe: Failed to register logbuffer!` appears; +it is debug-log registration only and I did not look into it. The reboot +to bootloader ran cpif's shutdown path with the modem OFFLINE. + +Does not prove: who powers the modem or in what order; any way to power it +down (stock cpif has none once the modem is on); anything about firmware or +the SIM. + +## S5: power lines, in five parts + +The hook (test only, not for merge): `modem_ctrl_s5100.c` gets a debugfs +directory `cpif_test/`, created only when cpif is loaded with +`cpif_test_gpio=1`. Files: `lines` (read, the 11 line levels and +`phone_state`), `gpio_off` and `gpio_on` (any write fires them; they call +only the stock `gpio_power_off_cp` and `gpio_power_offon_cp`), and from S5c a +`pda_active` file. `gpio_on` is refused with -EBUSY unless six AP2CP lines +read 0: `cp_pwr`, `nreset`, `wakeup`, `dump_noti`, `cp_wrst_n` and +`pm_wrst_n`. `ap2cp-pda-active` is left out of that check because stock +`power_on_cp` sets it before the power-on, and S5e's E3 needs it high. No +state change, no CP memory write (`clear_boot_stage` and `init_ctrl_msg` are +skipped on purpose), no PCIe, no PMU, no ioctl. cpif has no module_exit, so +it cannot be unloaded. + +Builds: S5a and S5b ran an earlier build of the same code without the +`pda_active` file, the module kept on the phone as `/root/cpif.ko.s5a` +(sha256 `4ee11e7d01764522c5eebca5f6378439d2fc45db4decf17e1e883add0855d972`). +S5c to S5e ran the build that has it (sha256 +`f1e3173f55a07cb70685d611abfa05b004266dbfb23ed1aa0718ed57de7bbe11`). + +Edges [V] (the code is in my `soc-gs` copy; the line numbers are derekross's +from Google's s5300 tree: stock `modem_ctrl_s5100.c`, `gpio_power_off_cp()` +at 906-918 and `gpio_power_offon_cp()` at 921-933, non-`CP_WRESET_WA` branch, +confirmed compiled; `CP_WRESET_WA`, `CP_LCD_NOTIFIER` and +`LINK_DEVICE_PCIE_GPIO_WA` are not set in this build): + +- `gpio_off` from the all-0 state: one 10 ms pulse of `ap2cp-wakeup`; + `nreset`, `cp_wrst`, `cp_pwr` and `pm_wrst` are rewritten to 0 (no + change). +- `gpio_on` from all-0: that pulse, then `pm_wrst` 1, `cp_pwr` 1, `nreset` + 1, `cp_wrst` 1, 10 ms apart, about 130 ms in all. +- `gpio_off` with the lines high: wakeup pulse, `nreset` 0, `cp_wrst` 0, + `cp_pwr` 0 (30 ms), `pm_wrst` 0 (50 ms). + +Setup for each S5 stage: push the new `cpif.ko` (the S4 original kept as +`/root/cpif.ko.s4-original`), write `/etc/modprobe.d/modem-test.conf` (the +blacklist lines), flash images-s4, count 3, stream `dmesg -w` to the desktop, +repeat the S4 pre-checks, then `modprobe pcie-gs201-cp`, `shm_ipc`, +`cpif cpif_test_gpio=1`. + +Extra stop rules for S5b to S5e: `gpio_on` returning -EBUSY or -EINVAL (do +not retry, read `lines`, stop); any `IOCTL_`, `poweron`, `link up` or +`SET GPIO ... not valid` line; the modem lines on for more than 60 s in one +cycle; battery down more than 3 % in the stage; if a CP2AP line stays high +after `gpio_off`: do not write `gpio_off` again, do not write +`pda_active` = 0, do not reboot, read `lines` every 10 s for 2 minutes and +stop. + +### S5-0: read only (2026-11-07 22:25) + +`cat cpif_test/lines`: all 11 lines read 0, `phone_state` 0. No write. +Kernel `7.3.0-rc6-omamobile-push1-g6a203e4b8a67` (`modem-s5-pre.txt`; this +read did not print `uname -r` again). That checks the read path and the +module parameter. It does not show that a later power-on is safe. + +### S5a: gpio_off from the all-0 state (2026-11-07 22:25:50, my go) + +This is the hook run (one write to `gpio_off` from the all-0 state). The +earlier note that S5a was NO-GO meant the pre-hook plan: cpif has no +software power-off, and `IOCTL_POWER_ON` writes CP DRAM. That plan was not +run. This result is only the hook's `gpio_off`. + +What it does: one write to `gpio_off` with everything at 0, to see whether the +way down runs from the all-0 state and leaves the lines at 0. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-g6a203e4b8a67`: PASS. The +log shows the 10 ms wakeup pulse and `nreset`, `cp_wrst`, `cp_pwr` and +`pm_wrst` rewritten to 0 as duplicates; "after" all 0; 60 s later all 0, +OFFLINE, UFS counters 0, no error handler start, no oops, Wi-Fi up, 57 C, +battery 92 %. + +Does not prove: that `gpio_off` is safe with the modem on (that is only +shown in S5b). + +### S5b: first power-on of the lines (2026-11-07 22:34:12, separate go, charger in) + +What it does: `/root/s5b.sh` on the phone: one `gpio_on`, one sample per +second of `lines` for 55 s, then `gpio_off`, then samples. `pda_active` +stays at 0 (the hook cannot set it yet). + +Stop: the general rules and the S5 rules; `gpio_off` at 55 s whatever +happened. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-g6a203e4b8a67` (S4 image set; +the S5b log itself does not print `uname -r`): the edges came in stock +order, 10 ms apart. For the 55 s the four AP2CP power lines read 1 and all +four CP2AP lines (`ps_hold`, `wakeup`, `cp_active`, `cp_wrst`) stayed 0; +`phone_state` OFFLINE; UFS 0 before, during and after; battery 92 %, +battery 35.8 to 36.1 C; no oops, no hang. After `gpio_off` all 11 lines 0, +57 C, Wi-Fi up. (My sleeps were shorter than the labels in the script +output; the tail covered about 20 s, and a check at 22:37 read all 0.) + +Does not prove: that the modem has no power. Stock `power_on_cp` sets +`ap2cp-pda-active` to 1 and `dump-noti` to 0 right before the power-on and +clears the shared-memory control blocks (stock `modem_ctrl_s5100.c`: +`clear_boot_stage()` called at 1000, and the `ap2cp-pda-active`/`dump-noti` +pair and the two `init_ctrl_msg()` calls in `power_on_cp()` at 1022-1027); +S5b did neither. Current was not measured. + +### S5c: S5b again with pda_active = 1 and current sampling (2026-11-07 22:44, my go) + +What it does: `/root/s5c.sh` (hook with the `pda_active` file): 30 s +baseline of lines, UFS, battery `current_now`, `current_avg` and voltage; +`pda_active` = 1; one `gpio_on`; 1 s samples; `gpio_off`; `pda_active` = 0 +only if all four CP2AP lines read 0. Built-in aborts to `gpio_off`: any UFS +counter or error handler start, battery over 45 C, `current_now` more than +300 mA below the baseline. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-g6a203e4b8a67`: ended by its +own abort after 24 s (one `current_now` sample at -303 mA against a 117 mA +baseline mean); `gpio_off`, `pda_active` = 0. All four CP2AP lines read 0 +in every sample; UFS 0 throughout; no oops; clean end state. A no-write +control run with the same music playing and the charger in showed the same +kind of slide (`current_avg` from +170 mA to about 0, one -377 mA sample), +so the current figures of S5b and S5c are inconclusive. + +Does not prove: anything about the modem's current draw. The charger +(holding 92 %) can feed the rail, and music was playing. From here on the +abort rule uses a median of 5 or more samples and the current runs are +battery-only. + +### S5d: battery-only current around the power-on (2026-11-07 22:58:17, my go) + +What it does: `/root/s5d.sh`, USB cable out, music off, screen off, ssh +over Wi-Fi after an identity check (model and exact test kernel). Phase A +150 s with no writes; phase B `pda_active` = 1 then one `gpio_on` +(23:00:51), 60 s, median-of-5 abort (UFS error, battery over 45 C, or a +5-sample median more than 300 mA below the baseline median); `gpio_off`, +`pda_active` = 0 if the CP2AP lines are 0; phase C 120 s no writes; phase D +120 s no-write control. Battery 92 % at 38.1 C, SoC 59 C. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-g6a203e4b8a67` (S4 image set; +the identity check before the run read it, but the S5d log itself does not +print `uname -r`): ran the full 60 s (no abort). Median `current_now` per phase: A -550.6 mA, B -615.9 mA, +C -556.3 mA, D -554.7 mA (negative = discharge). The three no-write phases +agree within about 10 mA; the power-on phase is about 60 to 65 mA deeper (62 against the mean of A, C +and D), with a +sharp start at the `gpio_on` write and a sharp return after `gpio_off`. All +four CP2AP lines 0 in every sample; UFS 0; battery 38.1 to 37.1 C. + +Does not prove: that the load is the modem. `pda_active` = 1 was written +immediately before `gpio_on` (back-to-back writes in the script, no timing +recorded), so the two cannot be split; it is one run; +the CP2AP lines never moved. `s5d.sh` has no signal trap, so a killed +script would not have switched the lines off by itself. + +### S5e: pda_active separated from gpio_on (2026-11-07 23:12:35, battery only) + +What it does: `/root/s5e.sh` (v3, with INT, TERM and HUP trapped into a +safe off, started with `nohup setsid`), USB out, screen off. Phases: A +baseline 90 s | E1 `pda_active` = 1 alone 30 s | B base 60 s | E2 `gpio_on` +with `pda_active` low 60 s | C base | E3 `pda_active` = 1 then `gpio_on` +60 s | D base | E1b replicate of E1 30 s | E base. The script had a +simulated four-case test before the run. + +Result [V], kernel `7.3.0-rc6-omamobile-push1-g6a203e4b8a67` (S4 image +set; the log does not print `uname -r`): no phase hit a stop; UFS 0 and all +four CP2AP lines 0 in every sample; clean end state. Median `current_now` (as printed by the script): +A -556.6 mA, E1 -541.3, B -561.3, E2 -607.2, C -550.9, E3 -611.6, D -560.6, +E1b -546.9, E -548.1. `pda_active` alone does not change the current (E1 +is about 18 mA less discharge than the mean of A and B and E1b about 8 mA +less than the mean of D and E: noise). `gpio_on` draws about 51 mA extra with `pda_active` low (E2 against +the mean of B and C) and about 56 mA with it high (E3 against C and D); S5d +measured about 60 to 65 mA. The step starts one sample after each `gpio_on` write +and ends one sample after `gpio_off`, all three times. Medians only: the +screen woke during two baseline phases (about 9 s in B, about 11 s in D right +after the E3 `gpio_off`; S5d had the same shape once in C), which makes the +means unreliable but sits against the effect, not for it. + +Does not prove: that the load is the S5300. It could be another load on the +same rail, a power stage or level shifters with no modem core behind them, +or the ROM idling. The CP ROM gave no sign of life on any CP2AP line. +Two battery-only runs, three power-on phases, one phone and one gauge. + +## Current state: on hold + +- S3, S4, S5a, S5b, S5c, S5d and S5e ran after my question on + omarchy-mobile#472 (2026-11-07 18:04 UTC) and before any answer to it. + So the hold now covers S6 and any repeat, but it came too late for S3 to + S5e, which should have waited as well. +- No further modem step and no power-line step on the 8 Pro until derekross + answers the question on omarchy-mobile#472 + (https://github.com/derekross/omarchy-mobile/pull/472#issuecomment-6711065625); + his instruction to wait is on linux-omarchy-mobile#187. +- The hook is on the branch `husky-modem-cpif-test-hook` of + Somnius/linux-omarchy-mobile (commit 058a439b3). It is test only and not + for merge. +- `tools/nv-backup --check` on 2026-11-08: `efs`, `efs_backup`, + `modem_userdata`, `persist`, `modem_a`, `modem_b`, `trusty_persist` and + `trusty_userdata` are SAME as the 2026-11-01 10:01 backup. `devinfo` is + different, as expected (the retry bit and boot counts change with every + flash). +- Leftovers on the phone (checked 2026-11-08 at 21:40 local): `/etc/modprobe.d/` + has no `modem-test.conf`; the folder holds only `hid_apple.conf` and + `omamobile-aoc-blacklist.conf`, neither from the modem tests (the AoC one + is dated 2026-11-05 and does not shadow a packaged file). The test + `cpif.ko` is still inside the two test module trees (`...gc5b6ae8f4dc2` + and `...g6a203e4b8a67`) and as `/root/cpif.ko.s5a` and + `/root/cpif.ko.s4-original`; the normal NFC set's tree has none, so a + normal boot loads none of it. +- What ran is in this folder: the overlays `overlays/modem-s1-link.dtso` + (`pcie_0` and `pcie_0_phy` on), `overlays/modem-s2-lines.dtso` (S1 plus the + `modem` child of `pcie_0`) and `overlays/modem-s4-cpif.dtso` (the controller + on, its `modem` child off, and `/cp-shmem` and `/cpif` on), and the scripts + `bringup/s5b.sh`, `s5c.sh`, `s5c-control.sh`, `s5d.sh` and `s5e.sh`, as they + ran (two comment lines were added at the top of each: an SPDX line and a note). The headers of the overlays now point at this file; nothing else in them changed. `bringup/s5e.sh` is the version the S5e result + above describes, with INT, TERM and HUP trapped into a safe off (its own + header still says v2). The S3 module change was one line: `CP_LINK_TRIES` from 3 + to 1 in `pcie-gs201-cp`, test only, not committed. +- The phone is on the normal NFC image set. The first revert boot on + 2026-11-07 had no drivers because a clean-up timer had deleted the + module folder; I fixed it by hand between 23:26 and 23:35 and checked the module + tree before every revert since. +- Not run, and not to be run before the answer: S6 (the same power-on plus + one `link_up` try with the modem powered), a PMIC power-meter reading of + the modem channel, repeats of the S5 power-ons for more statistics. +- When S6 comes, each step gets an Expect line, a rollback and a risk level + as well as its stop rules, and the NV check runs first. + +## Unknowns + +- Whether the 50 to 65 mA is the modem [I]. A control that would split it: + not available without a way to see the CP side (S6 or the power meter). +- Which rail the lines switch. The stock husky DT has no regulator or + consumer named cp, modem, rfic, rf, lte, 5g, sub6, vdd_cp or qlink [V]; + `cp_pwr_on` and `pm_wrst_n` are plain pinctrl there, so the rail is + unknown. The only modem-named items are PMIC power-meter sense channels + (`VSYS_PWR_MODEM`, `VSYS_PWR_RFFE`, `VSYS_PWR_MMWAVE`), which suggests the + modem runs from VSYS [I, from the DT only]. The PCIe0 rails are S2MPG14 + LDO16M and LDO18M, which our driver does not cover. +- Whether the CP ROM waits for the shared-memory control blocks or for the + PCIe link before any CP2AP line moves [I]. Stock `power_on_cp` writes + `clear_boot_stage` and `init_ctrl_msg` before the lines; the hook skips + that on purpose. `cp2ap_cp_wrst_n` (gpa0-1) is high while the CP is alive + in stock logic and stayed 0 here; whether it rises before PCIe training + is unknown. Source reading, then S6, would settle it. +- What the bootloader does with the modem lines on a forced reboot or a + hang. Nothing in my notes covers it. A hung kernel needs Power + Volume Up + held for 15 to 30 s, and the debugfs hook exists only while the test + module is loaded. +- Whether a power-off edge triggers the UFS error pass on husky (it did on + cheetah). S5b, S5c, S5d and S5e saw none. +- The husky modem image and partition mapping, the BAR and doorbell layout, + and who sets up the S2MPU windows for CP memory. diff --git a/device/husky/bringup/s5b.sh b/device/husky/bringup/s5b.sh new file mode 100755 index 000000000..25bc84de6 --- /dev/null +++ b/device/husky/bringup/s5b.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes. +L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5b.log +: > $O +snap() { echo "$(date +%T.%N | cut -c1-12) $1 $(awk '{printf "%s=%s ",$1,$2}' $L/lines) ufs=$(grep -vc ': 0$' $U) errh=$(dmesg | grep -c 'ufshcd_err_handler started') bat=$(cat /sys/class/power_supply/*battery*/capacity)% bt=$(cat /sys/class/power_supply/*battery*/temp)" >> $O; } +snap pre +echo 1 > $L/gpio_on; echo "gpio_on rc=$?" >> $O +i=0 +while [ $i -lt 55 ]; do + sleep 1; i=$((i+1)); snap "on+$i" + if [ "$(grep -vc ': 0$' $U)" != 0 ]; then echo "STOP-UFS-COUNTER" >> $O; break; fi +done +echo 1 > $L/gpio_off; echo "gpio_off rc=$?" >> $O +for t in 1 5 10 30 60; do + sleep $([ $t = 1 ] && echo 1 || echo 5); snap "off+$t" +done +echo DONE >> $O diff --git a/device/husky/bringup/s5c-control.sh b/device/husky/bringup/s5c-control.sh new file mode 100755 index 000000000..272b973fc --- /dev/null +++ b/device/husky/bringup/s5c-control.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes. +# CONTROL for S5c: the same 30 s + 55 s + 30 s sampling, NO writes to any modem line. Log: /root/s5c-control.log +L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5c-control.log +B=/sys/class/power_supply/max170xx_battery +: > $O +snap() { echo "$(date +%T.%N | cut -c1-12) $1 cur=$(cat $B/current_now) avg=$(cat $B/current_avg) v=$(cat $B/voltage_now) bat=$(cat $B/capacity)% bt=$(cat $B/temp) ufs=$(grep -vc ': 0$' $U) lines=$(awk '{s+=$2} END {print s+0}' $L/lines)" >> $O; } +i=0; while [ $i -lt 30 ]; do snap "base-$i"; sleep 1; i=$((i+1)); done +snap "pda1(none)" +i=0; while [ $i -lt 55 ]; do sleep 1; i=$((i+1)); snap "on+$i(none)"; done +sleep 2; snap "off+2(none)" +for t in 3 8 13 18 23 28; do sleep 5; snap "post+$t(none)"; done +echo DONE >> $O diff --git a/device/husky/bringup/s5c.sh b/device/husky/bringup/s5c.sh new file mode 100755 index 000000000..fd15e7eee --- /dev/null +++ b/device/husky/bringup/s5c.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes. +# S5c (TEST ONLY): pda_active=1, then gpio_on once, 55 s of 1 s samples, gpio_off, pda_active=0 only if the CP side is quiet. +# Runs ON the phone so the power-off happens even if ssh drops. Log: /root/s5c.log +L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5c.log +B=$(ls -d /sys/class/power_supply/*battery* | head -1) +: > $O +cp2ap() { awk '/^CP2AP_/ {s+=$2} END {print s+0}' $L/lines; } +ufsbad() { [ "$(grep -vc ': 0$' $U)" != 0 ] || [ "$(dmesg | grep -c 'ufshcd_err_handler started')" != 0 ]; } +snap() { echo "$(date +%T.%N | cut -c1-12) $1 $(awk '{printf "%s=%s ",$1,$2}' $L/lines | sed 's/AP2CP_//g;s/CP2AP_/c2a_/g') ufs=$(grep -vc ': 0$' $U) cur=$(cat $B/current_now) avg=$(cat $B/current_avg 2>/dev/null) v=$(cat $B/voltage_now) bat=$(cat $B/capacity)% bt=$(cat $B/temp)" >> $O; } +# 30 s baseline at the same cadence +i=0; while [ $i -lt 30 ]; do snap "base-$i"; sleep 1; i=$((i+1)); done +BASE=$(awk '/ base-/ {for(i=1;i<=NF;i++) if ($i ~ /^cur=/) {sub("cur=","",$i); s+=$i; n++}} END {printf "%d", s/n}' $O) +echo "baseline cur=$BASE uA" >> $O +echo 1 > $L/pda_active; echo "pda_active=1 rc=$?" >> $O; snap "pda1" +echo 1 > $L/gpio_on; RC=$?; echo "gpio_on rc=$RC" >> $O +STOP="" +if [ $RC = 0 ]; then + i=0 + while [ $i -lt 55 ]; do + sleep 1; i=$((i+1)); snap "on+$i" + ufsbad && { STOP="UFS"; break; } + BT=$(cat $B/temp); [ "$BT" -gt 450 ] && { STOP="BATTEMP"; break; } + CUR=$(cat $B/current_now); [ $((BASE - CUR)) -gt 300000 ] && { STOP="CURRENT"; break; } + done +fi +echo "STOPREASON=${STOP:-none-at-55s}" >> $O +echo 1 > $L/gpio_off; echo "gpio_off rc=$?" >> $O +sleep 2; snap "off+2" +if [ "$(cp2ap)" = 0 ]; then + echo 0 > $L/pda_active; echo "pda_active=0 rc=$?" >> $O +else + echo "CP2AP STILL HIGH after gpio_off: pda_active NOT lowered, do not reboot" >> $O +fi +for t in 3 8 13 18 23 28; do sleep 5; snap "post+$t"; done +echo DONE >> $O diff --git a/device/husky/bringup/s5d.sh b/device/husky/bringup/s5d.sh new file mode 100755 index 000000000..f7ff5759c --- /dev/null +++ b/device/husky/bringup/s5d.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes. +# S5d (TEST ONLY): battery-only current measurement around the modem power-on. Runs ON the phone; log /root/s5d.log. +# Phases: A baseline 150 s (no writes) -> B pda_active=1 + gpio_on, 60 s (median-of-5 abort) -> gpio_off, pda_active=0 if CP2AP quiet +# -> C post 120 s -> D control 120 s (no writes). 1 s samples of current_now/current_avg/voltage. +L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5d.log; B=/sys/class/power_supply/max170xx_battery +: > $O +cp2ap() { awk '/^CP2AP_/ {s+=$2} END {print s+0}' $L/lines; } +ufsbad() { [ "$(grep -vc ': 0$' $U)" != 0 ] || [ "$(dmesg | grep -c 'ufshcd_err_handler started')" != 0 ]; } +snap() { echo "$(date +%T) $1 cur=$(cat $B/current_now) avg=$(cat $B/current_avg) v=$(cat $B/voltage_now) bt=$(cat $B/temp) c2a=$(cp2ap) ufs=$(grep -vc ': 0$' $U)" >> $O; } +med5() { tail -5 $O | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | sed -n 3p; } +phase() { n=$1; tag=$2; i=0; while [ $i -lt $n ]; do snap "$tag-$i"; sleep 1; i=$((i+1)); done; } +phase 150 A +BASEMED=$(sed -n '/ A-/p' $O | tail -60 | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | awk '{a[NR]=$1} END {print a[int((NR+1)/2)]}') +echo "BASELINE_MEDIAN_cur=$BASEMED uA" >> $O +echo 1 > $L/pda_active; echo "pda_active=1 rc=$?" >> $O +echo 1 > $L/gpio_on; RC=$?; echo "gpio_on rc=$RC" >> $O +STOP="" +if [ $RC = 0 ]; then + i=0 + while [ $i -lt 60 ]; do + sleep 1; i=$((i+1)); snap "B-$i" + ufsbad && { STOP="UFS"; break; } + [ "$(cat $B/temp)" -gt 450 ] && { STOP="BATTEMP"; break; } + if [ $i -ge 5 ]; then M=$(med5); [ $((BASEMED - M)) -gt 300000 ] && { STOP="CURRENT_MEDIAN"; break; }; fi + done +fi +echo "STOPREASON=${STOP:-none-at-60s}" >> $O +echo 1 > $L/gpio_off; echo "gpio_off rc=$?" >> $O +sleep 2; snap "off+2" +if [ "$(cp2ap)" = 0 ]; then echo 0 > $L/pda_active; echo "pda_active=0 rc=$?" >> $O; else echo "CP2AP STILL HIGH: pda_active NOT lowered, do not reboot" >> $O; fi +phase 120 C +phase 120 D +echo DONE >> $O diff --git a/device/husky/bringup/s5e.sh b/device/husky/bringup/s5e.sh new file mode 100755 index 000000000..70c82cb2c --- /dev/null +++ b/device/husky/bringup/s5e.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Test only, as run on the 8 Pro on 2026-11-07 (see device/husky/MODEM-PLAN.md); this note and the SPDX line are the only changes. +# S5e v2 (TEST ONLY): battery-only current, isolating pda_active from gpio_on. Run as: nohup setsid sh /root/s5e.sh & Log: /root/s5e.log +# A 90 s base | E1 pda_active ALONE 30 s | B 60 s | E2 gpio_on, pda LOW 60 s | C 60 s | E3 pda=1 then gpio_on 60 s | D 60 s | E1b (replicate) 30 s | E 60 s +# Fixes after review: trap (safe_off on INT/TERM/HUP), abort ends the run, CP2AP-high stops, pda verified low before powered steps, +# UFS error count compared to the count at start, tighter E1 rule (150 mA), screen state in every sample, per-phase medians at the end. +L=/sys/kernel/debug/cpif_test; U=/sys/kernel/debug/ufshcd/13200000.ufs/stats; O=/root/s5e.log; B=/sys/class/power_supply/max170xx_battery +: > $O +N0=$(dmesg | grep -c 'ufshcd_err_handler started') +ABORT="" +hw() { echo "$2" > $L/$1; } +cp2ap() { awk '/^CP2AP_/ {s+=$2} END {print s+0}' $L/lines; } +ap2cp() { awk '/^AP2CP_/ {s+=$2} END {print s+0}' $L/lines; } +pda() { awk '/^AP2CP_AP_ACTIVE/ {print $2}' $L/lines; } +ufsbad() { [ "$(grep -vc ': 0$' $U)" != 0 ] || [ "$(dmesg | grep -c 'ufshcd_err_handler started')" != "$N0" ]; } +snap() { echo "$(date +%T) $1 cur=$(cat $B/current_now) avg=$(cat $B/current_avg) v=$(cat $B/voltage_now) bt=$(cat $B/temp) c2a=$(cp2ap) a2c=$(ap2cp) pda=$(pda) ufs=$(grep -vc ': 0$' $U) bl=$(cat /sys/class/backlight/*/bl_power | head -1)" >> $O; } +med5() { tail -5 $O | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | sed -n 3p; } +phase() { n=$1; tag=$2; i=0; while [ $i -lt $n ]; do snap "$tag-$i"; sleep 1; i=$((i+1)); done; } +safe_off() { + hw gpio_off 1; echo "gpio_off rc=$?" >> $O; sleep 2; snap "off+2" + if [ "$(cp2ap)" = 0 ]; then hw pda_active 0; echo "pda_active=0 rc=$?" >> $O + else echo "CP2AP STILL HIGH: pda_active NOT lowered, do not reboot" >> $O; ABORT="CP2AP_HIGH"; fi + [ "$(pda)" = 0 ] || [ "$ABORT" = "CP2AP_HIGH" ] || ABORT="PDA_NOT_LOW" +} +trap 'echo TRAP >> $O; safe_off; echo ABORTED-BY-SIGNAL >> $O; exit 1' INT TERM HUP +# powered TAG SECONDS THRESHOLD_uA : the enabling write(s) were done by the caller +powered() { tag=$1; n=$2; th=$3; STOP=""; i=0 + while [ $i -lt $n ]; do sleep 1; i=$((i+1)); snap "$tag-$i" + ufsbad && { STOP=UFS; break; } + [ "$(cat $B/temp)" -gt 450 ] && { STOP=BATTEMP; break; } + if [ $i -ge 5 ]; then M=$(med5); [ $((BASEMED - M)) -gt $th ] && { STOP=CURRENT_MEDIAN; break; }; fi + done + echo "STOPREASON($tag)=${STOP:-none-at-${n}s}" >> $O; [ -n "$STOP" ] && ABORT="$tag:$STOP"; } +finish() { phase 30 Z; echo "ABORTED=$ABORT" >> $O; summary; echo DONE >> $O; exit 1; } +summary() { echo "--- per-phase median cur (uA) and n" >> $O + for ph in A E1 B E2 C E3 D E1b E; do grep -E "^[0-9:]+ $ph-[0-9]+ " $O | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | awk -v ph=$ph '{a[NR]=$1} END { if (NR) printf "%s median=%d n=%d\n", ph, a[int((NR+1)/2)], NR }' >> $O; done; } +echo "start: bl=$(cat /sys/class/backlight/*/bl_power | head -1) N0=$N0 status=$(cat $B/status)" >> $O +[ "$(cat $B/status)" = "Discharging" ] || { echo "NOT DISCHARGING: refusing" >> $O; ABORT=START_STATUS; finish; } +[ "$(cat $B/temp)" -le 450 ] || { echo "BATTERY HOT: refusing" >> $O; ABORT=START_TEMP; finish; } +[ "$(ap2cp)$(cp2ap)" = "00" ] || { echo "LINES NOT ALL 0: refusing" >> $O; ABORT=START_LINES; finish; } +ufsbad && { echo "UFS NOT CLEAN: refusing" >> $O; ABORT=START_UFS; finish; } +phase 90 A +BASEMED=$(sed -n '/ A-/p' $O | tail -60 | sed 's/.* cur=\([-0-9]*\) .*/\1/' | sort -n | awk '{a[NR]=$1} END {print a[int((NR+1)/2)]}') +echo "BASELINE_MEDIAN_cur=$BASEMED uA" >> $O +[ "$(pda)" = 0 ] || { echo "pda not low at start" >> $O; ABORT=START; finish; } +# E1: pda_active alone (tight rule 150 mA) +hw pda_active 1; echo "E1 pda_active=1 rc=$?" >> $O +if [ "$(pda)" = 1 ] && [ "$(ap2cp)" = 1 ]; then powered E1 30 150000; else echo "E1 READBACK MISMATCH" >> $O; ABORT="E1:READBACK"; fi +hw pda_active 0; echo "E1 pda_active=0 rc=$?" >> $O; [ -z "$ABORT" ] || finish +[ "$(pda)" = 0 ] || { ABORT="PDA_NOT_LOW_AFTER_E1"; finish; } +phase 60 B +# E2: gpio_on with pda low +[ "$(pda)" = 0 ] || { ABORT="PDA_NOT_LOW_BEFORE_E2"; finish; } +hw gpio_on 1; RC=$?; echo "E2 gpio_on(pda low) rc=$RC" >> $O +if [ "$(ap2cp)" = 4 ] && [ "$(pda)" = 0 ]; then powered E2 60 400000; else echo "E2 READBACK MISMATCH (ap2cp=$(ap2cp) pda=$(pda))" >> $O; ABORT="E2:READBACK"; fi +safe_off; [ -z "$ABORT" ] || finish +phase 60 C +# E3: pda_active then gpio_on (the S5d order) +hw pda_active 1; echo "E3 pda_active=1 rc=$?" >> $O +hw gpio_on 1; RC=$?; echo "E3 gpio_on rc=$RC" >> $O +if [ "$(ap2cp)" = 5 ] && [ "$(pda)" = 1 ]; then powered E3 60 400000; else echo "E3 READBACK MISMATCH (ap2cp=$(ap2cp) pda=$(pda))" >> $O; ABORT="E3:READBACK"; fi +safe_off; [ -z "$ABORT" ] || finish +phase 60 D +# E1b: replicate of E1 +hw pda_active 1; echo "E1b pda_active=1 rc=$?" >> $O +if [ "$(pda)" = 1 ] && [ "$(ap2cp)" = 1 ]; then powered E1b 30 150000; else echo "E1b READBACK MISMATCH" >> $O; ABORT="E1b:READBACK"; fi +hw pda_active 0; echo "E1b pda_active=0 rc=$?" >> $O; [ -z "$ABORT" ] || finish +phase 60 E +summary +echo DONE >> $O diff --git a/device/husky/overlays/modem-s1-link.dtso b/device/husky/overlays/modem-s1-link.dtso new file mode 100644 index 000000000..52ddf557e --- /dev/null +++ b/device/husky/overlays/modem-s1-link.dtso @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Modem link bring-up, stage S1, never default (device/husky/ + * MODEM-PLAN.md): turns on the modem PCIe controller node + * (pcie_0, ch0) and its PHY (pcie_0_phy) and nothing else. The `modem` + * child stays disabled, so the controller driver takes no modem line, and + * the pins are not touched (pcie_0 has only an "active" pinctrl state, which + * only link_up selects). Both drivers only map their registers at probe. + * The controller module is blacklisted and loaded by hand after the boot. + * The modem power lines are not described as enabled anywhere in this file. + */ +/dts-v1/; +/plugin/; + +&pcie_0_phy { + status = "okay"; +}; + +&pcie_0 { + status = "okay"; +}; diff --git a/device/husky/overlays/modem-s2-lines.dtso b/device/husky/overlays/modem-s2-lines.dtso new file mode 100644 index 000000000..d91aa0586 --- /dev/null +++ b/device/husky/overlays/modem-s2-lines.dtso @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Modem link bring-up, stage S2, never default (device/husky/ + * MODEM-PLAN.md): S1 (pcie_0 and pcie_0_phy) plus the `modem` + * child of pcie_0, so the controller driver requests the eleven modem lines + * as the bootloader left them (GPIOD_ASIS: no direction or level change at + * probe). Only the debugfs `status` file reads them. There is no cpif node + * (samsung,exynos-cp) in the tree, so cpif and shm_ipc cannot bind and must + * not be loaded. No pin state is selected and no line is driven by hand. + */ +/dts-v1/; +/plugin/; + +&pcie_0_phy { + status = "okay"; +}; + +&pcie_0 { + status = "okay"; + + modem { + status = "okay"; + }; +}; diff --git a/device/husky/overlays/modem-s4-cpif.dtso b/device/husky/overlays/modem-s4-cpif.dtso new file mode 100644 index 000000000..9e0581d3d --- /dev/null +++ b/device/husky/overlays/modem-s4-cpif.dtso @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Modem link test, stage S4, never default (device/husky/ + * MODEM-PLAN.md): the controller (pcie_0_phy, pcie_0) + * is on, but its `modem` child is OFF so the lines are free for CPIF, and + * /cp-shmem and /cpif (disabled in the base dtb, kernel branch + * husky-e1-modem-cpif) are switched on. cpif probe forces the seven AP2CP + * outputs low; nothing powers the modem or starts PCIe. + */ +/dts-v1/; +/plugin/; + +&pcie_0_phy { + status = "okay"; +}; + +&pcie_0 { + status = "okay"; + + modem { + status = "disabled"; + }; +}; + +&{/cp-shmem} { + status = "okay"; +}; + +&{/cpif} { + status = "okay"; +};