From nobody Fri May 3 04:42:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1519991683572367.3969781249981; Fri, 2 Mar 2018 03:54:43 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 583532255D6CE; Fri, 2 Mar 2018 03:48:32 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 9E4C522546BBF for ; Fri, 2 Mar 2018 03:48:30 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 03:54:40 -0800 Received: from unknown (HELO ray-dev.ccr.corp.intel.com) ([10.239.9.44]) by fmsmga002.fm.intel.com with ESMTP; 02 Mar 2018 03:54:39 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,412,1515484800"; d="scan'208";a="24581947" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Mar 2018 19:54:33 +0800 Message-Id: <20180302115437.140240-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180302115437.140240-1-ruiyu.ni@intel.com> References: <20180302115437.140240-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/5] MdeModulePkg/UsbMass: Revert POWER_ON(29h) ASC handling logic 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: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit 6461344c318cd43a5494c0302e142a0cbe386d52. * MdeModulePkg/UsbMass: Fix hot-plug USB CDROM can't be recognized UsbBootExecCmd() only calls UsbBootRequestSense() to get sense key when CMD fails. When POWER ON (29h) ASC returns from REQUEST SENSE, implementation should retry the CMD, instead of treating this as a SUCCESS. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Reviewed-by: Star Zeng --- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 2 -- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c index 12e68d2149..613008bde7 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c @@ -124,8 +124,6 @@ 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 5ee50ac52a..13a926035c 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 - 2018, 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 @@ -55,7 +55,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. #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 --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 04:42:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1519991685715627.920271578225; Fri, 2 Mar 2018 03:54:45 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C69BF2255D6DF; Fri, 2 Mar 2018 03:48:33 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 6297322546BBD for ; Fri, 2 Mar 2018 03:48:31 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 03:54:40 -0800 Received: from unknown (HELO ray-dev.ccr.corp.intel.com) ([10.239.9.44]) by fmsmga002.fm.intel.com with ESMTP; 02 Mar 2018 03:54:40 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,412,1515484800"; d="scan'208";a="24581952" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Mar 2018 19:54:34 +0800 Message-Id: <20180302115437.140240-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180302115437.140240-1-ruiyu.ni@intel.com> References: <20180302115437.140240-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/5] MdeModulePkg/UsbMass: Revert "map -r" media change detection fix 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: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This reverts commit a662afb5b023a187ef638d3cb0e0c313ad39a7fc. * MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change The above commit fixed the following issue: When system boots to Shell without CDROM inside USB CDROM drive, and then user inserts the CDROM with Eltorito file system, "map -r" cannot show the new ELtorito file system. The commit caused EFI_MEDIA_CHANGED status returned from UsbBootDetectMedia(). But that fix exposes another issue: When issuing ReadCapacity command to certain USB key (Kingston DataTraveler G3 8GB) after it's hot-plugged, USB device returns STALL error and RequestSense command returns media changed sense data. (Most of the USB keys return SUCCESS for ReadCapacity command after hot-plug.) Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Reviewed-by: Star Zeng --- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 19 ++++------------= --- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c index 613008bde7..a8b6a1c5f1 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 - 2018, 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 @@ -630,10 +630,8 @@ UsbBootGetParams ( { EFI_BLOCK_IO_MEDIA *Media; EFI_STATUS Status; - UINT8 CmdSet; =20 Media =3D &(UsbMass->BlockIoMedia); - CmdSet =3D ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->Interf= aceSubClass; =20 Status =3D UsbBootInquiry (UsbMass); if (EFI_ERROR (Status)) { @@ -668,18 +666,9 @@ UsbBootGetParams ( Media->BlockSize =3D 0x0800; } =20 - if ((UsbMass->Pdt !=3D USB_PDT_CDROM) && (CmdSet =3D=3D USB_MASS_STORE_S= CSI)) { - // - // ModeSense is required for the device with PDT of 0x00/0x07/0x0E, - // which is from [MassStorageBootabilitySpec-Page7]. - // ModeSense(10) is useless here, while ModeSense(6) defined in SCSI - // could get the information of WriteProtected. - // Since not all device support this command, so skip if fail. - // - UsbScsiModeSense (UsbMass); - } + Status =3D UsbBootDetectMedia (UsbMass); =20 - return UsbBootReadCapacity (UsbMass); + return Status; } =20 =20 @@ -710,7 +699,7 @@ UsbBootDetectMedia ( CmdSet =3D ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->Interf= aceSubClass; =20 Status =3D UsbBootIsUnitReady (UsbMass); - if (EFI_ERROR (Status)) { + if (EFI_ERROR (Status) && (Status !=3D EFI_MEDIA_CHANGED)) { goto ON_ERROR; } =20 --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 04:42:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1519991687848119.41910917673749; Fri, 2 Mar 2018 03:54:47 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3854E2255D6E6; Fri, 2 Mar 2018 03:48:34 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 38C192255D6CA for ; Fri, 2 Mar 2018 03:48:32 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 03:54:41 -0800 Received: from unknown (HELO ray-dev.ccr.corp.intel.com) ([10.239.9.44]) by fmsmga002.fm.intel.com with ESMTP; 02 Mar 2018 03:54:41 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,412,1515484800"; d="scan'208";a="24581956" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Mar 2018 19:54:35 +0800 Message-Id: <20180302115437.140240-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180302115437.140240-1-ruiyu.ni@intel.com> References: <20180302115437.140240-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 3/5] MdeModulePkg/UsbMass: Add more debug message 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: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Reviewed-by: Star Zeng --- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c index a8b6a1c5f1..d212960bbc 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 - 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 available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -137,8 +137,9 @@ UsbBootRequestSense ( break; } =20 - DEBUG ((EFI_D_INFO, "UsbBootRequestSense: (%r) with sense key %x/%x/%x\n= ", + DEBUG ((EFI_D_INFO, "UsbBootRequestSense: (%r) with error code (%x) sens= e key %x/%x/%x\n", Status, + SenseData.ErrorCode, USB_BOOT_SENSE_KEY (SenseData.SenseKey), SenseData.Asc, SenseData.Ascq @@ -196,7 +197,7 @@ UsbBootExecCmd ( ); =20 if (Status =3D=3D EFI_TIMEOUT) { - DEBUG ((EFI_D_ERROR, "UsbBootExecCmd: Timeout to Exec 0x%x Cmd\n", *(U= INT8 *)Cmd)); + DEBUG ((EFI_D_ERROR, "UsbBootExecCmd: %r to Exec 0x%x Cmd\n", Status, = *(UINT8 *)Cmd)); return EFI_TIMEOUT; } =20 @@ -211,6 +212,7 @@ UsbBootExecCmd ( // // If command execution failed, then retrieve error info via sense reque= st. // + DEBUG ((EFI_D_ERROR, "UsbBootExecCmd: %r to Exec 0x%x Cmd (Result =3D %x= )\n", Status, *(UINT8 *)Cmd, CmdResult)); return UsbBootRequestSense (UsbMass); } =20 --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 04:42:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151999169010327.9190257432017; Fri, 2 Mar 2018 03:54:50 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 934AC2255D6E8; Fri, 2 Mar 2018 03:48:34 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 ED74D2255D6D4 for ; Fri, 2 Mar 2018 03:48:32 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 03:54:42 -0800 Received: from unknown (HELO ray-dev.ccr.corp.intel.com) ([10.239.9.44]) by fmsmga002.fm.intel.com with ESMTP; 02 Mar 2018 03:54:41 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,412,1515484800"; d="scan'208";a="24581960" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Mar 2018 19:54:36 +0800 Message-Id: <20180302115437.140240-5-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180302115437.140240-1-ruiyu.ni@intel.com> References: <20180302115437.140240-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 4/5] MdeModulePkg/UsbMass: remove unnecessary RestoreTPL() call 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: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Reviewed-by: Star Zeng --- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c index d212960bbc..dd4b3a5f0a 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c @@ -691,7 +691,6 @@ UsbBootDetectMedia ( EFI_BLOCK_IO_MEDIA OldMedia; EFI_BLOCK_IO_MEDIA *Media; UINT8 CmdSet; - EFI_TPL OldTpl; EFI_STATUS Status; =20 Media =3D &UsbMass->BlockIoMedia; @@ -740,11 +739,10 @@ ON_ERROR: (Media->LastBlock !=3D OldMedia.LastBlock)) { =20 // - // This function is called by Block I/O Protocol APIs, which run at TP= L_NOTIFY. - // Here we temporarily restore TPL to TPL_CALLBACK to invoke Reinstall= ProtocolInterface(). - // - OldTpl =3D EfiGetCurrentTpl (); - gBS->RestoreTPL (TPL_CALLBACK); + // This function is called from: + // Block I/O Protocol APIs, which run at TPL_CALLBACK. + // DriverBindingStart(), which raises to TPL_CALLBACK. + ASSERT (EfiGetCurrentTpl () =3D=3D TPL_CALLBACK); =20 gBS->ReinstallProtocolInterface ( UsbMass->Controller, @@ -753,9 +751,6 @@ ON_ERROR: &UsbMass->BlockIo ); =20 - ASSERT (EfiGetCurrentTpl () =3D=3D TPL_CALLBACK); - gBS->RaiseTPL (OldTpl); - // // Update MediaId after reinstalling Block I/O Protocol. // --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 04:42:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1519991692457954.825193510743; Fri, 2 Mar 2018 03:54:52 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0840A2255D6EC; Fri, 2 Mar 2018 03:48:37 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 B346E2255D6DC for ; Fri, 2 Mar 2018 03:48:33 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 03:54:43 -0800 Received: from unknown (HELO ray-dev.ccr.corp.intel.com) ([10.239.9.44]) by fmsmga002.fm.intel.com with ESMTP; 02 Mar 2018 03:54:42 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,412,1515484800"; d="scan'208";a="24581963" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 2 Mar 2018 19:54:37 +0800 Message-Id: <20180302115437.140240-6-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180302115437.140240-1-ruiyu.ni@intel.com> References: <20180302115437.140240-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 5/5] MdeModulePkg/UsbMass: Retry CMD for MediaChanged sense key 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: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When a USB device reports failure for a CMD and REQUEST SENSE returns Media Changed key, UsbBootExecCmdWithRetry() stops to retry CMD and returns EFI_MEDIA_CHANGED to caller. For this case, the CMD should be retried until success, getting NoMedia sense key or timeout. The patch updates UsbBootExecCmdWithRetry() to follow the above rule so EFI_MEDIA_CHANGED is no longer returned. UsbBootDetectMedia() is updated accordingly. Because UsbBootGetParams() is called for new plugged USB storage, and some USB storage devices may report Media Changed key, UsbBootGetParams() is updated to treat it as a Success. This change could fix the issue that some USB storage devices cannot be detected. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Reviewed-by: Star Zeng --- .../Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 60 ++++++++++++++----= ---- .../Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c | 10 +++- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c index dd4b3a5f0a..b84bfd2d72 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c @@ -234,7 +234,7 @@ UsbBootExecCmd ( @param Timeout The timeout used to transfer =20 @retval EFI_SUCCESS The command is executed successfully. - @retval EFI_MEDIA_CHANGED The device media has been changed. + @retval EFI_NO_MEDIA The device media is removed. @retval Others Command execution failed after retrial. =20 **/ @@ -284,7 +284,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_NO_MEDIA) { break; } // @@ -700,30 +700,42 @@ UsbBootDetectMedia ( CmdSet =3D ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->Interf= aceSubClass; =20 Status =3D UsbBootIsUnitReady (UsbMass); - if (EFI_ERROR (Status) && (Status !=3D EFI_MEDIA_CHANGED)) { - goto ON_ERROR; + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: UsbBootIsUnitReady (%r)\n", = Status)); } =20 - if ((UsbMass->Pdt !=3D USB_PDT_CDROM) && (CmdSet =3D=3D USB_MASS_STORE_S= CSI)) { - // - // MODE SENSE is required for the device with PDT of 0x00/0x07/0x0E, - // according to Section 4 of USB Mass Storage Specification for Bootab= ility. - // MODE SENSE(10) is useless here, while MODE SENSE(6) defined in SCSI - // could get the information of Write Protected. - // Since not all device support this command, skip if fail. - // - UsbScsiModeSense (UsbMass); - } + // + // Status could be: + // EFI_SUCCESS: all good. + // EFI_NO_MEDIA: media is not present. + // others: HW error. + // For either EFI_NO_MEDIA, or HW error, skip to get WriteProtected and = capacity information. + // + if (!EFI_ERROR (Status)) { + if ((UsbMass->Pdt !=3D USB_PDT_CDROM) && (CmdSet =3D=3D USB_MASS_STORE= _SCSI)) { + // + // MODE SENSE is required for the device with PDT of 0x00/0x07/0x0E, + // according to Section 4 of USB Mass Storage Specification for Boot= ability. + // MODE SENSE(10) is useless here, while MODE SENSE(6) defined in SC= SI + // could get the information of Write Protected. + // Since not all device support this command, skip if fail. + // + UsbScsiModeSense (UsbMass); + } =20 - Status =3D UsbBootReadCapacity (UsbMass); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: UsbBootReadCapacity (%r)\n",= Status)); - goto ON_ERROR; + Status =3D UsbBootReadCapacity (UsbMass); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: UsbBootReadCapacity (%r)\n= ", Status)); + } } =20 - return EFI_SUCCESS; + if (EFI_ERROR (Status) && Status !=3D EFI_NO_MEDIA) { + // + // For NoMedia, BlockIo is still needed. + // + return Status; + } =20 -ON_ERROR: // // Detect whether it is necessary to reinstall the Block I/O Protocol. // @@ -744,6 +756,10 @@ ON_ERROR: // DriverBindingStart(), which raises to TPL_CALLBACK. ASSERT (EfiGetCurrentTpl () =3D=3D TPL_CALLBACK); =20 + // + // When it is called from DriverBindingStart(), below reinstall fails. + // So ignore the return status check. + // gBS->ReinstallProtocolInterface ( UsbMass->Controller, &gEfiBlockIoProtocolGuid, @@ -752,7 +768,7 @@ ON_ERROR: ); =20 // - // Update MediaId after reinstalling Block I/O Protocol. + // Reset MediaId after reinstalling Block I/O Protocol. // if (Media->MediaPresent !=3D OldMedia.MediaPresent) { if (Media->MediaPresent) { @@ -767,6 +783,8 @@ ON_ERROR: (Media->LastBlock !=3D OldMedia.LastBlock)) { Media->MediaId++; } + + Status =3D Media->MediaPresent ? EFI_MEDIA_CHANGED : EFI_NO_MEDIA; } =20 return Status; diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c b/MdeModu= lePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c index 9d1bb25fb3..bb292ed3eb 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c @@ -1,7 +1,7 @@ /** @file USB Mass Storage Driver that manages USB Mass Storage Device and produce= s Block I/O Protocol. =20 -Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2018, 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 @@ -361,6 +361,14 @@ UsbMassInitMedia ( Media->MediaId =3D 1; =20 Status =3D UsbBootGetParams (UsbMass); + DEBUG ((DEBUG_INFO, "UsbMassInitMedia: UsbBootGetParams (%r)\n", Status)= ); + if (Status =3D=3D EFI_MEDIA_CHANGED) { + // + // Some USB storage devices may report MEDIA_CHANGED sense key when ho= t-plugged. + // Treat it as SUCCESS + // + Status =3D EFI_SUCCESS; + } return Status; } =20 --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel