linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath9k: fix channel flag / regd issues with multiple cards
@ 2010-09-30 23:06 Felix Fietkau
  2010-09-30 23:37 ` Felix Fietkau
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Fietkau @ 2010-09-30 23:06 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luis R. Rodriguez, John W. Linville

Since the regulatory code touches the channel array, it needs to be
copied for each device instance. That way the original channel array
can also be made const.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Cc: stable@kernel.org [all]
---
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -57,7 +57,7 @@ MODULE_PARM_DESC(blink, "Enable LED blin
  * on 5 MHz steps, we support the channels which we know
  * we have calibration data for all cards though to make
  * this static */
-static struct ieee80211_channel ath9k_2ghz_chantable[] = {
+static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
 	CHAN2G(2412, 0), /* Channel 1 */
 	CHAN2G(2417, 1), /* Channel 2 */
 	CHAN2G(2422, 2), /* Channel 3 */
@@ -78,7 +78,7 @@ static struct ieee80211_channel ath9k_2g
  * on 5 MHz steps, we support the channels which we know
  * we have calibration data for all cards though to make
  * this static */
-static struct ieee80211_channel ath9k_5ghz_chantable[] = {
+static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
 	/* _We_ call this UNII 1 */
 	CHAN5G(5180, 14), /* Channel 36 */
 	CHAN5G(5200, 15), /* Channel 40 */
@@ -478,10 +478,17 @@ err:
 	return -EIO;
 }
 
-static void ath9k_init_channels_rates(struct ath_softc *sc)
+static int ath9k_init_channels_rates(struct ath_softc *sc)
 {
+	void *channels;
+
 	if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) {
-		sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
+		channels = kmemdup(ath9k_2ghz_chantable,
+			sizeof(ath9k_2ghz_chantable), GFP_KERNEL);
+		if (!channels)
+		    return -ENOMEM;
+
+		sc->sbands[IEEE80211_BAND_2GHZ].channels = channels;
 		sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
 		sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
 			ARRAY_SIZE(ath9k_2ghz_chantable);
@@ -491,7 +498,15 @@ static void ath9k_init_channels_rates(st
 	}
 
 	if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
-		sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable;
+		channels = kmemdup(ath9k_5ghz_chantable,
+			sizeof(ath9k_5ghz_chantable), GFP_KERNEL);
+		if (!channels) {
+			if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
+				kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
+			return -ENOMEM;
+		}
+
+		sc->sbands[IEEE80211_BAND_5GHZ].channels = channels;
 		sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
 		sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
 			ARRAY_SIZE(ath9k_5ghz_chantable);
@@ -500,6 +515,7 @@ static void ath9k_init_channels_rates(st
 		sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
 			ARRAY_SIZE(ath9k_legacy_rates) - 4;
 	}
+	return 0;
 }
 
 static void ath9k_init_misc(struct ath_softc *sc)
@@ -602,8 +618,11 @@ static int ath9k_init_softc(u16 devid, s
 	if (ret)
 		goto err_btcoex;
 
+	ret = ath9k_init_channels_rates(sc);
+	if (ret)
+		goto err_btcoex;
+
 	ath9k_init_crypto(sc);
-	ath9k_init_channels_rates(sc);
 	ath9k_init_misc(sc);
 
 	return 0;
@@ -784,6 +803,12 @@ static void ath9k_deinit_softc(struct at
 {
 	int i = 0;
 
+	if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
+		kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
+
+	if (sc->sbands[IEEE80211_BAND_5GHZ].channels)
+		kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels);
+
         if ((sc->btcoex.no_stomp_timer) &&
 	    sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
 		ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer);

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

* Re: [PATCH] ath9k: fix channel flag / regd issues with multiple cards
  2010-09-30 23:06 [PATCH] ath9k: fix channel flag / regd issues with multiple cards Felix Fietkau
@ 2010-09-30 23:37 ` Felix Fietkau
  2010-10-01 14:51   ` Felix Fietkau
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Fietkau @ 2010-09-30 23:37 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luis R. Rodriguez, John W. Linville

On 2010-10-01 1:06 AM, Felix Fietkau wrote:
> Since the regulatory code touches the channel array, it needs to be
> copied for each device instance. That way the original channel array
> can also be made const.
> 
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> Cc: stable@kernel.org [all]
Hmm, don't merge this one just yet. Seems that this may not be the cause
for the weird multi-card regd issues after all, since the code looks
like that part should be properly locked, even for multiple wiphys
sharing the same channel list.

- Felix

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

* Re: [PATCH] ath9k: fix channel flag / regd issues with multiple cards
  2010-09-30 23:37 ` Felix Fietkau
@ 2010-10-01 14:51   ` Felix Fietkau
  0 siblings, 0 replies; 3+ messages in thread
From: Felix Fietkau @ 2010-10-01 14:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: Luis R. Rodriguez, John W. Linville

On 2010-10-01 1:37 AM, Felix Fietkau wrote:
> On 2010-10-01 1:06 AM, Felix Fietkau wrote:
>> Since the regulatory code touches the channel array, it needs to be
>> copied for each device instance. That way the original channel array
>> can also be made const.
>> 
>> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
>> Cc: stable@kernel.org [all]
> Hmm, don't merge this one just yet. Seems that this may not be the cause
> for the weird multi-card regd issues after all, since the code looks
> like that part should be properly locked, even for multiple wiphys
> sharing the same channel list.
I got user confirmation that this patch does indeed help with this
issue. I think we should merge this patch until we figure out why
sharing the channel list over multiple devices causes these issues.
Without this patch, the channel flags can get messed up in a way that
breaks regulatory compliance.

- Felix

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

end of thread, other threads:[~2010-10-01 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-30 23:06 [PATCH] ath9k: fix channel flag / regd issues with multiple cards Felix Fietkau
2010-09-30 23:37 ` Felix Fietkau
2010-10-01 14:51   ` Felix Fietkau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).