* [PATCH net v2 0/2] smsc911x: fix issues when interface is not up yet
@ 2023-03-20 9:20 Wolfram Sang
2023-03-20 9:20 ` [PATCH net v2 1/2] smsc911x: only update stats when interface is up Wolfram Sang
2023-03-20 9:20 ` [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up Wolfram Sang
0 siblings, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-03-20 9:20 UTC (permalink / raw)
To: netdev; +Cc: linux-renesas-soc, Geert Uytterhoeven, Wolfram Sang, linux-kernel
Similar to upstream commit 7f5ebf5dae42 ("ravb: avoid PHY being resumed
when interface is not up"), here is the fix for SMSC911x (patch 2).
Also, I saw a splat running 'ifconfig' when interface was not up. Patch
1 fixes it. Thank to Geert for a comment on this one.
Patches are based on v6.2-rc3 and tested on a Renesas APE6-EK.
Changes since v1:
* patch 1 is not a revert but a proper fix this time
Wolfram Sang (2):
smsc911x: only update stats when interface is up
smsc911x: avoid PHY being resumed when interface is not up
drivers/net/ethernet/smsc/smsc911x.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v2 1/2] smsc911x: only update stats when interface is up
2023-03-20 9:20 [PATCH net v2 0/2] smsc911x: fix issues when interface is not up yet Wolfram Sang
@ 2023-03-20 9:20 ` Wolfram Sang
2023-03-20 16:32 ` Simon Horman
2023-03-21 16:59 ` Florian Fainelli
2023-03-20 9:20 ` [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up Wolfram Sang
1 sibling, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-03-20 9:20 UTC (permalink / raw)
To: netdev
Cc: linux-renesas-soc, Geert Uytterhoeven, Wolfram Sang,
Steve Glendinning, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel
Otherwise the clocks are not enabled and reading registers will BUG.
Fixes: 1e30b8d755b8 ("net: smsc911x: Make Runtime PM handling more fine-grained")
Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Changes since v1:
* patch is not a revert but a proper fix this time
drivers/net/ethernet/smsc/smsc911x.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index a2e511912e6a..67cb5eb9c716 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1838,8 +1838,12 @@ smsc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
static struct net_device_stats *smsc911x_get_stats(struct net_device *dev)
{
struct smsc911x_data *pdata = netdev_priv(dev);
- smsc911x_tx_update_txcounters(dev);
- dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
+
+ if (netif_running(dev)) {
+ smsc911x_tx_update_txcounters(dev);
+ dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
+ }
+
return &dev->stats;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up
2023-03-20 9:20 [PATCH net v2 0/2] smsc911x: fix issues when interface is not up yet Wolfram Sang
2023-03-20 9:20 ` [PATCH net v2 1/2] smsc911x: only update stats when interface is up Wolfram Sang
@ 2023-03-20 9:20 ` Wolfram Sang
2023-03-20 16:33 ` Simon Horman
2023-03-21 14:39 ` Paolo Abeni
1 sibling, 2 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-03-20 9:20 UTC (permalink / raw)
To: netdev
Cc: linux-renesas-soc, Geert Uytterhoeven, Wolfram Sang,
Heiner Kallweit, Steve Glendinning, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Florian Fainelli,
linux-kernel
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(-)
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:
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 1/2] smsc911x: only update stats when interface is up
2023-03-20 9:20 ` [PATCH net v2 1/2] smsc911x: only update stats when interface is up Wolfram Sang
@ 2023-03-20 16:32 ` Simon Horman
2023-03-21 16:59 ` Florian Fainelli
1 sibling, 0 replies; 8+ messages in thread
From: Simon Horman @ 2023-03-20 16:32 UTC (permalink / raw)
To: Wolfram Sang
Cc: netdev, linux-renesas-soc, Geert Uytterhoeven, Steve Glendinning,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel
On Mon, Mar 20, 2023 at 10:20:40AM +0100, Wolfram Sang wrote:
> Otherwise the clocks are not enabled and reading registers will BUG.
>
> Fixes: 1e30b8d755b8 ("net: smsc911x: Make Runtime PM handling more fine-grained")
> Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up
2023-03-20 9:20 ` [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up Wolfram Sang
@ 2023-03-20 16:33 ` Simon Horman
2023-03-21 14:39 ` Paolo Abeni
1 sibling, 0 replies; 8+ messages in thread
From: Simon Horman @ 2023-03-20 16:33 UTC (permalink / raw)
To: Wolfram Sang
Cc: netdev, linux-renesas-soc, Geert Uytterhoeven, Heiner Kallweit,
Steve Glendinning, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Florian Fainelli, linux-kernel
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>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up
2023-03-20 9:20 ` [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up Wolfram Sang
2023-03-20 16:33 ` Simon Horman
@ 2023-03-21 14:39 ` Paolo Abeni
2023-03-21 17:56 ` Wolfram Sang
1 sibling, 1 reply; 8+ messages in thread
From: Paolo Abeni @ 2023-03-21 14:39 UTC (permalink / raw)
To: Wolfram Sang, netdev
Cc: linux-renesas-soc, Geert Uytterhoeven, Heiner Kallweit,
Steve Glendinning, David S. Miller, Eric Dumazet, Jakub Kicinski,
Florian Fainelli, linux-kernel
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 1/2] smsc911x: only update stats when interface is up
2023-03-20 9:20 ` [PATCH net v2 1/2] smsc911x: only update stats when interface is up Wolfram Sang
2023-03-20 16:32 ` Simon Horman
@ 2023-03-21 16:59 ` Florian Fainelli
1 sibling, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2023-03-21 16:59 UTC (permalink / raw)
To: Wolfram Sang, netdev
Cc: linux-renesas-soc, Geert Uytterhoeven, Steve Glendinning,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel
On 3/20/23 02:20, Wolfram Sang wrote:
> Otherwise the clocks are not enabled and reading registers will BUG.
>
> Fixes: 1e30b8d755b8 ("net: smsc911x: Make Runtime PM handling more fine-grained")
> Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up
2023-03-21 14:39 ` Paolo Abeni
@ 2023-03-21 17:56 ` Wolfram Sang
0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2023-03-21 17:56 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, linux-renesas-soc, Geert Uytterhoeven, Heiner Kallweit,
Steve Glendinning, David S. Miller, Eric Dumazet, Jakub Kicinski,
Florian Fainelli, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 603 bytes --]
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!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-03-21 17:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20 9:20 [PATCH net v2 0/2] smsc911x: fix issues when interface is not up yet Wolfram Sang
2023-03-20 9:20 ` [PATCH net v2 1/2] smsc911x: only update stats when interface is up Wolfram Sang
2023-03-20 16:32 ` Simon Horman
2023-03-21 16:59 ` Florian Fainelli
2023-03-20 9:20 ` [PATCH net v2 2/2] smsc911x: avoid PHY being resumed when interface is not up Wolfram Sang
2023-03-20 16:33 ` Simon Horman
2023-03-21 14:39 ` Paolo Abeni
2023-03-21 17:56 ` Wolfram Sang
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).