From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 E312F21A6F105 for ; Sun, 16 Apr 2017 18:58:54 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 16 Apr 2017 18:58:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,210,1488873600"; d="scan'208";a="88227102" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga005.jf.intel.com with ESMTP; 16 Apr 2017 18:58:54 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 16 Apr 2017 18:58:54 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 16 Apr 2017 18:58:53 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.178]) by shsmsx102.ccr.corp.intel.com ([169.254.2.246]) with mapi id 14.03.0319.002; Mon, 17 Apr 2017 09:58:50 +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+ATtUKQPesbPciQFaHIw3EQ Date: Mon, 17 Apr 2017 01:58:49 +0000 Message-ID: References: <1492263886-17209-1-git-send-email-haojian.zhuang@linaro.org> In-Reply-To: <1492263886-17209-1-git-send-email-haojian.zhuang@linaro.org> 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 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 01:58:55 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 >=20 > 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. >=20 > 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. >=20 > And both of these two features are relied on UNMAP command. >=20 > 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(-) >=20 > 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