Skip to content

Commit 7be4cb7

Browse files
jtornosmdavem330
authored andcommitted
net: usb: ax88179_178a: improve reset check
After ecf848e ("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: [email protected] # 6.6+ Fixes: ecf848e ("net: usb: ax88179_178a: fix link status when link is set to down/up") Reported-by: Yongqin Liu <[email protected]> Reported-by: Antje Miederhöfer <[email protected]> Reported-by: Arne Fitzenreiter <[email protected]> Tested-by: Yongqin Liu <[email protected]> Tested-by: Antje Miederhöfer <[email protected]> Signed-off-by: Jose Ignacio Tornos Martinez <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b8c4336 commit 7be4cb7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/net/usb/ax88179_178a.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ struct ax88179_data {
174174
u32 wol_supported;
175175
u32 wolopts;
176176
u8 disconnecting;
177-
u8 initialized;
178177
};
179178

180179
struct ax88179_int_data {
@@ -1678,12 +1677,21 @@ static int ax88179_reset(struct usbnet *dev)
16781677

16791678
static int ax88179_net_reset(struct usbnet *dev)
16801679
{
1681-
struct ax88179_data *ax179_data = dev->driver_priv;
1680+
u16 tmp16;
16821681

1683-
if (ax179_data->initialized)
1682+
ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, GMII_PHY_PHYSR,
1683+
2, &tmp16);
1684+
if (tmp16) {
1685+
ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
1686+
2, 2, &tmp16);
1687+
if (!(tmp16 & AX_MEDIUM_RECEIVE_EN)) {
1688+
tmp16 |= AX_MEDIUM_RECEIVE_EN;
1689+
ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
1690+
2, 2, &tmp16);
1691+
}
1692+
} else {
16841693
ax88179_reset(dev);
1685-
else
1686-
ax179_data->initialized = 1;
1694+
}
16871695

16881696
return 0;
16891697
}

0 commit comments

Comments
 (0)