Re: [PATCH wireless-next v2 5/6] wifi: brcmfmac: add vendor commands for AWDL
From: Arend van Spriel
Date: Thu Nov 26 2026 - 11:15:26 EST
On Wed, 25 Nov 2026 20:02:53 +0100, Andre Eikmeyer <dev@deq.rocks> wrote:
> AWDL election, peer discovery and services run in user space, the
> firmware carries the AWDL frames and data. Add vendor commands of the
> Broadcom OUI on the primary interface, described in vendor.h:
[...]
> Tested-by: Yossef Osman <Yossef.Osman@xxxxxxxxx>
> Tested-by: Aditya Garg <aditya.garg@xxxxxxxxx>
> Signed-off-by: Andre Eikmeyer <dev@deq.rocks>
> ---
> .../broadcom/brcm80211/brcmfmac/awdl.c | 644 +++++++++++++++++-
> .../broadcom/brcm80211/brcmfmac/awdl.h | 53 ++
> .../broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +-
> .../broadcom/brcm80211/brcmfmac/feature.c | 6 +
> .../broadcom/brcm80211/brcmfmac/feature.h | 5 +-
> .../broadcom/brcm80211/brcmfmac/vendor.c | 82 +++
> .../broadcom/brcm80211/brcmfmac/vendor.h | 92 +++
> 7 files changed, 881 insertions(+), 6 deletions(-)
[...]
> @@ -116,9 +238,12 @@ bool brcmf_awdl_if_removed(struct brcmf_pub *drvr, struct brcmf_if *ifp)
> awdl->ifp = NULL;
> }
> spin_unlock(&awdl->lock);
> - if (!requested)
> + if (!requested) {
> brcmf_proto_configure_addr_mode(drvr, ifp->ifidx,
> ADDR_INDIRECT);
> + brcmf_awdl_send_result(drvr, BRCMF_VNDR_EVTS_AWDL_STOPPED,
> + -ENOLINK, NULL);
> + }
> return requested;
> }
brcmf_awdl_if_removed() clears awdl->ifp in the firmware event worker
without the wiphy mutex, and brcmf_fweh_handle_if_event() then
unregisters the net_device and frees the ifp from there too. awdl.h
says changes of @ifp hold RTNL and the wiphy mutex. The vendor commands
(wiphy mutex only) and aftx_work/settle_work check awdl->ifp and then
use it several times, so a firmware initiated removal in between gives a
NULL pointer or a freed ifp in brcmf_fil_iovar_data_set().
AWDL_STOPPED is also sent before the interface is gone on the host, so
a START sent in reaction to it can still fail with -EBUSY from
brcmf_awdl_ifidx_used().
Handing the unsolicited removal over to a work item that runs with RTNL
and the wiphy mutex, and sends AWDL_STOPPED when it is done, would fix
both. The event worker itself cannot take the locks because
brcmf_awdl_add() and brcmf_awdl_del() wait for its events with them held.
[...]
> +/*
> + * Removes the AWDL interface before system sleep, with RTNL and the wiphy
> + * mutex held, while the firmware still takes commands. A queued operation is
> + * dropped.
> + */
> +void brcmf_awdl_suspend(struct brcmf_pub *drvr)
> +{
> + struct brcmf_awdl *awdl = &drvr->awdl;
> + int err;
> +
> + spin_lock(&awdl->lock);
> + awdl->op = BRCMF_AWDL_OP_NONE;
> + spin_unlock(&awdl->lock);
> + if (!awdl->ifp)
> + return;
> + err = brcmf_awdl_del(drvr);
> + brcmf_awdl_send_result(drvr, BRCMF_VNDR_EVTS_AWDL_STOPPED, err, NULL);
> +}
A queued AWDL_START is dropped here without an AWDL_STARTED event, user
space waits for an answer that never comes. Answer a dropped START with
AWDL_STARTED and an error (e.g. -ECANCELED).
[...]
> + * @BRCMF_VNDR_CMDS_AWDL_SET_SYNC: synchronize to the master of
> + * %BRCMF_AWDL_ATTR_MASTER, %BRCMF_AWDL_ATTR_MASTER_METRIC and
> + * %BRCMF_AWDL_ATTR_MASTER_DISTANCE. Without %BRCMF_AWDL_ATTR_MASTER the
> + * device is its own master.
The commit message says awdl_opmode fails while the firmware does not
know a new master yet, and SET_SYNC returns the first error of the
refresh. So user space gets an error on a normal master change and only
the next SET_FRAMES or SET_SYNC sends awdl_opmode again. As this is ABI
it better be documented here, or do not return that error.
[...]
Regards,
Arend