Repository navigation
soc: apple: sleep, mfd: macsmc: T6050: the wake's sources in macOS's order - #2611
Conversation
448120a to
8aa11d7
Compare
|
Thanks for the trace table. The ordering change reads cleanly, and
Assisted-by: LLM (Claude:Opus 5.5) |
8aa11d7 to
f796159
Compare
…order About 2 in 84 of the J714s's deep sleeps end early (0.5-13 s into a 60 s alarm, MBSW 0, the PMU's alarm not fired) with nothing that names the source. macOS's wake handles its wake sources in a fixed order. From the macOS-HV rings of three docked sleeps (mxt4, dk1, dk2; dk2 hooked the SPMI controllers only), with times from the wake: - 57 ms: each SPMI controller's handler (nub-spmi0, nub-spmi-a0, nub-spmi-a1) reads its eight latched-source words (+0x600..+0x61c). It acknowledges each set source that is enabled (+0x400..), and masks it until its driver has seen it. Those were nub-spmi0's 0x02 (the PMU), nub-spmi-a1's 0x0b, and in dk1 also nub-spmi-a0's 0x3f. Set sources that aren't enabled stay set. At run time the handler takes each source as it comes, so none is pending at a sleep's entry. - 63 ms (mxt4, dk1): AP ON to the SMC. At 66-68 ms MBSE is read (0x10650), MBSW is read, and MBSE = waka; at 68.6-69.0 ms MSLD. - 95 ms: the PMU. Its RTC control is read, the boot stage 0xf801 = 0xfe is written, and then 0xf801, 0xf808, 0xf802, 0xf818, 0xf819, 0xf800 and 0xa7dc are read (the DT's apple,pmu-sleep-reads, as at the entry). - Its console logs "system wake events: NUB.SPMI0Sw3IRQ nub-spmi0.0x02 nub-spmi-a1.0x0B rtc" (wm2), and pmset the same names. Linux acknowledged only nub-spmi0's PMU sources. It wrote the PMU's boot stage before AP ON and before the SMC's wake record, so MBSE read 0x106fe. It logged only the AP status bits. Do as macOS does: - t6050_spmi_src_ack() replaces t6050_spmi_pmu_ack(). At the entry, before the sleep's masks, and at the wake, before the run-time masks, it acknowledges each set and enabled source, and nub-spmi0's DT PMU sources, on nub-spmi0 and on every apple,spmi-buses controller. The enables are left alone. A set source that is enabled holds the controller's output up, and nub-spmi0's outputs are AP wake sources. - macsmc gets a new saved op, .woken. Right after .end's AP ON at the platform wake, it reads MBSE and MBSW, writes waka and reads MSLD, polled, after any ordinary command in flight has had its reply polled in, as the noirq resume does (one helper, apple_smc_poll_in_flight(), now does that wait for both). The noirq resume keeps pmVC (the policy's 58 ms floor after waka; macOS's came 55-62 ms after), the lid's handling and the dark wakes. It takes the record itself if .woken didn't run for this wake or didn't get both a clean record and waka (an ordinary command released with the scope can make one fail for the moment). A failed read in that first try logs no record line, so it never leaves an all-zero one; the noirq resume logs the record it reads. After a clean read and a failed waka, both record lines are real ones. A new scope's begin, and a resume that bails, clear what an earlier wake left (woken_done, saved_wake). The KUnit tests' calls take the path without a policy (woken false). - The sleep core gets a new op, .pmu_wake, run after the SMC's commands. For T6050 it reads the PMU's RTC control, writes the DT's boot stage and does the DT's reads. .finish writes the stage itself only for an attempt that never committed. - After each wake, one line in macOS's form: "wake events:" with the set AP sources by their ADT names, the acknowledged SPMI sources as <controller>.0x<source>, and "rtc" if the PMU's alarm fired. The raw words go to the debug log. The AP wake masks are unchanged: macOS arms the same 28 sources, ATC1/ATC2.PMGRUSBWakeup among them. The J716c shares the T6050 ops and the SMC policy and gets the same order; the traces are J714s ones. Signed-off-by: Diljit Singh <hey@djdev.me> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f796159 to
f197658
Compare
|
Independent review (Opus 5.5, xhigh) on the exact head
The only checkpatch warnings left are cosmetic: "memory barrier without comment", which the rest of the file's 🤖 Generated with Claude Code |
|
Merging on the exact head Hardware gate on the J714s (kit A separate class stays possible after the merge: the AOP crashing at a sleep's entry. Its crash message wakes the AP 0.5-0.6 s in, with MBSE 0x107fe and The rest of the count toward 40 sleeps, with 0 unexplained early wakes, comes after the merge. It will come from the new default's sleeps (sw4 / sship4) and the soaks, as with #2609. 🤖 Generated with Claude Code |
On the J714s (M5 Pro), about 2 in 84 deep sleeps woke early: 0.5-13 s into a 60 s alarm, with MBSW 0 and the PMU's alarm not fired. Nothing named the source. This copies how macOS's wake handles its wake sources, taken from the macOS-HV rings of three docked sleeps (mxt4, dk1, dk2). Times are from the wake.
Its console logs
system wake events: NUB.SPMI0Sw3IRQ nub-spmi0.0x02 nub-spmi-a1.0x0B rtc.Linux acked only nub-spmi0's PMU sources. It wrote the PMU boot stage before AP ON and before the SMC's wake record, so MBSE read 0x106fe instead of macOS's 0x10650. It logged only the AP status bits.
Changes
t6050_spmi_src_ack()replacest6050_spmi_pmu_ack(). At entry and at wake, it acks each latched and enabled source on nub-spmi0 and on everyapple,spmi-busescontroller, plus nub-spmi0's DT PMU sources. The enables are left alone..woken. Right after.end's AP ON at the platform wake, it reads MBSE and MBSW, writes waka and reads MSLD, all polled. The noirq resume keeps pmVC (58 ms floor after waka), the lid handling and the dark wakes. It takes the record itself when.wokendidn't run or got no clean record; a failed first read logs no record line. Both wait for an ordinary command's in-flight reply through one helper,apple_smc_poll_in_flight(). A new scope's begin, and a resume that bails, clear what an earlier wake left (woken_done,saved_wake)..pmu_wake, run after the SMC's commands. For T6050 it reads the RTC control, writes the DT boot stage and does the DT reads.wake events:line per wake, in macOS's form: AP sources by ADT name, acked SPMI sources as<controller>.0x<source>, andrtc. The raw words go to the debug log.The AP wake masks are unchanged: macOS arms the same 28 sources, ATC1/ATC2.PMGRUSBWakeup included. The J716c shares the T6050 ops and SMC policy, so it gets the same order; the traces are from the J714s. There is no switch: the new steps key on the DT (
apple,spmi-buses,apple,spmi-pmu-sources,apple,pmu-wake-stage,apple,pmu-sleep-reads, the wake block), the controllers' own enables and the driver's state; no module parameter, no SoC or board check.Testing
CONFIG_KUNIT=yandCONFIG_MFD_MACSMC_KUNIT_TEST=y.BUILD_BUG_ONarray size), v2 FAIL (KUnit build break inmacsmc-test.c), v3, v4 and v5 PASS-WITH-NITS. Every finding is fixed in this head or listed as a follow-up. This head's own review is on the PR.m5-test/kitN3-20261120(this change's code on the kitI1 stack; later revisions changed only the failure paths, the wording and the shared wait helper): 5 deep sleeps on 60 s alarms, 0 early wakes, all 5 wake reasons named.wake record: MBSE 0x10650, MBSW 0, macOS's value (Linux read 0x106fe before), andwake events: NUB.SPMI0Sw3IRQ nub-spmi0.0x02 rtc, macOS's form.🤖 Generated with Claude Code