Skip to content

wifi: brcmfmac: pcie: keep Apple firmware in D0 across s2idle - #1722

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
wowhang/brcmfmac-s2idle-d0
Nov 12, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
wowhang/brcmfmac-s2idle-d0

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Without WoWLAN, s2idle sends HOST_D3_INFORM and lets PCI PM put the Wi-Fi function into D3hot. On the M1 Pro (BCM4387, firmware 20.96.31.0.8.7.148) the firmware sometimes acknowledges D3 while a DMA is still in flight. Its console, read from TCM at the failure:

TX: pend count is 1
pciedev_d3_ack: dma in progress   (x3)
... resume, association ...
FIFO-1 TXPEND = 360
MQ ERROR wlc_bmac_flush_tx_fifos: flush timeout fifo 1
wl0: fatal error, reinitializing, reinit reason[12]
TRAP 4(...): ... dfsr 80d, dfar 0

The trap is never reported to the host, so every dongle command times out (brcmf_msgbuf_query_dcmd_len: Timeout on response, then Failed to reserve space in commonring) and Wi-Fi stays down until reboot, 5-16 s after the address is assigned. The same signature shows up on the J616s (BCM4388).

cfg80211 has already left the network before the driver suspends and the radio is off (mpc), so the D3 handshake buys nothing in s2idle. With this change Apple firmware (fw_seed) stays in D0 across s2idle, as in the WoWLAN sleep: the PCI state is saved so PCI PM leaves the power state alone, and resume skips D0_INFORM. Hibernation and other firmware keep the D3 handshake.

Tests (one-shot kernels on fleet67 c6c15ac + brcm80211 at integration 3a7a3f9, which carries #1653, #1679 and #1707; s2idle on the PMU RTC; WoWLAN off unless stated):

Mac kernel stress s2idle firmware hangs
M1 Pro D3 handshake (before) double sleep, 2nd at join start 38 1 (cycle 19, console above)
M1 Pro D3 handshake (before) WoWLAN armed sleep, then WoWLAN-off sleep 21 off 2
M1 Pro D0 in s2idle (test switch, same path) double sleep, 2nd at join start 42 0
M1 Pro this change (pcie.c byte-identical) WoWLAN armed sleep, then WoWLAN-off sleep, x40 80 0
M2 this change WoWLAN armed sleep, then WoWLAN-off sleep, x30 60 0

M1 Pro with this change, magic-packet wake while asleep: unicast 10/10, broadcast 9/10, no packet 0 wakes. 0 IOMMU faults, 0 ioctl timeouts, 0 AVC in every row; association kept through the armed sleeps, reconnect after every WoWLAN-off sleep.

Production fleet67 for scale: M1 Pro 1 hang in about 110 s2idle, M2 0 in 260, J616s 3 in about 45 (fast sleep loops).

tools/asahi/brcmf-suspend-tests.py covers the new path (no D3 inform, saved PCI state, TX fenced and restored, resume without D0_INFORM or reprobe, rollback when saving the state fails, D3 handshake outside s2idle); the s2idle-d3 mutation fails it. checkpatch: clean; W=1: no new warnings.

🤖 Generated with Claude Code

Without WoWLAN, s2idle sends HOST_D3_INFORM and lets PCI PM put the
function into D3hot. The Apple BCM4387 firmware (20.96.31.0.8.7.148)
acknowledges D3 while a DMA is still in flight; its console then reads

  TX: pend count is 1
  pciedev_d3_ack: dma in progress

After resume and the next association its TX FIFO 1 stalls ("flush
timeout", TXPEND 360), the firmware starts a fatal-error reinit and
traps in it (TRAP 4, data abort). It never reports the trap, so every
dongle command times out and Wi-Fi stays down until reboot, typically
5 to 16 s after the address is assigned.

cfg80211 has already left the network before the driver suspends and
the radio is off (mpc), so the D3 handshake buys nothing in s2idle.
Keep the function in D0 like the WoWLAN sleep does (save the PCI state
so PCI PM leaves the power state alone) and resume without D0_INFORM.
Hibernation and non-Apple firmware keep the D3 handshake.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Run the Apple-firmware s2idle sleep against the PCIe PM stubs: no
HOST_D3_INFORM, saved PCI state, TX fenced and restored, a hot resume
without D0_INFORM or reprobe, rollback when saving the PCI state fails,
and the D3 handshake outside s2idle. The s2idle-d3 mutation drops the
D0 branch and must fail.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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.

1 participant