[edk2] [Patch] MdeModulePkg/UsbMassStorageDxe: Fix USB Mass Storage detection

Michael D Kinney posted 1 patch 7 years, 1 month ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 11 +++++++++--
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h |  9 +++++----
2 files changed, 14 insertions(+), 6 deletions(-)
[edk2] [Patch] MdeModulePkg/UsbMassStorageDxe: Fix USB Mass Storage detection
Posted by Michael D Kinney 7 years, 1 month ago
https://bugzilla.tianocore.org/show_bug.cgi?id=766

Update logic to not return an error from UsbBootRequestSense()
if a Request Sense command responds with no sense information.
It is legal for a USB mass storage device to respond to a
Request Sense command with a SenseKey of
USB_BOOT_SENSE_NO_SENSE and an Additional Sense
Code of USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION.

This is described in Section 3.3 of the Universal Serial
Bus Mass Storage Specification For Bootability:

http://www.usb.org/developers/docs/devclass_docs/usb_msc_boot_1.0.pdf

The previous logic returned an error of EFI_NO_RESPONSE
and this caused USB mass storage devices such as a USB
floppy drive to not be detected.

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 | 11 +++++++++--
 MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h |  9 +++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
index 0c46f888eb..2eb30f0c5f 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.
 
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 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
@@ -80,7 +80,14 @@ UsbBootRequestSense (
   switch (USB_BOOT_SENSE_KEY (SenseData.SenseKey)) {
 
   case USB_BOOT_SENSE_NO_SENSE:
-    Status = EFI_NO_RESPONSE;
+    if (SenseData.Asc == USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION) {
+      //
+      // It is not an error if a device does not have additional sense information
+      //
+      Status = EFI_SUCCESS;
+    } else {
+      Status = EFI_NO_RESPONSE;
+    }
     break;
 
   case USB_BOOT_SENSE_RECOVERED:
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
index c4082558fa..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.
 
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 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
@@ -51,9 +51,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define USB_BOOT_SENSE_VOLUME_OVERFLOW  0x0D ///< Partition overflow
 #define USB_BOOT_SENSE_MISCOMPARE       0x0E ///< Source data mis-match while verfying.
 
-#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_NO_ADDITIONAL_SENSE_INFORMATION  0x00
+#define USB_BOOT_ASC_NOT_READY                        0x04
+#define USB_BOOT_ASC_NO_MEDIA                         0x3A
+#define USB_BOOT_ASC_MEDIA_CHANGE                     0x28
 
 //
 // Supported PDT codes, or Peripheral Device Type
-- 
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: Fix USB Mass Storage detection
Posted by Zeng, Star 7 years, 1 month ago
Mike,

Have you evaluated whether the code in PeiUsbRequestSense() of PeiAtapi.c also needs to be updated?


Thanks,
Star
-----Original Message-----
From: Kinney, Michael D 
Sent: Thursday, November 9, 2017 6:03 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>
Subject: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix USB Mass Storage detection

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

Update logic to not return an error from UsbBootRequestSense() if a Request Sense command responds with no sense information.
It is legal for a USB mass storage device to respond to a Request Sense command with a SenseKey of USB_BOOT_SENSE_NO_SENSE and an Additional Sense Code of USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION.

This is described in Section 3.3 of the Universal Serial Bus Mass Storage Specification For Bootability:

http://www.usb.org/developers/docs/devclass_docs/usb_msc_boot_1.0.pdf

The previous logic returned an error of EFI_NO_RESPONSE and this caused USB mass storage devices such as a USB floppy drive to not be detected.

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 | 11 +++++++++--  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h |  9 +++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
index 0c46f888eb..2eb30f0c5f 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.
 
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 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 @@ -80,7 +80,14 @@ UsbBootRequestSense (
   switch (USB_BOOT_SENSE_KEY (SenseData.SenseKey)) {
 
   case USB_BOOT_SENSE_NO_SENSE:
-    Status = EFI_NO_RESPONSE;
+    if (SenseData.Asc == USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION) {
+      //
+      // It is not an error if a device does not have additional sense information
+      //
+      Status = EFI_SUCCESS;
+    } else {
+      Status = EFI_NO_RESPONSE;
+    }
     break;
 
   case USB_BOOT_SENSE_RECOVERED:
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
index c4082558fa..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.
 
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 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 @@ -51,9 +51,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define USB_BOOT_SENSE_VOLUME_OVERFLOW  0x0D ///< Partition overflow
 #define USB_BOOT_SENSE_MISCOMPARE       0x0E ///< Source data mis-match while verfying.
 
-#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_NO_ADDITIONAL_SENSE_INFORMATION  0x00
+#define USB_BOOT_ASC_NOT_READY                        0x04
+#define USB_BOOT_ASC_NO_MEDIA                         0x3A
+#define USB_BOOT_ASC_MEDIA_CHANGE                     0x28
 
 //
 // Supported PDT codes, or Peripheral Device Type
--
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: Fix USB Mass Storage detection
Posted by Kinney, Michael D 7 years, 1 month ago
Star,

No.  I have not evaluated the PEI use case.

I will test that and provide an updated patch if
needed.

Thanks,

Mike

> -----Original Message-----
> From: Zeng, Star
> Sent: Monday, November 13, 2017 1:22 AM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; edk2-
> devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: RE: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix
> USB Mass Storage detection
> 
> Mike,
> 
> Have you evaluated whether the code in
> PeiUsbRequestSense() of PeiAtapi.c also needs to be
> updated?
> 
> 
> Thanks,
> Star
> -----Original Message-----
> From: Kinney, Michael D
> Sent: Thursday, November 9, 2017 6:03 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric
> <eric.dong@intel.com>
> Subject: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix USB
> Mass Storage detection
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=766
> 
> Update logic to not return an error from
> UsbBootRequestSense() if a Request Sense command responds
> with no sense information.
> It is legal for a USB mass storage device to respond to a
> Request Sense command with a SenseKey of
> USB_BOOT_SENSE_NO_SENSE and an Additional Sense Code of
> USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION.
> 
> This is described in Section 3.3 of the Universal Serial
> Bus Mass Storage Specification For Bootability:
> 
> http://www.usb.org/developers/docs/devclass_docs/usb_msc_
> boot_1.0.pdf
> 
> The previous logic returned an error of EFI_NO_RESPONSE
> and this caused USB mass storage devices such as a USB
> floppy drive to not be detected.
> 
> 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 |
> 11 +++++++++--
> MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h |  9
> +++++----
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
> b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
> index 0c46f888eb..2eb30f0c5f 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.
> 
> -Copyright (c) 2007 - 2016, Intel Corporation. All rights
> reserved.<BR>
> +Copyright (c) 2007 - 2017, Intel Corporation. All rights
> reserved.<BR>
>  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 @@ -80,7 +80,14 @@ UsbBootRequestSense (
>    switch (USB_BOOT_SENSE_KEY (SenseData.SenseKey)) {
> 
>    case USB_BOOT_SENSE_NO_SENSE:
> -    Status = EFI_NO_RESPONSE;
> +    if (SenseData.Asc ==
> USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION) {
> +      //
> +      // It is not an error if a device does not have
> additional sense information
> +      //
> +      Status = EFI_SUCCESS;
> +    } else {
> +      Status = EFI_NO_RESPONSE;
> +    }
>      break;
> 
>    case USB_BOOT_SENSE_RECOVERED:
> diff --git
> a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
> b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
> index c4082558fa..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.
> 
> -Copyright (c) 2007 - 2012, Intel Corporation. All rights
> reserved.<BR>
> +Copyright (c) 2007 - 2017, Intel Corporation. All rights
> reserved.<BR>
>  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 @@ -51,9 +51,10 @@ WITHOUT WARRANTIES OR
> REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>  #define USB_BOOT_SENSE_VOLUME_OVERFLOW  0x0D ///<
> Partition overflow
>  #define USB_BOOT_SENSE_MISCOMPARE       0x0E ///< Source
> data mis-match while verfying.
> 
> -#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_NO_ADDITIONAL_SENSE_INFORMATION
> 0x00
> +#define USB_BOOT_ASC_NOT_READY
> 0x04
> +#define USB_BOOT_ASC_NO_MEDIA
> 0x3A
> +#define USB_BOOT_ASC_MEDIA_CHANGE
> 0x28
> 
>  //
>  // Supported PDT codes, or Peripheral Device Type
> --
> 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: Fix USB Mass Storage detection
Posted by Kinney, Michael D 7 years, 1 month ago
Star,

The specific USB mass storage device that demonstrated this issue
has a Protocol of 0x00 (CBI), and the PEI phase USB recovery seems
to only support a Protocol of 0x50 (BOT).  So I am not able to
reproduce the issue in PEI recovery path.

From code review, the PEI request sense API collects sense
data until no more is available.  If there is none on the 
first attempt, EFI_SUCCESS is returned with a count of 0.
This case appears to be processed correctly by the code
that calls PeiUsbRequestSense().

I do not think any additional code changes are required.

Thanks,

Mike


> -----Original Message-----
> From: Kinney, Michael D
> Sent: Monday, November 13, 2017 9:03 AM
> To: Zeng, Star <star.zeng@intel.com>; edk2-
> devel@lists.01.org; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Cc: Dong, Eric <eric.dong@intel.com>
> Subject: RE: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix
> USB Mass Storage detection
> 
> Star,
> 
> No.  I have not evaluated the PEI use case.
> 
> I will test that and provide an updated patch if
> needed.
> 
> Thanks,
> 
> Mike
> 
> > -----Original Message-----
> > From: Zeng, Star
> > Sent: Monday, November 13, 2017 1:22 AM
> > To: Kinney, Michael D <michael.d.kinney@intel.com>;
> edk2-
> > devel@lists.01.org
> > Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star
> > <star.zeng@intel.com>
> > Subject: RE: [Patch] MdeModulePkg/UsbMassStorageDxe:
> Fix
> > USB Mass Storage detection
> >
> > Mike,
> >
> > Have you evaluated whether the code in
> > PeiUsbRequestSense() of PeiAtapi.c also needs to be
> > updated?
> >
> >
> > Thanks,
> > Star
> > -----Original Message-----
> > From: Kinney, Michael D
> > Sent: Thursday, November 9, 2017 6:03 AM
> > To: edk2-devel@lists.01.org
> > Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric
> > <eric.dong@intel.com>
> > Subject: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix
> USB
> > Mass Storage detection
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=766
> >
> > Update logic to not return an error from
> > UsbBootRequestSense() if a Request Sense command
> responds
> > with no sense information.
> > It is legal for a USB mass storage device to respond to
> a
> > Request Sense command with a SenseKey of
> > USB_BOOT_SENSE_NO_SENSE and an Additional Sense Code of
> > USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION.
> >
> > This is described in Section 3.3 of the Universal
> Serial
> > Bus Mass Storage Specification For Bootability:
> >
> >
> http://www.usb.org/developers/docs/devclass_docs/usb_msc_
> > boot_1.0.pdf
> >
> > The previous logic returned an error of EFI_NO_RESPONSE
> > and this caused USB mass storage devices such as a USB
> > floppy drive to not be detected.
> >
> > 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 |
> > 11 +++++++++--
> > MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h |
> 9
> > +++++----
> >  2 files changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git
> > a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
> > b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
> > index 0c46f888eb..2eb30f0c5f 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.
> >
> > -Copyright (c) 2007 - 2016, Intel Corporation. All
> rights
> > reserved.<BR>
> > +Copyright (c) 2007 - 2017, Intel Corporation. All
> rights
> > reserved.<BR>
> >  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 @@ -80,7 +80,14 @@ UsbBootRequestSense (
> >    switch (USB_BOOT_SENSE_KEY (SenseData.SenseKey)) {
> >
> >    case USB_BOOT_SENSE_NO_SENSE:
> > -    Status = EFI_NO_RESPONSE;
> > +    if (SenseData.Asc ==
> > USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION) {
> > +      //
> > +      // It is not an error if a device does not have
> > additional sense information
> > +      //
> > +      Status = EFI_SUCCESS;
> > +    } else {
> > +      Status = EFI_NO_RESPONSE;
> > +    }
> >      break;
> >
> >    case USB_BOOT_SENSE_RECOVERED:
> > diff --git
> > a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
> > b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
> > index c4082558fa..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.
> >
> > -Copyright (c) 2007 - 2012, Intel Corporation. All
> rights
> > reserved.<BR>
> > +Copyright (c) 2007 - 2017, Intel Corporation. All
> rights
> > reserved.<BR>
> >  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 @@ -51,9 +51,10 @@ WITHOUT WARRANTIES OR
> > REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> >  #define USB_BOOT_SENSE_VOLUME_OVERFLOW  0x0D ///<
> > Partition overflow
> >  #define USB_BOOT_SENSE_MISCOMPARE       0x0E ///<
> Source
> > data mis-match while verfying.
> >
> > -#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_NO_ADDITIONAL_SENSE_INFORMATION
> > 0x00
> > +#define USB_BOOT_ASC_NOT_READY
> > 0x04
> > +#define USB_BOOT_ASC_NO_MEDIA
> > 0x3A
> > +#define USB_BOOT_ASC_MEDIA_CHANGE
> > 0x28
> >
> >  //
> >  // Supported PDT codes, or Peripheral Device Type
> > --
> > 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: Fix USB Mass Storage detection
Posted by Zeng, Star 7 years, 1 month ago
Ok, Reviewed-by: Star Zeng <star.zeng@intel.com> to this patch.

Thanks,
Star
-----Original Message-----
From: Kinney, Michael D 
Sent: Tuesday, November 14, 2017 3:54 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org; Kinney, Michael D <michael.d.kinney@intel.com>
Cc: Dong, Eric <eric.dong@intel.com>
Subject: RE: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix USB Mass Storage detection

Star,

The specific USB mass storage device that demonstrated this issue has a Protocol of 0x00 (CBI), and the PEI phase USB recovery seems to only support a Protocol of 0x50 (BOT).  So I am not able to reproduce the issue in PEI recovery path.

From code review, the PEI request sense API collects sense data until no more is available.  If there is none on the first attempt, EFI_SUCCESS is returned with a count of 0.
This case appears to be processed correctly by the code that calls PeiUsbRequestSense().

I do not think any additional code changes are required.

Thanks,

Mike


> -----Original Message-----
> From: Kinney, Michael D
> Sent: Monday, November 13, 2017 9:03 AM
> To: Zeng, Star <star.zeng@intel.com>; edk2- devel@lists.01.org; 
> Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Dong, Eric <eric.dong@intel.com>
> Subject: RE: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix USB Mass 
> Storage detection
> 
> Star,
> 
> No.  I have not evaluated the PEI use case.
> 
> I will test that and provide an updated patch if needed.
> 
> Thanks,
> 
> Mike
> 
> > -----Original Message-----
> > From: Zeng, Star
> > Sent: Monday, November 13, 2017 1:22 AM
> > To: Kinney, Michael D <michael.d.kinney@intel.com>;
> edk2-
> > devel@lists.01.org
> > Cc: Dong, Eric <eric.dong@intel.com>; Zeng, Star 
> > <star.zeng@intel.com>
> > Subject: RE: [Patch] MdeModulePkg/UsbMassStorageDxe:
> Fix
> > USB Mass Storage detection
> >
> > Mike,
> >
> > Have you evaluated whether the code in
> > PeiUsbRequestSense() of PeiAtapi.c also needs to be updated?
> >
> >
> > Thanks,
> > Star
> > -----Original Message-----
> > From: Kinney, Michael D
> > Sent: Thursday, November 9, 2017 6:03 AM
> > To: edk2-devel@lists.01.org
> > Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric
> > <eric.dong@intel.com>
> > Subject: [Patch] MdeModulePkg/UsbMassStorageDxe: Fix
> USB
> > Mass Storage detection
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=766
> >
> > Update logic to not return an error from
> > UsbBootRequestSense() if a Request Sense command
> responds
> > with no sense information.
> > It is legal for a USB mass storage device to respond to
> a
> > Request Sense command with a SenseKey of
> > USB_BOOT_SENSE_NO_SENSE and an Additional Sense Code of
> > USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION.
> >
> > This is described in Section 3.3 of the Universal
> Serial
> > Bus Mass Storage Specification For Bootability:
> >
> >
> http://www.usb.org/developers/docs/devclass_docs/usb_msc_
> > boot_1.0.pdf
> >
> > The previous logic returned an error of EFI_NO_RESPONSE
> > and this caused USB mass storage devices such as a USB
> > floppy drive to not be detected.
> >
> > 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 |
> > 11 +++++++++--
> > MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h |
> 9
> > +++++----
> >  2 files changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git
> > a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
> > b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c
> > index 0c46f888eb..2eb30f0c5f 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.
> >
> > -Copyright (c) 2007 - 2016, Intel Corporation. All
> rights
> > reserved.<BR>
> > +Copyright (c) 2007 - 2017, Intel Corporation. All
> rights
> > reserved.<BR>
> >  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 @@ -80,7 +80,14 @@ UsbBootRequestSense (
> >    switch (USB_BOOT_SENSE_KEY (SenseData.SenseKey)) {
> >
> >    case USB_BOOT_SENSE_NO_SENSE:
> > -    Status = EFI_NO_RESPONSE;
> > +    if (SenseData.Asc ==
> > USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION) {
> > +      //
> > +      // It is not an error if a device does not have
> > additional sense information
> > +      //
> > +      Status = EFI_SUCCESS;
> > +    } else {
> > +      Status = EFI_NO_RESPONSE;
> > +    }
> >      break;
> >
> >    case USB_BOOT_SENSE_RECOVERED:
> > diff --git
> > a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
> > b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.h
> > index c4082558fa..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.
> >
> > -Copyright (c) 2007 - 2012, Intel Corporation. All
> rights
> > reserved.<BR>
> > +Copyright (c) 2007 - 2017, Intel Corporation. All
> rights
> > reserved.<BR>
> >  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 @@ -51,9 +51,10 @@ WITHOUT WARRANTIES OR
> > REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> >  #define USB_BOOT_SENSE_VOLUME_OVERFLOW  0x0D ///<
> > Partition overflow
> >  #define USB_BOOT_SENSE_MISCOMPARE       0x0E ///<
> Source
> > data mis-match while verfying.
> >
> > -#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_NO_ADDITIONAL_SENSE_INFORMATION
> > 0x00
> > +#define USB_BOOT_ASC_NOT_READY
> > 0x04
> > +#define USB_BOOT_ASC_NO_MEDIA
> > 0x3A
> > +#define USB_BOOT_ASC_MEDIA_CHANGE
> > 0x28
> >
> >  //
> >  // Supported PDT codes, or Peripheral Device Type
> > --
> > 2.14.2.windows.3

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