net: phy: relax error checking when creating sysfs link netdev->phydev
Subsystems (4)
v2 cover net: phy: relax error checking when creating sysfs link netdev->phydev
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 <[email protected]>
Cc: Andrew Lunn <[email protected]>
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(-)
Signature · 1 line
2.10.5
PATCH v2 1/2 sysfs: symlink: export sysfs_create_link_nowarn()
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.
---
"Fixes" added as there is dependency this and subsequent patch.
fs/sysfs/symlink.c | 1 + 1 file changed, 1 insertion(+)
fs/sysfs/symlink.c +1 -0
@@ -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.
Signature · 1 line
2.10.5
PATCH v2 2/2 net: phy: relax error checking when creating sysfs link netdev->phydev
In reply to Grygorii StrashkoSome 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.
--- drivers/net/phy/phy_device.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/net/phy/phy_device.c +11 -4
@@ -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; }
Signature · 1 line
2.10.5
Re: [PATCH v2 1/2] sysfs: symlink: export sysfs_create_link_nowarn()
In reply to Grygorii StrashkoQuoted 7 lines · 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, exportsysfs_create_link_nowarn()to avoid build errors.Cc Florian Fainelli <[email protected]>Cc Andrew Lunn <[email protected]>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...
David Miller
maintainerFrom: Grygorii Strashko <[email protected]>
Date: Fri, 16 Mar 2018 17:08:33 -0500
Quoted 11 lines
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->phydevfor second PHY
inphy_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 onsysfs_create_link()"
Quoted 7 lines
Patch 1: exports
sysfs_create_link_nowarn()function as preparation for Patch 2. Patch 2: relaxes error checking when PHYLIB framework is creating sysfs linknetdev->phydevinphy_attach_direct(), suppresses warning by usingsysfs_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.