[edk2] [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL

Haojian Zhuang posted 1 patch 7 years, 6 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[edk2] [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL
Posted by Haojian Zhuang 7 years, 6 months ago
If bit TPZ and bit TPRZ are set, the erase feature is implemented.
If bit TPZ is set and bit TPRZ is clear, the discard feature is
implemented. And discard is a non-secure variant of the erase
functionality.

So the detecting operation of EFI_ERASE_BLOCK_PROTOCOL, we should
consider to support both functionality. Since discard functionality is
only supported in some UFS devices.

And both of these two features are relied on UNMAP command.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index b5eff25..6e12e4f 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -5400,11 +5400,11 @@ DetermineInstallEraseBlock (
   if (CommandStatus == EFI_SUCCESS) {
     //
     // Universal Flash Storage (UFS) Version 2.0
-    // Section 11.3.9.2
+    // Section 11.3.9.2 & Section 12.2.3
     // Bits TPE and TPRZ should both be set to enable the erase feature on UFS.
+    // Setting bit TPE and clearing bit TPRZ to enable the discard feature on UFS.
     //
-    if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
-        ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) {
+    if ((CapacityData16->LowestAlignLogic2 & BIT7) == 0) {
       DEBUG ((
         EFI_D_VERBOSE,
         "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL
Posted by Wu, Hao A 7 years, 6 months ago
Hi Haojian,

The reason for me to check both bits TPE and TPRZ being set when
determining whether the Erase Block Protocol should be produced is:

According to the Universal Flash Storage (UFS) Version 2.0 spec Section
12.2.3.2 Discard:
Since the TPRZ bit is set to zero if the discard functionality is enabled,
a READ command specifying a deallocated LBA may return any data.

And according to the UEFI 2.6 spec Section 12.12 in the 'Description' part
of the EFI_ERASE_BLOCK_PROTOCOL.EraseBlocks():
The EraseBlocks() function erases the requested number of device blocks.
Upon the successful execution of EraseBlocks() with an EFI_SUCCESS return
code, any subsequent reads of the same LBA range would return an
initialized/formatted value.

Since after the 'discard' operation, the device may return any data. My
concern is that the 'discard' operation does not match exactly with the
description of the behavior of the EraseBlocks() by the UEFI spec to
return an initialized/formatted value.

Best Regards,
Hao Wu


> -----Original Message-----
> From: Haojian Zhuang [mailto:haojian.zhuang@linaro.org]
> Sent: Saturday, April 15, 2017 9:45 PM
> To: Wu, Hao A; Tian, Feng; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org;
> edk2-devel@lists.01.org
> Cc: Haojian Zhuang
> Subject: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support
> EFI_ERASE_BLOCK_PROTOCOL
> 
> If bit TPZ and bit TPRZ are set, the erase feature is implemented.
> If bit TPZ is set and bit TPRZ is clear, the discard feature is
> implemented. And discard is a non-secure variant of the erase
> functionality.
> 
> So the detecting operation of EFI_ERASE_BLOCK_PROTOCOL, we should
> consider to support both functionality. Since discard functionality is
> only supported in some UFS devices.
> 
> And both of these two features are relied on UNMAP command.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> ---
>  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> index b5eff25..6e12e4f 100644
> --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> @@ -5400,11 +5400,11 @@ DetermineInstallEraseBlock (
>    if (CommandStatus == EFI_SUCCESS) {
>      //
>      // Universal Flash Storage (UFS) Version 2.0
> -    // Section 11.3.9.2
> +    // Section 11.3.9.2 & Section 12.2.3
>      // Bits TPE and TPRZ should both be set to enable the erase feature on UFS.
> +    // Setting bit TPE and clearing bit TPRZ to enable the discard feature on UFS.
>      //
> -    if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
> -        ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) {
> +    if ((CapacityData16->LowestAlignLogic2 & BIT7) == 0) {
>        DEBUG ((
>          EFI_D_VERBOSE,
>          "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",
> --
> 2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL
Posted by Haojian Zhuang 7 years, 6 months ago
Hi Hao,

I tried the discard operation on my UFS device. It just return 0.

And erase operation isn’t supported on my UFS device. If I don’t support discard operation, I can’t erase blocks at all.

Best Regards
Haojian

From: Wu, Hao A<mailto:hao.a.wu@intel.com>
Sent: 2017年4月17日 9:59
To: Haojian Zhuang<mailto:haojian.zhuang@linaro.org>
Cc: Tian, Feng<mailto:feng.tian@intel.com>; leif.lindholm@linaro.org<mailto:leif.lindholm@linaro.org>; ard.biesheuvel@linaro.org<mailto:ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Subject: RE: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL

Hi Haojian,

The reason for me to check both bits TPE and TPRZ being set when
determining whether the Erase Block Protocol should be produced is:

According to the Universal Flash Storage (UFS) Version 2.0 spec Section
12.2.3.2 Discard:
Since the TPRZ bit is set to zero if the discard functionality is enabled,
a READ command specifying a deallocated LBA may return any data.

And according to the UEFI 2.6 spec Section 12.12 in the 'Description' part
of the EFI_ERASE_BLOCK_PROTOCOL.EraseBlocks():
The EraseBlocks() function erases the requested number of device blocks.
Upon the successful execution of EraseBlocks() with an EFI_SUCCESS return
code, any subsequent reads of the same LBA range would return an
initialized/formatted value.

Since after the 'discard' operation, the device may return any data. My
concern is that the 'discard' operation does not match exactly with the
description of the behavior of the EraseBlocks() by the UEFI spec to
return an initialized/formatted value.

Best Regards,
Hao Wu


> -----Original Message-----
> From: Haojian Zhuang [mailto:haojian.zhuang@linaro.org]
> Sent: Saturday, April 15, 2017 9:45 PM
> To: Wu, Hao A; Tian, Feng; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org;
> edk2-devel@lists.01.org
> Cc: Haojian Zhuang
> Subject: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support
> EFI_ERASE_BLOCK_PROTOCOL
>
> If bit TPZ and bit TPRZ are set, the erase feature is implemented.
> If bit TPZ is set and bit TPRZ is clear, the discard feature is
> implemented. And discard is a non-secure variant of the erase
> functionality.
>
> So the detecting operation of EFI_ERASE_BLOCK_PROTOCOL, we should
> consider to support both functionality. Since discard functionality is
> only supported in some UFS devices.
>
> And both of these two features are relied on UNMAP command.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> ---
>  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> index b5eff25..6e12e4f 100644
> --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> @@ -5400,11 +5400,11 @@ DetermineInstallEraseBlock (
>    if (CommandStatus == EFI_SUCCESS) {
>      //
>      // Universal Flash Storage (UFS) Version 2.0
> -    // Section 11.3.9.2
> +    // Section 11.3.9.2 & Section 12.2.3
>      // Bits TPE and TPRZ should both be set to enable the erase feature on UFS.
> +    // Setting bit TPE and clearing bit TPRZ to enable the discard feature on UFS.
>      //
> -    if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
> -        ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) {
> +    if ((CapacityData16->LowestAlignLogic2 & BIT7) == 0) {
>        DEBUG ((
>          EFI_D_VERBOSE,
>          "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",
> --
> 2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL
Posted by Wu, Hao A 7 years, 6 months ago
Hi Haojian,

I checked the UFS 2.0 spec, in Section 12.1 UFS Security Feature Support
Requirements:

The security features outlined in this specification are mandatory for all
devices.

and the 'Erase Operation' is listed under section 12.2.2.2, which makes me
think that the erase option should be supported by a UFS device if it
follows the specification.

Also, have you tried setting the 'bProvisioningType' to 03h by writing the
Configuration Descriptor? According to Section 12.2.3.5, doing so will
enable thin provisioning and set TPRZ to one, if I understand correctly.

Could you help to test if doing so can enable the erase operation on your
UFS device? Thanks in advance.

Best Regards,
Hao Wu

From: Haojian Zhuang [mailto:haojian.zhuang@linaro.org]
Sent: Monday, April 17, 2017 10:03 PM
To: Wu, Hao A
Cc: Tian, Feng; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org; edk2-devel@lists.01.org
Subject: RE: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL

Hi Hao,

I tried the discard operation on my UFS device. It just return 0.

And erase operation isn’t supported on my UFS device. If I don’t support discard operation, I can’t erase blocks at all.

Best Regards
Haojian

From: Wu, Hao A<mailto:hao.a.wu@intel.com>
Sent: 2017年4月17日 9:59
To: Haojian Zhuang<mailto:haojian.zhuang@linaro.org>
Cc: Tian, Feng<mailto:feng.tian@intel.com>; leif.lindholm@linaro.org<mailto:leif.lindholm@linaro.org>; ard.biesheuvel@linaro.org<mailto:ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Subject: RE: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL

Hi Haojian,

The reason for me to check both bits TPE and TPRZ being set when
determining whether the Erase Block Protocol should be produced is:

According to the Universal Flash Storage (UFS) Version 2.0 spec Section
12.2.3.2 Discard:
Since the TPRZ bit is set to zero if the discard functionality is enabled,
a READ command specifying a deallocated LBA may return any data.

And according to the UEFI 2.6 spec Section 12.12 in the 'Description' part
of the EFI_ERASE_BLOCK_PROTOCOL.EraseBlocks():
The EraseBlocks() function erases the requested number of device blocks.
Upon the successful execution of EraseBlocks() with an EFI_SUCCESS return
code, any subsequent reads of the same LBA range would return an
initialized/formatted value.

Since after the 'discard' operation, the device may return any data. My
concern is that the 'discard' operation does not match exactly with the
description of the behavior of the EraseBlocks() by the UEFI spec to
return an initialized/formatted value.

Best Regards,
Hao Wu


> -----Original Message-----
> From: Haojian Zhuang [mailto:haojian.zhuang@linaro.org]
> Sent: Saturday, April 15, 2017 9:45 PM
> To: Wu, Hao A; Tian, Feng; leif.lindholm@linaro.org<mailto:leif.lindholm@linaro.org>; ard.biesheuvel@linaro.org<mailto:ard.biesheuvel@linaro.org>;
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Haojian Zhuang
> Subject: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support
> EFI_ERASE_BLOCK_PROTOCOL
>
> If bit TPZ and bit TPRZ are set, the erase feature is implemented.
> If bit TPZ is set and bit TPRZ is clear, the discard feature is
> implemented. And discard is a non-secure variant of the erase
> functionality.
>
> So the detecting operation of EFI_ERASE_BLOCK_PROTOCOL, we should
> consider to support both functionality. Since discard functionality is
> only supported in some UFS devices.
>
> And both of these two features are relied on UNMAP command.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org<mailto:haojian.zhuang@linaro.org>>
> ---
>  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> index b5eff25..6e12e4f 100644
> --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> @@ -5400,11 +5400,11 @@ DetermineInstallEraseBlock (
>    if (CommandStatus == EFI_SUCCESS) {
>      //
>      // Universal Flash Storage (UFS) Version 2.0
> -    // Section 11.3.9.2
> +    // Section 11.3.9.2 & Section 12.2.3
>      // Bits TPE and TPRZ should both be set to enable the erase feature on UFS.
> +    // Setting bit TPE and clearing bit TPRZ to enable the discard feature on UFS.
>      //
> -    if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
> -        ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) {
> +    if ((CapacityData16->LowestAlignLogic2 & BIT7) == 0) {
>        DEBUG ((
>          EFI_D_VERBOSE,
>          "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",
> --
> 2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL
Posted by Haojian Zhuang 7 years, 6 months ago
Hi Hao,

I tried to edit bProvisioningType. And I finially found that it’s the read-only bit.

And my understanding on “return any data by discard operation” is implemented by vendor. I think it means returning any random data by controller, not original programmed data from UFS device.

Best Regards
Haojian

From: Wu, Hao A<mailto:hao.a.wu@intel.com>
Sent: 2017年4月18日 21:06
To: Haojian Zhuang<mailto:haojian.zhuang@linaro.org>
Cc: Tian, Feng<mailto:feng.tian@intel.com>; leif.lindholm@linaro.org<mailto:leif.lindholm@linaro.org>; ard.biesheuvel@linaro.org<mailto:ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Subject: RE: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL

Hi Haojian,

I checked the UFS 2.0 spec, in Section 12.1 UFS Security Feature Support
Requirements:

The security features outlined in this specification are mandatory for all
devices.

and the 'Erase Operation' is listed under section 12.2.2.2, which makes me
think that the erase option should be supported by a UFS device if it
follows the specification.

Also, have you tried setting the 'bProvisioningType' to 03h by writing the
Configuration Descriptor? According to Section 12.2.3.5, doing so will
enable thin provisioning and set TPRZ to one, if I understand correctly.

Could you help to test if doing so can enable the erase operation on your
UFS device? Thanks in advance.

Best Regards,
Hao Wu

From: Haojian Zhuang [mailto:haojian.zhuang@linaro.org]
Sent: Monday, April 17, 2017 10:03 PM
To: Wu, Hao A
Cc: Tian, Feng; leif.lindholm@linaro.org; ard.biesheuvel@linaro.org; edk2-devel@lists.01.org
Subject: RE: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL

Hi Hao,

I tried the discard operation on my UFS device. It just return 0.

And erase operation isn’t supported on my UFS device. If I don’t support discard operation, I can’t erase blocks at all.

Best Regards
Haojian

From: Wu, Hao A<mailto:hao.a.wu@intel.com>
Sent: 2017年4月17日 9:59
To: Haojian Zhuang<mailto:haojian.zhuang@linaro.org>
Cc: Tian, Feng<mailto:feng.tian@intel.com>; leif.lindholm@linaro.org<mailto:leif.lindholm@linaro.org>; ard.biesheuvel@linaro.org<mailto:ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
Subject: RE: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL

Hi Haojian,

The reason for me to check both bits TPE and TPRZ being set when
determining whether the Erase Block Protocol should be produced is:

According to the Universal Flash Storage (UFS) Version 2.0 spec Section
12.2.3.2 Discard:
Since the TPRZ bit is set to zero if the discard functionality is enabled,
a READ command specifying a deallocated LBA may return any data.

And according to the UEFI 2.6 spec Section 12.12 in the 'Description' part
of the EFI_ERASE_BLOCK_PROTOCOL.EraseBlocks():
The EraseBlocks() function erases the requested number of device blocks.
Upon the successful execution of EraseBlocks() with an EFI_SUCCESS return
code, any subsequent reads of the same LBA range would return an
initialized/formatted value.

Since after the 'discard' operation, the device may return any data. My
concern is that the 'discard' operation does not match exactly with the
description of the behavior of the EraseBlocks() by the UEFI spec to
return an initialized/formatted value.

Best Regards,
Hao Wu


> -----Original Message-----
> From: Haojian Zhuang [mailto:haojian.zhuang@linaro.org]
> Sent: Saturday, April 15, 2017 9:45 PM
> To: Wu, Hao A; Tian, Feng; leif.lindholm@linaro.org<mailto:leif.lindholm@linaro.org>; ard.biesheuvel@linaro.org<mailto:ard.biesheuvel@linaro.org>;
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Haojian Zhuang
> Subject: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support
> EFI_ERASE_BLOCK_PROTOCOL
>
> If bit TPZ and bit TPRZ are set, the erase feature is implemented.
> If bit TPZ is set and bit TPRZ is clear, the discard feature is
> implemented. And discard is a non-secure variant of the erase
> functionality.
>
> So the detecting operation of EFI_ERASE_BLOCK_PROTOCOL, we should
> consider to support both functionality. Since discard functionality is
> only supported in some UFS devices.
>
> And both of these two features are relied on UNMAP command.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org<mailto:haojian.zhuang@linaro.org>>
> ---
>  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> index b5eff25..6e12e4f 100644
> --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> @@ -5400,11 +5400,11 @@ DetermineInstallEraseBlock (
>    if (CommandStatus == EFI_SUCCESS) {
>      //
>      // Universal Flash Storage (UFS) Version 2.0
> -    // Section 11.3.9.2
> +    // Section 11.3.9.2 & Section 12.2.3
>      // Bits TPE and TPRZ should both be set to enable the erase feature on UFS.
> +    // Setting bit TPE and clearing bit TPRZ to enable the discard feature on UFS.
>      //
> -    if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
> -        ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) {
> +    if ((CapacityData16->LowestAlignLogic2 & BIT7) == 0) {
>        DEBUG ((
>          EFI_D_VERBOSE,
>          "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",
> --
> 2.7.4


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL
Posted by Paolo Bonzini 7 years, 6 months ago

On 15/04/2017 15:44, Haojian Zhuang wrote:
> If bit TPZ and bit TPRZ are set, the erase feature is implemented.
> If bit TPZ is set and bit TPRZ is clear, the discard feature is
> implemented. And discard is a non-secure variant of the erase
> functionality.
> 
> So the detecting operation of EFI_ERASE_BLOCK_PROTOCOL, we should
> consider to support both functionality. Since discard functionality is
> only supported in some UFS devices.
> 
> And both of these two features are relied on UNMAP command.

Hi,

you need to use WRITE SAME, with a zero payload and the UNMAP bit set in
the command descriptor, in order to achieve a "secure" erase
functionality.  UNMAP is only an advisory command, and does not
guarantee that the blocks are unmapped.

Discard can use either WRITE SAME or UNMAP.

Also,

>      // Bits TPE and TPRZ should both be set to enable the erase feature on UFS.
> +    // Setting bit TPE and clearing bit TPRZ to enable the discard feature on UFS.
>      //
> -    if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) ||
> -        ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) {
> +    if ((CapacityData16->LowestAlignLogic2 & BIT7) == 0) {
>        DEBUG ((
>          EFI_D_VERBOSE,
>          "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n",

The debug message is now wrong.

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