Repository navigation
wifi: brcmfmac: negotiate PCIe in-band device wake - #1261
RyanTheTide wants to merge 14 commits into
Conversation
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
The LPAS fallback only knew the "any" trigger, which passes every unicast frame and so wakes the host for any traffic addressed to it. That is too broad for a default Wake-on-WLAN setting. Advertise WIPHY_WOWLAN_MAGIC_PKT as well and, for that trigger, install forward-on-match packet filters that match the magic sequence (six 0xff bytes, then the interface address sixteen times) at the UDP payload start over IPv4 and IPv6 and after EtherType 0x0842. Every other frame stays in the firmware; ARP and neighbour discovery are still answered by their offloads. "any" keeps its single unicast filter. Track the installed filters in a bitmap so the rollback and the resume path remove exactly what was added. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Allow boards to describe WLAN wake capability. PCIe devices without a host-wake line can use their in-band interrupt. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
The BCM4387 on the M2 MacBook Air (J413, J415) has no separate host-wake line; its firmware wakes the host with the endpoint's allocated MSI. Mark the WLAN node as a wakeup source so brcmfmac arms that MSI for Wake-on-WLAN and keeps the function in D0 across s2idle. Leave the other Apple laptops unchanged until their wake path is tested. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
…offset On BCM4387 firmware the LPAS sleep packet filters only become host-wake sources when they are added and enabled while lpas is already on. The fallback set lpas last, so the association was kept but no frame woke the host: after the D3 handshake the firmware raised no interrupt at all. Set the forward-on-match mode, then lpas, then add and enable the filters, and only then apply nolinkup and the sleep event mask. Use the firmware's magic pattern filter type (variable offset, public WL_PKT_FILTER_TYPE_MAGIC_PATTERN_MATCH) from the start of the Ethernet payload instead of three fixed-offset pattern filters; it covers UDP over IPv4 and IPv6 and EtherType 0x0842. "any" keeps its fixed-offset unicast pattern filter. Also make sure the D2H doorbell/mailbox interrupt mask is enabled when the wake IRQ is armed after the D3 acknowledgement, since that interrupt is the wake signal. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Advertise in-band device wake only when firmware exposes the shared DS capability. Serialize active ring publication with deep-sleep enter and exit, and integrate the state with host D3 and D0 transitions. Add host controls for capability-absent firmware, deferred DS acknowledgement, wake exit and timeout handling, D3 races, unwind, and transport ordering. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
|
M2 (J413, BCM4387 firmware 20.96.31.0.8.7.148), 7.3.0 lab kernel with this branch as modules, module load only (no suspend): attach fails. The firmware reports boot complete, then the first ioctl (CLM load) returns -5, |
Keep in-band deep-sleep mailbox data in shared TCM, but notify firmware through enumeration-core doorbell 1. Config-space SBMBX is not serviced after the endpoint accepts device sleep, so using it for DEVICE_WAKE_ASSERT leaves the first attach ioctl waiting for a DS exit that never arrives. Do not queue reset work from the setup failure path immediately before unconditional driver removal, and cover both regressions in the host model. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Advertising in-band device wake lets firmware request deep sleep before HOSTREADY and the initial DCMDs have completed. The DS state machine starts with no active host reference, so it acknowledges that request. The first attach ring operation then has to wake a not-yet-ready endpoint. Hold one host-active reference from negotiation through brcmf_attach(). This defers DS_ACK until HOSTREADY, CLM and initial ring setup complete. Keep mailbox data in shared TCM and use enumeration-core DB1 for in-band DS notifications, matching the public transport contract. Mark reset removal under bus_reset_lock, but drop the mutex before waiting for reset work. The removing flag still excludes new arming without holding the arming mutex across cancel_work_sync(). Extend the host model with attach admission, DB1 delivery and setup/reset unwind mutation controls. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
|
M2 retests of the two new commits (modules on the running 7.3.0 lab kernels): 5f32b61 (DB1 notify) alone fails attach the same way as before: H2D 0x2, then 0x40 0.3 ms later, no DS_EXIT_NOTE, |
Advertising in-band deep sleep during firmware attach can let the device enter DS before HOSTREADY and CLM complete. The attach-time host-active hold does not make that transition safe and exposes mailbox waits from the threaded IRQ path. Keep in-band DS disabled by default and publish its host capability only after brcmf_attach() when explicitly requested. Defer D2H DS handling to bounded work, reject ring wake waits from the IRQ thread, and make an occupied IRQ-side H2D mailbox a nonblocking failure. Drain mailbox work before reset work during removal. Extend the host control with safe-admission, occupied-mailbox, IRQ deferral and bounded-storm mutations. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
|
M2 retest of 0408f61 (lab twin with the hardware watchdog armed): with the default |
|
Superseded by #1653. |
Summary
This is stacked on #1232 and must land after it.
HOSTCAP_DS_INBAND_DWtogether withHOSTCAP_DS_NO_OOB_DWonly when firmware reportsPCIE_SHARED_INBAND_DSDS_ENTER_REQacknowledgement and boundedDS_EXIT_NOTEwaitsHOST_D3_INFORMand D0/HOSTREADY, with exact unwind on preparation, mailbox, timeout, IRQ-wake, and resume failuresVerification
Buildbox arm64 LLVM=1 W=1 with the PCIe transport explicitly enabled:
Result: rc 0, with no warning or error diagnostics.
Linux host tests:
M2 qualification plan
No target hardware was used for this implementation.
Use the existing RAM-only LPAS test flow on the M2, keeping the PCI function in D0 with MSI wake and the existing ASPM policy:
anyand send one unicast ping to cover the type-0 filter path with the same association-retention checks.