Message ID | 20230320092041.1656-3-wsa+renesas@sang-engineering.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | smsc911x: fix issues when interface is not up yet | expand |
Context | Check | Description |
---|---|---|
netdev/series_format | success | Posting correctly formatted |
netdev/tree_selection | success | Clearly marked for net |
netdev/fixes_present | success | Fixes tag present in non-next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 18 this patch: 18 |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/build_clang | success | Errors and warnings before: 18 this patch: 18 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 18 this patch: 18 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 42 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Mon, Mar 20, 2023 at 10:20:41AM +0100, Wolfram Sang wrote: > SMSC911x doesn't need mdiobus suspend/resume, that's why it sets > 'mac_managed_pm'. However, setting it needs to be moved from init to > probe, so mdiobus PM functions will really never be called (e.g. when > the interface is not up yet during suspend/resume). The errno is changed > because ENODEV has a special meaning when returned in probe(). > > Fixes: 3ce9f2bef755 ("net: smsc911x: Stop and start PHY during suspend and resume") > Suggested-by: Heiner Kallweit <hkallweit1@gmail.com> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Simon Horman <simon.horman@corigine.com>
On Mon, 2023-03-20 at 10:20 +0100, Wolfram Sang wrote: > SMSC911x doesn't need mdiobus suspend/resume, that's why it sets > 'mac_managed_pm'. However, setting it needs to be moved from init to > probe, so mdiobus PM functions will really never be called (e.g. when > the interface is not up yet during suspend/resume). The errno is changed > because ENODEV has a special meaning when returned in probe(). > > Fixes: 3ce9f2bef755 ("net: smsc911x: Stop and start PHY during suspend and resume") > Suggested-by: Heiner Kallweit <hkallweit1@gmail.com> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> > --- > Changes since v1: > * no change > > In smsc911x_mii_probe(), I remove the sanity check for 'phydev' because > it was already done in smsc911x_mii_init(). Let me know if this is > acceptable or if a more defensive approach is favoured. Since this is a fix, I would keep the old check, too. > @@ -1108,6 +1102,15 @@ static int smsc911x_mii_init(struct platform_device *pdev, > goto err_out_free_bus_2; > } > > + phydev = phy_find_first(pdata->mii_bus); > + if (!phydev) { > + netdev_err(dev, "no PHY found\n"); > + err = -ENOENT; > + goto err_out_free_bus_2; Why don't you call mdiobus_unregister() in this error path? mdiobus_register() completed successfully a few lines above. Cheers, Paolo
Hi Paolo, > > In smsc911x_mii_probe(), I remove the sanity check for 'phydev' because > > it was already done in smsc911x_mii_init(). Let me know if this is > > acceptable or if a more defensive approach is favoured. > > Since this is a fix, I would keep the old check, too. Yes, makes sense. > > + phydev = phy_find_first(pdata->mii_bus); > > + if (!phydev) { > > + netdev_err(dev, "no PHY found\n"); > > + err = -ENOENT; > > + goto err_out_free_bus_2; > > Why don't you call mdiobus_unregister() in this error path? Oversight. I will fix it. Thank you for the review!
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 67cb5eb9c716..8b875bbbc05e 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -1019,12 +1019,7 @@ static int smsc911x_mii_probe(struct net_device *dev) struct phy_device *phydev = NULL; int ret; - /* find the first phy */ phydev = phy_find_first(pdata->mii_bus); - if (!phydev) { - netdev_err(dev, "no PHY found\n"); - return -ENODEV; - } SMSC_TRACE(pdata, probe, "PHY: addr %d, phy_id 0x%08X", phydev->mdio.addr, phydev->phy_id); @@ -1037,8 +1032,6 @@ static int smsc911x_mii_probe(struct net_device *dev) return ret; } - /* Indicate that the MAC is responsible for managing PHY PM */ - phydev->mac_managed_pm = true; phy_attached_info(phydev); phy_set_max_speed(phydev, SPEED_100); @@ -1066,6 +1059,7 @@ static int smsc911x_mii_init(struct platform_device *pdev, struct net_device *dev) { struct smsc911x_data *pdata = netdev_priv(dev); + struct phy_device *phydev; int err = -ENXIO; pdata->mii_bus = mdiobus_alloc(); @@ -1108,6 +1102,15 @@ static int smsc911x_mii_init(struct platform_device *pdev, goto err_out_free_bus_2; } + phydev = phy_find_first(pdata->mii_bus); + if (!phydev) { + netdev_err(dev, "no PHY found\n"); + err = -ENOENT; + goto err_out_free_bus_2; + } + + phydev->mac_managed_pm = true; + return 0; err_out_free_bus_2:
SMSC911x doesn't need mdiobus suspend/resume, that's why it sets 'mac_managed_pm'. However, setting it needs to be moved from init to probe, so mdiobus PM functions will really never be called (e.g. when the interface is not up yet during suspend/resume). The errno is changed because ENODEV has a special meaning when returned in probe(). Fixes: 3ce9f2bef755 ("net: smsc911x: Stop and start PHY during suspend and resume") Suggested-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> --- Changes since v1: * no change In smsc911x_mii_probe(), I remove the sanity check for 'phydev' because it was already done in smsc911x_mii_init(). Let me know if this is acceptable or if a more defensive approach is favoured. drivers/net/ethernet/smsc/smsc911x.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)