ar71xx: prevent spurious ethernet resets from dma hang check false positives
[openwrt/staging/lynxis/omap.git] / target / linux / ar71xx / files / drivers / net / ethernet / atheros / ag71xx / ag71xx_main.c
index d5253609cd834c83117a9a331f9d410aa7ba962d..65bc89eb0d6ae481a6a80d88b907fa5dc47a495e 100644 (file)
@@ -453,16 +453,11 @@ static void ag71xx_hw_stop(struct ag71xx *ag)
 static void ag71xx_hw_setup(struct ag71xx *ag)
 {
        struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
-       struct ag71xx_mdio_platform_data *mpdata;
        u32 init = MAC_CFG1_INIT;
 
-       if (pdata->mii_bus_dev && ag->pdev->id == 0) {
-               mpdata = pdata->mii_bus_dev->platform_data;
-               if (mpdata && mpdata->builtin_switch)
-                   init |= MAC_CFG1_TFC | MAC_CFG1_RFC;
-       }
-
        /* setup MAC configuration registers */
+       if (pdata->builtin_switch)
+               init |= MAC_CFG1_TFC | MAC_CFG1_RFC;
        ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, init);
 
        ag71xx_sb(ag, AG71XX_REG_MAC_CFG2,
@@ -913,12 +908,12 @@ static void ag71xx_tx_timeout(struct net_device *dev)
        if (netif_msg_tx_err(ag))
                pr_info("%s: tx timeout\n", ag->dev->name);
 
-       schedule_work(&ag->restart_work);
+       schedule_delayed_work(&ag->restart_work, 1);
 }
 
 static void ag71xx_restart_work_func(struct work_struct *work)
 {
-       struct ag71xx *ag = container_of(work, struct ag71xx, restart_work);
+       struct ag71xx *ag = container_of(work, struct ag71xx, restart_work.work);
 
        rtnl_lock();
        ag71xx_hw_disable(ag);
@@ -971,7 +966,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
                if (!flush && !ag71xx_desc_empty(desc)) {
                        if (pdata->is_ar724x &&
                            ag71xx_check_dma_stuck(ag, ring->buf[i].timestamp))
-                               schedule_work(&ag->restart_work);
+                               schedule_delayed_work(&ag->restart_work, HZ / 2);
                        break;
                }
 
@@ -1007,6 +1002,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
        netdev_completed_queue(ag->dev, sent, bytes_compl);
        if ((ring->curr - ring->dirty) < (ring_size * 3) / 4)
                netif_wake_queue(ag->dev);
+       cancel_delayed_work(&ag->restart_work);
 
        return sent;
 }
@@ -1326,7 +1322,7 @@ static int ag71xx_probe(struct platform_device *pdev)
        dev->netdev_ops = &ag71xx_netdev_ops;
        dev->ethtool_ops = &ag71xx_ethtool_ops;
 
-       INIT_WORK(&ag->restart_work, ag71xx_restart_work_func);
+       INIT_DELAYED_WORK(&ag->restart_work, ag71xx_restart_work_func);
 
        init_timer(&ag->oom_timer);
        ag->oom_timer.data = (unsigned long) dev;