[edk2-devel] [edk2-platforms: PATCH 2/3] Platform/RPi3: Gracefully disable USB channel after a timeout

Pete Batard pete at akeo.ie
Wed Jul 17 11:46:44 UTC 2019


From: Michael Brown <mbrown at fensystems.co.uk>

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: Michael Brown <mbrown at fensystems.co.uk>
Signed-off-by: Pete Batard <pete at akeo.ie>
---
 Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
index c1e1229f858e..22d9bd822f96 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;
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43879): https://edk2.groups.io/g/devel/message/43879
Mute This Topic: https://groups.io/mt/32502335/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list