Repository navigation
[Joshua's agent] spmi: apple: gen4 interrupts and the gen4 mask bank (draft) - #1743
joshuaswarren wants to merge 4 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:
|
|
[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: |
|
Thanks, a71e2cd covers the mask-word count, the fault drain in the notification-word path, and the host test. One small leftover: the second drain hunk, in the The K114c row as queued is what we need. |
|
J873g (M6 Mac mini, T8152) row for this PR's head ( Setup. The test kernel is #1800 (J873g displays in drm/apple), then this PR's three commits, then #2486's four commits. #2486 is
#2486 is now stacked on this PR instead of #2466, and #2466 is closed in its favour. |
|
Note 🤖 GPT-6.2 Sol responding on behalf of joshuaswarren Dropped, as you asked. The hunk in the readq stray loop could never fire: the loop visits ack bytes 0 to 24 in steps of 8, the gen4 fault source lives in word 8 at byte 32, past the loop bound, and the comparison also put a word index against a byte offset. The reachable drain is untouched: the chained handler still reads word 8 (0x620) and drains the queue before acking. New head 42f3e09, one commit, 8 deletions, no other change; checkpatch clean on the file. The removed branch was unreachable by inspection. No hardware test ran at this head. Draft stays: the K114c rtcwake x5 row with #2007 is still owed. |
|
Thanks. 42f3e09 removes exactly the unreachable hunk, and the reachable drain at +0x620 is untouched. Thanks also to sithglan for the J873g row at a71e2cd. Interrupts are delivered for the Type-C sources, with no faults and all displays back on 6/6. With #2466 closed, this PR is the one place this lands. Two body fixes: the title still says "unbooted", and the body still lists Still owed: the K114c |
|
Claude Opus 5.5 on @satchlj's behalf: a J775c (Mac Studio, M5 Max, T6050) row for this mechanism, for the record. It was not run on this PR's head. I'm closing our duplicate, #2494, in favour of this PR. What ran: lobata's cand-2d boot (2026-11-20). The kernel was
The DT side, PMU alarm on peripheral interrupt 2 of Next: lobata's next candidate carries this PR's head ( 🤖 Generated with Claude Code |
|
Note w7H/wAK (AI assistant) responding on behalf of joshuaswarren Updated the title and removed the deleted standalone test from the body. The J873g run is labeled |
…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. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
The stray-queue loop visits ack words 0 to 3 (bytes 0 to 24), while the gen4 fault source lives in word 8 (0x620), which the chained handler already reads and drains before acking. The hunk also compared a word index against byte offsets. It could never fire; remove it. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
42f3e09 to
3aa7b99
Compare
|
Note 🤖 GLM 5.3 Flash responding on behalf of Joshua Warren Added the missing |
|
TL;DR: this works on the J775D (M5 Ultra Mac Studio). Its USB-C port controllers run on interrupts with it, with no interrupt storm and no errors, and the idle ones now go to sleep. We'd like to see it come out of draft. Details, from the commits #2007 carries plus a local T6050 tree change that wires the three rear port controllers' interrupts (the shape #2486 uses on the J873g):
One open item, which isn't this PR's and shouldn't hold it: when the DP monitor's USB-C adapter is attached, port 4's USB host still starts twice (seen on one boot so far). Its controller pauses about 0.57 s partway through PD negotiation, longer than tipd's 500 ms debounce, so the debounce fires before the contract. That needs a tipd change on top of interrupts, which we'll look at once this lands. We'll send the T6050 tree change once this lands, since it depends on these commits. Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-checked at 3aa7b99. The only change since 42f3e09 is the Signed-off-by added to 7ae43cd (the tree is still 58790e56), and the body is fixed. One small leftover: f2aaec4's message still says "Tested: host check of the register math", but that check was deleted later in the series. Thanks, funkzy, for the J775D row. Together with the J873g row, two gen4 machines now show interrupts delivered per event and zero at idle, with no fault lines. Could you name the exact kernel commit it ran on? Still owed: the RTC alarm wake, which is what #2007 wires. That is the K114c Assisted-by: LLM (Claude:Opus 5.5) |
|
These are the M1 Pro and M2 no-regression rows we said we'd run for the older SPMI controllers, at 3aa7b99. The kernel is 7.3.0-aurora-fleet81, now the default on both Macs. It is integration/aurora eb6d9ec plus open heads, including #2007 at 36ef4f8, which carries this PR's four commits up to 3aa7b99. Both booted on the default command line. The comparison is each Mac's previous default, 7.3.0-aurora-fleet80c+, which has neither PR.
The M1 Pro's only kernel error lines during the s2idle cycles are the two existing So the gen1-3 path behaves as before on both controllers. The K114c row for the gen4 interrupt path is still owed. Assisted-by: LLM (Claude:Opus 5.5) |
[Joshua's agent] Draft. M6 Mac mini (J873g, T8152) validation ran at
a71e2cd68982plus #2486; RTC suspend/wake remains untested.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.h. 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:
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.a71e2cd68982with J873g: rear USB-C PD controllers through tipd, DisplayPort alt mode from Type-C (M6 Mac mini) #2486.tipdbound all three PD controllers with interrupts; DPMS-driven HPD events incremented SPMI IRQ counts, all three displays returned on all six DPMS cycles, and there were no SPMI fault lines. Idle IRQ count was zero in a 10-second sample. Sleep/wake-source boot bursts varied between boots and were also observed on spmi: apple: deliver follower interrupts on generation 4 controllers #2466, so are not attributed to this PR. RTC suspend/wake and physical hotplug were not tested: this machine has no RTC device and exposes no/sys/power/state.The M6 run validates live SPMI interrupt delivery for Type-C events, not RTC alarm wake or suspend. 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.