From: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
To: Johannes Berg <johannes@sipsolutions.net>,
linux-wireless@vger.kernel.org
Cc: "ath12k@lists.infradead.org" <ath12k@lists.infradead.org>
Subject: Re: [RFC PATCH 00/12] wifi: AP side locking improvements
Date: Mon, 5 Oct 2026 19:05:39 -0700 [thread overview]
Message-ID: <3db68884-f6b5-499c-9959-7eec59ba40cd@oss.qualcomm.com> (raw)
In-Reply-To: <20261004214504.1636783-14-johannes@sipsolutions.net>
On 10/4/2026 2:40 PM, Johannes Berg wrote:
> This obviously goes on top of my (fixed) RTNL redux series.
>
> The idea here is that wiphy mutex can be held for quite a bit
> of time (e.g. waiting for firmware), but beacon updates (e.g.
> with the critical update design I had proposed a long while
> back) and other things should be fast.
>
> So with this not all things require wiphy mutex. These are:
>
> - beacon and related template updates
> (this one needs driver opt-in),
> - mgmt frame TX,
> - control port TX, and
> - peer probe.
>
> This does make the implementation slightly more complex, but
> the added complexity is almost entirely in mac80211 (and some
> in cfg80211), unless a driver wants to opt in to unlocked
> beacon/template updates, which it has to implement itself for
> obvious reasons.
>
> I think we probably want this even without the critical update
> design we're still debating, but I thought I'd throw this out
> here because a lot of the discussion has been focused on the
> latencies throughout the stack, and I never thought they were
> fundamental. QED ;-)
>
> johannes
With both the redux and this series applied, I prompted my review agent:
prior to the 2 patchsets (18 patches and 12 patches) ath12k relied upon the
wiphy mutex to serialize many of the mac80211 operations. are any ath12k
object references now subject to new race conditions with this entire set of
30 patches applied?
The reply:
<LLM>
New Race: ath12k_reg_notifier vs ath12k_mac_op_start/ath12k_mac_op_stop on
ah->state
Before the series: ath12k_reg_notifier was called from
notify_self_managed_wiphys(), which ran inside reg_todo() under RTNL.
ath12k_mac_op_start() and ath12k_mac_op_stop() both assert
lockdep_assert_wiphy() at entry — and mac80211 calls them holding the wiphy
lock. The wiphy lock was acquired under RTNL (rtnl_lock() → wiphy_lock()), so
RTNL serialized the notifier against start/stop.
After the series (patch 18, 7fccd0f981b5): reg_todo() now holds cfg80211_mutex
instead of RTNL. notify_self_managed_wiphys() calls ath12k_reg_notifier()
holding only cfg80211_mutex — no wiphy lock, no RTNL.
ath12k_mac_op_start()/ath12k_mac_op_stop() hold only the wiphy lock — no
cfg80211_mutex. These two locks are disjoint.
Inside ath12k_reg_notifier(), the first thing it does is read ah->state
without holding ah->hw_mutex:
if (ah->state != ATH12K_HW_STATE_ON) /* plain read, no hw_mutex */
return;
ah->state is written exclusively under ah->hw_mutex (in ath12k_mac_op_start(),
ath12k_mac_op_stop(), and ath12k_mac_op_reconfig_complete()), none of which
hold cfg80211_mutex. The reg notifier (on CPU A, holding cfg80211_mutex) and
mac_op_stop (on CPU B, holding wiphy lock + hw_mutex) can now execute
concurrently. The ah->state read in the notifier and the ah->state =
ATH12K_HW_STATE_OFF write in stop share no common lock. This is a new data
race.
The same applies to the ah->regd_updated = false write further down in the
notifier and the ah->regd_updated = true write in ath12k_regd_update() (called
from a workqueue with no lock), and the ah->regd_updated read in
ath12k_regd_update() — none of these are serialized.
Before the series, RTNL acting as a global serializer masked all of this.
Pre-existing but Newly Exposed: ath12k_regd_update vs ath12k_reg_notifier on
ah->regd_updated
ath12k_regd_update() is called from ath12k_regd_update_work (a workqueue) and
reads then writes ah->regd_updated with no lock at all. ath12k_reg_notifier()
writes ah->regd_updated = false also with no lock. These two were already
concurrent before the series — workqueue items are not serialized by RTNL — so
this is not a new problem introduced by the patches. However, RTNL previously
prevented the reg notifier from being called while a mac op was running,
which reduced the window. That window is now wider.
</LLM>
So we'll probably need to address those issue.
/jeff
next prev parent reply other threads:[~2026-10-06 2:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 21:40 [RFC PATCH 00/12] wifi: AP side locking improvements Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 01/12] wifi: mac80211: protect AP template pointers with a spinlock Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 02/12] wifi: nl80211: add NL80211_CMD_UPDATE_BEACON Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 03/12] wifi: mac80211: implement lockless beacon updates Johannes Berg
2026-10-09 16:05 ` Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 04/12] wifi: mac80211_hwsim: support " Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 05/12] wifi: cfg80211: make cookie counter atomic Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 06/12] wifi: nl80211: allow mgmt frame TX without wiphy mutex Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 07/12] wifi: mac80211: refactor mgmt frames TX Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 08/12] wifi: mac80211: implement mgmt_tx_unlocked() Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 09/12] wifi: mac80211: don't require wiphy mutex for probe_peer Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 10/12] wifi: nl80211: probe peers without wiphy mutex Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 11/12] wifi: mac80211: don't require wiphy mutex for control port TX Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 12/12] wifi: nl80211: transmit control port frames without wiphy mutex Johannes Berg
2026-10-05 8:43 ` [RFC PATCH 00/12] wifi: AP side locking improvements Johannes Berg
2026-10-06 2:05 ` Jeff Johnson [this message]
2026-10-06 7:14 ` Johannes Berg
2026-10-06 7:55 ` 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=3db68884-f6b5-499c-9959-7eec59ba40cd@oss.qualcomm.com \
--to=jeff.johnson@oss.qualcomm.com \
--cc=ath12k@lists.infradead.org \
--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