Skip to contentSkip to conversation

powerpc/gianfar: fix ethernet cannot work after restoring from hibernation

PATCH New Wang Dongsheng 4 participants 4 messages Nov 6, 2012 – Nov 9, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/gianfar: fix ethernet cannot work after restoring from hibernation

we should make sure a ethernet has been taken down when system into hibernation status. when the system restoring form hibernation, the ethernet cannot be taken up.
eg:
~# ifconfig eth0 down
~# echo disk > /sys/power/state

hibernation restore

~# ifconfig eth0 up
SIOCSIFFLAGS: No such device

---
 drivers/net/ethernet/freescale/gianfar.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +4 -1
index 4605f72..487b944 100644
@@ -1345,8 +1345,11 @@ static int gfar_restore(struct device *dev)
 	struct gfar_private *priv = dev_get_drvdata(dev);
 	struct net_device *ndev = priv->ndev;
 
-	if (!netif_running(ndev))
+	if (!netif_running(ndev)) {
+		netif_device_attach(ndev);
+
 		return 0;
+	}
 
 	gfar_init_bds(ndev);
 	init_registers(ndev);
Signature · 1 line
1.7.5.1
#1 lore raw

PATCH 1/1 gianfar: ethernet vanishes after restoring from hibernation

From: Wang Dongsheng <[email protected]>

If a gianfar ethernet device is down prior to hibernating a system, it will no longer be present upon system restore.

For example:

~# ifconfig eth0 down
~# echo disk > /sys/power/state

<trigger a restore from hibernation>

~# ifconfig eth0 up
SIOCSIFFLAGS: No such device

This happens because the restore function bails out early upon finding devices that were not up at hibernation. In doing so, it never gets to the netif_device_attach call at the end of the restore function. Adding the netif_device_attach as done here also makes the gfar_restore code consistent with what is done in the gfar_resume code.

---
[v2: expand on details in commit log a bit more, to superceed
v1 at http://patchwork.ozlabs.org/patch/197412/ ]

 drivers/net/ethernet/freescale/gianfar.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/gianfar.c +4 -1
index 1d03dcd..19ac096 100644
@@ -1353,8 +1353,11 @@ static int gfar_restore(struct device *dev)
 	struct gfar_private *priv = dev_get_drvdata(dev);
 	struct net_device *ndev = priv->ndev;
 
-	if (!netif_running(ndev))
+	if (!netif_running(ndev)) {
+		netif_device_attach(ndev);
+
 		return 0;
+	}
 
 	gfar_init_bds(ndev);
 	init_registers(ndev);
Signature · 1 line
1.8.0
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH] gianfar: ethernet vanishes after restoring from hibernation

Quoted 15 lines · Paul Gortmaker

From: Wang Dongsheng <[email protected]>

If a gianfar ethernet device is down prior to hibernating a system, it will no longer be present upon system restore.

For example:

~# ifconfig eth0 down
~# echo disk > /sys/power/state

<trigger a restore from hibernation>

~# ifconfig eth0 up
SIOCSIFFLAGS: No such device

Quoted 8 lines

This happens because the restore function bails out early upon finding devices that were not up at hibernation. In doing so, it never gets to the netif_device_attach call at the end of the restore function. Adding the netif_device_attach as done here also makes the gfar_restore code consistent with what is done in the gfar_resume code.

Cc Claudiu Manoil <[email protected]>

Hello Paul,

Thought I don't have the proper setup to test the hibernation feature, I agree with this patch especially now that the description is much clearer. I fully agree on the consistency argument b/w gfar_restore and gfar_resume. (good observation)

maintainer Applied
#3 lore raw

Re: [PATCH] gianfar: ethernet vanishes after restoring from hibernation

In reply to Paul Gortmaker

From: Paul Gortmaker <[email protected]>
Date: Fri, 9 Nov 2012 09:43:51 -0500

Quoted 22 lines

From: Wang Dongsheng <[email protected]>

If a gianfar ethernet device is down prior to hibernating a system, it will no longer be present upon system restore.

For example:

~# ifconfig eth0 down
~# echo disk > /sys/power/state

<trigger a restore from hibernation>

~# ifconfig eth0 up
SIOCSIFFLAGS: No such device

This happens because the restore function bails out early upon finding devices that were not up at hibernation. In doing so, it never gets to the netif_device_attach call at the end of the restore function. Adding the netif_device_attach as done here also makes the gfar_restore code consistent with what is done in the gfar_resume code.

Quoted 3 lines

Applied, thanks.