Skip to content

Commit a5feba7

Browse files
diandersdavem330
authored andcommitted
r8152: Increase USB control msg timeout to 5000ms as per spec
According to the comment next to USB_CTRL_GET_TIMEOUT and USB_CTRL_SET_TIMEOUT, although sending/receiving control messages is usually quite fast, the spec allows them to take up to 5 seconds. Let's increase the timeout in the Realtek driver from 500ms to 5000ms (using the #defines) to account for this. This is not just a theoretical change. The need for the longer timeout was seen in testing. Specifically, if you drop a sc7180-trogdor based Chromebook into the kdb debugger and then "go" again after sitting in the debugger for a while, the next USB control message takes a long time. Out of ~40 tests the slowest USB control message was 4.5 seconds. While dropping into kdb is not exactly an end-user scenario, the above is similar to what could happen due to an temporary interrupt storm, what could happen if there was a host controller (HW or SW) issue, or what could happen if the Realtek device got into a confused state and needed time to recover. This change is fairly critical since the r8152 driver in Linux doesn't expect register reads/writes (which are backed by USB control messages) to fail. Fixes: ac718b6 ("net/usb: new driver for RTL8152") Suggested-by: Hayes Wang <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: Grant Grundler <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 51a32e8 commit a5feba7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/net/usb/r8152.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ int get_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data)
12121212

12131213
ret = usb_control_msg(tp->udev, tp->pipe_ctrl_in,
12141214
RTL8152_REQ_GET_REGS, RTL8152_REQT_READ,
1215-
value, index, tmp, size, 500);
1215+
value, index, tmp, size, USB_CTRL_GET_TIMEOUT);
12161216
if (ret < 0)
12171217
memset(data, 0xff, size);
12181218
else
@@ -1235,7 +1235,7 @@ int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data)
12351235

12361236
ret = usb_control_msg(tp->udev, tp->pipe_ctrl_out,
12371237
RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE,
1238-
value, index, tmp, size, 500);
1238+
value, index, tmp, size, USB_CTRL_SET_TIMEOUT);
12391239

12401240
kfree(tmp);
12411241

@@ -9494,7 +9494,8 @@ static u8 __rtl_get_hw_ver(struct usb_device *udev)
94949494

94959495
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
94969496
RTL8152_REQ_GET_REGS, RTL8152_REQT_READ,
9497-
PLA_TCR0, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500);
9497+
PLA_TCR0, MCU_TYPE_PLA, tmp, sizeof(*tmp),
9498+
USB_CTRL_GET_TIMEOUT);
94989499
if (ret > 0)
94999500
ocp_data = (__le32_to_cpu(*tmp) >> 16) & VERSION_MASK;
95009501

0 commit comments

Comments
 (0)