Skip to content

wifi: centauri: recover after DMA was released before physical reset - #2144

Merged
DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/m5-n1-released-dma-20261117
Nov 20, 2026
Merged

DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/m5-n1-released-dma-20261117

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

After a J714s RTC sleep returned successfully, N1 recovery refused with DMA resources retained (-16, original 0) and Wi-Fi stayed absent. Successful suspend had already freed the DMA allocations; deferred removal tried to fence the old Alpha/Beta PCI objects again after hardware reset hid their config space.

Fence bound and independent teardown only while an authoritative IPC, firmware, descriptor or Bluetooth arena allocation remains. Producer shutdown, identity checks, domain leases and refusal with retained backing are preserved. Reset is not used as proof that live DMA is safe.

Add extraction tests for 15 production functions covering reset-hidden PCI objects, individually retained tuples, pending-transaction retry, producer/release failure and identity changes. Both guard reversions and six tuple omissions must compile and fail runtime assertions. The legacy recovery mock gains its existing arena field.

Validation:

  • GCC and Clang each pass all 15 Centauri host runner jobs (30 total). Independent source review found no blocking issues in the DMA inventory/refusal change.
  • Public Host tests run44112274184 passed on exact public head 1e56c6f890df49178daad301f700d9564d676898.
  • A full controlled native Image/modules/DTB build now passed for 3f1a7fb18168f4635ab759d3f730a0eb38c98ce3, release 7.3.0-m5-n1r4, with 1,774 modules and 1,950 boot DTBs. Full config unchanged; independent guard passed and cleanup/lock release verified. Unrelated working HPM edits stayed untouched; a pinned private compiler view supplied the committed HPM input.
  • The controlled candidate contains identical N1/test input files to this public projection plus already retained wake/PD observations. This is not an exact-public-head native build or hardware recovery proof.

The recovered failing RTC row reports AP76 only, GFX0 and zero MBSW8, with approximately 41.6 seconds physical sleep; that original row remains failed due to N1 recovery. Original intg9/default and display layout were restored and released. Packaging and fresh R4 returning/physical recovery validation are next. Ordinary suspend remains masked.

Draft pending coordinated hardware recovery validation; no long-hold or flawless-deep-sleep claim.

Successful firmware suspend releases Control IPC, firmware and descriptor
backing and the Bluetooth arena before the host resets N1. The old Alpha
and Beta PCI objects can survive that reset while their config space is
hidden. Deferred recovery then fences them again despite owning no DMA,
refuses with -EBUSY and leaves Wi-Fi absent after an otherwise successful
RTC wake.

Fence each bound or independent owner while any authoritative DMA tuple
remains. Keep producer shutdown, identity checks, leases and refusal when
backing is retained; do not treat reset as proof that live DMA is safe.

Add production-function extraction tests covering physical-reset recovery,
retained allocations, failed quiesce/release, identity changes and retry.
Both guard reversions and six tuple omissions must compile and fail a
runtime assertion. Extend the existing recovery mock with its arena field.

GCC and Clang focused host checks pass. Native kernel compilation and
physical validation of this follow-up remain pending the storage gate.
@axboe

axboe commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

This looks like the failure I hit on the K116s (T6050, firmware 27.2) and sent #2141 for a few hours earlier: after a real deep sleep the wake's recovery ends in N1 recovery refused: DMA resources retained (-16, original 0) and Wi-Fi and Bluetooth stay gone until a reboot. On my machine functions 1 and 2 read Command 0xffff at that point, because the host has reset the endpoint and it is not enumerated again yet.

The two PRs take different routes:

  • wifi: apple: centauri: let the wake's recovery pass a reset endpoint #2141 keeps the fence and lets it pass an all-ones Command read while apple_pcie_t6050_warm_reset_done() is true for the bridge. It changes centauri_t6050_stop_dma() and the Bluetooth side, cen_dma_stopped(). +30/−9.
  • This PR skips the fence when no IPC, firmware, descriptor or arena allocation is left.

#2141 is tested on hardware: three RTC deep-sleep cycles plus four ordinary sleeps on the K116s, Wi-Fi and Bluetooth back each time.

Two things I can't tell from here:

  • Whether this PR alone covers the K116s case. It does not touch btcentauri_t6050.c, and I have not checked which allocations were still held when my fence failed.
  • Whether you see a hole in wifi: apple: centauri: let the wake's recovery pass a reset endpoint #2141's condition. The window in which the all-ones read is accepted runs from the wake to the next PM_SUSPEND_PREPARE; if that is too wide for your taste, say so there.

I can run this branch on the K116s once it is out of draft, so we know whether one of the two is enough or they should be combined.

@Isaac-Duarte

Copy link
Copy Markdown
Contributor

J714s (14-inch M5 Pro) hardware result: this fixes it. The commit is cherry-picked unchanged (1e56c6f) onto 0abc2f3 plus my carried PRs.

Without it (the same base with #2441 on top; one deep sleep, woken by its RTC alarm after about 20 s):

pcie-apple 1cb0000000.pcie: port 0: link up again after the sleep in 284 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)

Wi-Fi and Bluetooth stayed gone, and every later s2idle was refused (centauri_t6050_suspend [apple_centauri_t6050] returns -16).

With it: five deep sleeps in one boot. Two woke within seconds (a key, then the SMC's USB-C_plug); three ran 30 s to their RTC alarm. After each wake the functions were enumerated again and the firmware booted:

pcie-apple 1cb0000000.pcie: port 0: link up again after the sleep in 281 ms, status 0x9b001001
pci 0000:01:00.0: [106b:1900] type 00 class 0xff0000 PCIe Endpoint
pcie-apple 1cb0000000.pcie: port 0: link retrained after a root-port reset
pci 0000:01:00.1: [106b:1902] type 00 class 0x0d2000 PCIe Endpoint
pci 0000:01:00.2: [106b:1903] type 00 class 0x0d1100 PCIe Endpoint
apple_centauri_t6050 0000:01:00.0: Wi-Fi firmware channels: 2.4 GHz 11, 5 GHz 25, 6 GHz 59 (167 entries)

No N1 recovery refused line in the boot. After each of the three full sleeps NetworkManager had the Wi-Fi connection back 8 to 14 s after the wake and hci0 was present. An s2idle after them was not refused.

Not tested: sleeps longer than 30 s, a suspend given up half way, and the case where the wake's reset write fails.

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 20, 2026 04:35
@DjDeveloperr
DjDeveloperr merged commit 67e6c99 into integration/aurora Nov 20, 2026
1 check passed
@DjDeveloperr

DjDeveloperr commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged as 67e6c9904411 (head 1e56c6f890df, unchanged), for the M5 ship candidate.

Hardware evidence comes from @Isaac-Duarte's J714s run above: five deep sleeps, with Wi-Fi and BT back every time and no N1 recovery refused.

Review (independent, code only): no blocking issue.

  • Freed memory: the skipped fence never comes before a free. In both quiesce and rewake_teardown, the guard checks exactly the four DMA allocations freed after it (IPC, firmware, descriptor, BT arena), and every earlier free was fenced. With memory still held, the code still fences and refuses.
  • Other SoCs: this code only runs under apple,t6050-pcie, so T6040, T6041, T8142 and T8140 are unaffected.

Local checks: centauri* host tests 15/15 pass (GCC) on integration 449c6a19 merged with #2510 and #1996.

The local object compile is queued behind a host I/O stall. Isaac's kernel built this exact code: the touched files are identical between his base 0abc2f385e and 449c6a19.

Nits for later:

  • READ_ONCE(rw->arena) plus a comment on the unlocked reads.
  • A missing-bound-arena mutation for the bound guard.

@axboe: #2141 can now be checked against this on the K116s.

Update 00:45: the local object compile has now passed. All touched objects built with the M5 asahi config at W=1 with no compiler warnings, on integration 449c6a19 merged with all three PRs (and #2515). The integration tip de2c29696952 has byte-identical sources for these files.

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