From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6BCDE2034EE26 for ; Thu, 16 Nov 2017 02:58:57 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Nov 2017 03:03:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,402,1505804400"; d="scan'208";a="1244814537" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 16 Nov 2017 03:03:06 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 16 Nov 2017 03:03:06 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Thu, 16 Nov 2017 19:03:04 +0800 From: "Zeng, Star" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" Thread-Topic: [Patch V3 2/2] MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN status/value Thread-Index: AQHTXo8gCDcDhsYLj0ez4Jn3yO/5sKMW1wGA Date: Thu, 16 Nov 2017 11:03:03 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B63E3@shsmsx102.ccr.corp.intel.com> References: <20171116035755.12448-1-michael.d.kinney@intel.com> <20171116035755.12448-3-michael.d.kinney@intel.com> In-Reply-To: <20171116035755.12448-3-michael.d.kinney@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 V3 2/2] MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN status/value X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2017 10:58:58 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Mike, After this patch, the return status of UsbBotGetMaxLun seems confusing and = useless. Fortunately, there is no one using the return status of it. What do you think? Thanks, Star -----Original Message----- From: Kinney, Michael D=20 Sent: Thursday, November 16, 2017 11:58 AM To: edk2-devel@lists.01.org Cc: Zeng, Star ; Dong, Eric Subject: [Patch V3 2/2] MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN s= tatus/value https://bugzilla.tianocore.org/show_bug.cgi?id=3D767 If a USB Mass Storage device does not support the Get Max LUN command, then= the USB I/O Protocol ControlTransfer() service may return an error. If an= error is returned for this command, then assume that the device does not s= upport multiple LUNs and return a maximum LUN value of 0. The USB Mass Storage Class Specification states that a maximum LUN value la= rger than 0x0F is invalid. Add a check to make sure this maximum LUN value= is in this valid range, and if it is not, then assume that the device does= not support multiple LUNs and return a maximum LUN value of 0. This change improves compatibility with USB FLASH drives that do not suppor= t the Get Max LUN command or return an invalid maximum LUN value. Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c b/MdeModul= ePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c index 4bb7222b89..6afe2ae235 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 - 2017, 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 @@ -576,6 +57= 6,18 @@ UsbBotGetMaxLun ( 1, &Result ); + if (EFI_ERROR (Status) || *MaxLun > USB_BOT_MAX_LUN) { + // + // If the Get LUN request returns an error or the MaxLun is larger tha= n + // the maximum LUN value (0x0f) supported by the USB Mass Storage Clas= s + // Bulk-Only Transport Spec, then set MaxLun to 0. + // + // This improves compatibility with USB FLASH drives that have a singl= e LUN + // and either do not return a max LUN value or return an invalid maxim= um LUN + // value. + // + *MaxLun =3D 0; + } =20 return Status; } -- 2.14.2.windows.3