From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6D14921A18AAB for ; Tue, 18 Apr 2017 06:06:04 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 18 Apr 2017 06:06:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208,217";a="88849240" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 18 Apr 2017 06:06:03 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 18 Apr 2017 06:06:03 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 18 Apr 2017 06:06:02 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.178]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.193]) with mapi id 14.03.0319.002; Tue, 18 Apr 2017 21:06:00 +0800 From: "Wu, Hao A" To: Haojian Zhuang CC: "Tian, Feng" , "leif.lindholm@linaro.org" , "ard.biesheuvel@linaro.org" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL Thread-Index: AQHSte55tnpna+ATtUKQPesbPciQFaHIw3EQgABRQICAAgOJ4A== Date: Tue, 18 Apr 2017 13:06:00 +0000 Message-ID: References: <1492263886-17209-1-git-send-email-haojian.zhuang@linaro.org>, In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BLOCK_PROTOCOL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2017 13:06:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable 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-d= evel@lists.01.org Subject: RE: [PATCH] MdeModulePkg: ScsiDiskDxe: fix to support EFI_ERASE_BL= OCK_PROTOCOL Hi Hao, I tried the discard operation on my UFS device. It just return 0. And erase operation isn=1B$B!G=1B(Bt supported on my UFS device. If I don= =1B$B!G=1B(Bt support discard operation, I can=1B$B!G=1B(Bt erase blocks at= all. Best Regards Haojian From: Wu, Hao A Sent: 2017=1B$BG/=1B(B4=1B$B7n=1B(B17=1B$BF|=1B(B 9:59 To: Haojian Zhuang 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_BL= OCK_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 > > --- > 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 =3D=3D 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 featu= re on UFS. > // > - if (((CapacityData16->LowestAlignLogic2 & BIT7) =3D=3D 0) || > - ((CapacityData16->LowestAlignLogic2 & BIT6) =3D=3D 0)) { > + if ((CapacityData16->LowestAlignLogic2 & BIT7) =3D=3D 0) { > DEBUG (( > EFI_D_VERBOSE, > "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n", > -- > 2.7.4