2009-06-02 11:13:20

by Johannes Berg

[permalink] [raw]
Subject: [RFT 2/3] ath9k: port to cfg80211 rfkill

This ports the ath9k rfkill code to the new API offered by
cfg80211 and thus removes a lot of useless stuff.

Signed-off-by: Johannes Berg <[email protected]>
Cc: Luis Rodriguez <[email protected]>
---
drivers/net/wireless/ath/ath9k/Kconfig | 1
drivers/net/wireless/ath/ath9k/ath9k.h | 9 ---
drivers/net/wireless/ath/ath9k/hw.c | 29 ++++------
drivers/net/wireless/ath/ath9k/hw.h | 3 -
drivers/net/wireless/ath/ath9k/main.c | 93 ++++-----------------------------
5 files changed, 26 insertions(+), 109 deletions(-)

--- wireless-testing.orig/drivers/net/wireless/ath/ath9k/Kconfig 2009-06-02 12:53:43.000000000 +0200
+++ wireless-testing/drivers/net/wireless/ath/ath9k/Kconfig 2009-06-02 12:56:10.000000000 +0200
@@ -1,7 +1,6 @@
config ATH9K
tristate "Atheros 802.11n wireless cards support"
depends on PCI && MAC80211 && WLAN_80211
- depends on RFKILL || RFKILL=n
select ATH_COMMON
select MAC80211_LEDS
select LEDS_CLASS
--- wireless-testing.orig/drivers/net/wireless/ath/ath9k/ath9k.h 2009-06-02 12:53:43.000000000 +0200
+++ wireless-testing/drivers/net/wireless/ath/ath9k/ath9k.h 2009-06-02 12:56:10.000000000 +0200
@@ -21,7 +21,6 @@
#include <linux/device.h>
#include <net/mac80211.h>
#include <linux/leds.h>
-#include <linux/rfkill.h>

#include "hw.h"
#include "rc.h"
@@ -464,12 +463,6 @@ struct ath_led {
bool registered;
};

-struct ath_rfkill {
- struct rfkill *rfkill;
- struct rfkill_ops ops;
- char rfkill_name[32];
-};
-
/********************/
/* Main driver core */
/********************/
@@ -509,7 +502,6 @@ struct ath_rfkill {
#define SC_OP_PROTECT_ENABLE BIT(6)
#define SC_OP_RXFLUSH BIT(7)
#define SC_OP_LED_ASSOCIATED BIT(8)
-#define SC_OP_RFKILL_REGISTERED BIT(9)
#define SC_OP_WAIT_FOR_BEACON BIT(12)
#define SC_OP_LED_ON BIT(13)
#define SC_OP_SCANNING BIT(14)
@@ -595,7 +587,6 @@ struct ath_softc {

int beacon_interval;

- struct ath_rfkill rf_kill;
struct ath_ani ani;
struct ath9k_node_stats nodestats;
#ifdef CONFIG_ATH9K_DEBUG
--- wireless-testing.orig/drivers/net/wireless/ath/ath9k/hw.c 2009-06-02 12:53:43.000000000 +0200
+++ wireless-testing/drivers/net/wireless/ath/ath9k/hw.c 2009-06-02 12:56:10.000000000 +0200
@@ -2186,6 +2186,18 @@ static void ath9k_hw_spur_mitigate(struc
REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask);
}

+static void ath9k_enable_rfkill(struct ath_hw *ah)
+{
+ REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
+ AR_GPIO_INPUT_EN_VAL_RFSILENT_BB);
+
+ REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2,
+ AR_GPIO_INPUT_MUX2_RFSILENT);
+
+ ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio);
+ REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB);
+}
+
int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
bool bChannelChange)
{
@@ -2313,10 +2325,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
ath9k_hw_init_interrupt_masks(ah, ah->opmode);
ath9k_hw_init_qos(ah);

-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
ath9k_enable_rfkill(ah);
-#endif
+
ath9k_hw_init_user_settings(ah);

REG_WRITE(ah, AR_STA_ID1,
@@ -3613,20 +3624,6 @@ void ath9k_hw_set_gpio(struct ath_hw *ah
AR_GPIO_BIT(gpio));
}

-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
-void ath9k_enable_rfkill(struct ath_hw *ah)
-{
- REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL,
- AR_GPIO_INPUT_EN_VAL_RFSILENT_BB);
-
- REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2,
- AR_GPIO_INPUT_MUX2_RFSILENT);
-
- ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio);
- REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB);
-}
-#endif
-
u32 ath9k_hw_getdefantenna(struct ath_hw *ah)
{
return REG_READ(ah, AR_DEF_ANTENNA) & 0x7;
--- wireless-testing.orig/drivers/net/wireless/ath/ath9k/hw.h 2009-06-02 12:53:43.000000000 +0200
+++ wireless-testing/drivers/net/wireless/ath/ath9k/hw.h 2009-06-02 12:56:10.000000000 +0200
@@ -565,9 +565,6 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah,
void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio,
u32 ah_signal_type);
void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val);
-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
-void ath9k_enable_rfkill(struct ath_hw *ah);
-#endif
u32 ath9k_hw_getdefantenna(struct ath_hw *ah);
void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna);
bool ath9k_hw_setantennaswitch(struct ath_hw *ah,
--- wireless-testing.orig/drivers/net/wireless/ath/ath9k/main.c 2009-06-02 12:53:43.000000000 +0200
+++ wireless-testing/drivers/net/wireless/ath/ath9k/main.c 2009-06-02 12:56:10.000000000 +0200
@@ -1178,8 +1178,6 @@ void ath_radio_disable(struct ath_softc
ath9k_ps_restore(sc);
}

-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
-
/*******************/
/* Rfkill */
/*******************/
@@ -1192,81 +1190,27 @@ static bool ath_is_rfkill_set(struct ath
ah->rfkill_polarity;
}

-/* s/w rfkill handlers */
-static int ath_rfkill_set_block(void *data, bool blocked)
-{
- struct ath_softc *sc = data;
-
- if (blocked)
- ath_radio_disable(sc);
- else
- ath_radio_enable(sc);
-
- return 0;
-}
-
-static void ath_rfkill_poll_state(struct rfkill *rfkill, void *data)
+static void ath9k_rfkill_poll_state(struct ieee80211_hw *hw)
{
- struct ath_softc *sc = data;
+ struct ath_wiphy *aphy = hw->priv;
+ struct ath_softc *sc = aphy->sc;
bool blocked = !!ath_is_rfkill_set(sc);

- if (rfkill_set_hw_state(rfkill, blocked))
+ wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
+
+ if (blocked)
ath_radio_disable(sc);
else
ath_radio_enable(sc);
}

-/* Init s/w rfkill */
-static int ath_init_sw_rfkill(struct ath_softc *sc)
+static void ath_start_rfkill_poll(struct ath_softc *sc)
{
- sc->rf_kill.ops.set_block = ath_rfkill_set_block;
- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
- sc->rf_kill.ops.poll = ath_rfkill_poll_state;
-
- snprintf(sc->rf_kill.rfkill_name, sizeof(sc->rf_kill.rfkill_name),
- "ath9k-%s::rfkill", wiphy_name(sc->hw->wiphy));
-
- sc->rf_kill.rfkill = rfkill_alloc(sc->rf_kill.rfkill_name,
- wiphy_dev(sc->hw->wiphy),
- RFKILL_TYPE_WLAN,
- &sc->rf_kill.ops, sc);
- if (!sc->rf_kill.rfkill) {
- DPRINTF(sc, ATH_DBG_FATAL, "Failed to allocate rfkill\n");
- return -ENOMEM;
- }
-
- return 0;
-}
-
-/* Deinitialize rfkill */
-static void ath_deinit_rfkill(struct ath_softc *sc)
-{
- if (sc->sc_flags & SC_OP_RFKILL_REGISTERED) {
- rfkill_unregister(sc->rf_kill.rfkill);
- rfkill_destroy(sc->rf_kill.rfkill);
- sc->sc_flags &= ~SC_OP_RFKILL_REGISTERED;
- }
-}
-
-static int ath_start_rfkill_poll(struct ath_softc *sc)
-{
- if (!(sc->sc_flags & SC_OP_RFKILL_REGISTERED)) {
- if (rfkill_register(sc->rf_kill.rfkill)) {
- DPRINTF(sc, ATH_DBG_FATAL,
- "Unable to register rfkill\n");
- rfkill_destroy(sc->rf_kill.rfkill);
-
- /* Deinitialize the device */
- ath_cleanup(sc);
- return -EIO;
- } else {
- sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
- }
- }
+ struct ath_hw *ah = sc->sc_ah;

- return 0;
+ if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
+ wiphy_rfkill_start_polling(sc->hw->wiphy);
}
-#endif /* CONFIG_RFKILL */

void ath_cleanup(struct ath_softc *sc)
{
@@ -1286,9 +1230,6 @@ void ath_detach(struct ath_softc *sc)

DPRINTF(sc, ATH_DBG_CONFIG, "Detach ATH hw\n");

-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
- ath_deinit_rfkill(sc);
-#endif
ath_deinit_leds(sc);
cancel_work_sync(&sc->chan_work);
cancel_delayed_work_sync(&sc->wiphy_work);
@@ -1626,13 +1567,6 @@ int ath_attach(u16 devid, struct ath_sof
if (error != 0)
goto error_attach;

-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
- /* Initialize s/w rfkill */
- error = ath_init_sw_rfkill(sc);
- if (error)
- goto error_attach;
-#endif
-
INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work);
INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work);
sc->wiphy_scheduler_int = msecs_to_jiffies(500);
@@ -2018,9 +1952,7 @@ static int ath9k_start(struct ieee80211_

ieee80211_wake_queues(hw);

-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
- r = ath_start_rfkill_poll(sc);
-#endif
+ ath_start_rfkill_poll(sc);

mutex_unlock:
mutex_unlock(&sc->mutex);
@@ -2159,7 +2091,7 @@ static void ath9k_stop(struct ieee80211_
} else
sc->rx.rxlink = NULL;

- rfkill_pause_polling(sc->rf_kill.rfkill);
+ wiphy_rfkill_stop_polling(sc->hw->wiphy);

/* disable HAL and put h/w to sleep */
ath9k_hw_disable(sc->sc_ah);
@@ -2765,6 +2697,7 @@ struct ieee80211_ops ath9k_ops = {
.ampdu_action = ath9k_ampdu_action,
.sw_scan_start = ath9k_sw_scan_start,
.sw_scan_complete = ath9k_sw_scan_complete,
+ .rfkill_poll = ath9k_rfkill_poll_state,
};

static struct {

--



Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Thu, Jun 11, 2009 at 04:09:55PM +0530, Vasanth Thiagarajan wrote:
> On Thu, Jun 11, 2009 at 03:40:03PM +0530, Johannes Berg wrote:
> >
> > But that's undesirable, especially if for some reason we already know
> > it's in rfkill, we really want to know about the rfkill state even when
> > the interface is down so userspace can properly react to it and not even
> > give the user the option of bringing the interfaces up.
> >
> > Hence my suggestion of moving the start_polling().
>
> I agree, will move it to ath9k_start().
>
sorry, to ath_attach();

Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Thu, Jun 11, 2009 at 03:27:41PM +0530, Johannes Berg wrote:
>
> Well, the thing is that currently ath_start_rfkill_poll() will never be
> called until you try bringing the interface up, afaict?

right.

Vasanth

Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Wed, Jun 10, 2009 at 06:50:16PM +0530, Vasanth Thiagarajan wrote:
> On Tue, Jun 02, 2009 at 04:40:29PM +0530, Johannes Berg wrote:
> > This ports the ath9k rfkill code to the new API offered by
> > cfg80211 and thus removes a lot of useless stuff.
> >
>
> I get the following lockdep warning few times when tried to scan
> after rfkill on/off. One more issue is, when rfkill is enabled before
> reboot, I could not bring up the interface when the rfkill is turned
> off after reboot. Apart from this it looks good, fixes a panic which
> used to happen during module unload.
>
> [ 757.714466] [<c015e17e>] __lock_acquire+0xece/0x1780
> [ 757.714473] [<c015eb10>] lock_acquire+0xe0/0x110
> [ 757.714477] [<c03bac0e>] mutex_lock_nested+0x5e/0x360
> [ 757.714484] [<c0307824>] rtnl_lock+0x14/0x20
> [ 757.714488] [<fbfc99cd>] 0xfbfc99cd
> [ 757.714501] [<f9d2d975>] rfkill_set_block+0x65/0xd0
> [rfkill]
> [ 757.714509] [<f9d2dcd4>] rfkill_epo+0x44/0xa0 [rfkill]
> [ 757.714515] [<f9d2e7ed>] rfkill_op_handler+0x5d/0x1c0
> [rfkill]
> [ 757.714522] [<c01459b0>] worker_thread+0x1c0/0x2f0
> [ 757.714528] [<c0149deb>] kthread+0x4b/0x80
> [ 757.714532] [<c01045e3>] kernel_thread_helper+0x7/0x10
> [ 757.714538] [<ffffffff>] 0xffffffff
> [ 757.714545]
> [ 757.714545] -> #1 (rfkill_global_mutex){+.+.+.}:
> [ 757.714550] [<c015e17e>] __lock_acquire+0xece/0x1780
> [ 757.714555] [<c015eb10>] lock_acquire+0xe0/0x110
> [ 757.714559] [<c03bac0e>] mutex_lock_nested+0x5e/0x360
> [ 757.714564] [<f9d2e3c4>] rfkill_register+0x24/0x270
> [rfkill]
> [ 757.714572] [<f89526e1>] wiphy_register+0x181/0x230
> [cfg80211]
> [ 757.714579] [<f8a05376>] ieee80211_register_hw+0x136/0x4d0
> [mac80211]
> [ 757.714593] [<f8a6b02c>] ath_attach+0x74c/0xa20 [ath9k]
> [ 757.714605] [<f8a7300c>] ath_pci_probe+0x12c/0x2e0 [ath9k]
> [ 757.714614] [<c02650c3>] local_pci_probe+0x13/0x20
> [ 757.714620] [<c0265f78>] pci_device_probe+0x68/0x90
> [ 757.714625] [<c02ce131>] driver_probe_device+0x71/0x170
> [ 757.714631] [<c02ce2b9>] __driver_attach+0x89/0xa0
> [ 757.714635] [<c02cd9bb>] bus_for_each_dev+0x5b/0x80
> [ 757.714639] [<c02cdfde>] driver_attach+0x1e/0x20
> [ 757.714644] [<c02cd2f7>] bus_add_driver+0x237/0x2f0
> [ 757.714648] [<c02ce59a>] driver_register+0x7a/0x150
> [ 757.714652] [<c02663d3>] __pci_register_driver+0x53/0xc0
> [ 757.714657] [<f8a731dc>] ath_pci_init+0x1c/0x20 [ath9k]
> [ 757.714666] [<f88c0022>] 0xf88c0022
> [ 757.714678] [<c010112b>] do_one_initcall+0x2b/0x1c0
> [ 757.714682] [<c0167c2a>] sys_init_module+0x8a/0x1d0
> [ 757.714687] [<c0103b08>] sysenter_do_call+0x12/0x3c
> [ 757.714691] [<ffffffff>] 0xffffffff
> [ 757.714709]


I was doing load/unload along with rf on/off and scan.

2009-06-10 15:32:17

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Wed, 2009-06-10 at 18:50 +0530, Vasanthakumar Thiagarajan wrote:
> On Tue, Jun 02, 2009 at 04:40:29PM +0530, Johannes Berg wrote:
> > This ports the ath9k rfkill code to the new API offered by
> > cfg80211 and thus removes a lot of useless stuff.
> >
>
> I get the following lockdep warning few times when tried to scan
> after rfkill on/off.

Thanks, will fix, this doesn't seem to be ath9k specific. It's the
dreaded locking in rfkill. I can work around it easily in cfg80211, or
fix rfkill, will see what's easier.

> One more issue is, when rfkill is enabled before
> reboot, I could not bring up the interface when the rfkill is turned
> off after reboot.

Sounds like the driver doesn't initialise properly. Hmm, maybe we just
need to move ath_start_rfkill_poll() to ath_attach(), could you please
try that?

> Apart from this it looks good, fixes a panic which
> used to happen during module unload.

Heh.

Thanks,
johannes


Attachments:
signature.asc (801.00 B)
This is a digitally signed message part
Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Tue, Jun 02, 2009 at 04:40:29PM +0530, Johannes Berg wrote:
> This ports the ath9k rfkill code to the new API offered by
> cfg80211 and thus removes a lot of useless stuff.
>

I get the following lockdep warning few times when tried to scan
after rfkill on/off. One more issue is, when rfkill is enabled before
reboot, I could not bring up the interface when the rfkill is turned
off after reboot. Apart from this it looks good, fixes a panic which
used to happen during module unload.

757.714408]
[ 757.714410]
=======================================================
[ 757.714414] [ INFO: possible circular locking dependency detected
]
[ 757.714418] 2.6.30-rc8-wl #87
[ 757.714420]
-------------------------------------------------------
[ 757.714423] iwlist/3121 is trying to acquire lock:
[ 757.714425] (cfg80211_mutex){+.+.+.}, at: [<f8952c1d>]
cfg80211_get_dev_from_ifindex+0x1d/0x80 [cfg80211]
[ 757.714439]
[ 757.714440] but task is already holding lock:
[ 757.714443] (rtnl_mutex){+.+.+.}, at: [<c0307824>]
rtnl_lock+0x14/0x20
[ 757.714453]
[ 757.714453] which lock already depends on the new lock.
[ 757.714454]
[ 757.714457]
[ 757.714457] the existing dependency chain (in reverse order) is:
[ 757.714460]
[ 757.714461] -> #2 (rtnl_mutex){+.+.+.}:
[ 757.714466] [<c015e17e>] __lock_acquire+0xece/0x1780
[ 757.714473] [<c015eb10>] lock_acquire+0xe0/0x110
[ 757.714477] [<c03bac0e>] mutex_lock_nested+0x5e/0x360
[ 757.714484] [<c0307824>] rtnl_lock+0x14/0x20
[ 757.714488] [<fbfc99cd>] 0xfbfc99cd
[ 757.714501] [<f9d2d975>] rfkill_set_block+0x65/0xd0
[rfkill]
[ 757.714509] [<f9d2dcd4>] rfkill_epo+0x44/0xa0 [rfkill]
[ 757.714515] [<f9d2e7ed>] rfkill_op_handler+0x5d/0x1c0
[rfkill]
[ 757.714522] [<c01459b0>] worker_thread+0x1c0/0x2f0
[ 757.714528] [<c0149deb>] kthread+0x4b/0x80
[ 757.714532] [<c01045e3>] kernel_thread_helper+0x7/0x10
[ 757.714538] [<ffffffff>] 0xffffffff
[ 757.714545]
[ 757.714545] -> #1 (rfkill_global_mutex){+.+.+.}:
[ 757.714550] [<c015e17e>] __lock_acquire+0xece/0x1780
[ 757.714555] [<c015eb10>] lock_acquire+0xe0/0x110
[ 757.714559] [<c03bac0e>] mutex_lock_nested+0x5e/0x360
[ 757.714564] [<f9d2e3c4>] rfkill_register+0x24/0x270
[rfkill]
[ 757.714572] [<f89526e1>] wiphy_register+0x181/0x230
[cfg80211]
[ 757.714579] [<f8a05376>] ieee80211_register_hw+0x136/0x4d0
[mac80211]
[ 757.714593] [<f8a6b02c>] ath_attach+0x74c/0xa20 [ath9k]
[ 757.714605] [<f8a7300c>] ath_pci_probe+0x12c/0x2e0 [ath9k]
[ 757.714614] [<c02650c3>] local_pci_probe+0x13/0x20
[ 757.714620] [<c0265f78>] pci_device_probe+0x68/0x90
[ 757.714625] [<c02ce131>] driver_probe_device+0x71/0x170
[ 757.714631] [<c02ce2b9>] __driver_attach+0x89/0xa0
[ 757.714635] [<c02cd9bb>] bus_for_each_dev+0x5b/0x80
[ 757.714639] [<c02cdfde>] driver_attach+0x1e/0x20
[ 757.714644] [<c02cd2f7>] bus_add_driver+0x237/0x2f0
[ 757.714648] [<c02ce59a>] driver_register+0x7a/0x150
[ 757.714652] [<c02663d3>] __pci_register_driver+0x53/0xc0
[ 757.714657] [<f8a731dc>] ath_pci_init+0x1c/0x20 [ath9k]
[ 757.714666] [<f88c0022>] 0xf88c0022
[ 757.714678] [<c010112b>] do_one_initcall+0x2b/0x1c0
[ 757.714682] [<c0167c2a>] sys_init_module+0x8a/0x1d0
[ 757.714687] [<c0103b08>] sysenter_do_call+0x12/0x3c
[ 757.714691] [<ffffffff>] 0xffffffff
[ 757.714709]
[ 757.714710] -> #0 (cfg80211_mutex){+.+.+.}:
[ 757.714715] [<c015e2b3>] __lock_acquire+0x1003/0x1780
[ 757.714720] [<c015eb10>] lock_acquire+0xe0/0x110
[ 757.714724] [<c03bac0e>] mutex_lock_nested+0x5e/0x360
[ 757.714729] [<f8952c1d>]
cfg80211_get_dev_from_ifindex+0x1d/0x80 [cfg80211]
[ 757.714737] [<f8956053>] cfg80211_wext_siwscan+0x43/0x210
[cfg80211]
[ 757.714746] [<c03a32a1>] ioctl_standard_call+0x1a1/0x3a0
[ 757.714751] [<c03a2daf>] wext_handle_ioctl+0x14f/0x220
[ 757.714756] [<c02ff325>] dev_ioctl+0x485/0x560
[ 757.714760] [<c02ec105>] sock_ioctl+0xf5/0x270
[ 757.714765] [<c01d22dd>] vfs_ioctl+0x2d/0x90
[ 757.714771] [<c01d23ba>] do_vfs_ioctl+0x7a/0x590
[ 757.714775] [<c01d293b>] sys_ioctl+0x6b/0x70
[ 757.714779] [<c0103b08>] sysenter_do_call+0x12/0x3c
[ 757.714784] [<ffffffff>] 0xffffffff
[ 757.714795]
[ 757.714796] other info that might help us debug this:
[ 757.714797]
[ 757.714799] 1 lock held by iwlist/3121:
[ 757.714802] #0: (rtnl_mutex){+.+.+.}, at: [<c0307824>]
rtnl_lock+0x14/0x20
[ 757.714809]
[ 757.714810] stack backtrace:
[ 757.714813] Pid: 3121, comm: iwlist Not tainted 2.6.30-rc8-wl #87
[ 757.714816] Call Trace:
[ 757.714820] [<c03b8f7f>] ? printk+0x1d/0x26
[ 757.714825] [<c015cddc>] print_circular_bug_tail+0xbc/0xc0
[ 757.714829] [<c015cb1b>] ? print_circular_bug_entry+0x4b/0x50
[ 757.714834] [<c015e2b3>] __lock_acquire+0x1003/0x1780
[ 757.714839] [<c015d3fd>] ? __lock_acquire+0x14d/0x1780
[ 757.714848] [<f8952c1d>] ?
cfg80211_get_dev_from_ifindex+0x1d/0x80 [cfg80211]
[ 757.714852] [<c015eb10>] lock_acquire+0xe0/0x110
[ 757.714859] [<f8952c1d>] ?
cfg80211_get_dev_from_ifindex+0x1d/0x80 [cfg80211]
[ 757.714867] [<f8952c1d>] ?
cfg80211_get_dev_from_ifindex+0x1d/0x80 [cfg80211]
[ 757.714871] [<c03bac0e>] mutex_lock_nested+0x5e/0x360
[ 757.714878] [<f8952c1d>] ?
cfg80211_get_dev_from_ifindex+0x1d/0x80 [cfg80211]
[ 757.714883] [<c015c282>] ? mark_held_locks+0x62/0x80
[ 757.714888] [<c01bf89c>] ? __kmalloc+0x9c/0x250
[ 757.714895] [<f8952c1d>] cfg80211_get_dev_from_ifindex+0x1d/0x80
[cfg80211]
[ 757.714903] [<f8956053>] cfg80211_wext_siwscan+0x43/0x210
[cfg80211]
[ 757.714907] [<c03a326b>] ? ioctl_standard_call+0x16b/0x3a0
[ 757.714912] [<c03a326b>] ? ioctl_standard_call+0x16b/0x3a0
[ 757.714916] [<c03a32a1>] ioctl_standard_call+0x1a1/0x3a0
[ 757.714920] [<c0307824>] ? rtnl_lock+0x14/0x20
[ 757.714926] [<c02fa905>] ? __dev_get_by_name+0x85/0xb0
[ 757.714930] [<c03a2daf>] wext_handle_ioctl+0x14f/0x220
[ 757.714938] [<f8956010>] ? cfg80211_wext_siwscan+0x0/0x210
[cfg80211]
[ 757.714942] [<c02ff325>] dev_ioctl+0x485/0x560
[ 757.714947] [<c02ec010>] ? sock_ioctl+0x0/0x270
[ 757.714951] [<c02ec105>] sock_ioctl+0xf5/0x270
[ 757.714955] [<c02ec010>] ? sock_ioctl+0x0/0x270
[ 757.714959] [<c01d22dd>] vfs_ioctl+0x2d/0x90
[ 757.714964] [<c01d23ba>] do_vfs_ioctl+0x7a/0x590
[ 757.714969] [<c01abf26>] ? handle_mm_fault+0x126/0x740
[ 757.714975] [<c0120bce>] ? do_page_fault+0x17e/0x2c0
[ 757.714980] [<c02555fc>] ? trace_hardirqs_off_thunk+0xc/0x10
[ 757.714984] [<c02555ec>] ? trace_hardirqs_on_thunk+0xc/0x10
[ 757.714989] [<c014e8bb>] ? up_read+0x1b/0x30
[ 757.714993] [<c0103b41>] ? sysenter_exit+0xf/0x1a
[ 757.714997] [<c01d293b>] sys_ioctl+0x6b/0x70
[ 757.715001] [<c0103b08>] sysenter_do_call+0x12/0x3c
[ 757.715011] phy0: device no longer idle - scanning
[ 758.876667] wlan0: dropped data frame to not associated station
00:00:00:00:00:00
[ 763.813869] phy0: device now idle



Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Thu, Jun 11, 2009 at 03:40:03PM +0530, Johannes Berg wrote:
>
> But that's undesirable, especially if for some reason we already know
> it's in rfkill, we really want to know about the rfkill state even when
> the interface is down so userspace can properly react to it and not even
> give the user the option of bringing the interfaces up.
>
> Hence my suggestion of moving the start_polling().

I agree, will move it to ath9k_start().


Vasanth

Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Wed, Jun 10, 2009 at 08:08:32PM +0530, Johannes Berg wrote:
>
> Thanks, will fix, this doesn't seem to be ath9k specific. It's the
> dreaded locking in rfkill. I can work around it easily in cfg80211, or
> fix rfkill, will see what's easier.

Thanks.
>
> > One more issue is, when rfkill is enabled before
> > reboot, I could not bring up the interface when the rfkill is turned
> > off after reboot.
>
> Sounds like the driver doesn't initialise properly.

I dont think this one is driver specific as this happens
only when module is loaded at boot time. I works fine after ath9k
is reloaded.

> need to move ath_start_rfkill_poll() to ath_attach(), could you please
> try that?

We do hw reset during radio enable/disable, this needs current
channel to be configured but i'm not sure if we need to do all these
during attach time.

Thanks,

Vasanth


2009-06-11 10:09:21

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Thu, 2009-06-11 at 15:29 +0530, Vasanthakumar Thiagarajan wrote:
> On Thu, Jun 11, 2009 at 03:27:41PM +0530, Johannes Berg wrote:
> >
> > Well, the thing is that currently ath_start_rfkill_poll() will never be
> > called until you try bringing the interface up, afaict?
>
> right.

But that's undesirable, especially if for some reason we already know
it's in rfkill, we really want to know about the rfkill state even when
the interface is down so userspace can properly react to it and not even
give the user the option of bringing the interfaces up.

Hence my suggestion of moving the start_polling().

johannes


Attachments:
signature.asc (801.00 B)
This is a digitally signed message part

2009-06-11 09:57:03

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFT 2/3] ath9k: port to cfg80211 rfkill

On Thu, 2009-06-11 at 12:22 +0530, Vasanthakumar Thiagarajan wrote:

> > > One more issue is, when rfkill is enabled before
> > > reboot, I could not bring up the interface when the rfkill is turned
> > > off after reboot.
> >
> > Sounds like the driver doesn't initialise properly.
>
> I dont think this one is driver specific as this happens
> only when module is loaded at boot time. I works fine after ath9k
> is reloaded.

That's strange. I don't see anything in the core that would behave
differently between those two paths.

> > need to move ath_start_rfkill_poll() to ath_attach(), could you please
> > try that?
>
> We do hw reset during radio enable/disable, this needs current
> channel to be configured but i'm not sure if we need to do all these
> during attach time.

Well, the thing is that currently ath_start_rfkill_poll() will never be
called until you try bringing the interface up, afaict?

johannes


Attachments:
signature.asc (801.00 B)
This is a digitally signed message part