From: Andrew Lunn <andrew@lunn.ch>
To: Fabio Estevam <festevam@gmail.com>
Cc: kuba@kernel.org, steve.glendinning@shawell.net,
UNGLinuxDriver@microchip.com, fntoth@gmail.com,
martyn.welch@collabora.com, netdev@vger.kernel.org,
linux-usb@vger.kernel.org, Fabio Estevam <festevam@denx.de>
Subject: Re: [PATCH] smsc95xx: Ignore -ENODEV errors when device is unplugged
Date: Sat, 5 Mar 2022 20:24:51 +0100 [thread overview]
Message-ID: <YiO5Ayetj9aCRkmR@lunn.ch> (raw)
In-Reply-To: <20220305184503.2954013-1-festevam@gmail.com>
On Sat, Mar 05, 2022 at 03:45:03PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
>
> According to Documentation/driver-api/usb/URB.rst when a device
> is unplugged usb_submit_urb() returns -ENODEV.
>
> This error code propagates all the way up to usbnet_read_cmd() and
> usbnet_write_cmd() calls inside the smsc95xx.c driver during
> Ethernet cable unplug, unbind or reboot.
>
> This causes the following errors to be shown on reboot, for example:
>
> ci_hdrc ci_hdrc.1: remove, state 1
> usb usb2: USB disconnect, device number 1
> usb 2-1: USB disconnect, device number 2
> usb 2-1.1: USB disconnect, device number 3
> smsc95xx 2-1.1:1.0 eth1: unregister 'smsc95xx' usb-ci_hdrc.1-1.1, smsc95xx USB 2.0 Ethernet
> smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19
> smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
> smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy
> smsc95xx 2-1.1:1.0 eth1: Failed to read reg index 0x00000114: -19
> smsc95xx 2-1.1:1.0 eth1: Error reading MII_ACCESS
> smsc95xx 2-1.1:1.0 eth1: __smsc95xx_mdio_read: MII is busy
> smsc95xx 2-1.1:1.0 eth1: hardware isn't capable of remote wakeup
> usb 2-1.4: USB disconnect, device number 4
> ci_hdrc ci_hdrc.1: USB bus 2 deregistered
> ci_hdrc ci_hdrc.0: remove, state 4
> usb usb1: USB disconnect, device number 1
> ci_hdrc ci_hdrc.0: USB bus 1 deregistered
> imx2-wdt 30280000.watchdog: Device shutdown: Expect reboot!
> reboot: Restarting system
>
> Ignore the -ENODEV errors inside __smsc95xx_mdio_read() and
> __smsc95xx_phy_wait_not_busy() and do not print error messages
> when -ENODEV is returned.
>
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> ---
> Hi,
>
> Tested on 5.10.102 and 5.17-rc6.
Please indicate what tree this patch is actually for. It should be
against net, since you want it backporting. Please see the netdev FAQ.
Please also include a Fixes: tag.
> @@ -84,7 +84,7 @@ static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
> ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN
> | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> 0, index, &buf, 4);
> - if (unlikely(ret < 0)) {
> + if (ret < 0 && ret != -ENODEV) {
> netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n",
> index, ret);
> return ret;
I suspect this will result in kasan warnings. The contents of buf is
probably undefined because of the error, yet you continue to set *data
to it. You probably need to explicitly handle the ENODEV case setting
*data to some value.
Andrew
next prev parent reply other threads:[~2022-03-05 19:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-05 18:45 [PATCH] smsc95xx: Ignore -ENODEV errors when device is unplugged Fabio Estevam
2022-03-05 19:24 ` Andrew Lunn [this message]
2022-03-05 20:49 ` Fabio Estevam
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=YiO5Ayetj9aCRkmR@lunn.ch \
--to=andrew@lunn.ch \
--cc=UNGLinuxDriver@microchip.com \
--cc=festevam@denx.de \
--cc=festevam@gmail.com \
--cc=fntoth@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=martyn.welch@collabora.com \
--cc=netdev@vger.kernel.org \
--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