[PATCH ath-next 3/7] wifi: ath12k: fix ath12k_mac_op_change_vif_links() for active-link updates
Rameshkumar Sundaram
rameshkumar.sundaram at oss.qualcomm.com
Tue Nov 24 13:19:43 PST 2026
On 11/18/2026 8:25 AM, Miaoqing Pan wrote:
> 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 at 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.
> + */
This seems quite ambiguous from the mac80211 code flow,
Consider a 2-link STA associated with an AP, where one link is removed
by the AP:
wlan0: MLO Reconfiguration: work: valid=0x3, removed=0x2
In ieee80211_ml_reconf_work(),
Initially:
valid_links = 0x3
active_links = 0x3
ieee80211_set_active_links() first removes the link from active_links:
valid_links = 0x3
active_links = 0x1
This calls drv_change_vif_links() with 0x3 -> 0x1, but ath12k would not
remove the corresponding arvif/arsta since vif->valid_links is still 0x3.
Subsequently, ieee80211_vif_set_links() removes the link from valid_links:
valid_links = 0x1
active_links = 0x1
However, the call to drv_change_vif_links() uses:
old_links & old_active
new_links & sdata->vif.active_links
which evaluates to:
0x3 & 0x1 = 0x1
0x1 & 0x1 = 0x1
Since old_links == new_links, drv_change_vif_links() returns without
calling the driver.
After this, mac80211 removes/frees its link object, while ath12k still
seems to retain the corresponding arvif/arsta. Is this expected?
> + 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;
--
Ramesh
More information about the ath12k
mailing list