]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UsbMass: Revert "map -r" media change detection fix
authorRuiyu Ni <ruiyu.ni@intel.com>
Fri, 2 Mar 2018 09:30:06 +0000 (17:30 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Sat, 3 Mar 2018 07:49:04 +0000 (15:49 +0800)
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 <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c

index 613008bde76837f174b37335c5a7e47d4bdae30f..a8b6a1c5f13c9cca81490650ddb6c0a5ca013fa5 100644 (file)
@@ -2,7 +2,7 @@
   Implementation of the command set of USB Mass Storage Specification\r
   for Bootability, Revision 1.0.\r
 \r
-Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -630,10 +630,8 @@ UsbBootGetParams (
 {\r
   EFI_BLOCK_IO_MEDIA          *Media;\r
   EFI_STATUS                  Status;\r
-  UINT8                       CmdSet;\r
 \r
   Media  = &(UsbMass->BlockIoMedia);\r
-  CmdSet = ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->InterfaceSubClass;\r
 \r
   Status = UsbBootInquiry (UsbMass);\r
   if (EFI_ERROR (Status)) {\r
@@ -668,18 +666,9 @@ UsbBootGetParams (
     Media->BlockSize        = 0x0800;\r
   }\r
 \r
-  if ((UsbMass->Pdt != USB_PDT_CDROM) && (CmdSet == USB_MASS_STORE_SCSI)) {\r
-    //\r
-    // ModeSense is required for the device with PDT of 0x00/0x07/0x0E,\r
-    // which is from [MassStorageBootabilitySpec-Page7].\r
-    // ModeSense(10) is useless here, while ModeSense(6) defined in SCSI\r
-    // could get the information of WriteProtected.\r
-    // Since not all device support this command, so skip if fail.\r
-    //\r
-    UsbScsiModeSense (UsbMass);\r
-  }\r
+  Status = UsbBootDetectMedia (UsbMass);\r
 \r
-  return UsbBootReadCapacity (UsbMass);\r
+  return Status;\r
 }\r
 \r
 \r
@@ -710,7 +699,7 @@ UsbBootDetectMedia (
   CmdSet = ((EFI_USB_INTERFACE_DESCRIPTOR *) (UsbMass->Context))->InterfaceSubClass;\r
 \r
   Status = UsbBootIsUnitReady (UsbMass);\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) {\r
     goto ON_ERROR;\r
   }\r
 \r