[PATCH ath-next 5/7] wifi: ath12k: restart STA link vdev on chanctx assign if channel changed
From: Miaoqing Pan
Date: Tue Nov 17 2026 - 21:56:31 EST
When mac80211 changes the active links on an MLO STA interface it calls
assign_vif_chanctx() and unassign_vif_chanctx() on the affected links.
A deactivated link has its channel context released, and a link that is
activated again gets one assigned.
Currently unassign_vif_chanctx() does not stop the vdev of a STA link,
but it still clears is_started. The vdev and the BSS peer therefore stay
in firmware while the driver believes the vdev is not started. When the
link gets a chanctx again, assign_vif_chanctx() starts a vdev that is
already running in firmware and counts it twice in num_started_vdevs.
Fix this by not clearing is_started for a STA vdev in
unassign_vif_chanctx(), so the driver state matches the firmware state
and the vdev and the BSS peer stay in firmware across an active links
change. Only non-STA vdevs, which are stopped there, clear is_started.
A STA vdev may already have been stopped, with is_started cleared, by
station removal, so the is_started check at entry is limited to non-STA
vdev types.
As a result, assign_vif_chanctx() can see a STA vdev that is still
started. Compare the new channel with the one the vdev was started on,
recorded in started_chandef:
- Same channel: nothing to do, the vdev is already running on it.
- Channel changed: restart the vdev on the new chanctx (vdev restart if
it is up, otherwise stop and start), the same way
switch_vif_chanctx() does.
A started vdev of any other type still hits WARN_ON() and returns
-EBUSY as before.
Since unassign_vif_chanctx() no longer clears is_started for a STA vdev,
clear it in ath12k_mac_station_remove(), where the STA vdev is actually
stopped, but only if the stop succeeded. Otherwise is_started stays set
after a disconnect although the vdev is stopped in firmware, and on
targets using vdev_start_delay (WCN7850, QCC2072)
ath12k_mac_station_add() skips ath12k_start_vdev_delay() on reconnect,
so the vdev is never started.
Tested-on: QCC2072 hw1.0 PCI WLAN.COL.1.0.c2-00277-QCACOLSWPL_V1_TO_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Signed-off-by: Miaoqing Pan <miaoqing.pan@xxxxxxxxxxxxxxxx>
---
drivers/net/wireless/ath/ath12k/core.h | 5 +++
drivers/net/wireless/ath/ath12k/mac.c | 47 +++++++++++++++++++++++---
2 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 3a92a4b03359..7c7057468916 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -331,6 +331,11 @@ struct ath12k_link_vif {
bool is_created;
bool is_started;
bool is_up;
+ /*
+ * Channel the vdev was last started on. Used to tell whether a
+ * still started vdev needs a restart when it gets a chanctx again.
+ */
+ struct cfg80211_chan_def started_chandef;
u8 bssid[ETH_ALEN];
struct cfg80211_bitrate_mask bitrate_mask;
struct delayed_work connection_loss_work;
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 08d9af0a1127..f57d4ef413e8 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7167,6 +7167,13 @@ static int ath12k_mac_station_remove(struct ath12k *ar,
if (ret)
ath12k_warn(ar->ab, "failed to stop vdev %i: %d\n",
arvif->vdev_id, ret);
+ else
+ /*
+ * vdev is stopped in firmware now; clear the flag so
+ * ath12k_mac_station_add() starts it again on reconnect
+ * (vdev_start_delay targets).
+ */
+ arvif->is_started = false;
}
if (sta->mlo)
@@ -11536,6 +11543,7 @@ ath12k_mac_vdev_start_restart(struct ath12k_link_vif *arvif,
}
ar->num_started_vdevs++;
+ arvif->started_chandef = *chandef;
ath12k_dbg(ab, ATH12K_DBG_MAC, "vdev %pM started, vdev_id %d\n",
ahvif->vif->addr, arvif->vdev_id);
@@ -12430,9 +12438,32 @@ ath12k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
goto out;
}
- if (WARN_ON(arvif->is_started)) {
- ret = -EBUSY;
- goto out;
+ if (arvif->is_started) {
+ if (WARN_ON(ahvif->vdev_type != WMI_VDEV_TYPE_STA)) {
+ ret = -EBUSY;
+ goto out;
+ }
+
+ if (cfg80211_chandef_identical(&arvif->started_chandef, &ctx->def)) {
+ ath12k_dbg(ab, ATH12K_DBG_MAC,
+ "vdev %d still started on same channel, skip restart\n",
+ arvif->vdev_id);
+ return 0;
+ }
+
+ if (arvif->is_up) {
+ ret = ath12k_mac_vdev_restart(arvif, ctx);
+ } else {
+ ret = ath12k_mac_vdev_stop(arvif);
+ if (!ret)
+ ret = ath12k_mac_vdev_start(arvif, ctx);
+ }
+
+ if (ret)
+ ath12k_warn(ab, "failed to restart vdev %i addr %pM on freq %d: %d\n",
+ arvif->vdev_id, vif->addr,
+ ctx->def.chan->center_freq, ret);
+ return ret;
}
if (ahvif->vdev_type == WMI_VDEV_TYPE_MONITOR) {
@@ -12497,7 +12528,7 @@ ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
"mac chanctx unassign ptr %p vdev_id %i\n",
ctx, arvif->vdev_id);
- WARN_ON(!arvif->is_started);
+ WARN_ON(ahvif->vdev_type != WMI_VDEV_TYPE_STA && !arvif->is_started);
if (ahvif->vdev_type == WMI_VDEV_TYPE_MONITOR) {
ret = ath12k_mac_monitor_stop(ar);
@@ -12514,8 +12545,14 @@ ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
if (ret)
ath12k_warn(ab, "failed to stop vdev %i: %d\n",
arvif->vdev_id, ret);
+ arvif->is_started = false;
}
- arvif->is_started = false;
+
+ /*
+ * is_started is intentionally not cleared for a STA vdev: it is not
+ * stopped here, so the flag has to keep matching the firmware state.
+ * assign_vif_chanctx() restarts it if the channel changed.
+ */
if (test_bit(WMI_TLV_SERVICE_11D_OFFLOAD, ab->wmi_ab.svc_map) &&
ahvif->vdev_type == WMI_VDEV_TYPE_STA &&
--
2.34.1