Repository navigation
soc: apple: sleep: Keep the T6030 MCA clock muxes the boot loader set - #4225
Merged
Merged
Conversation
t6030_boot_replay() writes 0 to the four "mca-switch" words at probe. Those words are the MCA audio clock muxes: the boot loader points mux i at NCO channel i (aura's clk_set_mca_muxes(), from ADT /arm-io/mca-switch reg[2]), and nothing in Linux sets them again. At 0 the MCA clusters run from the 24 MHz reference, so on J516s every playback after boot runs about 6.7 times too fast (2 s of audio plays in 0.30 s) and the cs42l84 headphone codec reports PLL lock errors. Leave the muxes alone at probe. In the sleep entry, save them and park them at 0 for the commit, which is the commit state the J516s wakes were tested with, and write the saved words back on wake. A mux finishes a switch only while the source it leaves runs. After a playback the muxes sit on NCO channels that the clock driver has stopped again, and a mux that cannot leave its stopped channel turns the J516s wake into a cold boot. So run each selected channel until its mux has parked, then put the channel's control word back. Fixes: 4d410bc ("soc: apple: sleep: add T6030 firmware sleep provider") Signed-off-by: DjDeveloperr <hey@djdev.me>
Contributor
Author
|
J516s row at head
Merge with current main (
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
commented
Dec 3, 2026
DjDeveloperr
left a comment
Contributor
Author
There was a problem hiding this comment.
Independent review at 9dd2888214bf: looks right, no blocker.
- Probe no longer zeroes the four MCA muxes, which fixes the audio running about 7x too fast after boot (#4067).
- Sleep saves each mux, runs the NCO channel it leaves only until the switch clears BUSY, then puts that channel's control back. Wake writes the saved sources back with BUSY masked, and the switch finishes once audio starts the channel again.
- No entry path skips the restore.
after_ansruns inside the secondapple_sleep_coprocs_stop(), and after that the entry either commits and comes back throught6030_sleep_wake()or panics.enter_cleanup()andundo_regsare never reached with the muxes parked. - The register fields come from a public source: aura's
clk_set_mca_muxes()and ADT/arm-io/mca-switch. Only J516s enablesapple,t6030-sleep, so nothing else changes. - Hardware: the J516s row at this exact head passes 53/53. 2 s of audio still plays in 2.02-2.06 s before and after 2 deep sleeps, with 0 GPU recoveries and 5/5 PCIe.
- Local checks on the merge tree
6a19720ef4cf, on top ofe2d3b330e944: W=1sleep.ogives 0 warnings (main also 0),checkpatch --strictis clean, and the host tests that readsleep.c/sleep-t6030.hpass 47/47. Main has since moved to907e724cfeaf, which only touches drm/asahi.
Merging at this head.
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.
What: On J516s,
mainplays every sound about 6.7 times too fast (2 s of audio in 0.30 s), and the cs42l84 headphone codec keeps loggingPLL lock error. The T6030 sleep driver from #4067 writes 0 to the four MCA audio clock mux words at probe. Those words are the boot loader's audio clock setup, and nothing in Linux sets them again. This PR leaves them alone at probe. It parks them at 0 only for the sleep commit and puts the saved values back on wake.Tested: J516s (fw 27.2) row at
9dd2888214bf+ #4213 (now on main), kernel7.3.0-mcasw3: 53/53 PASS. Timed 2 s audio plays in 2.06 s before sleep and 2.02-2.05 s after each of two deep sleeps (main: 0.32 s), 0 PLL lock errors, 0 mux park warnings. Local checks on the merge with maine2d3b330e944: W=1sleep.o0 warnings (main 0), checkpatch --strict clean, sleep-related host tests 47/47.Risk: two-way · M3 Pro J516s (T6030) only. The changed code runs only under
apple,t6030-sleep, which onlyt6030.dtsihas and only J516s enables. The commit state doesn't change: the muxes are at 0 during the commit, as they are on main today.Not yet:
t6030.dtsinode but doesn't enable the sleep controller, so the changed code doesn't run there today.sleep-t6030.his only built intosleep.oand only reached through theapple,t6030-sleepmatch. The M3 Max and Ultra trees (t6031, t6032) don't use that node.Details
Cause. The
mca-switchregion (0x3500400c0, 4 words, ADT/arm-io/mca-switchreg[2]) holds the MCA audio clock muxes. At boot, aura'sclk_set_mca_muxes()sets bits 27:24 of word i to NCO channel 5+i. Read on stock7.3.0-f3822(bootb68c4d63, read-only/dev/mem), the words are85100100 86100100 87100100 88100100.t6030_boot_replay()has written 0 to all four since the provider was added (4d410bca78c5, then through a hard-codedioremap_np(0x350040000)+ 0xc0). It runs at probe since #4067 (49d5220916b8). With the mux at 0 the MCA clusters clock from the 24 MHz reference: 24 MHz / 64 = 375000 frames/s, so 2 s at 48 kHz takes about 0.26 s plus setup, and the codec PLL can't lock to that bit clock. This is the same failure #3999 fixed on J414s after deep sleep, except here it happens at boot.Fix.
t6030_boot_replay()no longer touches the muxes.t6030_sleep_after_ans()saves each word, runs the NCO channel it selects, writes 0 and polls until bit 30 (switch pending) clears, then puts that channel's control word back. After that point the entry either commits or panics, so there is no abort path to undo. A mux that does not park is counted and named in one warning after the wake.t6030_sleep_wake()writes the saved words back next to the I2C6 restore.Why park them, and why run the channel: every J516s deep sleep tested so far committed with the muxes at 0, so parking keeps the commit as tested. A mux finishes a switch only while the source it leaves runs (bit 30 stays set until then, as #3999 found on T6020). At boot on J516s, muxes 0/1 read
c5100100 c6100100while NCO0/1 are stopped. A first version of this change parked without running the channel. On a kernel from before #4200, its first deep sleep after a playback came back as a cold boot (J516s, 12-03 19:22Z, boot 7d16b5b7 -> 133fccec). Since #4200, clk-apple-nco runs every channel over a firmware sleep (suspend_late, before this code), so the enable here is a no-op on main. It keeps the park correct on its own. The NCO block (apple,t6030-nco) is mapped, not requested, as on T6020.Not in any shipped distro. No pin includes #4067: ALARM/Fedora
9177b2d474f8, Neo Edgee0ee46a18e33, NixOSca5ea532b8c9. This is amain-only regression.What the row covers on the merge. The row's tree (
be496ae4b232= main4f1bf66c8c90+ this commit + #4213) and the merge tree (6a19720ef4cf) differ in 82 files, none of them in the sleep, NCO, MCA, clock, audio or device tree paths:drivers/gpu/drm/{asahi,apple,radeon},drivers/pci/{iomap,mmap,pci-sysfs}.c,drivers/spi/spi-apple-qspi.c,Documentation/ABI,tools/and selftests (#3485, #3486, #3490, #3340, #4040, #4197).sleep-t6030.hon main is unchanged since4f1bf66c8c90, and main'spcie-apple.cis the same blob as the tested #4213 head.Evidence
/dev/mem): mux words85100100 86100100 87100100 88100100; NCO ch0/ch1 ctrl 0, ch2-480000000.7.3.0-pwren, boot 2c7898d0) and + clk: apple-nco: put the probe-time registers back for a firmware sleep #4200 (7.3.0-pr4200f): timed 2 s at 48k/44.1k = 0.32/0.29 s; cs42l84 PLL lock error x3 before, x5 at the end.7.3.0-mcasw, boot 7d16b5b7): before the sleep 2.049/2.053 s, 0 PLL lines, muxesc5100100 c6100100 87100100 88100100; the deep sleep came back as a cold boot.O=(config7.3.0-f3822+ LOCALVERSION):make W=1 drivers/soc/apple/sleep.o: 0 warnings, 0 errors. Same object with main'ssleep-t6030.h(= main's tree): 0 warnings.scripts/checkpatch.pl --stricton the commit: 0 errors, 0 warnings, 0 checks (Fixes: tag checked against the history).tools/asahi/run-host-tests.py --onlyfor every host test that readssleep.corsleep-t6030.h: t6030-sleep-qblk 2/2, m3-sleep-steps 6/6, sep-suspend-errors 22/22, apple-wdt-tests 10/10, t8132-sleep-refuse, sio-engine-reset, t8122-apcie-wake, display26, dart-sleep-power, radio-sleep-power, pmgr-inherited 1/1 each.