* [PATCH REPOST net-next 1/2] r8152: If inaccessible at resume time, issue a reset
@ 2024-05-30 23:43 Douglas Anderson
2024-06-03 6:39 ` Hayes Wang
2024-06-04 2:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Douglas Anderson @ 2024-05-30 23:43 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Hayes Wang
Cc: danielgeorgem, Douglas Anderson, Andrew Lunn, Grant Grundler,
Heiner Kallweit, linux-kernel, linux-usb, netdev
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: Douglas Anderson <dianders@chromium.org>
---
Reposting now that the merge window is open as per [1].
[1] https://lore.kernel.org/r/75651199a933427a7fc3980ef8a2139f5f1f1695.camel@redhat.com
drivers/net/usb/r8152.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 19df1cd9f072..6a3f4b2114ee 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -8554,6 +8554,19 @@ static int rtl8152_system_resume(struct r8152 *tp)
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;
}
--
2.45.1.288.g0e0cd299f1-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH REPOST net-next 1/2] r8152: If inaccessible at resume time, issue a reset
2024-05-30 23:43 [PATCH REPOST net-next 1/2] r8152: If inaccessible at resume time, issue a reset Douglas Anderson
@ 2024-06-03 6:39 ` Hayes Wang
2024-06-04 2:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Hayes Wang @ 2024-06-03 6:39 UTC (permalink / raw)
To: Douglas Anderson, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: danielgeorgem@google.com, Andrew Lunn, Grant Grundler,
Heiner Kallweit, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, netdev@vger.kernel.org
Douglas Anderson <dianders@chromium.org>
> Sent: Friday, May 31, 2024 7:43 AM
[...]
> 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: Douglas Anderson <dianders@chromium.org>
Acked-by: Hayes Wang <hayeswang@realtek.com>
Best Regards,
Hayes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH REPOST net-next 1/2] r8152: If inaccessible at resume time, issue a reset
2024-05-30 23:43 [PATCH REPOST net-next 1/2] r8152: If inaccessible at resume time, issue a reset Douglas Anderson
2024-06-03 6:39 ` Hayes Wang
@ 2024-06-04 2:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-04 2:00 UTC (permalink / raw)
To: Doug Anderson
Cc: davem, edumazet, kuba, pabeni, hayeswang, danielgeorgem, andrew,
grundler, hkallweit1, linux-kernel, linux-usb, netdev
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 30 May 2024 16:43:08 -0700 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [REPOST,net-next,1/2] r8152: If inaccessible at resume time, issue a reset
https://git.kernel.org/netdev/net-next/c/4933b066fefb
- [REPOST,net-next,2/2] r8152: Wake up the system if the we need a reset
https://git.kernel.org/netdev/net-next/c/8c1d92a740c0
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
end of thread, other threads:[~2024-06-04 2:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-30 23:43 [PATCH REPOST net-next 1/2] r8152: If inaccessible at resume time, issue a reset Douglas Anderson
2024-06-03 6:39 ` Hayes Wang
2024-06-04 2:00 ` patchwork-bot+netdevbpf
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).