From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x231.google.com (mail-oi0-x231.google.com [IPv6:2607:f8b0:4003:c06::231]) (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 A3DA721954061 for ; Mon, 17 Apr 2017 07:04:33 -0700 (PDT) Received: by mail-oi0-x231.google.com with SMTP id f22so142674102oib.2 for ; Mon, 17 Apr 2017 07:04:33 -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=Ec8EqkIRGpy20Tfl0mBVcdtvWeWow1fFIdwfYn4rC9s=; b=Mk8Iw+WJ3ZJf0uWDPezOXAqli1FUCVFLGiae+R+G1GtfRzADxojZ+omQit0ijHPVEu sfVOG03cnb2CWHynU+UrAFBotN5h1dmME7MBIVbiXBcTCErqCvLIvn6MWVPb5iqi/hxE ehSI3EdmbcsMn+YCX3U8fNb+csfwCHHAb2rnc= 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=Ec8EqkIRGpy20Tfl0mBVcdtvWeWow1fFIdwfYn4rC9s=; b=dIzs7I79q1zD9pCr8zz7DagUabAe6lM5jFL2N87dxBeoHGc1evfNDL6YKOh4v5VHX7 EdDWDFSAsTb1f7/myRGUbUzLxgNd/Isto1t7kZ4N5JG4eua5A40agT0snKZed+FwbqEi /UY0savKv9uJ8JQtgjE0uXFJml3kHpyPIiax6hU9heJc9ww7MuJfYlHE/wNlW1MAUBFK J2BaLbP2ZSrPKYaCQQ8S22AJ27mriCE4jpVZmXyB/Gp6t3mqLPHm/l3LIJSFOVokbBIC DzI3DjsGyWltHvoITd0YOH8GptsEznMIXoOb6p9yZXt9qJB9ZBmtm57utTg1rbH6k7++ VdWA== X-Gm-Message-State: AN3rC/5FPbRkNRY8p0EOOEiqf7GJDj70T+xiu/BY2nPd9NKwc3I+/RTp x3d1NkouY6TFYm2p X-Received: by 10.157.3.231 with SMTP id f94mr4609006otf.140.1492437872782; Mon, 17 Apr 2017 07:04:32 -0700 (PDT) Received: from CY1PR15MB0730.namprd15.prod.outlook.com ([132.245.253.237]) by smtp.gmail.com with ESMTPSA id u74sm4671961oia.28.2017.04.17.07.04.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Apr 2017 07:04:32 -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/4UyN6HxalQlNhqHI0HKAgADKXLs= X-MS-Exchange-MessageSentRepresentingType: 2 Date: Mon, 17 Apr 2017 14:03:05 +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: Mon, 17 Apr 2017 14:04:34 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable 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@linar= o.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