Repository navigation
Conversation
…rupts The controller's interrupt words hold the peripheral interrupts first and the controller's own events after them, "notify" (the RX FIFO is no longer empty) first. The driver puts notify at 256, after T6030's 256 peripheral interrupts. T6000's nub-spmi0 has 192: macOS's device tree numbers its events from 0xc0, and with a reply left in the FIFO the pending bit is 192 (ack word 6, bit 0). So once a T6000 device tree gives nub-spmi0 its interrupt, the driver unmasks bit 256 and waits for a notify that never comes: every SPMI read times out and the PMU becomes unreachable. Take the peripheral interrupt count from the match data, 192 for apple,t6000-spmi and 256 for the rest, and derive the notify position, the irq domain's bounds, the handler's scan and the mask/ack setup from it. Tested on J314s (M1 Pro): with nub-spmi0's interrupt described, SPMI transfers complete in 40-60 us and the PMU's RTC alarm wakes the system from s2idle. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Corey Henderson <nuwanda@gmail.com>
The Maverick PMUs (the M1 Pro's and the M2 Pro's) latch a fired alarm in an event byte as well as in the alarm control byte, and keep the alarm interrupt silent until the event byte is cleared by writing 1 to it. Allow a fifth cell, rtc_alarm_event, after the four alarm cells. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Corey Henderson <nuwanda@gmail.com>
…gister The Maverick PMUs (the M1 Pro's and the M2 Pro's) latch a fired alarm in two places: bit 1 of the alarm control byte and an interrupt status byte. Writing the control byte back with bit 1 set, which is how T6030's PMU acknowledges the event, leaves the bit set here. It clears when it is written as 0. The status byte clears when 1 is written to it, and until then the PMU keeps the alarm interrupt silent, so every later alarm would be lost. With the optional rtc_alarm_event cell, clear the status byte before arming and after firing. The control byte's bit 1 then clears where it is written as 0. Without the cell, nothing changes. Tested on J314s (M1 Pro): awake alarms fire on their second and leave both registers clear, and every timed s2idle sleep that nothing else woke ended on the alarm. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Corey Henderson <nuwanda@gmail.com>
The time is the SMC's CLKM plus a tick offset, but the PMU's alarm compares against the PMU's own counter, which CLKM lags by a few ms (5.5 to 6.3 ms on J314s, once 14 to 24 ms right after boot). When the tick offset's fraction is under that lag, the alarm fires while the time still reads the second before. The RTC core then finds its timer not yet expired and sets the same second again, the PMU fires again at once, and so on until the time catches up: five or six interrupts and a burst of SPMI traffic for one alarm. That is the state after the PMU loses power, which leaves the offset at 0. When the offset's fraction is under 1/32 s, arm the alarm one counter second later. It then fires within the set second, and read_alarm still reports the time that was set. For fractions between the lag and 1/32 s the alarm comes up to a second late, which the tick-offset path already allowed. The seconds-offset path is unchanged. Tested on J314s (M1 Pro) with the offset's fraction cleared: three awake alarms raised one interrupt each, where they raised 6, 5 and 5 before. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Corey Henderson <nuwanda@gmail.com>
The Maverick PMU on nub-spmi0 has an RTC alarm (macOS's device tree: info-rtc_alarm_ctrl 0x1401, info-rtc_alarm_offset 0x140c, info-rtc_alarm_event 0x14c0, info-rtc_irq_mask_offset 0x14c2). It raises peripheral interrupt 2 of nub-spmi0, whose own interrupt is AIC 636. Describe nub-spmi0 as an interrupt controller and the alarm's four cells, and give the SMC's rtc node the cells, the alarm interrupt and wakeup-source. This needs the SPMI controller to put T6000's notify event at 192 (previous patches); without it, describing the interrupt breaks every SPMI transfer. Tested on J314s (M1 Pro) with the same description applied to the live device tree: the alarm fires on its second, and it wakes the system from s2idle. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Corey Henderson <nuwanda@gmail.com>
CoreyH
requested review from
chriskearney,
maralcbr and
scottjones
as code owners
November 4, 2026 13:34
CoreyH
added a commit
to CoreyH/sleep-drain
that referenced
this pull request
Nov 4, 2026
PLAN.md: B3 posted as omacom/linux-aurora#351
|
Tested this series' rtc-macsmc on a third PMU: Stowe, on a J413 (MacBook Air 13" M2), 7.2.11.aurora16. It works unchanged with a T8112 description added. That commit is in #454, on top of this branch; fold it in here if that is easier for you. What Stowe does, from reads and writes by hand through the nvmem device:
Results: 3 of 3 awake alarms raised one interrupt each, and 19 of 19 timed s2idle sleeps ended on the alarm (18 at 20–30 s, 1 at 3600 s). I did not look for the repeated-interrupt case patch 4 fixes; I saw one interrupt per alarm in all 3 awake runs. 🤖 Generated with Claude Code |
Author
|
Thank you for testing this on a third PMU, and for writing down how Stowe behaves.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes the PMU's RTC wake alarm work on T600x (M1 Pro/Max/Ultra):
rtcwake, and timed wakes from s2idle. It builds on the rtc-macsmc alarm from #274 (T6030) and on 2037f35, the commit that lets SPMI peripheral interrupts wake the system.Patches
spmi: apple:T6000's controller has 192 peripheral interrupts, so its own events start at 192, not 256. Notify, "reply ready", is the first of them. Without this, once a T600x device tree gives nub-spmi0 its interrupt, every SPMI transfer times out and the PMU is unreachable.dt-bindings: rtc: apple,smc-rtc:an optional fifth cell,rtc_alarm_event.rtc: macsmc:clear a Maverick PMU's fired alarm in both places. Maverick PMUs (M1 Pro, M2 Pro) latch a fired alarm in0x14c0, which clears when 1 is written to it, as well as in the control byte, whose bit 1 clears when written as 0. Until both are cleared, every later alarm is lost.rtc: macsmc:arm the alarm one second later when the tick offset's fraction is under 1/32 s.arm64: dts: apple: t600x:describe the alarm:info-rtc_alarm_ctrl0x1401,info-rtc_alarm_offset0x140c,info-rtc_alarm_event0x14c0,info-rtc_irq_mask_offset0x14c2;wakeup-source.Testing on J314s (M1 Pro), 7.2.11.aurora14:
W=1(LLVM).dt-doc-validateanddt-validatepass, andcheckpatch.pl --strictis clean.ci:buildfrom a maintainer. With the package, I'll boot it on J314s and report back here.t600x-die0.dtsi.Credit: JJRPF/Aurora-DeepIdle first found the Maverick PMU's RTC register map, and that it needs both clears, on an M2 Pro. This J314s's own macOS device tree confirms the same layout.
The patches were written with Claude's help (each carries
Assisted-by:); I've reviewed and tested them, and they carry mySigned-off-by.