]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.27/net-usb-asix-ax88772_bind-return-error-when-hw_reset.patch
Linux 4.14.105
[thirdparty/kernel/stable-queue.git] / releases / 4.19.27 / net-usb-asix-ax88772_bind-return-error-when-hw_reset.patch
1 From d232a83aad0d3964142933c6b861a4882cffa9c1 Mon Sep 17 00:00:00 2001
2 From: Zhang Run <zhang.run@zte.com.cn>
3 Date: Thu, 24 Jan 2019 13:48:49 +0800
4 Subject: net: usb: asix: ax88772_bind return error when hw_reset fail
5
6 [ Upstream commit 6eea3527e68acc22483f4763c8682f223eb90029 ]
7
8 The ax88772_bind() should return error code immediately when the PHY
9 was not reset properly through ax88772a_hw_reset().
10 Otherwise, The asix_get_phyid() will block when get the PHY
11 Identifier from the PHYSID1 MII registers through asix_mdio_read()
12 due to the PHY isn't ready. Furthermore, it will produce a lot of
13 error message cause system crash.As follows:
14 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to write
15 reg index 0x0000: -71
16 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to send
17 software reset: ffffffb9
18 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to write
19 reg index 0x0000: -71
20 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to enable
21 software MII access
22 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to read
23 reg index 0x0000: -71
24 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to write
25 reg index 0x0000: -71
26 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to enable
27 software MII access
28 asix 1-1:1.0 (unnamed net_device) (uninitialized): Failed to read
29 reg index 0x0000: -71
30 ...
31
32 Signed-off-by: Zhang Run <zhang.run@zte.com.cn>
33 Reviewed-by: Yang Wei <yang.wei9@zte.com.cn>
34 Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
35 Signed-off-by: David S. Miller <davem@davemloft.net>
36 Signed-off-by: Sasha Levin <sashal@kernel.org>
37 ---
38 drivers/net/usb/asix_devices.c | 9 +++++++--
39 1 file changed, 7 insertions(+), 2 deletions(-)
40
41 diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
42 index b654f05b2ccd0..3d93993e74da0 100644
43 --- a/drivers/net/usb/asix_devices.c
44 +++ b/drivers/net/usb/asix_devices.c
45 @@ -739,8 +739,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
46 asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &chipcode, 0);
47 chipcode &= AX_CHIPCODE_MASK;
48
49 - (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) :
50 - ax88772a_hw_reset(dev, 0);
51 + ret = (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) :
52 + ax88772a_hw_reset(dev, 0);
53 +
54 + if (ret < 0) {
55 + netdev_dbg(dev->net, "Failed to reset AX88772: %d\n", ret);
56 + return ret;
57 + }
58
59 /* Read PHYID register *AFTER* the PHY was reset properly */
60 phyid = asix_get_phyid(dev);
61 --
62 2.19.1
63