Commit 8f641d93 authored by Daniel Drake's avatar Daniel Drake Committed by John W. Linville

libertas: detect TX lockups and reset hardware

Recent patches added support for resetting the SD8686 hardware when
commands time out, which seems to happen quite frequently soon after
resuming the system from a Wake-on-WLAN-triggered resume.

At http://dev.laptop.org/ticket/10969 we see the same thing happen
with transmits. In this case, the hardware will fail to respond to
a frame passed for transmission, and libertas (correctly) will block
all further commands and transmissions as the hardware can only
deal with one thing at a time. This results in a lockup while the
system waits indefinitely for the dead card to respond.

Hook up a TX lockup timer to detect this and reset the hardware.
Signed-off-by: default avatarDaniel Drake <dsd@laptop.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 8a3a3c85
...@@ -158,6 +158,7 @@ struct lbs_private { ...@@ -158,6 +158,7 @@ struct lbs_private {
/* protected by hard_start_xmit serialization */ /* protected by hard_start_xmit serialization */
u8 txretrycount; u8 txretrycount;
struct sk_buff *currenttxskb; struct sk_buff *currenttxskb;
struct timer_list tx_lockup_timer;
/* Locks */ /* Locks */
struct mutex lock; struct mutex lock;
......
...@@ -188,6 +188,7 @@ int lbs_stop_iface(struct lbs_private *priv) ...@@ -188,6 +188,7 @@ int lbs_stop_iface(struct lbs_private *priv)
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
cancel_work_sync(&priv->mcast_work); cancel_work_sync(&priv->mcast_work);
del_timer_sync(&priv->tx_lockup_timer);
/* Disable command processing, and wait for all commands to complete */ /* Disable command processing, and wait for all commands to complete */
lbs_deb_main("waiting for commands to complete\n"); lbs_deb_main("waiting for commands to complete\n");
...@@ -243,6 +244,7 @@ void lbs_host_to_card_done(struct lbs_private *priv) ...@@ -243,6 +244,7 @@ void lbs_host_to_card_done(struct lbs_private *priv)
lbs_deb_enter(LBS_DEB_THREAD); lbs_deb_enter(LBS_DEB_THREAD);
spin_lock_irqsave(&priv->driver_lock, flags); spin_lock_irqsave(&priv->driver_lock, flags);
del_timer(&priv->tx_lockup_timer);
priv->dnld_sent = DNLD_RES_RECEIVED; priv->dnld_sent = DNLD_RES_RECEIVED;
...@@ -585,6 +587,9 @@ static int lbs_thread(void *data) ...@@ -585,6 +587,9 @@ static int lbs_thread(void *data)
if (ret) { if (ret) {
lbs_deb_tx("host_to_card failed %d\n", ret); lbs_deb_tx("host_to_card failed %d\n", ret);
priv->dnld_sent = DNLD_RES_RECEIVED; priv->dnld_sent = DNLD_RES_RECEIVED;
} else {
mod_timer(&priv->tx_lockup_timer,
jiffies + (HZ * 5));
} }
priv->tx_pending_len = 0; priv->tx_pending_len = 0;
if (!priv->currenttxskb) { if (!priv->currenttxskb) {
...@@ -601,6 +606,7 @@ static int lbs_thread(void *data) ...@@ -601,6 +606,7 @@ static int lbs_thread(void *data)
} }
del_timer(&priv->command_timer); del_timer(&priv->command_timer);
del_timer(&priv->tx_lockup_timer);
del_timer(&priv->auto_deepsleep_timer); del_timer(&priv->auto_deepsleep_timer);
lbs_deb_leave(LBS_DEB_THREAD); lbs_deb_leave(LBS_DEB_THREAD);
...@@ -734,6 +740,32 @@ static void lbs_cmd_timeout_handler(unsigned long data) ...@@ -734,6 +740,32 @@ static void lbs_cmd_timeout_handler(unsigned long data)
lbs_deb_leave(LBS_DEB_CMD); lbs_deb_leave(LBS_DEB_CMD);
} }
/**
* lbs_tx_lockup_handler - handles the timeout of the passing of TX frames
* to the hardware. This is known to frequently happen with SD8686 when
* waking up after a Wake-on-WLAN-triggered resume.
*
* @data: &struct lbs_private pointer
*/
static void lbs_tx_lockup_handler(unsigned long data)
{
struct lbs_private *priv = (struct lbs_private *)data;
unsigned long flags;
lbs_deb_enter(LBS_DEB_TX);
spin_lock_irqsave(&priv->driver_lock, flags);
netdev_info(priv->dev, "TX lockup detected\n");
if (priv->reset_card)
priv->reset_card(priv);
priv->dnld_sent = DNLD_RES_RECEIVED;
wake_up_interruptible(&priv->waitq);
spin_unlock_irqrestore(&priv->driver_lock, flags);
lbs_deb_leave(LBS_DEB_TX);
}
/** /**
* auto_deepsleep_timer_fn - put the device back to deep sleep mode when * auto_deepsleep_timer_fn - put the device back to deep sleep mode when
* timer expires and no activity (command, event, data etc.) is detected. * timer expires and no activity (command, event, data etc.) is detected.
...@@ -820,6 +852,8 @@ static int lbs_init_adapter(struct lbs_private *priv) ...@@ -820,6 +852,8 @@ static int lbs_init_adapter(struct lbs_private *priv)
setup_timer(&priv->command_timer, lbs_cmd_timeout_handler, setup_timer(&priv->command_timer, lbs_cmd_timeout_handler,
(unsigned long)priv); (unsigned long)priv);
setup_timer(&priv->tx_lockup_timer, lbs_tx_lockup_handler,
(unsigned long)priv);
setup_timer(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn, setup_timer(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn,
(unsigned long)priv); (unsigned long)priv);
...@@ -857,6 +891,7 @@ static void lbs_free_adapter(struct lbs_private *priv) ...@@ -857,6 +891,7 @@ static void lbs_free_adapter(struct lbs_private *priv)
lbs_free_cmd_buffer(priv); lbs_free_cmd_buffer(priv);
kfifo_free(&priv->event_fifo); kfifo_free(&priv->event_fifo);
del_timer(&priv->command_timer); del_timer(&priv->command_timer);
del_timer(&priv->tx_lockup_timer);
del_timer(&priv->auto_deepsleep_timer); del_timer(&priv->auto_deepsleep_timer);
lbs_deb_leave(LBS_DEB_MAIN); lbs_deb_leave(LBS_DEB_MAIN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment