]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: ath12k: enforce vdev limit in ath12k_mac_vdev_create()
authorRameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>
Sun, 26 Oct 2025 18:22:53 +0000 (23:52 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Thu, 30 Oct 2025 21:55:08 +0000 (14:55 -0700)
Currently, vdev limit check is performed only in
ath12k_mac_assign_vif_to_vdev(). If the host has already created
maximum number of vdevs for the radio (ar) and a scan request
arrives for the same radio, ath12k_mac_initiate_hw_scan() attempts
to create a vdev without checking the limit, causing firmware asserts.

Centralize the vdev limit guard by moving the check into
ath12k_mac_vdev_create() so that all callers obey the limit.
While doing this, update the condition from
`num_created_vdevs > (TARGET_NUM_VDEVS(ab) - 1)` to
`num_created_vdevs >= TARGET_NUM_VDEVS(ab)` for clarity and to
eliminate unnecessary arithmetic.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1

Fixes: 0d6e6736ed9f ("wifi: ath12k: scan statemachine changes for single wiphy")
Fixes: 4938ba733ee2 ("wifi: ath12k: modify remain on channel for single wiphy")
Signed-off-by: Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20251026182254.1399650-2-rameshkumar.sundaram@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/mac.c

index 29a0b022c32eb8786f0e05a554ac4283fb00d111..8f0d914d7fc3a80af495a55fb6d25e4bcfe3413d 100644 (file)
@@ -10031,6 +10031,12 @@ int ath12k_mac_vdev_create(struct ath12k *ar, struct ath12k_link_vif *arvif)
        if (vif->type == NL80211_IFTYPE_MONITOR && ar->monitor_vdev_created)
                return -EINVAL;
 
+       if (ar->num_created_vdevs >= TARGET_NUM_VDEVS(ab)) {
+               ath12k_warn(ab, "failed to create vdev, reached max vdev limit %d\n",
+                           TARGET_NUM_VDEVS(ab));
+               return -ENOSPC;
+       }
+
        link_id = arvif->link_id;
 
        if (link_id < IEEE80211_MLD_MAX_NUM_LINKS) {
@@ -10390,12 +10396,6 @@ static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
        if (arvif->is_created)
                goto flush;
 
-       if (ar->num_created_vdevs > (TARGET_NUM_VDEVS(ab) - 1)) {
-               ath12k_warn(ab, "failed to create vdev, reached max vdev limit %d\n",
-                           TARGET_NUM_VDEVS(ab));
-               goto unlock;
-       }
-
        ret = ath12k_mac_vdev_create(ar, arvif);
        if (ret) {
                ath12k_warn(ab, "failed to create vdev %pM ret %d", vif->addr, ret);