From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x232.google.com (mail-oi0-x232.google.com [IPv6:2607:f8b0:4003:c06::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AC68C21A18AAB for ; Tue, 18 Apr 2017 06:19:26 -0700 (PDT) Received: by mail-oi0-x232.google.com with SMTP id r203so176080383oib.3 for ; Tue, 18 Apr 2017 06:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:content-language:mime-version; bh=MvtRGx5EozmlyMx7Febhafci7s/b8DF5YSPohzjH48k=; b=ICAihwFvtz1agcde9BE73D2W5HsKeOTwIMAT5y+5GVwyTs3dx6A65a7nq317zXzOC+ P7Z48zsLJsh3Ujkszd7X4ro58SrvgpVgN1tEhMU6n3xBbr1X1GMJeX9jdK70qvongq3X aGfgc9QAcFI6PVWeT7dG2sk4JLdeMHALqi2dA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:thread-topic:thread-index :date:message-id:references:in-reply-to:content-language :mime-version; bh=MvtRGx5EozmlyMx7Febhafci7s/b8DF5YSPohzjH48k=; b=M+ZsQq/mGe1bLCHoq1BqVVOB3f8vCJx4b4ghcKGiMp365eBm4/+aB8Gr7kDTgVZzAh 4QQeygBmXDhDZAUEtae4EC7GxsrMef0YBKU/PZB22I1k6NE72sy5PJi6fb3wldTx2VvC VhX2Hp+Pz/jp/S2vAVpkBHohnAPXkOKAi0k/NfSfB0oH+bYnehKqTj9SNTK5AX0zlRpg m/5D7RznOxXWTOTzp+jrCan4pE4cdLxFDw7Cy2eh9FLRvsNk55u1JLNFWSj6fyMFsN+U fpWRG1W1rbmhLq2gIGlzGUHwKBgaRd8n+fxJ+HSfAdT9n9NCCR4JMSejh1UVzmX9wUif V3Fw== X-Gm-Message-State: AN3rC/4YUp/laBYU29wyYsUxO1zei1/URlZGA535PXm4M37oPuHZ5uuY H6nsbIpWQYzPZbat X-Received: by 10.157.18.193 with SMTP id g59mr7141847otg.261.1492521565767; Tue, 18 Apr 2017 06:19:25 -0700 (PDT) Received: from CY1PR15MB0730.namprd15.prod.outlook.com ([132.245.253.237]) by smtp.gmail.com with ESMTPSA id e46sm6154513otc.17.2017.04.18.06.19.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Apr 2017 06:19:25 -0700 (PDT) From: Haojian Zhuang To: "Wu, Hao A" 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: AQHSte56fG5/3JN/4UyN6HxalQlNhqHI0HKAgADKXLuAAYJhAIAAAzQU X-MS-Exchange-MessageSentRepresentingType: 2 Date: Tue, 18 Apr 2017 13:17:27 +0000 Message-ID: References: <1492263886-17209-1-git-send-email-haojian.zhuang@linaro.org>, , In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: 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:19:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable Hi Hao, I tried to edit bProvisioningType. And I finially found that it=1B$B!G=1B(B= s the read-only bit. And my understanding on =1B$B!H=1B(Breturn any data by discard operation=1B= $B!I=1B(B is implemented by vendor. I think it means returning any random d= ata by controller, not original programmed data from UFS device. Best Regards Haojian From: Wu, Hao A Sent: 2017=1B$BG/=1B(B4=1B$B7n=1B(B18=1B$BF|=1B(B 21:06 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, 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