wifi: ath12k: fix frequency range for single-pdev devices
Subsystems (2)
PATCH 1/1 wifi: ath12k: fix frequency range for single-pdev devices
Commit 0d777aa2ca77 ("wifi: ath12k: fix mac pdev frequency range update") made ath12k_regd_update() handle each supported band independently. However, it uses WMI band capability values as indices into pdev->cap.band[]. Those values are bit flags, while cap.band[] is indexed by enum nl80211_band. As a result, the 2.4 GHz lookup reads the 5 GHz entry, while the 5 GHz lookup reads the 60 GHz entry.
Also, the 5 GHz range is skipped whenever the radio supports 6 GHz. This is valid when 5 and 6 GHz belong to separate pdevs, but not for single-pdev devices such as WCN7850, where the same pdev covers both bands. After a regulatory update, 5 GHz is therefore omitted from ar->freq_range and later filtered out of the channel list sent to firmware.
On the tested WCN7850, the 11d regulatory update left the frequency range at 2402-2482 MHz and sent 13 channels to firmware. A subsequent 5 GHz scan failed with WMI_SCAN_REASON_INTERNAL_FAILURE. With both ranges combined, the range is 2402-5835 MHz and 26 channels are sent to firmware.
Index cap.band[] with NL80211_BAND_* and update 5 GHz for single-pdev devices even when 6 GHz is supported.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
---
Testing notes:
- Runtime testing was performed on WCN7850 under the CN regulatory domain.
- 2.4 and 5 GHz scanning and 5 GHz association were verified.
- 6 GHz operation was not tested because it is unavailable under the CN regulatory domain.
- QCC2072 was not tested because the hardware was not available.
drivers/net/wireless/ath/ath12k/reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath12k/reg.c +4 -3
@@ -300,7 +300,7 @@ int ath12k_regd_update(struct ath12k *ar, bool init)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; + phy_id = ar->pdev->cap.band[NL80211_BAND_2GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }
@@ -310,9 +310,10 @@ int ath12k_regd_update(struct ath12k *ar, bool init)ath12k_mac_update_freq_range (ar, freq_low, freq_high); } -if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { +if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && + (!ar->supports_6ghz || ab->hw_params->single_pdev_only)) {if (ab->hw_params->single_pdev_only) { - phy_id = ar->pdev->cap.band[WMI_HOST_WLAN_5GHZ_CAP ].phy_id; + phy_id = ar->pdev->cap.band[NL80211_BAND_5GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }
base-commit: a1a21995c2e1cc2ca6b2226cfe4f5f018370182a
Signature · 1 line
2.55.0
Quoted 7 lines · Shenghan Gao
Commit
0d777aa2ca77("wifi: ath12k: fix mac pdev frequency range update") madeath12k_regd_update()handle each supported band independently. However, it uses WMI band capability values as indices into pdev->cap.band[]. Those values are bit flags, while cap.band[] is indexed by enumnl80211_band. As a result, the 2.4 GHz lookup reads the 5 GHz entry, while the 5 GHz lookup reads the 60 GHz entry.
Quoted 8 lines
Also, the 5 GHz range is skipped whenever the radio supports 6 GHz. This is valid when 5 and 6 GHz belong to separate pdevs, but not for single-pdev devices such as WCN7850, where the same pdev covers both bands. After a regulatory update, 5 GHz is therefore omitted from
ar->freq_rangeand later filtered out of the channel list sent to firmware.On the tested WCN7850, the 11d regulatory update left the frequency range at 2402-2482 MHz and sent 13 channels to firmware. A subsequent 5 GHz scan
can you share more details on how the frequency range is updated to cover only 2 GHz band ?
Quoted 52 lines
failed with
WMI_SCAN_REASON_INTERNAL_FAILURE. With both ranges combined, the range is 2402-5835 MHz and 26 channels are sent to firmware.Index cap.band[] with NL80211_BAND_* and update 5 GHz for single-pdev devices even when 6 GHz is supported.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Fixes 0d777aa2ca77 ("wifi: ath12k: fix mac pdev frequency range update")Assisted-by Codex:GPT-5.6 SolSigned-off-by Shenghan Gao <[email protected]>---
Testing notes:- Runtime testing was performed on WCN7850 under the CN regulatory domain.
- 2.4 and 5 GHz scanning and 5 GHz association were verified.
- 6 GHz operation was not tested because it is unavailable under the CN regulatory domain.
- QCC2072 was not tested because the hardware was not available.drivers/net/wireless/ath/ath12k/reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath12k/reg.c +4
-3@@ -300,7 +300,7 @@ int ath12k_regd_update(struct ath12k *ar, bool init)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; + phy_id = ar->pdev->cap.band[NL80211_BAND_2GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }@@ -310,9 +310,10 @@ int ath12k_regd_update(struct ath12k *ar, bool init)ath12k_mac_update_freq_range (ar, freq_low, freq_high); } -if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { +if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && + (!ar->supports_6ghz || ab->hw_params->single_pdev_only)) {if (ab->hw_params->single_pdev_only) { - phy_id = ar->pdev->cap.band[WMI_HOST_WLAN_5GHZ_CAP ].phy_id; + phy_id = ar->pdev->cap.band[NL80211_BAND_5GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }base-commit:
a1a21995c2e1cc2ca6b2226cfe4f5f018370182a
The update sequence is as follows.
ath12k_regd_update() first resets ar->freq_range to zero. On the tested WCN7850 under the CN regulatory domain, the 2 GHz branch calculates a valid range, so the first call to ath12k_mac_update_freq_range() sets ar->freq_range to 2402-2482 MHz.
The existing 5 GHz branch is skipped because ar->supports_6ghz is true.
When the new regulatory domain is built, reg_freq_6ghz.end_freq is reset to zero. Since the CN regulatory event contains no 6 GHz rules, it remains zero. The 6 GHz branch therefore calculates freq_high as zero, and ath12k_mac_update_freq_range() returns without extending the existing range.
Consequently, ar->freq_range remains 2402-2482 MHz, and the subsequent channel-list update filters out all 5 GHz channels.
With this patch, the 5 GHz branch also runs for single-pdev devices and merges the valid 5 GHz range, extending ar->freq_range to 2402-5835 MHz.
Quoted 75 lines · Baochen Qiang <[email protected]> 于2026年7月20日周一 16:34写道:
Quoted 7 lines · Shenghan Gao
Commit
0d777aa2ca77("wifi: ath12k: fix mac pdev frequency range update") madeath12k_regd_update()handle each supported band independently. However, it uses WMI band capability values as indices into pdev->cap.band[]. Those values are bit flags, while cap.band[] is indexed by enumnl80211_band. As a result, the 2.4 GHz lookup reads the 5 GHz entry, while the 5 GHz lookup reads the 60 GHz entry.Quoted 8 lines
Also, the 5 GHz range is skipped whenever the radio supports 6 GHz. This is valid when 5 and 6 GHz belong to separate pdevs, but not for single-pdev devices such as WCN7850, where the same pdev covers both bands. After a regulatory update, 5 GHz is therefore omitted from
ar->freq_rangeand later filtered out of the channel list sent to firmware.On the tested WCN7850, the 11d regulatory update left the frequency range at 2402-2482 MHz and sent 13 channels to firmware. A subsequent 5 GHz scan
can you share more details on how the frequency range is updated to cover only 2 GHz band ?
Quoted 52 lines
failed with
WMI_SCAN_REASON_INTERNAL_FAILURE. With both ranges combined, the range is 2402-5835 MHz and 26 channels are sent to firmware.Index cap.band[] with NL80211_BAND_* and update 5 GHz for single-pdev devices even when 6 GHz is supported.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Fixes 0d777aa2ca77 ("wifi: ath12k: fix mac pdev frequency range update")Assisted-by Codex:GPT-5.6 SolSigned-off-by Shenghan Gao <[email protected]>---
Testing notes:- Runtime testing was performed on WCN7850 under the CN regulatory domain.
- 2.4 and 5 GHz scanning and 5 GHz association were verified.
- 6 GHz operation was not tested because it is unavailable under the CN regulatory domain.
- QCC2072 was not tested because the hardware was not available.drivers/net/wireless/ath/ath12k/reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath12k/reg.c +4
-3@@ -300,7 +300,7 @@ int ath12k_regd_update(struct ath12k *ar, bool init)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; + phy_id = ar->pdev->cap.band[NL80211_BAND_2GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }@@ -310,9 +310,10 @@ int ath12k_regd_update(struct ath12k *ar, bool init)ath12k_mac_update_freq_range (ar, freq_low, freq_high); } -if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { +if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && + (!ar->supports_6ghz || ab->hw_params->single_pdev_only)) {if (ab->hw_params->single_pdev_only) { - phy_id = ar->pdev->cap.band[WMI_HOST_WLAN_5GHZ_CAP ].phy_id; + phy_id = ar->pdev->cap.band[NL80211_BAND_5GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }base-commit:
a1a21995c2e1cc2ca6b2226cfe4f5f018370182a
Quoted 9 lines · Shenghan Gao
The update sequence is as follows.
ath12k_regd_update()first resetsar->freq_rangeto zero. On the tested WCN7850 under the CN regulatory domain, the 2 GHz branch calculates a valid range, so the first call toath12k_mac_update_freq_range()setsar->freq_rangeto 2402-2482 MHz.The existing 5 GHz branch is skipped because
ar->supports_6ghzis true.
Quoted 8 lines
When the new regulatory domain is built, reg_freq_6ghz.end_freq is reset to zero. Since the CN regulatory event contains no 6 GHz rules, it remains zero. The 6 GHz branch therefore calculates
freq_highas zero, andath12k_mac_update_freq_range()returns without extending the existing range.Consequently,
ar->freq_rangeremains 2402-2482 MHz, and the subsequent channel-list update filters out all 5 GHz channels.
Thanks, now I get the root cause.
However the change of this patch looks more like a workaround rather than a proper fix:
Current radio frequency logic has been architecturally wrong from the start. Ever since 657b0c72c4ad introduced reg_freq_*, the entire purpose of this code has been to compute a per-radio frequency range (to advertise each radio's own Frequency Range to user space — Idx 0/Idx 1 in iw phyX info). Since the quantity is per-radio, reg_freq_2ghz/5ghz/6ghz should not live in struct ath12k_base (per-device). Storing a per-radio quantity in a per-device field is a layer mismatch, and every problem below derives from it.
Two problems caused by keeping them in ath12k_base:
(a) A cross-phy race that silently drops a range. Firmware sends WMI_REG_CHAN_LIST_CC_EXT per phy. build_regd() resets all three ab->reg_freq_* to {INT_MAX, 0} and refills only its own phy's band on every event, while regd_update() runs per-ar off a workqueue reading that shared per-device state. A later phy's event can reset, e.g., reg_freq_5ghz back to {INT_MAX, 0} before an earlier radio's regd_update_work runs; that radio then computes freq_high = min(high_5ghz_chan, 0) = 0 and the range is silently dropped by ath12k_mac_update_freq_range(). This is a real shared-state race.
(b) It forces the ar->supports_6ghz proxy — which is where your change comes from. Because ab->reg_freq_* is per-device, regd_update() can't tell from it which band this radio covers, so it falls back to ar->supports_6ghz to guess whether this is the 6 GHz-only radio. That proxy only holds on split-pdev; on single-pdev (one pdev covers 5+6 GHz, supports_6ghz=true) it breaks, which is exactly why you had to add the || single_pdev_only exception to rescue 5 GHz. The awkward compound gate is rooted in using a per-device proxy to decide per-radio band ownership.
Based on above, I would suggest making reg_freq_2ghz/5ghz/6ghz per-radio, in struct ath12k_pdev. ath12k_pdev is the driver's canonical per-radio object (1:1 with a radio, holding ar/cap/mac_addr), and this operating range is a property of the radio — so it belongs there, right next to cap (the HW freq limits), which is the same class of data (HW capability vs. the rule-intersected actual range). Both problems then dissolve:
- (a) is gone: each radio's range is isolated; a later phy's event can no longer clobber another's.
- (b) is gone: the gate can ask the ground-truth question — "did this radio receive reg rules for this band?" (end_freq != 0) — with no supports_6ghz proxy:
if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP &&
ar->pdev->reg_freq_5ghz.end_freq) {Quoted 81 lines
With this patch, the 5 GHz branch also runs for single-pdev devices and merges the valid 5 GHz range, extending
ar->freq_rangeto 2402-5835 MHz.Quoted 75 lines · Baochen Qiang <[email protected]> 于2026年7月20日周一 16:34写道:
Quoted 7 lines · Shenghan Gao
Commit
0d777aa2ca77("wifi: ath12k: fix mac pdev frequency range update") madeath12k_regd_update()handle each supported band independently. However, it uses WMI band capability values as indices into pdev->cap.band[]. Those values are bit flags, while cap.band[] is indexed by enumnl80211_band. As a result, the 2.4 GHz lookup reads the 5 GHz entry, while the 5 GHz lookup reads the 60 GHz entry.Quoted 8 lines
Also, the 5 GHz range is skipped whenever the radio supports 6 GHz. This is valid when 5 and 6 GHz belong to separate pdevs, but not for single-pdev devices such as WCN7850, where the same pdev covers both bands. After a regulatory update, 5 GHz is therefore omitted from
ar->freq_rangeand later filtered out of the channel list sent to firmware.On the tested WCN7850, the 11d regulatory update left the frequency range at 2402-2482 MHz and sent 13 channels to firmware. A subsequent 5 GHz scan
can you share more details on how the frequency range is updated to cover only 2 GHz band ?
Quoted 52 lines
failed with
WMI_SCAN_REASON_INTERNAL_FAILURE. With both ranges combined, the range is 2402-5835 MHz and 26 channels are sent to firmware.Index cap.band[] with NL80211_BAND_* and update 5 GHz for single-pdev devices even when 6 GHz is supported.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Fixes 0d777aa2ca77 ("wifi: ath12k: fix mac pdev frequency range update")Assisted-by Codex:GPT-5.6 SolSigned-off-by Shenghan Gao <[email protected]>---
Testing notes:- Runtime testing was performed on WCN7850 under the CN regulatory domain.
- 2.4 and 5 GHz scanning and 5 GHz association were verified.
- 6 GHz operation was not tested because it is unavailable under the CN regulatory domain.
- QCC2072 was not tested because the hardware was not available.drivers/net/wireless/ath/ath12k/reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath12k/reg.c +4
-3@@ -300,7 +300,7 @@ int ath12k_regd_update(struct ath12k *ar, bool init)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; + phy_id = ar->pdev->cap.band[NL80211_BAND_2GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }@@ -310,9 +310,10 @@ int ath12k_regd_update(struct ath12k *ar, bool init)ath12k_mac_update_freq_range (ar, freq_low, freq_high); } -if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { +if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && + (!ar->supports_6ghz || ab->hw_params->single_pdev_only)) {if (ab->hw_params->single_pdev_only) { - phy_id = ar->pdev->cap.band[WMI_HOST_WLAN_5GHZ_CAP ].phy_id; + phy_id = ar->pdev->cap.band[NL80211_BAND_5GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }base-commit:
a1a21995c2e1cc2ca6b2226cfe4f5f018370182a
Quoted 56 lines · Baochen Qiang
Quoted 9 lines · Shenghan Gao
The update sequence is as follows.
ath12k_regd_update()first resetsar->freq_rangeto zero. On the tested WCN7850 under the CN regulatory domain, the 2 GHz branch calculates a valid range, so the first call toath12k_mac_update_freq_range()setsar->freq_rangeto 2402-2482 MHz.The existing 5 GHz branch is skipped because
ar->supports_6ghzis true.Quoted 8 lines
When the new regulatory domain is built, reg_freq_6ghz.end_freq is reset to zero. Since the CN regulatory event contains no 6 GHz rules, it remains zero. The 6 GHz branch therefore calculates
freq_highas zero, andath12k_mac_update_freq_range()returns without extending the existing range.Consequently,
ar->freq_rangeremains 2402-2482 MHz, and the subsequent channel-list update filters out all 5 GHz channels.Thanks, now I get the root cause.
However the change of this patch looks more like a workaround rather than a proper fix:
Current radio frequency logic has been architecturally wrong from the start. Ever since
657b0c72c4adintroduced reg_freq_*, the entire purpose of this code has been to compute a per-radio frequency range (to advertise each radio's own Frequency Range to user space — Idx 0/Idx 1 in iw phyX info). Since the quantity is per-radio, reg_freq_2ghz/5ghz/6ghz should not live in structath12k_base(per-device). Storing a per-radio quantity in a per-device field is a layer mismatch, and every problem below derives from it.Two problems caused by keeping them in
ath12k_base:(a) A cross-phy race that silently drops a range. Firmware sends
WMI_REG_CHAN_LIST_CC_EXTper phy.build_regd()resets all three ab->reg_freq_* to {INT_MAX, 0} and refills only its own phy's band on every event, whileregd_update()runs per-ar off a workqueue reading that shared per-device state. A later phy's event can reset, e.g.,reg_freq_5ghzback to {INT_MAX, 0} before an earlier radio'sregd_update_workruns; that radio then computesfreq_high=min(high_5ghz_chan, 0)= 0 and the range is silently dropped byath12k_mac_update_freq_range(). This is a real shared-state race.(b) It forces the
ar->supports_6ghzproxy — which is where your change comes from. Because ab->reg_freq_* is per-device,regd_update()can't tell from it which band this radio covers, so it falls back toar->supports_6ghzto guess whether this is the 6 GHz-only radio. That proxy only holds on split-pdev; on single-pdev (one pdev covers 5+6 GHz, supports_6ghz=true) it breaks, which is exactly why you had to add the ||single_pdev_onlyexception to rescue 5 GHz. The awkward compound gate is rooted in using a per-device proxy to decide per-radio band ownership.Based on above, I would suggest making reg_freq_2ghz/5ghz/6ghz per-radio, in struct
ath12k_pdev.ath12k_pdevis the driver's canonical per-radio object (1:1 with a radio, holding ar/cap/mac_addr), and this operating range is a property of the radio — so it belongs there, right next to cap (the HW freq limits), which is the same class of data (HW capability vs. the rule-intersected actual range). Both problems then dissolve:
Quoted 7 lines
- (a) is gone: each radio's range is isolated; a later phy's event can no longer clobber another's.
- (b) is gone: the gate can ask the ground-truth question — "did this radio receive reg rules for this band?" (end_freq!= 0) — with nosupports_6ghzproxy:if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->pdev->reg_freq_5ghz.end_freq) {
Shenghan, any thoughts on the suggestion?
Quoted 64 lines · Baochen Qiang
Quoted 61 lines · Baochen Qiang
Quoted 9 lines · Shenghan Gao
The update sequence is as follows.
ath12k_regd_update()first resetsar->freq_rangeto zero. On the tested WCN7850 under the CN regulatory domain, the 2 GHz branch calculates a valid range, so the first call toath12k_mac_update_freq_range()setsar->freq_rangeto 2402-2482 MHz.The existing 5 GHz branch is skipped because
ar->supports_6ghzis true.Quoted 8 lines
When the new regulatory domain is built, reg_freq_6ghz.end_freq is reset to zero. Since the CN regulatory event contains no 6 GHz rules, it remains zero. The 6 GHz branch therefore calculates
freq_highas zero, andath12k_mac_update_freq_range()returns without extending the existing range.Consequently,
ar->freq_rangeremains 2402-2482 MHz, and the subsequent channel-list update filters out all 5 GHz channels.Thanks, now I get the root cause.
However the change of this patch looks more like a workaround rather than a proper fix:
Current radio frequency logic has been architecturally wrong from the start. Ever since
657b0c72c4adintroduced reg_freq_*, the entire purpose of this code has been to compute a per-radio frequency range (to advertise each radio's own Frequency Range to user space — Idx 0/Idx 1 in iw phyX info). Since the quantity is per-radio, reg_freq_2ghz/5ghz/6ghz should not live in structath12k_base(per-device). Storing a per-radio quantity in a per-device field is a layer mismatch, and every problem below derives from it.Two problems caused by keeping them in
ath12k_base:(a) A cross-phy race that silently drops a range. Firmware sends
WMI_REG_CHAN_LIST_CC_EXTper phy.build_regd()resets all three ab->reg_freq_* to {INT_MAX, 0} and refills only its own phy's band on every event, whileregd_update()runs per-ar off a workqueue reading that shared per-device state. A later phy's event can reset, e.g.,reg_freq_5ghzback to {INT_MAX, 0} before an earlier radio'sregd_update_workruns; that radio then computesfreq_high=min(high_5ghz_chan, 0)= 0 and the range is silently dropped byath12k_mac_update_freq_range(). This is a real shared-state race.(b) It forces the
ar->supports_6ghzproxy — which is where your change comes from. Because ab->reg_freq_* is per-device,regd_update()can't tell from it which band this radio covers, so it falls back toar->supports_6ghzto guess whether this is the 6 GHz-only radio. That proxy only holds on split-pdev; on single-pdev (one pdev covers 5+6 GHz, supports_6ghz=true) it breaks, which is exactly why you had to add the ||single_pdev_onlyexception to rescue 5 GHz. The awkward compound gate is rooted in using a per-device proxy to decide per-radio band ownership.Based on above, I would suggest making reg_freq_2ghz/5ghz/6ghz per-radio, in struct
ath12k_pdev.ath12k_pdevis the driver's canonical per-radio object (1:1 with a radio, holding ar/cap/mac_addr), and this operating range is a property of the radio — so it belongs there, right next to cap (the HW freq limits), which is the same class of data (HW capability vs. the rule-intersected actual range). Both problems then dissolve:- (a) is gone: each radio's range is isolated; a later phy's event can no longer clobber another's.
- (b) is gone: the gate can ask the ground-truth question — "did this radio receive reg rules for this band?" (end_freq!= 0) — with nosupports_6ghzproxy:
Quoted 4 lines
Quoted 2 lines
if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->pdev->reg_freq_5ghz.end_freq) {Shenghan, any thoughts on the suggestion?
Working through my backlog. Is there any action on this?
PATCH 1/1 wifi: ath12k: fix lost 5 GHz range by tracking reg ranges per radio
ath12k_reg_build_regd() records the frequency span covered by the received reg rules in ab->reg_freq_{2,5,6}ghz. Those fields live in struct ath12k_base, but firmware sends WMI_REG_CHAN_LIST_CC_EXT per radio, and ath12k_regd_update() uses them to compute the frequency range of a single radio (ar->freq_range). This causes two problems.
First, ath12k_regd_update() cannot tell which bands a radio received rules for, so it uses ar->supports_6ghz as a proxy: the 5 GHz range is skipped for any radio that supports 6 GHz. That is only valid for split-pdev devices. On single-pdev devices such as WCN7850 one radio covers 2 GHz, 5 GHz and 6 GHz. When firmware switches to a country without 6 GHz rules, for example after an 11d update to CN or EG, ar->freq_range collapses to 2402-2482 MHz and ath12k_reg_update_chan_list() drops every 5 GHz channel from the list sent to firmware. From then on firmware no longer scans 5 GHz, a 5 GHz-only scan request fails ("received scan start failure event"), and 5 GHz networks disappear from scan results, typically shortly after boot. They stay gone until the driver is reloaded or firmware moves to a country that has 6 GHz rules.
Second, by code inspection, build_regd() resets all three per-device ranges on every event, so on multi-radio devices an event for one radio can wipe the range of another radio whose regd_update_work has not run yet, silently dropping a band.
Move reg_freq_{2,5,6}ghz into struct ath12k_pdev and fill them for the radio identified by reg_info->phy_id. In ath12k_regd_update(), include a band only if this radio registered that band and received reg rules for it, instead of guessing from ar->supports_6ghz. Checking the registered band is needed because a radio can receive rules for bands it does not operate on, e.g. the 6 GHz radio of a split-pdev device.
Also fix the reg_cap lookup for single-pdev devices: pdev->cap.band[] is indexed by enum nl80211_band, but was indexed with the WMI_HOST_WLAN_*_CAP bit flags, so the 2 GHz lookup used the 5 GHz entry and the 5 GHz lookup used the unset 60 GHz entry. Refresh reg_cap for the 6 GHz band as well, as is done for 2 GHz and 5 GHz.
With ATH12K_DBG_MAC enabled on WCN7850 and the firmware switching to EG, the range before this change is:
mac pdev 0 freq limit updated. New range 2402->2482 MHz
and after it:
mac pdev 0 freq limit updated. New range 2402->2482 MHz mac pdev 0 freq limit updated. New range 2402->5330 MHz
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
---
Notes:
Jeff, sorry for the duplicate: a test send reached you a few minutes ago without the lists.
This picks up Shenghan Gao's patch "wifi: ath12k: fix frequency range for single-pdev devices" [1], reworked as Baochen suggested in review [2]: reg_freq_* are now per radio, and each band is gated on whether the radio received rules for it instead of on ar->supports_6ghz. On top of that suggestion, the band must also be registered on the radio, since the 6 GHz pdev of a split-pdev device receives rules for all bands.
Shenghan, I hope you don't mind me picking this up after the thread went quiet. I kept your band-index fix and credited your report.
Testing:
- WCN7850 (single-pdev) with the firmware above. Firmware sets the country to EG via 11d about 7 s after the driver loads.
Before: freq_range drops to 2402->2482 MHz after the EG update, a 5 GHz-only scan is rejected ("received scan start failure event"), and all 5 GHz networks are gone from scan results after about a minute.
After: the range is 2402->5330 MHz, a 5 GHz-only scan returns 26 BSSes, 5 GHz networks stayed visible for the whole 26 minute run while associated on 2.4 GHz, and association to a 5 GHz AP works.
- Built for x86_64 with W=1; checkpatch --strict and sparse report nothing new.
Not tested: split-pdev devices such as QCN9274, and 6 GHz operation (EG has no 6 GHz rules). The split-pdev handling is based on reading the code only.
AI assistance: I used Claude (claude-opus-5-5) to investigate the problem on my machine, write the patch following Baochen's suggestion, draft this message and run the tests above. I reviewed the change and tested it on my hardware.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
drivers/net/wireless/ath/ath12k/core.h | 20 +++++---- drivers/net/wireless/ath/ath12k/mac.c | 12 ++--- drivers/net/wireless/ath/ath12k/reg.c | 61 ++++++++++++++++---------- 3 files changed, 56 insertions(+), 37 deletions(-)
drivers/net/wireless/ath/ath12k/core.h +12 -8
@@ -850,6 +850,11 @@ struct mlo_timestamp {u32 mlo_comp_timer; }; +struct ath12k_reg_freq { +u32 start_freq; +u32 end_freq; +}; +struct ath12k_pdev {struct ath12k *ar;u32 pdev_id;
@@ -857,6 +862,13 @@ struct ath12k_pdev {struct ath12k_pdev_cap cap;u8 mac_addr[ETH_ALEN ];struct mlo_timestamp timestamp; + +/* Frequency ranges covered by the reg rules last received for +* this radio, per band. end_freq is 0 if no rules were received. +*/ +struct ath12k_reg_freq reg_freq_2ghz; +struct ath12k_reg_freq reg_freq_5ghz; +struct ath12k_reg_freq reg_freq_6ghz; };struct ath12k_fw_pdev {
@@ -871,11 +883,6 @@ struct ath12k_board_data {size_t len; }; -struct ath12k_reg_freq { -u32 start_freq; -u32 end_freq; -}; -struct ath12k_mlo_memory {struct target_mem_chunk chunk[ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01 ];int mlo_mem_size;
@@ -1147,9 +1154,6 @@ struct ath12k_base {/* Denote whether MLO is possible within the device */ bool single_chip_mlo_support; -struct ath12k_reg_freq reg_freq_2ghz; -struct ath12k_reg_freq reg_freq_5ghz; -struct ath12k_reg_freq reg_freq_6ghz;const struct ath12k_mem_profile_based_param *profile_param;enum ath12k_qmi_mem_mode target_mem_mode;
drivers/net/wireless/ath/ath12k/mac.c +6 -6
@@ -14263,9 +14263,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, } freq_low =max (reg_cap->low_2ghz_chan, - ab->reg_freq_2ghz.start_freq); + ar->pdev->reg_freq_2ghz.start_freq); freq_high =min (reg_cap->high_2ghz_chan, - ab->reg_freq_2ghz.end_freq); + ar->pdev->reg_freq_2ghz.end_freq); ath12k_mac_update_ch_list(ar, band, reg_cap->low_2ghz_chan,
@@ -14308,9 +14308,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, band->bitrates = ath12k_a_rates; freq_low =max (reg_cap->low_5ghz_chan, - ab->reg_freq_6ghz.start_freq); + ar->pdev->reg_freq_6ghz.start_freq); freq_high =min (reg_cap->high_5ghz_chan, - ab->reg_freq_6ghz.end_freq); + ar->pdev->reg_freq_6ghz.end_freq); ath12k_mac_update_ch_list(ar, band, reg_cap->low_5ghz_chan,
@@ -14365,9 +14365,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, } freq_low =max (reg_cap->low_5ghz_chan, - ab->reg_freq_5ghz.start_freq); + ar->pdev->reg_freq_5ghz.start_freq); freq_high =min (reg_cap->high_5ghz_chan, - ab->reg_freq_5ghz.end_freq); + ar->pdev->reg_freq_5ghz.end_freq); ath12k_mac_update_ch_list(ar, band, reg_cap->low_5ghz_chan,
drivers/net/wireless/ath/ath12k/reg.c +38 -23
132 lines not on this page · raw message
base-commit: 9f0fe5ad0c9af369400bb87143bc936ebb741391
Signature · 1 line
2.56.0
Re: [PATCH ath-current] wifi: ath12k: fix lost 5 GHz range by tracking reg ranges per radio
Quoted 50 lines · Ahmed Essam
ath12k_reg_build_regd()records the frequency span covered by the received reg rules in ab->reg_freq_{2,5,6}ghz. Those fields live in structath12k_base, but firmware sendsWMI_REG_CHAN_LIST_CC_EXTper radio, andath12k_regd_update()uses them to compute the frequency range of a single radio (ar->freq_range). This causes two problems.First,
ath12k_regd_update()cannot tell which bands a radio received rules for, so it usesar->supports_6ghzas a proxy: the 5 GHz range is skipped for any radio that supports 6 GHz. That is only valid for split-pdev devices. On single-pdev devices such as WCN7850 one radio covers 2 GHz, 5 GHz and 6 GHz. When firmware switches to a country without 6 GHz rules, for example after an 11d update to CN or EG,ar->freq_rangecollapses to 2402-2482 MHz andath12k_reg_update_chan_list()drops every 5 GHz channel from the list sent to firmware. From then on firmware no longer scans 5 GHz, a 5 GHz-only scan request fails ("received scan start failure event"), and 5 GHz networks disappear from scan results, typically shortly after boot. They stay gone until the driver is reloaded or firmware moves to a country that has 6 GHz rules.Second, by code inspection,
build_regd()resets all three per-device ranges on every event, so on multi-radio devices an event for one radio can wipe the range of another radio whoseregd_update_workhas not run yet, silently dropping a band.Move reg_freq_{2,5,6}ghz into struct
ath12k_pdevand fill them for the radio identified byreg_info->phy_id. Inath12k_regd_update(), include a band only if this radio registered that band and received reg rules for it, instead of guessing fromar->supports_6ghz. Checking the registered band is needed because a radio can receive rules for bands it does not operate on, e.g. the 6 GHz radio of a split-pdev device.Also fix the
reg_caplookup for single-pdev devices: pdev->cap.band[] is indexed by enumnl80211_band, but was indexed with the WMI_HOST_WLAN_*_CAP bit flags, so the 2 GHz lookup used the 5 GHz entry and the 5 GHz lookup used the unset 60 GHz entry. Refreshreg_capfor the 6 GHz band as well, as is done for 2 GHz and 5 GHz.With
ATH12K_DBG_MACenabled on WCN7850 and the firmware switching to EG, the range before this change is:mac pdev 0 freq limit updated. New range 2402->2482 MHz
and after it:
mac pdev 0 freq limit updated. New range 2402->2482 MHz mac pdev 0 freq limit updated. New range 2402->5330 MHz
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Quoted 9 lines
Fixes 657b0c72c4ad ("wifi: ath12k: Fix frequency range in driver")Fixes 13324cecbb2c ("wifi: ath12k: Update frequency range if reg rules changes")Fixes 0d777aa2ca77 ("wifi: ath12k: fix mac pdev frequency range update")Reported-by Shenghan Gao <[email protected]>Suggested-by Baochen Qiang <[email protected]>Assisted-by Claude:claude-opus-5-5 sparseSigned-off-by Ahmed Essam <[email protected]>
Ah, I have an almost-identical fix pending internal review, but I think yours is better. Thanks.
Quoted 53 lines · Shenghan Gao
Commit
0d777aa2ca77("wifi: ath12k: fix mac pdev frequency range update") madeath12k_regd_update()handle each supported band independently. However, it uses WMI band capability values as indices into pdev->cap.band[]. Those values are bit flags, while cap.band[] is indexed by enumnl80211_band. As a result, the 2.4 GHz lookup reads the 5 GHz entry, while the 5 GHz lookup reads the 60 GHz entry.Also, the 5 GHz range is skipped whenever the radio supports 6 GHz. This is valid when 5 and 6 GHz belong to separate pdevs, but not for single-pdev devices such as WCN7850, where the same pdev covers both bands. After a regulatory update, 5 GHz is therefore omitted from
ar->freq_rangeand later filtered out of the channel list sent to firmware.On the tested WCN7850, the 11d regulatory update left the frequency range at 2402-2482 MHz and sent 13 channels to firmware. A subsequent 5 GHz scan failed with
WMI_SCAN_REASON_INTERNAL_FAILURE. With both ranges combined, the range is 2402-5835 MHz and 26 channels are sent to firmware.Index cap.band[] with NL80211_BAND_* and update 5 GHz for single-pdev devices even when 6 GHz is supported.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Fixes 0d777aa2ca77 ("wifi: ath12k: fix mac pdev frequency range update")Assisted-by Codex:GPT-5.6 SolSigned-off-by Shenghan Gao <[email protected]>---
Testing notes:- Runtime testing was performed on WCN7850 under the CN regulatory domain.
- 2.4 and 5 GHz scanning and 5 GHz association were verified.
- 6 GHz operation was not tested because it is unavailable under the CN regulatory domain.
- QCC2072 was not tested because the hardware was not available.drivers/net/wireless/ath/ath12k/reg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/net/wireless/ath/ath12k/reg.c +1
-1@@ -300,7 +300,7 @@ int ath12k_regd_update(struct ath12k *ar, bool init)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; + phy_id = ar->pdev->cap.band[NL80211_BAND_2GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id]; }
drivers/net/wireless/ath/ath12k/reg.c int ath12k_regd_update(struct ath12k *ar, bool init) · line 317
Quoted 10 lines
drivers/net/wireless/ath/ath12k/reg.c +3
-2@@ -310,9 +310,10 @@ int ath12k_regd_update(struct ath12k *ar, bool init)ath12k_mac_update_freq_range (ar, freq_low, freq_high); } -if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { +if (supported_bands &WMI_HOST_WLAN_5GHZ_CAP && + (!ar->supports_6ghz || ab->hw_params->single_pdev_only)) {if (ab->hw_params->single_pdev_only) { - phy_id = ar->pdev->cap.band[WMI_HOST_WLAN_5GHZ_CAP ].phy_id; + phy_id = ar->pdev->cap.band[NL80211_BAND_5GHZ ].phy_id; reg_cap = &ab->hal_reg_cap[phy_id];
seems we should also refresh reg_cap for single-pdev case 6 GHz band?
Quoted 4 lines
drivers/net/wireless/ath/ath12k/reg.c +0
-0}base-commit:
a1a21995c2e1cc2ca6b2226cfe4f5f018370182a