mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-08 00:29:36 -04:00
wifi: ath12k: fix mac pdev frequency range update
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: 13324cecbb ("wifi: ath12k: Update frequency range if reg rules changes")
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/20250520-fix_freq_range_update-v1-1-e061fd147b87@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
This commit is contained in:
committed by
Jeff Johnson
parent
08e3cc13b0
commit
0d777aa2ca
@@ -11361,8 +11361,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,
|
||||
|
||||
@@ -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) {
|
||||
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) {
|
||||
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];
|
||||
}
|
||||
|
||||
ath12k_dbg(ab, ATH12K_DBG_REG, "pdev %u reg updated freq limits %u->%u MHz\n",
|
||||
ar->pdev->pdev_id, freq_low, freq_high);
|
||||
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);
|
||||
|
||||
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_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
|
||||
|
||||
Reference in New Issue
Block a user