diff mbox

gianfar: ethernet vanishes after restoring from hibernation

Message ID 1352472231-17927-1-git-send-email-paul.gortmaker@windriver.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Paul Gortmaker Nov. 9, 2012, 2:43 p.m. UTC
From: Wang Dongsheng <dongsheng.wang@freescale.com>

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.

Cc: Claudiu Manoil <claudiu.manoil@freescale.com>
Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
[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(-)

Comments

Claudiu Manoil Nov. 9, 2012, 4:02 p.m. UTC | #1
On 11/9/2012 4:43 PM, Paul Gortmaker wrote:
> From: Wang Dongsheng <dongsheng.wang@freescale.com>
>
> 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.
>
> Cc: Claudiu Manoil <claudiu.manoil@freescale.com>

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)

Acked-by: Claudiu Manoil <claudiu.manoil@freescale.com>


--
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
David Miller Nov. 9, 2012, 10:08 p.m. UTC | #2
From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Fri,  9 Nov 2012 09:43:51 -0500

> From: Wang Dongsheng <dongsheng.wang@freescale.com>
> 
> 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.
> 
> Cc: Claudiu Manoil <claudiu.manoil@freescale.com>
> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

Applied, thanks.
--
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
diff mbox

Patch

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 1d03dcd..19ac096 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -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);