netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe
@ 2009-04-04 21:37 Rafael J. Wysocki
  2009-04-04 21:39 ` [RFT][PATCH 1/3] NET/e1000: Fix powering off during shutdown Rafael J. Wysocki
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-04-04 21:37 UTC (permalink / raw)
  To: NetDev; +Cc: Jesse Brandeburg, Jeff Kirsher, Yinghai Lu, pm list, LKML

Hi,

Commit 3fe7c4c9dca4fbbff92eb61a660690dad7029ec3 (net/igb: Fix kexec with igb
(rev. 3)) fixed a kexec problem with igb by making its shutdown routine only
put the device into a low power state if the system is going to be powered off.

The following three patches make analogous changes to e1000, e1000e and ixgbe.

Thanks,
Rafael


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFT][PATCH 1/3] NET/e1000: Fix powering off during shutdown
  2009-04-04 21:37 [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Rafael J. Wysocki
@ 2009-04-04 21:39 ` Rafael J. Wysocki
  2009-04-04 21:40 ` [RFT][PATCH 2/3] NET/e1000e: " Rafael J. Wysocki
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-04-04 21:39 UTC (permalink / raw)
  To: NetDev; +Cc: Jesse Brandeburg, Jeff Kirsher, Yinghai Lu, pm list, LKML

From: Rafael J. Wysocki <rjw@sisk.pl>

Impact: Fix

Prevent e1000 from putting the adapter into D3 during shutdown
except when we're going to power off the system, since doing that may
generally cause problems with kexec to happen (such problems were
observed for igb and forcedeth).  For this purpose seperate
e1000_shutdown() from e1000_suspend() and use the appropriate PCI
PM callbacks in both of them.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/net/e1000/e1000_main.c |   44 +++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

Index: linux-2.6/drivers/net/e1000/e1000_main.c
===================================================================
--- linux-2.6.orig/drivers/net/e1000/e1000_main.c
+++ linux-2.6/drivers/net/e1000/e1000_main.c
@@ -4583,7 +4583,7 @@ int e1000_set_spd_dplx(struct e1000_adap
 	return 0;
 }
 
-static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -4646,22 +4646,18 @@ static int e1000_suspend(struct pci_dev 
 
 		ew32(WUC, E1000_WUC_PME_EN);
 		ew32(WUFC, wufc);
-		pci_enable_wake(pdev, PCI_D3hot, 1);
-		pci_enable_wake(pdev, PCI_D3cold, 1);
 	} else {
 		ew32(WUC, 0);
 		ew32(WUFC, 0);
-		pci_enable_wake(pdev, PCI_D3hot, 0);
-		pci_enable_wake(pdev, PCI_D3cold, 0);
 	}
 
+	*enable_wake = !!wufc;
+
 	e1000_release_manageability(adapter);
 
 	/* make sure adapter isn't asleep if manageability is enabled */
-	if (adapter->en_mng_pt) {
-		pci_enable_wake(pdev, PCI_D3hot, 1);
-		pci_enable_wake(pdev, PCI_D3cold, 1);
-	}
+	if (adapter->en_mng_pt)
+		*enable_wake = true;
 
 	if (hw->phy_type == e1000_phy_igp_3)
 		e1000_phy_powerdown_workaround(hw);
@@ -4675,12 +4671,29 @@ static int e1000_suspend(struct pci_dev 
 
 	pci_disable_device(pdev);
 
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
-
 	return 0;
 }
 
 #ifdef CONFIG_PM
+static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	int retval;
+	bool wake;
+
+	retval = __e1000_shutdown(pdev, &wake);
+	if (retval)
+		return retval;
+
+	if (wake) {
+		pci_prepare_to_sleep(pdev);
+	} else {
+		pci_wake_from_d3(pdev, false);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
+
+	return 0;
+}
+
 static int e1000_resume(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
@@ -4735,7 +4748,14 @@ static int e1000_resume(struct pci_dev *
 
 static void e1000_shutdown(struct pci_dev *pdev)
 {
-	e1000_suspend(pdev, PMSG_SUSPEND);
+	bool wake;
+
+	__e1000_shutdown(pdev, &wake);
+
+	if (system_state == SYSTEM_POWER_OFF) {
+		pci_wake_from_d3(pdev, wake);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFT][PATCH 2/3] NET/e1000e: Fix powering off during shutdown
  2009-04-04 21:37 [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Rafael J. Wysocki
  2009-04-04 21:39 ` [RFT][PATCH 1/3] NET/e1000: Fix powering off during shutdown Rafael J. Wysocki
@ 2009-04-04 21:40 ` Rafael J. Wysocki
  2009-04-04 21:41 ` [RFT][PATCH 3/3] NET/ixgbe: " Rafael J. Wysocki
  2009-04-05  7:59 ` [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Jeff Kirsher
  3 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-04-04 21:40 UTC (permalink / raw)
  To: NetDev; +Cc: Jesse Brandeburg, Jeff Kirsher, Yinghai Lu, pm list, LKML

From: Rafael J. Wysocki <rjw@sisk.pl>

Impact: Fix

Prevent e1000e from putting the adapter into D3 during shutdown
except when we're going to power off the system, since doing that may
generally cause problems with kexec to happen (such problems were
observed for igb and forcedeth).  For this purpose seperate
e1000e_shutdown() from e1000e_suspend() and use the appropriate PCI
PM callbacks in both of them.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/net/e1000e/netdev.c |   58 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 44 insertions(+), 14 deletions(-)

Index: linux-2.6/drivers/net/e1000e/netdev.c
===================================================================
--- linux-2.6.orig/drivers/net/e1000e/netdev.c
+++ linux-2.6/drivers/net/e1000e/netdev.c
@@ -4346,7 +4346,7 @@ static int e1000_ioctl(struct net_device
 	}
 }
 
-static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -4409,20 +4409,16 @@ static int e1000_suspend(struct pci_dev 
 
 		ew32(WUC, E1000_WUC_PME_EN);
 		ew32(WUFC, wufc);
-		pci_enable_wake(pdev, PCI_D3hot, 1);
-		pci_enable_wake(pdev, PCI_D3cold, 1);
 	} else {
 		ew32(WUC, 0);
 		ew32(WUFC, 0);
-		pci_enable_wake(pdev, PCI_D3hot, 0);
-		pci_enable_wake(pdev, PCI_D3cold, 0);
 	}
 
+	*enable_wake = !!wufc;
+
 	/* make sure adapter isn't asleep if manageability is enabled */
-	if (adapter->flags & FLAG_MNG_PT_ENABLED) {
-		pci_enable_wake(pdev, PCI_D3hot, 1);
-		pci_enable_wake(pdev, PCI_D3cold, 1);
-	}
+	if (adapter->flags & FLAG_MNG_PT_ENABLED)
+		*enable_wake = true;
 
 	if (adapter->hw.phy.type == e1000_phy_igp_3)
 		e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
@@ -4435,6 +4431,25 @@ static int e1000_suspend(struct pci_dev 
 
 	pci_disable_device(pdev);
 
+	return 0;
+}
+
+static void e1000_power_off(struct pci_dev *pdev, bool sleep, bool wake)
+{
+	if (sleep && wake) {
+		pci_prepare_to_sleep(pdev);
+		return;
+	}
+
+	pci_wake_from_d3(pdev, wake);
+	pci_set_power_state(pdev, PCI_D3hot);
+}
+
+static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep, bool wake)
+{
+	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct e1000_adapter *adapter = netdev_priv(netdev);
+
 	/*
 	 * The pci-e switch on some quad port adapters will report a
 	 * correctable error when the MAC transitions from D0 to D3.  To
@@ -4450,14 +4465,12 @@ static int e1000_suspend(struct pci_dev 
 		pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL,
 		                      (devctl & ~PCI_EXP_DEVCTL_CERE));
 
-		pci_set_power_state(pdev, pci_choose_state(pdev, state));
+		e1000_power_off(pdev, sleep, wake);
 
 		pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl);
 	} else {
-		pci_set_power_state(pdev, pci_choose_state(pdev, state));
+		e1000_power_off(pdev, sleep, wake);
 	}
-
-	return 0;
 }
 
 static void e1000e_disable_l1aspm(struct pci_dev *pdev)
@@ -4486,6 +4499,18 @@ static void e1000e_disable_l1aspm(struct
 }
 
 #ifdef CONFIG_PM
+static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	int retval;
+	bool wake;
+
+	retval = __e1000_shutdown(pdev, &wake);
+	if (!retval)
+		e1000_complete_shutdown(pdev, true, wake);
+
+	return retval;
+}
+
 static int e1000_resume(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
@@ -4549,7 +4574,12 @@ static int e1000_resume(struct pci_dev *
 
 static void e1000_shutdown(struct pci_dev *pdev)
 {
-	e1000_suspend(pdev, PMSG_SUSPEND);
+	bool wake;
+
+	__e1000_shutdown(pdev, &wake);
+
+	if (system_state == SYSTEM_POWER_OFF)
+		e1000_complete_shutdown(pdev, false, wake);
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFT][PATCH 3/3] NET/ixgbe: Fix powering off during shutdown
  2009-04-04 21:37 [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Rafael J. Wysocki
  2009-04-04 21:39 ` [RFT][PATCH 1/3] NET/e1000: Fix powering off during shutdown Rafael J. Wysocki
  2009-04-04 21:40 ` [RFT][PATCH 2/3] NET/e1000e: " Rafael J. Wysocki
@ 2009-04-04 21:41 ` Rafael J. Wysocki
  2009-04-05  7:59 ` [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Jeff Kirsher
  3 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-04-04 21:41 UTC (permalink / raw)
  To: NetDev; +Cc: Jesse Brandeburg, Jeff Kirsher, Yinghai Lu, pm list, LKML

From: Rafael J. Wysocki <rjw@sisk.pl>

Impact: Fix

Prevent ixgbe from putting the adapter into D3 during shutdown
except when we're going to power off the system, since doing that may
generally cause problems with kexec to happen (such problems were
observed for igb and forcedeth).  For this purpose seperate
ixgbe_shutdown() from ixgbe_suspend() and use the appropriate PCI
PM callbacks in both of them.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/net/ixgbe/ixgbe_main.c |   36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/net/ixgbe/ixgbe_main.c
===================================================================
--- linux-2.6.orig/drivers/net/ixgbe/ixgbe_main.c
+++ linux-2.6/drivers/net/ixgbe/ixgbe_main.c
@@ -3611,9 +3611,9 @@ static int ixgbe_resume(struct pci_dev *
 
 	return 0;
 }
-
 #endif /* CONFIG_PM */
-static int ixgbe_suspend(struct pci_dev *pdev, pm_message_t state)
+
+static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct ixgbe_adapter *adapter = netdev_priv(netdev);
@@ -3672,18 +3672,46 @@ static int ixgbe_suspend(struct pci_dev 
 		pci_enable_wake(pdev, PCI_D3cold, 0);
 	}
 
+	*enable_wake = !!wufc;
+
 	ixgbe_release_hw_control(adapter);
 
 	pci_disable_device(pdev);
 
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int ixgbe_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	int retval;
+	bool wake;
+
+	retval = __ixgbe_shutdown(pdev, &wake);
+	if (retval)
+		return retval;
+
+	if (wake) {
+		pci_prepare_to_sleep(pdev);
+	} else {
+		pci_wake_from_d3(pdev, false);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 
 	return 0;
 }
+#endif /* CONFIG_PM */
 
 static void ixgbe_shutdown(struct pci_dev *pdev)
 {
-	ixgbe_suspend(pdev, PMSG_SUSPEND);
+	bool wake;
+
+	__ixgbe_shutdown(pdev, &wake);
+
+	if (system_state == SYSTEM_POWER_OFF) {
+		pci_wake_from_d3(pdev, wake);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 }
 
 /**

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe
  2009-04-04 21:37 [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2009-04-04 21:41 ` [RFT][PATCH 3/3] NET/ixgbe: " Rafael J. Wysocki
@ 2009-04-05  7:59 ` Jeff Kirsher
  2009-04-05 10:14   ` Rafael J. Wysocki
  3 siblings, 1 reply; 6+ messages in thread
From: Jeff Kirsher @ 2009-04-05  7:59 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: NetDev, Jesse Brandeburg, Yinghai Lu, pm list, LKML

On Sat, Apr 4, 2009 at 2:37 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> Hi,
>
> Commit 3fe7c4c9dca4fbbff92eb61a660690dad7029ec3 (net/igb: Fix kexec with igb
> (rev. 3)) fixed a kexec problem with igb by making its shutdown routine only
> put the device into a low power state if the system is going to be powered off.
>
> The following three patches make analogous changes to e1000, e1000e and ixgbe.
>

Thanks Rafael, I will add these patches to my tree and get them into
testing on Monday/Tuesday.  If everything looks good after testing, I
will push them with our other patches.

-- 
Cheers,
Jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe
  2009-04-05  7:59 ` [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Jeff Kirsher
@ 2009-04-05 10:14   ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-04-05 10:14 UTC (permalink / raw)
  To: Jeff Kirsher; +Cc: NetDev, Jesse Brandeburg, Yinghai Lu, pm list, LKML

On Sunday 05 April 2009, Jeff Kirsher wrote:
> On Sat, Apr 4, 2009 at 2:37 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > Hi,
> >
> > Commit 3fe7c4c9dca4fbbff92eb61a660690dad7029ec3 (net/igb: Fix kexec with igb
> > (rev. 3)) fixed a kexec problem with igb by making its shutdown routine only
> > put the device into a low power state if the system is going to be powered off.
> >
> > The following three patches make analogous changes to e1000, e1000e and ixgbe.
> >
> 
> Thanks Rafael, I will add these patches to my tree and get them into
> testing on Monday/Tuesday.  If everything looks good after testing, I
> will push them with our other patches.

Great, thanks a lot!

Rafael

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-05 10:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-04 21:37 [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Rafael J. Wysocki
2009-04-04 21:39 ` [RFT][PATCH 1/3] NET/e1000: Fix powering off during shutdown Rafael J. Wysocki
2009-04-04 21:40 ` [RFT][PATCH 2/3] NET/e1000e: " Rafael J. Wysocki
2009-04-04 21:41 ` [RFT][PATCH 3/3] NET/ixgbe: " Rafael J. Wysocki
2009-04-05  7:59 ` [RFT][PATCH 0/3] NET: Shutdown fixes for e1000, e1000e and ixgbe Jeff Kirsher
2009-04-05 10:14   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).