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.93; helo=mga11.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 145F521CF1CE9 for ; Mon, 12 Feb 2018 23:20:42 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2018 23:26:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,506,1511856000"; d="scan'208";a="17488139" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 12 Feb 2018 23:26:32 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 12 Feb 2018 23:26:32 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 12 Feb 2018 23:26:32 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.253]) with mapi id 14.03.0319.002; Tue, 13 Feb 2018 15:26:30 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Tian, Feng" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdeModulePkg/UsbMass: Fix hot-plug USB CDROM can't be recognized Thread-Index: AQHTpJtmQmVlaxnTi0ycKtGmVFm+1qOh7pyg Date: Tue, 13 Feb 2018 07:26:29 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BA3F145@shsmsx102.ccr.corp.intel.com> References: <20180213072215.91092-1-ruiyu.ni@intel.com> In-Reply-To: <20180213072215.91092-1-ruiyu.ni@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: Fix hot-plug USB CDROM can't be recognized X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Feb 2018 07:20:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiy= u Ni Sent: Tuesday, February 13, 2018 3:22 PM To: edk2-devel@lists.01.org Cc: Tian, Feng ; Zeng, Star Subject: [edk2] [PATCH] MdeModulePkg/UsbMass: Fix hot-plug USB CDROM can't = be recognized In below calling stack: UsbBootIsUnitReady() UsbBootExecCmdWithRetry() UsbBootExecCmd() UsbBootRequestSense() When USB CDROM is hot-plugged, UsbBootRequestSense() retrieves sense key (6= =3D UnitAttention), additional sense code (29h =3D Power ON). But it wrongly maps such sense data to Device Error status. It causes UsbBootExecCmd() executed again. In the second time call to UsbBootExecCmd(), UsbBootRequestSense() retrieve= s sense key (6 =3D UnitAttention), additional sense code (28h =3D media cha= nged). The above analysis explains why hot-plug USB CDROM cannot be recognized aft= er below commit: SHA1 a662afb5b023a187ef638d3cb0e0c313ad39a7fc * MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change, which r= emoves the media changed status check in UsbBootDetectMedia(). The proper fix to this problem is to map the ASC (additional sense code 29h= ) properly to success status so that no second call to UsbBootExecCmd() is made. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Feng Tian --- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 2 ++ MdeModulePkg/= Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c index 613008bde7..12e68d2149 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c @@ -124,6 +124,8 @@ UsbBootRequestSense ( Status =3D EFI_NOT_READY; } else if (SenseData.Asc =3D=3D USB_BOOT_ASC_NO_MEDIA) { Status =3D EFI_NOT_READY; + } else if (SenseData.Asc =3D=3D USB_BOOT_ASC_POWER_ON) { + Status =3D EFI_SUCCESS; } break; =20 diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h index 13a926035c..5ee50ac52a 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h @@ -2,7 +2,7 @@ Definition of the command set of USB Mass Storage Specification for Bootability, Revision 1.0. =20 -Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2018, 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 @@ -55,6 +55,= 7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. #define USB_BOOT_ASC_NOT_READY 0x04 #define USB_BOOT_ASC_NO_MEDIA 0x3A #define USB_BOOT_ASC_MEDIA_CHANGE 0x28 +#define USB_BOOT_ASC_POWER_ON 0x29 =20 // // Supported PDT codes, or Peripheral Device Type -- 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel