lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1891546521.01607998501831.JavaMail.epsvc@epcpadp3>
Date:   Tue, 15 Dec 2020 10:24:52 +0900
From:   Daejun Park <daejun7.park@...sung.com>
To:     Greg KH <gregkh@...uxfoundation.org>,
        Daejun Park <daejun7.park@...sung.com>
CC:     "avri.altman@....com" <avri.altman@....com>,
        "jejb@...ux.ibm.com" <jejb@...ux.ibm.com>,
        "martin.petersen@...cle.com" <martin.petersen@...cle.com>,
        "asutoshd@...eaurora.org" <asutoshd@...eaurora.org>,
        "beanhuo@...ron.com" <beanhuo@...ron.com>,
        "stanley.chu@...iatek.com" <stanley.chu@...iatek.com>,
        "cang@...eaurora.org" <cang@...eaurora.org>,
        "bvanassche@....org" <bvanassche@....org>,
        "tomas.winkler@...el.com" <tomas.winkler@...el.com>,
        ALIM AKHTAR <alim.akhtar@...sung.com>,
        "gregkh@...gle.com" <gregkh@...gle.com>,
        "linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Sang-yoon Oh <sangyoon.oh@...sung.com>,
        Sung-Jun Park <sungjun07.park@...sung.com>,
        yongmyung lee <ymhungry.lee@...sung.com>,
        Jinyoung CHOI <j-young.choi@...sung.com>,
        Adel Choi <adel.choi@...sung.com>,
        BoRam Shin <boram.shin@...sung.com>,
        SEUNGUK SHIN <seunguk.shin@...sung.com>
Subject: RE: Re: [PATCH v13 1/3] scsi: ufs: Introduce HPB feature

Hi Greg,

> > This is a patch for the HPB feature.
> > This patch adds HPB function calls to UFS core driver.
> 
> Ok, I asked if there was anything left to do, and I see some stuff here.
> 
> First off, this changelog is really really sparse.  It needs to be much
> more detailed, saying what HPB is, where in the specification it is
> defined, and why Linux needs to support it.
> 
> Please fill all of that out, otherwise people that do not follow UFS do
> not know what this is.

OK, I will add the following description in this patch comment.

===
This is a patch for the HPB initialization and adds HPB function calls to
UFS core driver.

NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of IO requests to the corresponding physical
addresses of the flash storage.
In UFS, Logical-address-to-Physical-address (L2P) map data, which is
required to identify the physical address for the requested IOs, can only
be partially stored in SRAM from NAND flash. Due to this partial loading, 
accessing the flash address area where the L2P information for that address
is not loaded in the SRAM can result in serious performance degradation.

The basic concept of HPB is to cache L2P mapping entries in host system
memory so that both physical block address (PBA) and logical block address
(LBA) can be delivered in HPB read command.
The HPB READ command allows to read data faster than a read command in UFS
since it provides the physical address (HPB Entry) of the desired logical
block in addition to its logical address. The UFS device can access the
physical block in NAND directly without searching and uploading L2P mapping
table. This improves read performance because the NAND read operation for
uploading L2P mapping table is removed.

In HPB initialization, the host checks if the UFS device supports HPB
feature and retrieves related device capabilities. Then, some HPB
parameters are configured in the device.
===
> > 
> > Reviewed-by: Bart Van Assche <bvanassche@....org>
> > Acked-by: Avri Altman <Avri.Altman@....com>
> > Tested-by: Bean Huo <beanhuo@...ron.com>
> > Signed-off-by: Daejun Park <daejun7.park@...sung.com>
> > ---
> >  drivers/scsi/ufs/Kconfig     |   9 +
> >  drivers/scsi/ufs/Makefile    |   1 +
> >  drivers/scsi/ufs/ufs-sysfs.c |  18 ++
> >  drivers/scsi/ufs/ufs.h       |  13 +
> >  drivers/scsi/ufs/ufshcd.c    |  48 +++
> >  drivers/scsi/ufs/ufshcd.h    |  23 +-
> >  drivers/scsi/ufs/ufshpb.c    | 583 +++++++++++++++++++++++++++++++++++
> >  drivers/scsi/ufs/ufshpb.h    | 167 ++++++++++
> >  8 files changed, 861 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/scsi/ufs/ufshpb.c
> >  create mode 100644 drivers/scsi/ufs/ufshpb.h
> > 
> > diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
> > index dcdb4eb1f90b..fd1cf7bc0eca 100644
> > --- a/drivers/scsi/ufs/Kconfig
> > +++ b/drivers/scsi/ufs/Kconfig
> > @@ -181,3 +181,12 @@ config SCSI_UFS_CRYPTO
> >  	  Enabling this makes it possible for the kernel to use the crypto
> >  	  capabilities of the UFS device (if present) to perform crypto
> >  	  operations on data being transferred to/from the device.
> > +
> > +config SCSI_UFS_HPB
> > +	bool "Support UFS Host Performance Booster"
> > +	depends on SCSI_UFSHCD
> > +	help
> > +	  The UFS HPB feature improves random read performance. It caches
> > +	  L2P (logical to physical) map of UFS to host DRAM. The driver uses HPB
> > +	  read command by piggybacking physical page number for bypassing FTL (flash
> > +	  translation layer)'s L2P address translation.
> > diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
> > index 4679af1b564e..663e17cee359 100644
> > --- a/drivers/scsi/ufs/Makefile
> > +++ b/drivers/scsi/ufs/Makefile
> > @@ -11,6 +11,7 @@ obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
> >  ufshcd-core-y				+= ufshcd.o ufs-sysfs.o
> >  ufshcd-core-$(CONFIG_SCSI_UFS_BSG)	+= ufs_bsg.o
> >  ufshcd-core-$(CONFIG_SCSI_UFS_CRYPTO) += ufshcd-crypto.o
> > +ufshcd-core-$(CONFIG_SCSI_UFS_HPB) += ufshpb.o
> >  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
> >  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
> >  obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o
> > diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
> > index bdcd27faa054..6ccda6e57c7f 100644
> > --- a/drivers/scsi/ufs/ufs-sysfs.c
> > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > @@ -284,6 +284,8 @@ UFS_DEVICE_DESC_PARAM(device_version, _DEV_VER, 2);
> >  UFS_DEVICE_DESC_PARAM(number_of_secure_wpa, _NUM_SEC_WPA, 1);
> >  UFS_DEVICE_DESC_PARAM(psa_max_data_size, _PSA_MAX_DATA, 4);
> >  UFS_DEVICE_DESC_PARAM(psa_state_timeout, _PSA_TMT, 1);
> > +UFS_DEVICE_DESC_PARAM(hpb_version, _HPB_VER, 2);
> > +UFS_DEVICE_DESC_PARAM(hpb_control, _HPB_CONTROL, 1);
> >  UFS_DEVICE_DESC_PARAM(ext_feature_sup, _EXT_UFS_FEATURE_SUP, 4);
> >  UFS_DEVICE_DESC_PARAM(wb_presv_us_en, _WB_PRESRV_USRSPC_EN, 1);
> >  UFS_DEVICE_DESC_PARAM(wb_type, _WB_TYPE, 1);
> > @@ -316,6 +318,8 @@ static struct attribute *ufs_sysfs_device_descriptor[] = {
> >  	&dev_attr_number_of_secure_wpa.attr,
> >  	&dev_attr_psa_max_data_size.attr,
> >  	&dev_attr_psa_state_timeout.attr,
> > +	&dev_attr_hpb_version.attr,
> > +	&dev_attr_hpb_control.attr,
> 
> You add a bunch of new sysfs attributes, but I do not see any
> Documentation/ABI/ entries for them.  Why not?  Those are required for
> any new sysfs files added to the kernel.  Please fix that up when you
> resend this.

I will add ABI entries for them.

> > --- /dev/null
> > +++ b/drivers/scsi/ufs/ufshpb.c
> > @@ -0,0 +1,583 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> 
> Do you really mean "or later"?  I have to ask, sorry.

I will change this: "// SPDX-License-Identifier: GPL-2.0"

> > +/*
> > + * Universal Flash Storage Host Performance Booster
> > + *
> > + * Copyright (C) 2017-2018 Samsung Electronics Co., Ltd.
> 
> This has not been touched since 2018?  I somehow doubt that :(
> 

It will be changed to "2017-2020".

> > +static void ufshpb_lu_parameter_init(struct ufs_hba *hba,
> > +				     struct ufshpb_lu *hpb,
> > +				     struct ufshpb_dev_info *hpb_dev_info,
> > +				     struct ufshpb_lu_info *hpb_lu_info)
> > +{
> > +	u32 entries_per_rgn;
> > +	u64 rgn_mem_size, tmp;
> > +
> > +	hpb->lu_pinned_start = hpb_lu_info->pinned_start;
> > +	hpb->lu_pinned_end = hpb_lu_info->num_pinned ?
> > +		(hpb_lu_info->pinned_start + hpb_lu_info->num_pinned - 1)
> > +		: PINNED_NOT_SET;
> > +
> > +	rgn_mem_size = (1ULL << hpb_dev_info->rgn_size) * HPB_RGN_SIZE_UNIT
> > +			* HPB_ENTRY_SIZE;
> > +	do_div(rgn_mem_size, HPB_ENTRY_BLOCK_SIZE);
> > +	hpb->srgn_mem_size = (1ULL << hpb_dev_info->srgn_size)
> > +		* HPB_RGN_SIZE_UNIT / HPB_ENTRY_BLOCK_SIZE * HPB_ENTRY_SIZE;
> > +
> > +	tmp = rgn_mem_size;
> > +	do_div(tmp, HPB_ENTRY_SIZE);
> > +	entries_per_rgn = (u32)tmp;
> > +	hpb->entries_per_rgn_shift = ilog2(entries_per_rgn);
> > +	hpb->entries_per_rgn_mask = entries_per_rgn - 1;
> > +
> > +	hpb->entries_per_srgn = hpb->srgn_mem_size / HPB_ENTRY_SIZE;
> > +	hpb->entries_per_srgn_shift = ilog2(hpb->entries_per_srgn);
> > +	hpb->entries_per_srgn_mask = hpb->entries_per_srgn - 1;
> > +
> > +	tmp = rgn_mem_size;
> > +	do_div(tmp, hpb->srgn_mem_size);
> > +	hpb->srgns_per_rgn = (int)tmp;
> > +
> > +	hpb->rgns_per_lu = DIV_ROUND_UP(hpb_lu_info->num_blocks,
> > +				entries_per_rgn);
> > +	hpb->srgns_per_lu = DIV_ROUND_UP(hpb_lu_info->num_blocks,
> > +				(hpb->srgn_mem_size / HPB_ENTRY_SIZE));
> > +
> > +	hpb->pages_per_srgn = DIV_ROUND_UP(hpb->srgn_mem_size, PAGE_SIZE);
> > +
> > +	dev_info(hba->dev, "ufshpb(%d): region memory size - %llu (bytes)\n",
> > +		 hpb->lun, rgn_mem_size);
> > +	dev_info(hba->dev, "ufshpb(%d): subregion memory size - %u (bytes)\n",
> > +		 hpb->lun, hpb->srgn_mem_size);
> > +	dev_info(hba->dev, "ufshpb(%d): total blocks per lu - %d\n",
> > +		 hpb->lun, hpb_lu_info->num_blocks);
> > +	dev_info(hba->dev, "ufshpb(%d): subregions per region - %d, regions per lu - %u\n",
> > +		 hpb->lun, hpb->srgns_per_rgn, hpb->rgns_per_lu);
> 
> Why all the kernel log spam for when things are working?  Shouldn't
> drivers, if all is working properly, be totally silent?  Who will do
> anything with this?  Worst case, make it dev_dbg(), right?

I will delete these message because it is used for debugging.

> > +/* SYSFS functions */
> > +#define ufshpb_sysfs_attr_show_func(__name)				\
> > +static ssize_t __name##_show(struct device *dev,			\
> > +	struct device_attribute *attr, char *buf)			\
> > +{									\
> > +	struct scsi_device *sdev = to_scsi_device(dev);			\
> > +	struct ufshpb_lu *hpb = ufshpb_get_hpb_data(sdev);		\
> > +									\
> > +	if (!hpb)							\
> > +		return -ENOENT;						\
> 
> How can this ever be true?

I think it can be removed.

> > +	return snprintf(buf, PAGE_SIZE, "%d\n",				\
> > +			atomic_read(&hpb->stats.__name));		\
> 
> sysfs_emit() is nicer to use now, please use that.

OK,

> And why are your stats atomic variables?  That feels like a waste and a
> slow-down just for debugging stuff.  What's wrong with a simple u64?

OK, I will change these variables as simple u64.

> > +void ufshpb_reset_host(struct ufs_hba *hba)
> > +{
> > +	struct ufshpb_lu *hpb;
> > +	struct scsi_device *sdev;
> > +
> > +	dev_dbg(hba->dev, "ufshpb run reset_host\n");
> 
> This is what ftrace is for, no need for this here, or in many other
> places you have added it, please remove.

OK, I will remove.

> > +void ufshpb_remove(struct ufs_hba *hba)
> > +{
> > +}
> 
> An empty remove function?  Are you _SURE_ that is ok?  That always is a
> huge red flag to me...

OK, I will remove it.

> > diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h
> > new file mode 100644
> > index 000000000000..6fa5db94bcae
> > --- /dev/null
> > +++ b/drivers/scsi/ufs/ufshpb.h
> > @@ -0,0 +1,167 @@
> > +/* SPDX-License-Identifier: GPL-2.0-or-later */
> 
> Same license question as before.

OK,

> > +/*
> > + * Universal Flash Storage Host Performance Booster
> > + *
> > + * Copyright (C) 2017-2018 Samsung Electronics Co., Ltd.
> 
> Again, date?

OK,

> > + *
> > + * Authors:
> > + *	Yongmyung Lee <ymhungry.lee@...sung.com>
> > + *	Jinyoung Choi <j-young.choi@...sung.com>
> > + */
> > +
> > +#ifndef _UFSHPB_H_
> > +#define _UFSHPB_H_
> > +
> > +/* hpb response UPIU macro */
> > +#define HPB_RSP_NONE				0x0
> > +#define	HPB_RSP_REQ_REGION_UPDATE		0x1
> 
> Why a tab after "define" on only 1 line?

I will fix it.

Thanks,
Daejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ