Subject: Re: ordering of call to unbind() in usbnet_disconnect

From: Lukas Wunner <[email-masked]>
Date: Mon, 14 Mar 2022 19:42:34 +0100

[cc += Heiner Kallweit, Andrew Lunn]

On Thu, Mar 10, 2022 at 12:38:20PM +0100, Oleksij Rempel wrote:
> On Thu, Mar 10, 2022 at 12:25:08PM +0100, Oliver Neukum wrote:
> > I got bug reports that 2c9d6c2b871d ("usbnet: run unbind() before
> > unregister_netdev()")
> > is causing regressions.

I would like to see this reverted as well.  For obvious reasons,
the order in usbnet_disconnect() should be the inverse of
usbnet_probe().  Since 2c9d6c2b871d, that's no longer the case.

> > Rather than simply reverting it,
> > it seems to me that the call needs to be split. One in the old place
> > and one in the place you moved it to.

I disagree.  The commit message claims that the change is necessary
because phy_disconnect() fails if called with phydev->attached_dev == NULL.

I've just gone through the code to check that and the only thing that
caught my eye is an unconditional call to netif_testing_off(dev) in
phy_stop().  It seems to me that making that call conditional on
"if (dev)" would solve the issue.

That's a bug introduced by
   4a459bdc7472 ("net: phy: Put interface into oper testing during cable
                  test")
or 472115d9834c ("net: phy: stop PHY if needed when entering
                  phy_disconnect")
depending on how you look at it.

Thanks,

Lukas

> > Could you tell me which drivers you moved the call for?
> 
> I moved it for asix_devices.c:ax88772_unbind()
> 
> Probably smsc95xx.c:smsc95xx_unbind() has same issue.