From 24614a0e84261706e7f70e6fe3fec2a1f78faa89 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 17 Jul 2019 12:46:44 +0100 Subject: Platform/RPi3: Gracefully disable USB channel after a timeout When a timeout occurs, attempt to gracefully disable the channel. Report a final status of EFI_TIMEOUT if the channel was disabled successfully, or EFI_DEVICE_ERROR if we were unable to disable the channel. Signed-off-by: Pete Batard Reviewed-by: Leif Lindholm --- .../RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Platform') diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c index c1e1229f..22d9bd82 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c @@ -318,13 +318,21 @@ DwHcTransfer ( Ret = Wait4Chhltd (DwHc, Timeout, Channel, &Sub, Pid, IgnoreAck, &Split); if (Ret == XFER_NOT_HALTED) { - /* - * FIXME: do proper channel reset. - */ - MmioWrite32 (DwHc->DwUsbBase + HCCHAR (Channel), DWC2_HCCHAR_CHDIS); - *TransferResult = EFI_USB_ERR_TIMEOUT; - Status = EFI_DEVICE_ERROR; + MmioOr32 (DwHc->DwUsbBase + HCCHAR (Channel), DWC2_HCCHAR_CHDIS); + Status = gBS->SetTimer (Timeout, TimerRelative, + EFI_TIMER_PERIOD_MILLISECONDS (1)); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + break; + } + Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel), + DWC2_HCINT_CHHLTD, 1); + if (Status == EFI_SUCCESS) { + Status = EFI_TIMEOUT; + } else { + Status = EFI_DEVICE_ERROR; + } break; } else if (Ret == XFER_STALL) { *TransferResult = EFI_USB_ERR_STALL; -- cgit v1.2.3