Skip to contentSkip to conversation

libertas: Fix interface driver unload with PS mode

PATCH In review Andrey Yurovsky 2 participants 3 messages Jun 15, 2009 – Jun 16, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libertas: Fix interface driver unload with PS mode

When IEEE PS mode is enabled, lbs_remove_card needs to exit PS mode before returning. It will then set surpriseremoved=1, which blocks any further attempts to issue commands. In the SDIO, SPI, and USB drivers, lbs_remove_card is called with surpriseremoved already set, which makes it impossible to exit PS mode. As a result, reloading the driver while PS mode is enabled does not work.

This patch removes the setting of surpriseremoved in the interface drivers and corrects the order in which lbs_stop_card and lbs_remove_card are called. Tested on SPI with V9 firmware.

---
 drivers/net/wireless/libertas/if_sdio.c |    2 --
 drivers/net/wireless/libertas/if_spi.c  |    4 ++--
 drivers/net/wireless/libertas/if_usb.c  |    1 -
 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +0 -2
index 8cdb88c..6bb95ce 100644
@@ -1096,8 +1096,6 @@ static void if_sdio_remove(struct sdio_func *func)
 			lbs_pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n");
 	}
 
-	card->priv->surpriseremoved = 1;
-
 	lbs_deb_sdio("call remove card\n");
 	lbs_stop_card(card->priv);
 	lbs_remove_card(card->priv);
drivers/net/wireless/libertas/if_spi.c +2 -2
index 923ed58..757352c 100644
@@ -1171,12 +1171,12 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
 
 	lbs_deb_spi("libertas_spi_remove\n");
 	lbs_deb_enter(LBS_DEB_SPI);
-	priv->surpriseremoved = 1;
 
 	lbs_stop_card(priv);
+	lbs_remove_card(priv); /* will call free_netdev */
+
 	free_irq(spi->irq, card);
 	if_spi_terminate_spi_thread(card);
-	lbs_remove_card(priv); /* will call free_netdev */
 	if (card->pdata->teardown)
 		card->pdata->teardown(spi);
 	free_if_spi_card(card);
drivers/net/wireless/libertas/if_usb.c +0 -1
index ea3dc03..7e03f0e 100644
@@ -357,7 +357,6 @@ static void if_usb_disconnect(struct usb_interface *intf)
 	cardp->surprise_removed = 1;
 
 	if (priv) {
-		priv->surpriseremoved = 1;
 		lbs_stop_card(priv);
 		lbs_remove_card(priv);
 	}
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 10 lines · Andrey Yurovsky

When IEEE PS mode is enabled, lbs_remove_card needs to exit PS mode before returning. It will then set surpriseremoved=1, which blocks any further attempts to issue commands. In the SDIO, SPI, and USB drivers, lbs_remove_card is called with surpriseremoved already set, which makes it impossible to exit PS mode. As a result, reloading the driver while PS mode is enabled does not work.

This patch removes the setting of surpriseremoved in the interface drivers and corrects the order in which lbs_stop_card and lbs_remove_card are called. Tested on SPI with V9 firmware.

Makes me a bit nervious; any chance you can test with usb8388 or SDIO firmware and hot-unplug or rmmod?

Dan

Quoted 51 lines
---
 drivers/net/wireless/libertas/if_sdio.c |    2 --
 drivers/net/wireless/libertas/if_spi.c  |    4 ++--
 drivers/net/wireless/libertas/if_usb.c  |    1 -
 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +0 -2
index 8cdb88c..6bb95ce 100644
@@ -1096,8 +1096,6 @@ static void if_sdio_remove(struct sdio_func *func)
 			lbs_pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n");
 	}
 
-	card->priv->surpriseremoved = 1;
-
 	lbs_deb_sdio("call remove card\n");
 	lbs_stop_card(card->priv);
 	lbs_remove_card(card->priv);
drivers/net/wireless/libertas/if_spi.c +2 -2
index 923ed58..757352c 100644
@@ -1171,12 +1171,12 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
 
 	lbs_deb_spi("libertas_spi_remove\n");
 	lbs_deb_enter(LBS_DEB_SPI);
-	priv->surpriseremoved = 1;
 
 	lbs_stop_card(priv);
+	lbs_remove_card(priv); /* will call free_netdev */
+
 	free_irq(spi->irq, card);
 	if_spi_terminate_spi_thread(card);
-	lbs_remove_card(priv); /* will call free_netdev */
 	if (card->pdata->teardown)
 		card->pdata->teardown(spi);
 	free_if_spi_card(card);
drivers/net/wireless/libertas/if_usb.c +0 -1
index ea3dc03..7e03f0e 100644
@@ -357,7 +357,6 @@ static void if_usb_disconnect(struct usb_interface *intf)
 	cardp->surprise_removed = 1;
 
 	if (priv) {
-		priv->surpriseremoved = 1;
 		lbs_stop_card(priv);
 		lbs_remove_card(priv);
 	}
#2 lore raw
Quoted 8 lines · Dan Williams
Quoted 7 lines · Andrey Yurovsky

When IEEE PS mode is enabled, lbs_remove_card needs to exit PS mode before returning.  It will then set surpriseremoved=1, which blocks any further attempts to issue commands.  In the SDIO, SPI, and USB drivers, lbs_remove_card is called with surpriseremoved already set, which makes it impossible to exit PS mode.  As a result, reloading the driver while PS mode is enabled does not work.

Quoted 6 lines
Quoted 3 lines

This patch removes the setting of surpriseremoved in the interface drivers and corrects the order in which lbs_stop_card and lbs_remove_card are called.  Tested on SPI with V9 firmware.

Makes me a bit nervious; any chance you can test with usb8388 or SDIO firmware and hot-unplug or rmmod?

I'll comment on these separately:

- For USB, we hit the case where if_usb.c doesn't like the response for CMD_802_11_FW_WAKE_METHOD and therefore decides that PS mode isn't supported even though it is. I suspect the IEEE PS would work otherwise but I haven't had a chance to try it and I don't want to cause a regression for whoever needed this wake-method check unless it's really irrelevant.
- I've tested with SDIO, however reloading the module doesn't work due to the other known issues being discussed and I don't have an '8688 to try where it might work. That said, with this patch SDIO does the right thing in turning off IEEE PS, so I should have said that it has been tested on SDIO as well. On SPI I can also say that I can then load the driver again and things work properly.

The setting of surpriseremoved=1 before calling lbs_remove_card is wrong regardless because lbs_remove_card is then unable to actually send commands.

-Andrey

Quoted 53 lines
Quoted 51 lines

---
 drivers/net/wireless/libertas/if_sdio.c |    2 -- drivers/net/wireless/libertas/if_spi.c  |    4 ++-- drivers/net/wireless/libertas/if_usb.c  |    1 -

 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +0 -2
index 8cdb88c..6bb95ce 100644
@@ -1096,8 +1096,6 @@ static void if_sdio_remove(struct sdio_func *func)
                       lbs_pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n");
       }
 
-     card->priv->surpriseremoved = 1;
-
       lbs_deb_sdio("call remove card\n");
       lbs_stop_card(card->priv);
       lbs_remove_card(card->priv);
drivers/net/wireless/libertas/if_spi.c +2 -2
index 923ed58..757352c 100644
@@ -1171,12 +1171,12 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
 
       lbs_deb_spi("libertas_spi_remove\n");
       lbs_deb_enter(LBS_DEB_SPI);
-     priv->surpriseremoved = 1;
 
       lbs_stop_card(priv);
+     lbs_remove_card(priv); /* will call free_netdev */
+
       free_irq(spi->irq, card);
       if_spi_terminate_spi_thread(card);
-     lbs_remove_card(priv); /* will call free_netdev */
       if (card->pdata->teardown)
               card->pdata->teardown(spi);
       free_if_spi_card(card);
drivers/net/wireless/libertas/if_usb.c +0 -1
index ea3dc03..7e03f0e 100644
@@ -357,7 +357,6 @@ static void if_usb_disconnect(struct usb_interface *intf)
       cardp->surprise_removed = 1;
 
       if (priv) {
-             priv->surpriseremoved = 1;
               lbs_stop_card(priv);
               lbs_remove_card(priv);
       }