Re: [edk2] [patch] MdeModulePkg/UsbMass: Not retry if usb bot transfer execution fail

2016-08-02 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Tian, Feng 
Sent: Wednesday, August 3, 2016 10:08 AM
To: Zeng, Star 
Cc: edk2-devel@lists.01.org
Subject: [patch] MdeModulePkg/UsbMass: Not retry if usb bot transfer execution 
fail

[Sorry, this patch was pushed into EDKII trunk by wrong operation.

If the review mail could pass review, I would prefer to not do a roll-back.
Sorry again for that.

If there is other opinions, please let me know.]

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 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian 
---
 MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 9 +++--  
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c  | 8 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/UsbMass: Not retry if usb bot transfer execution fail

2016-08-02 Thread Feng Tian
[Sorry, this patch was pushed into EDKII trunk by wrong operation.

If the review mail could pass review, I would prefer to not do a roll-back.
Sorry again for that.

If there is other opinions, please let me know.]

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 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian 
---
 MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 9 +++--
 MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c  | 8 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel