Re: [PATCH wireless-next v2 3/6] wifi: brcmfmac: create and remove the AWDL interface

From: Arend van Spriel

Date: Thu Nov 26 2026 - 11:15:04 EST


On Wed, 25 Nov 2026 20:02:51 +0100, Andre Eikmeyer <dev@deq.rocks> wrote:
> Firmware with AWDL support creates an interface of type AWDL with
> interface_create. The host gives the MAC address, the firmware
> interface index 2 and the AWDL BSSID 00:25:00:ff:94:73.

[...]

> Signed-off-by: Andre Eikmeyer <dev@deq.rocks>
> ---
> .../broadcom/brcm80211/brcmfmac/Makefile | 3 +-
> .../broadcom/brcm80211/brcmfmac/awdl.c | 288 ++++++++++++++++++
> .../broadcom/brcm80211/brcmfmac/awdl.h | 51 ++++
> .../broadcom/brcm80211/brcmfmac/cfg80211.c | 6 +
> .../broadcom/brcm80211/brcmfmac/core.c | 65 +++-
> .../broadcom/brcm80211/brcmfmac/core.h | 7 +
> .../broadcom/brcm80211/brcmfmac/fweh.c | 17 ++
> 7 files changed, 428 insertions(+), 9 deletions(-)
> create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c
> create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.h

[...]

> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c
> new file mode 100644
> index 000000000000..1ef6dd50958f
> --- /dev/null
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/awdl.c
> @@ -0,0 +1,288 @@
> +// SPDX-License-Identifier: GPL-2.0

Missed this in the earlier review round, but all other brcmfmac files are ISC.
I always struggle with the per-file identifiers. If ISC is acceptable for you
please consider changing this here and in awdl.h.

[...]

> + spin_lock(&awdl->lock);
> + ether_addr_copy(awdl->mac, mac);
> + awdl->adding = true;
> + awdl->abandoned = false;
> + reinit_completion(&awdl->if_event);
> + spin_unlock(&awdl->lock);

awdl->abandoned is cleared here. After an add that timed out, the
firmware interface event may still be on its way. If the next add fails
in interface_create (the interface exists) the late event is claimed by
nobody, brcmf_add_if() keeps the ifp with ifidx 2 in iflist and
brcmf_awdl_ifidx_used() blocks every later add, as in v1. Keep
abandoned set here and clear it when brcmf_awdl_if_added() has claimed
an event instead.

[...]

> + spin_lock(&awdl->lock);
> + awdl->adding = false;
> + ifp = awdl->ifp;
> + /* The firmware created the interface, its event may still come */
> + if (!err && !ifp)
> + awdl->abandoned = true;
> + spin_unlock(&awdl->lock);
> +
> + if (err) {
> + bphy_err(drvr, "AWDL interface_create failed: %d\n", err);
> + return err;
> + }
> + if (!left || !ifp) {
> + bphy_err(drvr, "no interface event for the AWDL interface\n");
> + return -ETIMEDOUT;
> + }

If the event is handled after wait_for_completion_timeout() expired but
before the spin_lock() above, ifp is set and adding is already cleared.
Then !left makes this return -ETIMEDOUT with awdl->ifp set and no
network device registered, so AWDL_START reports a failure while the
interface is kept. Test !ifp only.

[...]

Regards,
Arend