aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r--drivers/net/e1000/e1000_main.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index ddc5c533e89c..b1419e21b46b 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -156,8 +156,8 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
156static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid); 156static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
157static void e1000_restore_vlan(struct e1000_adapter *adapter); 157static void e1000_restore_vlan(struct e1000_adapter *adapter);
158 158
159static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
160#ifdef CONFIG_PM 159#ifdef CONFIG_PM
160static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
161static int e1000_resume(struct pci_dev *pdev); 161static int e1000_resume(struct pci_dev *pdev);
162#endif 162#endif
163static void e1000_shutdown(struct pci_dev *pdev); 163static void e1000_shutdown(struct pci_dev *pdev);
@@ -3738,7 +3738,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
3738 struct e1000_hw *hw = &adapter->hw; 3738 struct e1000_hw *hw = &adapter->hw;
3739 u32 rctl, icr = er32(ICR); 3739 u32 rctl, icr = er32(ICR);
3740 3740
3741 if (unlikely((!icr) || test_bit(__E1000_RESETTING, &adapter->flags))) 3741 if (unlikely((!icr) || test_bit(__E1000_DOWN, &adapter->flags)))
3742 return IRQ_NONE; /* Not our interrupt */ 3742 return IRQ_NONE; /* Not our interrupt */
3743 3743
3744 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is 3744 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
@@ -3834,7 +3834,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3834 struct e1000_buffer *buffer_info; 3834 struct e1000_buffer *buffer_info;
3835 unsigned int i, eop; 3835 unsigned int i, eop;
3836 unsigned int count = 0; 3836 unsigned int count = 0;
3837 bool cleaned;
3838 unsigned int total_tx_bytes=0, total_tx_packets=0; 3837 unsigned int total_tx_bytes=0, total_tx_packets=0;
3839 3838
3840 i = tx_ring->next_to_clean; 3839 i = tx_ring->next_to_clean;
@@ -3843,7 +3842,8 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3843 3842
3844 while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && 3843 while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
3845 (count < tx_ring->count)) { 3844 (count < tx_ring->count)) {
3846 for (cleaned = false; !cleaned; count++) { 3845 bool cleaned = false;
3846 for ( ; !cleaned; count++) {
3847 tx_desc = E1000_TX_DESC(*tx_ring, i); 3847 tx_desc = E1000_TX_DESC(*tx_ring, i);
3848 buffer_info = &tx_ring->buffer_info[i]; 3848 buffer_info = &tx_ring->buffer_info[i];
3849 cleaned = (i == eop); 3849 cleaned = (i == eop);
@@ -3871,7 +3871,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3871 tx_ring->next_to_clean = i; 3871 tx_ring->next_to_clean = i;
3872 3872
3873#define TX_WAKE_THRESHOLD 32 3873#define TX_WAKE_THRESHOLD 32
3874 if (unlikely(cleaned && netif_carrier_ok(netdev) && 3874 if (unlikely(count && netif_carrier_ok(netdev) &&
3875 E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) { 3875 E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
3876 /* Make sure that anybody stopping the queue after this 3876 /* Make sure that anybody stopping the queue after this
3877 * sees the new next_to_clean. 3877 * sees the new next_to_clean.
@@ -4601,7 +4601,7 @@ int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
4601 return 0; 4601 return 0;
4602} 4602}
4603 4603
4604static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) 4604static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
4605{ 4605{
4606 struct net_device *netdev = pci_get_drvdata(pdev); 4606 struct net_device *netdev = pci_get_drvdata(pdev);
4607 struct e1000_adapter *adapter = netdev_priv(netdev); 4607 struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -4664,22 +4664,18 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4664 4664
4665 ew32(WUC, E1000_WUC_PME_EN); 4665 ew32(WUC, E1000_WUC_PME_EN);
4666 ew32(WUFC, wufc); 4666 ew32(WUFC, wufc);
4667 pci_enable_wake(pdev, PCI_D3hot, 1);
4668 pci_enable_wake(pdev, PCI_D3cold, 1);
4669 } else { 4667 } else {
4670 ew32(WUC, 0); 4668 ew32(WUC, 0);
4671 ew32(WUFC, 0); 4669 ew32(WUFC, 0);
4672 pci_enable_wake(pdev, PCI_D3hot, 0);
4673 pci_enable_wake(pdev, PCI_D3cold, 0);
4674 } 4670 }
4675 4671
4676 e1000_release_manageability(adapter); 4672 e1000_release_manageability(adapter);
4677 4673
4674 *enable_wake = !!wufc;
4675
4678 /* make sure adapter isn't asleep if manageability is enabled */ 4676 /* make sure adapter isn't asleep if manageability is enabled */
4679 if (adapter->en_mng_pt) { 4677 if (adapter->en_mng_pt)
4680 pci_enable_wake(pdev, PCI_D3hot, 1); 4678 *enable_wake = true;
4681 pci_enable_wake(pdev, PCI_D3cold, 1);
4682 }
4683 4679
4684 if (hw->phy_type == e1000_phy_igp_3) 4680 if (hw->phy_type == e1000_phy_igp_3)
4685 e1000_phy_powerdown_workaround(hw); 4681 e1000_phy_powerdown_workaround(hw);
@@ -4693,12 +4689,29 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4693 4689
4694 pci_disable_device(pdev); 4690 pci_disable_device(pdev);
4695 4691
4696 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4697
4698 return 0; 4692 return 0;
4699} 4693}
4700 4694
4701#ifdef CONFIG_PM 4695#ifdef CONFIG_PM
4696static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4697{
4698 int retval;
4699 bool wake;
4700
4701 retval = __e1000_shutdown(pdev, &wake);
4702 if (retval)
4703 return retval;
4704
4705 if (wake) {
4706 pci_prepare_to_sleep(pdev);
4707 } else {
4708 pci_wake_from_d3(pdev, false);
4709 pci_set_power_state(pdev, PCI_D3hot);
4710 }
4711
4712 return 0;
4713}
4714
4702static int e1000_resume(struct pci_dev *pdev) 4715static int e1000_resume(struct pci_dev *pdev)
4703{ 4716{
4704 struct net_device *netdev = pci_get_drvdata(pdev); 4717 struct net_device *netdev = pci_get_drvdata(pdev);
@@ -4753,7 +4766,14 @@ static int e1000_resume(struct pci_dev *pdev)
4753 4766
4754static void e1000_shutdown(struct pci_dev *pdev) 4767static void e1000_shutdown(struct pci_dev *pdev)
4755{ 4768{
4756 e1000_suspend(pdev, PMSG_SUSPEND); 4769 bool wake;
4770
4771 __e1000_shutdown(pdev, &wake);
4772
4773 if (system_state == SYSTEM_POWER_OFF) {
4774 pci_wake_from_d3(pdev, wake);
4775 pci_set_power_state(pdev, PCI_D3hot);
4776 }
4757} 4777}
4758 4778
4759#ifdef CONFIG_NET_POLL_CONTROLLER 4779#ifdef CONFIG_NET_POLL_CONTROLLER