* [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable
@ 2022-12-01 17:55 Lucas Stach
2022-12-01 17:55 ` [PATCH 2/2] net: asix: Avoid looping when the device is diconnected Lucas Stach
2022-12-04 11:46 ` [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable Leon Romanovsky
0 siblings, 2 replies; 5+ messages in thread
From: Lucas Stach @ 2022-12-01 17:55 UTC (permalink / raw)
To: linux-usb, netdev
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
kernel, patchwork-lst
Any negative return value from this function is indicative of an
error. Simplify the condition to cover all possible error codes.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
drivers/net/usb/asix_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 72ffc89b477a..be1e103b7a95 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -504,7 +504,7 @@ static int __asix_mdio_read(struct net_device *netdev, int phy_id, int loc,
mutex_lock(&dev->phy_mutex);
ret = asix_check_host_enable(dev, in_pm);
- if (ret == -ENODEV || ret == -ETIMEDOUT) {
+ if (ret < 0) {
mutex_unlock(&dev->phy_mutex);
return ret;
}
@@ -542,7 +542,7 @@ static int __asix_mdio_write(struct net_device *netdev, int phy_id, int loc,
mutex_lock(&dev->phy_mutex);
ret = asix_check_host_enable(dev, in_pm);
- if (ret == -ENODEV)
+ if (ret < 0)
goto out;
ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2,
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] net: asix: Avoid looping when the device is diconnected
2022-12-01 17:55 [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable Lucas Stach
@ 2022-12-01 17:55 ` Lucas Stach
2022-12-04 11:48 ` Leon Romanovsky
2022-12-04 11:46 ` [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable Leon Romanovsky
1 sibling, 1 reply; 5+ messages in thread
From: Lucas Stach @ 2022-12-01 17:55 UTC (permalink / raw)
To: linux-usb, netdev
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
kernel, patchwork-lst
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)
break;
usleep_range(1000, 1100);
ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG,
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable
2022-12-01 17:55 [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable Lucas Stach
2022-12-01 17:55 ` [PATCH 2/2] net: asix: Avoid looping when the device is diconnected Lucas Stach
@ 2022-12-04 11:46 ` Leon Romanovsky
1 sibling, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2022-12-04 11:46 UTC (permalink / raw)
To: Lucas Stach
Cc: linux-usb, netdev, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, kernel, patchwork-lst
On Thu, Dec 01, 2022 at 06:55:24PM +0100, Lucas Stach wrote:
> Any negative return value from this function is indicative of an
> error. Simplify the condition to cover all possible error codes.
Some calls to asix_read_cmd() in asix_check_host_enable() return -ENODATA
and such are simply skipped (... continue ...). It is unclear if it
indicates an error or not.
Thanks
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> drivers/net/usb/asix_common.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
> index 72ffc89b477a..be1e103b7a95 100644
> --- a/drivers/net/usb/asix_common.c
> +++ b/drivers/net/usb/asix_common.c
> @@ -504,7 +504,7 @@ static int __asix_mdio_read(struct net_device *netdev, int phy_id, int loc,
> mutex_lock(&dev->phy_mutex);
>
> ret = asix_check_host_enable(dev, in_pm);
> - if (ret == -ENODEV || ret == -ETIMEDOUT) {
> + if (ret < 0) {
> mutex_unlock(&dev->phy_mutex);
> return ret;
> }
> @@ -542,7 +542,7 @@ static int __asix_mdio_write(struct net_device *netdev, int phy_id, int loc,
> mutex_lock(&dev->phy_mutex);
>
> ret = asix_check_host_enable(dev, in_pm);
> - if (ret == -ENODEV)
> + if (ret < 0)
> goto out;
>
> ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2,
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] net: asix: Avoid looping when the device is diconnected
2022-12-01 17:55 ` [PATCH 2/2] net: asix: Avoid looping when the device is diconnected Lucas Stach
@ 2022-12-04 11:48 ` Leon Romanovsky
2022-12-06 1:17 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2022-12-04 11:48 UTC (permalink / raw)
To: Lucas Stach
Cc: linux-usb, netdev, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, kernel, patchwork-lst
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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] net: asix: Avoid looping when the device is diconnected
2022-12-04 11:48 ` Leon Romanovsky
@ 2022-12-06 1:17 ` Jakub Kicinski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2022-12-06 1:17 UTC (permalink / raw)
To: Leon Romanovsky, Lucas Stach
Cc: linux-usb, netdev, David S . Miller, Eric Dumazet, Paolo Abeni,
kernel, patchwork-lst
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).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-06 1:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 17:55 [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable Lucas Stach
2022-12-01 17:55 ` [PATCH 2/2] net: asix: Avoid looping when the device is diconnected Lucas Stach
2022-12-04 11:48 ` Leon Romanovsky
2022-12-06 1:17 ` Jakub Kicinski
2022-12-04 11:46 ` [PATCH 1/2] net: asix: Simplify return value check after asix_check_host_enable Leon Romanovsky
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).