Repository navigation
[Joshua's agent] spmi: apple: gen4 interrupts and the gen4 mask bank (draft, unbooted) - #1743
joshuaswarren wants to merge 3 commits into
Conversation
Generation 4 (t8142, t6050) had its interrupt refused at probe. macOS's trace (reported by Dj on the Aurora M5 Pro thread) acks peripheral sources 0..255 per bit in words from +0x600, with the controller fault source 263 at +0x620 bit 7. On K114c the PMIC RTC alarm sets +0x600 bit 2 (read-only probe, alarm armed 20 s out). Take the mask and ack bank offsets from the hw table (gen1 unchanged, shared with a host check in spmi-apple-irq.h). Generation 4 has no mask bank we could find (no word in 0x20..0x7f or 0x500..0x6ff toggles), so sources are masked in the cache only. Commands stay polled: the RX notification is not wired for gen 4. Tested: host check of the register math; compile only, not booted. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
|
[Joshua's agent] w71 data for #1743 (K114c, M5 Max, kernel b13 without this PR, /dev/mem read and single-word writes inside nub-spmi0, no Apple code):
Guesses, not measured: the PMIC alarm arming differs between runs (baseline ctrl 0x41 with the firmware's far-future alarm vs 0x01 after a disarm); or the alarm value or counter base was off. Next probe: same arming as the first with per-second readback of ctrl, alarm, mask byte 0x200e, counter and the +0x400/+0x600 words. |
|
[Joshua's agent] w71 correction to my previous comment: the "alarm did not fire" runs were my probe's bug, not a hardware route problem. Measured on K114c: the PMIC counter at nvmem 0x2002 ticks at 65536 Hz (>>15 advanced 2 per wall second), and rtc time = ((C/2) + offset(0x2100)) >> 15 matched /sys/class/rtc since_epoch exactly. The alarm compares C >> 16 (the earlier run using >>16 fired on target and set +0x600 bit 2). My later probes armed the alarm in C >> 15 units, so 2x too far in the future (about 13 days). That is the same unit the rtc-macsmc alarm path uses (CLKM >> 15 with CLKM = C/2), so the driver's alarm value is consistent. Still open: W1C ack at +0x600 (rerun queued), and the real s2idle wake. The +0x400 mask result stands. |
Probe on K114c: +0x400..0x41c toggle and restore (8 words), +0x420 does not, matching the +0x600 ack bank 0x200 above (Dj, seq 713, from write offsets in a macOS trace). The alarm latches +0x600 bit 2 once the PMIC alarm mask byte 0x200e is 0 (as rtc-macsmc writes it) and a write of 4 to +0x600 clears it (measured). Whether the +0x400 bit gates the AIC line is not measured. Drop the cache-only masking for gen 4. On a firmware resume re-apply the runtime mask, since a firmware sleep entry writes the mask bank itself. Host check extended; compile only, not booted. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
|
[Joshua's agent] w71 update (K114c, still compile-only, not booted): pushed a1463e1, gen4 now uses the hardware mask bank at +0x400, and on a firmware resume re-applies the runtime mask (as Dj asked in seq 713, since the S2R entry writes the bank itself). Measured on K114c with /dev/mem, alarm armed 8 s out in the right unit:
|
a1463e1 to
d18d765
Compare
|
[Joshua's agent] Boot result, 14-inch M5 Max MacBook Pro (K114c, T6050): this PR's two driver commits, the descriptor form of the mask bank at +0x400, booted on top of release/7.3.0-40. What the boot shows:
What the boot does NOT show: the interrupt path ran. |
|
GREEN on d18d765 Checked the body against the diff and the split against the trees. The split claim verifies at blob level: the t6050-die0.dtsi content at this head is byte-identical to integration/aurora (sha256 924f6c4c... at both), and the PR touches exactly the three spmi files. The body's mask-bank paragraph now matches the second commit: the register values live in spmi-apple-irq.h (mask 0x400, ack 0x600, fault source 256+7 acked at 0x620 bit 7 - the arithmetic checks: word 8 at 0x620, bit 7), the mask/unmask raw functions write the per-generation bank (replacing cache-only masking for gen 4), and resume_noirq re-applies the cached runtime mask for a non-parked gen 4 after a firmware resume - the firmware-sleep-writes-the-bank reasoning the body states. The gen4 -EOPNOTSUPP refusal is gone, the notification stays unwired for gen 4 (legacy_irqs gate, commands polled), and gen1/t6000 keep their old offsets by value. I built and ran the host check here from the files at this head (gcc -Wall -Werror): it passes. The Validated-on section claims nothing beyond read-only probes, the host check and compile-only builds, with not-boototed-anywhere and the AIC-gating question stated as open. Draft, unbooted - consistent throughout. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
GREEN on d18d765 First review. This is the split I asked for: three SPMI files ( What I checked:
I did not build the driver or boot anything. No Apple GPU or M-series machine was available. Non-blocking notes:
|
|
Thanks. Keying on the gen4 match data rather than a board list is the right shape, and the probe data is careful. Two small code points that are still open from the earlier review:
Also, Row on the K114c with #2007:
|
…ask writes Both open code points from review: The controller's fault source (263, word 0x620 bit 7 on gen4) shares its ack word with the notification word the handler reads first, and the stray-source path acked it directly: queued fault records were lost. Drain the queue before the bit is acked, in both the notification-word path and the readq stray path. gen4 has no notification source, and the word at +0x420 does not behave as a mask bank, so the init and teardown loops now write only the num_irqs / 32 mask words on gen4 (the legacy controllers keep the extra notification word). The host-test file is dropped: kbuild never built it and it checked constants against themselves.
|
[Joshua's agent] Both code points are fixed at head a71e2cd, and the never-built host test is dropped.
Build: The row (K114c with #2007: |
[Joshua's agent] Draft, compile-only, NOT booted.
Gen4 SPMI (t8142/t6050) refused any interrupt at probe, so the PMIC RTC alarm cannot wake s2idle. This takes the interrupt in the driver. The T6050 device-tree wiring was split out of this PR as its own fix (see the end).
Basis (no Apple code): Dj's macOS trace on the Aurora M5 Pro thread (peripheral sources 0..255 acked per bit from +0x600; fault source 263 at +0x620 bit 7; hpm2 wake as peripheral bit 19) plus our K114c read-only probe: the alarm sets nub-spmi0 +0x600 bit 2 and sticks while PMIC ctrl is 0x03.
spmi: apple: take interrupts on generation 4 controllers: bank offsets move into the hw table (gen1/t6000 unchanged); the register math lives inspmi-apple-irq.hwith a host check (spmi-apple-irq-host-test.c, failed first, passes). Commands stay polled: the RX notification is not wired for gen 4.spmi: apple: use the generation 4 mask bank at +0x400: on the K114c the words +0x400..0x41c toggle and restore, +0x420 does not, matching the +0x600 ack bank. This replaces the cache-only masking for gen 4, and a firmware resume re-applies the runtime mask because a firmware sleep entry writes the mask bank itself. Whether the +0x400 bit gates the AIC line is not measured.Open: whether the +0x400 bit gates the AIC line, and the ack semantics. A boot card (
rtcwake -m freeze, lid wake) is with our boot owner.Validated on, and reach
What ran where:
gcc -Wall -Werror, gcc 12.2): passes, on a Debian x86-64 container.drivers/spmi/spmi-apple-controller.ocompiles with gcc 16.1.1 andW=1on a depth-1 checkout of this head withARCH_APPLE,SPMIandSPMI_APPLEset, no warnings. Not booted.Not booted on any machine with this change. Applies beyond the M4: by the driver's own description gen4 SPMI is t8142 (M4) and t6050, so the interrupt code is shared; nothing was run on an M4 or on an M5 Pro, and no M1/M2/M3 was booted.
The T6050 device-tree change (
nub-spmi0as an interrupt controller on AIC 726,smc_rtcsource 2 as a wake source) is in its own PR: #2007, which depends on this one.m tester run (omarchy-m-testing.org): feature rows Suspend and sleep (RTC alarm wake). The tester needs the hardware; no tester run is linked to this change.