Skip to content

wifi: brcmfmac: capability-gated LPAS associated sleep (v2, supersedes #1216) - #1218

Closed
RyanTheTide wants to merge 6 commits into
integration/aurorafrom
wifi/brcmf-lpas-2
Closed

RyanTheTide wants to merge 6 commits into
integration/aurorafrom
wifi/brcmf-lpas-2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #1216 (same series, rebased onto current integration/aurora; that branch conflicted).

What

brcmfmac keeps the Wi-Fi association across s2idle on firmware that has the lpas capability but no wowl iovar (BCM4387 on the M2 and the M1 Pro class machines returns -23 for wowl). Today cfg80211 disconnects on every suspend and the Mac needs ~4 s after resume to get back on the network.

Commits (driver changes under drivers/net/wireless/broadcom/brcm80211/brcmfmac/, plus the host-test harness):

  1. advertise WoWLAN on retained Apple PCIe (drop the Apple chip-ID quirk, keep the firmware gate)
  2. arm a DT-selected (wakeup-source) in-band PCIe MSI for WoWLAN, s2idle only, balanced wake-IRQ handling
  3. preserve existing PCI wakeup ownership
  4. LPAS fallback: BRCMF_FEAT_LPAS only from the firmware cap token lpas; save PM, ARP/ND, packet filter, event mask and nolinkup, install a minimal unicast filter, enable lpas last; unwind on any failure so cfg80211 falls back to the normal disconnect; restore after D0/HOSTREADY

Without lpas in cap, or without retained transport and a wake route, nothing is advertised and behaviour is unchanged.

Changes from #1216: conflict in brcmf_pcie_pm_enter_D3() resolved against #1081 (WoWLAN refusal checks first, then the TX quiesce; the D3-ack timeout path keeps brcmf_msgbuf_resume()); the two warning-only follow-ups are squashed into the LPAS commit (tree identical); the LPAS commit message had literal \n sequences, fixed.

Firmware capability (M2, J413, BCM4387, fleet33)

Read with the brcmfmac nl80211 vendor DCMD (cap iovar, read-only): lpas present, wowl absent; ndoe, arpoe, pktfltr2, tko, evt_ext present. The M2's BCM4387 reports PME from D3hot, so the wake route is available without a DT change.

Hardware receipts (M2 J413, 7.3.0-aurora-fleet33, 2026-11-08)

Test modules built against fleet33 exactly (009c878 + this branch's brcm80211 dir, fleet33 .config, fleet33 signing key), swapped in with a non-persistent bind mount and restored afterwards. Each row is 3 real rtcwake -d rtc1 -m freeze -s 15 cycles. Time is from resume to the first gateway ping reply.

module WoWLAN sleep path ping after resume association
stock n/a (-95) NM Sleep 4.06-4.12 s dropped 3/3
this PR (e16b5cb) off (default) NM Sleep 4.03-4.12 s dropped 3/3 (same as stock)
this PR any NM Sleep 5.7-7.6 s kept in firmware, then NM drops it at wake
this PR any direct freeze 13.6-14.5 ms kept 3/3 (same BSSID, connected time keeps counting)
stock n/a direct freeze 7.43-7.44 s dropped 3/3
  • 0 new AVC, 0 brcmfmac errors, 0 flowring txstatus warnings in every phase. iw phy wowlan show advertises only "wake up on anything".
  • Unicast wake: with any set and a 90 s RTC alarm, pings from another host from t+25 s did not wake the M2 (slept 92.6 s; association still kept). Its wake route is PCI PME only; the in-band MSI route needs wakeup-source on the wifi node in the DT, which the J413 DT doesn't have yet.
  • NetworkManager 1.56.1 doesn't tear down a WoWLAN device when the system goes to sleep, but it takes it down at wake (wld0 activated -> unmanaged, a locally generated deauth with reason 3), and then a full reconnect follows. That's why the NM row is slower, and the lid-close path (logind -> NM Sleep) won't benefit until NM keeps the device.

Status: draft. The driver mechanism works. There's no gain on the default path (WoWLAN off) and no regression either. The user-visible gain needs the NM wake behaviour fixed plus the DT wake route. The fixed head (3518415 + harness) still has to be re-run on the M2.

Traces (lab): traces/wifi-bt/20261108-m2-lpas-s2idle, traces/wifi-bt/20261108-m2-fwcap.

🤖 Generated with Claude Code

The BCM4378 and BCM4387 on Apple Arm systems retain firmware across the existing D3 path, but their endpoint does not advertise standard D3hot PME. The platform has a separate wake route, so using PME as the firmware feature-probe gate prevents cfg80211 from ever keeping an association.

Split transport retention from host wake routing, retain the standard PME test, and opt only the public Apple Arm BCM4378/4387 identities into the platform wake route. Require successful wowl and wowl_cap probes before advertising anything.

Make WoWLAN setup transactional. Check each retained-state operation and unwind to cfg80211's ordinary disconnect fallback on failure. Restore the bus WoWLAN state on resume. Firmware without the public capability therefore keeps the previous behavior.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Replace the Apple machine quirk with wakeup-source permission and an
allocated MSI. Keep the firmware capability gate and the ordinary PCI
PME path.

After the firmware host-sleep acknowledgment, arm the IRQ and keep the
PCI function in D0 using pci_save_state(), so PCI PM also retains its
upstream bridges. Limit this in-band route to s2idle. Account for an
early interrupt before suspend_device_irqs(), and balance wake arming on
resume, thaw, suspend failure and IRQ teardown.

Use explicit enable_irq_wake() rather than automatic wakeirq arming so
an arming failure can refuse suspend and restore the bus. The wiphy
resume callback then clears the firmware policy on the PM unwind.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Track the wakeup source created for a DT-selected MSI separately from
pre-existing PCI wake capability. On IRQ teardown, remove only the
source we created and restore the original capability. Leave an already
enabled source owned by the bus or platform intact.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Firmware with the lpas capability can retain an association without the
standard wowl iovar. Advertise only the generic WoWLAN any trigger when
retained transport and a wake route are both available.

Save PM, ARP/ND, packet-filter, event-mask and link-event policy, install
a minimal public unicast filter, and enable lpas last. Unwind every
completed step on failure so cfg80211 can use its ordinary disconnect
fallback. Restore the saved policy after the existing D0/HOSTREADY path
and report an unspecified wake reason.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The LPAS branch of brcmf_cfg80211_resume() returned straight after
restoring the firmware policy, so cfg->suspended stayed set. Country
updates deferred across the sleep were then never applied and every
later hint stayed pending.

Fall through to the common tail instead: clear the suspended state,
replay the deferred country update, then return the restore result.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Stub the in-band wake fields and helpers that brcmf_pcie_pm_enter_D3()
and the LPAS resume path now use, and add an LPAS resume control: the
restore runs with the bus up, the wake is reported, the suspended state
clears and a country hint deferred across the sleep is applied, also
when the restore fails. The lpas-resume mutation (early return) fails
the control.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Re-run on the fixed head (3518415, LPAS resume clears the suspended state) on the M2, kernel 7.3.0-aurora-fleet35. Modules were built against dc8dd01 exactly, and the stock module was restored afterwards.

  • WoWLAN any with direct freeze, 3 RTC s2idle cycles: association kept 3/3 (same BSSID, connected time 15->33, 45->65, 74->92 s), first ping 12.5-14.7 ms after resume, 0 disconnects. iw reg get still shows country AU after the resumes.
  • WoWLAN any with NM Sleep, 2 cycles: 5.6-5.8 s. NetworkManager takes the WoWLAN device down at wake, same as before.
  • 0 AVC, 0 brcmfmac errors, 0 flowring txstatus warnings. Host-tests CI is green on 23c88bd.

Leaving this as a draft. The default path (WoWLAN off) behaves the same as stock. The lid-close path will only gain once NetworkManager keeps a WoWLAN device associated across wake and the J413 DT gets a wakeup-source wake route.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #1232 (adds magic-packet WoWLAN, the J413/J415 wake route and the resume fix on current integration/aurora).

@RyanTheTide RyanTheTide closed this Nov 8, 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.

1 participant