]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: ath12k: factor out peer assoc send-and-wait into a helper
authorBaochen Qiang <baochen.qiang@oss.qualcomm.com>
Mon, 20 Jul 2026 06:43:23 +0000 (14:43 +0800)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Mon, 27 Jul 2026 15:00:42 +0000 (08:00 -0700)
ath12k_bss_assoc(), ath12k_mac_station_assoc() and
ath12k_sta_rc_update_wk() all open-code the same sequence: reinit the
peer_assoc_done completion, send the peer assoc WMI command, then wait
for the firmware confirmation event. The reinit_completion() was buried
in ath12k_peer_assoc_prepare(), far from the wait_for_completion_timeout()
that consumes it, making the reinit/send/wait sequence hard to follow,
and the three open-coded copies are easy to get out of sync.

Move the sequence into a new helper ath12k_mac_peer_assoc() and call it
from all three sites. The reinit, send and wait now live together so the
completion's lifecycle is easy to read.

While at it, ath12k_sta_rc_update_wk() previously warned but still
waited the full timeout when the peer assoc command failed to send. Now
a send failure returns immediately and skips the pointless 1 second
wait, matching the other two callers.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3

Signed-off-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Reviewed-by: Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>
Link: https://patch.msgid.link/20260720-ath12k-fw-allocated-ml-peer-id-v2-2-630632758a80@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/mac.c

index aa82c8fccc4efa5b64998d4b3eb34823fda13294..b4df222f0c19a936d7abf61e7244cc3ac5554b2a 100644 (file)
@@ -3598,8 +3598,6 @@ static void ath12k_peer_assoc_prepare(struct ath12k *ar,
 
        memset(arg, 0, sizeof(*arg));
 
-       reinit_completion(&ar->peer_assoc_done);
-
        arg->peer_new_assoc = !reassoc;
        ath12k_peer_assoc_h_basic(ar, arvif, arsta, arg);
        ath12k_peer_assoc_h_crypto(ar, arvif, arsta, arg);
@@ -3839,6 +3837,29 @@ static u32 ath12k_mac_ieee80211_sta_bw_to_wmi(struct ath12k *ar,
        return bw;
 }
 
+static int ath12k_mac_peer_assoc(struct ath12k *ar,
+                                struct ath12k_wmi_peer_assoc_arg *peer_arg)
+{
+       int ret;
+
+       reinit_completion(&ar->peer_assoc_done);
+
+       ret = ath12k_wmi_send_peer_assoc_cmd(ar, peer_arg);
+       if (ret) {
+               ath12k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n",
+                           peer_arg->peer_mac, peer_arg->vdev_id, ret);
+               return ret;
+       }
+
+       if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) {
+               ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
+                           peer_arg->peer_mac, peer_arg->vdev_id);
+               return -ETIMEDOUT;
+       }
+
+       return 0;
+}
+
 static void ath12k_bss_assoc(struct ath12k *ar,
                             struct ath12k_link_vif *arvif,
                             struct ieee80211_bss_conf *bss_conf)
@@ -3919,18 +3940,10 @@ static void ath12k_bss_assoc(struct ath12k *ar,
        }
 
        peer_arg->is_assoc = true;
-       ret = ath12k_wmi_send_peer_assoc_cmd(ar, peer_arg);
-       if (ret) {
-               ath12k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n",
-                           bss_conf->bssid, arvif->vdev_id, ret);
-               return;
-       }
 
-       if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) {
-               ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
-                           bss_conf->bssid, arvif->vdev_id);
+       ret = ath12k_mac_peer_assoc(ar, peer_arg);
+       if (ret)
                return;
-       }
 
        ret = ath12k_setup_peer_smps(ar, arvif, bss_conf->bssid,
                                     &link_sta->ht_cap, &link_sta->he_6ghz_capa);
@@ -6484,18 +6497,10 @@ static int ath12k_mac_station_assoc(struct ath12k *ar,
        }
 
        peer_arg->is_assoc = true;
-       ret = ath12k_wmi_send_peer_assoc_cmd(ar, peer_arg);
-       if (ret) {
-               ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n",
-                           arsta->addr, arvif->vdev_id, ret);
-               return ret;
-       }
 
-       if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) {
-               ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
-                           arsta->addr, arvif->vdev_id);
-               return -ETIMEDOUT;
-       }
+       ret = ath12k_mac_peer_assoc(ar, peer_arg);
+       if (ret)
+               return ret;
 
        num_vht_rates = ath12k_mac_bitrate_mask_num_vht_rates(ar, band, mask);
        num_he_rates = ath12k_mac_bitrate_mask_num_he_rates(ar, band, mask);
@@ -6844,14 +6849,8 @@ static void ath12k_sta_rc_update_wk(struct wiphy *wiphy, struct wiphy_work *wk)
                                                  peer_arg, true);
 
                        peer_arg->is_assoc = false;
-                       err = ath12k_wmi_send_peer_assoc_cmd(ar, peer_arg);
-                       if (err)
-                               ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n",
-                                           arsta->addr, arvif->vdev_id, err);
 
-                       if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ))
-                               ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
-                                           arsta->addr, arvif->vdev_id);
+                       ath12k_mac_peer_assoc(ar, peer_arg);
                }
        }
 }