Skip to content

wifi: brcmfmac: pcie: guard D3 suspend IRQ and verify device presence before resume BAR0 read - #3951

Merged
DjDeveloperr merged 2 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-brcmfmac-d3-resume-bar0-guard
Dec 4, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-brcmfmac-d3-resume-bar0-guard

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: Guard brcmfmac PCIe D3 suspend/resume against spurious MSIs and absent-endpoint BAR0 reads in drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:

  1. In brcmf_pcie_pm_enter_D3(), set devinfo->d3_suspended (WRITE_ONCE), drain any in-flight IRQ handler via synchronize_irq(devinfo->pdev->irq) when irq_allocated, and mask mailboxmask via brcmf_pcie_intr_disable() (leaving intmask intact for hot-resume detection).
  2. In brcmf_pcie_quick_check_isr(), return IRQ_NONE immediately while READ_ONCE(devinfo->d3_suspended) is true so replayed/spurious MSIs during suspend/resume do not read BAR0 while the link is down.
  3. In brcmf_pcie_pm_leave_D3(), verify pci_device_is_present(devinfo->pdev) before reading BAR0 + 0x2000 (intmask), returning -ENODEV (and notifying apple_radio_sleep_endpoint_resumed(dev, -ENODEV)) instead of reading an unlinked BAR0; clear d3_suspended (WRITE_ONCE(devinfo->d3_suspended, false)) only on the hot-resume path right before brcmf_pcie_intr_enable() so -ENODEV and owned-sleep -EUCLEAN early returns keep d3_suspended armed (and reprobe starts with fresh state).
  4. Update tools/asahi/brcmf-suspend-tests.py, tools/asahi/brcmfmac-sleep-lifetime-tests.c, and tools/asahi/run-host-tests.py with controls and mutations covering D3 ISR gating, absent-endpoint -ENODEV without BAR0 reads, and owned-sleep -EUCLEAN retention of d3_suspended.

Tested:

  • Offline at exact head d2dcb0af97d9 (f61003b58813 + merge of main b924bf47f0c9):
    • python3 -I tools/asahi/run-host-tests.py --only brcmf-suspend: 19/19 passed (including s2idle-l1-* and d3-* mutations).
    • python3 -I tools/asahi/run-host-tests.py --only brcmfmac-sleep-lifetime: 1/1 passed (production + 5/5 mutations).
    • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
    • ARM64 W=1 compile of drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o: 0 warnings.
  • Earlier carry-kernel smoke (linux-aurora 7.3.0.aurora1-1.1685, J604 T8132): 1/1 deep-sleep wake (rc=0, 0 SErrors, 0 kernel faults); not an exact-head standalone row.

Risk: two-way door · brcmfmac PCIe (drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c, +16 / -0 lines, plus host tests) — s2idle D0 and WoWLAN early-return paths in brcmf_pcie_pm_enter_D3() and brcmf_pcie_pm_leave_D3() return before touching d3_suspended, failed suspend restores via pm_leave_D3(), normal hot-resume wakes clear d3_suspended right before brcmf_pcie_intr_enable(), and a plain revert restores prior behavior.

Not yet:

  • Standalone exact-head (d2dcb0af97d9) hardware row on J604 (T8132): deep sleep and s2idle with Wi-Fi recovery after each wake plus one module unload/reload (brcmfmac_wcc then brcmfmac) at the end.
  • Second-generation complete automated row (J516s M3 Pro / T6030 d2dcb0af97d9 run exercised 3 deep-sleep wakes + s2idle cleanly with wld0 reassociation and 0 faults, marked INCOMPLETE only on two harness checks).
Details and verification

Scope (j604-brcmfmac-d3-resume-bar0-guard, head d2dcb0af97d9)

  • drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c (+16 / -0)
  • tools/asahi/brcmf-suspend-tests.py (+63 / -12)
  • tools/asahi/brcmfmac-sleep-lifetime-tests.c (+19 / -1)
  • tools/asahi/run-host-tests.py (+2 / -1)
  • Sign-off: Signed-off-by: Dylan Ironside <dylan@dylanironside.io>

Mechanism summary

  • On Apple Silicon, an MMIO read to a downstream PCIe BAR whose link failed to retrain triggers an asynchronous fabric SError (fatal on the host).
  • During deep-sleep D3 transitions, pm_enter_D3() sets d3_suspended, drains in-flight IRQs via synchronize_irq(), and masks mailboxmask while BAR access is still valid. brcmf_pcie_quick_check_isr() returns IRQ_NONE while d3_suspended is set.
  • On pm_leave_D3(), pci_device_is_present() guards the first BAR0 + 0x2000 (intmask) read; d3_suspended is cleared only on the retained hot-resume path right before brcmf_pcie_intr_enable(), leaving it armed across -ENODEV and -EUCLEAN early returns until reprobe allocates fresh devinfo.

@IronsideXXVI
IronsideXXVI requested review from a team as code owners December 2, 2026 14:58
@github-actions github-actions Bot added area:wireless Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at d2dcb0af: ready to merge

Check Detail
CI at head ok 1 check passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at d2dcb0af
Conflicts ok none
PR text ok Risk: two-way · brcmfmac PCIe (drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c, +16 / -0 lines, plus host tests) — s2idle D0 and WoWLAN early-return paths in brcmfpciepmenterD3() and brcmfpciepmleaveD3() return before touching d3suspended, failed suspend restores via pmleaveD3(), normal hot-resume wakes clear d3suspended right before brcmfpcieintrenable(), and a plain revert restores prior behavior.

Areas: area:gpu, area:wireless
Merge: gh pr merge 3951 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 80d19d6

Blockers:

  1. Wait for the approved Actions CI runs (host-tests, pr-text, readiness) to complete green at 80d19d66bb11.
  2. Post an exact-head 80d19d66bb11 hardware deep-sleep + s2idle row (and a second brcmfmac Mac control row, per merge policy §1/§3 — currently listed under Not yet).

Checked:

  • Audited the full 16-line diff in drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c at 80d19d66bb11: no code blockers found.
  • Setting d3_suspended before synchronize_irq() and brcmf_pcie_intr_disable() in brcmf_pcie_pm_enter_D3() (after the WoWLAN and s2idle_d0 early returns) drains any in-flight ISR and blocks spurious MSIs from reading BAR0 in brcmf_pcie_quick_check_isr() while the link is down.
  • Checking pci_device_is_present() in brcmf_pcie_pm_leave_D3() before clearing d3_suspended or reading intmask avoids an asynchronous fabric SError on a failed relink and cleanly reports -ENODEV to apple_radio_sleep_endpoint_resumed(). On hot resume, brcmf_pcie_intr_enable() restores irq_ready and unmasks interrupts; on cold reprobe, a fresh devinfo starts with d3_suspended = false.
  • Non-blocking note: clearing d3_suspended = false after confirming intmask != 0 (just before brcmf_pcie_intr_enable()) would also keep d3_suspended set if pm_leave_D3() takes the apple_radio_sleep_owned() -EUCLEAN early return without reprobing.

@github-actions github-actions Bot added the changes-requested A reviewer requested changes (bot) label Dec 2, 2026
@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member

Host tests (46908912600) failed on brcmf-suspend-tests.py and brcmfmac-sleep-lifetime-tests.py, which extract brcmf_pcie_pm_enter_D3() / brcmf_pcie_pm_leave_D3() from pcie.c:

  • struct bcmrf_pciedev_info / struct brcmf_pciedev_info stub is missing bool d3_suspended (and irq_allocated if not already present)
  • missing stubs for synchronize_irq(), brcmf_pcie_intr_disable(), and pci_device_is_present()

Updating those two host test harnesses (and covering pci_device_is_present() == false returning -ENODEV without touching BAR0) will make host-tests green.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 2, 2026
… before resume BAR0 read

If the PCIe host port fails to relink after deep sleep, reading
BAR0 + 0x2000 (intmask) in brcmf_pcie_pm_leave_D3() or handling a
replayed/spurious MSI in brcmf_pcie_quick_check_isr() while the link is
down triggers an asynchronous fabric SError on Apple Silicon.

- In brcmf_pcie_pm_enter_D3(), set devinfo->d3_suspended, drain any
  in-flight IRQ handler via synchronize_irq(), and mask mailboxmask
  via brcmf_pcie_intr_disable() while leaving intmask intact for
  hot-resume detection.
- Short-circuit brcmf_pcie_quick_check_isr() while d3_suspended is set.
- In brcmf_pcie_pm_leave_D3(), verify pci_device_is_present() before
  reading BAR0 + 0x2000 (intmask), returning -ENODEV cleanly (and
  reporting -ENODEV to apple_radio_sleep_endpoint_resumed()) if the
  endpoint is absent, and clear d3_suspended only on hot resume right
  before brcmf_pcie_intr_enable() so -ENODEV and owned-sleep -EUCLEAN
  early returns keep d3_suspended armed.
- Update the brcmf-suspend-tests.py and brcmfmac-sleep-lifetime-tests.c
  host test harnesses with the new fields/stubs and add controls and
  mutations covering D3 ISR gating, absent-endpoint -ENODEV without BAR0
  reads, and owned-sleep -EUCLEAN retention of d3_suspended.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI
IronsideXXVI force-pushed the j604-brcmfmac-d3-resume-bar0-guard branch from 80d19d6 to f61003b Compare December 2, 2026 16:02
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks for catching both host-test harness failures and for the review note on d3_suspended placement! Pushed updated head f61003b58813:

  • Updated drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c to clear WRITE_ONCE(devinfo->d3_suspended, false) right before brcmf_pcie_intr_enable(devinfo) on hot resume, so both the absent-endpoint -ENODEV path and the owned-sleep -EUCLEAN early return keep d3_suspended set.
  • Updated tools/asahi/brcmfmac-sleep-lifetime-tests.c with struct pci_dev, pdev/d3_suspended/irq_allocated fields, WRITE_ONCE, synchronize_irq(), and brcmf_pcie_intr_disable().
  • Updated tools/asahi/brcmf-suspend-tests.py (and registered the new mutations in tools/asahi/run-host-tests.py) with d3_suspended, synchronize_irq(), brcmf_pcie_intr_disable(), pci_device_is_present(), brcmf_pcie_quick_check_isr() extraction, and controls/mutations (d3-absent-bar0, d3-isr-guard, d3-euclean-clear) verifying:
    • D3 suspend sets d3_suspended before synchronize_irq(), masks interrupts, and short-circuits brcmf_pcie_quick_check_isr() without reading BAR0 (cleared on hot resume).
    • pci_device_is_present() == false on D3 resume returns -ENODEV with zero BAR0 reads, reports -ENODEV to apple_radio_sleep_endpoint_resumed(), and keeps d3_suspended set.
    • Owned-sleep -EUCLEAN early return without reprobing keeps d3_suspended set.

Local verification at f61003b58813:

  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks (259 lines checked)
  • Clang 18.1.8 ARM64 LLVM=1 W=1: drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o — 0 warnings, 0 errors
  • python3 -I tools/asahi/brcmf-suspend-tests.py: 53/53 controls passed
  • python3 -I tools/asahi/brcmfmac-sleep-lifetime-tests.py: production + 5/5 mutations passed
  • python3 -I tools/asahi/run-host-tests.py --only brcmf: 93/93 passed (including all 16 brcmf-suspend-tests mutations)

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) and removed changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (bot) labels Dec 2, 2026
@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member

Code, updated d3_suspended placement, and new brcmf-suspend-tests / brcmfmac-sleep-lifetime-tests controls + mutations at f61003b58813 look clean, and host-tests / pr-text / readiness are all green. Ready to approve once an exact-head hardware row at f61003b58813 is posted.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Quick J604 (Mac16,1, M4 MacBook Pro 14", T8132, OS FW 27.2 / 26B123) soak update:

  • On our integrated J604 kernel (linux-aurora-next 1.1686, head 1e959da5e66c, carrying commit 89d82de1c143), a full 10/10 deep-sleep (10x 600 s rtcwake -m mem) + 10/10 s2idle (10x 300 s) soak passed with 10/10 Wi-Fi recovery (1.35 s median on deep wake, 1.3 s on s2idle), 0 SErrors, 0 L2C/kernel/GPU faults, and 0 resets.
  • For full transparency: that soak was on our integrated kernel (which still had the initial d3_suspended placement before the intmask read, alongside soc: apple: sleep: fix APCIe auto-PM teardown and BUSY-latch lowering #3950's sleep.c change and a pcie-apple.c relink guard), not yet a standalone build at exact head f61003b58813 (which moves d3_suspended = false right before brcmf_pcie_intr_enable()). I will run and post a standalone exact-head f61003b58813 deep-sleep + s2idle row on J604 next to clear the exact-head requirement.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 2, 2026
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Forward-merged main (b924bf47f0c9, including 9b4f6882dd11 BCM4378 s2idle ASPM L1 suppression) into j604-brcmfmac-d3-resume-bar0-guard (d2dcb0af97d9, no force-push) to clear the merge conflicts in tools/asahi/brcmf-suspend-tests.py and tools/asahi/run-host-tests.py. drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c merged cleanly with no functional changes.

Local verification at d2dcb0af97d9:

  • scripts/checkpatch.pl --strict on diff vs main: 0 errors, 0 warnings, 0 checks (259 lines checked)
  • Clang 18.1.8 ARM64 LLVM=1 W=1: drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o — 0 warnings, 0 errors
  • python3 -I tools/asahi/brcmf-suspend-tests.py: 58/58 controls passed
  • python3 -I tools/asahi/brcmfmac-sleep-lifetime-tests.py: production + 5/5 mutations passed
  • python3 -I tools/asahi/run-host-tests.py --only brcmf-suspend: 19/19 passed (including both s2idle-l1-* and d3-* mutations)
  • python3 -I tools/asahi/run-host-tests.py --only brcmfmac-sleep-lifetime: 1/1 passed

Next: standalone exact-head hardware row at d2dcb0af97d9 on J604.

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Dec 2, 2026
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: the code is fine at d2dcb0af97d9. Merge once the two hardware results below are in. I'm not approving yet only because they are missing.

Forward merge: clean. The pcie.c change is line for line the one at f61003b5, and nothing from main is removed. The branch tree is exactly b924bf47 plus the four PR files. The BCM4378 s2idle L1 suppression (prepare/complete/remove) is intact. The result also merges cleanly into main 5fe340ac (tree 42a56ca0); later main commits don't touch these files.

Still needed (blocking):

  1. J604 deep sleep + s2idle on this head, with Wi-Fi back after each wake and one modprobe -r brcmfmac / modprobe brcmfmac at the end. The 10/10 soak is good support, but it ran the earlier flag placement next to other sleep changes.
  2. A second brcmfmac Mac of another generation, same steps. Best is an M1 with the BCM4378 (T8103, where deep sleep is offered); a T6040 MacBook Pro also works. Please enable dyndbg for brcmf_pcie_pm_* or note whether the wake was a hot resume or a reprobe.

Not blocking, a follow-up is fine (main faults at the first wake in these cases, so nothing here is a regression):

  • After an absent-device wake the driver stays bound, and the next step still touches the dead link. s2idle masks over BAR0 (pcie.c:3593) and its wake marks the bus up while the ISR is still gated. Deep sleep sends HOST_D3_INFORM (:3659). modprobe -r runs brcmf_pcie_reset_device(). An early return in brcmf_pcie_pm_enter_D3() while d3_suspended is set would cover both sleeps (keep the last good saved config: a fresh pci_save_state() would store all-ones).
  • brcmf_pcie_reset() reuses the same devinfo, so clear d3_suspended in brcmf_pcie_request_irq(). Otherwise a reset after a failed wake comes back with its interrupts ignored.
  • On the J713, a reported -ENODEV ends in apple_radio_terminal() (a panic), as -EUCLEAN already does. The "degrades cleanly" wording holds for the other boards.
  • The PR body still describes 80d19d66 (flag cleared before the intmask read); update it with the new result.
What I ran and read

Run on the merge tree 42a56ca0 (no hardware):

  • arm64 clang W=1 of drivers/net/wireless/broadcom/brcm80211/brcmfmac/ (BRCMDBG=y): 0 warnings.
  • checkpatch.pl --strict: 0/0/0 on the commit and on the net diff.
  • run-host-tests.py --only brcm 95/95, --only bcm4377 13/13, in the CI container image.

Read:

  • BCM4378/4387/4388 (and 4355/4364/4377) all set fw_seed, so s2idle keeps the function in D0 and returns before the new code; WoWLAN too. Only deep sleep and hibernation use it.
  • Suspend order is right: flag, drain, then mask, so no thread can unmask afterwards. intmask and mailboxmask are separate registers in both layouts. A failed D0_INFORM still goes through remove/probe with a fresh devinfo.
  • The presence check is one config read, which the PCI core already does in its noirq resume.

Hosted Host tests and pr-text are waiting for approval at this head.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at d2dcb0a

Checked: D3 entry guards new IRQ arrivals before draining in-flight handlers, then masks interrupts while BAR access is still valid. Resume checks presence before the first BAR read and restores IRQ admission on the successful retained path. The D0 s2idle return paths remain separate. I ran the exact production-backed host suite and all 58 controls passed.

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at d2dcb0af97d9. The code is the same as in my review of this head, where only the rows were missing, and I found nothing that has to change. My follow-up notes there still stand and don't block this.

What I checked again

  • Suspend sets the flag, waits for the running handler, then masks the dongle, so nothing can unmask afterwards. A suspend that fails after that goes through the hot resume, which clears the flag.
  • Resume checks the device before its first register read. The flag is cleared only on a hot resume; a reprobe starts with new state.
  • s2idle (device left in D0) and WoWLAN return before the new code, so only deep sleep and hibernation use it.
  • It merges cleanly on main dc4d6f065001 and brcmfmac/pcie.o compiles there (arm64, GCC, W=1, no warnings).

Rows still owed before merge

  1. J604: deep sleep and s2idle at this head, Wi-Fi back after each wake, one module reload at the end.
  2. A second generation. Our J516s (M3 Pro, T6030, BCM4388) can be it if its deep sleep wakes; this head is in our next kernel for it. An M1 (BCM4378) or a T6040 MacBook Pro row counts as well. (Corrected 10:17 UTC: an earlier version also named our J773g. Its test install has no Wi-Fi firmware, so it can't give this row.)

Please update the PR body: it still describes the older flag placement.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Apple Mac mini M4, T8132, G16G B0, os-fw 27.2, 24 GB RAM) hardware row for head d2dcb0af97d9b67d61cf91ac4a7096a37f23b51f (work/m4rows-b8818ae1-j773g-20261203, kernel 7.3.0-j773g-r1480, local merge b8818ae173f0 on main c43014f079f5, vmlinux build ID ff1e987389e53799e752ac3fc62c843fdb77f70d, boot 5812289d-cae8-43c5-bc9c-0e56c002cce0):

  • Judge line: linux#3951: INCOMPLETE: 3/3 committed deep sleeps with 0 SError/IRQ/BAR/AER lines, but brcmfmac was not bound on this boot (no firmware on the kboot route): Wi-Fi recovery not shown
  • All 4 committed deep sleeps on HEAD (Q4197 sleep + SLEEP 1..3: success=1->2->3->4 fail=0 same_boot=y) completed cleanly with serror=0 irqbar=0 gpu=0 warn=0 brcmerr=0; brcmfmac was unbound (bound=0 wlan=none) on the kboot route as expected.
  • Stock 7.3.0-j773g-main3685+ cleanly restored (boot beaa437c-6c1c-44f0-87be-9a073461f45d).

Verdict: INCOMPLETE (3/3 deep sleeps + PCIe/IRQ/BAR/AER/SError clean; Wi-Fi brcmfmac recovery uncovered on kboot route without firmware).

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Hardware check on MacBook Pro 16-inch (M3 Pro, J516s, T6030, BCM4388/4, OS firmware 27.2) at head d2dcb0af97d9:

  • Kernel: 7.3.0-j516s-r1940 (main dc68a27f33d8 + #4213 a313071a0aad + #4225 9dd2888214bf + #3993 f39dcd8f0ad8 + #4014 33a87e888ec3 + #3951 d2dcb0af97d9 + #3953 fd11c9d886c1 + #4194 ea79c2f6e858, merge b9d21a54482f, tree fa8faef7a54f), boot 4d298191-adbc-4ad0-af5d-dc0f2b26e3f3
  • Automated PR judge: INCOMPLETE (two harness-side gaps prevented a full automated PASS):
    1. During deep sleep 1 an intermediate dark wake (SMC.OutboxNotEmpty, boot object resumes 0 -> 1) re-entered sleep before the RTC wake (NUB.SPMI0.SW3, 1 -> 2), followed by deep sleep 2 (2 -> 3), leaving back_count=3 whereas the judge checked back_count == 2.
    2. The module-unload sub-check ran modprobe -r brcmfmac without first unloading brcmfmac_wcc (modprobe: FATAL: Module brcmfmac is in use., wifi_unload_rc=1), so the unload/reload cycle was not actually exercised.
  • Observed hardware behavior (clean on every exercised path):
    • brcmfmac stayed bound across all 3 committed deep-sleep wakes (S2R: L1.2 off on the link set up again on each wake); wld0 reassociated and answered gateway pings in 7 s after both sleeps, 0 AER errors, 0 DART/IOMMU faults, 0 WARN/BUG/SError.
    • s2idle probe passed (wifi_s2idle_rc=0, wifi_s2idle_commits=1, same boot, gateway ping 3/3 0% loss, wifi_extra_faults=0).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (MacBook Pro 14-inch M3 Pro, T6030, OS firmware 27.2) narrow rerun + s2idle/reload split on #3951 (d2dcb0af97d9): INCOMPLETE (deterministic reset right after s2idle wake, before module unload/reload); deep-sleep Wi-Fi path clean across 6/6 wakes.

Stack under test

  • Kernel: 7.3.0-j516s-r1940 (main c43014f079f5 + #3993 #4014 #3951 #3953, local merge 08b8fa7e8151, #3951 head d2dcb0af97d9).
  • Stage 1 / Stage 2: 1.0.0b17-gf52d8324 / 1.0.0b17-g683a128b with trial DT (apple,t6030-sleep enabled, mem_sleep: s2idle [deep]).
  • Boots: 901db950 (narrow run 1), 67b147d6 (narrow run 2), a94b9c70-f0e7-426b-9800-515bb67d20a4 (synced split run, 2026-12-03T23:24:42Z).

1. Deep-sleep Wi-Fi path (#3951 target case)

  • Across all 3 boots / 6 committed deep sleeps (resumes 0 -> 1 -> 2, suspend_stats success 0 -> 1 -> 2, wake source NUB.SPMI0.SW3):
    • wld0 gateway ping recovered in 7 s on every wake; brcmfmac, hci_bcm4377, and sdhci-pci remained bound with 0 PCIe 0xffff reads.
    • 0 DART/IOMMU faults, 0 AER errors, 0 brcmfmac firmware traps, 0 WARN/BUG/Oops/SError, 0 new kernel error lines (45/45 deep-sleep + system checks PASS on a94b9c70).
  • Pre-#3951 comparison on the same J516s hardware: on a pre-#3951 deep-sleep kernel (7.3.0-pwren, boot df10128c-e02a-4512-a52c-6ca6a89af415, wake 2), brcmfmac hit the wake-time fault #3951 targets:
    • apple-dart 594000000.iommu: translation fault: status:0x80100008 stream:1 code:0x8 (NO PTE FOR IOVA) at 0xbf680330
    • brcmfmac 0000:01:00.0: brcmf_pcie_ctl_stall: firmware trap 0x84 at 0x0025f325
    • brcmfmac 0000:01:00.0: brcmf_pcie_fw_died: firmware died (trap in shared RAM), resetting the chip (1/5)
    • None of these occurred across 6/6 deep-sleep wakes with #3951.

2. Deterministic reset after s2idle wake (blocks the unload/reload check)

  • Adding synced phase markers (sync -f + journalctl --sync) between s2idle, s2idle_woke, s2idle_gate_done, unload_wcc, and unload_brcmfmac on boot a94b9c70 isolated the reset cleanly:
    • 23:27:05Z (115.514 s): phase=s2idle, PM: suspend entry (s2idle) (rtcwake -d /dev/rtc0 -m freeze -s 20).
    • 23:27:26.396Z (117.350 s): wifi_s2idle_rc=0, wifi_s2idle_commits=1, wifi_s2idle_same_boot=yes, phase=s2idle_woke synced to disk.
    • 23:27:26.399Z: PM: suspend exit; last journal line at 23:27:26.410Z.
    • 23:27:56.571Z (+30.16 s after s2idle_woke, matching the +52 s from phase=s2idle on boots 901db950 and 67b147d6): system booted cleanly into the default stock kernel (boot c84cb753).
  • The reset occurs immediately after s2idle wake (during the post-s2idle Wi-Fi recovery window, before s2idle_gate_done and before modprobe -r brcmfmac_wcc / modprobe -r brcmfmac ever ran). Because the s2idle step resets the machine, the module unload/reload + link-restore step could not be reached in the same run (linux#3951: INCOMPLETE).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (MacBook Pro 14" M3 Pro, apple,j516s, T6030, BCM4388, OS fw 27.2) single-boot A/B follow-up to #issuecomment-7395650202 on 7.3.0-j516s-r1940 (main dc68a27f + #4213/#4225/#3993/#4014 + #3951 d2dcb0af), boot_id=6625ec77-43af-4645-845d-708a1d0c8150:

  • Verdict: FAIL (blocks merge) — the single-boot A/B isolates the deterministic s2idle-after-deep-sleep hard reset directly to #3951's 16-line brcmfmac/pcie.c hunk, while confirming the hunk fixes the deep-sleep wake DART fault / firmware trap and passes no-sleep unload/reload.
  • Check 1 — Module B (#3951 d2dcb0af, brcmfmac.ko sha256 34a10de255ea), no-sleep unload/reload: PASS
    • rmmod brcmfmac_wcc && rmmod brcmfmac (rc=0, modules unloaded) -> modprobe brcmfmac (rc=0, brcmfmac + brcmfmac_wcc reloaded, wld0 gateway ping rc=0, 0 DART / brcmfmac / WARN errors).
  • Check 2 — Module A (same 7.3.0-j516s-r1940 tree with only #3951's 16-line drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c hunk reverted, brcmfmac-no3951.ko sha256 69bfb2cbcc90) in the same boot (6625ec77):
    • Unloaded B and insmod'd A (rc=0, gateway ping rc=0), then ran the same 2 deep + 1 s2idle sequence:
      • Deep sleep 1: hit the pre-#3951 wake fault (apple-dart 594000000.iommu: translation fault: status:0x80100008 stream:1 code:0x8 (NO PTE FOR IOVA) at 0xbf1d81e0, brcmf_pcie_ctl_stall: firmware trap 0x84 at 0x0025f325, brcmf_pcie_fw_died: firmware died (trap in shared RAM), resetting the chip (1/5)), Wi-Fi recovered in 12 s. This confirms #3951 genuinely eliminates that deep-sleep wake fault (0/6 wakes on B across boots 901db950, 67b147d6, a94b9c70).
      • Deep sleep 2: clean (rc=0, Wi-Fi back in 7 s, 0 DART faults / traps).
      • s2idle after 2 deep sleeps: PASS — zero reset (rc=0, commits=1, same_boot=yes, Wi-Fi back in 2 s, 0 DART / brcmfmac / WARN errors; stayed in boot 6625ec77 through completion and clean stock return b9c3a3ee).
  • Read: with B (#3951 hunk present), J516s hit 3/3 hard resets (901db950, 67b147d6, a94b9c70) ~30 s after s2idle wake following deep sleep; with A (only the pcie.c hunk reverted on the exact same kernel/DT/boot), s2idle after 2 deep sleeps completed cleanly with 0 resets. Note that in the diff, brcmf_pcie_pm_enter_D3() sets d3_suspended = true and calls brcmf_pcie_intr_disable(), while brcmf_pcie_pm_leave_D3() only clears d3_suspended = false on the hot-resume branch (intmask != 0) and not on the cold-resume / cleanup: / s2idle_d0 paths.
  • Evidence: work/j516s-3951-ab-20261203/results/run-20261203T234951Z/facts.txt.

@DjDeveloperr DjDeveloperr removed the ready-to-merge Meets the merge policy: merge it (bot) label Dec 3, 2026
@github-actions github-actions Bot added the ready-to-merge Meets the merge policy: merge it (bot) label Dec 4, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (M3 Pro, T6030, OS firmware 27.2) hardware run of linux#3951 (d2dcb0af97d9b67d61cf91ac4a7096a37f23b51f) + djdev/3951-s2idle-fix (2a179a9b86977b09270660fa38464a2c14975496): INCONCLUSIVE / UNPAIRED — silent hard reset at 62.4 s post-s2idle wake while still on Arm C (before Arm B started)

Environment & build

  • Kernel: 7.3.0-j516s-r1940 (build-id 5a16828d03f5298dac042fb7576e42701e7fe398, trial DT m1n1/m3r3951.bin, mem_sleep=s2idle [deep], boot 530b134f-d81b-4c9f-8fb9-03275c99e91a).
  • Arm C module (#3951 + 2a179a9b, irq_wake_thread() in brcmf_pcie_pm_leave_D3() D3 hot-resume path): brcmfmac.ko sha256 09981a1fc2753b64dcd498da6ba1c77319d91ae182bc84233e7d61e54b0b089e (taint=OE).
  • Arm B module (installed #3951 d2dcb0af): brcmfmac.ko sha256 34a10de255ea8e06b5c7bf7089785c1648a62b91555698fa89ff1c26b8152d62.

Arm C results (40/40 automated judge checks before reset)

  • Module swap: unload rc=0, insmod rc=0, wld0 gateway ping rc=0 (9 s), 0 WARN/BUG/SError.
  • Deep 1 (rtcwake -m mem -s 20): rc=0, committed (apple-sleep: back from sleep, boot object resumes 0 -> 1), same boot, wld0 gateway ping rc=0 (7 s), 0 DART faults, 0 brcmfmac traps/errors, 0 WARN/BUG/SError. Trace confirmed enter_d3 -> leave_d3 (D3 hot-resume path, no wowl_wake).
  • Deep 2 (rtcwake -m mem -s 20): rc=0, committed (resumes 1 -> 2), same boot, wld0 gateway ping rc=0 (7 s), 0 DART faults, 0 brcmfmac traps/errors, 0 WARN/BUG/SError.
  • s2idle after 2 deep sleeps (rtcwake -m freeze -s 20): rc=0, committed, same boot (c_s2idle_woke at t=100.258 s, trace confirmed enter_d3 -> leave_d3 -> wowl_wake -> pm_complete), wld0 gateway ping rc=0 in 2 s (t=102.286 s), held 62 s (c_hb1..c_hb12, IRQs 12361 -> 42275, wld0 connected throughout), 0 DART faults, 0 brcmfmac errors, 0 WARN/BUG/SError.

Silent hard reset immediately after phase=c_finished (before Arm B)

  • t=162.633 s: phase=c_done logged and synced (systemd-journald: Received client request to sync journal, flushed to facts.txt on disk).
  • t=162.643 s (62.4 s after c_s2idle_woke): phase=c_finished reached kmsg / journald / remote streams, and the machine hard-reset before sync_point c_finished finished (facts.txt on disk never received c_end_boot/phase=c_finished, journalctl --sync for c_finished never logged, and phase=b_swap / Arm B never ran).
  • 0 WARN/BUG/SError/panic lines in the streamed dmesg (3,163 lines), /sys/fs/pstore empty; the Mac cold-booted back to stock 7.3.0-f3822 (boot_id 2b31e4dd-30b9-4b83-a64c-57e5c03f27f8, RTC ~27 s later).
  • Note on trace volume during the 60 s hold: kprobe tracing of brcmf_pcie_quick_check_isr / brcmf_pcie_isr_thread streamed over wld0 produced ~28.7k probe pairs during the hold (trace.txt 10.2 MiB) right up to t=162.636 s.

Summary

Automated judging scored Arm C 40 PASS / 0 FAIL and PAIRED arm B not run only because phase=c_finished was emitted milliseconds before the reset. Because J516s suffered a silent hard reset at 62.4 s post-s2idle wake while still on Arm C (before b_swap started) and Arm B never ran, this run does not confirm that 2a179a9b prevents the post-s2idle reset on J516s; a longer hold (e.g. >= 120–180 s) without high-rate ISR tracing over Wi-Fi is needed to tell whether 2a179a9b only delayed the reset or whether something else triggered it at 62 s.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (MacBook Pro 16" M3 Pro, apple,j516s, T6030, OS fw 27.2) paired A/B v2 hardware row for linux#3951 (d2dcb0af) + djdev/3951-s2idle-fix (2a179a9b), kernel 7.3.0-j516s-r1940, trial DT m1n1/m3r3951.bin, boot 49596dec-42e2-4e24-b5e5-0ef9038a1e8f -> 7689f326-35d4-4f60-9a29-99541d22f9f3 (stock 7.3.0-f3822), arm C brcmfmac.ko sha256 09981a1fc2753b64dcd498da6ba1c77319d91ae182bc84233e7d61e54b0b089e, arm B installed brcmfmac.ko sha256 34a10de255ea8e06b5c7bf7089785c1648a62b91555698fa89ff1c26b8152d62, 180 s post-s2idle hold with continuous hardware WD1 kprobe readouts:

  • Timing correction to earlier receipts: earlier receipts said arm B reset ~30 s after the s2idle wake; it was ~3 s (the ~30 s included the ~27 s J516s cold boot), and v1 arm C's reset (boot 530b134f-d81b-4c9f-8fb9-03275c99e91a) came 62.4 s after its s2idle wake, inside the post-c_finished sync/transition.
  • Verdict: FAIL (41 PASS, 2 FAIL, 3 INCOMPLETE; unpaired — the Mac hard-reset during b_swap before arm B loaded, so arm B did not run).
  • Arm C (2a179a9b) results:
    • Initial swap/load (taint OE, Wi-Fi up) and deep sleep 1 (resumes 0 -> 1, Wi-Fi back, 0 DART faults, 0 brcmfmac errors, 0 WARN/BUG/SError): PASS.
    • Deep sleep 2 (resumes 1 -> 2): FAIL — hit the exact wake DART fault and firmware trap 0x84 despite 2a179a9b:
      • [91.125715] ieee80211 phy1: brcmf_msgbuf_process_flow_ring_create_response: Flowring creation failed, code 4
      • [91.125879] apple-dart 594000000.iommu: translation fault: status:0x80100008 stream:1 code:0x8 (NO PTE FOR IOVA) at 0xbfe88c90
      • [91.135066] ieee80211 phy1: brcmf_msgbuf_query_dcmd_len: Timeout on response for query command
      • [91.135194] brcmfmac 0000:01:00.0: brcmf_pcie_ctl_stall: firmware trap 0x84 at 0x0025f325
      • [91.135437] brcmfmac 0000:01:00.0: brcmf_pcie_fw_died: firmware died (trap in shared RAM), resetting the chip (1/5)
      • [91.135861] ieee80211 phy1: PM: dpm_run_callback(): wiphy_resume [cfg80211] returns -5
      • Chip reset recovered Wi-Fi (brcmf_pcie_reset + firmware reload BCM4388/4, wld0 back up, gateway ping 0).
    • s2idle + 180 s hold (following the deep-2 chip reset): PASS — committed (1), Wi-Fi back, held 183 s in the same boot, 0 DART faults, 0 brcmfmac errors, 0 WARN/BUG/SError.
    • Hardware WD1 proof (NOT a watchdog bite): 127 WD1 readouts total; during the 180 s hold, 12 systemd pings in 182 s, max gap 15.3 s, all 88 readouts ctl=0x4 (RESET_EN) with bite=1440000000 (60 s).
    • Post-C hard reset at b_swap (modprobe -r): phase=c_done (290.233), phase=c_finished (290.243), phase=b_swap (290.253), synced=b_swap (290.257), last journal sync (290.259), then immediate hard reset to stock 7.3.0-f3822 (0 WARN/BUG/SError on the stream; last phase flushed to facts.txt on disk was c_done, while c_finished and b_swap were streamed). Last WD1 ping was at 289.068 (1.2 s before the last sign of life at 290.259; wd1_sync at 290.257 read ctl=0x4 bite=1440000000 cnt=28534000 = 1.19 s), ruling out WD1 and pinning the reset to the b_swap unload transition after the sleeps (matching v1's reset right after c_finished).
  • Stock 7.3.0-f3822 and stock boot.bin (efab68fa…) verified and cleaned afterward.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (MacBook Pro 14" M3 Pro, T6030, OS firmware 27.2), v3 row on 7.3.0-j516s-r1940 with the m3r3951 trial device tree: PASS.

This replaces the 23:58Z "FAIL (blocks merge)" comment, which got the cause wrong. The reset it blamed on #3951 comes from unloading brcmfmac_wcc after deep sleeps, and main's brcmfmac does that too.

Setup. Each arm gets its own trial boot. That boot loads the arm's brcmfmac by itself (from updates/), and nothing unloads or swaps the module during the arm. Both modules are built the same way from the same tree, so the only difference is this PR's 16-line hunk in pcie.c.

  • Arm B, main: pcie.c blob 04d99874, the same as main today (9b8e29fe). Module 69bfb2cb.
  • Arm C, this PR: pcie.c blob ba6cd70e, the same as the head d2dcb0af, so the driver is tested at the exact head. Module b8d35a7c.

Each arm ran 3 deep sleeps, then an s2idle, then held 180 s after the s2idle wake. The hardware watchdog was read throughout.

Results (run 20261204T021234Z; boots 7152f794 for B and 4d1fbe42 for C):

  • Arm C (wifi: brcmfmac: pcie: guard D3 suspend IRQ and verify device presence before resume BAR0 read #3951): 44/44 checks pass.
    • Wi-Fi was back after every wake: 7 s after each deep sleep, 2 s after the s2idle.
    • 0 DART faults, 0 firmware traps, 0 WARN/BUG/SError lines.
    • The 180 s after the s2idle held, with no reset.
  • Arm B (main): deep 1 hit the firmware death. The kernel log shows Flowring creation failed, code 4, apple-dart 594000000.iommu: translation fault ... (NO PTE FOR IOVA), firmware trap 0x84, brcmf_pcie_fw_died and wiphy_resume [cfg80211] returns -5.
    • The chip reset, but Wi-Fi wasn't back within 75 s. It was back by deep 2.
    • Deep 2, deep 3, the s2idle and the 180 s hold were clean.
  • Then, as B's last step, modprobe -r brcmfmac_wcc with main's brcmfmac hard-reset the Mac at once. It wasn't the watchdog: the last watchdog ping came 1.7 s before.

What this changes:

  • The 23:58Z FAIL. The earlier rows unloaded brcmfmac about 3 s after the s2idle wake, as their next step after the Wi-Fi check, and that's where they reset. Their record on disk stops at the wake, because on this Mac the last writes before a hard reset don't survive, even after sync -f has returned. In this run, B's disk stops at b_finished, while the stream to another machine shows the next sync had finished. With no unload, this PR held 183 s after the s2idle.
  • The firmware death on wake is pre-existing on main. It hit 1 of 4 wakes here, and 1 of 3 in the 23:50Z run. This PR showed it in 0 of 4. That fits what the PR is for, but 4 wakes per arm is a small sample, so this row alone doesn't prove a fix.
  • Unloading brcmfmac after deep sleeps resets this Mac on main too. That's a separate bug, not this PR's.

Not yet: a row on T8132, the J604's SoC. A J773g (M4 mini) row is next.

Evidence: work/j516s-3951-v3-boot-per-arm-20261204/results/run-20261204T021234Z/ holds verdict.txt, the per-arm facts, kernel logs and streams. The kit is sealed (SHA256SUMS 6fe190cb).

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Mac mini M4, T8132, the J604's SoC, OS firmware 27.2), exact-head row on the stock kernel 7.3.0-j773g-main3685+, module only: PASS (46/46 checks).

  • Module: the stock kernel's own source and config with this PR's pcie.c (blob ba6cd70e, head d2dcb0af). Built the same way, the unchanged source gives back the installed stock brcmfmac in every loaded section except .modinfo and the build id.
  • Sequence: 3 deep sleeps, then 1 s2idle (rtcwake on rtc1), then 124 s held.
  • Every wake:
    • came back in the same boot, committed, in the right mode, with rtcwake rc 0;
    • still had brcmfmac bound with this module;
    • had Wi-Fi back in 2 s (gateway ping through wld0);
    • showed 0 WARN/BUG/SError lines, and no Flowring failure, DART fault, firmware trap, fw_died or wiphy_resume -5.
  • No module was unloaded after a sleep. That unload reset is the separate main bug from the J516s comment above.

Evidence: work/j773g-3951-d2dcb0af-20261204/results/run1 (kit SHA256SUMS 7f479599).

With the J516s v3 PASS above, both generations are covered. Merging at d2dcb0af.

@DjDeveloperr
DjDeveloperr merged commit 0d55602 into aurora-silicon:main Dec 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:wireless Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants