From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: Andre Eikmeyer <dev@deq.rocks>
Cc: arend.vanspriel@broadcom.com, linux-wireless@vger.kernel.org,
brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com,
linux-kernel@vger.kernel.org,
Sasha Finkelstein <k@chaosmail.tech>,
Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
Aditya Garg <aditya.garg@linux.dev>,
Yossef Osman <Yossef.Osman@proton.me>
Subject: Re: [PATCH wireless-next v2 5/6] wifi: brcmfmac: add vendor commands for AWDL
Date: Thu, 26 Nov 2026 17:14:44 +0100 [thread overview]
Message-ID: <20261126161444.2484980-6-arend.vanspriel@broadcom.com> (raw)
In-Reply-To: <20261125190254.176055-6-dev@deq.rocks>
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@proton.me>
> Tested-by: Aditya Garg <aditya.garg@linux.dev>
> 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
next prev parent reply other threads:[~2026-11-26 16:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 19:02 [PATCH wireless-next v2 0/6] wifi: brcmfmac: AWDL for AirDrop on Apple T2 Macs Andre Eikmeyer
2026-11-25 19:02 ` [PATCH wireless-next v2 1/6] wifi: brcmfmac: move the interface_create definitions to fwil_types.h Andre Eikmeyer
2026-11-26 16:14 ` Arend van Spriel
2026-11-25 19:02 ` [PATCH wireless-next v2 2/6] wifi: brcmfmac: detect AWDL support of the firmware Andre Eikmeyer
2026-11-26 16:14 ` Arend van Spriel
2026-11-25 19:02 ` [PATCH wireless-next v2 3/6] wifi: brcmfmac: create and remove the AWDL interface Andre Eikmeyer
2026-11-26 16:14 ` Arend van Spriel
2026-11-25 19:02 ` [PATCH wireless-next v2 4/6] wifi: brcmfmac: add the AWDL data path Andre Eikmeyer
2026-11-26 16:14 ` Arend van Spriel
2026-11-25 19:02 ` [PATCH wireless-next v2 5/6] wifi: brcmfmac: add vendor commands for AWDL Andre Eikmeyer
2026-11-26 16:14 ` Arend van Spriel [this message]
2026-11-25 19:02 ` [PATCH wireless-next v2 6/6] wifi: brcmfmac: pass AWDL frames and role changes to user space Andre Eikmeyer
2026-11-26 16:14 ` Arend van Spriel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126161444.2484980-6-arend.vanspriel@broadcom.com \
--to=arend.vanspriel@broadcom.com \
--cc=Yossef.Osman@proton.me \
--cc=aditya.garg@linux.dev \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=dev@deq.rocks \
--cc=j@jannau.net \
--cc=k@chaosmail.tech \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=sven@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®