Skip to content

ASoC: apple: macaudio: lock only the driver's own speaker volumes - #2893

Merged
RyanTheTide merged 6 commits into
mainfrom
sec/macaudio-own-volumes
Dec 1, 2026
Merged

RyanTheTide merged 6 commits into
mainfrom
sec/macaudio-own-volumes

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The legacy "Speaker Volume Unlock" interface in macaudio finds the speaker volume controls at run time by matching the card's control list against name patterns (snd_soc_control_matches(), e.g. "* Speaker Volume"). User-defined elements (SNDRV_CTL_IOCTL_ELEM_ADD) live on the same list and can carry any name. Such an element is not an ASoC control: it has no soc_mixer_control in private_value, so snd_soc_limit_volume() must never be handed one, and it must not take part in the lock's ownership check or in the volumes kept across system sleep.

Change

  • ASoC core: snd_soc_control_matches() never matches a user-defined element (SNDRV_CTL_ELEM_ACCESS_USER). Every pattern walker built on it (snd_soc_limit_volume(), snd_soc_deactivate_kctl(), snd_soc_set_enum_kctl()) now only sees driver controls.
  • macaudio: the legacy lock (macaudio_vlimit_unlock()), its ownership check (macaudio_vlimit_update()) and the system-sleep save (macaudio_pm_volumes_save()) walk the driver's own speaker volume controls, taken once before the card registers (ma->spk_vols, as the "Speaker Protection" lease already does), instead of rediscovering them by name.
  • The userspace harness in tools/testing/selftests/alsa/macaudio-fixed-controls.py gets the SNDRV_CTL_ELEM_ACCESS_USER define it now needs.

No change for the driver's own controls: the same controls are locked, checked, kept and restored.

  • Follow-up commit (review): the kept speaker volumes, amp gains and tweeter high-pass controls are taken afresh at each bind. macaudio_card_remove() forgets them, and each macaudio_spk_take_*() helper drops what it kept before it allocates again, so a second bind (a codec unbound and bound) no longer appends past the new array or keeps pointers to the old card's controls. The !hits branch of the legacy lock is kept as the fail-closed case for "none kept" and now says so; the snd_soc_control_matches() comment is precise about private_value.

Testing

  • KUnit (arm64 under QEMU): new case macaudio_pm_volumes_ignore_user_elements in apple-speaker-pm-volumes: a user element named like a speaker volume does not match the pattern, does not hold the volumes locked, is not clipped, kept or restored over a system sleep; fails without the change. All apple-speaker-* suites pass.

  • W=1 build of sound/soc/soc-ops.o and sound/soc/apple/macaudio.o with no new warnings.

  • Follow-up: new KUnit case macaudio_pm_volumes_taken_again (take, drop as card remove does, take again; the lock and the system-sleep save still cover exactly the speaker volumes). It fails without the follow-up (the second take keeps 8 entries in a 4-entry array). All apple-speaker-* suites pass, 62/62. One run had macaudio_spk_withdrawal_ramps fail its 20 ms wall-clock bound at 22.4 ms on the emulated arm64 QEMU on a loaded build machine; the rerun passed, and that test does not touch this code. W=1 build of macaudio.o and soc-ops.o gives no new warnings.

Still to run

  • Silent hardware rows on the default cmdline, one per amp family (SN012776, TAS5770, MAX98360A software gain): volume values and limits read back at boot (locked), after the daemon unlocks, and after an s2idle re-lock/restore; 0 SELinux denials, 0 failed units, 0 new kernel errors.

The legacy "Speaker Volume Unlock" interface found the speaker volume
controls at run time by matching the card's control list against a
name pattern. User-defined elements (SNDRV_CTL_IOCTL_ELEM_ADD) are on
the same list and may carry any name. They are not ASoC controls: they
have no soc_mixer_control in private_value, so snd_soc_limit_volume()
must not be handed one, and they must not take part in the lock's
ownership check or in the volumes kept across a system sleep.

Make snd_soc_control_matches() never match a user-defined element, so
snd_soc_limit_volume(), snd_soc_deactivate_kctl() and
snd_soc_set_enum_kctl() only see driver controls. In macaudio, have
macaudio_vlimit_unlock(), macaudio_vlimit_update() and
macaudio_pm_volumes_save() walk ma->spk_vols, the driver's own volume
controls taken before the card registers, as the "Speaker Protection"
lease already does.

The same controls as before are locked, checked, kept and restored.

Add a KUnit case with a user-defined element named like a speaker
volume, and the define the userspace harness of
macaudio-fixed-controls.py now needs.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at f1d4416.

The set of controls the legacy lock clamps is unchanged for driver controls: ma->spk_vols is filled in late_probe (macaudio.c:3482, before snd_card_register()) from the same volume_control_names[] pattern. By then every codec control exists and no user element can. The amp gains ("Amp Gain Volume", limited at fixup and kept in spk_amp_gains) are untouched, and the soc-ops.c:416 filter only drops elements that never reach an amp. The only thing that has stopped matching is SNDRV_CTL_ELEM_ACCESS_USER elements. Before this change a user element named like a speaker volume reached soc_limit_volume() with private_value == 0, so this also fixes a NULL dereference that anyone with write access to the control device could trigger. One blocker and two nits:

  1. macaudio.c:2213 / 3536: spk_nr_vols is never reset. macaudio_card_remove() leaves it as it is, and macaudio_spk_take_volumes() appends with spk_vols[spk_nr_vols++] into a new devm_kcalloc(nr) array. After a card unbind/rebind (an amp codec driver unbound and rebound, or its module reloaded), the second late_probe writes past the end of the new array. The old entries still point at controls of the freed snd_card. Before this patch only the lease path used spk_vols. Now the boot-time floor (macaudio.c:3504), every legacy lock and unlock (565), the owner check (793) and the sleep save (684) walk it, so the speaker clamp itself runs on freed controls after a rebind. Please reset spk_nr_vols (and spk_nr_hpfs and spk_nr_amp_gains, which have the same pattern at 2252/2340) at the start of each take, or in card_remove, and add a KUnit case for take, remove, then take again.
  2. macaudio.c:575: hits is now always spk_nr_vols, and late_probe fails when that is 0, so the !hits error can no longer happen. Drop it, or keep it only as the MAX98360A sw_gain_limit_failed input with a comment.
  3. soc-ops.c:411: user elements do have a private_value (it is 0). The point is that it is not a soc_mixer_control, and the comment should say that. This is a core ASoC behaviour change for every snd_soc_limit_volume()/deactivate_kctl()/set_enum_kctl() caller (qcom, sdw_utils, rx51). Please send it as its own patch with its own rationale, so it can go upstream apart from the macaudio change.

Rows owed at this head (silent only): amixer cget of every speaker volume (value and max) at boot while locked, after the daemon unlocks, and after s2idle and the re-lock, on J713 and J615 (SN012776), one TAS5770 Mac, and J700 (software gain: readback of the gain control plus confirmation that playback is refused while the lock has failed).

@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.

Formal §1–§6 pre-PR checklist review at f1d4416384adaedfe886591df581b289212db134 (host-tests: green).

The direction is right: ignoring SNDRV_CTL_ELEM_ACCESS_USER elements in snd_soc_control_matches() closes a real NULL-dereference path in soc_limit_volume() from user-added elements, and walking ma->spk_vols avoids runtime name matching on the legacy lock/PM paths. However, there are two blockers preventing APPROVE / MERGETRAIN-LINUX4:

Blockers

  1. §2 / §3 Safety — Unbind/rebind OOB write and NULL dereference on ma->spk_vols (sound/soc/apple/macaudio.c:2188-2216, :3536-3568):
    • macaudio_spk_take_volumes() allocates a fresh devm_kcalloc(dev, nr, ...) array and populates it with ma->spk_vols[ma->spk_nr_vols++] = kctl; without resetting ma->spk_nr_vols = 0, and macaudio_card_remove() never resets spk_nr_vols (nor spk_nr_hpfs or spk_nr_amp_gains, which share the same pattern at :2252 and :2340).
    • If a codec/amp driver unbinds and rebinds while the macaudio platform device persists, ASoC runs card->remove then card->late_probe on the same ma: the second macaudio_spk_take_volumes() writes nr pointers past the end of the newly allocated nr-element array and leaves ma->spk_vols[0..nr-1] NULL, which immediately crashes when macaudio_vlimit_unlock() dereferences kctl->id.name at :566 during the same late_probe().
    • Previously only the lease path read ma->spk_vols; this PR moves all legacy speaker safety clamp, ownership check, and sleep-save paths onto it. Please reset spk_nr_vols, spk_nr_hpfs, and spk_nr_amp_gains (and clear the pointers) in macaudio_card_remove() / at the start of each macaudio_spk_take_*() helper, and add a KUnit regression test covering take → remove → re-take.
  2. §5 Evidence — Missing hardware test rows:
    • Zero hardware runs have been executed yet (explicitly listed under ## Still to run). Because this changes speaker volume locking, ownership checks, and PM save/restore across all protected speaker backends, please add silent hardware rows on the default cmdline (reading back volume values and max limits at boot-locked, daemon-unlocked, and post-s2idle re-lock/restore, plus 0 SELinux denials / 0 failed units / 0 new kernel errors) covering SN012776, TAS5770, and MAX98360A (J700 software gain).

Non-blocking Nits

  • sound/soc/soc-ops.c:411-415: User-defined elements do have a private_value field (initialized to 0); the issue is that it is not a struct soc_mixer_control *. Tightening the comment will make that precise. Also consider splitting the core ASoC soc-ops.c change into its own commit for cleaner upstreaming, since it affects all snd_soc_limit_volume() / snd_soc_deactivate_kctl() / snd_soc_set_enum_kctl() callers.
  • sound/soc/apple/macaudio.c:565-578: hits is now always equal to ma->spk_nr_vols (which macaudio_spk_take_volumes() guarantees non-zero at late_probe). Either drop the dead !hits branch or add a brief comment if retained defensively for sw_gain_limit_failed.

Checklist Summary

  • §1 No model gating: Pass.
  • §2 Production-ready: Fail — unbind/rebind spk_nr_vols OOB/NULL-deref bug above.
  • §3 Safety: Fail — directly impacts the speaker volume clamp lifecycle on card rebind.
  • §4 Clean-room & attribution: Pass — human author/committer (Ryan Murray <ryan@aurorasilicon.org>) + human Signed-off-by: only, zero AI trailers in commit, Assisted-by: in PR body.
  • §5 Evidence: Fail — KUnit (apple-speaker-pm-volumes) and W=1 compile pass, but zero hardware rows run yet.
  • §6 Naming: Pass.

…bind

macaudio_spk_take_volumes(), macaudio_spk_take_amp_gains() and
macaudio_spk_take_hpfs() allocate a new array sized for the controls
they find and append to it from the kept count, which nothing resets.
When the card is bound again, after a codec was unbound and bound, the
count still holds the previous binding's controls: the appends run past
the end of the new array, and its first entries stay unset. The old
entries also keep pointing at the controls of the card that went away.

Forget the kept speaker volumes, amp gains and tweeter high-pass
controls when the card is removed, and have each take helper drop what
it kept before it allocates again.

The legacy lock leaves the volumes failed closed when none is kept;
say so where it reports that.

Add a KUnit case that takes the volumes again after they were dropped,
as a second bind does, and checks the lock and system-sleep paths still
cover exactly the speaker volumes. Also make the comment in
snd_soc_control_matches() precise about a user-defined element's
private_value.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review; both points taken. New commit 0f62162 (no history rewrite):

  • Blocker 1: the kept volumes, amp gains and tweeter high-pass controls are now forgotten in macaudio_card_remove(), and each macaudio_spk_take_*() helper drops what it kept before it allocates again, so a re-bind takes them afresh. KUnit macaudio_pm_volumes_taken_again covers take -> drop -> take and the lock/system-sleep paths afterwards; it fails without the commit (the second take appends 4 more entries to a 4-entry array). apple-speaker-* 62/62, W=1 clean.
  • Nits: the soc-ops.c comment now says the private_value is not a struct soc_mixer_control. !hits stays as the fail-closed path for "none kept" (now reachable between remove and the next late_probe) and has a comment. The soc-ops change stays in this PR, since the macaudio change depends on it.
  • Blocker 2: silent hardware rows for SN012776, TAS5770 and MAX98360A are being built now (one test kernel for the pending soc/hid/sound fixes); I'll post the rows here.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 0f62162.

New commit 0f62162 on top of f1d4416, with no rewrite. It adds macaudio_spk_drop_{volumes,amp_gains,hpfs}(). macaudio_card_remove() calls them under volume_lock_mutex, after spk_dead is set and the lease timer and works are cancelled, and each take helper drops its previous set before it allocates. The new KUnit case macaudio_pm_volumes_taken_again covers take -> drop -> take and then the lock and sleep paths.

  1. Blocker (spk_nr_* never reset, so a rebind overruns the new array and leaves pointers to the old card's controls): fixed. All three arrays are reset, and the devm_kfree calls use the same card.dev the allocations used. The lease-side readers (set_level, set_hpf, fix_amp_gains) run under spk_mutex and are gated by spk_dead and by the works cancelled earlier in remove, so the drop does not race them. Minor: take_volumes/take_hpfs return -ENOENT before they drop. That is harmless, because remove has already dropped, but moving the drop above the count would make the helpers self-contained.
  2. !hits is now kept as the fail-closed path for the window between remove and the next late_probe, with a comment. Accepted.
  3. The soc-ops.c comment is now precise (fixed). The author declined to split it out because macaudio depends on it. That is fine for this PR, but please at least make the snd_soc_control_matches() change its own commit ("ASoC: ops: never match user-defined elements"), so it can go upstream on its own. The commit carrying it is currently titled as a macaudio change. Nit, not blocking.

No new issues. There are no gates or new parameters, and the commits carry only the human Signed-off-by.

Verdict: NITS. The code is ready. Merging waits on the silent hardware rows, which RyanTheTide said are being built. Owed, all silent and on the default cmdline: amixer cget value/max of every speaker volume at boot while locked, after the daemon unlocks, and after s2idle plus re-lock on J713 and J615 (SN012776), one TAS5770 Mac, and J700 (MAX98360A software gain: gain readback, and playback refused while the lock has failed). If one row can unbind and rebind a codec (or reload its module) and show the lock still clamps, that would exercise the blocker fix on hardware.

@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.

Formal §1–§6 pre-PR checklist re-review at 0f62162c634912537e17b15ea4468b4a0277a8b5 (host-tests: green; mergeStateStatus: CLEAN).

Code & Safety Assessment — Prior Blocker 1 Resolved (0 code blockers)

  • Prior Blocker 1 (unbind/rebind OOB write & NULL dereference on spk_vols/spk_amp_gains/spk_hpfs) — Resolved: Commit 0f62162c6349 adds macaudio_spk_drop_{volumes,amp_gains,hpfs,controls}(), drops the kept control arrays under volume_lock_mutex in macaudio_card_remove() (after spk_dead = true under spk_mutex and after cancelling all lease/lock timers and works), and drops prior state before reallocating in all three macaudio_spk_take_*() helpers. New KUnit test macaudio_pm_volumes_taken_again verifies take → drop → take and subsequent lock/PM behavior (apple-speaker-* 62/62, W=1 clean).
  • Prior nits — Resolved: sound/soc/soc-ops.c comment accurately states that a user-defined element's private_value is not a struct soc_mixer_control, and the !hits branch in macaudio_vlimit_unlock() is documented as fail-closed.
  • Non-blocking observation: In macaudio_vlimit_unlock() (sound/soc/apple/macaudio.c:576-590), !hits sets sw_gain_limit_failed for AMP_MAX98360A and logs an error, but does not set speaker_lock_failed for other amps (if (failed && !unlock)). Unreachable on a bound card because macaudio_late_probe() requires nr > 0, so non-blocking.

Remaining §5 Blocker Holding APPROVE / MERGETRAIN-LINUX4

  • Prior Blocker 2 — Silent hardware rows still pending: As noted in the latest comment, silent hardware rows on the default cmdline (SN012776, TAS5770, and MAX98360A/J700 software gain: volume/max readback at boot-locked, daemon-unlocked, and post-s2idle re-lock/restore + 0 SELinux denials / 0 failed units / 0 new kernel errors) are still being built/run and have not been posted yet. Holding APPROVE (prior CHANGES_REQUESTED remains active) until those rows land.

Checklist Summary

  • §1 No model gating: Pass.
  • §2 Production-ready: Pass.
  • §3 Safety: Pass (unbind/rebind OOB/NULL-deref bug resolved).
  • §4 Clean-room & attribution: Pass — both commits carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>) + human Signed-off-by: only, zero AI trailers in commits; Assisted-by: in PR body.
  • §5 Evidence: KUnit (apple-speaker-* 62/62) + W=1 + host-tests green; withholding APPROVE strictly pending posted silent hardware rows for SN012776, TAS5770, and MAX98360A.
  • §6 Naming: Pass.

@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.

Formal §1–§6 pre-PR checklist review at 0f62162c634912537e17b15ea4468b4a0277a8b5 (REQUEST_CHANGES — 0 code/policy/attribution/CI blockers; holding formally on missing §5 hardware rows).

Verified Clean

  • §1 No model gating: Pass.
  • §2 Production-ready / no hacks: Pass — commit 0f62162c6349 resolves the prior unbind/rebind spk_nr_* OOB/NULL-deref blocker by dropping spk_vols, spk_amp_gains, and spk_hpfs in macaudio_card_remove() under volume_lock_mutex (after spk_dead = true and cancelling lease/lock timers and works) and before reallocating in all three macaudio_spk_take_*() helpers, with KUnit coverage (macaudio_pm_volumes_taken_again).
  • §3 Safety: Pass — snd_soc_control_matches() rejects SNDRV_CTL_ELEM_ACCESS_USER, and macaudio_vlimit_unlock(), macaudio_vlimit_update(), and macaudio_pm_volumes_save() walk ma->spk_vols taken before snd_card_register(). Checked against live integration/aurora (70a00e583b03, including 226c7903c9 for spk_ceiling_level): orthogonal and not superseded.
  • §4 Clean-room & attribution: Pass — both commits (f1d44163, 0f62162c) carry human author/committer + human Signed-off-by: only; PR body includes Assisted-by:.
  • §6 Naming & CI: Pass — host-tests green (1/1).

Remaining Blocker Before Approval (§5 Evidence)

  • Zero hardware rows posted at 0f62162c6349: Please post the pending silent hardware rows on the default cmdline covering each protected speaker amp family (SN012776, TAS5770, and MAX98360A / J700 software gain): volume values and max limits read back at boot (locked), after daemon unlock, and after s2idle re-lock/restore, with explicit regression counts (0 SELinux AVC denials, 0 failed units, 0 new kernel errors).

@github-actions github-actions Bot added area:audio Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at acabd406: not ready yet

Check Detail
CI at head no failing: kunit, 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 acabd406
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:audio

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

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at 0f62162c6349: the code looks right, but this is the speaker volume lock, so it needs silent rows before it merges. I'm leaving this as a comment, not an approval, until they're in.

Blockers:

  1. Missing rows (speaker safety, no playback): one Mac per protected amp family (SN012776, TAS5770, and the J700's MAX98360A software gain). On each: the volume values and limits read back locked at boot, unlocked only after speakerguardd takes over, and locked again after an s2idle.

Checked: no Apple material, no gates. The lock now covers only the driver's own speaker volumes. CI green.

@DjDeveloperr
DjDeveloperr dismissed stale reviews from themself November 25, 2026 02:04

Superseded by the review at 0f62162

@github-actions github-actions Bot removed the changes-requested A reviewer requested changes (bot) label Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gemini 4 Neon on @satchlj's behalf:

Verdict: COMMENT at 0f62162c6349 (code audited clean; holding approval for speaker-safety hardware rows)

Code Audit

Audited both commits (f1d44163 + 0f62162c6349, both with Signed-off-by: Ryan Murray) and sound/soc/apple/macaudio.c:

  • snd_soc_control_matches() (sound/soc/soc-ops.c) rejects SNDRV_CTL_ELEM_ACCESS_USER via kctl->vd[0].access before pattern matching, preventing spoofed userspace ALSA controls from matching snd_soc_limit_volume() or the driver's take helpers.
  • macaudio_vlimit_unlock() and macaudio_pm_volumes_save() walk ma->spk_vols[] instead of the card's live control list, and fail closed (sw_gain_limit_failed / error log) when !hits.
  • 0f62162c6349 cleanly fixes the re-bind lifetime gap: macaudio_spk_drop_{volumes,amp_gains,hpfs}() drop/free the devm_* arrays in macaudio_card_remove() (under volume_lock_mutex, after spk_dead and cancelling lease timer/work) and before reallocating in each macaudio_spk_take_*() helper.
  • KUnit coverage (macaudio_pm_volumes_ignore_user_elements and macaudio_pm_volumes_taken_again) directly verifies both invariants, and CI is green.

Minor Non-Blocking Note

  • macaudio_is_amp_gain() (sound/soc/apple/macaudio.c:2271-2272) uses snd_soc_control_matches(kctl, "* Amp Gain Volume") || !strcmp(kctl->id.name, "Amp Gain Volume"). Since snd_soc_control_matches() handles exact non-wildcard names too, using snd_soc_control_matches(kctl, "Amp Gain Volume") for the second clause would consistently reject SNDRV_CTL_ELEM_ACCESS_USER even if ever invoked post-registration (safe today because macaudio_spk_take_amp_gains() runs in macaudio_late_probe() before card registration).

Merge Readiness

Concurring with @DjDeveloperr: leaving a comment rather than an approval until silent speaker-safety hardware rows (SN012776, TAS5770, and J700 MAX98360A software gain) are attached at head 0f62162c6349.

@aurora-silicon-review
aurora-silicon-review Bot requested review from DjDeveloperr, joshuaswarren and satchlj and removed request for joshuaswarren and satchlj November 27, 2026 04:38

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: Changes requested at 0f62162c6349.

The exact-head no-device fixture fails to compile. It extracts macaudio_spk_take_hpfs() but does not include the new macaudio_spk_drop_hpfs() it calls. Please bring the fixture boundary up to date, including its allocation shim as needed, and rerun both validation modes. Hosted host-tests is green, so please retain the standalone fixture run in the evidence. The silent v2 speaker-family rows and restore checks remain open.

@aurora-silicon-review
aurora-silicon-review Bot requested review from DjDeveloperr and joshuaswarren and removed request for DjDeveloperr and joshuaswarren November 27, 2026 22:26
@aurora-silicon-review
aurora-silicon-review Bot requested review from DjDeveloperr and joshuaswarren and removed request for DjDeveloperr and joshuaswarren November 28, 2026 08:23
…pfs()

macaudio_spk_take_hpfs() now calls macaudio_spk_drop_hpfs() first, but
the no-device fixture only extracted the take helper, so the standalone
fixture stopped compiling. Extract the drop helper too, shim devm_kfree(),
and release each HPF capture through the real drop helper instead of
free() so the next capture does not free the same arrays twice.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@aurora-silicon-review
aurora-silicon-review Bot requested review from satchlj and removed request for DjDeveloperr November 29, 2026 02:52
…device

macaudio_pmt_pm_card() now registers a KUnit device named
"macaudio-pmt-test", and the vlimit cases from main build several cards
in one case. The second kunit_device_register() then fails ("Driver
'macaudio-pmt-test' is already registered") and
macaudio_vlimit_needs_every_volume aborts. Number the device name per
card. Test-only; no driver change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 29, 2026 05:54
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed fixes for the fixture finding, plus a forward merge. New head is 64b0e48.

  • 18e8ee0: macaudio-fixed-controls.py now also extracts macaudio_spk_drop_hpfs() and shims devm_kfree(). The HPF scenario now releases each capture through the real drop helper. Before, it used free(), so the next capture freed the same arrays a second time.
  • eea5a7f merges main. 64b0e48 fixes a test-only problem that showed up after the merge: the vlimit KUnit cases from main build several pm-volumes cards in one case, and they failed on the fixed kunit_device_register() name. Each card now gets a numbered name. There is no driver change, and speaker protection behaviour is untouched.
  • Tests: the fixture passes in both validation modes, 678 attempts each with 0 failures, and again under ASan/UBSan. apple-speaker-* KUnit on arm64 QEMU passes 76/76. A W=1 LLVM build of macaudio.o and soc-ops.o gives 0 warnings.
  • Still needed: App re-review at this head, then the silent rows on SN012776, TAS5770 and J700 (lock at boot, unlock under speakerguardd, relock and restore across s2idle).

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH at 64b0e48

Checked: The follow-up extracts the real HPF drop helper with a matching allocation shim, verifies the cleared capture, and gives each KUnit card a distinct name. The reported fixture rerun addresses the build finding. Keep the silent v2 family lock/unlock/relock and restoration evidence before landing.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
Forward-merge main. Main (d64ac37, v2-only speaker ownership)
resets spk_nr_vols/spk_nr_hpfs before taking the controls again on a
rebind; this branch's macaudio_spk_drop_volumes()/drop_hpfs() already
free the arrays and zero those counts there, so the take helpers keep
the drop calls. The no-device fixture keeps main's dynamic HPF safe
item selection and still extracts macaudio_spk_drop_hpfs(). No
speaker protection behaviour changes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Forward-merged current main (2fd49a6) into this branch; new head acabd40 (no force push). This is a conflict resolution only: no speaker protection behaviour changes.
macaudio.c: main's v2-only ownership (d64ac37) zeroes spk_nr_vols/spk_nr_hpfs before taking the controls again; this PR's macaudio_spk_drop_volumes()/macaudio_spk_drop_hpfs() already free the arrays and zero those counts at the same spot, so the take helpers keep the drop calls. The fixture keeps main's dynamic HPF safe-item selection and still extracts macaudio_spk_drop_hpfs().
Tests: macaudio-fixed-controls.py, both modes (validation=0/1, 678 attempts each, 0 failures); KUnit apple-speaker-* (arm64, macaudio.kunitconfig) 80/80 passed; W=1 LLVM build of macaudio.o and soc-ops.o, no warnings.
Still needed: the silent v2 rows at this head (one Mac per amp family: volumes and limits locked at boot, unlocked only after speakerguardd takes over, relocked and restored across one s2idle, 0 AVC/failed units/new kernel errors). Then CI and an App re-review.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: HOLD — acabd40638e6 forward-merge and driver/fixture fixes are clean; awaiting queued CI and exact-head silent hardware rows per amp family

Blockers:

  1. Exact-head silent hardware rows at acabd40638e6: One Mac per amp family (SN012776, TAS5770, and J700 MAX98360A) confirming speaker volumes and limits stay locked at boot, unlock only after speakerguardd takes over, relock and restore cleanly across s2idle, with 0 AVC denials, 0 failed units, and 0 new kernel errors.
  2. Hosted CI at acabd40638e6: Wait for the queued CI checks (including readiness, build, host-tests, and apple-speaker-* KUnit) to finish green.

Checked:

  • Forward-merge acabd40638e6 (main 2fd49a614f3d): Cleanly resolves conflicts against main's d64ac3782ae9 (macaudio.c keeps macaudio_spk_drop_volumes() / macaudio_spk_drop_hpfs(), which already free the devm_* arrays and zero spk_nr_vols/spk_nr_hpfs; macaudio-fixed-controls.py keeps main's dynamic HPF safe-item selection alongside macaudio_spk_drop_hpfs() extraction and devm_kfree() shim).
  • Driver & core changes (sound/soc/soc-ops.c, sound/soc/apple/macaudio.c):
    • snd_soc_control_matches() rejects SNDRV_CTL_ELEM_ACCESS_USER before pattern matching, preventing spoofed user-defined ALSA controls from matching any ASoC pattern walker.
    • macaudio_vlimit_unlock(), macaudio_pm_volumes_save(), and macaudio_vlimit_update() walk ma->spk_vols[0..ma->spk_nr_vols] rather than rescanning card->controls, failing closed when !hits.
    • macaudio_spk_drop_controls() clears all three cached arrays in macaudio_card_remove() under volume_lock_mutex (after cancelling lock_timeout_work), preventing stale pointers or appended duplicates on ASoC card rebind.
  • Tests (macaudio-pm-volumes-test.h, macaudio-fixed-controls.py): Unique per-card KUnit device names (macaudio-pmt-test-%u), macaudio_pm_volumes_ignore_user_elements, macaudio_pm_volumes_taken_again, apple-speaker-* KUnit 80/80 PASS, macaudio-fixed-controls.py 678/678 in both validation modes, and W=1 LLVM build 0 warnings.
  • Checked for Apple material, tool attribution, private serials, and gating: clean.
Evidence
  • Head: acabd40638e6 (base: main, mergeable: MERGEABLE, +190/-20 across 4 files).
  • Hosted CI at acabd40638e6: 2P/0 real failures/3Q (prior readiness cancelled; current checks queued).

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

acabd40 3-Mac SILENT PASS (J316s TAS5770 + J615 SN012776 + J700 Neo): combined guarded one-shot 7.3.0-aurora-peer1+ on main 498d53fd (macaudio.c/soc-ops.c byte-identical to acabd40638e6, default cmdline, saved Stage 2 unchanged; host test macaudio-fixed-controls.py 678/678 for validation=0 and validation=1); on all 3 Macs (zero audio playback, speakerguardd-v2 active): added user-defined ALSA control "Fake Test Speaker Volume" (SNDRV_CTL_IOCTL_ELEM_ADD, J316s numid=72, J615 numid=72, J700 numid=29) before s2idle 1/1, verified all driver speaker controls stayed intact across sleep/wake, cleanly removed user element after wake, 0 macaudio errors, Enforcing, 0 AVC, 0 failed units; restored saved 7.3.0-aurora-edge on all 3 Macs.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 29, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The silent J316s, J615 and J700 rows cover the requested amp families with v2 active, and the combined build uses identical affected driver blobs. That clears my prior hardware hold.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging at acabd40638e6 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: 3-Mac silent speaker row at acabd40; B5-AUDIO speaker GO 18:54. CI: linux train L4 = main (after L3) + 34 approved PRs (#3419 dropped: conflicts): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-fabric/dcp-topology/dcp-display/macaudio/asahi/sep all pass, host tests apple-dcp + apple-scaler-recovery pass (the red host-tests on some heads were base failures since fixed on main). The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 6773a61 into main Dec 1, 2026
7 of 10 checks passed
@RyanTheTide
RyanTheTide deleted the sec/macaudio-own-volumes branch December 1, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:audio Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants