mbox series

[0/2] USB fixes: (Re)implement timeouts

Message ID 20231029-usb-fixes-5-v1-0-54bb13001f54@marcan.st
Headers show
Series USB fixes: (Re)implement timeouts | expand

Message

Hector Martin Oct. 29, 2023, 7:36 a.m. UTC
A long time ago, the USB code was interrupt-driven and used top-level
timeout handling. This has long been obsolete, and that code is just
broken dead cruft. HC drivers instead hardcode timeouts today.

We need to be able to specify timeouts explicitly to handle cases like
USB hard disks spinning up, without having ridiculously long timeouts
across the board (which would cause endless waiting when things go
wrong anywhere else). So, it's time to rip out the old broken nonsense
and actually pass through timeouts to USB host controller drivers, so
they can be implemented properly.

This series adds the necessary top-level scaffolding for control/bulk
timeouts, and implements them in xHCI. I didn't bother with interrupt
transfers, since I figure those probably never need long timeouts
anyway.

The platform I deal with only has xHCI, so I'll leave implementing this
for EHCI/OHCI to someone else if anyone cares :)

This series needs to be applied after [1], since the xHCI changes depend
on changes made there.

[1] https://lore.kernel.org/u-boot/20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st/

Signed-off-by: Hector Martin <marcan@marcan.st>
---
Hector Martin (2):
      usb: Pass through timeout to drivers
      usb: xhci: Hook up timeouts

 common/usb.c                    | 21 ++-------------------
 drivers/usb/host/ehci-hcd.c     |  5 +++--
 drivers/usb/host/ohci-hcd.c     |  5 +++--
 drivers/usb/host/r8a66597-hcd.c |  5 +++--
 drivers/usb/host/usb-sandbox.c  |  6 ++++--
 drivers/usb/host/usb-uclass.c   |  9 +++++----
 drivers/usb/host/xhci-ring.c    | 32 ++++++++++++++++++++------------
 drivers/usb/host/xhci.c         | 28 ++++++++++++++++------------
 include/usb.h                   | 10 ++++++----
 include/usb/xhci.h              | 14 ++++++++++----
 10 files changed, 72 insertions(+), 63 deletions(-)
---
base-commit: 3d5d748e4d66b98109669c05d0c473fe67795801
change-id: 20231029-usb-fixes-5-ca87bbedb40c

Best regards,

Comments

Marek Vasut Oct. 29, 2023, 11:35 a.m. UTC | #1
On 10/29/23 08:36, Hector Martin wrote:
> A long time ago, the USB code was interrupt-driven and used top-level
> timeout handling. This has long been obsolete, and that code is just
> broken dead cruft. HC drivers instead hardcode timeouts today.
> 
> We need to be able to specify timeouts explicitly to handle cases like
> USB hard disks spinning up, without having ridiculously long timeouts
> across the board (which would cause endless waiting when things go
> wrong anywhere else). So, it's time to rip out the old broken nonsense
> and actually pass through timeouts to USB host controller drivers, so
> they can be implemented properly.

I like this.

[...]
Neal Gompa Oct. 29, 2023, 2:39 p.m. UTC | #2
On Sun, Oct 29, 2023 at 3:36 AM Hector Martin <marcan@marcan.st> wrote:
>
> A long time ago, the USB code was interrupt-driven and used top-level
> timeout handling. This has long been obsolete, and that code is just
> broken dead cruft. HC drivers instead hardcode timeouts today.
>
> We need to be able to specify timeouts explicitly to handle cases like
> USB hard disks spinning up, without having ridiculously long timeouts
> across the board (which would cause endless waiting when things go
> wrong anywhere else). So, it's time to rip out the old broken nonsense
> and actually pass through timeouts to USB host controller drivers, so
> they can be implemented properly.
>
> This series adds the necessary top-level scaffolding for control/bulk
> timeouts, and implements them in xHCI. I didn't bother with interrupt
> transfers, since I figure those probably never need long timeouts
> anyway.
>
> The platform I deal with only has xHCI, so I'll leave implementing this
> for EHCI/OHCI to someone else if anyone cares :)
>
> This series needs to be applied after [1], since the xHCI changes depend
> on changes made there.
>
> [1] https://lore.kernel.org/u-boot/20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st/
>
> Signed-off-by: Hector Martin <marcan@marcan.st>
> ---
> Hector Martin (2):
>       usb: Pass through timeout to drivers
>       usb: xhci: Hook up timeouts
>
>  common/usb.c                    | 21 ++-------------------
>  drivers/usb/host/ehci-hcd.c     |  5 +++--
>  drivers/usb/host/ohci-hcd.c     |  5 +++--
>  drivers/usb/host/r8a66597-hcd.c |  5 +++--
>  drivers/usb/host/usb-sandbox.c  |  6 ++++--
>  drivers/usb/host/usb-uclass.c   |  9 +++++----
>  drivers/usb/host/xhci-ring.c    | 32 ++++++++++++++++++++------------
>  drivers/usb/host/xhci.c         | 28 ++++++++++++++++------------
>  include/usb.h                   | 10 ++++++----
>  include/usb/xhci.h              | 14 ++++++++++----
>  10 files changed, 72 insertions(+), 63 deletions(-)
> ---
> base-commit: 3d5d748e4d66b98109669c05d0c473fe67795801
> change-id: 20231029-usb-fixes-5-ca87bbedb40c
>

Series LGTM.

Reviewed-by: Neal Gompa <neal@gompa.dev>