[edk2] [Patch] MdeModulePkg/UsbMassStorageDxe: Enhance Request Sense Handling

Michael D Kinney posted 1 patch 6 years, 5 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 4 ++++
1 file changed, 4 insertions(+)
[edk2] [Patch] MdeModulePkg/UsbMassStorageDxe: Enhance Request Sense Handling
Posted by Michael D Kinney 6 years, 5 months ago
https://bugzilla.tianocore.org/show_bug.cgi?id=782

Update the Request Sense check for the Request Sense Key of
USB_BOOT_SENSE_UNIT_ATTENTION.  For this Sense Key, the
Additional Sense Key to EFI_STATUS mappings are:

USB_BOOT_ASC_MEDIA_CHANGE -> EFI_MEDIA_CHANGE
USB_BOOT_ASC_NOT_READY    -> EFI_NOT_READY
USB_BOOT_ASC_NO_MEDIA     -> EFI_NOT_READY
All others                -> EFI_DEVICE_ERROR

A USB flash drive is returning Request Sense Key of
USB_BOOT_SENSE_UNIT_ATTENTION and an Additional Sense Key of
USB_BOOT_ASC_NO_MEDIA for a few seconds before returning an
Additional Sense Key of USB_BOOT_ASC_MEDIA_CHANGE.

The current logic treats this initial Request Sense info as an
error and reties the command 5 times before failing completely.

With this change the USB Flash Drive works correctly.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
index 2eb30f0c5f..a8b6a1c5f1 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
@@ -120,6 +120,10 @@ UsbBootRequestSense (
       Status = EFI_MEDIA_CHANGED;
       Media->ReadOnly = FALSE;
       Media->MediaId++;
+    } else if (SenseData.Asc == USB_BOOT_ASC_NOT_READY) {
+      Status = EFI_NOT_READY;
+    } else if (SenseData.Asc == USB_BOOT_ASC_NO_MEDIA) {
+      Status = EFI_NOT_READY;
     }
     break;
 
-- 
2.14.2.windows.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] MdeModulePkg/UsbMassStorageDxe: Enhance Request Sense Handling
Posted by Zeng, Star 6 years, 5 months ago
Mike,

Returning EFI_NOT_READY for USB_BOOT_ASC_NO_MEDIA seems a little confusing, but based on the real case, I am ok with the patch.

Reviewed-by: Star Zeng <star.zeng@intel.com>


Thanks,
Star
-----Original Message-----
From: Kinney, Michael D 
Sent: Wednesday, November 15, 2017 9:28 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>
Subject: [Patch] MdeModulePkg/UsbMassStorageDxe: Enhance Request Sense Handling

https://bugzilla.tianocore.org/show_bug.cgi?id=782

Update the Request Sense check for the Request Sense Key of USB_BOOT_SENSE_UNIT_ATTENTION.  For this Sense Key, the Additional Sense Key to EFI_STATUS mappings are:

USB_BOOT_ASC_MEDIA_CHANGE -> EFI_MEDIA_CHANGE
USB_BOOT_ASC_NOT_READY    -> EFI_NOT_READY
USB_BOOT_ASC_NO_MEDIA     -> EFI_NOT_READY
All others                -> EFI_DEVICE_ERROR

A USB flash drive is returning Request Sense Key of USB_BOOT_SENSE_UNIT_ATTENTION and an Additional Sense Key of USB_BOOT_ASC_NO_MEDIA for a few seconds before returning an Additional Sense Key of USB_BOOT_ASC_MEDIA_CHANGE.

The current logic treats this initial Request Sense info as an error and reties the command 5 times before failing completely.

With this change the USB Flash Drive works correctly.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
index 2eb30f0c5f..a8b6a1c5f1 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
@@ -120,6 +120,10 @@ UsbBootRequestSense (
       Status = EFI_MEDIA_CHANGED;
       Media->ReadOnly = FALSE;
       Media->MediaId++;
+    } else if (SenseData.Asc == USB_BOOT_ASC_NOT_READY) {
+      Status = EFI_NOT_READY;
+    } else if (SenseData.Asc == USB_BOOT_ASC_NO_MEDIA) {
+      Status = EFI_NOT_READY;
     }
     break;
 
--
2.14.2.windows.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel