From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 3BA002035BB19 for ; Fri, 17 Nov 2017 08:32:17 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 08:36:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,410,1505804400"; d="scan'208";a="8823253" Received: from orsmsx110.amr.corp.intel.com ([10.22.240.8]) by orsmga002.jf.intel.com with ESMTP; 17 Nov 2017 08:36:27 -0800 Received: from orsmsx153.amr.corp.intel.com (10.22.226.247) by ORSMSX110.amr.corp.intel.com (10.22.240.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 17 Nov 2017 08:36:26 -0800 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.80]) by ORSMSX153.amr.corp.intel.com ([169.254.12.223]) with mapi id 14.03.0319.002; Fri, 17 Nov 2017 08:36:19 -0800 From: "Kinney, Michael D" To: "Zeng, Star" , "edk2-devel@lists.01.org" , "Kinney, Michael D" CC: "Dong, Eric" Thread-Topic: [Patch V3 2/2] MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN status/value Thread-Index: AQHTXsp7IAg64hsHa0CUTgWVB+FuC6MYxlYA Date: Fri, 17 Nov 2017 16:36:18 +0000 Message-ID: References: <20171116035755.12448-1-michael.d.kinney@intel.com> <20171116035755.12448-3-michael.d.kinney@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9B63E3@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B63E3@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmUwZTMyNTYtNzIwMS00YzQ1LWJjMDktMWFkZjdkZTk2ZjgwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJTVm5hTU1tTXpHRDdEZ0ZxNlErbmdYTWNlWnFMUWJoUGZpQVNZazFOQ1pNVTZ1QXVwK2hYZ3FRR3RKU2VxUVJNIn0= dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.22.254.140] 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: Fri, 17 Nov 2017 16:32:18 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Star, I agree. I will update patch once more to make sure Return status is meaningful. I will also remove ASSERT For Context NULL and return EFI_INVALID_PARAMETER Instead if either Context or MaxLun are NULL. Mike > -----Original Message----- > From: Zeng, Star > Sent: Thursday, November 16, 2017 3:03 AM > To: Kinney, Michael D ; > edk2-devel@lists.01.org > Cc: Dong, Eric ; Zeng, Star > > Subject: RE: [Patch V3 2/2] > MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN > status/value >=20 > Mike, >=20 > 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? >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Kinney, Michael D > 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 status/value >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D767 >=20 > 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 support multiple LUNs and return a > maximum LUN value of 0. >=20 > The USB Mass Storage Class Specification states that a > maximum LUN value larger 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. >=20 > This change improves compatibility with USB FLASH > drives that do not support the Get Max LUN command or > return an invalid maximum LUN value. >=20 > 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(-) >=20 > diff --git > a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c > b/MdeModulePkg/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 available under the terms and > conditions of the BSD License which accompanies this > distribution. The full text of the license may be > found at @@ -576,6 +576,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 than > + // the maximum LUN value (0x0f) supported by the > USB Mass Storage Class > + // Bulk-Only Transport Spec, then set MaxLun to 0. > + // > + // This improves compatibility with USB FLASH > drives that have a single LUN > + // and either do not return a max LUN value or > return an invalid maximum LUN > + // value. > + // > + *MaxLun =3D 0; > + } >=20 > return Status; > } > -- > 2.14.2.windows.3