From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: netdev@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
Florian Fainelli <f.fainelli@gmail.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Steve Glendinning <steve.glendinning@shawell.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] smsc911x: avoid PHY being resumed when interface is not up
Date: Thu, 16 Mar 2023 08:45:58 +0100 [thread overview]
Message-ID: <20230316074558.15268-3-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20230316074558.15268-1-wsa+renesas@sang-engineering.com>
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>
---
drivers/net/ethernet/smsc/smsc911x.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 9d12fd54281a..4cc5b9833e8f 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1015,12 +1015,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);
@@ -1033,8 +1028,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);
@@ -1062,6 +1055,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();
@@ -1104,6 +1098,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:
--
2.30.2
prev parent reply other threads:[~2023-03-16 7:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 7:45 [PATCH net 0/2] smsc: fix bugs when interface is not up Wolfram Sang
2023-03-16 7:45 ` [PATCH 1/2] Revert "net: smsc911x: Make Runtime PM handling more fine-grained" Wolfram Sang
2023-03-16 9:07 ` Geert Uytterhoeven
2023-03-17 5:00 ` Wolfram Sang
2023-03-16 7:45 ` Wolfram Sang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230316074558.15268-3-wsa+renesas@sang-engineering.com \
--to=wsa+renesas@sang-engineering.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=geert+renesas@glider.be \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steve.glendinning@shawell.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox