From d8030c2ae06b771c78d0438c869cd882e82d0c8f Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Tue, 14 Nov 2017 15:56:30 -0800 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 Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-by: Star Zeng --- 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.39.2