@@ -4303,6 +4303,7 @@ static int e1000_open(struct net_device *netdev)
43034303 netif_start_queue (netdev );
43044304
43054305 adapter -> idle_check = true;
4306+ hw -> mac .get_link_status = true;
43064307 pm_runtime_put (& pdev -> dev );
43074308
43084309 /* fire a link status change interrupt to start the watchdog */
@@ -4662,6 +4663,7 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
46624663 (adapter -> hw .phy .media_type == e1000_media_type_copper )) {
46634664 int ret_val ;
46644665
4666+ pm_runtime_get_sync (& adapter -> pdev -> dev );
46654667 ret_val = e1e_rphy (hw , MII_BMCR , & phy -> bmcr );
46664668 ret_val |= e1e_rphy (hw , MII_BMSR , & phy -> bmsr );
46674669 ret_val |= e1e_rphy (hw , MII_ADVERTISE , & phy -> advertise );
@@ -4672,6 +4674,7 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
46724674 ret_val |= e1e_rphy (hw , MII_ESTATUS , & phy -> estatus );
46734675 if (ret_val )
46744676 e_warn ("Error reading PHY register\n" );
4677+ pm_runtime_put_sync (& adapter -> pdev -> dev );
46754678 } else {
46764679 /* Do not read PHY registers if link is not up
46774680 * Set values to typical power-on defaults
@@ -5887,8 +5890,7 @@ static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
58875890 return retval ;
58885891}
58895892
5890- static int __e1000_shutdown (struct pci_dev * pdev , bool * enable_wake ,
5891- bool runtime )
5893+ static int __e1000_shutdown (struct pci_dev * pdev , bool runtime )
58925894{
58935895 struct net_device * netdev = pci_get_drvdata (pdev );
58945896 struct e1000_adapter * adapter = netdev_priv (netdev );
@@ -5912,10 +5914,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
59125914 }
59135915 e1000e_reset_interrupt_capability (adapter );
59145916
5915- retval = pci_save_state (pdev );
5916- if (retval )
5917- return retval ;
5918-
59195917 status = er32 (STATUS );
59205918 if (status & E1000_STATUS_LU )
59215919 wufc &= ~E1000_WUFC_LNKC ;
@@ -5971,13 +5969,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
59715969 ew32 (WUFC , 0 );
59725970 }
59735971
5974- * enable_wake = !!wufc ;
5975-
5976- /* make sure adapter isn't asleep if manageability is enabled */
5977- if ((adapter -> flags & FLAG_MNG_PT_ENABLED ) ||
5978- (hw -> mac .ops .check_mng_mode (hw )))
5979- * enable_wake = true;
5980-
59815972 if (adapter -> hw .phy .type == e1000_phy_igp_3 )
59825973 e1000e_igp3_phy_powerdown_workaround_ich8lan (& adapter -> hw );
59835974
@@ -5986,27 +5977,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
59865977 */
59875978 e1000e_release_hw_control (adapter );
59885979
5989- pci_disable_device (pdev );
5990-
5991- return 0 ;
5992- }
5993-
5994- static void e1000_power_off (struct pci_dev * pdev , bool sleep , bool wake )
5995- {
5996- if (sleep && wake ) {
5997- pci_prepare_to_sleep (pdev );
5998- return ;
5999- }
6000-
6001- pci_wake_from_d3 (pdev , wake );
6002- pci_set_power_state (pdev , PCI_D3hot );
6003- }
6004-
6005- static void e1000_complete_shutdown (struct pci_dev * pdev , bool sleep ,
6006- bool wake )
6007- {
6008- struct net_device * netdev = pci_get_drvdata (pdev );
6009- struct e1000_adapter * adapter = netdev_priv (netdev );
5980+ pci_clear_master (pdev );
60105981
60115982 /* The pci-e switch on some quad port adapters will report a
60125983 * correctable error when the MAC transitions from D0 to D3. To
@@ -6021,12 +5992,13 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
60215992 pcie_capability_write_word (us_dev , PCI_EXP_DEVCTL ,
60225993 (devctl & ~PCI_EXP_DEVCTL_CERE ));
60235994
6024- e1000_power_off (pdev , sleep , wake );
5995+ pci_save_state (pdev );
5996+ pci_prepare_to_sleep (pdev );
60255997
60265998 pcie_capability_write_word (us_dev , PCI_EXP_DEVCTL , devctl );
6027- } else {
6028- e1000_power_off (pdev , sleep , wake );
60295999 }
6000+
6001+ return 0 ;
60306002}
60316003
60326004#ifdef CONFIG_PCIEASPM
@@ -6084,9 +6056,7 @@ static int __e1000_resume(struct pci_dev *pdev)
60846056 if (aspm_disable_flag )
60856057 e1000e_disable_aspm (pdev , aspm_disable_flag );
60866058
6087- pci_set_power_state (pdev , PCI_D0 );
6088- pci_restore_state (pdev );
6089- pci_save_state (pdev );
6059+ pci_set_master (pdev );
60906060
60916061 e1000e_set_interrupt_capability (adapter );
60926062 if (netif_running (netdev )) {
@@ -6152,14 +6122,8 @@ static int __e1000_resume(struct pci_dev *pdev)
61526122static int e1000_suspend (struct device * dev )
61536123{
61546124 struct pci_dev * pdev = to_pci_dev (dev );
6155- int retval ;
6156- bool wake ;
6157-
6158- retval = __e1000_shutdown (pdev , & wake , false);
6159- if (!retval )
6160- e1000_complete_shutdown (pdev , true, wake );
61616125
6162- return retval ;
6126+ return __e1000_shutdown ( pdev , false) ;
61636127}
61646128
61656129static int e1000_resume (struct device * dev )
@@ -6182,13 +6146,10 @@ static int e1000_runtime_suspend(struct device *dev)
61826146 struct net_device * netdev = pci_get_drvdata (pdev );
61836147 struct e1000_adapter * adapter = netdev_priv (netdev );
61846148
6185- if (e1000e_pm_ready (adapter )) {
6186- bool wake ;
6187-
6188- __e1000_shutdown (pdev , & wake , true);
6189- }
6149+ if (!e1000e_pm_ready (adapter ))
6150+ return 0 ;
61906151
6191- return 0 ;
6152+ return __e1000_shutdown ( pdev , true) ;
61926153}
61936154
61946155static int e1000_idle (struct device * dev )
@@ -6226,12 +6187,7 @@ static int e1000_runtime_resume(struct device *dev)
62266187
62276188static void e1000_shutdown (struct pci_dev * pdev )
62286189{
6229- bool wake = false;
6230-
6231- __e1000_shutdown (pdev , & wake , false);
6232-
6233- if (system_state == SYSTEM_POWER_OFF )
6234- e1000_complete_shutdown (pdev , false, wake );
6190+ __e1000_shutdown (pdev , false);
62356191}
62366192
62376193#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -6352,9 +6308,9 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
63526308 "Cannot re-enable PCI device after reset.\n" );
63536309 result = PCI_ERS_RESULT_DISCONNECT ;
63546310 } else {
6355- pci_set_master (pdev );
63566311 pdev -> state_saved = true;
63576312 pci_restore_state (pdev );
6313+ pci_set_master (pdev );
63586314
63596315 pci_enable_wake (pdev , PCI_D3hot , 0 );
63606316 pci_enable_wake (pdev , PCI_D3cold , 0 );
@@ -6783,7 +6739,11 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
67836739
67846740 /* initialize the wol settings based on the eeprom settings */
67856741 adapter -> wol = adapter -> eeprom_wol ;
6786- device_set_wakeup_enable (& adapter -> pdev -> dev , adapter -> wol );
6742+
6743+ /* make sure adapter isn't asleep if manageability is enabled */
6744+ if (adapter -> wol || (adapter -> flags & FLAG_MNG_PT_ENABLED ) ||
6745+ (hw -> mac .ops .check_mng_mode (hw )))
6746+ device_wakeup_enable (& pdev -> dev );
67876747
67886748 /* save off EEPROM version number */
67896749 e1000_read_nvm (& adapter -> hw , 5 , 1 , & adapter -> eeprom_vers );
0 commit comments