Skip to content

i2c: pasemi: Reset a controller that stays stuck in a transaction - #825

Merged
erykwieliczko merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/i2c-recovery
Nov 4, 2026
Merged

erykwieliczko merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/i2c-recovery

Conversation

@erikwb

@erikwb erikwb commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

If a device doesn't complete a transfer, the Apple I2C controller can be left stuck in its transaction, with XIP set in SMSTA. Nothing in the driver gets it out. The CTL reset after the failed transfer doesn't, and neither does rebinding the driver, so every later transfer on that bus fails with "Bus is still stuck" until the next boot. This resets the controller through its PMGR power state, which does end the transaction.

How it showed up

On the M4 MacBook Air (J713), reading a TAS2764's full regmap registers file in debugfs caches the amp's whole register space: 63,606 registers, where the driver normally caches about 110. At the next suspend-to-idle resume, the cache sync writes all of them back. The amp didn't complete the 0xb3-0x313 block, and the controller of the speaker amps' bus stayed stuck at SMSTA 0x10850140. That silenced all four amps until a reboot. Normal use doesn't trigger it, but the dead bus is the real problem. A transaction left open on purpose produces the same stuck state.

The change

  1. dt-bindings: apple,i2c allows resets.

  2. i2c: pasemi: an optional reset in struct pasemi_smbus. When a controller has one:

    • At the start of a transfer: if the bus is still busy after the usual idle wait, reset the controller. Then write IMASK and CTL again as the probe does (the reset returns CTL to its reset value) and wait once more.
    • After a timed-out I2C transfer: if XIP is still set, apply the same reset and return -EAGAIN, and the adapter retries the transfer once. The retry resends the whole transfer, including anything that may already have reached the device. SMBus transfers get no retry; they recover at the start of the next transfer.

    Controllers without a reset, such as the PA Semi one, behave exactly as before.

  3. arm64: dts: apple: t8132: resets = <&ps_i2cN> on all five controllers.

The reset leaves the controller's other configuration registers (0x2c, 0x30, 0x38) as they were, so only IMASK and CTL need writing again.

Relation to #807

This complements #807, which adds suspend/resume handling to the same driver. #807 restores CTL and IMASK after the controller's power domain was off. This PR handles a controller that is stuck mid-transaction, which a CTL write can't end: on the J713, rewriting CTL and rebinding the driver both left it stuck. Each covers a case the other doesn't. The two branches merge cleanly in either order.

Testing (J713)

On integration/aurora 41c4055 with the J713 audio series, plus a test-only module parameter that leaves a transaction open:

Stuck transfer Next transfers
Reset disabled fails (Timeout, status 0x10850140) all fail, Bus is still stuck (status 0x10850140 xfstatus 0x20000000)
Reset enabled succeeds after one controller reset and the retry all succeed
  • Between transfers: a transaction left open is cleared by one reset at the start of the next transfer.
  • TAS2764 probe: a transaction left open during the speaker card's probe isn't noticed by the amp driver. All four amps bind, and speaker protection and playback work afterwards.
  • The debugfs case across real suspend-to-idle: the bus recovered (4 controller resets, no "still stuck") and the other amps carried on. The amp's write of the poisoned registers failed again on its retry, as expected for a write the device itself doesn't complete.
  • PMGR reset on i2c3: CTL goes from 0x90f to its reset value 0x1104, and the first transfer after the CTL write works.

Checks:

  • checkpatch --strict is clean;
  • W=1 is clean for both driver files;
  • dt_binding_check is clean for apple,i2c.yaml;
  • CHECK_DTBS W=1 on all six T8132 DTBs gives the same output as the base.

Not tested: other Apple SoCs; this only adds resets to T8132. The PA Semi PCI driver isn't affected: without a reset, the new paths don't run.

erikwb and others added 3 commits November 4, 2026 09:30
The controller's power state in the PMGR can also reset it. The driver
uses that reset to recover a controller that stays stuck in a
transaction.

Signed-off-by: Erik Bourget <[email protected]>
A transfer that a device doesn't complete can leave the controller in
its transaction, with XIP set in SMSTA. The CTL reset that follows the
failed transfer doesn't end it, and neither does rebinding the driver,
so every later transfer on the bus fails with "Bus is still stuck"
until the next boot.

This was seen on the M4 MacBook Air (J713) after a debugfs read of a
TAS2764's regmap had cached the amp's whole register space: the cache
sync at the next resume wrote back registers the amp didn't complete,
and the stuck controller (SMSTA 0x10850140) took down the bus of all
four speaker amps. A transaction left open on purpose gives the same
state.

Only resetting the controller ends that transaction. When it has a
reset:

- a bus still busy after the wait at the start of a transfer is reset,
  and IMASK and CTL are written again as at probe (the reset returns CTL
  to its reset value) before waiting once more;
- an I2C transfer that times out and leaves XIP set gets the same reset
  and returns -EAGAIN, and the adapter retries it once. The retry sends
  the whole transfer again, including what may already have reached the
  device. SMBus transfers have no retry; they recover at the start of
  the next transfer.

Controllers without a reset, such as the PA Semi one, behave as before.

Signed-off-by: Erik Bourget <[email protected]>
[eryk: rebased onto integration/aurora 21f7ffc, where 8d54cd2 holds
 a runtime PM reference around each transfer: reset the controller of a
 timed-out transfer before that reference is dropped, and leave with -EAGAIN
 through the put; get the reset before the clock is enabled]
Signed-off-by: Eryk Wieliczko <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each I2C controller is reset through its own PMGR power state. The
driver resets a controller that stays stuck in a transaction.

Signed-off-by: Erik Bourget <[email protected]>
@erykwieliczko

Copy link
Copy Markdown
Member

Merging with a conflict resolved. This comment is from Claude Opus 5.5, working for Eryk, not from Eryk himself.

Rebased onto integration/aurora 0cfb3017e8a5 and force-pushed, as Erik agreed. The binding and DT commits are unchanged. The driver commit carries an [eryk: …] note.

Changes in i2c: pasemi: Reset a controller that stays stuck in a transaction

8d54cd288f05 added a runtime PM reference around every transfer and reordered the probe.

  • pasemi_i2c_xfer(): the recovery stays before out:, under that reference, and sets ret = -EAGAIN instead of returning. Returning would leak a reference on every recovery; moving it after the put would reset the controller without one, racing the autosuspend.
  • Probe: the reset lookup and retries = 1 now come right after the clock divider is computed, before the clock is enabled, so a lookup failure needs no unwinding.

It's still needed with runtime suspend: the failing transfer still gets no retry without it, and transfers under 100 ms apart keep the domain on.

Testing

  • KUnit: upstream's suite 4/4.
  • It ran in Eryk's J713 test kernels, but the reset path itself has never fired on hardware.
  • Built together with the rest of this batch on integration/aurora (arm64: Image, modules, DTB).

🤖 Written by Claude Opus 5.5 (in Claude Code) for Eryk.

@erykwieliczko
erykwieliczko merged commit 0ab1cac into aurora-silicon:integration/aurora Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants