* [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling
@ 2026-11-18 2:55 Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 1/7] wifi: ath12k: add WMI response handling for MLO link set active command Miaoqing Pan
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
mac80211 calls drv_change_vif_links() and drv_change_sta_links() for
both valid-links and active-links changes. ath12k does not distinguish
between the two, causing WARN_ON/incorrect teardown in change_vif_links(),
inconsistent vdev state in the chanctx callbacks, and silent
firmware miss in change_sta_links().
This series derives link object lifetime from vif->valid_links and
sta->valid_links, which mac80211 updates before calling the driver,
instead of from the active-links sets. A STA link vdev keeps running when
its link is deactivated. The active/inactive link state is programmed to
firmware with WMI_MLO_LINK_SET_ACTIVE_CMDID, sent to each device that
holds vdevs of the STA, and only when it differs from the state last
programmed.
Patch 1 adds WMI infrastructure: the response event struct,
WMI_TAG_MLO_LINK_SET_ACTIVE_RESP_EVENT tag, and the event handler
registered in ath12k_wmi_op_rx(). The handler only parses and logs
the event at this point; delivery to the waiter is wired up in patch 7.
Patch 2 sets CTRL_F_OVERWRITE_FORCE_ACTIVE_BITMAP and
CTRL_F_OVERWRITE_FORCE_INACTIVE_BITMAP for FORCE_ACTIVE_INACTIVE, so that
firmware replaces the force bitmaps instead of accumulating them. It also
copies the AP MLD address into the command, and fixes the
CRTL_F_DYNC_FORCE_LINK_NUM typo.
Patch 3 fixes ath12k_mac_op_change_vif_links() so that link vif lifetime
follows vif->valid_links. A link that is only deactivated keeps its link
vif, and a disconnect (valid_links == 0) removes all remaining link vifs.
Patch 4 makes ath12k_mac_get_vif_up() skip links without a channel
context. A deactivated link keeps its vdev up in firmware but has
released its channel context, so it must not be used to derive the
target pdev. The WARN_ON() in ath12k_mac_get_target_pdev_id_from_vif()
is kept.
Patch 5 stops clearing is_started for a STA vdev in
unassign_vif_chanctx(). The vdev is not stopped there, so the flag now
keeps matching the firmware state. assign_vif_chanctx() then compares the
new channel with started_chandef: if it is unchanged nothing is done.
Otherwise the vdev is restarted on the new channel, or stopped and started
if it is not up. Station removal clears is_started once the STA vdev has
been stopped, so that a reconnect on targets with vdev_start_delay starts
the vdev again.
Patch 6 fixes the bounds checks in ath12k_mac_mlo_sta_set_link_active().
The vdev_bitmap and inactive_vdev_bitmap arrays are sized by
WMI_MLO_VDEV_BITMAP_SZ, but the checks compared against
WMI_MLO_LINK_NUM_SZ. Both are 2 today, so there is no functional change.
The checks now use the constant of the array they guard.
Patch 7 makes ath12k_mac_op_change_sta_links() create link STAs for
sta->valid_links that are not yet in links_map. Link STA removal is
still left to STA removal, as firmware does not support it. Once the STA
is authorized, a link holding a channel context is active, and a link
with a link STA and link vif but no channel context is inactive. The
result is compared with ahvif->fw_active_links and
ahvif->fw_inactive_links, and WMI_MLO_LINK_SET_ACTIVE_CMDID is sent only
when it differs. It is sent to each device that holds vdevs of the STA,
with that device's links, and the driver waits for each device's
response, except in the INACTIVE_LINK_NUM case, which is sent without
waiting. If a device holds some of the STA's links but none of them is
active, the update fails with -EOPNOTSUPP. If the device crashes while a request is pending,
ath12k_core_pre_reconfigure_recovery() releases the waiter before it
takes the wiphy lock.
Patch 7 depends on patches 1, 2, 3 and 5: it needs the response event
from patch 1, the ap_mld_addr argument from patch 2, link vifs that
survive deactivation from patch 3, and a STA link vdev that stays
started across deactivation from patch 5. Patches 1-6 each apply to the
base on their own, and the whole series applies in order.
Miaoqing Pan (7):
wifi: ath12k: add WMI response handling for MLO link set active
command
wifi: ath12k: send overwrite flags and AP MLD addr in MLO link set
active
wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link
updates
wifi: ath12k: skip links without channel context in
ath12k_mac_get_vif_up()
wifi: ath12k: restart STA link vdev on chanctx assign if channel
changed
wifi: ath12k: use WMI_MLO_VDEV_BITMAP_SZ for vdev bitmap bounds check
wifi: ath12k: handle MLO active link updates
drivers/net/wireless/ath/ath12k/core.c | 15 ++
drivers/net/wireless/ath/ath12k/core.h | 25 ++
drivers/net/wireless/ath/ath12k/mac.c | 335 ++++++++++++++++++++++---
drivers/net/wireless/ath/ath12k/wmi.c | 54 +++-
drivers/net/wireless/ath/ath12k/wmi.h | 11 +-
5 files changed, 405 insertions(+), 35 deletions(-)
base-commit: 4016f6c3149e7e3faccc1654db6a3030c069383a
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ath-next 1/7] wifi: ath12k: add WMI response handling for MLO link set active command
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
@ 2026-11-18 2:55 ` Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 2/7] wifi: ath12k: send overwrite flags and AP MLD addr in MLO link set active Miaoqing Pan
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
WMI_MLO_LINK_SET_ACTIVE_CMDID allows the driver to tell firmware which
MLO links should be active or inactive. Add parsing and logging of the
corresponding firmware response event. Delivery of the response to the
sender is added in a subsequent patch.
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@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/wmi.c | 36 +++++++++++++++++++++++++++
drivers/net/wireless/ath/ath12k/wmi.h | 6 +++++
2 files changed, 42 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index f41138a7c68e..dde7721182af 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -209,6 +209,8 @@ static const struct ath12k_wmi_tlv_policy ath12k_wmi_tlv_policies[] = {
.min_len = sizeof(struct wmi_obss_color_collision_event) },
[WMI_TAG_PDEV_CSA_SWITCH_COUNT_STATUS_EVENT] = {
.min_len = sizeof(struct ath12k_wmi_pdev_csa_event) },
+ [WMI_TAG_MLO_LINK_SET_ACTIVE_RESP_EVENT] = {
+ .min_len = sizeof(struct wmi_mlo_link_set_active_resp_event) },
};
__le32 ath12k_wmi_tlv_hdr(u32 cmd, u32 len)
@@ -9710,6 +9712,37 @@ static void ath12k_wmi_gtk_offload_status_event(struct ath12k_base *ab,
rcu_read_unlock();
}
+static void ath12k_wmi_event_mlo_link_set_active(struct ath12k_base *ab,
+ struct sk_buff *skb)
+{
+ const struct wmi_mlo_link_set_active_resp_event *ev;
+ u32 status, use_ieee;
+ const void **tb;
+ int ret;
+
+ tb = ath12k_wmi_tlv_parse(ab, skb);
+ if (IS_ERR(tb)) {
+ ret = PTR_ERR(tb);
+ ath12k_warn(ab, "failed to parse mlo link set active resp: %d\n", ret);
+ return;
+ }
+
+ ev = tb[WMI_TAG_MLO_LINK_SET_ACTIVE_RESP_EVENT];
+ if (!ev) {
+ ath12k_warn(ab, "mlo link set active resp event tag not found\n");
+ return;
+ }
+
+ status = le32_to_cpu(ev->status);
+ use_ieee = le32_to_cpu(ev->use_ieee_link_id_bitmap);
+
+ ath12k_dbg(ab, ATH12K_DBG_WMI,
+ "mlo link set active resp status %u use_ieee 0x%x\n",
+ status, use_ieee);
+
+ /* Response delivery to waiters will be wired up in a subsequent patch */
+}
+
static void ath12k_wmi_event_mlo_setup_complete(struct ath12k_base *ab,
struct sk_buff *skb)
{
@@ -10504,6 +10537,9 @@ static void ath12k_wmi_op_rx(struct ath12k_base *ab, struct sk_buff *skb)
case WMI_GTK_OFFLOAD_STATUS_EVENTID:
ath12k_wmi_gtk_offload_status_event(ab, skb);
break;
+ case WMI_MLO_LINK_SET_ACTIVE_RESP_EVENTID:
+ ath12k_wmi_event_mlo_link_set_active(ab, skb);
+ break;
case WMI_MLO_SETUP_COMPLETE_EVENTID:
ath12k_wmi_event_mlo_setup_complete(ab, skb);
break;
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 843f1d11f9c8..68dd13cafe51 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -2016,6 +2016,7 @@ enum wmi_tlv_tag {
WMI_TAG_VDEV_SET_TPC_POWER_CMD = 0x3B5,
WMI_TAG_VDEV_CH_POWER_INFO,
WMI_TAG_MLO_LINK_SET_ACTIVE_CMD = 0x3BE,
+ WMI_TAG_MLO_LINK_SET_ACTIVE_RESP_EVENT,
WMI_TAG_EHT_RATE_SET = 0x3C4,
WMI_TAG_DCS_INCUMBENT_SIGNAL_INTERFERENCE_TYPE = 0x3C5,
WMI_TAG_MLO_TX_SEND_PARAMS,
@@ -6496,6 +6497,11 @@ struct wmi_mlo_link_set_active_arg {
struct wmi_ml_disallow_mode_bmap_arg disallow_bmap[WMI_ML_MAX_DISALLOW_BMAP_COMB];
};
+struct wmi_mlo_link_set_active_resp_event {
+ __le32 status;
+ __le32 use_ieee_link_id_bitmap;
+} __packed;
+
#define ATH12K_MAX_20MHZ_SEGMENTS 16
#define ATH12K_MAX_NUM_ANTENNA 8
#define ATH12K_MAX_NUM_NF_HW_DBM 32
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ath-next 2/7] wifi: ath12k: send overwrite flags and AP MLD addr in MLO link set active
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 1/7] wifi: ath12k: add WMI response handling for MLO link set active command Miaoqing Pan
@ 2026-11-18 2:55 ` Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 3/7] wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link updates Miaoqing Pan
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
When CTRL_F_OVERWRITE_FORCE_ACTIVE_BITMAP or
CTRL_F_OVERWRITE_FORCE_INACTIVE_BITMAP is set in ctrl_flags, firmware
replaces the existing force link bitmaps rather than OR-ing the new bitmap
into the accumulated force state. Without these flags, successive commands
accumulate: forcing link A active and then forcing link B active would
leave both links forced simultaneously, making it impossible to clear a
previously forced link. With the overwrite flags, each command atomically
replaces the force bitmap, giving the driver precise control over which
links are active.
Encode the two overwrite flags in WMI_MLO_LINK_SET_ACTIVE_CMDID, and copy
the AP MLD MAC address from the argument into the command. Also fix the
CRTL_F_DYNC_FORCE_LINK_NUM typo.
ath12k_mac_mlo_sta_set_link_active() takes the AP MLD address and sets
both overwrite flags when the mode is FORCE_ACTIVE_INACTIVE. The existing
caller passes NULL and uses INACTIVE_LINK_NUM, so its behavior does not
change.
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@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 10 ++++++++++
drivers/net/wireless/ath/ath12k/wmi.c | 11 +++++++++--
drivers/net/wireless/ath/ath12k/wmi.h | 4 +++-
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index eee3f38375ae..3f106ac6141c 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7562,6 +7562,7 @@ static bool ath12k_mac_freqs_on_same_mac(struct ath12k_base *ab,
static int ath12k_mac_mlo_sta_set_link_active(struct ath12k_base *ab,
enum wmi_mlo_link_force_reason reason,
enum wmi_mlo_link_force_mode mode,
+ const u8 *ap_mld_addr,
u8 *mlo_vdev_id_lst,
u8 num_mlo_vdev,
u8 *mlo_inactive_vdev_lst,
@@ -7574,6 +7575,14 @@ static int ath12k_mac_mlo_sta_set_link_active(struct ath12k_base *ab,
param.reason = reason;
param.force_mode = mode;
+ if (ap_mld_addr)
+ ether_addr_copy(param.force_cmd.ap_mld_mac_addr, ap_mld_addr);
+
+ if (mode == WMI_MLO_LINK_FORCE_MODE_ACTIVE_INACTIVE) {
+ param.ctrl_flags.overwrite_force_active_bitmap = true;
+ param.ctrl_flags.overwrite_force_inactive_bitmap = true;
+ }
+
for (vdev_idx = 0; vdev_idx < num_mlo_vdev; vdev_idx++) {
vdev_id = mlo_vdev_id_lst[vdev_idx];
entry_idx = vdev_id / 32;
@@ -7672,6 +7681,7 @@ static int ath12k_mac_mlo_sta_update_link_active(struct ath12k_base *ab,
mode = WMI_MLO_LINK_FORCE_MODE_INACTIVE_LINK_NUM;
reason = WMI_MLO_LINK_FORCE_REASON_NEW_CONNECT;
return ath12k_mac_mlo_sta_set_link_active(ab, reason, mode,
+ NULL,
mlo_vdev_id_lst, num_mlo_vdev,
NULL, 0);
}
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index dde7721182af..7e06dbb1e884 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -11832,6 +11832,7 @@ int ath12k_wmi_send_mlo_link_set_active_cmd(struct ath12k_base *ab,
sizeof(*cmd));
cmd->force_mode = cpu_to_le32(arg->force_mode);
cmd->reason = cpu_to_le32(arg->reason);
+ ether_addr_copy(cmd->ap_mld_mac_addr.addr, arg->force_cmd.ap_mld_mac_addr);
ath12k_dbg(ab, ATH12K_DBG_WMI,
"mode %d reason %d num_link_num_param %d num_vdev_bitmap %d inactive %d num_disallow_mode_comb %d",
arg->force_mode, arg->reason, num_link_num_param,
@@ -11844,10 +11845,16 @@ int ath12k_wmi_send_mlo_link_set_active_cmd(struct ath12k_base *ab,
sizeof(*link_num_param) * num_link_num_param);
buf_ptr += TLV_HDR_SIZE;
+ cmd->ctrl_flags =
+ le32_encode_bits(arg->ctrl_flags.overwrite_force_active_bitmap ? 1 : 0,
+ CTRL_F_OVERWRITE_FORCE_ACTIVE_BITMAP) |
+ le32_encode_bits(arg->ctrl_flags.overwrite_force_inactive_bitmap ? 1 : 0,
+ CTRL_F_OVERWRITE_FORCE_INACTIVE_BITMAP);
+
if (num_link_num_param) {
- cmd->ctrl_flags =
+ cmd->ctrl_flags |=
le32_encode_bits(arg->ctrl_flags.dync_force_link_num ? 1 : 0,
- CRTL_F_DYNC_FORCE_LINK_NUM);
+ CTRL_F_DYNC_FORCE_LINK_NUM);
link_num_param = buf_ptr;
for (i = 0; i < num_link_num_param; i++) {
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 68dd13cafe51..6d590b30ecbe 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -6385,7 +6385,9 @@ struct wmi_vdev_set_tpc_power_cmd {
*/
} __packed;
-#define CRTL_F_DYNC_FORCE_LINK_NUM GENMASK(3, 2)
+#define CTRL_F_OVERWRITE_FORCE_ACTIVE_BITMAP BIT(0)
+#define CTRL_F_OVERWRITE_FORCE_INACTIVE_BITMAP BIT(1)
+#define CTRL_F_DYNC_FORCE_LINK_NUM GENMASK(3, 2)
struct wmi_mlo_link_set_active_cmd {
__le32 tlv_header;
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ath-next 3/7] wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link updates
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 1/7] wifi: ath12k: add WMI response handling for MLO link set active command Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 2/7] wifi: ath12k: send overwrite flags and AP MLD addr in MLO link set active Miaoqing Pan
@ 2026-11-18 2:55 ` Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 4/7] wifi: ath12k: skip links without channel context in ath12k_mac_get_vif_up() Miaoqing Pan
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
Currently, ath12k_mac_op_change_vif_links() derives the links to add and
remove from the old_links/new_links arguments: it creates a link vif
(arvif) for each link in ~old_links & new_links and frees the arvif of
each link in old_links & ~new_links.
However, mac80211 invokes drv_change_vif_links() both when the valid
links change and when the active links change. In the first case
old_links/new_links are the valid links. In the second case they are
only the active links, while vif->valid_links is not modified. A link
that is deactivated is therefore reported as removed, although it is
still a valid link of the MLD.
To fix this, derive the arvif lifetime from vif->valid_links, which
mac80211 updates before calling the driver and which an active-link
change leaves untouched. Create an arvif for each link in
valid_links & ~links_map and remove those in links_map & ~valid_links.
A link that is only deactivated keeps its arvif. On disconnect
(valid_links == 0) every remaining arvif is removed. The WARN_ON() for
adding a link that already has an arvif is dropped, since links already
in links_map are not selected for creation.
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
Fixes: 315d80be304a ("wifi: ath12k: allocate new links in change_vif_links()")
Signed-off-by: Miaoqing Pan <miaoqing.pan@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 3f106ac6141c..28cb549b1f46 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -4377,9 +4377,8 @@ ath12k_mac_op_change_vif_links(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *ol[IEEE80211_MLD_MAX_NUM_LINKS])
{
struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
- unsigned long to_remove = old_links & ~new_links;
- unsigned long to_add = ~old_links & new_links;
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+ unsigned long to_remove, to_add;
struct ath12k_link_vif *arvif;
u8 link_id;
@@ -4389,14 +4388,15 @@ ath12k_mac_op_change_vif_links(struct ieee80211_hw *hw,
"mac vif link changed for MLD %pM old_links 0x%x new_links 0x%x\n",
vif->addr, old_links, new_links);
- for_each_set_bit(link_id, &to_add, IEEE80211_MLD_MAX_NUM_LINKS) {
- arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]);
- /* mac80211 wants to add link but driver already has the
- * link. This should not happen ideally.
- */
- if (WARN_ON(arvif))
- return -EINVAL;
+ /*
+ * Link objects follow vif->valid_links, which mac80211 updates before
+ * calling us. old_links/new_links only describe the active links and
+ * must not be used to decide object lifetime.
+ */
+ to_add = vif->valid_links & ~ahvif->links_map;
+ to_remove = ahvif->links_map & ~vif->valid_links;
+ for_each_set_bit(link_id, &to_add, IEEE80211_MLD_MAX_NUM_LINKS) {
arvif = ath12k_mac_assign_link_vif(ah, vif, link_id);
if (WARN_ON(!arvif))
return -EINVAL;
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ath-next 4/7] wifi: ath12k: skip links without channel context in ath12k_mac_get_vif_up()
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
` (2 preceding siblings ...)
2026-11-18 2:55 ` [PATCH ath-next 3/7] wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link updates Miaoqing Pan
@ 2026-11-18 2:55 ` Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 5/7] wifi: ath12k: restart STA link vdev on chanctx assign if channel changed Miaoqing Pan
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
Active-link deactivation releases the channel context of a link while its
vdev stays up in firmware. ath12k_mac_get_vif_up() returns the first vdev
that is up, and that vdev is used to derive the target pdev. It could pick
such a deactivated link, and ath12k_mac_get_target_pdev_id_from_vif() would
then find no channel for it.
Skip links without a channel context in ath12k_mac_get_vif_up(). The
WARN_ON() in ath12k_mac_get_target_pdev_id_from_vif() is kept, since
callers reaching it are expected to have a channel context.
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@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 28cb549b1f46..08d9af0a1127 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -953,12 +953,23 @@ void ath12k_mac_get_any_chanctx_conf_iter(struct ieee80211_hw *hw,
static struct ath12k_link_vif *ath12k_mac_get_vif_up(struct ath12k *ar)
{
struct ath12k_link_vif *arvif;
+ struct cfg80211_chan_def def;
lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy);
list_for_each_entry(arvif, &ar->arvifs, list) {
- if (arvif->is_up)
- return arvif;
+ if (!arvif->is_up)
+ continue;
+
+ /*
+ * A deactivated MLO link keeps its vdev up in firmware but has
+ * released its channel context, so it cannot be used to pick
+ * the target pdev.
+ */
+ if (ath12k_mac_vif_link_chan(arvif->ahvif->vif, arvif->link_id, &def))
+ continue;
+
+ return arvif;
}
return NULL;
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ath-next 5/7] wifi: ath12k: restart STA link vdev on chanctx assign if channel changed
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
` (3 preceding siblings ...)
2026-11-18 2:55 ` [PATCH ath-next 4/7] wifi: ath12k: skip links without channel context in ath12k_mac_get_vif_up() Miaoqing Pan
@ 2026-11-18 2:55 ` Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 6/7] wifi: ath12k: use WMI_MLO_VDEV_BITMAP_SZ for vdev bitmap bounds check Miaoqing Pan
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
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@oss.qualcomm.com>
---
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ath-next 6/7] wifi: ath12k: use WMI_MLO_VDEV_BITMAP_SZ for vdev bitmap bounds check
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
` (4 preceding siblings ...)
2026-11-18 2:55 ` [PATCH ath-next 5/7] wifi: ath12k: restart STA link vdev on chanctx assign if channel changed Miaoqing Pan
@ 2026-11-18 2:55 ` Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 7/7] wifi: ath12k: handle MLO active link updates Miaoqing Pan
2026-11-21 0:16 ` [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Jeff Johnson
7 siblings, 0 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
ath12k_mac_mlo_sta_set_link_active() fills the vdev_bitmap and
inactive_vdev_bitmap arrays of struct wmi_mlo_link_set_active_arg, and
both arrays are sized by WMI_MLO_VDEV_BITMAP_SZ. The bounds checks on
entry_idx, however, compared against WMI_MLO_LINK_NUM_SZ, which is the
size of link_num[].
Both constants are 2 today, so nothing changes at runtime. The check
still has to match the array it guards: if the constants ever diverge,
the wrong bound either rejects valid vdev IDs or allows writes past the
end of the bitmap arrays.
Use WMI_MLO_VDEV_BITMAP_SZ in both the active and the inactive vdev
checks.
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@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index f57d4ef413e8..dfb0f6e678ac 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7605,7 +7605,7 @@ static int ath12k_mac_mlo_sta_set_link_active(struct ath12k_base *ab,
vdev_id = mlo_vdev_id_lst[vdev_idx];
entry_idx = vdev_id / 32;
entry_offset = vdev_id % 32;
- if (entry_idx >= WMI_MLO_LINK_NUM_SZ) {
+ if (entry_idx >= WMI_MLO_VDEV_BITMAP_SZ) {
ath12k_warn(ab, "Invalid entry_idx %d num_mlo_vdev %d vdev %d",
entry_idx, num_mlo_vdev, vdev_id);
return -EINVAL;
@@ -7625,7 +7625,7 @@ static int ath12k_mac_mlo_sta_set_link_active(struct ath12k_base *ab,
vdev_id = mlo_inactive_vdev_lst[vdev_idx];
entry_idx = vdev_id / 32;
entry_offset = vdev_id % 32;
- if (entry_idx >= WMI_MLO_LINK_NUM_SZ) {
+ if (entry_idx >= WMI_MLO_VDEV_BITMAP_SZ) {
ath12k_warn(ab, "Invalid entry_idx %d num_mlo_vdev %d vdev %d",
entry_idx, num_mlo_inactive_vdev, vdev_id);
return -EINVAL;
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ath-next 7/7] wifi: ath12k: handle MLO active link updates
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
` (5 preceding siblings ...)
2026-11-18 2:55 ` [PATCH ath-next 6/7] wifi: ath12k: use WMI_MLO_VDEV_BITMAP_SZ for vdev bitmap bounds check Miaoqing Pan
@ 2026-11-18 2:55 ` Miaoqing Pan
2026-11-21 0:16 ` [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Jeff Johnson
7 siblings, 0 replies; 9+ messages in thread
From: Miaoqing Pan @ 2026-11-18 2:55 UTC (permalink / raw)
To: jjohnson; +Cc: ath12k, linux-wireless, linux-kernel, Miaoqing Pan
ath12k_mac_op_change_sta_links() handles both valid-link and active-link
changes from mac80211. For an active-link change, old_links and new_links
are the active sets. The callback returned early whenever new_links was
smaller than old_links, and outside connect nothing sends an active-link
command to firmware. So when an associated MLO STA deactivates a link,
e.g. active links 0x5 -> 0x1, firmware keeps link 2 active while
mac80211 has already released its channel context.
Sync the active links to firmware from the callback once the STA is
AUTHORIZED:
- Create link STAs for sta->valid_links instead of new_links. Firmware
cannot remove a single link sta, so removals are only logged and are
left to STA removal.
- Take the active set from channel contexts: a link with a link STA and
a link vif is active if it holds a chanctx, inactive otherwise.
mac80211 releases the chanctx of a deactivated link and assigns one to
a newly activated link before it calls the callback.
- Send WMI_MLO_LINK_SET_ACTIVE only when this set differs from the one
last programmed, cached per vif. Send it to each device that holds
vdevs of the STA, with that device's links, and wait up to 5 seconds
for each response. Two active links on the same MAC use
INACTIVE_LINK_NUM, as at connect, and that command is not waited for.
Update the cache only if all devices succeed, so a failed sync is
retried on the next callback.
- Reset the cache on ASSOC -> AUTHORIZED, so the first sync after each
(re)connect is always sent. This also covers hw restart, where
mac80211 replays the station state transitions.
If the device crashes while a request is pending, the waiter still holds
the wiphy lock. ath12k_core_pre_reconfigure_recovery() therefore releases
the waiter before it takes the lock, otherwise recovery stalls until the
timeout expires.
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@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/core.c | 15 ++
drivers/net/wireless/ath/ath12k/core.h | 20 ++
drivers/net/wireless/ath/ath12k/mac.c | 241 +++++++++++++++++++++++--
drivers/net/wireless/ath/ath12k/wmi.c | 9 +-
drivers/net/wireless/ath/ath12k/wmi.h | 1 +
5 files changed, 271 insertions(+), 15 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 42a9cd28c652..183da4cb5e64 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -1524,6 +1524,19 @@ void ath12k_core_halt(struct ath12k *ar)
idr_init(&ar->txmgmt_idr);
}
+static void ath12k_core_abort_mlo_link_set_active(struct ath12k_base *ab)
+{
+ struct ath12k_mlo_link_set_active_req *req;
+
+ rcu_read_lock();
+ req = rcu_dereference(ab->mlo_link_set_active_req);
+ if (req) {
+ req->status = -ESHUTDOWN;
+ complete(&req->done);
+ }
+ rcu_read_unlock();
+}
+
static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
{
struct ath12k_hw_group *ag = ab->ag;
@@ -1538,6 +1551,8 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
if (ab->is_reset)
set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags);
+ ath12k_core_abort_mlo_link_set_active(ab);
+
for (i = 0; i < ag->num_hw; i++) {
ah = ath12k_ag_to_ah(ag, i);
if (!ah || ah->state == ATH12K_HW_STATE_OFF ||
diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 7c7057468916..74f184d283b7 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -401,6 +401,12 @@ struct ath12k_vif {
struct ath12k_link_vif deflink;
struct ath12k_link_vif __rcu *link[ATH12K_NUM_MAX_LINKS];
struct ath12k_vif_cache *cache[IEEE80211_MLD_MAX_NUM_LINKS];
+ /*
+ * Last active/inactive link state programmed to firmware via
+ * WMI_MLO_LINK_SET_ACTIVE. Zero means unknown: forces a resend.
+ */
+ u16 fw_active_links;
+ u16 fw_inactive_links;
/* indicates bitmap of link vif created in FW */
u32 links_map;
/* Must be last - ends in a flexible-array member.
@@ -797,6 +803,12 @@ struct ath12k {
} incumbent_signal_interference;
};
+struct ath12k_mlo_link_set_active_req {
+ struct completion done;
+ int status;
+ struct rcu_head rcu_head;
+};
+
struct ath12k_hw {
struct ieee80211_hw *hw;
struct device *dev;
@@ -1153,6 +1165,14 @@ struct ath12k_base {
#endif /* CONFIG_ACPI */
struct ath12k_hw_group *ag;
+
+ /*
+ * Set-active request in flight to this device, NULL when idle. Freed
+ * via kfree_rcu(). The links of an MLO STA can be on several devices,
+ * and each device is programmed separately, so at most one request is
+ * outstanding per device.
+ */
+ struct ath12k_mlo_link_set_active_req __rcu *mlo_link_set_active_req;
struct ath12k_wsi_info wsi_info;
enum ath12k_qmi_firmware_mode fw_mode;
struct ath12k_ftm_event_obj ftm_event_obj;
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index dfb0f6e678ac..885eedbbdd67 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7667,6 +7667,8 @@ static int ath12k_mac_mlo_sta_update_link_active(struct ath12k_base *ab,
u8 num_mlo_vdev = 0;
u8 link_id;
+ lockdep_assert_wiphy(hw->wiphy);
+
for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) {
arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]);
/* make sure vdev is created on this device */
@@ -7982,6 +7984,14 @@ int ath12k_mac_op_sta_state(struct ieee80211_hw *hw,
if (ieee80211_vif_is_mld(vif) && vif->type == NL80211_IFTYPE_STATION &&
old_state == IEEE80211_STA_ASSOC && new_state == IEEE80211_STA_AUTHORIZED) {
+ /*
+ * The cached active link state is only updated while AUTHORIZED,
+ * so reset it on each ASSOC -> AUTHORIZED. The next active-link
+ * sync then sends the state to firmware.
+ */
+ ahvif->fw_active_links = 0;
+ ahvif->fw_inactive_links = 0;
+
for_each_ar(ah, ar, i) {
ab = ar->ab;
if (prev_ab == ab)
@@ -8243,6 +8253,194 @@ static struct ath12k_link_sta *ath12k_mac_alloc_assign_link_sta(struct ath12k_hw
return arsta;
}
+static struct ieee80211_chanctx_conf *
+ath12k_mac_link_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+ u8 link_id)
+{
+ struct ieee80211_bss_conf *link_conf;
+
+ link_conf = wiphy_dereference(hw->wiphy, vif->link_conf[link_id]);
+ if (!link_conf)
+ return NULL;
+
+ return wiphy_dereference(hw->wiphy, link_conf->chanctx_conf);
+}
+
+struct ath12k_mlo_dev_links {
+ u8 active_vdev[IEEE80211_MLD_MAX_NUM_LINKS];
+ u8 inactive_vdev[IEEE80211_MLD_MAX_NUM_LINKS];
+ u32 active_freq[IEEE80211_MLD_MAX_NUM_LINKS];
+ unsigned int num_active;
+ unsigned int num_inactive;
+};
+
+static u16 ath12k_mac_mlo_vif_active_links(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ unsigned long links)
+{
+ u16 active = 0;
+ u8 link_id;
+
+ for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) {
+ if (ath12k_mac_link_chanctx(hw, vif, link_id))
+ active |= BIT(link_id);
+ }
+
+ return active;
+}
+
+static void ath12k_mac_mlo_sta_collect_dev_links(struct ieee80211_hw *hw,
+ struct ath12k_vif *ahvif,
+ struct ath12k_base *ab,
+ unsigned long links,
+ struct ath12k_mlo_dev_links *dl)
+{
+ struct ieee80211_chanctx_conf *conf;
+ struct ath12k_link_vif *arvif;
+ u8 link_id;
+
+ dl->num_active = 0;
+ dl->num_inactive = 0;
+
+ for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) {
+ arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]);
+ if (!arvif || !arvif->is_created || arvif->ar->ab != ab)
+ continue;
+
+ conf = ath12k_mac_link_chanctx(hw, ahvif->vif, link_id);
+ if (!conf) {
+ dl->inactive_vdev[dl->num_inactive++] = arvif->vdev_id;
+ continue;
+ }
+
+ dl->active_freq[dl->num_active] = conf->def.chan->center_freq;
+ dl->active_vdev[dl->num_active++] = arvif->vdev_id;
+ }
+}
+
+static bool ath12k_mac_mlo_dev_same_mac(struct ath12k_base *ab,
+ const struct ath12k_mlo_dev_links *dl)
+{
+ return dl->num_active == 2 &&
+ ath12k_mac_freqs_on_same_mac(ab, dl->active_freq[0],
+ dl->active_freq[1]);
+}
+
+static int ath12k_mac_mlo_sta_send_inactive_link_num(struct ath12k_base *ab,
+ struct ath12k_mlo_dev_links *dl)
+{
+ return ath12k_mac_mlo_sta_set_link_active(ab,
+ WMI_MLO_LINK_FORCE_REASON_NEW_CONNECT,
+ WMI_MLO_LINK_FORCE_MODE_INACTIVE_LINK_NUM,
+ NULL, dl->active_vdev, dl->num_active,
+ NULL, 0);
+}
+
+static int ath12k_mac_mlo_sta_send_set_active(struct ath12k_base *ab,
+ struct ieee80211_vif *vif,
+ struct ath12k_mlo_dev_links *dl)
+{
+ struct ath12k_mlo_link_set_active_req *req;
+ enum wmi_mlo_link_force_mode mode;
+ int ret;
+
+ req = kzalloc_obj(*req);
+ if (!req)
+ return -ENOMEM;
+
+ init_completion(&req->done);
+ rcu_assign_pointer(ab->mlo_link_set_active_req, req);
+
+ mode = dl->num_inactive ? WMI_MLO_LINK_FORCE_MODE_ACTIVE_INACTIVE :
+ WMI_MLO_LINK_FORCE_MODE_ACTIVE;
+
+ ret = ath12k_mac_mlo_sta_set_link_active(ab,
+ WMI_MLO_LINK_FORCE_REASON_NEW_CONNECT,
+ mode, vif->cfg.ap_addr,
+ dl->active_vdev, dl->num_active,
+ dl->inactive_vdev, dl->num_inactive);
+
+ if (!ret && !wait_for_completion_timeout(&req->done,
+ ATH12K_MLO_LINK_SET_ACTIVE_TIMEOUT_HZ)) {
+ ath12k_warn(ab, "timeout waiting for mlo set active links resp\n");
+ ret = -ETIMEDOUT;
+ }
+
+ if (!ret && req->status)
+ ret = -EIO;
+
+ rcu_assign_pointer(ab->mlo_link_set_active_req, NULL);
+ kfree_rcu(req, rcu_head);
+
+ return ret;
+}
+
+static int ath12k_mac_mlo_sta_sync_active_links(struct ath12k_hw *ah,
+ struct ath12k_vif *ahvif,
+ struct ath12k_sta *ahsta,
+ struct ieee80211_sta *sta)
+{
+ struct ath12k_base *ab, *prev_ab = NULL;
+ struct ieee80211_hw *hw = ah->hw;
+ struct ath12k_mlo_dev_links dl;
+ unsigned long links;
+ u16 active, inactive;
+ struct ath12k *ar;
+ int ret;
+ int i;
+
+ lockdep_assert_wiphy(hw->wiphy);
+
+ links = ahsta->links_map & ahvif->links_map;
+
+ /*
+ * A link holding a channel context is active. The links of an MLO STA
+ * can be on different devices, so the active set is derived over all
+ * links and each device is then programmed with the links it holds.
+ */
+ active = ath12k_mac_mlo_vif_active_links(hw, ahvif->vif, links);
+ inactive = links & ~active;
+
+ if (!active) {
+ ath12k_hw_warn(ah, "no active link for sta %pM\n", sta->addr);
+ return -EINVAL;
+ }
+
+ if (active == ahvif->fw_active_links &&
+ inactive == ahvif->fw_inactive_links)
+ return 0;
+
+ for_each_ar(ah, ar, i) {
+ ab = ar->ab;
+ if (ab == prev_ab)
+ continue;
+ prev_ab = ab;
+
+ ath12k_mac_mlo_sta_collect_dev_links(hw, ahvif, ab, links, &dl);
+
+ if (!dl.num_active && !dl.num_inactive)
+ continue;
+
+ if (!dl.num_active) {
+ ath12k_hw_warn(ah,
+ "cannot deactivate all STA links on a device\n");
+ return -EOPNOTSUPP;
+ }
+
+ if (ath12k_mac_mlo_dev_same_mac(ab, &dl))
+ ret = ath12k_mac_mlo_sta_send_inactive_link_num(ab, &dl);
+ else
+ ret = ath12k_mac_mlo_sta_send_set_active(ab, ahvif->vif, &dl);
+ if (ret)
+ return ret;
+ }
+
+ ahvif->fw_active_links = active;
+ ahvif->fw_inactive_links = inactive;
+
+ return 0;
+}
+
int ath12k_mac_op_change_sta_links(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
@@ -8250,26 +8448,22 @@ int ath12k_mac_op_change_sta_links(struct ieee80211_hw *hw,
{
struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
struct ath12k_sta *ahsta = ath12k_sta_to_ahsta(sta);
+ unsigned long to_create, to_remove;
struct ath12k_hw *ah = hw->priv;
struct ath12k_link_vif *arvif;
struct ath12k_link_sta *arsta;
- unsigned long valid_links;
struct ath12k *ar;
+ int ret = 0;
u8 link_id;
- int ret;
lockdep_assert_wiphy(hw->wiphy);
+ to_create = sta->valid_links & ~ahsta->links_map;
+ to_remove = ahsta->links_map & ~sta->valid_links;
+
if (!sta->valid_links)
return -EINVAL;
- /* Firmware does not support removal of one of link stas. All sta
- * would be removed during ML STA delete in sta_state(), hence link
- * sta removal is not handled here.
- */
- if (new_links < old_links)
- return 0;
-
if (ahsta->ml_peer_id == ATH12K_MLO_PEER_ID_INVALID) {
ath12k_hw_warn(ah, "unable to add link for ml sta %pM", sta->addr);
return -EINVAL;
@@ -8279,11 +8473,17 @@ int ath12k_mac_op_change_sta_links(struct ieee80211_hw *hw,
if (WARN_ON(ahsta->links_map == 0))
return -EINVAL;
- valid_links = new_links;
- for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) {
- if (ahsta->links_map & BIT(link_id))
- continue;
+ /*
+ * Firmware does not support removal of one of link stas. All sta
+ * would be removed during ML STA delete in sta_state(), hence link
+ * sta removal is not handled here.
+ */
+ if (to_remove)
+ ath12k_generic_dbg(ATH12K_DBG_MAC,
+ "ignoring link sta removal 0x%lx for %pM\n",
+ to_remove, sta->addr);
+ for_each_set_bit(link_id, &to_create, IEEE80211_MLD_MAX_NUM_LINKS) {
arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]);
if (!arvif || !arvif->is_created)
continue;
@@ -8305,7 +8505,20 @@ int ath12k_mac_op_change_sta_links(struct ieee80211_hw *hw,
}
}
- return 0;
+ /*
+ * Active-links are only meaningful once the sta is authorized. Before
+ * that, the connect path in sta_state() programs firmware.
+ */
+ if (sta->mlo && vif->type == NL80211_IFTYPE_STATION &&
+ ahsta->state == IEEE80211_STA_AUTHORIZED) {
+ ret = ath12k_mac_mlo_sta_sync_active_links(ah, ahvif, ahsta, sta);
+ if (ret)
+ ath12k_hw_warn(ah,
+ "failed to sync mlo active links for sta %pM: %d\n",
+ sta->addr, ret);
+ }
+
+ return ret;
}
EXPORT_SYMBOL(ath12k_mac_op_change_sta_links);
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 7e06dbb1e884..8d4938ff3163 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -9716,6 +9716,7 @@ static void ath12k_wmi_event_mlo_link_set_active(struct ath12k_base *ab,
struct sk_buff *skb)
{
const struct wmi_mlo_link_set_active_resp_event *ev;
+ struct ath12k_mlo_link_set_active_req *req;
u32 status, use_ieee;
const void **tb;
int ret;
@@ -9740,7 +9741,13 @@ static void ath12k_wmi_event_mlo_link_set_active(struct ath12k_base *ab,
"mlo link set active resp status %u use_ieee 0x%x\n",
status, use_ieee);
- /* Response delivery to waiters will be wired up in a subsequent patch */
+ rcu_read_lock();
+ req = rcu_dereference(ab->mlo_link_set_active_req);
+ if (req) {
+ req->status = status;
+ complete(&req->done);
+ }
+ rcu_read_unlock();
}
static void ath12k_wmi_event_mlo_setup_complete(struct ath12k_base *ab,
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 6d590b30ecbe..7b18de37f0bf 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -3030,6 +3030,7 @@ struct ath12k_wmi_ssid_params {
} __packed;
#define ATH12K_VDEV_SETUP_TIMEOUT_HZ (5 * HZ)
+#define ATH12K_MLO_LINK_SET_ACTIVE_TIMEOUT_HZ (5 * HZ)
enum wmi_vdev_mbssid_flags {
WMI_VDEV_MBSSID_FLAGS_NON_MBSSID_AP = BIT(0),
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
` (6 preceding siblings ...)
2026-11-18 2:55 ` [PATCH ath-next 7/7] wifi: ath12k: handle MLO active link updates Miaoqing Pan
@ 2026-11-21 0:16 ` Jeff Johnson
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Johnson @ 2026-11-21 0:16 UTC (permalink / raw)
To: Miaoqing Pan, jjohnson; +Cc: ath12k, linux-wireless, linux-kernel
On 11/17/2026 6:55 PM, Miaoqing Pan wrote:
> mac80211 calls drv_change_vif_links() and drv_change_sta_links() for
> both valid-links and active-links changes. ath12k does not distinguish
> between the two, causing WARN_ON/incorrect teardown in change_vif_links(),
> inconsistent vdev state in the chanctx callbacks, and silent
> firmware miss in change_sta_links().
>
> This series derives link object lifetime from vif->valid_links and
> sta->valid_links, which mac80211 updates before calling the driver,
> instead of from the active-links sets. A STA link vdev keeps running when
> its link is deactivated. The active/inactive link state is programmed to
> firmware with WMI_MLO_LINK_SET_ACTIVE_CMDID, sent to each device that
> holds vdevs of the STA, and only when it differs from the state last
> programmed.
>
> Patch 1 adds WMI infrastructure: the response event struct,
> WMI_TAG_MLO_LINK_SET_ACTIVE_RESP_EVENT tag, and the event handler
> registered in ath12k_wmi_op_rx(). The handler only parses and logs
> the event at this point; delivery to the waiter is wired up in patch 7.
>
> Patch 2 sets CTRL_F_OVERWRITE_FORCE_ACTIVE_BITMAP and
> CTRL_F_OVERWRITE_FORCE_INACTIVE_BITMAP for FORCE_ACTIVE_INACTIVE, so that
> firmware replaces the force bitmaps instead of accumulating them. It also
> copies the AP MLD address into the command, and fixes the
> CRTL_F_DYNC_FORCE_LINK_NUM typo.
>
> Patch 3 fixes ath12k_mac_op_change_vif_links() so that link vif lifetime
> follows vif->valid_links. A link that is only deactivated keeps its link
> vif, and a disconnect (valid_links == 0) removes all remaining link vifs.
>
> Patch 4 makes ath12k_mac_get_vif_up() skip links without a channel
> context. A deactivated link keeps its vdev up in firmware but has
> released its channel context, so it must not be used to derive the
> target pdev. The WARN_ON() in ath12k_mac_get_target_pdev_id_from_vif()
> is kept.
>
> Patch 5 stops clearing is_started for a STA vdev in
> unassign_vif_chanctx(). The vdev is not stopped there, so the flag now
> keeps matching the firmware state. assign_vif_chanctx() then compares the
> new channel with started_chandef: if it is unchanged nothing is done.
> Otherwise the vdev is restarted on the new channel, or stopped and started
> if it is not up. Station removal clears is_started once the STA vdev has
> been stopped, so that a reconnect on targets with vdev_start_delay starts
> the vdev again.
>
> Patch 6 fixes the bounds checks in ath12k_mac_mlo_sta_set_link_active().
> The vdev_bitmap and inactive_vdev_bitmap arrays are sized by
> WMI_MLO_VDEV_BITMAP_SZ, but the checks compared against
> WMI_MLO_LINK_NUM_SZ. Both are 2 today, so there is no functional change.
> The checks now use the constant of the array they guard.
>
> Patch 7 makes ath12k_mac_op_change_sta_links() create link STAs for
> sta->valid_links that are not yet in links_map. Link STA removal is
> still left to STA removal, as firmware does not support it. Once the STA
> is authorized, a link holding a channel context is active, and a link
> with a link STA and link vif but no channel context is inactive. The
> result is compared with ahvif->fw_active_links and
> ahvif->fw_inactive_links, and WMI_MLO_LINK_SET_ACTIVE_CMDID is sent only
> when it differs. It is sent to each device that holds vdevs of the STA,
> with that device's links, and the driver waits for each device's
> response, except in the INACTIVE_LINK_NUM case, which is sent without
> waiting. If a device holds some of the STA's links but none of them is
> active, the update fails with -EOPNOTSUPP. If the device crashes while a request is pending,
> ath12k_core_pre_reconfigure_recovery() releases the waiter before it
> takes the wiphy lock.
>
> Patch 7 depends on patches 1, 2, 3 and 5: it needs the response event
> from patch 1, the ap_mld_addr argument from patch 2, link vifs that
> survive deactivation from patch 3, and a STA link vdev that stays
> started across deactivation from patch 5. Patches 1-6 each apply to the
> base on their own, and the whole series applies in order.
>
>
> Miaoqing Pan (7):
> wifi: ath12k: add WMI response handling for MLO link set active
> command
> wifi: ath12k: send overwrite flags and AP MLD addr in MLO link set
> active
> wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link
> updates
> wifi: ath12k: skip links without channel context in
> ath12k_mac_get_vif_up()
> wifi: ath12k: restart STA link vdev on chanctx assign if channel
> changed
> wifi: ath12k: use WMI_MLO_VDEV_BITMAP_SZ for vdev bitmap bounds check
> wifi: ath12k: handle MLO active link updates
>
> drivers/net/wireless/ath/ath12k/core.c | 15 ++
> drivers/net/wireless/ath/ath12k/core.h | 25 ++
> drivers/net/wireless/ath/ath12k/mac.c | 335 ++++++++++++++++++++++---
> drivers/net/wireless/ath/ath12k/wmi.c | 54 +++-
> drivers/net/wireless/ath/ath12k/wmi.h | 11 +-
> 5 files changed, 405 insertions(+), 35 deletions(-)
>
>
> base-commit: 4016f6c3149e7e3faccc1654db6a3030c069383a
My review agent notes there is a pre-existing issue that isn't addressed by
this series.
The review:
"file": "drivers/net/wireless/ath/ath12k/mac.c",
"line": 12683,
"summary": "arvif->is_started stays true when vdev_stop succeeds but
vdev_start fails, breaking the firmware/driver state invariant",
"failure_scenario": "In ath12k_mac_op_assign_vif_chanctx(), the !is_up
STA restart path calls vdev_stop (which does NOT clear is_started) then
vdev_start. If vdev_start fails, is_started=true but firmware has the vdev
stopped. started_chandef still holds the old channel (vdev_start_restart only
writes it on success). On the next assign_vif_chanctx for the new channel,
the same-channel check (line 12673) does NOT fire since
started_chandef≠ctx->def; however, calling vdev_stop again on an
already-stopped vdev hits the num_started_vdevs=0 WARN and corrupts the
counter. For the same-channel case a future assign_vif_chanctx would silently
return 0 without restarting, leaving the STA with a dead vdev in firmware
indefinitely."
My refute agent concurs:
is_started can diverge from firmware on a failed vdev restart ·
mac.c:12667-12693
Confirmed the mechanics: ath12k_mac_vdev_stop() (mac.c:1556) does not clear
is_started, and ath12k_mac_vdev_start_restart() only sets
started_chandef/num_started_vdevs on success. So in the new STA restart
branch, if vdev_stop succeeds but vdev_start fails, is_started stays true
while firmware has the vdev stopped — which violates the very invariant this
patch introduces ("driver state matches firmware state"). A later
assign_vif_chanctx for the same (old) channel would then hit the
cfg80211_chandef_identical check and return 0, leaving a dead vdev.
Caveat on severity: this is a firmware-error-only path, and it exactly mirrors
the long-standing switch_vif_chanctx() error handling (mac.c:12007-12019),
which has the same gap and clears nothing on failure. So it's a real but
pre-existing-pattern concern.
I also concur with the recommended action:
— worth a note to the author (clear is_started on vdev_stop success / after a
failed vdev_start), not a submission blocker.
So resolve with a follow-up patch if necessary once this series lands.
/jeff
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-21 0:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 2:55 [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 1/7] wifi: ath12k: add WMI response handling for MLO link set active command Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 2/7] wifi: ath12k: send overwrite flags and AP MLD addr in MLO link set active Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 3/7] wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link updates Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 4/7] wifi: ath12k: skip links without channel context in ath12k_mac_get_vif_up() Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 5/7] wifi: ath12k: restart STA link vdev on chanctx assign if channel changed Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 6/7] wifi: ath12k: use WMI_MLO_VDEV_BITMAP_SZ for vdev bitmap bounds check Miaoqing Pan
2026-11-18 2:55 ` [PATCH ath-next 7/7] wifi: ath12k: handle MLO active link updates Miaoqing Pan
2026-11-21 0:16 ` [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling Jeff Johnson
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®