Repository navigation
ASoC: cs42l84: ring-sense plug detection for the J604 - #1895
RyanTheTide merged 3 commits into
Conversation
|
Please hold this one for now. We found a side effect on the J604 (MEASURED 2026-11-14). One of the macOS probe writes, 0x1480 = 0x80, unmasks bits 5-6 of The fix is to read 0x1484 once after the |
…terrupt storm) UPSTREAM.md: the cs42l84 pull request is held by us. One of the macOS writes it carries unmasks a status latch the driver never reads, which keeps the codec's interrupt asserted at idle; the fix is built for the next kernel.
|
Tested on a J604 (MacBook Pro 14", M4, Mac16,1; os-fw 26.6.2, system-fw 27.0; aura 1.0.0b13). The kernel was alarm-aurora's pkgrel 38 recipe on
Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening and looking, reviewed it, and am responsible for it. Assisted-by: LLM |
|
The hold is resolved: I pushed a 4th commit, c0a5945 "ASoC: cs42l84: acknowledge the remote status latch after apple,init-writes". The cause: the init writes move 0x1480 from 0xe0 to 0x80, which unmasks bits 5 and 6. Their status latches in REMOTE_BUTTON_STATUS1 (0x1484) at power-up and only clears when 0x1484 is read. macOS reads it once at boot. This driver read it only for button polling, so the latch held the IRQ line asserted. The fix: when init writes were applied, read 0x1484 once right after them and on every codec interrupt. Measured on the J604, kernel 7.3.0 1.913, screen unlocked, nothing plugged in:
One difference from what ran: on our tree the same read sits inside the ring-sense path. This branch has no ring-sense detection, so here it is keyed on the init writes instead. It makes the same reads at the same points. Still to do: the plug/unplug test with a headset. Build: checkpatch --strict 0/0/0, and the codec builds with W=1 and no warnings. Tested on the J604 only (linux-aurora 1.913). |
…p reading corrected kernel/: the 8 patches 1.913 and 1.914 add (595 in all), same Aurora base. 1.913 (0588-0593): the thermal sensor polled every 50 ms while cool, the ISP's old first-open workarounds dropped, the SMC's power channels in the device tree, a wake mark at __cpu_setup, the headset codec reading its remote status as macOS does, and a deeper G16 job queue. 1.914 (0594-0595): the HDMI converter powered the Apple device-tree way, and the doorbell count macOS keeps in the GPU firmware's Globals. The recipe is the linux-aurora-next package. STATUS.md: 1.914 is the default as linux-aurora-next with 1.913 beside it as linux-aurora. 1.913 stalled early in boot on its first start and passed on its second; a 1.911 build failed its gate and was never the default. The headset codec's idle interrupt storm is gone (0 in 10 s, as macOS), so the jack moves to parity at idle: 22 at parity, 16 short, 13 untested. Correction: 1.910's deep-sleep reset was in the resume stub's 60 s window, not in __cpu_setup; every deep sleep since 1.905 slept and woke before the reset. The GPU's fourth idle fix is in 1.914, not measured yet. UPSTREAM.md: aurora-silicon/linux#1895's hold resolved by a fourth commit; #1894 held on an outside J604 test that reports silent speakers.
c0a5945 to
f0ca074
Compare
|
I force-pushed to fix the dt-checks failure ( The cause is in the binding. It gave The binding commit now also has |
|
@IronsideXXVI The fourth commit works on a second J604. I built this PR at c0a5945, plus #1543, #1894, #1917, #1918, #1919 and #1922, on
For comparison, on our default kernel (linux 2129f55, no codec init writes) the same counters also stay at 0 in 10 s. Not tested: plug/unplug and headset buttons, since I have no wired headset here. Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening, reviewed it, and am responsible for it. Assisted-by: LLM |
|
@davishann15-commits thank you, that is the independent check this needed. It is also a fair point that your default kernel without the init writes stays at 0 too: the storm only came with Results so far for the four commits:
Still open on both machines: plug/unplug and headset buttons. I will post ours here when someone at our Mac has a headset plugged in. |
f0ca074 to
41fd34e
Compare
|
Rebased onto
On 1.1125 the codec takes 0 interrupts in 10 s at idle. Plug/unplug and the headset buttons are still untested, so patch 4 has not seen a plug yet. The description is updated. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Thanks for tracking the interrupt storm down to the 0x1484 latch; reading it as macOS does is the right fix. A few things need to change before this goes in.
1. Resume after a deep sleep. cs42l84_resume() (the sleep_reset path) still sets the masks the tip-sense way:
- with a plug in,
cs42l84_set_interrupt_masks(cs42l84, 0); - with none, ring sense masked.
Under ring_detect that unmasks tip sense, which you measured re-asserting about 1000 times a second with nothing plugged in. It also masks the ring sense the IRQ handler now relies on. After the reset, the remote status latch comes back set until 0x1484 is read. So the first deep sleep brings the storm back. The resume path needs the same ring-detect setup as probe: the 0x1484 read, the initial ring state, and the TS-masked interrupt mask.
2. Plug detection is untested. Patch 4 changes how plug state is detected, and plug/unplug and the headset buttons haven't been tried yet. Before merge, please post a row with:
- headphones in and out;
- a headset with a mic, in and out;
- a button press;
- one of those after a deep sleep.
3. Where the writes live. This has the shape #2595 had: a raw register list in the J604 board file. Here the presence of that list also switches the jack-detect scheme (ring_detect). The direction you and Ryan settled for the amplifiers on #2615 applies here too:
- writes macOS makes on every CS42L84 belong in the driver's own init;
- values that really differ per board want named properties with a stated reason;
- the ring-sense scheme shouldn't depend on whether a register blob is present.
Do you know which of the 20 are chip-level, for example what 0x31b0..0x31d4 and 0x31e8/0x31f4 control? A macOS trace from another CS42L84 Mac would settle it; the M2 and M3 laptops have this codec. If the J604 really differs, the binding and the DT comment should say what makes it different.
4. Smaller. The bounds check seq[i] > CS42L84_REVID lets the list write the device-ID and status registers. With the writes in the driver this goes away. If a list stays, it should refuse the volatile registers.
|
Thanks. I'll give the resume path the same ring-detect setup as probe, and post the rows you listed: headphones in and out, a headset with a mic, a button press, and one of those after a deep sleep. On which of the 20 writes are chip-level: I don't know yet for 0x31b0..0x31d4 and 0x31e8/0x31f4, and I'd rather find out than guess. I'll look for a CS42L84 trace from another Mac, move what's common into the driver's own init, use named properties only for what really differs on the J604, and stop tying the ring-sense scheme to the list. |
41fd34e to
c7e13af
Compare
|
Rebased onto
checkpatch --strict is clean on all 7 commits, Still open:
|
|
Blockers: 1. The resume fix (8fe3761) and the volatile-register refusal (c7e13af) address points 1 and 4 of the earlier review. Points 2 (jack rows) and 3 (chip-level writes in the driver, ring sense not keyed on the list) are still open, and I have nothing to add to them. New:
HW row: J604, this head on Assisted-by: LLM (Claude:Opus 5.5) |
c7e13af to
f90e1c0
Compare
|
Both done at f90e1c0.
The description was behind the branch. It now lists all eight patches, and it no longer says the driver is byte for byte what my J604 runs: that holds for patches 1 to 5 only. Still open, as you say: point 2 (the jack rows) and point 3 (the chip-level writes). The HW row needs someone at the Mac with a plug, so it comes with the jack rows, on this head over 5b596e6 and with the IRQ deltas before and after the sleep. Rechecked on 5b596e6: checkpatch --strict 0 errors, 0 warnings, 0 checks on all eight; |
|
Coming back on the vendor/model part I left open: it's in now. The descriptions of all my open PRs in this repo end with the full The trailers are also off the commits on the PRs you hadn't got to yet (#1894, #1918, #1959, #1962, #1994, #1995, #2020, #2615). Those were message-only rewrites: same trees, same authorship, Signed-off-by untouched. #1998 gets the same with the rework push. |
|
Re-review of f90e1c0: Blockers: 2. Since 11:42Z there is one new commit (f90e1c0). The first seven commits keep the same tree as c7e13af (be031391); only their messages changed. From the last review:
Still open from the earlier review (not repeated here): the jack rows (headphones, headset with mic, button, after deep sleep), and moving the chip-level writes into the driver so that ring-sense detection doesn't depend on whether the list is present. Nit: cs42l84.c:1501 "The sync wrote macOS's probe writes back" is now the replay plus the sync. Say "The replay wrote ...". HW row: J604, this head on Assisted-by: LLM (Claude:Opus 5.5) |
f90e1c0 to
1126b15
Compare
|
Thanks Ryan. I looked at where those writes come from. macOS's driver for this codec makes the same register writes in the M4 and M2 kernels, and none of the values depends on the machine. The only per-machine inputs it reads are whether ring sense is on (and inverted), DC ID and the MCLK source. So the writes are chip setup, and the driver now makes them itself, with the registers named, at probe and again at resume before the cache is written back. The I also squashed the series into the three commits that stay (binding, driver, J604 DTS), so no commit adds the list and a later one takes it out. The final tree is the same as the unsquashed rework. The description is updated for the new head 1126b15. Checkpatch, the W=1 builds with clang and gcc, and apple-dt-check with dt_binding_check are clean. The host tests differ from the base only in five Thunderbolt/CIO suites, none in sound, and all five pass on both the head and the base when run alone. The numbers are in the description. None of this new head has run on the J604 yet. The jack checks (headphones, headset with mic, button, and after a deep sleep) will follow on 1126b15. The tip-sense path on a machine without the property hasn't run either. If anyone with an M2 or M3 and the headphone jack can try one playback and a plug/unplug, that would cover it. |
|
Re-review of 1126b15: Blockers: 2. Since f90e1c0 the series is squashed into three commits and the register list is gone: the setup is now From the earlier reviews:
HW row: J604, this head on Assisted-by: LLM (Claude:Opus 5.5) |
The tip-sense plug detection the driver uses does not fit every machine with this codec. On the J604 (MacBook Pro 14-inch, M4) the jack reports the plug on ring sense, and tip sense keeps re-asserting with nothing plugged in, measured at about 1000 interrupts a second. Add cirrus,ring-sense-detect to select ring-sense plug detection. Without it, plug detection stays on tip sense as before. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
On the J604 (MacBook Pro 14-inch, M4) the headset jack reports the plug on ring sense. With the tip-sense scheme this driver uses, tip sense re-asserts about 1000 times a second with nothing plugged in, each interrupt costing two I2C reads. With cirrus,ring-sense-detect: - write the detect block setup: TIP_SENSE_CTL2 mode only, bit 5 set in 0x1471, 0x1478 = 0x8f and 0x1480 = 0x80. Apart from TIP_SENSE_CTL2 these registers have no public description. The addresses and values come from an I2C trace of the codec probe under macOS on a J604 and are written in the order of that trace. What the single bits do is not known, and no other machine has been measured, - mask tip sense (TSRS_PLUG_INT_MASK = 0xfc, as in the trace) and take plug and unplug from the ring sense state in TSRS_PLUG_STATUS, - read REMOTE_BUTTON_STATUS1 (0x1484) once after the setup and on every codec interrupt. The 0x1480 write clears bits 5 and 6 there, and 0x1484 then reads 0x60 once and 0 after that: two more sources are unmasked and their status is latched from power-up. Unread, it holds the interrupt line asserted. The polled button bits (0 and 1) are not affected. The interrupt is requested before this point, so probe holds irq_lock from the detect setup until the masks are written and the first ring state is read. A plug that is in at boot raises no ring interrupt, so probe runs the headset detection itself in that case, as resume does. The resume after a deep sleep gets the same setup as probe: the detect block before the cache is written back, the 0x1484 read after the sync, the first ring state from TSRS_PLUG_STATUS, and tip sense masked. Machines without the property get no new register writes and keep the tip-sense scheme as before. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…set codec The J604's headset jack reports the plug on ring sense, and tip sense keeps re-asserting with nothing plugged in (about 1000 interrupts a second). Select ring-sense plug detection for its codec. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
1126b15 to
d7271ae
Compare
|
Thanks. Both blockers are addressed in 1. Where the values come from. You're right, and I want to be plain about it: on the earlier heads I took the What the series uses now comes only from an I2C trace I took on this J604: macOS booted under the hypervisor with the and before them I dropped the rest of the old chip setup: the Commit messages, code comments, the DTS comment and the PR body are rewritten to say what the hardware does and to The earlier heads are still in this PR's history. If you'd rather not have them attached to the tree at all, tell me 2. Probe. Probe now takes Nit. The resume comment now names HW rows. Not run on this head yet. I'll post the J604 rows (codec IRQ delta over 10 s idle before and after a |
fe5bd71
into
aurora-silicon:integration/aurora
On the J604 (MacBook Pro 14-inch, M4) the headset jack reports the plug on ring sense. With the tip-sense scheme this driver uses, tip sense keeps re-asserting with nothing plugged in: about 1000 interrupts a second at idle, each costing two I2C reads.
A new boolean,
cirrus,ring-sense-detect, selects ring-sense detection. With it the driver:TIP_SENSE_CTL2mode only, bit 5 set in0x1471,0x1478=0x8f,0x1480=0x80,TSRS_PLUG_INT_MASK=0xfc) and takes plug and unplug from the ring-sense state inTSRS_PLUG_STATUS,REMOTE_BUTTON_STATUS1(0x1484) once after the setup and on every codec interrupt. The0x1480write unmasks two more sources whose status is latched from power-up; unread, it holds the interrupt line asserted. The polled button bits are not affected.Probe holds
irq_lockfrom the detect setup until the masks are written and the first ring state is read, and runs the headset detection itself when a plug is already in. The resume after a deep sleep gets the same setup as probe.Where the values come from. Only from an I2C trace I took on this J604: macOS booted under the hypervisor with the I2C controller's MMIO window traced, codec at
0x4b, nothing plugged in. The addresses, the values and their order are the ones in that trace. Apart fromTIP_SENSE_CTL2, the detect block registers have no public description, so they are written by address with a comment that says where the values were measured, that what the single bits do is not known, and that no other machine has been measured.What this no longer does. The earlier heads also added chip setup for every machine (a soft reset, the
0x31xxblock,0x3065, the pad slew rates, aDAC_CTL1change). That is gone. Machines without the property get no new register writes and keep the tip-sense scheme as before.cs42l84.his unchanged from the base.This series:
cirrus,ring-sense-detect.cirrus,ring-sense-detecton the headset codec.Checked on
integration/aurora5b596e6:cs42l84.obuilds with W=1 under clang 18.1.3 and gcc 13.3 with no warningst8132-j604.dtbbuilds with W=1; the three warnings it prints are int8132.dtsi,t8132-dcp.dtsiandt8132-gpu.dtsi, none from this seriesscripts/dtc/apple-dt-check.shagainst the base: 138 DTBs, no new warnings, none removeddt_binding_checkoncirrus,cs42l84.yamlpasses (dtschema 2026.9)tools/asahi/run-host-tests.pyon this head and on the base, same machine and toolchain (rustc 1.100.0): 422/451 and 424/451. 27 failures are the same on both and are my setup: the four g15 tests want rust 1.93.1, which is not installed here, the 22 sep-suspend-errors tests fail at link, and one tbnet-refill mutant (refill-count). The two extra on this head are also tbnet-refill mutants (no-cancel,worker-allocation). Run on its own, tbnet-refill passes 5/5 on both trees, twice each, and this series does not touch tbnetWhat ran on the J604: an earlier list-based version of the ring-sense and latch changes did, and with it the codec took 0 interrupts in 10 s at idle. This head has not run on the J604 yet. I'll post the rows before asking for another look: codec interrupts over 10 s at idle, the same after a deep sleep, headphones, headset with mic, the button, and boot with the headset already in.
This is independent of #1894, though both touch
t8132-j604.dts; whichever lands second gets rebased.Assisted-by: LLM (Claude:Opus 5.5, Claude:Fable 5.2)