netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] net: phy: relax error checking when creating sysfs link netdev->phydev
@ 2018-03-16 22:08 Grygorii Strashko
  2018-03-16 22:08 ` [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn() Grygorii Strashko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Grygorii Strashko @ 2018-03-16 22:08 UTC (permalink / raw)
  To: David S. Miller, netdev, Andrew Lunn, Florian Fainelli,
	Greg Kroah-Hartman
  Cc: Sekhar Nori, linux-kernel, linux-omap, Grygorii Strashko

Some ethernet drivers (like TI CPSW) may connect and manage >1 Net PHYs per
one netdevice, as result such drivers will produce warning during system
boot and fail to connect second phy to netdevice when PHYLIB framework
will try to create sysfs link netdev->phydev for second PHY
in phy_attach_direct(), because sysfs link with the same name has been
created already for the first PHY.
As result, second CPSW external port will became unusable.
This regression was introduced by commits:
5568363f0cb3 ("net: phy: Create sysfs reciprocal links for attached_dev/phydev"
a3995460491d ("net: phy: Relax error checking on sysfs_create_link()"

Patch 1: exports sysfs_create_link_nowarn() function as preparation for Patch 2.
Patch 2: relaxes error checking when PHYLIB framework is creating sysfs
link netdev->phydev in phy_attach_direct(), suppresses warning by using
sysfs_create_link_nowarn() and adds error message instead, so links creation
failure is not fatal any more and system can continue working,
which fixes TI CPSW issue and makes boot logs accessible
in case of NFS boot, for example.

This can be stable material 4.13+.

Changes in v2:
- commit messages updated.

v1: 
 https://patchwork.ozlabs.org/cover/886058/

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Grygorii Strashko (2):
  sysfs: symlink: export sysfs_create_link_nowarn()
  net: phy: relax error checking when creating sysfs link netdev->phydev

 drivers/net/phy/phy_device.c | 15 +++++++++++----
 fs/sysfs/symlink.c           |  1 +
 2 files changed, 12 insertions(+), 4 deletions(-)

-- 
2.10.5

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

* [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn()
  2018-03-16 22:08 [PATCH v2 0/2] net: phy: relax error checking when creating sysfs link netdev->phydev Grygorii Strashko
@ 2018-03-16 22:08 ` Grygorii Strashko
  2018-03-18 13:13   ` Greg Kroah-Hartman
  2018-03-16 22:08 ` [PATCH v2 2/2] net: phy: relax error checking when creating sysfs link netdev->phydev Grygorii Strashko
  2018-03-20  1:15 ` [PATCH v2 0/2] " David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Grygorii Strashko @ 2018-03-16 22:08 UTC (permalink / raw)
  To: David S. Miller, netdev, Andrew Lunn, Florian Fainelli,
	Greg Kroah-Hartman
  Cc: Sekhar Nori, linux-kernel, linux-omap, Grygorii Strashko

The sysfs_create_link_nowarn() is going to be used in phylib framework in
subsequent patch which can be built as module. Hence, export
sysfs_create_link_nowarn() to avoid build errors.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Fixes: a3995460491d ("net: phy: Relax error checking on sysfs_create_link()")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
"Fixes" added as there is dependency this and subsequent patch.
 fs/sysfs/symlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 8664db2..215c225 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -106,6 +106,7 @@ int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target,
 {
 	return sysfs_do_create_link(kobj, target, name, 0);
 }
+EXPORT_SYMBOL_GPL(sysfs_create_link_nowarn);
 
 /**
  *	sysfs_delete_link - remove symlink in object's directory.
-- 
2.10.5

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

* [PATCH v2 2/2] net: phy: relax error checking when creating sysfs link netdev->phydev
  2018-03-16 22:08 [PATCH v2 0/2] net: phy: relax error checking when creating sysfs link netdev->phydev Grygorii Strashko
  2018-03-16 22:08 ` [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn() Grygorii Strashko
@ 2018-03-16 22:08 ` Grygorii Strashko
  2018-03-20  1:15 ` [PATCH v2 0/2] " David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Grygorii Strashko @ 2018-03-16 22:08 UTC (permalink / raw)
  To: David S. Miller, netdev, Andrew Lunn, Florian Fainelli,
	Greg Kroah-Hartman
  Cc: Sekhar Nori, linux-kernel, linux-omap, Grygorii Strashko

Some ethernet drivers (like TI CPSW) may connect and manage >1 Net PHYs per
one netdevice, as result such drivers will produce warning during system
boot and fail to connect second phy to netdevice when PHYLIB framework
will try to create sysfs link netdev->phydev for second PHY
in phy_attach_direct(), because sysfs link with the same name has been
created already for the first PHY. As result, second CPSW external
port will became unusable.

Fix it by relaxing error checking when PHYLIB framework is creating sysfs
link netdev->phydev in phy_attach_direct(), suppressing warning by using
sysfs_create_link_nowarn() and adding error message instead.
After this change links (phy->netdev and netdev->phy) creation failure is not
fatal any more and system can continue working, which fixes TI CPSW issue.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Fixes: a3995460491d ("net: phy: Relax error checking on sysfs_create_link()")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/phy/phy_device.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 478405e..fe16f58 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1012,10 +1012,17 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 	err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj,
 				"attached_dev");
 	if (!err) {
-		err = sysfs_create_link(&dev->dev.kobj, &phydev->mdio.dev.kobj,
-					"phydev");
-		if (err)
-			goto error;
+		err = sysfs_create_link_nowarn(&dev->dev.kobj,
+					       &phydev->mdio.dev.kobj,
+					       "phydev");
+		if (err) {
+			dev_err(&dev->dev, "could not add device link to %s err %d\n",
+				kobject_name(&phydev->mdio.dev.kobj),
+				err);
+			/* non-fatal - some net drivers can use one netdevice
+			 * with more then one phy
+			 */
+		}
 
 		phydev->sysfs_links = true;
 	}
-- 
2.10.5

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

* Re: [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn()
  2018-03-16 22:08 ` [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn() Grygorii Strashko
@ 2018-03-18 13:13   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-18 13:13 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: David S. Miller, netdev, Andrew Lunn, Florian Fainelli,
	Sekhar Nori, linux-kernel, linux-omap

On Fri, Mar 16, 2018 at 05:08:34PM -0500, Grygorii Strashko wrote:
> The sysfs_create_link_nowarn() is going to be used in phylib framework in
> subsequent patch which can be built as module. Hence, export
> sysfs_create_link_nowarn() to avoid build errors.
> 
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Fixes: a3995460491d ("net: phy: Relax error checking on sysfs_create_link()")

This specific patch doesn't fix anything, it just _allows_ it to be
fixed in the second patch :)

Anyway, just a nit...

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH v2 0/2] net: phy: relax error checking when creating sysfs link netdev->phydev
  2018-03-16 22:08 [PATCH v2 0/2] net: phy: relax error checking when creating sysfs link netdev->phydev Grygorii Strashko
  2018-03-16 22:08 ` [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn() Grygorii Strashko
  2018-03-16 22:08 ` [PATCH v2 2/2] net: phy: relax error checking when creating sysfs link netdev->phydev Grygorii Strashko
@ 2018-03-20  1:15 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-03-20  1:15 UTC (permalink / raw)
  To: grygorii.strashko
  Cc: netdev, andrew, f.fainelli, gregkh, nsekhar, linux-kernel, linux-omap

From: Grygorii Strashko <grygorii.strashko@ti.com>
Date: Fri, 16 Mar 2018 17:08:33 -0500

> Some ethernet drivers (like TI CPSW) may connect and manage >1 Net PHYs per
> one netdevice, as result such drivers will produce warning during system
> boot and fail to connect second phy to netdevice when PHYLIB framework
> will try to create sysfs link netdev->phydev for second PHY
> in phy_attach_direct(), because sysfs link with the same name has been
> created already for the first PHY.
> As result, second CPSW external port will became unusable.
> This regression was introduced by commits:
> 5568363f0cb3 ("net: phy: Create sysfs reciprocal links for attached_dev/phydev"
> a3995460491d ("net: phy: Relax error checking on sysfs_create_link()"
> 
> Patch 1: exports sysfs_create_link_nowarn() function as preparation for Patch 2.
> Patch 2: relaxes error checking when PHYLIB framework is creating sysfs
> link netdev->phydev in phy_attach_direct(), suppresses warning by using
> sysfs_create_link_nowarn() and adds error message instead, so links creation
> failure is not fatal any more and system can continue working,
> which fixes TI CPSW issue and makes boot logs accessible
> in case of NFS boot, for example.

Series applied and queued up for -stable, thanks.

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

end of thread, other threads:[~2018-03-20  1:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-16 22:08 [PATCH v2 0/2] net: phy: relax error checking when creating sysfs link netdev->phydev Grygorii Strashko
2018-03-16 22:08 ` [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn() Grygorii Strashko
2018-03-18 13:13   ` Greg Kroah-Hartman
2018-03-16 22:08 ` [PATCH v2 2/2] net: phy: relax error checking when creating sysfs link netdev->phydev Grygorii Strashko
2018-03-20  1:15 ` [PATCH v2 0/2] " David Miller

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).