]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: Fix incorrect rates sent to firmware
authorPradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
Thu, 20 Mar 2025 11:24:26 +0000 (16:54 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Mon, 7 Apr 2025 15:21:58 +0000 (08:21 -0700)
Before firmware assert, if there is a station interface in the device
which is not associated with an AP, the basic rates are set to zero.
Following this, during firmware recovery, when basic rates are zero,
ath12k driver is sending invalid rate codes, which are negative values,
to firmware. This results in firmware assert.

Fix this by checking if rate codes are valid, before sending them
to the firmware.

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

Signed-off-by: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
Signed-off-by: Roopni Devanathan <quic_rdevanat@quicinc.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250320112426.1956961-1-quic_rdevanat@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/mac.c

index b19e30d955605cc5fe9b3723f43c15d795b61841..5a6630d6e9b95be5629225fdcdc7139afe1aa6a7 100644 (file)
@@ -3349,7 +3349,10 @@ static void ath12k_recalculate_mgmt_rate(struct ath12k *ar,
        }
 
        sband = hw->wiphy->bands[def->chan->band];
-       basic_rate_idx = ffs(bss_conf->basic_rates) - 1;
+       if (bss_conf->basic_rates)
+               basic_rate_idx = __ffs(bss_conf->basic_rates);
+       else
+               basic_rate_idx = 0;
        bitrate = sband->bitrates[basic_rate_idx].bitrate;
 
        hw_rate_code = ath12k_mac_get_rate_hw_value(bitrate);
@@ -3887,10 +3890,14 @@ static void ath12k_mac_bss_info_changed(struct ath12k *ar,
                band = def.chan->band;
                mcast_rate = info->mcast_rate[band];
 
-               if (mcast_rate > 0)
+               if (mcast_rate > 0) {
                        rateidx = mcast_rate - 1;
-               else
-                       rateidx = ffs(info->basic_rates) - 1;
+               } else {
+                       if (info->basic_rates)
+                               rateidx = __ffs(info->basic_rates);
+                       else
+                               rateidx = 0;
+               }
 
                if (ar->pdev->cap.supported_bands & WMI_HOST_WLAN_5GHZ_CAP)
                        rateidx += ATH12K_MAC_FIRST_OFDM_RATE_IDX;