From: Lukas Wunner <lukas@wunner•de>
To: Oliver Neukum <oneukum@suse•com>
Cc: Oleksij Rempel <o.rempel@pengutronix•de>,
Andrew Lunn <andrew@lunn•ch>,
Oleksij Rempel <linux@rempel-privat•de>,
"netdev@vger•kernel.org" <netdev@vger•kernel.org>,
Heiner Kallweit <hkallweit1@gmail•com>
Subject: Re: ordering of call to unbind() in usbnet_disconnect
Date: Thu, 31 Mar 2022 11:30:40 +0200 [thread overview]
Message-ID: <20220331093040.GA20035@wunner.de> (raw)
In-Reply-To: <37ff78db-8de5-56c0-3da2-9effc17b4e41@suse.com>
On Thu, Mar 31, 2022 at 11:20:50AM +0200, Oliver Neukum wrote:
> I am afraid, putting my
> maintainer's hat on, I have to point on that we have a stable tree for
> which we will need some solution.
>
> Nor can usbnet exclusively cater to device that expose their PHY
> over MDIO. (or at all really). Intuitively I must say that exactly reversing
> the order of probe() in disconnect() is kind of the default.
> If there is a need to deviate from that, of course we will acomodate that,
> but making this the exclusive order is another matter.
>
> I really get that you want to discuss this matter exhaustively, but we
> need to
> come to some kind of conclusion.
I propose the below patch. If you could provide more details on the
regressions you've reported (+ ideally bugzilla links), I'll be happy
to include them in the commit message. Thanks!
-- >8 --
Subject: [PATCH] usbnet: Run unregister_netdev() before unbind() again
Oliver says he got bug reports that commit 2c9d6c2b871d ("usbnet: run
unbind() before unregister_netdev()") is causing regressions.
The commit made binding and unbinding of USB Ethernet asymmetrical:
Before, usbnet_probe() first invoked the ->bind() callback and then
register_netdev(). usbnet_disconnect() mirrored that by first invoking
unregister_netdev() and then ->unbind().
Since the commit, the order in usbnet_disconnect() is reversed and no
longer mirrors usbnet_probe().
One consequence is that a PHY disconnected (and stopped) in ->unbind()
is afterwards stopped once more by unregister_netdev() as it closes the
netdev before unregistering. That necessitates a contortion in ->stop()
because the PHY may only be stopped if it hasn't already been
disconnected.
Reverting the commit allows making the call to phy_stop() unconditional
in ->stop() and also fixes the issues reported by Oliver.
Fixes: 2c9d6c2b871d ("usbnet: run unbind() before unregister_netdev()")
Link: https://lore.kernel.org/netdev/62b944a1-0df2-6e81-397c-6bf9dea266ef@suse.com/
Reported-by: Oliver Neukum <oneukum@suse•com>
Signed-off-by: Lukas Wunner <lukas@wunner•de>
Cc: stable@vger•kernel.org # v5.14+
Cc: Oleksij Rempel <o.rempel@pengutronix•de>
Cc: Martyn Welch <martyn.welch@collabora•com>
Cc: Andrew Lunn <andrew@lunn•ch>
---
drivers/net/usb/asix_devices.c | 6 +-----
drivers/net/usb/smsc95xx.c | 3 +--
drivers/net/usb/usbnet.c | 6 +++---
3 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 4514d35..7d569f0 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -794,11 +794,7 @@ static int ax88772_stop(struct usbnet *dev)
{
struct asix_common_private *priv = dev->driver_priv;
- /* On unplugged USB, we will get MDIO communication errors and the
- * PHY will be set in to PHY_HALTED state.
- */
- if (priv->phydev->state != PHY_HALTED)
- phy_stop(priv->phydev);
+ phy_stop(priv->phydev);
return 0;
}
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 193635e..3dc6df6 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1280,8 +1280,7 @@ static int smsc95xx_start_phy(struct usbnet *dev)
static int smsc95xx_stop(struct usbnet *dev)
{
- if (dev->net->phydev)
- phy_stop(dev->net->phydev);
+ phy_stop(dev->net->phydev);
return 0;
}
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 9a6450f..e8b4a93 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1616,9 +1616,6 @@ void usbnet_disconnect (struct usb_interface *intf)
xdev->bus->bus_name, xdev->devpath,
dev->driver_info->description);
- if (dev->driver_info->unbind)
- dev->driver_info->unbind(dev, intf);
-
net = dev->net;
unregister_netdev (net);
@@ -1626,6 +1623,9 @@ void usbnet_disconnect (struct usb_interface *intf)
usb_scuttle_anchored_urbs(&dev->deferred);
+ if (dev->driver_info->unbind)
+ dev->driver_info->unbind (dev, intf);
+
usb_kill_urb(dev->interrupt);
usb_free_urb(dev->interrupt);
kfree(dev->padding_pkt);
--
2.34.1
next prev parent reply other threads:[~2022-03-31 9:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 11:25 ordering of call to unbind() in usbnet_disconnect Oliver Neukum
2022-03-10 11:38 ` Oleksij Rempel
2022-03-14 18:42 ` Lukas Wunner
2022-03-14 19:14 ` Andrew Lunn
2022-03-15 5:44 ` Oleksij Rempel
2022-03-15 8:32 ` Lukas Wunner
2022-03-15 11:38 ` Oleksij Rempel
2022-03-15 13:28 ` Andrew Lunn
2022-03-17 15:53 ` Oliver Neukum
2022-03-17 21:03 ` Lukas Wunner
2022-03-21 10:17 ` Lukas Wunner
2022-03-21 10:43 ` Oleksij Rempel
2022-03-31 9:35 ` Oliver Neukum
2022-03-21 10:02 ` Lukas Wunner
2022-03-21 13:10 ` Andrew Lunn
2022-03-26 12:39 ` Lukas Wunner
2022-03-26 12:49 ` Andrew Lunn
2022-03-26 13:04 ` Lukas Wunner
2022-03-27 8:37 ` Oleksij Rempel
2022-03-31 9:20 ` Oliver Neukum
2022-03-31 9:30 ` Lukas Wunner [this message]
2022-03-31 9:59 ` Oliver Neukum
2022-03-31 11:22 ` Lukas Wunner
2022-03-26 12:25 ` Lukas Wunner
2022-03-26 12:44 ` Andrew Lunn
2022-03-26 13:01 ` Lukas Wunner
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=20220331093040.GA20035@wunner.de \
--to=lukas@wunner$(echo .)de \
--cc=andrew@lunn$(echo .)ch \
--cc=hkallweit1@gmail$(echo .)com \
--cc=linux@rempel-privat$(echo .)de \
--cc=netdev@vger$(echo .)kernel.org \
--cc=o.rempel@pengutronix$(echo .)de \
--cc=oneukum@suse$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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