e1000e: Reduce boot time by tightening sleep ranges
[linux-2.6-microblaze.git] / drivers / net / ethernet / intel / e1000e / netdev.c
index 0e09bed..f6f73d5 100644 (file)
@@ -3208,7 +3208,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
        if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
                ew32(RCTL, rctl & ~E1000_RCTL_EN);
        e1e_flush();
-       usleep_range(10000, 20000);
+       usleep_range(10000, 11000);
 
        if (adapter->flags2 & FLAG2_DMA_BURST) {
                /* set the writeback threshold (only takes effect if the RDTR
@@ -4046,12 +4046,12 @@ void e1000e_reset(struct e1000_adapter *adapter)
        case e1000_pch_lpt:
        case e1000_pch_spt:
        case e1000_pch_cnp:
-               fc->refresh_time = 0x0400;
+               fc->refresh_time = 0xFFFF;
+               fc->pause_time = 0xFFFF;
 
                if (adapter->netdev->mtu <= ETH_DATA_LEN) {
                        fc->high_water = 0x05C20;
                        fc->low_water = 0x05048;
-                       fc->pause_time = 0x0650;
                        break;
                }
 
@@ -4208,7 +4208,7 @@ void e1000e_up(struct e1000_adapter *adapter)
                e1000_configure_msix(adapter);
        e1000_irq_enable(adapter);
 
-       netif_start_queue(adapter->netdev);
+       /* Tx queue started by watchdog timer when link is up */
 
        e1000e_trigger_lsc(adapter);
 }
@@ -4272,7 +4272,7 @@ void e1000e_down(struct e1000_adapter *adapter, bool reset)
 
        /* flush both disables and wait for them to finish */
        e1e_flush();
-       usleep_range(10000, 20000);
+       usleep_range(10000, 11000);
 
        e1000_irq_disable(adapter);
 
@@ -4310,7 +4310,7 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)
 {
        might_sleep();
        while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
-               usleep_range(1000, 2000);
+               usleep_range(1000, 1100);
        e1000e_down(adapter, true);
        e1000e_up(adapter);
        clear_bit(__E1000_RESETTING, &adapter->state);
@@ -4606,6 +4606,7 @@ int e1000e_open(struct net_device *netdev)
        pm_runtime_get_sync(&pdev->dev);
 
        netif_carrier_off(netdev);
+       netif_stop_queue(netdev);
 
        /* allocate transmit descriptors */
        err = e1000e_setup_tx_resources(adapter->tx_ring);
@@ -4666,7 +4667,6 @@ int e1000e_open(struct net_device *netdev)
        e1000_irq_enable(adapter);
 
        adapter->tx_hang_recheck = false;
-       netif_start_queue(netdev);
 
        hw->mac.get_link_status = true;
        pm_runtime_put(&pdev->dev);
@@ -4707,7 +4707,7 @@ int e1000e_close(struct net_device *netdev)
        int count = E1000_CHECK_RESET_COUNT;
 
        while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
-               usleep_range(10000, 20000);
+               usleep_range(10000, 11000);
 
        WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
 
@@ -5288,6 +5288,7 @@ static void e1000_watchdog_task(struct work_struct *work)
                        if (phy->ops.cfg_on_link_up)
                                phy->ops.cfg_on_link_up(hw);
 
+                       netif_wake_queue(netdev);
                        netif_carrier_on(netdev);
 
                        if (!test_bit(__E1000_DOWN, &adapter->state))
@@ -5301,6 +5302,7 @@ static void e1000_watchdog_task(struct work_struct *work)
                        /* Link status message must follow this format */
                        pr_info("%s NIC Link is Down\n", adapter->netdev->name);
                        netif_carrier_off(netdev);
+                       netif_stop_queue(netdev);
                        if (!test_bit(__E1000_DOWN, &adapter->state))
                                mod_timer(&adapter->phy_info_timer,
                                          round_jiffies(jiffies + 2 * HZ));
@@ -5308,13 +5310,8 @@ static void e1000_watchdog_task(struct work_struct *work)
                        /* 8000ES2LAN requires a Rx packet buffer work-around
                         * on link down event; reset the controller to flush
                         * the Rx packet buffer.
-                        *
-                        * If the link is lost the controller stops DMA, but
-                        * if there is queued Tx work it cannot be done.  So
-                        * reset the controller to flush the Tx packet buffers.
                         */
-                       if ((adapter->flags & FLAG_RX_NEEDS_RESTART) ||
-                           e1000_desc_unused(tx_ring) + 1 < tx_ring->count)
+                       if (adapter->flags & FLAG_RX_NEEDS_RESTART)
                                adapter->flags |= FLAG_RESTART_NOW;
                        else
                                pm_schedule_suspend(netdev->dev.parent,
@@ -5337,6 +5334,14 @@ link_up:
        adapter->gotc_old = adapter->stats.gotc;
        spin_unlock(&adapter->stats64_lock);
 
+       /* If the link is lost the controller stops DMA, but
+        * if there is queued Tx work it cannot be done.  So
+        * reset the controller to flush the Tx packet buffers.
+        */
+       if (!netif_carrier_ok(netdev) &&
+           (e1000_desc_unused(tx_ring) + 1 < tx_ring->count))
+               adapter->flags |= FLAG_RESTART_NOW;
+
        /* If reset is necessary, do it outside of interrupt context. */
        if (adapter->flags & FLAG_RESTART_NOW) {
                schedule_work(&adapter->reset_task);
@@ -6016,7 +6021,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
        }
 
        while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
-               usleep_range(1000, 2000);
+               usleep_range(1000, 1100);
        /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
        adapter->max_frame_size = max_frame;
        e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
@@ -6296,7 +6301,7 @@ static int e1000e_pm_freeze(struct device *dev)
                int count = E1000_CHECK_RESET_COUNT;
 
                while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
-                       usleep_range(10000, 20000);
+                       usleep_range(10000, 11000);
 
                WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
 
@@ -6711,7 +6716,7 @@ static int e1000e_pm_runtime_suspend(struct device *dev)
                int count = E1000_CHECK_RESET_COUNT;
 
                while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
-                       usleep_range(10000, 20000);
+                       usleep_range(10000, 11000);
 
                WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));