Skip to content

soc: apple: sleep: T8122: keep the audio clocks across deep sleep - #3590

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
satchlj:fix/t8122-sleep-audio-clk-mux
Dec 1, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
satchlj:fix/t8122-sleep-audio-clk-mux

Conversation

@satchlj

@satchlj satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What: Keep the MCA audio clocks across T8122 deep sleep. Deep sleep resets NCO0..3 and parks the four audio clock muxes (clk-mux +0xd8..+0xe4) on the 24 MHz bypass, so audio after a wake runs at 93,750 Hz instead of the rate it was set to. The sleep driver now saves the NCO channels and the mux selections at the commit and restores them on wake, NCOs first.

As T8103 already does, it also enables any stopped NCO channel before the commit and stops it again once the muxes have settled. A mux switch only completes (BUSY, bit 30, clears) while its source runs, and a mux left BUSY on a stopped NCO holds the commit until the watchdog resets the SoC. The mux block comes from a new clk-mux register range on the sleep node, and the NCO block from a new apple,nco phandle. Neither is a fixed address, and without either that half is skipped.
Tested: J613 (MacBook Air 13" M3, T8122) at 0f755337, on main 7ccd92ac with #3504/#3605/#3607/#3608, non-debug, apple_sleep.deep=1 apple_sleep.untested_commit=1: 15/15 real mem/deep cycles (5 and then 10 in a row, RTC wakes after 15 s, no reset). After every wake, a timed capture on the MCA headset-jack PCM ran at the set rate, 48000 and 44100 Hz (4.000 s of frames in 4007–4088 ms). Every sleep after the first was entered with a stopped NCO behind a selected mux. 0 failed units. This loader's device tree has no clk-mux or apple,nco, so the fallback path ran.

  • Also at this head: arm64 LLVM=1 W=1 build of drivers/soc/apple/sleep.o; the apple-sleep KUnit suite (17 tests, 16 passed, 1 skipped); t8122-j613/t8122-j615 DTBs build; dt_binding_check of apple,t8140-sleep.yaml and CHECK_DTBS of t8122-j613.dtb clean.
  • Earlier, without the stopped-NCO handling: a cycle entered with a mux BUSY on a stopped NCO hit the watchdog reset. That is the case this head handles.
    Risk: two-way · M3 (T8122)
    Not yet: the device-tree path (a loader that passes clk-mux and apple,nco); playback after a wake (only capture was timed); reading BUSY at the commit; J615.

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

First hardware row on J613. The fix is inactive on a real machine, because the loader's devicetree has neither clk-mux nor apple,nco.

Setup: candidate kernel 7.3.0-1-rubracand1-ARCH (main 694a5fb3 plus this PR at 92e725ec, #2163, #3504, #3505 and #1490), with apple_sleep.deep=1 apple_sleep.untested_commit=1. Booted one-shot through the test J613-try-kernel.

Results:

  • The driver logs at probe: apple-sleep 2d0700000.sleep-controller: no clk-mux registers: audio clock muxes will not be restored. The DT the test J613 boots comes from its Stage 2 loader, which predates the t8122.dtsi change in this PR.
  • 3/3 real mem/deep cycles succeeded (boot object resumes 0 -> 3, suspend_stats 3/0).
  • Before sleep: muxes +0xd8..+0xe4 = 0x85100100 0x86100100 0x87100100 0x88100100, and silent playback on macaudio pcm1p measures 47,995 / 44,104 / 47,999 Hz.
  • After every wake: all four muxes are 0x80100100 (parked on the 24 MHz bypass), NCO0..3 are reset (ctrl 0x80000000, div/inc 0), and playback runs at 93,764 / 93,743 / 93,743 Hz (24 MHz / 256). That is the bug, unfixed.
  • The stuck-mux precondition never arose: after the wake reset, NCO0 reads as running, so the BUSY case wasn't exercised.

What the PR needs, as I read it: dropping the fixed-address fallback was right for the guidelines, but on current loaders it makes the fix a no-op. Either:

  • the loader DT has to carry clk-mux and apple,nco for J613/J615 (an aura change that ships with this PR), or
  • the driver needs another source for both blocks that isn't a hardcoded address, for example the existing nco node by compatible, plus the mux range from the PMGR clock node.

Leaving this a draft until one of those is in and a row shows 48,000 / 44,100 Hz after wake.

@satchlj
satchlj force-pushed the fix/t8122-sleep-audio-clk-mux branch from 92e725e to 0f75533 Compare November 29, 2026 18:22
@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

0f75533722d6 makes the fix work without a loader devicetree update. Not hardware-tested at this head.

  • NCO block: the sleep node's apple,nco phandle, else the available node matching apple,t8122-nco. The test J613's loader DT has it: clock-controller@2d0044000, 0x14000.
  • Mux block: the sleep node's clk-mux registers, else the PMGR page 0x4000 below the NCO block (0x2d0040000, 0x1000, as t8122.dtsi here describes it). It is mapped, not requested, like the NCO block.
  • What's still a constant: that 0x4000 offset. The test J613's loader DT has no node covering 0x2d0040000: no PMGR clock node, nothing in the sleep node's reg, and no reg on the MCA node. The only other range over it is the error handler's. So the offset sits next to the existing T8122 mux offsets in sleep-t8122.h and is used only when clk-mux is absent.
  • Probe logs: which source was used (no apple,nco: using …, no clk-mux registers: using 0x2d0040000, below the NCO block). A half with no block is skipped with a warning, as before.
  • DT and binding: unchanged. A loader with the updated t8122.dtsi takes the DT path.

Checked at this head:

Still to do: a J613 row showing 48,000 / 44,100 Hz after a deep wake, once the test J613 has its recovery cable back. Staying a draft until then.

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Hardware row at this head on J613 (MacBook Air 13" M3, T8122): 3/3 mem/deep cycles woke, and audio ran at the requested rate after every wake.

Setup: main 972a5665 merged with this PR at 0f75533722d6, #2163 2115ca6e, #1490 16915f57 and #3504 8e6a5b81 (#3504 is needed: an earlier build without it, on main af1413dd, had every deep suspend refused by the GPU with genpd_prepare -16). Loader devicetree unchanged, so the driver uses the fallbacks: no apple,nco: using /soc/clock-controller@2d0044000 and no clk-mux registers: using 0x2d0040000, below the NCO block. Daily command line plus apple_sleep.deep=1 apple_sleep.untested_commit=1. 8 s RTC wakes.

Results:

  • All three cycles reached the commit and came back through the boot object (boot object resumes 0 -> 1 -> 2 -> 3), each waking on NUB.SPMI0.SW3. suspend_stats: 3 successes, 0 failures. No mux commit or wake timeout was logged.

  • Playback rate on the headphone PCM, measured from hw_ptr over 1 s, requested 48,000 / 44,100 / 48,000 Hz:

    • before any sleep: 48,018 / 44,097 / 46,525
    • after C1: 47,827 / 43,993 / 47,919
    • after C2: 47,995 / 44,089 / 47,988
    • after C3: 48,018 / 44,089 / 47,999

    None is near the 93,750 Hz seen after a deep wake without this PR. The spread, including the 46,525 before any sleep, is the 1 s sampling window.

  • At idle NCO0 is stopped (ctrl=0) and mux +0xd8 selects source 5. After each wake +0xd8 reads 0xc5100100, with BUSY (bit 30) set and NCO0 still stopped, and stays so through the next cycle without holding the commit.

Not yet:

  • The case this head adds the fix for is not reproduced. Before C3, a write moving +0xd8 from source 5 to 0, and back again, with NCO0 stopped, completed both times within 200 ms without BUSY. Since BUSY appears after the wakes by itself, cycles 2 and 3 did enter with a mux BUSY on a stopped NCO, but this run does not show what the commit would have done without the keep-running step.
  • Capture rate (pcm2c) was not measured: no capture stream was open.

@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Hardware rows at this head (0f755337) on J613 (MacBook Air 13" M3, T8122, 26.6.2 / 25G83 firmware).

Kernel: main 7ccd92ac with #3605 222e0e6b, #3607 40936f13, #3608 87830763, #3504 8e6a5b81 and this PR 0f755337 merged unchanged. linux-aurora packaging and config, non-debug. Booted once on a read-only root with a tmpfs overlay, with apple_sleep.deep=1 apple_sleep.untested_commit=1. Each cycle is rtcwake -m mem -s 15 with mem_sleep set to deep, pm_test=none.

The boot loader's device tree on this Mac predates the new clk-mux registers and apple,nco phandle, so the fallback ran. At boot the driver logged no apple,nco: using /soc/clock-controller@2d0044000 and no clk-mux registers: using 0x00000002d0040000, below the NCO block.

Audio-rate check, before the first sleep and after every wake: 4.000 s of frames were captured from the MCA headset-jack PCM to /dev/null at 48000 and 44100 Hz, and the capture was timed. A mux left on the 24 MHz bypass would run at 93,750 Hz and finish in about 2 s. Each capture stops its NCO with the mux still selected, so every sleep after the first was entered with a stopped NCO behind a selected mux.

Row Cycles Deep resumes (boot object resumes) Capture time after each wake
A2 5 5/5 (0 → 5) 4010–4017 ms at both rates
B 10 10/10 (0 → 10), no reset 4007–4088 ms at both rates

After each row: 0 failed units, and no new EDAC reports.

Not tested:

  • the path that reads clk-mux and apple,nco from the device tree, because this boot loader does not provide them;
  • playback after a wake. Only capture was timed, and the internal speakers were not used;
  • whether a mux was actually BUSY when a sleep committed. The stopped-NCO state was entered each time, but BUSY itself was not read;
  • rates other than 48000 and 44100 Hz;
  • sleeps longer than 15 s.

@satchlj
satchlj marked this pull request as ready for review December 1, 2026 07:11
@satchlj
satchlj requested review from a team as code owners December 1, 2026 07:11
@satchlj
satchlj requested review from LiamRay11 and maralcbr December 1, 2026 07:11
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at d6c980a3: not ready yet

Check Detail
CI at head no failing: host-tests
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at d6c980a3
Conflicts ok none
PR text ok Risk: two-way · M3 (T8122)

Areas: area:platform

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

Deep sleep resets NCO0..3 and parks the four MCA audio clock muxes
(clk-mux +0xd8..+0xe4) on the 24 MHz bypass, so audio after a wake runs
at 93,750 Hz (24 MHz / 256) instead of the rate it was set to.

Save NCO0..3 and the mux selections at the commit and put them back on
wake, NCOs first. A mux only finishes a switch (BUSY, bit 30, clears)
while its source clock runs, so, as T8103 already does, enable any NCO
channel that is off before the commit and disable it again once the
muxes have settled on wake. Without that, a mux left BUSY on a stopped
NCO holds the commit, and the watchdog resets the machine.

The NCO block comes from the sleep node's apple,nco phandle, else from
the node matching "apple,t8122-nco". The mux block comes from the sleep
node's "clk-mux" registers, else from the PMGR page 0x4000 below the
NCO block, as T8122 lays them out: loaders whose devicetree predates
those two properties still describe the NCO node. A half with no block
found is skipped.

Signed-off-by: Satya Benson <[email protected]>
@satchlj
satchlj force-pushed the fix/t8122-sleep-audio-clk-mux branch from 0f75533 to d6c980a Compare December 1, 2026 08:58
@satchlj

satchlj commented Dec 1, 2026 •

Copy link
Copy Markdown
Member Author

Rebased onto main efa5537b (6361 commits ahead of the old base) to clear host-test failures in unrelated tests on the stale base (apple-scaler-recovery-tests, g17-output-fence-tests). Clean rebase, no conflicts, same diff (3 files, +201/-3). Old head 0f755337, new head d6c980a3. The hardware rows above were taken at 0f755337.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 1, 2026
@satchlj

satchlj commented Dec 1, 2026 •

Copy link
Copy Markdown
Member Author

host-tests at d6c980a3: the failures (ave-recovery-old, brcmf-ps-nap-tests and its mutations) also fail on main itself (Host tests on push 19ee1b5b, which additionally fails g17-render-owed-stamp-tests). None of them cover what this PR changes (the T8122 sleep data, its DT node and binding). No sleep-related host test fails here.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 1, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The applied patch matches the version used in the 15 J613 deep-wake cycles. The save and restore order brings the NCOs up before switching the muxes and returns the forced channels to their prior state. Apple build, DT checks and KUnit passed. The host failures are confined to AVE, Broadcom PS nap and G17 owed-stamp fixtures that already fail on the base. The J613 run exercised the legacy loader fallback. The named clk-mux and apple,nco path still needs a hardware row.

@DjDeveloperr
DjDeveloperr merged commit 684a4a4 into aurora-silicon:main Dec 1, 2026
27 of 30 checks passed
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) ci-failing A check failed at the PR head (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.

2 participants