ATH11K Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling
@ 2023-09-26 16:33 Kalle Valo
  2023-09-26 16:36 ` Kalle Valo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kalle Valo @ 2023-09-26 16:33 UTC (permalink / raw)
  To: ath11k; +Cc: linux-wireless

From: Kalle Valo <quic_kvalo@quicinc.com>

Commit e8c1841278a7 ("wifi: cfg80211: annotate iftype_data pointer with
sparse") added sparse checks for struct ieee80211_sband_iftype_data handling
which immediately found an issue in ath11k:

drivers/net/wireless/ath/ath11k/mac.c:7952:22: warning: incorrect type in argument 1 (different address spaces)
drivers/net/wireless/ath/ath11k/mac.c:7952:22:    expected struct ieee80211_sta_he_cap const *he_cap
drivers/net/wireless/ath/ath11k/mac.c:7952:22:    got struct ieee80211_sta_he_cap const [noderef] __iftype_data *

The problem here is that we are accessing sband->iftype_data directly even
though we should use for_each_sband_iftype_data() or similar. Fortunately
there's ieee80211_get_he_iftype_cap_vif() which is just we need here so use it
to get HE capabilities.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
---
 drivers/net/wireless/ath/ath11k/mac.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index c071bf5841af..79059c42e730 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -7910,12 +7910,14 @@ ath11k_mac_get_tx_mcs_map(const struct ieee80211_sta_he_cap *he_cap)
 
 static bool
 ath11k_mac_bitrate_mask_get_single_nss(struct ath11k *ar,
+				       struct ath11k_vif *arvif,
 				       enum nl80211_band band,
 				       const struct cfg80211_bitrate_mask *mask,
 				       int *nss)
 {
 	struct ieee80211_supported_band *sband = &ar->mac.sbands[band];
 	u16 vht_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map);
+	const struct ieee80211_sta_he_cap *he_cap;
 	u16 he_mcs_map = 0;
 	u8 ht_nss_mask = 0;
 	u8 vht_nss_mask = 0;
@@ -7946,7 +7948,8 @@ ath11k_mac_bitrate_mask_get_single_nss(struct ath11k *ar,
 			return false;
 	}
 
-	he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(&sband->iftype_data->he_cap));
+	he_cap = ieee80211_get_he_iftype_cap_vif(sband, arvif->vif);
+	he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(he_cap));
 
 	for (i = 0; i < ARRAY_SIZE(mask->control[band].he_mcs); i++) {
 		if (mask->control[band].he_mcs[i] == 0)
@@ -8362,7 +8365,7 @@ ath11k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw,
 		ieee80211_iterate_stations_atomic(ar->hw,
 						  ath11k_mac_disable_peer_fixed_rate,
 						  arvif);
-	} else if (ath11k_mac_bitrate_mask_get_single_nss(ar, band, mask,
+	} else if (ath11k_mac_bitrate_mask_get_single_nss(ar, arvif, band, mask,
 							  &single_nss)) {
 		rate = WMI_FIXED_RATE_NONE;
 		nss = single_nss;

base-commit: 73e13f6a439b75a9dbc84bbfa0b0d6624b354853
-- 
2.39.2


-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling
  2023-09-26 16:33 [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling Kalle Valo
@ 2023-09-26 16:36 ` Kalle Valo
  2023-09-26 16:43 ` Johannes Berg
  2023-09-26 20:55 ` Jeff Johnson
  2 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2023-09-26 16:36 UTC (permalink / raw)
  To: ath11k; +Cc: linux-wireless

Kalle Valo <kvalo@kernel.org> writes:

> From: Kalle Valo <quic_kvalo@quicinc.com>
>
> Commit e8c1841278a7 ("wifi: cfg80211: annotate iftype_data pointer with
> sparse") added sparse checks for struct ieee80211_sband_iftype_data handling
> which immediately found an issue in ath11k:
>
> drivers/net/wireless/ath/ath11k/mac.c:7952:22: warning: incorrect type
> in argument 1 (different address spaces)
> drivers/net/wireless/ath/ath11k/mac.c:7952:22: expected struct
> ieee80211_sta_he_cap const *he_cap
> drivers/net/wireless/ath/ath11k/mac.c:7952:22: got struct
> ieee80211_sta_he_cap const [noderef] __iftype_data *
>
> The problem here is that we are accessing sband->iftype_data directly even
> though we should use for_each_sband_iftype_data() or similar. Fortunately
> there's ieee80211_get_he_iftype_cap_vif() which is just we need here so use it
> to get HE capabilities.
>
> Tested-on: WCN6855 hw2.0 PCI
> WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23
>
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Changelog for v2:

* use ieee80211_get_he_iftype_cap_vif() instead of open coding it

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling
  2023-09-26 16:33 [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling Kalle Valo
  2023-09-26 16:36 ` Kalle Valo
@ 2023-09-26 16:43 ` Johannes Berg
  2023-09-26 19:05   ` Kalle Valo
  2023-09-26 20:55 ` Jeff Johnson
  2 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2023-09-26 16:43 UTC (permalink / raw)
  To: Kalle Valo, ath11k; +Cc: linux-wireless

On Tue, 2023-09-26 at 19:33 +0300, Kalle Valo wrote:
> 
> -	he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(&sband->iftype_data->he_cap));
> +	he_cap = ieee80211_get_he_iftype_cap_vif(sband, arvif->vif);
> +	he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(he_cap));

Technically, ieee80211_get_he_iftype_cap_vif() could return NULL if you
didn't actually configure/enable HE for this iftype, the static checkers
might complain here.

johannes

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling
  2023-09-26 16:43 ` Johannes Berg
@ 2023-09-26 19:05   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2023-09-26 19:05 UTC (permalink / raw)
  To: Johannes Berg; +Cc: ath11k, linux-wireless

Johannes Berg <johannes@sipsolutions.net> writes:

> On Tue, 2023-09-26 at 19:33 +0300, Kalle Valo wrote:
>> 
>> - he_mcs_map =
>> le16_to_cpu(ath11k_mac_get_tx_mcs_map(&sband->iftype_data->he_cap));
>> +	he_cap = ieee80211_get_he_iftype_cap_vif(sband, arvif->vif);
>> +	he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(he_cap));
>
> Technically, ieee80211_get_he_iftype_cap_vif() could return NULL if you
> didn't actually configure/enable HE for this iftype, the static checkers
> might complain here.

And this is even mentioned in the documentation which I failed to see:

 * Return: pointer to the struct ieee80211_sta_he_cap, or %NULL is none found

Thanks! I'll fix this in v3.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling
  2023-09-26 16:33 [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling Kalle Valo
  2023-09-26 16:36 ` Kalle Valo
  2023-09-26 16:43 ` Johannes Berg
@ 2023-09-26 20:55 ` Jeff Johnson
  2023-09-27  5:12   ` Kalle Valo
  2 siblings, 1 reply; 6+ messages in thread
From: Jeff Johnson @ 2023-09-26 20:55 UTC (permalink / raw)
  To: Kalle Valo, ath11k; +Cc: linux-wireless

On 9/26/2023 9:33 AM, Kalle Valo wrote:
> From: Kalle Valo <quic_kvalo@quicinc.com>
> 
> Commit e8c1841278a7 ("wifi: cfg80211: annotate iftype_data pointer with
> sparse") added sparse checks for struct ieee80211_sband_iftype_data handling
> which immediately found an issue in ath11k:
> 
> drivers/net/wireless/ath/ath11k/mac.c:7952:22: warning: incorrect type in argument 1 (different address spaces)
> drivers/net/wireless/ath/ath11k/mac.c:7952:22:    expected struct ieee80211_sta_he_cap const *he_cap
> drivers/net/wireless/ath/ath11k/mac.c:7952:22:    got struct ieee80211_sta_he_cap const [noderef] __iftype_data *
> 
> The problem here is that we are accessing sband->iftype_data directly even
> though we should use for_each_sband_iftype_data() or similar. Fortunately
> there's ieee80211_get_he_iftype_cap_vif() which is just we need here so use it

nit: just *what* we need

> to get HE capabilities.


-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling
  2023-09-26 20:55 ` Jeff Johnson
@ 2023-09-27  5:12   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2023-09-27  5:12 UTC (permalink / raw)
  To: Jeff Johnson; +Cc: ath11k, linux-wireless

Jeff Johnson <quic_jjohnson@quicinc.com> writes:

> On 9/26/2023 9:33 AM, Kalle Valo wrote:
>> From: Kalle Valo <quic_kvalo@quicinc.com>
>> Commit e8c1841278a7 ("wifi: cfg80211: annotate iftype_data pointer
>> with
>> sparse") added sparse checks for struct ieee80211_sband_iftype_data handling
>> which immediately found an issue in ath11k:
>> drivers/net/wireless/ath/ath11k/mac.c:7952:22: warning: incorrect
>> type in argument 1 (different address spaces)
>> drivers/net/wireless/ath/ath11k/mac.c:7952:22:    expected struct ieee80211_sta_he_cap const *he_cap
>> drivers/net/wireless/ath/ath11k/mac.c:7952:22:    got struct ieee80211_sta_he_cap const [noderef] __iftype_data *
>> The problem here is that we are accessing sband->iftype_data
>> directly even
>> though we should use for_each_sband_iftype_data() or similar. Fortunately
>> there's ieee80211_get_he_iftype_cap_vif() which is just we need here so use it
>
> nit: just *what* we need

I'll add that, thanks.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-09-27  5:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-26 16:33 [PATCH v2] wifi: ath11k: mac: fix struct ieee80211_sband_iftype_data handling Kalle Valo
2023-09-26 16:36 ` Kalle Valo
2023-09-26 16:43 ` Johannes Berg
2023-09-26 19:05   ` Kalle Valo
2023-09-26 20:55 ` Jeff Johnson
2023-09-27  5:12   ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox