Commit 4933b066 authored by Douglas Anderson's avatar Douglas Anderson Committed by Jakub Kicinski

r8152: If inaccessible at resume time, issue a reset

If we happened to get a USB transfer error during the transition to
suspend then the usb_queue_reset_device() that r8152_control_msg()
calls will get dropped on the floor. This is because
usb_lock_device_for_reset() (which usb_queue_reset_device() uses)
silently fails if it's called when a device is suspended or if too
much time passes.

Let's resolve this by resetting the device ourselves in r8152's
resume() function.

NOTE: due to timing, it's _possible_ that we could end up with two USB
resets: the one queued previously and the one called from the resume()
patch. This didn't happen in test cases I ran, though it's conceivably
possible. We can't easily know if this happened since
usb_queue_reset_device() can just silently drop the reset request. In
any case, it's not expected that this is a problem since the two
resets can't run at the same time (because of the device lock) and it
should be OK to reset the device twice. If somehow the double-reset
causes problems we could prevent resets from being queued up while
suspend is running.
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Acked-by: default avatarHayes Wang <hayeswang@realtek.com>
Link: https://lore.kernel.org/r/66590f22.170a0220.8b5ad.1750@mx.google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 83042ce9
...@@ -8554,6 +8554,19 @@ static int rtl8152_system_resume(struct r8152 *tp) ...@@ -8554,6 +8554,19 @@ static int rtl8152_system_resume(struct r8152 *tp)
usb_submit_urb(tp->intr_urb, GFP_NOIO); usb_submit_urb(tp->intr_urb, GFP_NOIO);
} }
/* If the device is RTL8152_INACCESSIBLE here then we should do a
* reset. This is important because the usb_lock_device_for_reset()
* that happens as a result of usb_queue_reset_device() will silently
* fail if the device was suspended or if too much time passed.
*
* NOTE: The device is locked here so we can directly do the reset.
* We don't need usb_lock_device_for_reset() because that's just a
* wrapper over device_lock() and device_resume() (which calls us)
* does that for us.
*/
if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
usb_reset_device(tp->udev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment