Repository navigation
ASoC: macaudio/tas2764: speakers safe and quiet across sleep and protection withdrawals - #1077
Merged
Merged
Conversation
…and click-free Three problems with how speaker protection is withdrawn, seen with the protection supervisor running across system sleep and in the audible kill test: 1. The floor after a withdrawal writes the amps through their controls' put callbacks from inside the kernel: from the owner's file closing, the lease timer's worker or a release. A write from userspace waits for the card to be powered (snd_power_ref_and_wait() in the control ioctls); these do not. An owner that dies while the card resumes (a supervisor killed by its watchdog at thaw) then writes the amps while their codecs sync their registers and ASoC brings the streams back. Wait for the card to reach D0 before any amp write of the floor, after closing the start gate and queueing the stream stop, which happen at once as before. A grant on a card that is not powered returns -EBUSY. (A card going away still gets the floor.) 2. alsactl restore writes every writable control it saved, and at boot fails on "Speaker Protection" and "Speaker Protection Crossover" with -EPERM: only their owner may write them. They are state between the kernel and the protection supervisor, not mixer settings. Mark both INACTIVE (and VOLATILE) so that mixers and alsactl's restore leave them alone; the owner's writes are unchanged, as the core does not gate writes on INACTIVE. 3. A release, the owner gone or a new owner stopped a playing stream with the amps still at the operating gain: the stop is a click (a single 100 ms analysis block at -0.4 dBFS on a J616s, above the music's -3.1 dBFS peak). On amps with a digital gain in 0.5 dB steps (SN012776/TAS2764, TAS5770), ramp the gain down in eleven roughly even steps from -2 to -50 dB, at least 0.5 ms apart, while the stream still plays, then stop it and set the floor. The start gate is closed first, the ramp never runs past the lease's end and takes at most 10 ms, and it runs only on a powered card. A lapsed lease, a system sleep and a failure still withdraw at once, as does the J700's software gain. Refused speaker starts stay quiet in the kernel log (quiet_trigger_eperm) and are counted; the next grant reports them once. KUnit: the ownership controls' access, the ramp (falling steps ending at the floor, a withdrawal under 20 ms, only the speaker volumes), no ramp past the lease or on the hard withdrawals or the J700, a floor that waits for D0 with the gate already closed, and a grant that needs D0. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
A regmap debugfs dump of a TAS2764/SN012776 ("registers") reads every
register of every page and leaves all of them in the cache. The next
system sleep marks the cache dirty, and the resume's regcache_sync()
then writes back everything cached as raw blocks of contiguous
registers: from the page 1 quirk register at 0xb3 through the page 6
quirk registers at 0x313, across pages the amp reserves. The amp never
completes that transfer, the I2C controller stays in its transaction
(SMSTA 0x10850140) and every amp on the bus is gone until the next
boot:
i2c-apple 23501c000.i2c: Timeout, status 0x10850140
tas2764 3-003c: Unable to sync registers 0xb3-0x313. -62
i2c-apple 23501c000.i2c: Bus is still stuck (status 0x10850140 ...)
A speaker wiring self-check that reads the amps' registers through
debugfs does exactly that dump, so the first sleep after such a check
broke the speakers on the J413 (M2), J316 (M1 Pro) and J616s alike.
The controller reset of commit 1dcabed ("i2c: pasemi: Reset a
controller that stays stuck in a transaction") recovers the bus, but
the write that stuck it is the bug.
Give the regmap a writeable_reg: page 0, the page 1 and page 6
registers of the quirk sequences and the SDOUT high-impedance masks,
and TI's quirk pages. regcache_sync() skips registers that are not
writeable, so a cache sync writes back only what the driver wrote.
Every register the driver and its quirk sequences write stays
writeable, which KUnit checks.
Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
RyanTheTide
marked this pull request as ready for review
November 7, 2026 05:04
RyanTheTide
added a commit
that referenced
this pull request
Nov 7, 2026
Brings aurora-wip up to the tested release branch: CTXR execmem (#985, #1079), KFIX speaker sleep and resume fixes (#1077, #1080), JPEG v2 (#1072), Jonathan's G17 and USB work (#1073-#1076), brcmfmac flowring count (#1081), ANE H16 startup restart (#1066) and the Touch ID per-prompt match (#904). Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
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.
Kernel half of the speakerguardd v2 (Plan B) ship blockers: speakers broken after system sleep on the J316 (M1 Pro), J413 (M2) and J616s, alsactl errors at boot, and a click when protection is withdrawn.
The stuck speaker buses after a resume (tas2764)
Unable to sync registers 0xb3-0x313. -62, i2c-appleTimeout, status 0x10850140andBus is still stuckon every speaker bus, at the first sleep after a boot. Cause: a regmap debugfs dump of the amps (the speaker wiring self-check reads/sys/kernel/debug/regmap/<amp>/registers) leaves every page of the amp in the regmap cache; the resume'sregcache_sync()then raw-writes one block from the page-1 quirk register 0xb3 through page 6, across reserved pages. The amp never completes it and the controller stays in its transaction. Reproduced on demand on the M2 with fleet18 (one freeze after a boot whose self-check ran).Fix: a
writeable_regfor the TAS2764/SN012776 regmap that lists the registers the driver writes, so a cache sync writes back only those. KUnit checks that every register the driver and its quirk sequences write is still writeable, and that the reserved pages are not.Protection withdrawals (macaudio)
Cannot write control ... Invalid argument/Operation not permitted(2 lines on every M2 boot). Owner writes are unchanged.Not in this PR
MCA loses its cluster registers across system sleep when a speaker PCM stays open through it (with the PCMs closed before sleep, which speakerguardd now does, nothing is in use). Restoring them at resume hangs the J316, so that change is still WIP on
kfix/mca-sleep-restore-wipand needs to go through the clock-then-domain order of the prepare path.Testing
macaudio_spk_timer_beats_a_fifo_spinnerfailed once on a loaded box, as before this series); tas2764 11/11 (2 new).🤖 Generated with Claude Code