* [PATCH] wifi: ath12k: fix chain-mask shift on 64-bit big-endian
@ 2026-09-16 14:30 Michael Pfeifroth
2026-09-17 3:07 ` Baochen Qiang
0 siblings, 1 reply; 2+ messages in thread
From: Michael Pfeifroth @ 2026-09-16 14:30 UTC (permalink / raw)
To: Jeff Johnson, Kalle Valo; +Cc: ath12k, linux-wireless, linux-kernel
ath12k_pull_mac_phy_cap_svc_ready_ext() derives the tx/rx chain-mask shift
with find_first_bit((unsigned long *)&pdev_cap->rx_chain_mask, 32).
pdev_cap->{tx,rx}_chain_mask are u32, but find_first_bit() treats the
pointer as an array of unsigned long. On 64-bit big-endian, unsigned long
is 8 bytes, so the u32 value ends up in the high 32 bits of the word while
find_first_bit(..., 32) only scans the low 32 bits, i.e. the adjacent
struct member. rx_chain_mask_shift is therefore computed as 32,
ath12k_mac_setup_ht_vht_cap() evaluates cfg_rx_chainmask >> 32 == 0, and
the driver advertises a VHT RX-MCS map with all streams "not supported".
mac80211 then rejects the VHT capability ("Ignoring VHT IE ... due to
invalid rx_mcs_map"), so the link only comes up as HT40 and never
negotiates 80/160 MHz. tx_chain_mask_shift happens to scan a zero word and
stays 0, so only the RX side is affected.
Use __ffs() on the mask value instead of pointing find_first_bit() at the
u32's storage. __ffs() takes its argument by value, so the shift is
computed correctly regardless of word size or endianness. The chain masks
are always non-zero here, so __ffs() is well defined.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Pfeifroth <micpf@westermo.com>
---
drivers/net/wireless/ath/ath12k/wmi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -563,10 +563,8 @@ ath12k_pull_mac_phy_cap_svc_ready_ext(struct ath12k_wmi_pdev *wmi_handle,
* for tx/rx chainmask which will be used to advertise supported ht/vht rates to
* mac80211.
*/
- pdev_cap->tx_chain_mask_shift =
- find_first_bit((unsigned long *)&pdev_cap->tx_chain_mask, 32);
- pdev_cap->rx_chain_mask_shift =
- find_first_bit((unsigned long *)&pdev_cap->rx_chain_mask, 32);
+ pdev_cap->tx_chain_mask_shift = __ffs(pdev_cap->tx_chain_mask);
+ pdev_cap->rx_chain_mask_shift = __ffs(pdev_cap->rx_chain_mask);
if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) {
cap_band = &pdev_cap->band[NL80211_BAND_2GHZ];
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] wifi: ath12k: fix chain-mask shift on 64-bit big-endian
2026-09-16 14:30 [PATCH] wifi: ath12k: fix chain-mask shift on 64-bit big-endian Michael Pfeifroth
@ 2026-09-17 3:07 ` Baochen Qiang
0 siblings, 0 replies; 2+ messages in thread
From: Baochen Qiang @ 2026-09-17 3:07 UTC (permalink / raw)
To: Michael Pfeifroth, Jeff Johnson, Kalle Valo
Cc: ath12k, linux-wireless, linux-kernel
On 9/16/2026 10:30 PM, Michael Pfeifroth wrote:
> ath12k_pull_mac_phy_cap_svc_ready_ext() derives the tx/rx chain-mask shift
> with find_first_bit((unsigned long *)&pdev_cap->rx_chain_mask, 32).
>
> pdev_cap->{tx,rx}_chain_mask are u32, but find_first_bit() treats the
> pointer as an array of unsigned long. On 64-bit big-endian, unsigned long
> is 8 bytes, so the u32 value ends up in the high 32 bits of the word while
> find_first_bit(..., 32) only scans the low 32 bits, i.e. the adjacent
> struct member. rx_chain_mask_shift is therefore computed as 32,
> ath12k_mac_setup_ht_vht_cap() evaluates cfg_rx_chainmask >> 32 == 0, and
> the driver advertises a VHT RX-MCS map with all streams "not supported".
> mac80211 then rejects the VHT capability ("Ignoring VHT IE ... due to
> invalid rx_mcs_map"), so the link only comes up as HT40 and never
> negotiates 80/160 MHz. tx_chain_mask_shift happens to scan a zero word and
> stays 0, so only the RX side is affected.
>
> Use __ffs() on the mask value instead of pointing find_first_bit() at the
> u32's storage. __ffs() takes its argument by value, so the shift is
> computed correctly regardless of word size or endianness. The chain masks
> are always non-zero here, so __ffs() is well defined.
>
> Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Michael Pfeifroth <micpf@westermo.com>
ath11k has the same issue, interested to fix it as well?
anyway:
Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-17 3:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 14:30 [PATCH] wifi: ath12k: fix chain-mask shift on 64-bit big-endian Michael Pfeifroth
2026-09-17 3:07 ` Baochen Qiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®