* [PATCH] net: usb: ax88179_178a: improve reset check
@ 2024-06-17 10:28 Jose Ignacio Tornos Martinez
2024-06-19 9:50 ` patchwork-bot+netdevbpf
2024-06-19 10:37 ` Arne Fitzenreiter
0 siblings, 2 replies; 3+ messages in thread
From: Jose Ignacio Tornos Martinez @ 2024-06-17 10:28 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms, linux-usb, netdev,
linux-kernel
Cc: jtornosm, stable, Yongqin Liu, Antje Miederhöfer,
Arne Fitzenreiter
After ecf848eb934b ("net: usb: ax88179_178a: fix link status when link is
set to down/up") to not reset from usbnet_open after the reset from
usbnet_probe at initialization stage to speed up this, some issues have
been reported.
It seems to happen that if the initialization is slower, and some time
passes between the probe operation and the open operation, the second reset
from open is necessary too to have the device working. The reason is that
if there is no activity with the phy, this is "disconnected".
In order to improve this, the solution is to detect when the phy is
"disconnected", and we can use the phy status register for this. So we will
only reset the device from reset operation in this situation, that is, only
if necessary.
The same bahavior is happening when the device is stopped (link set to
down) and later is restarted (link set to up), so if the phy keeps working
we only need to enable the mac again, but if enough time passes between the
device stop and restart, reset is necessary, and we can detect the
situation checking the phy status register too.
cc: stable@vger.kernel.org # 6.6+
Fixes: ecf848eb934b ("net: usb: ax88179_178a: fix link status when link is set to down/up")
Reported-by: Yongqin Liu <yongqin.liu@linaro.org>
Reported-by: Antje Miederhöfer <a.miederhoefer@gmx.de>
Reported-by: Arne Fitzenreiter <arne_f@ipfire.org>
Tested-by: Yongqin Liu <yongqin.liu@linaro.org>
Tested-by: Antje Miederhöfer <a.miederhoefer@gmx.de>
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
---
drivers/net/usb/ax88179_178a.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 51c295e1e823..c2fb736f78b2 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -174,7 +174,6 @@ struct ax88179_data {
u32 wol_supported;
u32 wolopts;
u8 disconnecting;
- u8 initialized;
};
struct ax88179_int_data {
@@ -1678,12 +1677,21 @@ static int ax88179_reset(struct usbnet *dev)
static int ax88179_net_reset(struct usbnet *dev)
{
- struct ax88179_data *ax179_data = dev->driver_priv;
+ u16 tmp16;
- if (ax179_data->initialized)
+ ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, GMII_PHY_PHYSR,
+ 2, &tmp16);
+ if (tmp16) {
+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+ 2, 2, &tmp16);
+ if (!(tmp16 & AX_MEDIUM_RECEIVE_EN)) {
+ tmp16 |= AX_MEDIUM_RECEIVE_EN;
+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+ 2, 2, &tmp16);
+ }
+ } else {
ax88179_reset(dev);
- else
- ax179_data->initialized = 1;
+ }
return 0;
}
--
2.45.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: usb: ax88179_178a: improve reset check
2024-06-17 10:28 [PATCH] net: usb: ax88179_178a: improve reset check Jose Ignacio Tornos Martinez
@ 2024-06-19 9:50 ` patchwork-bot+netdevbpf
2024-06-19 10:37 ` Arne Fitzenreiter
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-19 9:50 UTC (permalink / raw)
To: Jose Ignacio Tornos Martinez
Cc: davem, edumazet, kuba, pabeni, horms, linux-usb, netdev,
linux-kernel, stable, yongqin.liu, a.miederhoefer, arne_f
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Mon, 17 Jun 2024 12:28:21 +0200 you wrote:
> After ecf848eb934b ("net: usb: ax88179_178a: fix link status when link is
> set to down/up") to not reset from usbnet_open after the reset from
> usbnet_probe at initialization stage to speed up this, some issues have
> been reported.
>
> It seems to happen that if the initialization is slower, and some time
> passes between the probe operation and the open operation, the second reset
> from open is necessary too to have the device working. The reason is that
> if there is no activity with the phy, this is "disconnected".
>
> [...]
Here is the summary with links:
- net: usb: ax88179_178a: improve reset check
https://git.kernel.org/netdev/net/c/7be4cb7189f7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: usb: ax88179_178a: improve reset check
2024-06-17 10:28 [PATCH] net: usb: ax88179_178a: improve reset check Jose Ignacio Tornos Martinez
2024-06-19 9:50 ` patchwork-bot+netdevbpf
@ 2024-06-19 10:37 ` Arne Fitzenreiter
1 sibling, 0 replies; 3+ messages in thread
From: Arne Fitzenreiter @ 2024-06-19 10:37 UTC (permalink / raw)
To: Jose Ignacio Tornos Martinez
Cc: davem, edumazet, kuba, pabeni, horms, linux-usb, netdev,
linux-kernel, stable, Yongqin Liu, Antje Miederhöfer
Hello Jose Ignacio,
this patch fix my issues.
Best regards
Arne
Am 2024-06-17 12:28, schrieb Jose Ignacio Tornos Martinez:
> After ecf848eb934b ("net: usb: ax88179_178a: fix link status when link
> is
> set to down/up") to not reset from usbnet_open after the reset from
> usbnet_probe at initialization stage to speed up this, some issues have
> been reported.
>
> It seems to happen that if the initialization is slower, and some time
> passes between the probe operation and the open operation, the second
> reset
> from open is necessary too to have the device working. The reason is
> that
> if there is no activity with the phy, this is "disconnected".
>
> In order to improve this, the solution is to detect when the phy is
> "disconnected", and we can use the phy status register for this. So we
> will
> only reset the device from reset operation in this situation, that is,
> only
> if necessary.
>
> The same bahavior is happening when the device is stopped (link set to
> down) and later is restarted (link set to up), so if the phy keeps
> working
> we only need to enable the mac again, but if enough time passes between
> the
> device stop and restart, reset is necessary, and we can detect the
> situation checking the phy status register too.
>
> cc: stable@vger.kernel.org # 6.6+
> Fixes: ecf848eb934b ("net: usb: ax88179_178a: fix link status when link
> is set to down/up")
> Reported-by: Yongqin Liu <yongqin.liu@linaro.org>
> Reported-by: Antje Miederhöfer <a.miederhoefer@gmx.de>
> Reported-by: Arne Fitzenreiter <arne_f@ipfire.org>
> Tested-by: Yongqin Liu <yongqin.liu@linaro.org>
> Tested-by: Antje Miederhöfer <a.miederhoefer@gmx.de>
> Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
> ---
> drivers/net/usb/ax88179_178a.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/usb/ax88179_178a.c
> b/drivers/net/usb/ax88179_178a.c
> index 51c295e1e823..c2fb736f78b2 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -174,7 +174,6 @@ struct ax88179_data {
> u32 wol_supported;
> u32 wolopts;
> u8 disconnecting;
> - u8 initialized;
> };
>
> struct ax88179_int_data {
> @@ -1678,12 +1677,21 @@ static int ax88179_reset(struct usbnet *dev)
>
> static int ax88179_net_reset(struct usbnet *dev)
> {
> - struct ax88179_data *ax179_data = dev->driver_priv;
> + u16 tmp16;
>
> - if (ax179_data->initialized)
> + ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, GMII_PHY_PHYSR,
> + 2, &tmp16);
> + if (tmp16) {
> + ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
> + 2, 2, &tmp16);
> + if (!(tmp16 & AX_MEDIUM_RECEIVE_EN)) {
> + tmp16 |= AX_MEDIUM_RECEIVE_EN;
> + ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
> + 2, 2, &tmp16);
> + }
> + } else {
> ax88179_reset(dev);
> - else
> - ax179_data->initialized = 1;
> + }
>
> return 0;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-19 10:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 10:28 [PATCH] net: usb: ax88179_178a: improve reset check Jose Ignacio Tornos Martinez
2024-06-19 9:50 ` patchwork-bot+netdevbpf
2024-06-19 10:37 ` Arne Fitzenreiter
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).