aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <florian.fainelli@telecomint.eu>2007-12-12 17:01:33 -0500
committerFrancois Romieu <romieu@fr.zoreil.com>2008-02-05 17:29:15 -0500
commit106adf3c84d081776a1d1fbb8a047cad12af2bb9 (patch)
tree341e1d4acd15856f4dee1b385285ddbeefe8c043
parentb4f1255d6839bd970d5ff20a9c3d73f73c9adaa3 (diff)
r6040: recover from transmit timeout
Signed-off-by: Florian Fainelli <florian.fainelli@telecomint.eu> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
-rw-r--r--drivers/net/r6040.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 24f42d23156c..7ca6a934524f 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -61,7 +61,6 @@
61 61
62/* Time in jiffies before concluding the transmitter is hung. */ 62/* Time in jiffies before concluding the transmitter is hung. */
63#define TX_TIMEOUT (6000 * HZ / 1000) 63#define TX_TIMEOUT (6000 * HZ / 1000)
64#define TIMER_WUT (jiffies + HZ * 1)/* timer wakeup time : 1 second */
65 64
66/* RDC MAC I/O Size */ 65/* RDC MAC I/O Size */
67#define R6040_IO_SIZE 256 66#define R6040_IO_SIZE 256
@@ -266,19 +265,6 @@ static void r6040_free_rxbufs(struct net_device *dev)
266 } 265 }
267} 266}
268 267
269static void r6040_tx_timeout(struct net_device *dev)
270{
271 struct r6040_private *priv = netdev_priv(dev);
272
273 disable_irq(dev->irq);
274 napi_disable(&priv->napi);
275 spin_lock(&priv->lock);
276 dev->stats.tx_errors++;
277 spin_unlock(&priv->lock);
278
279 netif_stop_queue(dev);
280}
281
282static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring, 268static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring,
283 dma_addr_t desc_dma, int size) 269 dma_addr_t desc_dma, int size)
284{ 270{
@@ -350,6 +336,34 @@ static void r6040_alloc_rxbufs(struct net_device *dev)
350 iowrite16(lp->rx_ring_dma >> 16, ioaddr + MRD_SA1); 336 iowrite16(lp->rx_ring_dma >> 16, ioaddr + MRD_SA1);
351} 337}
352 338
339static void r6040_tx_timeout(struct net_device *dev)
340{
341 struct r6040_private *priv = netdev_priv(dev);
342 void __iomem *ioaddr = priv->base;
343
344 printk(KERN_WARNING "%s: transmit timed out, status %4.4x, PHY status "
345 "%4.4x\n",
346 dev->name, ioread16(ioaddr + MIER),
347 mdio_read(dev, priv->mii_if.phy_id, MII_BMSR));
348
349 disable_irq(dev->irq);
350 napi_disable(&priv->napi);
351 spin_lock(&priv->lock);
352 /* Clear all descriptors */
353 r6040_free_txbufs(dev);
354 r6040_free_rxbufs(dev);
355 r6040_alloc_txbufs(dev);
356 r6040_alloc_rxbufs(dev);
357
358 /* Reset MAC */
359 iowrite16(MAC_RST, ioaddr + MCR1);
360 spin_unlock(&priv->lock);
361 enable_irq(dev->irq);
362
363 dev->stats.tx_errors++;
364 netif_wake_queue(dev);
365}
366
353static struct net_device_stats *r6040_get_stats(struct net_device *dev) 367static struct net_device_stats *r6040_get_stats(struct net_device *dev)
354{ 368{
355 struct r6040_private *priv = netdev_priv(dev); 369 struct r6040_private *priv = netdev_priv(dev);
@@ -719,8 +733,7 @@ static void r6040_timer(unsigned long data)
719 } 733 }
720 734
721 /* Timer active again */ 735 /* Timer active again */
722 lp->timer.expires = TIMER_WUT; 736 mod_timer(&lp->timer, jiffies + round_jiffies(HZ));
723 add_timer(&lp->timer);
724} 737}
725 738
726/* Read/set MAC address routines */ 739/* Read/set MAC address routines */
@@ -776,14 +789,10 @@ static int r6040_open(struct net_device *dev)
776 napi_enable(&lp->napi); 789 napi_enable(&lp->napi);
777 netif_start_queue(dev); 790 netif_start_queue(dev);
778 791
779 if (lp->switch_sig != ICPLUS_PHY_ID) { 792 /* set and active a timer process */
780 /* set and active a timer process */ 793 setup_timer(&lp->timer, r6040_timer, (unsigned long) dev);
781 init_timer(&lp->timer); 794 if (lp->switch_sig != ICPLUS_PHY_ID)
782 lp->timer.expires = TIMER_WUT; 795 mod_timer(&lp->timer, jiffies + HZ);
783 lp->timer.data = (unsigned long)dev;
784 lp->timer.function = &r6040_timer;
785 add_timer(&lp->timer);
786 }
787 return 0; 796 return 0;
788} 797}
789 798