]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UsbMass: Not retry if usb bot transfer execution fail
authorFeng Tian <feng.tian@intel.com>
Tue, 19 Jul 2016 05:56:03 +0000 (13:56 +0800)
committerFeng Tian <feng.tian@intel.com>
Wed, 3 Aug 2016 01:52:19 +0000 (09:52 +0800)
The retry mechanism will bring issue if the usb device is unplugged
from XHCI HC but s/w is trying to access it through BlockIo. The
current cmd will get device error return status, but the sequential
cmds will be timeout. This behavior will cause system unresponsive
for a long while and bring bad user experience.

So we break the retry loop if found device error.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c

index 9f996507034f91cfd4486ea0b82034d650fe39d2..96c3622821c754107db9c2c3fc170e08bf7d9e97 100644 (file)
@@ -2,7 +2,7 @@
   Implementation of the command set of USB Mass Storage Specification\r
   for Bootability, Revision 1.0.\r
 \r
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -189,6 +189,11 @@ UsbBootExecCmd (
     return EFI_TIMEOUT;\r
   }\r
 \r
+  if (Status == EFI_DEVICE_ERROR) {\r
+    DEBUG ((EFI_D_ERROR, "UsbBootExecCmd: Device Error to Exec 0x%x Cmd\n", *(UINT8 *)Cmd));\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   //\r
   // If ExecCommand() returns no error and CmdResult is success,\r
   // then the commnad transfer is successful.\r
@@ -271,7 +276,7 @@ UsbBootExecCmdWithRetry (
                DataLen,\r
                Timeout\r
                );\r
-    if (Status == EFI_SUCCESS || Status == EFI_MEDIA_CHANGED || Status == EFI_NO_MEDIA) {\r
+    if (Status == EFI_SUCCESS || Status == EFI_MEDIA_CHANGED || Status == EFI_NO_MEDIA || Status == EFI_DEVICE_ERROR) {\r
       break;\r
     }\r
     //\r
index dd83540285770be023d22c4f7c263c39a13fac8b..0767ff0942711522be69d1673e943b90071bffe4 100644 (file)
@@ -2,7 +2,7 @@
   Implementation of the USB mass storage Bulk-Only Transport protocol,\r
   according to USB Mass Storage Class Bulk-Only Transport, Revision 1.0.\r
 \r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -432,7 +432,11 @@ UsbBotExecCommand (
   // whether it succeeds or fails.\r
   //\r
   TransLen = (UINTN) DataLen;\r
-  UsbBotDataTransfer (UsbBot, DataDir, Data, &TransLen, Timeout);\r
+  Status   = UsbBotDataTransfer (UsbBot, DataDir, Data, &TransLen, Timeout);\r
+  if (Status == EFI_DEVICE_ERROR) {\r
+    DEBUG ((EFI_D_ERROR, "UsbBotExecCommand: UsbBotDataTransfer (%r)\n", Status));\r
+    return Status;\r
+  }\r
 \r
   //\r
   // Get the status, if that succeeds, interpret the result\r