Repository navigation
kboot_audio: pass amp-tx-zd-config on only where the card's idle masks agree - #291
scottjones wants to merge 3 commits into
Conversation
|
Thanks for tracking down the silent J613 speakers. The check at src/kboot_audio.c:200 selects on the SoC compatible, but the cause you describe is a property of the data: the ADT row is the complement of the card's idle masks, so as "slots to zero" it covers another amp's sense slots. Could the check test that directly on every Mac, for example refuse an amp-tx-zd-config row that would zero slots the card assigns to another amp's IV sense, logging why? That protects speaker sensing everywhere instead of only on T8122. If the rows truly equal the card masks on all other Macs, it may also be simpler to stop passing the row whenever the card carries idle masks. A pasted before/after log or SDOUT register readout from the J613 would help. |
6366118 to
436058c
Compare
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks. This is the data-driven shape Ryan asked for. The row goes on only where the card's idle mask agrees with it. An amp whose row contradicts the mask goes back to the card's own mask, which is how it was set up before aura passed the rows on.
I checked speaker protection hardest. The change only affects which SDOUT slots an amp drives zeros on when idle. It doesn't touch the gain, level or limit rows (bop-config, amp-dcblocker-config and speaker-config go through as before), so no limit loosens, and nothing becomes audible without the speaker daemon. Where the check fires, the amp goes back to the long-standing card-mask behaviour, and aura logs it (src/kboot_audio.c:204). So any Mac other than the J613 that prints the "contradict" line is one to look at.
Two things before it merges:
- format-check fails on your own lines. At
src/kboot_audio.c:123-124, the comment abovedt_card_idle_mask()runs past 100 columns.clang-format -i src/kboot_audio.cfixes it. - DCO. 436058c has
Assisted-byandCo-Authored-Bylines but no Signed-off-by, which docs/licensing.md asks for. Your earlier version had one.
Once both are in and CI is green, I'll merge. These rows come after the merge, with a revert ready:
- a J613 boot of this version: both woofers log the "contradict" line, SDOUT_HIZ reads back as on 7.2, and speakersafetyd keeps running;
- a no-regression boot on the other SN012776 Macs that we and Ryan have: no "contradict" line in the aura log, and the speaker daemon starts as before.
RyanTheTide
left a comment
There was a problem hiding this comment.
No code blockers. Dj's two merge items are still open on 436058c, which is unchanged since his review.
Earlier points:
- SoC-compatible check (our 11-19 comment): resolved in code. The row is now kept back only where the card's idle mask for that amp contradicts it (src/kboot_audio.c:186-208), on every Mac, and the log says why. Only the idle-slot row changes:
bop-config,amp-dcblocker-configandspeaker-configstill go through as before, so no level or limit becomes looser. - Before/after log or SDOUT readout from the J613 (ours): still open. The commit message says this version has not run on hardware.
- format-check (Dj): still failing. src/kboot_audio.c:123 is 117 columns.
- Signed-off-by (Dj): still missing from 436058c.
Findings:
- The PR title and description still describe the old T8122-only version ("don't pass amp-tx-zd-config on to T8122 boards", "except on T8122"). Please update both to the data-driven rule in the commit message, so the merge commit doesn't record a SoC gate that no longer exists.
- src/kboot_audio.c:139
dt_card_idle_mask()matches only nodes named exactlycodec. A card that names its codec subnodescodec@0,codec@1(allowed by the binding) is never matched, so its rows go on unchecked, which is today's behaviour. Matching the name up to@(or usingstrncmp(name, "codec", 5)withname[5]either NUL or@) closes that gap. Not needed for the J613 tree. - Evidence: the J613 row should be shown with this exact version, and with the speaker daemon we ship rather than speakersafetyd. Pass if both woofers print the
contradictline, SDOUT_HIZ reads back as the card mask, the IV sense is valid with no protection trip, and the speakers play.
Hardware rows we can run:
- J615 (M3 Air 15-inch, T8122): this head as Stage 2. Pass if the aura log has the
contradictline for each amp whose row disagrees with the card mask, the SN012776 SDOUT_HIZ registers read back as the card's mask, and speakerguardd reports valid IV sense for every channel at low-level playback. - M1 Pro and M2 (no-regression): pass if there is no
contradictline, theapple,amp-tx-zd-configproperties in /sys/firmware/devicetree match the previous boot, and speakerguardd starts as before.
Assisted-by: LLM (Claude:Opus 5.5)
|
Nothing else in the tree trips the check. Assisted-by: LLM (Claude:Opus 5.5) |
|
Blockers: 1. The open items from the earlier reviews (format-check at src/kboot_audio.c:123, the missing Signed-off-by on 436058c, the T8122 title and description) still stand on this head; not repeated here.
Checked and fine: the n-th codec index matches macaudio's HW row: J613 and J615 on this head as Stage 2, with the speaker daemon that ships: the aura log prints every amp's row and decision. SDOUT_HIZ_1..4 on all amps read back without a zero bit on any other amp's imon/vmon slot. IV sense is valid on every channel at low-level playback and protection does not trip. Plus one no-regression boot on an M1 Pro or M2: no Assisted-by: LLM (Claude:Opus 5.5) |
…s agree On the 13" M3 Air (J613) the speakers stay silent and speakersafetyd stops with "Left Tweeter: Negative power, bad ivsense data?". The cause is the amp-tx-zd-config row aura passes on. The SN012776 driver takes the row as the amp's SDOUT slots to drive zeros on when idle (its first four bytes, slot 0 in bit 0), in place of the sound card's idle mask for that amp. On the J613 each woofer's row is the complement of the card mask its speakers worked with on 7.2: - left woofer: row f0 f0 f0 ff, mask 0x0f0f; - right woofer: row 0f 0f 0f ff, mask 0xf0f0. With the rows, SDOUT_HIZ_1..4 read back f0 f0 f0 ff and 0f 0f 0f ff, and speakersafetyd reports bad IV sense and stops. Decide by the data instead of by the SoC. For each amp, look up the card's idle mask: dai-tdm-slot-tx-idle-mask-<n>, in idle mode "zero", of each dai-link that lists the amp as its n-th codec, which is the mask macaudio applies. Where the card has one and the row's slots contradict it on the bytes up to the mask's highest slot, the row is not passed on, the log says why, and the card's mask stays in charge. The amp is then set up as before aura passed the rows on. The row also stays back when two dai-links give the amp different masks. Where the card has no mask for the amp, or its codec list is not one phandle per amp, the row goes on as before. Why compare, rather than drop the row whenever the card has a mask: on the Pros whose masks span three bytes, the rows (f0 f0 f0 ff as on the J414c) also zero slots 24-31, and dropping them there would change those Macs. Their trees describe their masks as the ADT rows; where that holds, nothing changes. Where a row contradicts a mask, that amp goes back to its card's mask. tests/run-kboot-audio.sh gains these scenarios: - card masks that agree, including on a T8122 tree; - a contradicting mask, on a T8122 tree and on another; - two dai-links that disagree; - a mask without the zero idle mode; - a codec list with a non-phandle entry; - short rows beside a mask; - the J613's real woofer rows and masks. All 36 scenarios pass. Restoring the T8122 check, dropping the check, comparing whole words, ignoring the idle mode, or dropping either of the consistency rules each fails a scenario. On the J613 with a 7.3 kernel and the row dropped (the earlier T8122 version): SDOUT_HIZ as on 7.2, speakersafetyd running, speakers audible. This version has not run on hardware. Signed-off-by: Scott Jones <scottajones@gmail.com>
436058c to
318e4e7
Compare
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at 318e4e74
Blockers:
- Merge conflicts (
mergeable: CONFLICTING): Branch is still based onc8799171and conflicts withmain(afc58ff9, specifically9d900c6068e6insrc/kboot_audio.c,tests/kboot_audio_adt.py, andtests/run-kboot-audio.sh). Because of the conflict, none of thepull_requestCI workflows (build,test,format-check,aurora-agent-policy,pr-text) have run on318e4e74. Mergemainin somergeable == MERGEABLEand CI runs on the new head. src/kboot_audio.c:123(format-check):318e4e74carries the exact same tree as436058c5; line 123 in the doc comment abovedt_card_idle_mask()is 117 columns (ColumnLimit: 100in.clang-format). Reflow withclang-format -i src/kboot_audio.c.src/kboot_audio.c:199-200,288-295(unmasked amps in a contradicting group, §3 safety):tx_zd_row_ok()returnstrueunconditionally whendt_card_idle_mask()returns0. Ont8122-j613.dts(codecs 1 & 3),t8122-j615.dts(codecs 1, 2, 4, 5), andt8122-j504.dts(codecs 1, 2, 4, 5), only the two primary woofers carrydai-tdm-idle-mode-<n>/dai-tdm-slot-tx-idle-mask-<n>. Any unmasked tweeter or secondary woofer now receives its ADTamp-tx-zd-configrow unchecked (the previously hardware-tested T8122 patch dropped rows for all amps in the group), whichtas2764programs intoSDOUT_HIZ_1..4withFORCE_0_ENif non-zero. If any amp in the group contradicts its card idle mask (or has conflicting dai-link masks), dropamp-tx-zd-configfor the whole group (or refuse non-zero rows on unmasked amps in that group) and cover the full 4-amp J613 layout intests/kboot_audio_adt.py.- PR body (§4 attribution): Remove the tool-attribution footer line at the end of the PR description. (Commit
318e4e74itself is now clean and carries a humanSigned-off-by:.) - PR title/body & hardware evidence (§5): Update the PR title and body from the obsolete T8122-only description to the data-driven card-idle-mask rule using the required
What:/Tested:/Risk:/Not yet:lines, and add exact-head hardware rows: (1) J613 (and/or J615) running this head withspeakerguardd(auracontradictlog,SDOUT_HIZreadback, valid IV sense, audio playback, plus regression counts: 0 SELinux denials, 0 failed units, 0 new kernel errors), and (2) a no-regression boot on another SN012776 Mac (e.g. M1 Pro / M2 / M4) confirming nocontradictline and unchangedapple,amp-tx-zd-config.
Checked: Full diff (src/kboot_audio.c, tests/kboot_audio_adt.py, tests/run-kboot-audio.sh) against main (afc58ff9) and Linux tas2764.c/macaudio.c/Apple DTS files across M1–M5, commit hygiene, formatting, CI check runs, and §1–§6 pre-PR checklist.
Evidence
- §1 No model gating: Pass in code —
dt_card_idle_mask()/tx_zd_row_ok()inspects the DT sound-carddai-tdm-idle-mode-<n>("zero") anddai-tdm-slot-tx-idle-mask-<n>rather than SoC/board compatibles. PR title and body still describe the removed T8122 gate and must be updated. - §2 Production-ready, no hacks: Pass in principle (no cmdline/module params or timing hacks), blocked on merge conflicts with
main(9d900c6068e6) andsrc/kboot_audio.c:123(117 columns vs 100-column limit). - §3 Safety:
bop-config,amp-dcblocker-config, andspeaker-configare untouched, and staleapple,amp-tx-zd-configproperties are deleted when rejected. However, unmasked amps (dt_card_idle_mask() == 0) still passtx_zd_row_ok()unconditionally even when masked amps in the same group contradict the card (t8122-j613.dts,t8122-j615.dts,t8122-j504.dtsonly define idle masks on the two primary woofers). Note for the fix: droppingamp-tx-zd-configfor the whole group whenever any amp in the group contradicts its card mask avoids breaking two-bus Macs (M1 Pro, M2 Air, M3 Pro, M4, M5) where a left woofer's valid row (0xf0f0/0xfff0f0f0) intentionally sets bits matching right-bus amps'ti,imon-slot-no/ti,vmon-slot-noon the opposite SDOUT bus. - §4 IP & attribution: Commit
318e4e74is clean (Signed-off-by: Scott Jones <scottajones@gmail.com>, previous attribution trailers removed). PR description still ends with an AI-tool generation footer and must be cleaned. - §5 Evidence & PR structure: Commit message states
"This version has not run on hardware."No exact-head HW row or no-regression row exists at318e4e74; PR body lacksWhat:/Tested:/Risk:/Not yet:lines. - §6 Naming: Pass (no prohibited driver or legacy loader names in the diff or commit).
- CI at
318e4e74: Onlyreadiness / readiness(pull_request_target) ran;build,test,format-check,aurora-agent-policy,pr-text,esp-stage2-size, andstage1-sizehave not run due to merge conflicts. - Non-blocking notes:
src/kboot_audio.c:140:strcmp(name, "codec")ignores unit-addressedcodec@Nsubnodes (all current Apple DTS files usecodec, so not blocking, though matching"codec"up to NUL or'@'matches the binding).src/kboot_audio.c:28: Comment referencesspeakersafetyd; preferspeakerguarddper §3.
|
Still open:
|
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
…ntradicts the card The card-mask check kept back only the row that contradicts its amp's card idle mask. An amp the card has no mask for, such as a tweeter on the 13" M3 Air (J613: masks for codecs 0 and 2 only) or the 15" (J615: codecs 0 and 3 only), still got its ADT row, which the SN012776 driver programs as SDOUT slots to force to zero. If that row has the same complement shape as the woofer rows, it zeroes the woofers' IV sense slots: the original failure, from another amp. The rows of one group are one layout. When the card contradicts any of them (or two dai-links give an amp different masks), pass none of the group's rows on, so the card's masks apply to the whole group, as before the rows were passed on and as in the version tested on the J613. Groups whose masked amps agree keep every row, as on main. Also match a codec subnode named codec@<n>, which the binding allows, and reflow the comment above dt_card_idle_mask() to the 100-column limit. tests: the J613's four-amp layout (unmasked tweeters with complement rows lose theirs too), a codec@0 card, and the whole-group result for the existing contradiction cases. 49 scenarios pass; card-codec-unit-address fails with the old name check. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
@scottjones I've pushed two commits to your branch (normal push, no rebase), since the branch had been quiet since 11-24:
Next: a silent J615 row at this code, built on main plus #551 because main's Stage 2 doesn't link until #551 lands. It will record the aura |
There was a problem hiding this comment.
Verdict: HOLD at 002d618b — code, formatting, conflict resolution, and commit sign-offs are clean; awaiting fork CI workflow approval/green checks and the exact-head J613 or J615 hardware boot row.
Blockers:
- Exact-head hardware verification at
002d618bon a J613 or J615 (clean boot with speakers quiet at start and gated byspeakerguardd, confirmingamp-tx-zd-configis dropped for the whole group including unmasked tweeters), plus fork CI workflow approval and green checks.
Checked: Full 3-file diff (src/kboot_audio.c, tests/kboot_audio_adt.py, tests/run-kboot-audio.sh), dt_card_idle_mask(), tx_zd_row_ok(), whole-group zd_ok gating in setup_amp_group(), codec@<n> matching, bare #sound-dai-cells == 0 validation, formatting (<= 100 cols), and Signed-off-by lines across all 3 commits.
Evidence
- All prior code/process blockers resolved (
ce4041c4,002d618b):- Cleanly merged
main(MERGEABLE), refloweddt_card_idle_mask()comment to 100 columns, and all 3 commits carry valid humanSigned-off-bylines. setup_amp_group()(src/kboot_audio.c:286-325) now validates every amp'samp-tx-zd-configrow against its sound-card TDM idle mask before writing any property; if any amp in the group contradicts its card mask (or has conflicting masks across dai-links),zd_okbecomesfalseanddt_amp_setprop(..., NULL, ...)stripsapple,amp-tx-zd-config(including stale DT copies) from every amp in the group — including unmasked tweeters.dt_card_idle_mask()matches bothcodecandcodec@<n>, verifies everysound-daiphandle has#sound-dai-cells == 0, requiresdai-tdm-idle-mode-<n> = "zero", and returns-1if two dai-links disagree.- Protection rows (
bop-config,amp-dcblocker-config,speaker-config) are untouched. - Test coverage expanded with 11 scenarios including
j613-four-ampsandcard-codec-unit-address(49scenarios reported passing).
- Cleanly merged
- Non-blocking nit: The PR title and description still describe the old SoC-gated T8122 approach rather than the current data-driven sound-card idle-mask check.
- Remaining merge gate: Once fork CI passes and the exact-head J613/J615 hardware boot row lands at
002d618b, this is ready to approve and merge.
|
J615 row at
So on the J615 the ADT rows keep the IV sense alive, and the card's idle masks kill it. That is the opposite of the J613 report. Both Macs have the same row shape ( The Mac is restored to its configured Stage 2: self-check passed, protection ready, Enforcing, 0 failed units. Evidence is in our lab's |
There was a problem hiding this comment.
Verdict: MERGE at 002d618b797a
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: Full 3-file diff (src/kboot_audio.c, tests/kboot_audio_adt.py, tests/run-kboot-audio.sh), dt_card_idle_mask(), tx_zd_row_ok(), whole-group zd_ok gating in setup_amp_group(), codec@<n> matching, bare #sound-dai-cells == 0 validation, formatting (<= 100 cols), and Signed-off-by lines across all 3 commits.
Follow-ups (not blocking): fork CI green; exact-head J613/J615 boot row; update stale title/description
DjDeveloperr
left a comment
There was a problem hiding this comment.
One thing is open at 002d618b797a: the J615 row at this head fails. With the rows dropped, all 12 sense channels are dead and speakerguardd v2 does not start, so that Mac loses its speakers. With the rows passed on, as on main, its self-check passes. The J613 has the same row and mask shape, so the card masks in the T8122 device trees look like the wrong side: t8122-j613.dts and t8122-j615.dts still have 0x0f0f/0xf0f0 and 0x0f0f0f/0xf0f0f0, the complement of the ADT rows.
What decides it is a J613 on the current Stage 2 and kernel with speakerguardd v2 (speakerguardd --check, no playback needed):
- If its self-check passes, nothing has to change in aura and this PR can be closed. The masks in the two device trees are then a linux fix.
- If it fails there, please post the SDOUT_HIZ readback and the aura audio lines, because then the J613 and J615 differ in something other than these two values, and the rule has to use that.
My earlier points (the whole-group rule, formatting, sign-off, description) are answered.
On the 13" M3 Air (J613) the speakers stay silent and the speaker daemon stops with "Left Tweeter: Negative power, bad ivsense data?".
The cause is the amp-tx-zd-config row aura passes on. On T8122 each amp's row is the complement of the sound card's idle masks: the J613 rows are f0 f0 f0 ff (left woofer) and 0f 0f 0f ff (right woofer), while the card masks are 0x0f0f and 0xf0f0. The SN012776 driver programs the row as the SDOUT slots to force to zero, so the right woofer zeroes slots 0-3 and 8-11, which carry the left woofer's and left tweeter's IV sense.
What: aura compares each amp's
amp-tx-zd-configrow with the sound card's TDM idle mask for that amp (dai-tdm-slot-tx-idle-mask-<n>in idle mode "zero", on the dai-link that lists the amp n-th). If any amp's row contradicts its mask, or two dai-links give an amp different masks, no amp of that group gets its row. That includes amps without a mask, such as the tweeters, whose complement-shaped rows would otherwise zero the woofers' sense slots. The card's masks then apply to the whole group, as before the rows were passed on. Groups whose masks agree keep every row, as on main. The rule depends only on the data, with no SoC or board check. aura logs every refusal.Tested:
tests/run-kboot-audio.sh: 49/49 scenarios pass, including the J613 four-amp layout and acodec@0card. The T8122 cases fail on main.--check): see the comments.Risk: two-way door. T8122 speaker sense-slot setup only;
bop-config,amp-dcblocker-configandspeaker-configare unchanged, so no level or limit loosens.Not yet: a no-regression boot on another SN012776 family (expect no refusal line and unchanged
apple,amp-tx-zd-config).Revert:
git revert -m 1 <merge commit>