Skip to content

wifi: apple: centauri: let the wake's recovery pass a reset endpoint - #2141

Closed
axboe wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
axboe:centauri-wake-fence
Closed

axboe wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
axboe:centauri-wake-fence

Conversation

@axboe

@axboe axboe commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

#2113 (53c1f63) breaks Wi-Fi and Bluetooth after a real deep sleep. Seen on a K116s (16" M5 Pro, T6050, firmware 27.2); the wake itself is fine, the N1 never comes back until a reboot:

pcie-apple 1cb0000000.pcie: port 0: link up again after the sleep in 282 ms, status 0x9b001001
pci 0000:01:00.1: Unable to change power state from unknown to D0, device inaccessible
btcentauri_t6050 0000:01:00.2: Unable to change power state from unknown to D0, device inaccessible
pcieport 0000:00:00.0: N1 recovery refused: DMA resources retained (-16, original 0)

Cause. The new fence frees nothing until each function's Command register reads back with bus mastering off. After a deep sleep the host has reset the endpoint before the port came up, and functions 1 and 2 read all-ones from configuration space until they are enumerated again (an instrumented run printed Command 0xffff for both). The read-back can never pass. pm_test=devices cycles do not show this, since the endpoint is never reset there.

Fix. In centauri_t6050_stop_dma() and cen_dma_stopped(): a function that reads all-ones, on an endpoint the host has reset for this wake (apple_pcie_t6050_warm_reset_done()), counts as stopped. Any other state is judged as before. One commit, 11 lines added.

Tested on the K116s, on integration/aurora dcce0e7 plus the K116s sleep series from #2075:

  • Without the fix: 1 of 1 deep sleeps wakes without Wi-Fi and Bluetooth.
  • With it: 3 of 3 cycles on one boot, Wi-Fi associated with its address and Bluetooth up after each, no refusal logged.

Not tested: J714s or any other board; a suspend that fails part-way (the case #2113 was written for); s2idle.

One thing for review: t6050_warm_done stays set from the wake until the next PM_SUSPEND_PREPARE, so the exception is open for that long, though only for a function that does not answer at all. If you would rather have it tied to the recovery work itself, say so and I will rework it.

Commit 53c1f63 ("wifi: apple: centauri: retain ownership across
failed suspend") releases no DMA memory until each function's Command
register reads back with bus mastering off.

After a deep sleep on a K116s (T6050, firmware 27.2), the host has reset
the endpoint before the port came up, and functions 1 and 2 read all-ones
from configuration space until they are enumerated again. The read-back
can never pass, the recovery is refused, and Wi-Fi and Bluetooth stay
gone until a reboot:

  pci 0000:01:00.1: Unable to change power state from unknown to D0, device inaccessible
  btcentauri_t6050 0000:01:00.2: Unable to change power state from unknown to D0, device inaccessible
  pcieport 0000:00:00.0: N1 recovery refused: DMA resources retained (-16, original 0)

A function that reads all-ones after the host has reset the endpoint for
this wake is not a bus master. Accept it as stopped in both checks. Any
other state is judged as before.

The Bluetooth host test models the new check and covers both outcomes.

Fixes: 53c1f63 ("wifi: apple: centauri: retain ownership across failed suspend")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
@axboe
axboe force-pushed the centauri-wake-fence branch from f23657c to b292418 Compare November 20, 2026 12:51
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Review now that #2144 has landed (integration/aurora 67e6c99; the Centauri files haven't changed since):

#2144 should cover the K116s case you hit, which makes this PR redundant on top of it.

Why:

Rebase status. The rebase onto #2144 is clean: GitHub reports it mergeable, and the only change from the 11-17 version is the PCI_POSSIBLE_ERROR stub in #2144's test file. On top of #2144, the all-ones exception only matters when a tuple is still held after a host reset, a case #2144 refuses on purpose ("Reset is not used as proof that live DMA is safe"). Because the exception sits in centauri_t6050_stop_dma(), it also covers port_cycle(), free_boot() and ipc_fenced() until the next PM_SUSPEND_PREPARE.

Retest, please. Build a K116s kernel from integration/aurora at or after 67e6c99 with #2201, but without this PR. #2201's head 965c1b5 doesn't contain 67e6c99 yet, so it needs a rebase or merge first. Do one real deep sleep and check that Wi-Fi and BT come back, with no N1 recovery refused line.

🤖 Generated with Claude Code

@erikwb

erikwb commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Note

🤖 Claude Opus 5.5 responding on behalf of erikwb

Tested on a J716c (16" M5 Max, T6050, 27.2 stub), base integration/aurora b3445d7 plus a few unrelated trial commits. That base predates #2144. All runs were 30 s RTC deep sleeps (rtcwake -m mem, mem_sleep deep).

  • Base alone: every deep sleep ended in N1 recovery refused: DMA resources retained (-16, original 0). Wi-Fi and Bluetooth stayed down until a reboot.
  • Base + this PR (driver files only): 3/3 sleeps came back.
  • Base + wifi: centauri: recover after DMA was released before physical reset #2144 only (1e56c6f), without this PR: 3/3 sleeps came back too. Wi-Fi reassociated and passed traffic to the gateway, a btmgmt find scan found devices, and no recovery refusal was logged.

So on the J716c, #2144 covers this, as @DjDeveloperr expected. This PR isn't needed on top of it.

(Edited: the first version of this comment compared against a base without #2144.)

@axboe

axboe commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Retested on the K116s (firmware 27.2) without this PR: integration/aurora 789b208, which has #2144, plus my K116s stack with this commit dropped.

One deep sleep by the lid, woken by the lid. The endpoint is reset as before (link up again after the sleep in 282 ms, then Unable to change power state from unknown to D0, device inaccessible for 01:00.1 and 01:00.2), and the recovery goes through: no N1 recovery refused line, Wi-Fi reassociated with its address and passes traffic to the gateway. Bluetooth not checked; it is off on this machine.

#2144 covers it here as well. Closing; thanks DjDeveloperr and Erik.

@axboe axboe closed this Nov 21, 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.

3 participants