From: Miaoqing Pan <miaoqing.pan@oss.qualcomm.com>
To: Jeff Johnson <jeff.johnson@oss.qualcomm.com>, jjohnson@kernel.org
Cc: ath12k@lists.infradead.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH ath-next 0/7] wifi: ath12k: fix MLO active-links handling
Date: Tue, 24 Nov 2026 14:01:57 +0800 [thread overview]
Message-ID: <d34b81a7-8dca-4975-b77b-a0344451f25b@oss.qualcomm.com> (raw)
In-Reply-To: <43452750-2fff-46f7-bc61-2f5547602c85@oss.qualcomm.com>
On 11/21/2026 8:16 AM, Jeff Johnson wrote:
> 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
Thanks for pointing this out. Agreed, I'll address this separately in a
follow-up patch.
next prev parent reply other threads:[~2026-11-24 6:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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
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
2026-11-24 6:01 ` Miaoqing Pan [this message]
2026-11-24 1:58 ` Baochen Qiang
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=d34b81a7-8dca-4975-b77b-a0344451f25b@oss.qualcomm.com \
--to=miaoqing.pan@oss.qualcomm.com \
--cc=ath12k@lists.infradead.org \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=jjohnson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®