Repository navigation
Apple SoC sleep: one driver for all Apple SoCs, matched only on tested ones - #1334
Closed
DjDeveloperr wants to merge 14 commits into
Closed
DjDeveloperr wants to merge 14 commits into
DjDeveloperr wants to merge 14 commits into
Conversation
The suspend-to-RAM driver for a kernel at EL2 isn't T8140's alone: other Apple SoCs are to share it, each added by match data once tested. Move t8140-sleep.c to sleep.c, built as apple-sleep, and rename its symbol to CONFIG_APPLE_SOC_SLEEP. CONFIG_APPLE_T8140_SLEEP stays as a transitional symbol, so an old config still enables it. The file moves unchanged. No functional change. Signed-off-by: Diljit Singh <hey@djdev.me>
Rename the driver's own identifiers from t8140_* to apple_sleep_* and sleep_*, and its platform driver from t8140-sleep to apple-sleep. The tables that hold T8140's measured power words, coprocessors and wake sources keep their t8140_ prefix, as the next change makes them T8140's match data. Every renamed identifier keeps its length. The object's text, data and relocations are unchanged; only the driver name string differs. Signed-off-by: Diljit Singh <hey@djdev.me>
The sleep controls' registers and properties aren't T8140's alone: the next SoC to get the suspend-to-RAM driver uses the same binding with its own compatible, as its power domains differ. Make the compatible an enum, so one is added there, and title and describe the binding for Apple SoCs. apple,t8140-sleep stays as it is, with the same properties. Signed-off-by: Diljit Singh <hey@djdev.me>
Everything the sleep driver knew about T8140 was in its code: the offsets of the power words it drives itself, the lists of words macOS was measured with at the commit and the wake, the stray words, the coprocessors that must be bound or stopped, the wake sources' names, the power-gate words and the PCIe host the radio is on. Put them in a struct apple_sleep_soc, one per compatible, and have the shared code take them from there. The books kept per word, until now sized by T8140's tables, are allocated for the SoC's lists at probe. The match table holds only SoCs whose sleep has been measured and tested, so only T8140 for now. Every other SoC doesn't match: the driver doesn't bind there, and s2idle stays the only sleep, as before. Another SoC is added by its own data and compatible, after the same test. The Kconfig help names Apple SoCs and the tested list. No functional change on T8140: each table and value in the new data is the one the code used before. Signed-off-by: Diljit Singh <hey@djdev.me>
A word that one of a SoC's lists names but its full list lacks is skipped at the wake without a word, and a duplicate splits the books kept for it. Check every matched SoC's data for both, that its lists fit the driver's books, that its wake sources are in range and unique, and that the match table holds only the SoCs whose sleep was tested. Signed-off-by: Diljit Singh <hey@djdev.me>
…h data The controller's state is saved across a firmware-driven suspend only on "apple,t8140-aic3", by a compatible check. Make that a flag in the AIC's own match data, so the SoC that gets the sleep driver next turns it on there. No functional change: only T8140's data sets it. Signed-off-by: Diljit Singh <hey@djdev.me>
Whether a firmware-driven sleep stops the DCP's firmware and powers it down, restarting it warm after, is decided by "apple,t8140-dcp" and "apple,t8140-dcpext" compatible checks. So is the log counter echo that the warm restart needs, and the internal panel's power cycle at DPMS off. Make both flags of the DCP's own match data, s2r and s2r_ext, set for T8140's two processors. No functional change: the flags are set exactly where the compatibles matched. The apple-dcp host test's copy of the struct gets the two fields, as it compiles T8140's two initializers. Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr
added a commit
to aurora-silicon/alarm-aurora
that referenced
this pull request
Nov 9, 2026
… RTC aurora-silicon/linux#1334 renames the deep-sleep driver for all Apple SoCs: CONFIG_APPLE_T8140_SLEEP becomes CONFIG_APPLE_SOC_SLEEP, and asahi.config sets the new one. #1333 makes the PMU RTC the J700's rtc0, built in, so asahi.config sets CONFIG_RTC_DRV_APPLE_PMU=y. Record both in the resolved config, which NixOS builds from without merging the fragment and then checks against it. TODO: both need the kernel pin to carry #1334 and #1333, which the PKGBUILD's TODO says too. Under d4d2678 neither symbol changes anything: it has no sleep driver, and olddefconfig drops the unknown one. Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr
added a commit
to aurora-silicon/nixos-aurora
that referenced
this pull request
Nov 9, 2026
Refresh kernel/config from alarm-aurora 5c410f8 (alarm-aurora#199). It renames CONFIG_APPLE_T8140_SLEEP to CONFIG_APPLE_SOC_SLEEP, as aurora-silicon/linux#1334 does for the sleep driver, and builds the PMU RTC in (CONFIG_RTC_DRV_APPLE_PMU=y), as #1333 does to make it the J700's rtc0. Both pins put those lines in asahi.config, and this build validates against that fragment after merging only nixos.config. TODO: this needs a kernel pin with #1334 and #1333, as the comment in overlay.nix says. Under d4d2678 the fragment still asks for the PMU RTC as a module, so the config's =y doesn't validate there. Signed-off-by: Diljit Singh <hey@djdev.me>
This was referenced Nov 9, 2026
…neric Bring the T8140 sleep follow-ups under the renamed driver. The one conflict is the comment above the enclave's tell, which takes the follow-ups' wording and the new apple_sleep_enclave_tell() name. Signed-off-by: Diljit Singh <hey@djdev.me>
The follow-ups were written against t8140-sleep.c. Move their last uses of the old names to the renamed driver: - apple_sleep_commit_stops_coprocs() reads apple_sleep, not t8140_sleep, which no longer exists. - The enclave's commit checks CONFIG_APPLE_SOC_SLEEP. The old APPLE_T8140_SLEEP is now a transitional symbol, which never reaches autoconf.h, so the old check was always false and every sleep commit would have been refused. - The SEP host test's mock and its no-capability-check mutation follow the new symbol. No functional change against the follow-ups on the old driver. Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr
changed the base branch from
fix/t8140-sleep-review
to
fix/t8140-sleep-followups
November 9, 2026 14:57
…neric Brings in the page select resend and integration/aurora 15f88e1. Git carries the resend's hunk into sleep.c without a conflict; the next commit moves it to the new names. Signed-off-by: Diljit Singh <hey@djdev.me>
The debug port's page select resend was written against t8140-sleep.c. Its two calls go to sleep_hpm_cmd(), the renamed t8140_hpm_cmd(), which no longer exists. No functional change against the resend on the old driver. Signed-off-by: Diljit Singh <hey@djdev.me>
…neric Brings in #1208's aop-bootargs host test fix. No conflicts. Signed-off-by: Diljit Singh <hey@djdev.me>
Signed-off-by: Diljit Singh <hey@djdev.me>
Contributor
Author
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.
Makes the T8140 suspend-to-RAM driver an Apple SoC sleep driver. It binds only on SoCs whose sleep has been measured and tested, which today means T8140 (MacBook Neo). Every other SoC keeps s2idle and doesn't change. Stacked on #1313 (
fix/t8140-sleep-review, cc859e5).What's generic now
drivers/soc/apple/t8140-sleep.cis nowdrivers/soc/apple/sleep.c, built asapple-sleepunderCONFIG_APPLE_SOC_SLEEP. That covers the whole path: CPU power ops, refusals, the coprocessors' last stops, the display off, the debug-link cut, ANS's PCIe block, the macOS match, the commit, the return and the rewake.CONFIG_APPLE_T8140_SLEEPstays as a Kconfigtransitionalsymbol, so an old.configstill turns the driver on.struct apple_sleep_soc, one per compatible. It holds:reg-namesentry: the PS word bits, ASC, SPMI/HPM, WDT, DCS, MCC, AMCC, DVFM, CLLT, cluster, PTD, clk-mux, the pin controller and the APCIe block. A SoC whose block differs gets a field for it when it's added.apple,t8140-aic3check is now anaic_info.fw_suspendflag in the AIC's own match data.apple,t8140-dcp/apple,t8140-dcpextchecks for the sleep and DPMS power cycle and the oslog echo are nowapple_dcp_hw_data.s2r/.s2r_ext.enum, and the title and description are generic.How a chip is added
<soc>_sleep_socand{ .compatible = "apple,<soc>-sleep", .data = &<soc>_sleep_soc }toapple_sleep_of_match. Add the compatible to the binding's enum and the node to the SoC's dtsi.fw_suspendin its AIC match data. Sets2r/s2r_extin its DCP data if the DCP's sequence holds there.apple_sleep_test_tested[]insleep-test.c. The KUnit suiteapple-sleep-soc-datachecks that every list names only words of the SoC's full lists, with no duplicates, and that the lists fit the books. A mistake there would otherwise be skipped at the wake without a word.Why untested chips are unchanged
apple,t8140-sleep, and onlyt8140.dtsihas that compatible. Without a match the driver never probes, so there's nosuspend_set_ops()and no spin-table power ops, andmem_sleepstayss2idleexactly as before.apple_sleep_*helpers are unchanged and still answer as before when no sleep driver has probed.No functional change on T8140
.textis identical to T8140 sleep: fixes from review #1313'st8140-sleep.o. The only data change is the module name string. Git shows the file as a 100% rename..text,.rodata,.dataand relocations are identical. Only the driver name string changes (apple-sleep, same length).t8140_sleep_socwas decoded from its DWARF layout and checked against the old object and source: every table, named word, pwrgate word, count, mask and string, and theof_matchdata pointer. 50 of 50 checks match.Not generalized, on purpose
rtkit.coslog echo. It's anof_machine_is_compatible("apple,t8140")check, but it's general RTKit behaviour, not sleep.pmp-export.capple_pmp_keep_bound(). This is a driver-widesuppress_bind_attrs, read before any device or match data exists. A helper that depends on the sleep config would change T8140 kernels built without it.dwc3-appleGCTL hibernation setup. It's controller reset programming, run at every reset, and the driver has no match data.has_t8140_dp. It's a PHY variant flag. Its sleep-in-place also needsapple_sleep_domain_check(), which fails without the sleep driver.apple,sleep-ssps,apple,sleep-ddr,apple,sleep-driver-owned), onpm_suspend_via_firmware(), on the sleep driver's registration, or on its own match data (NVMesleep_traced, GPUsleep_restart, SIOfirmware_only, EDACt8140_ni).Visible renames
apple-sleep, at/sys/bus/platform/drivers/apple-sleep/, and its log prefix isapple-sleep.apple_sleep.CONFIG_APPLE_SOC_SLEEP: alarm-aurora#199 and nixos-aurora#203 get a follow-up commit, which also takes T8140 sleep follow-ups: RTC wake on rtc0, SEP restart after a refusal, commit audit, USB recovery #1333'sCONFIG_RTC_DRV_APPLE_PMU=y. fedora-aurora#242 needs nothing, because it validates against the pinnedasahi.config.Tests
drivers/soc/apple/ drivers/irqchip/ drivers/gpu/drm/apple/ drivers/gpu/drm/asahi/ drivers/dma/ drivers/mfd/ drivers/nvme/host/ drivers/pci/controller/ drivers/phy/apple/ drivers/pmdomain/apple/ drivers/usb/dwc3/ drivers/usb/typec/tipd/plus the t8140-j700, t6000-j314s, t8112-j413, t6041-j614c and t6040-j616s DTBs. Exit 0. The only warnings are the knownapple.cthread-safety ones and rustc deprecation notes, none from this series.sleep.ois also clean with W=1, and checkpatch is clean.CONFIG_APPLE_SOC_SLEEP=yand the new suite):apple_g17_rx_util_min_test, which needs UCLAMP). That's T8140 sleep: fixes from review #1313's 528 plus the 4 cases ofapple-sleep-soc-data.drm_sched_parallel_submit_testcleanup:mock_sched_cancel_job()->hrtimer_cancel(), a NULL dereference). That broke the KUnit device bus for every later suite. This series doesn't touchdrivers/gpu/drm/scheduler.apple-sleep-soc-datafails on exactly that word.tools/asahi/run-host-tests.py): apple-dcp 87/87 (through the clang wrapper with-Wno-unused-but-set-global, as on T8140 sleep: fixes from review #1313), display26 1/1, t6030-wiring 3/3, tunnel-route 1/1, tiled-split 2/2 (with mutations), t6030-clock 1/1, rtkit-oslog 6/6, atc-usb3 2/2 (with mutations), neo-stability 10/10, apple-dart-fw 1/1, apple-dart-range 1/1, t8140-external-bw 1/1. apple-dcp'sresource-profilecopies the DCP's hw data struct, so its mock gets the two new fields in the DCP commit.dt_binding_checkon the binding passes.dt-validateof t8140-j700.dtb gives the same lines with the old and the new binding, and none for the sleep node.Merging with #1333 (sleep follow-ups)
#1333 (
fix/t8140-sleep-followups, a078d77) is also stacked on #1313. The rename commit here is a pure 100% move, so git carries #1333's changes tot8140-sleep.cover tosleep.c. A trial merge (git merge-tree):*_enclave_tell(): take T8140 sleep follow-ups: RTC wake on rtc0, SEP restart after a refusal, commit audit, USB recovery #1333's comment and this branch'sapple_sleep_enclave_tell(struct apple_sleep *s).apple_sleep_commit_stops_coprocs()readst8140_sleep. It merges cleanly but doesn't build until it readsapple_sleep.include/linux/soc/apple/sleep.h(its new declaration and stub land inside this branch'sCONFIG_APPLE_SOC_SLEEPblock) andasahi.config(RTC_DRV_APPLE_PMU=yandAPPLE_SOC_SLEEP=yare separate lines).🤖 Generated with Claude Code