[Updated patch] Re: [PATCH] igb: fix kexec with igb

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Rafael J. Wysocki
Date: Saturday, March 21, 2009 - 3:04 pm

On Thursday 12 March 2009, Yinghai Lu wrote:

Still, Yinghai, can you please also test the patch below?  It fixes all
shortcomings in the driver's suspend and shutdown methods I was talking about
in one of the previous messages.  If it works, IMO it will be a preferable fix
(in particular, it would be good to check if WoL still works with it,
but I don't have the hardware).

Thanks,
Rafael

---
From: Rafael J. Wysocki <rjw@sisk.pl>
Subject: net/igb: Fix kexec with igb (rev. 3)
Impact: Fix

Yinghai Lu found one system with 82575EB where, in the kernel that is
kexeced, probe igb failed with -2, the reason being that the adapter
could not be brought back from D3 by the kexec kernel, most probably
due to quirky hardware (it looks like the same behavior happened on
forcedeth).

Prevent igb from putting the adapter into D3 during shutdown except
when we going to power off the system.  For this purpose, seperate
igb_shutdown() from igb_suspend() and use the appropriate PCI PM
callbacks in both of them.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/net/igb/igb_main.c |   42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)

Index: linux-2.6/drivers/net/igb/igb_main.c
===================================================================
--- linux-2.6.orig/drivers/net/igb/igb_main.c
+++ linux-2.6/drivers/net/igb/igb_main.c
@@ -4277,7 +4277,7 @@ int igb_set_spd_dplx(struct igb_adapter 
 }
 
 
-static int igb_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct igb_adapter *adapter = netdev_priv(netdev);
@@ -4336,15 +4336,9 @@ static int igb_suspend(struct pci_dev *p
 		wr32(E1000_WUFC, 0);
 	}
 
-	/* make sure adapter isn't asleep if manageability/wol is enabled */
-	if (wufc || adapter->en_mng_pt) {
-		pci_enable_wake(pdev, PCI_D3hot, 1);
-		pci_enable_wake(pdev, PCI_D3cold, 1);
-	} else {
+	*enable_wake = wufc || adapter->en_mng_pt;
+	if (!*enable_wake)
 		igb_shutdown_fiber_serdes_link_82575(hw);
-		pci_enable_wake(pdev, PCI_D3hot, 0);
-		pci_enable_wake(pdev, PCI_D3cold, 0);
-	}
 
 	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
 	 * would have already happened in close and is redundant. */
@@ -4352,12 +4346,29 @@ static int igb_suspend(struct pci_dev *p
 
 	pci_disable_device(pdev);
 
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
-
 	return 0;
 }
 
 #ifdef CONFIG_PM
+static int igb_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	int retval;
+	bool wake;
+
+	retval = __igb_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 igb_resume(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
@@ -4412,7 +4423,14 @@ static int igb_resume(struct pci_dev *pd
 
 static void igb_shutdown(struct pci_dev *pdev)
 {
-	igb_suspend(pdev, PMSG_SUSPEND);
+	bool wake;
+
+	__igb_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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] igb: fix kexec with igb, Yinghai Lu, (Fri Mar 6, 9:33 pm)
Re: [PATCH] igb: fix kexec with igb, Jesse Brandeburg, (Sat Mar 7, 12:18 am)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Sat Mar 7, 12:31 am)
Re: [PATCH] igb: fix kexec with igb, Eric W. Biederman, (Sat Mar 7, 11:20 am)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Sat Mar 7, 11:50 am)
[PATCH] pci: fix kexec with power state D3, Yinghai Lu, (Sun Mar 8, 1:09 am)
Re: [PATCH] pci: fix kexec with power state D3, Rafael J. Wysocki, (Sun Mar 8, 3:08 am)
Re: [PATCH] pci: fix kexec with power state D3, Ingo Molnar, (Sun Mar 8, 3:15 am)
Re: [PATCH] pci: fix kexec with power state D3, Rafael J. Wysocki, (Sun Mar 8, 3:28 am)
Re: [PATCH] pci: fix kexec with power state D3, Rafael J. Wysocki, (Sun Mar 8, 3:33 am)
Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 8, 3:45 am)
Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 8, 3:57 am)
Re: [PATCH] pci: fix kexec with power state D3, Ingo Molnar, (Sun Mar 8, 4:08 am)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Sun Mar 8, 11:03 am)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Sun Mar 8, 11:10 am)
Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 8, 2:08 pm)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Sun Mar 8, 2:18 pm)
Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 8, 2:32 pm)
Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 8, 2:40 pm)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Sun Mar 8, 3:35 pm)
Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 8, 3:57 pm)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Sun Mar 8, 4:04 pm)
Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 8, 4:57 pm)
Re: [PATCH] igb: fix kexec with igb, Yinghai Lu, (Wed Mar 11, 4:37 pm)
Re: [PATCH] pci: fix kexec with power state D3, Jesse Barnes, (Thu Mar 19, 6:49 pm)
Re: [PATCH] pci: fix kexec with power state D3, Rafael J. Wysocki, (Fri Mar 20, 4:29 am)
[Updated patch] Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sat Mar 21, 3:04 pm)
Re: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sat Mar 28, 2:27 pm)
Re: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Jeff Kirsher, (Sat Mar 28, 7:30 pm)
Re: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Sun Mar 29, 4:19 am)
Re: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Jeff Kirsher, (Mon Mar 30, 2:36 pm)
Re: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Mon Mar 30, 2:39 pm)
RE: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Tantilov, Emil S, (Tue Mar 31, 12:14 pm)
Re: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Jeff Kirsher, (Tue Mar 31, 12:51 pm)
Re: [Updated patch] Re: [PATCH] igb: fix kexec with igb, Rafael J. Wysocki, (Tue Mar 31, 1:27 pm)