aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/e1000e/netdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/intel/e1000e/netdev.c')
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c77
1 files changed, 46 insertions, 31 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 2669fdc09c8e..7fd1feaeb405 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -3327,6 +3327,9 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
3327 struct e1000_hw *hw = &adapter->hw; 3327 struct e1000_hw *hw = &adapter->hw;
3328 u32 rctl; 3328 u32 rctl;
3329 3329
3330 if (pm_runtime_suspended(netdev->dev.parent))
3331 return;
3332
3330 /* Check for Promiscuous and All Multicast modes */ 3333 /* Check for Promiscuous and All Multicast modes */
3331 rctl = er32(RCTL); 3334 rctl = er32(RCTL);
3332 3335
@@ -4317,7 +4320,6 @@ static int e1000_open(struct net_device *netdev)
4317 adapter->tx_hang_recheck = false; 4320 adapter->tx_hang_recheck = false;
4318 netif_start_queue(netdev); 4321 netif_start_queue(netdev);
4319 4322
4320 adapter->idle_check = true;
4321 hw->mac.get_link_status = true; 4323 hw->mac.get_link_status = true;
4322 pm_runtime_put(&pdev->dev); 4324 pm_runtime_put(&pdev->dev);
4323 4325
@@ -4369,6 +4371,9 @@ static int e1000_close(struct net_device *netdev)
4369 if (!test_bit(__E1000_DOWN, &adapter->state)) { 4371 if (!test_bit(__E1000_DOWN, &adapter->state)) {
4370 e1000e_down(adapter, true); 4372 e1000e_down(adapter, true);
4371 e1000_free_irq(adapter); 4373 e1000_free_irq(adapter);
4374
4375 /* Link status message must follow this format */
4376 pr_info("%s NIC Link is Down\n", adapter->netdev->name);
4372 } 4377 }
4373 4378
4374 napi_disable(&adapter->napi); 4379 napi_disable(&adapter->napi);
@@ -5678,6 +5683,9 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
5678 adapter->max_frame_size = max_frame; 5683 adapter->max_frame_size = max_frame;
5679 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu); 5684 e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
5680 netdev->mtu = new_mtu; 5685 netdev->mtu = new_mtu;
5686
5687 pm_runtime_get_sync(netdev->dev.parent);
5688
5681 if (netif_running(netdev)) 5689 if (netif_running(netdev))
5682 e1000e_down(adapter, true); 5690 e1000e_down(adapter, true);
5683 5691
@@ -5705,6 +5713,8 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
5705 else 5713 else
5706 e1000e_reset(adapter); 5714 e1000e_reset(adapter);
5707 5715
5716 pm_runtime_put_sync(netdev->dev.parent);
5717
5708 clear_bit(__E1000_RESETTING, &adapter->state); 5718 clear_bit(__E1000_RESETTING, &adapter->state);
5709 5719
5710 return 0; 5720 return 0;
@@ -5979,6 +5989,9 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
5979 ew32(CTRL_EXT, ctrl_ext); 5989 ew32(CTRL_EXT, ctrl_ext);
5980 } 5990 }
5981 5991
5992 if (!runtime)
5993 e1000e_power_up_phy(adapter);
5994
5982 if (adapter->flags & FLAG_IS_ICH) 5995 if (adapter->flags & FLAG_IS_ICH)
5983 e1000_suspend_workarounds_ich8lan(&adapter->hw); 5996 e1000_suspend_workarounds_ich8lan(&adapter->hw);
5984 5997
@@ -6108,11 +6121,6 @@ static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
6108} 6121}
6109 6122
6110#ifdef CONFIG_PM 6123#ifdef CONFIG_PM
6111static bool e1000e_pm_ready(struct e1000_adapter *adapter)
6112{
6113 return !!adapter->tx_ring->buffer_info;
6114}
6115
6116static int __e1000_resume(struct pci_dev *pdev) 6124static int __e1000_resume(struct pci_dev *pdev)
6117{ 6125{
6118 struct net_device *netdev = pci_get_drvdata(pdev); 6126 struct net_device *netdev = pci_get_drvdata(pdev);
@@ -6167,11 +6175,6 @@ static int __e1000_resume(struct pci_dev *pdev)
6167 6175
6168 e1000_init_manageability_pt(adapter); 6176 e1000_init_manageability_pt(adapter);
6169 6177
6170 if (netif_running(netdev))
6171 e1000e_up(adapter);
6172
6173 netif_device_attach(netdev);
6174
6175 /* If the controller has AMT, do not set DRV_LOAD until the interface 6178 /* If the controller has AMT, do not set DRV_LOAD until the interface
6176 * is up. For all other cases, let the f/w know that the h/w is now 6179 * is up. For all other cases, let the f/w know that the h/w is now
6177 * under the control of the driver. 6180 * under the control of the driver.
@@ -6226,47 +6229,59 @@ static int e1000e_pm_resume(struct device *dev)
6226#endif /* CONFIG_PM_SLEEP */ 6229#endif /* CONFIG_PM_SLEEP */
6227 6230
6228#ifdef CONFIG_PM_RUNTIME 6231#ifdef CONFIG_PM_RUNTIME
6229static int e1000_runtime_suspend(struct device *dev) 6232static int e1000e_pm_runtime_idle(struct device *dev)
6230{ 6233{
6231 struct pci_dev *pdev = to_pci_dev(dev); 6234 struct pci_dev *pdev = to_pci_dev(dev);
6232 struct net_device *netdev = pci_get_drvdata(pdev); 6235 struct net_device *netdev = pci_get_drvdata(pdev);
6233 struct e1000_adapter *adapter = netdev_priv(netdev); 6236 struct e1000_adapter *adapter = netdev_priv(netdev);
6234 6237
6235 if (!e1000e_pm_ready(adapter)) 6238 if (!e1000e_has_link(adapter))
6236 return 0; 6239 pm_schedule_suspend(dev, 5 * MSEC_PER_SEC);
6237 6240
6238 return __e1000_shutdown(pdev, true); 6241 return -EBUSY;
6239} 6242}
6240 6243
6241static int e1000_idle(struct device *dev) 6244static int e1000e_pm_runtime_resume(struct device *dev)
6242{ 6245{
6243 struct pci_dev *pdev = to_pci_dev(dev); 6246 struct pci_dev *pdev = to_pci_dev(dev);
6244 struct net_device *netdev = pci_get_drvdata(pdev); 6247 struct net_device *netdev = pci_get_drvdata(pdev);
6245 struct e1000_adapter *adapter = netdev_priv(netdev); 6248 struct e1000_adapter *adapter = netdev_priv(netdev);
6249 int rc;
6246 6250
6247 if (!e1000e_pm_ready(adapter)) 6251 rc = __e1000_resume(pdev);
6248 return 0; 6252 if (rc)
6253 return rc;
6249 6254
6250 if (adapter->idle_check) { 6255 if (netdev->flags & IFF_UP)
6251 adapter->idle_check = false; 6256 rc = e1000e_up(adapter);
6252 if (!e1000e_has_link(adapter))
6253 pm_schedule_suspend(dev, MSEC_PER_SEC);
6254 }
6255 6257
6256 return -EBUSY; 6258 return rc;
6257} 6259}
6258 6260
6259static int e1000_runtime_resume(struct device *dev) 6261static int e1000e_pm_runtime_suspend(struct device *dev)
6260{ 6262{
6261 struct pci_dev *pdev = to_pci_dev(dev); 6263 struct pci_dev *pdev = to_pci_dev(dev);
6262 struct net_device *netdev = pci_get_drvdata(pdev); 6264 struct net_device *netdev = pci_get_drvdata(pdev);
6263 struct e1000_adapter *adapter = netdev_priv(netdev); 6265 struct e1000_adapter *adapter = netdev_priv(netdev);
6264 6266
6265 if (!e1000e_pm_ready(adapter)) 6267 if (netdev->flags & IFF_UP) {
6266 return 0; 6268 int count = E1000_CHECK_RESET_COUNT;
6269
6270 while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
6271 usleep_range(10000, 20000);
6267 6272
6268 adapter->idle_check = !dev->power.runtime_auto; 6273 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
6269 return __e1000_resume(pdev); 6274
6275 /* Down the device without resetting the hardware */
6276 e1000e_down(adapter, false);
6277 }
6278
6279 if (__e1000_shutdown(pdev, true)) {
6280 e1000e_pm_runtime_resume(dev);
6281 return -EBUSY;
6282 }
6283
6284 return 0;
6270} 6285}
6271#endif /* CONFIG_PM_RUNTIME */ 6286#endif /* CONFIG_PM_RUNTIME */
6272#endif /* CONFIG_PM */ 6287#endif /* CONFIG_PM */
@@ -7051,8 +7066,8 @@ static const struct dev_pm_ops e1000_pm_ops = {
7051 .thaw = e1000e_pm_thaw, 7066 .thaw = e1000e_pm_thaw,
7052 .poweroff = e1000e_pm_suspend, 7067 .poweroff = e1000e_pm_suspend,
7053 .restore = e1000e_pm_resume, 7068 .restore = e1000e_pm_resume,
7054 SET_RUNTIME_PM_OPS(e1000_runtime_suspend, e1000_runtime_resume, 7069 SET_RUNTIME_PM_OPS(e1000e_pm_runtime_suspend, e1000e_pm_runtime_resume,
7055 e1000_idle) 7070 e1000e_pm_runtime_idle)
7056}; 7071};
7057 7072
7058/* PCI Device API Driver */ 7073/* PCI Device API Driver */