gianfar: Call netif_carrier_off() prior to registration
PATCH 1/1 gianfar: Call netif_carrier_off() prior to registration
From: Fabio Estevam <[email protected]>
Quoting David Miller:
"At the moment you call register_netdev() the device is visible, notifications are sent to userspace, and userland tools can try to bring the interface up and see the incorrect link state, before you do the netif_carrier_off().
Said another way, between the register_netdev() and netif_carrier_off() call, userspace can see the device in an inconsistent state."
So call netif_carrier_off() prior to register_netdev().
---
This is untested
drivers/net/ethernet/freescale/gianfar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +3 -3
@@ -1384,6 +1384,9 @@ static int gfar_probe(struct platform_device *ofdev)gfar_hw_init (priv); +/* Carrier starts down, phylib will bring it up */ +netif_carrier_off (dev); + err =register_netdev (dev);if (err) {
@@ -1391,9 +1394,6 @@ static int gfar_probe(struct platform_device *ofdev) goto register_fail; } -/* Carrier starts down, phylib will bring it up */ -netif_carrier_off (dev); -device_init_wakeup (&dev->dev, priv->device_flags &FSL_GIANFAR_DEV_HAS_MAGIC_PACKET );
Signature · 1 line
1.8.3.2
2014-06-03 15:55 GMT-07:00 Fabio Estevam <[email protected]>:
Quoted 11 lines
From: Fabio Estevam <[email protected]>
Quoting David Miller:
"At the moment you callregister_netdev()the device is visible, notifications are sent to userspace, and userland tools can try to bring the interface up and see the incorrect link state, before you do thenetif_carrier_off().Said another way, between the
register_netdev()andnetif_carrier_off()call, userspace can see the device in an inconsistent state."So call
netif_carrier_off()prior toregister_netdev().
Potentially all drivers implementing libphy correctly should be fixed to start with a carrier off until the phy library has determined otherwise.
Quoted 39 lines
Signed-off-by Fabio Estevam <[email protected]>---
This is untesteddrivers/net/ethernet/freescale/gianfar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/freescale/gianfar.c +3
-4@@ -1384,6 +1384,9 @@ static int gfar_probe(struct platform_device *ofdev)gfar_hw_init (priv); +/* Carrier starts down, phylib will bring it up */ +netif_carrier_off (dev); + err =register_netdev (dev);if (err) {@@ -1391,9 +1394,6 @@ static int gfar_probe(struct platform_device *ofdev) goto register_fail; } -/* Carrier starts down, phylib will bring it up */ -netif_carrier_off (dev); -device_init_wakeup (&dev->dev, priv->device_flags &FSL_GIANFAR_DEV_HAS_MAGIC_PACKET ); --1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Florian
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Tue, 3 Jun 2014 16:04:49 -0700
Quoted 8 lines
2014-06-03 15:55 GMT-07:00 Fabio Estevam <[email protected]>:
Quoted 7 lines
From: Fabio Estevam <[email protected]>
Quoting David Miller:
"At the moment you callregister_netdev()the device is visible, notifications are sent to userspace, and userland tools can try to bring the interface up and see the incorrect link state, before you do thenetif_carrier_off().
Quoted 8 lines
Quoted 4 lines
Said another way, between the
register_netdev()andnetif_carrier_off()call, userspace can see the device in an inconsistent state."So call
netif_carrier_off()prior toregister_netdev().Potentially all drivers implementing libphy correctly should be fixed to start with a carrier off until the phy library has determined otherwise.
Are you saying we should hold off on this gianfar patch?
Quoted 14 lines · David Miller
From: Florian Fainelli <[email protected]>
Date: Tue, 3 Jun 2014 16:04:49 -0700Quoted 11 lines
2014-06-03 15:55 GMT-07:00 Fabio Estevam <[email protected]>:
Quoted 10 lines
From: Fabio Estevam <[email protected]>
Quoting David Miller:
"At the moment you callregister_netdev()the device is visible, notifications are sent to userspace, and userland tools can try to bring the interface up and see the incorrect link state, before you do thenetif_carrier_off().Said another way, between the
register_netdev()andnetif_carrier_off()call, userspace can see the device in an inconsistent state."
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
So call
netif_carrier_off()prior toregister_netdev().Potentially all drivers implementing libphy correctly should be fixed to start with a carrier off until the phy library has determined otherwise.
Are you saying we should hold off on this gianfar patch?
Not at all, I think this patch is fine. If Fabio wants/can audit the other Freescale drivers I think this should be beneficial. --
Florian
Quoted 2 lines · Florian Fainelli
Not at all, I think this patch is fine. If Fabio wants/can audit the other Freescale drivers I think this should be beneficial.
Yes, I have checked the other Freescale net drivers and the only one with this particular problem was gianfar.
From: Fabio Estevam <[email protected]>
Date: Tue, 3 Jun 2014 19:55:38 -0300
Quoted 7 lines
From: Fabio Estevam <[email protected]>
Quoting David Miller:
"At the moment you callregister_netdev()the device is visible, notifications are sent to userspace, and userland tools can try to bring the interface up and see the incorrect link state, before you do thenetif_carrier_off().
Quoted 6 lines
Said another way, between the
register_netdev()andnetif_carrier_off()call, userspace can see the device in an inconsistent state."So call
netif_carrier_off()prior toregister_netdev().Signed-off-by Fabio Estevam <[email protected]>
Applied, thank you.