Linux wireless drivers development
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, Francesco Dolcini <francesco@dolcini.it>
Subject: Re: [PATCH wireless-next v2 09/18] wifi: cfg80211: document wiphy mutex for radar/CAC events
Date: Mon, 5 Oct 2026 11:36:18 -0700	[thread overview]
Message-ID: <asPuIvquaejUkaLE@google.com> (raw)
In-Reply-To: <c5990e315e83eb6014d6ab02f9846a9d10a901f8.camel@sipsolutions.net>

On Mon, Oct 05, 2026 at 07:52:11PM +0200, Johannes Berg wrote:
> Woah, thanks for looking through this! :-)

Ha, well sometimes I read stuff with the "mwifiex" keyword in it :)

> On Mon, 2026-10-05 at 10:46 -0700, Brian Norris wrote:
> > > The DFS state of channels and the CAC state of the wdev is
> > > protected by the wiphy mutex, so the radar and CAC events
> > > must be reported by drivers with the wiphy mutex held. In
> > > mac80211 we do this, but some drivers don't yet:
> > >  - mwifiex/nxpwifi have an event handling worker,
> > 
> > FWIW, one of the two contexts that call cfg80211_cac_event() in mwifiex
> > does *not* (by inspection) seem to hold this. 
> 
> Yeah I know - that's why I wrote "some drivers __don't__ yet".
> 
> It's always been broken though, and I kinda just wanted to move on. It's
> racy, but I think mostly wrt. the valid_links warning (which isn't
> relevant here) and the data accesses, nothing worse will happen.

OK.

> > Is this something you'd
> > prefer individual driver users/maintainers resolve?
> 
> I think so. Or we can discuss it should be async in cfg80211, or an
> async version? I guess first we should discuss how to solve it either
> way, and look at all the drivers that still have the issue.

At first, I thought it'd be trivial to just throw in
wiphy_lock()/unlock() in 1 or 2 places, similar to commit 0d7c2194f17c
("wifi: mwifiex: add missing locking for cfg80211 calls"). But I'm not
sure that's actually sound -- it might introduce some locking inversion
problems, where (for example) mwifiex_del_virtual_intf() expects to be
able to flush/destroy these workers, but it's already holding the wiphy
mutex.

(I wonder if commit 0d7c2194f17c is similarly unsound.)

Either I'm missing something (quite possible), or it'll take a little
more thought on what the right solution should be.

Anyway, I'm fine with your approach of document first, fix later. It's
hard to move anything if you have to reason through every crazy /
lightly-maintained driver for every problem.

> > >  void cfg80211_cac_event(struct net_device *netdev,
> > >  			const struct cfg80211_chan_def *chandef,
> > 
> > Should we add an assert to this API?
> > 
> > 	lockdep_assert_wiphy(wiphy);
> 
> Well I figured if I do that now then tools (and perhaps people) will
> start complaining and that'd just put more pressure on everyone to fix
> it ... that's why I didn't yet, but I guess I should've outlined that
> better in the commit message (even after a --- marker).

Ack.

Brian

  reply	other threads:[~2026-10-05 18:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 10:03 [PATCH wireless-next v2 01/18] wifi: further RTNL redux Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 01/18] wifi: cfg80211: track netdev running state under wiphy mutex Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 02/18] wifi: nl80211: allow device lookup under RCU Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 03/18] wifi: nl80211: avoid rtnl for commands that don't want it Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 04/18] wifi: nl80211: don't take rtnl for most dumps Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 05/18] wifi: cfg80211: reg: update channels under wiphy mutex Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 06/18] wifi: cfg80211: reg: set intersected regd " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 07/18] wifi: cfg80211: update channel DFS data " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 08/18] wifi: mac80211_hwsim: call cfg80211 event with " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 09/18] wifi: cfg80211: document wiphy mutex for radar/CAC events Johannes Berg
2026-10-05 17:46   ` Brian Norris
2026-10-05 17:52     ` Johannes Berg
2026-10-05 18:36       ` Brian Norris [this message]
2026-10-05 18:43         ` Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 10/18] wifi: cfg80211: add a mutex for regulatory/device list Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 11/18] wifi: cfg80211: allow walking wiphy list under cfg80211_mutex Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 12/18] wifi: ath: use freq_reg_info() under RCU Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 13/18] wifi: brcmsmac: " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 14/18] wifi: rtlwifi: " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 15/18] wifi: nl80211: read WMM reg rule " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 16/18] wifi: ath11k: read wiphy regd " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 17/18] wifi: ath12k: " Johannes Berg
2026-10-05 10:03 ` [PATCH wireless-next v2 18/18] wifi: cfg80211: regulatory: stop using RTNL Johannes Berg

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=asPuIvquaejUkaLE@google.com \
    --to=briannorris@chromium.org \
    --cc=francesco@dolcini.it \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.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