[PATCH] bcm43xx: Fix low-traffic netdev watchdog TX timeouts

This fixes a netdev watchdog timeout problem.
The software needs to call netif_tx_disable before running the
hardware calibration code. The problem condition can be shown by the
following timegraph.

|---5secs - ~10 jiffies time---|---|OOPS
^ ^
last real TX periodic work stops netif

At OOPS, the following happens:
The watchdog timer triggers, because the timeout of 5secs
is over. The watchdog first checks for stopped TX.
_Usually_ TX is only stopped from the TX handler to indicate
a full TX queue. But this is different. We need to stop TX here,
regardless of the TX queue state. So the watchdog recognizes
the stopped device and assumes it is stopped due to full
TX queues (Which is a _wrong_ assumption in this case). It then
tests how far the last TX has been in the past. If it's more than
5secs (which is the case for low or no traffic), it will fire
a TX timeout.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by Michael Buesch and committed by John W. Linville 81e171b9 115e222d

+15 -1
+15 -1
drivers/net/wireless/bcm43xx/bcm43xx_main.c
··· 3163 static void bcm43xx_periodic_work_handler(void *d) 3164 { 3165 struct bcm43xx_private *bcm = d; 3166 unsigned long flags; 3167 u32 savedirqs = 0; 3168 int badness; 3169 3170 mutex_lock(&bcm->mutex); 3171 badness = estimate_periodic_work_badness(bcm->periodic_state); ··· 3175 /* Periodic work will take a long time, so we want it to 3176 * be preemtible. 3177 */ 3178 - netif_tx_disable(bcm->net_dev); 3179 spin_lock_irqsave(&bcm->irq_lock, flags); 3180 bcm43xx_mac_suspend(bcm); 3181 if (bcm43xx_using_pio(bcm)) ··· 3211 bcm43xx_pio_thaw_txqueues(bcm); 3212 bcm43xx_mac_enable(bcm); 3213 netif_wake_queue(bcm->net_dev); 3214 } 3215 mmiowb(); 3216 spin_unlock_irqrestore(&bcm->irq_lock, flags);
··· 3163 static void bcm43xx_periodic_work_handler(void *d) 3164 { 3165 struct bcm43xx_private *bcm = d; 3166 + struct net_device *net_dev = bcm->net_dev; 3167 unsigned long flags; 3168 u32 savedirqs = 0; 3169 int badness; 3170 + unsigned long orig_trans_start = 0; 3171 3172 mutex_lock(&bcm->mutex); 3173 badness = estimate_periodic_work_badness(bcm->periodic_state); ··· 3173 /* Periodic work will take a long time, so we want it to 3174 * be preemtible. 3175 */ 3176 + 3177 + netif_tx_lock_bh(net_dev); 3178 + /* We must fake a started transmission here, as we are going to 3179 + * disable TX. If we wouldn't fake a TX, it would be possible to 3180 + * trigger the netdev watchdog, if the last real TX is already 3181 + * some time on the past (slightly less than 5secs) 3182 + */ 3183 + orig_trans_start = net_dev->trans_start; 3184 + net_dev->trans_start = jiffies; 3185 + netif_stop_queue(net_dev); 3186 + netif_tx_unlock_bh(net_dev); 3187 + 3188 spin_lock_irqsave(&bcm->irq_lock, flags); 3189 bcm43xx_mac_suspend(bcm); 3190 if (bcm43xx_using_pio(bcm)) ··· 3198 bcm43xx_pio_thaw_txqueues(bcm); 3199 bcm43xx_mac_enable(bcm); 3200 netif_wake_queue(bcm->net_dev); 3201 + net_dev->trans_start = orig_trans_start; 3202 } 3203 mmiowb(); 3204 spin_unlock_irqrestore(&bcm->irq_lock, flags);