All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wifi: mt76: inititalize sband.band to correct value
@ 2024-02-07  0:01 Bert Karwatzki
  2024-02-07  5:46 ` Kalle Valo
  0 siblings, 1 reply; 4+ messages in thread
From: Bert Karwatzki @ 2024-02-07  0:01 UTC (permalink / raw)
  To: Lorenzo Bianconi, Felix Fietkau, Ryder Lee
  Cc: Bert Karwatzki, linux-kernel, linux-wireless, Johannes Berg

Set phy->sband_{2,5,6}g.sband.band to the correct enum value, otherwise
the ieee80211_register_hw() will fail to register the device.

Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=218466

Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 8a3a90d1bfac..6cf08446f445 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -363,6 +363,7 @@ mt76_init_sband_2g(struct mt76_phy *phy, struct ieee80211_rate *rates,
 		   int n_rates)
 {
 	phy->hw->wiphy->bands[NL80211_BAND_2GHZ] = &phy->sband_2g.sband;
+	phy->sband_2g.sband.band = NL80211_BAND_2GHZ;

 	return mt76_init_sband(phy, &phy->sband_2g, mt76_channels_2ghz,
 			       ARRAY_SIZE(mt76_channels_2ghz), rates,
@@ -374,6 +375,7 @@ mt76_init_sband_5g(struct mt76_phy *phy, struct ieee80211_rate *rates,
 		   int n_rates, bool vht)
 {
 	phy->hw->wiphy->bands[NL80211_BAND_5GHZ] = &phy->sband_5g.sband;
+	phy->sband_5g.sband.band = NL80211_BAND_5GHZ;

 	return mt76_init_sband(phy, &phy->sband_5g, mt76_channels_5ghz,
 			       ARRAY_SIZE(mt76_channels_5ghz), rates,
@@ -385,6 +387,7 @@ mt76_init_sband_6g(struct mt76_phy *phy, struct ieee80211_rate *rates,
 		   int n_rates)
 {
 	phy->hw->wiphy->bands[NL80211_BAND_6GHZ] = &phy->sband_6g.sband;
+	phy->sband_6g.sband.band = NL80211_BAND_6GHZ;

 	return mt76_init_sband(phy, &phy->sband_6g, mt76_channels_6ghz,
 			       ARRAY_SIZE(mt76_channels_6ghz), rates,
--
2.39.2

When using linux-next-20240205 my mediatek wifi device failed to start.
A bisection led to commit f04d2c247e0407 as the problem:
https://bugzilla.kernel.org/show_bug.cgi?id=218466
After closer examination of the mt76 code it the problem was to to be
the incomplete initialization of phy->sband_{2,5,6}g. The band field has
to be set to not confuse the new mac80211 code. (the sband_2g structure
was correctly initialized accidendly as NL80211_BAND_2GHZ is 0).

Bert Karwatzki

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

* Re: [PATCH] wifi: mt76: inititalize sband.band to correct value
  2024-02-07  0:01 [PATCH] wifi: mt76: inititalize sband.band to correct value Bert Karwatzki
@ 2024-02-07  5:46 ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2024-02-07  5:46 UTC (permalink / raw)
  To: Bert Karwatzki
  Cc: Lorenzo Bianconi, Felix Fietkau, Ryder Lee, linux-kernel,
	linux-wireless, Johannes Berg

Bert Karwatzki <spasswolf@web.de> writes:

> Set phy->sband_{2,5,6}g.sband.band to the correct enum value, otherwise
> the ieee80211_register_hw() will fail to register the device.
>
> Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=218466

s/Fixes/Closes/

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

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

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

* Re: [PATCH] wifi: mt76: inititalize sband.band to correct value
  2024-02-07  7:22 Bert Karwatzki
@ 2024-02-07 10:52 ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2024-02-07 10:52 UTC (permalink / raw)
  To: Bert Karwatzki, Lorenzo Bianconi, Felix Fietkau, Ryder Lee
  Cc: linux-kernel, linux-wireless

On Wed, 2024-02-07 at 08:22 +0100, Bert Karwatzki wrote:
> Set phy->sband_{2,5,6}g.sband.band to the correct enum value, otherwise
> the ieee80211_register_hw() will fail to register the device.

So turns out that technically, it wasn't needed before because cfg80211
*will* set sband->band, but *mac80211* now requires it to have been set
before ...

We could do a trivial fix in mac80211 as well:

--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1124,7 +1124,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 			supp_he = supp_he || iftd->he_cap.has_he;
 			supp_eht = supp_eht || iftd->eht_cap.has_eht;
 
-			if (sband->band == NL80211_BAND_2GHZ)
+			if (band == NL80211_BAND_2GHZ)
 				he_40_mhz_cap =
 					IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G;
 			else


but seems like no other driver even likely needed this, and it's
probably less reliable in the long term?

Or do both?

johannes


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

* [PATCH] wifi: mt76: inititalize sband.band to correct value
@ 2024-02-07  7:22 Bert Karwatzki
  2024-02-07 10:52 ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Bert Karwatzki @ 2024-02-07  7:22 UTC (permalink / raw)
  To: Lorenzo Bianconi, Felix Fietkau, Ryder Lee
  Cc: Bert Karwatzki, linux-kernel, linux-wireless, Johannes Berg

Set phy->sband_{2,5,6}g.sband.band to the correct enum value, otherwise
the ieee80211_register_hw() will fail to register the device.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218466

Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 8a3a90d1bfac..6cf08446f445 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -363,6 +363,7 @@ mt76_init_sband_2g(struct mt76_phy *phy, struct ieee80211_rate *rates,
 		   int n_rates)
 {
 	phy->hw->wiphy->bands[NL80211_BAND_2GHZ] = &phy->sband_2g.sband;
+	phy->sband_2g.sband.band = NL80211_BAND_2GHZ;

 	return mt76_init_sband(phy, &phy->sband_2g, mt76_channels_2ghz,
 			       ARRAY_SIZE(mt76_channels_2ghz), rates,
@@ -374,6 +375,7 @@ mt76_init_sband_5g(struct mt76_phy *phy, struct ieee80211_rate *rates,
 		   int n_rates, bool vht)
 {
 	phy->hw->wiphy->bands[NL80211_BAND_5GHZ] = &phy->sband_5g.sband;
+	phy->sband_5g.sband.band = NL80211_BAND_5GHZ;

 	return mt76_init_sband(phy, &phy->sband_5g, mt76_channels_5ghz,
 			       ARRAY_SIZE(mt76_channels_5ghz), rates,
@@ -385,6 +387,7 @@ mt76_init_sband_6g(struct mt76_phy *phy, struct ieee80211_rate *rates,
 		   int n_rates)
 {
 	phy->hw->wiphy->bands[NL80211_BAND_6GHZ] = &phy->sband_6g.sband;
+	phy->sband_6g.sband.band = NL80211_BAND_6GHZ;

 	return mt76_init_sband(phy, &phy->sband_6g, mt76_channels_6ghz,
 			       ARRAY_SIZE(mt76_channels_6ghz), rates,
--
2.39.2

It's "Fixes" for commits and "Closes" for bugs, ain't it?

Bert Karwatzki

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

end of thread, other threads:[~2024-02-07 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07  0:01 [PATCH] wifi: mt76: inititalize sband.band to correct value Bert Karwatzki
2024-02-07  5:46 ` Kalle Valo
2024-02-07  7:22 Bert Karwatzki
2024-02-07 10:52 ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.