]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
Fixed unexpected timeout in Usb MassStorage Driver.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciDxe / Ehci.c
index 13ce7fdfb1f9f9f58b4e57f107e46d12a8103642..07a690edce0788237587137a6e9853cdbd29c3b6 100644 (file)
@@ -126,14 +126,14 @@ EhcReset (
     // Host Controller must be Halt when Reset it\r
     //\r
     if (!EhcIsHalt (Ehc)) {\r
-      Status = EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+      Status = EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
 \r
       if (EFI_ERROR (Status)) {\r
         Status = EFI_DEVICE_ERROR;\r
         goto ON_EXIT;\r
       }\r
     }\r
-\r
+    \r
     //\r
     // Clean up the asynchronous transfers, currently only\r
     // interrupt supports asynchronous operation.\r
@@ -142,7 +142,7 @@ EhcReset (
     EhcAckAllInterrupt (Ehc);\r
     EhcFreeSched (Ehc);\r
 \r
-    Status = EhcResetHC (Ehc, EHC_STALL_1_SECOND);\r
+    Status = EhcResetHC (Ehc, EHC_RESET_TIMEOUT);\r
 \r
     if (EFI_ERROR (Status)) {\r
       goto ON_EXIT;\r
@@ -251,7 +251,7 @@ EhcSetState (
 \r
   switch (State) {\r
   case EfiUsbHcStateHalt:\r
-    Status = EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+    Status = EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
     break;\r
 \r
   case EfiUsbHcStateOperational:\r
@@ -260,7 +260,17 @@ EhcSetState (
       break;\r
     }\r
 \r
-    Status = EhcRunHC (Ehc, EHC_GENERIC_TIME);\r
+    //\r
+    // Software must not write a one to this field unless the host controller\r
+    // is in the Halted state. Doing so will yield undefined results. \r
+    // refers to Spec[EHCI1.0-2.3.1]\r
+    // \r
+    if (!EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT)) {\r
+      Status = EFI_DEVICE_ERROR;\r
+      break;\r
+    }\r
+\r
+    Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);\r
     break;\r
 \r
   case EfiUsbHcStateSuspend:\r
@@ -437,14 +447,14 @@ EhcSetRootHubPortFeature (
     // Make sure Host Controller not halt before reset it\r
     //\r
     if (EhcIsHalt (Ehc)) {\r
-      Status = EhcRunHC (Ehc, EHC_GENERIC_TIME);\r
+      Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);\r
 \r
       if (EFI_ERROR (Status)) {\r
         EHC_DEBUG (("EhcSetRootHubPortFeature :failed to start HC - %r\n", Status));\r
         break;\r
       }\r
     }\r
-\r
+    \r
     //\r
     // Set one to PortReset bit must also set zero to PortEnable bit\r
     //\r
@@ -1539,7 +1549,7 @@ EhcDriverBindingStart (
   // Robustnesss improvement such as for UoL\r
   //\r
   EhcClearLegacySupport (Ehc);\r
-  EhcResetHC (Ehc, EHC_STALL_1_SECOND);\r
+  EhcResetHC (Ehc, EHC_RESET_TIMEOUT);\r
 \r
   Status = EhcInitHC (Ehc);\r
 \r
@@ -1551,12 +1561,12 @@ EhcDriverBindingStart (
   //\r
   // Start the asynchronous interrupt monitor\r
   //\r
-  Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_TIME);\r
+  Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_INTERVAL);\r
 \r
   if (EFI_ERROR (Status)) {\r
     EHC_ERROR (("EhcDriverBindingStart: failed to start async interrupt monitor\n"));\r
 \r
-    EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+    EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
     goto UNINSTALL_USBHC;\r
   }\r
 \r
@@ -1659,8 +1669,8 @@ EhcDriverBindingStop (
   // Stop AsyncRequest Polling timer then stop the EHCI driver\r
   // and uninstall the EHCI protocl.\r
   //\r
-  gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_TIME);\r
-  EhcHaltHC (Ehc, EHC_GENERIC_TIME);\r
+  gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_INTERVAL);\r
+  EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
 \r
   Status = gBS->UninstallProtocolInterface (\r
                   Controller,\r