From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ml01.01.org (Postfix) with ESMTP id 594BB1A1E12 for ; Tue, 2 Aug 2016 19:35:44 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 02 Aug 2016 19:35:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,463,1464678000"; d="scan'208";a="149705218" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 02 Aug 2016 19:35:44 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 2 Aug 2016 19:35:43 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 2 Aug 2016 19:35:43 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.116]) with mapi id 14.03.0248.002; Wed, 3 Aug 2016 10:35:41 +0800 From: "Zeng, Star" To: "Tian, Feng" CC: "edk2-devel@lists.01.org" Thread-Topic: [patch] MdeModulePkg/UsbMass: Not retry if usb bot transfer execution fail Thread-Index: AQHR7Sv4wHmeHwxOrUCAkvG3cWDguaA2hQcw Date: Wed, 3 Aug 2016 02:35:40 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB048310036A0316@shsmsx102.ccr.corp.intel.com> References: <17f3e942bc527fbd75068d2d5752b6af54917487.1470189611.git.feng.tian@intel.com> In-Reply-To: <17f3e942bc527fbd75068d2d5752b6af54917487.1470189611.git.feng.tian@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdeModulePkg/UsbMass: Not retry if usb bot transfer execution fail X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Aug 2016 02:35:44 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: Tian, Feng=20 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 execut= ion 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 XH= CI 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. Th= is behavior will cause system unresponsive for a long while and bring bad u= ser 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 +++++++-- MdeMod= ulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/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. =20 -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 availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -189,6 +18= 9,11 @@ UsbBootExecCmd ( return EFI_TIMEOUT; } =20 + if (Status =3D=3D 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 =3D=3D EFI_SUCCESS || Status =3D=3D EFI_MEDIA_CHANGED || St= atus =3D=3D EFI_NO_MEDIA) { + if (Status =3D=3D EFI_SUCCESS || Status =3D=3D EFI_MEDIA_CHANGED || St= atus=20 + =3D=3D EFI_NO_MEDIA || Status =3D=3D EFI_DEVICE_ERROR) { break; } // diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c b/MdeModul= ePkg/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. =20 -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 availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -432,7 +43= 2,11 @@ UsbBotExecCommand ( // whether it succeeds or fails. // TransLen =3D (UINTN) DataLen; - UsbBotDataTransfer (UsbBot, DataDir, Data, &TransLen, Timeout); + Status =3D UsbBotDataTransfer (UsbBot, DataDir, Data, &TransLen, Timeo= ut); + if (Status =3D=3D EFI_DEVICE_ERROR) { + DEBUG ((EFI_D_ERROR, "UsbBotExecCommand: UsbBotDataTransfer (%r)\n", S= tatus)); + return Status; + } =20 // // Get the status, if that succeeds, interpret the result -- 2.7.1.windows.2