diff mbox series

[2/2] net: asix: Avoid looping when the device is diconnected

Message ID 20221201175525.2733125-2-l.stach@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/2] net: asix: Simplify return value check after asix_check_host_enable | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 3 maintainers not CCed: shaozhengchao@huawei.com paskripkin@gmail.com linux@rempel-privat.de
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: 'diconnected' may be misspelled - perhaps 'disconnected'?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Lucas Stach Dec. 1, 2022, 5:55 p.m. UTC
We've seen device access fail with -EPROTO when the device has been
recently disconnected and before the USB core had a chance to handle
the disconnect hub event. It doesn't make sense to continue on trying
to enable host access when the adapter is gone.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/usb/asix_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Leon Romanovsky Dec. 4, 2022, 11:48 a.m. UTC | #1
On Thu, Dec 01, 2022 at 06:55:25PM +0100, Lucas Stach wrote:
> We've seen device access fail with -EPROTO when the device has been
> recently disconnected and before the USB core had a chance to handle
> the disconnect hub event. It doesn't make sense to continue on trying
> to enable host access when the adapter is gone.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/net/usb/asix_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
> index be1e103b7a95..28b31e4da020 100644
> --- a/drivers/net/usb/asix_common.c
> +++ b/drivers/net/usb/asix_common.c
> @@ -96,7 +96,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
>  
>  	for (i = 0; i < AX_HOST_EN_RETRIES; ++i) {
>  		ret = asix_set_sw_mii(dev, in_pm);
> -		if (ret == -ENODEV || ret == -ETIMEDOUT)
> +		if (ret == -ENODEV || ret == -ETIMEDOUT || ret == -EPROTO)

It looks like you can put if (ret < 0) here,

>  			break;
>  		usleep_range(1000, 1100);
>  		ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG,
> -- 
> 2.30.2
>
Jakub Kicinski Dec. 6, 2022, 1:17 a.m. UTC | #2
On Sun, 4 Dec 2022 13:48:07 +0200 Leon Romanovsky wrote:
> On Thu, Dec 01, 2022 at 06:55:25PM +0100, Lucas Stach wrote:
> > We've seen device access fail with -EPROTO when the device has been
> > recently disconnected and before the USB core had a chance to handle
> > the disconnect hub event. It doesn't make sense to continue on trying
> > to enable host access when the adapter is gone.
> > 
> > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > ---
> >  drivers/net/usb/asix_common.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
> > index be1e103b7a95..28b31e4da020 100644
> > --- a/drivers/net/usb/asix_common.c
> > +++ b/drivers/net/usb/asix_common.c
> > @@ -96,7 +96,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
> >  
> >  	for (i = 0; i < AX_HOST_EN_RETRIES; ++i) {
> >  		ret = asix_set_sw_mii(dev, in_pm);
> > -		if (ret == -ENODEV || ret == -ETIMEDOUT)
> > +		if (ret == -ENODEV || ret == -ETIMEDOUT || ret == -EPROTO)  
> 
> It looks like you can put if (ret < 0) here,

Right, or we need a clarification in the commit message why it's okay
to continue for other errors (and continue as if the error didn't
happen, not just retry).
diff mbox series

Patch

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index be1e103b7a95..28b31e4da020 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -96,7 +96,7 @@  static int asix_check_host_enable(struct usbnet *dev, int in_pm)
 
 	for (i = 0; i < AX_HOST_EN_RETRIES; ++i) {
 		ret = asix_set_sw_mii(dev, in_pm);
-		if (ret == -ENODEV || ret == -ETIMEDOUT)
+		if (ret == -ENODEV || ret == -ETIMEDOUT || ret == -EPROTO)
 			break;
 		usleep_range(1000, 1100);
 		ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG,