From nobody Mon Dec 23 05:06:54 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 1518506542247504.64687040986826; Mon, 12 Feb 2018 23:22:22 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 17FED21CF1CE9; Mon, 12 Feb 2018 23:16:30 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 62DC421CF1CE4 for ; Mon, 12 Feb 2018 23:16:27 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2018 23:22:17 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by orsmga004.jf.intel.com with ESMTP; 12 Feb 2018 23:22:16 -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=134.134.136.65; helo=mga03.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.46,506,1511856000"; d="scan'208";a="174477870" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 13 Feb 2018 15:22:15 +0800 Message-Id: <20180213072215.91092-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [edk2] [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: , Cc: Feng Tian , 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" 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() retrieves sense key (6 =3D UnitAttention), additional sense code (28h =3D media changed). The above analysis explains why hot-plug USB CDROM cannot be recognized after below commit: SHA1 a662afb5b023a187ef638d3cb0e0c313ad39a7fc * MdeModulePkg/UsbStorage: Fix "map -r" cannot detect media change, which removes 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 Reviewed-by: Star Zeng --- 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 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,6 +55,7 @@ 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