The current implementation of per-pdev frequency range updates assumes that each pdev supports only a single band. As a result in ath12k_regd_update(), bands are handled using an if-else structure, which limits updates to only one of the band per pdev. This assumption does not hold for all chipsets. For example, the WCN7850 supports multiple bands within a single pdev. Hence to accommodate such cases, update the logic to account for all band cases by handling each band in a separate if conditions instead of the previous if-else structure. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Fixes: 13324cecbb2c ("wifi: ath12k: Update frequency range if reg rules changes") Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@xxxxxxxxxxxxxxxx> --- drivers/net/wireless/ath/ath12k/mac.c | 16 ++++++++-- drivers/net/wireless/ath/ath12k/reg.c | 56 +++++++++++++++++------------------ 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index fa39537fa4ce8a4a2aad5aff87868aeaecd73565..64500b04675dbeb1cdf52b3fa77f4d831f43103e 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -11353,8 +11353,20 @@ void ath12k_mac_update_freq_range(struct ath12k *ar, if (!(freq_low && freq_high)) return; - ar->freq_range.start_freq = MHZ_TO_KHZ(freq_low); - ar->freq_range.end_freq = MHZ_TO_KHZ(freq_high); + if (ar->freq_range.start_freq || ar->freq_range.end_freq) { + ar->freq_range.start_freq = min(ar->freq_range.start_freq, + MHZ_TO_KHZ(freq_low)); + ar->freq_range.end_freq = max(ar->freq_range.end_freq, + MHZ_TO_KHZ(freq_high)); + } else { + ar->freq_range.start_freq = MHZ_TO_KHZ(freq_low); + ar->freq_range.end_freq = MHZ_TO_KHZ(freq_high); + } + + ath12k_dbg(ar->ab, ATH12K_DBG_MAC, + "mac pdev %u freq limit updated. New range %u->%u MHz\n", + ar->pdev->pdev_id, KHZ_TO_MHZ(ar->freq_range.start_freq), + KHZ_TO_MHZ(ar->freq_range.end_freq)); } static void ath12k_mac_update_ch_list(struct ath12k *ar, diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c index 62936d518b1d767a198958150a13bb9ac8b73009..fb8b07c95355c4683c514c2d62624feafedcf1f3 100644 --- a/drivers/net/wireless/ath/ath12k/reg.c +++ b/drivers/net/wireless/ath/ath12k/reg.c @@ -265,8 +265,8 @@ static void ath12k_copy_regd(struct ieee80211_regdomain *regd_orig, int ath12k_regd_update(struct ath12k *ar, bool init) { - u32 phy_id, freq_low = 0, freq_high = 0, supported_bands, band; struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap; + u32 phy_id, freq_low, freq_high, supported_bands; struct ath12k_hw *ah = ath12k_ar_to_ah(ar); struct ieee80211_hw *hw = ah->hw; struct ieee80211_regdomain *regd, *regd_copy = NULL; @@ -276,45 +276,45 @@ int ath12k_regd_update(struct ath12k *ar, bool init) ab = ar->ab; supported_bands = ar->pdev->cap.supported_bands; - if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) { - band = NL80211_BAND_2GHZ; - } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { - band = NL80211_BAND_5GHZ; - } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->supports_6ghz) { - band = NL80211_BAND_6GHZ; - } else { - /* This condition is not expected. - */ - WARN_ON(1); - ret = -EINVAL; - goto err; - } - reg_cap = &ab->hal_reg_cap[ar->pdev_idx]; - if (ab->hw_params->single_pdev_only && !ar->supports_6ghz) { - phy_id = ar->pdev->cap.band[band].phy_id; - reg_cap = &ab->hal_reg_cap[phy_id]; - } - /* Possible that due to reg change, current limits for supported - * frequency changed. Update that + * frequency changed. Update it. As a first step, reset the + * previous values and then compute and set the new values. */ + ar->freq_range.start_freq = 0; + ar->freq_range.end_freq = 0; + if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) { + if (ab->hw_params->single_pdev_only) { + phy_id = ar->pdev->cap.band[WMI_HOST_WLAN_2GHZ_CAP].phy_id; + reg_cap = &ab->hal_reg_cap[phy_id]; + } + freq_low = max(reg_cap->low_2ghz_chan, ab->reg_freq_2ghz.start_freq); freq_high = min(reg_cap->high_2ghz_chan, ab->reg_freq_2ghz.end_freq); - } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { + + ath12k_mac_update_freq_range(ar, freq_low, freq_high); + } + + if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { + if (ab->hw_params->single_pdev_only) { + phy_id = ar->pdev->cap.band[WMI_HOST_WLAN_5GHZ_CAP].phy_id; + reg_cap = &ab->hal_reg_cap[phy_id]; + } + freq_low = max(reg_cap->low_5ghz_chan, ab->reg_freq_5ghz.start_freq); freq_high = min(reg_cap->high_5ghz_chan, ab->reg_freq_5ghz.end_freq); - } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->supports_6ghz) { - freq_low = max(reg_cap->low_5ghz_chan, ab->reg_freq_6ghz.start_freq); - freq_high = min(reg_cap->high_5ghz_chan, ab->reg_freq_6ghz.end_freq); + + ath12k_mac_update_freq_range(ar, freq_low, freq_high); } - ath12k_mac_update_freq_range(ar, freq_low, freq_high); + if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->supports_6ghz) { + freq_low = max(reg_cap->low_5ghz_chan, ab->reg_freq_6ghz.start_freq); + freq_high = min(reg_cap->high_5ghz_chan, ab->reg_freq_6ghz.end_freq); - ath12k_dbg(ab, ATH12K_DBG_REG, "pdev %u reg updated freq limits %u->%u MHz\n", - ar->pdev->pdev_id, freq_low, freq_high); + ath12k_mac_update_freq_range(ar, freq_low, freq_high); + } /* If one of the radios within ah has already updated the regd for * the wiphy, then avoid setting regd again --- base-commit: 0b7122d5c6a84dd18d2ebffbcc46db835f24628f change-id: 20250520-fix_freq_range_update-2cb86b41b196