Skip to content

soc: apple: sleep: Keep the T6030 MCA clock muxes the boot loader set - #4225

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/t6030-mca-clock-muxes
Dec 3, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/t6030-mca-clock-muxes

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: On J516s, main plays every sound about 6.7 times too fast (2 s of audio in 0.30 s), and the cs42l84 headphone codec keeps logging PLL 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), kernel 7.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 main e2d3b330e944: W=1 sleep.o 0 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 only t6030.dtsi has 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:

  • J514s includes the same t6030.dtsi node but doesn't enable the sleep controller, so the changed code doesn't run there today.
  • No peer row is owed: sleep-t6030.h is only built into sleep.o and only reached through the apple,t6030-sleep match. The M3 Max and Ultra trees (t6031, t6032) don't use that node.
Details

Cause. The mca-switch region (0x3500400c0, 4 words, ADT /arm-io/mca-switch reg[2]) holds the MCA audio clock muxes. At boot, aura's clk_set_mca_muxes() sets bits 27:24 of word i to NCO channel 5+i. Read on stock 7.3.0-f3822 (boot b68c4d63, read-only /dev/mem), the words are 85100100 86100100 87100100 88100100. t6030_boot_replay() has written 0 to all four since the provider was added (4d410bca78c5, then through a hard-coded ioremap_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 c6100100 while 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 Edge e0ee46a18e33, NixOS ca5ea532b8c9. This is a main-only regression.

What the row covers on the merge. The row's tree (be496ae4b232 = main 4f1bf66c8c90 + 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.h on main is unchanged since 4f1bf66c8c90, and main's pcie-apple.c is the same blob as the tested #4213 head.

Evidence
  • Stock f3822 (boot b68c4d63, read-only /dev/mem): mux words 85100100 86100100 87100100 88100100; NCO ch0/ch1 ctrl 0, ch2-4 80000000.
  • main + PCI: apple: link PWREN to the GPIO chip's device #4213 (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.
  • First version (park without running the channel, pre-clk: apple-nco: put the probe-time registers back for a firmware sleep #4200 base, 7.3.0-mcasw, boot 7d16b5b7): before the sleep 2.049/2.053 s, 0 PLL lines, muxes c5100100 c6100100 87100100 88100100; the deep sleep came back as a cold boot.
  • This change: receipt in the comment below.
  • Local checks on the merge tree, pc, warm J516s O= (config 7.3.0-f3822 + LOCALVERSION):
    • make W=1 drivers/soc/apple/sleep.o: 0 warnings, 0 errors. Same object with main's sleep-t6030.h (= main's tree): 0 warnings.
    • scripts/checkpatch.pl --strict on the commit: 0 errors, 0 warnings, 0 checks (Fixes: tag checked against the history).
    • tools/asahi/run-host-tests.py --only for every host test that reads sleep.c or sleep-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.

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>
@DjDeveloperr DjDeveloperr added door:two-way Revertible or not, from Merge risk (bot) area:audio Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) labels Dec 3, 2026
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 3, 2026 20:23
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s row at head 9dd2888214bf: 53/53 PASS, 0 FAIL, 0 INCOMPLETE

  • Mac15,7 (J516s, T6030), OS firmware 27.2, Stage 2 1.0.0b17-g683a128b (stock boot.bin), this kernel's own t6030-j516s.dtb.
  • Kernel 7.3.0-mcasw3 = kit commit 7f3a89eb4f8a, tree be496ae4b232: main 4f1bf66c8c90 + this head 9dd2888214bf + PCI: apple: link PWREN to the GPIO chip's device #4213 a313071a0aad (since merged; main's pcie-apple.c is the same blob). Built warm on pc with the J516s config 7.3.0-f3822; only LOCALVERSION differs.
  • Boot 3a6e3fe0-486a-4879-a348-8120a37327b6, 2026-12-03 20:09:03Z to 20:11:25Z. Watchdog (60 s) and dead-man armed, disarmed at the end.
before sleep after deep sleep 1 after deep sleep 2
2 s of audio at 48 kHz / 44.1 kHz 2.058 / 2.061 s 2.036 / 2.023 s 2.039 / 2.053 s
MCA mux words (bit 30 = switch pending) c5100100 86100100 87100100 88100100 c5100100 c6100100 87100100 88100100 same
Wi-Fi back up 8 s 7 s
GPU renders, recoveries rc 0, 0 rc 0, 0 rc 0, 0
PCIe endpoints 5 5, same, none reads ffff 5, same, none reads ffff
  • Both sleeps committed in one boot: boot object resumes 0 -> 1 -> 2, suspend_stats success 0 -> 1 -> 2 with fail 0, 21 s each, wake source NUB.SPMI0.SW3, mem_sleep still [deep].
  • 0 did not park warnings, 0 cs42l84 PLL lock error lines before the sleeps or at the end (main: 3 before and 5 at the end, with 0.32/0.29 s audio).
  • NVMe read and written data verified after each wake. The internal display stays connected. The USB-C controllers are unchanged. 0 GPU fault, DART or AER lines in either sleep window.
  • 0 WARN/BUG/Oops/SError lines (1160, 1600 and 2034 lines read). 0 new error lines against the baseline boots. One new warning line, not judged: phy-apple-atc bN.phy: power domain went off under an active USBN link.

Merge with current main (e2d3b330e944), merge tree 6a19720ef4cf: it differs from the row's tree only in 82 files outside the sleep, NCO, MCA, clock, audio and device tree paths (listed in the PR body), so this row covers the change on the merge. Local checks on that exact tree:

  • make W=1 drivers/soc/apple/sleep.o (warm J516s O=): 0 warnings, 0 errors. Main's tree, same config and object: 0 warnings.
  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
  • Host tests that read sleep.c or sleep-t6030.h (run-host-tests.py --only ...): 47/47 jobs pass.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed area:audio Area from CODEOWNERS (bot) labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Merge readiness at 9dd28882: not ready yet

Check Detail
CI at head running running: apple-build, host-tests, KUnit plan
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 9dd28882
Conflicts ok none
PR text ok Risk: two-way · M3 Pro J516s (T6030) only. The changed code runs only under apple,t6030-sleep, which only t6030.dtsi has and only J516s enables. The commit state doesn't change: the muxes are at 0 during the commit, as they are on main today.

Areas: area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ans runs inside the second apple_sleep_coprocs_stop(), and after that the entry either commits and comes back through t6030_sleep_wake() or panics. enter_cleanup() and undo_regs are 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 enables apple,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 of e2d3b330e944: W=1 sleep.o gives 0 warnings (main also 0), checkpatch --strict is clean, and the host tests that read sleep.c/sleep-t6030.h pass 47/47. Main has since moved to 907e724cfeaf, which only touches drm/asahi.

Merging at this head.

@DjDeveloperr
DjDeveloperr merged commit 0f641ea into main Dec 3, 2026
31 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/t6030-mca-clock-muxes branch December 3, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant