scsi: ufs: Add Host Performance Booster Support
A message that is not in the archive (sent off-list or not yet received): CGME20201103044021epcms2p8f1556853fc23414442b9e958f20781ce@epcms2p8
v13 cover scsi: ufs: Add Host Performance Booster Support
Changelog:
v12 -> v13
1. Cleanup codes by comments from Can Guo.
2. Add HPB related descriptor/flag/attributes in sysfs.
3. Change base commit from 5.10/scsi-queue to 5.11/scsi-queue.
v11 -> v12
1. Fixed to return error value when HPB fails to initialize pinned active region.
2. Fixed to disable HPB feature if HPB fails to allocate essential memory and workqueue.
3. Fixed to change proper sub-region state when region is already evicted.
v10 -> v11
Add a newline at end the last line on Kconfig file.
v9 -> v10
1. Fixed 64-bit division error
2. Fixed problems commentted in Bart's review.
v8 -> v9
1. Change sysfs initialization.
2. Change reading descriptor during HPB initialization
3. Fixed problems commentted in Bart's review.
4. Change base commit from 5.9/scsi-queue to 5.10/scsi-queue.
v7 -> v8
Remove wrongly added tags.
v6 -> v7
1. Remove UFS feature layer.
2. Cleanup for sparse error.
v5 -> v6
Change base commit to b53293fa662e28ae0cdd40828dc641c09f133405
v4 -> v5
Delete unused macro define.
v3 -> v4
1. Cleanup.
v2 -> v3
1. Add checking input module parameter value.
2. Change base commit from 5.8/scsi-queue to 5.9/scsi-queue.
3. Cleanup for unused variables and label.
v1 -> v2
1. Change the full boilerplate text to SPDX style.
2. Adopt dynamic allocation for sub-region data structure.
3. Cleanup.
NAND flash memory-based storage devices use Flash Translation Layer (FTL) to translate logical addresses of I/O requests to corresponding flash memory addresses. Mobile storage devices typically have RAM with constrained size, thus lack in memory to keep the whole mapping table. Therefore, mapping tables are partially retrieved from NAND flash on demand, causing random-read performance degradation.
To improve random read performance, JESD220-3 (HPB v1.0) proposes HPB (Host Performance Booster) which uses host system memory as a cache for the FTL mapping table. By using HPB, FTL data can be read from host memory faster than from NAND flash memory.
The current version only supports the DCM (device control mode). This patch consists of 3 parts to support HPB feature.
1) HPB probe and initialization process
2) READ -> HPB READ using cached map information
3) L2P (logical to physical) map management
In the HPB probe and init process, the device information of the UFS is queried. After checking supported features, the data structure for the HPB is initialized according to the device information.
A read I/O in the active sub-region where the map is cached is changed to HPB READ by the HPB.
The HPB manages the L2P map using information received from the device. For active sub-region, the HPB caches through ufshpb_map request. For the in-active region, the HPB discards the L2P map. When a write I/O occurs in an active sub-region area, associated dirty bitmap checked as dirty for preventing stale read.
HPB is shown to have a performance improvement of 58 - 67% for random read workload. [1]
This series patches are based on the 5.11/scsi-queue branch.
[1]:
https://www.usenix.org/conference/hotstorage17/program/presentation/jeong
Daejun park (3):
scsi: ufs: Introduce HPB feature
scsi: ufs: L2P map management for HPB read
scsi: ufs: Prepare HPB read for cached sub-region
drivers/scsi/ufs/Kconfig | 9 + drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/ufs-sysfs.c | 18 + drivers/scsi/ufs/ufs.h | 49 + drivers/scsi/ufs/ufshcd.c | 53 ++ drivers/scsi/ufs/ufshcd.h | 23 +- drivers/scsi/ufs/ufshpb.c | 1784 +++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshpb.h | 230 +++++ 8 files changed, 2166 insertions(+), 1 deletion(-)
created mode 100644 drivers/scsi/ufs/ufshpb.c
created mode 100644 drivers/scsi/ufs/ufshpb.h
PATCH v13 1/3 scsi: ufs: Introduce HPB feature
This is a patch for the HPB feature.
This patch adds HPB function calls to UFS core driver.
--- 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
drivers/scsi/ufs/Kconfig +9 -0
@@ -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.
drivers/scsi/ufs/Makefile +1 -0
@@ -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
drivers/scsi/ufs/ufs-sysfs.c +18 -0
@@ -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, &dev_attr_ext_feature_sup.attr, &dev_attr_wb_presv_us_en.attr, &dev_attr_wb_type.attr,
@@ -389,6 +393,10 @@ UFS_GEOMETRY_DESC_PARAM(enh4_memory_max_alloc_units, _ENM4_MAX_NUM_UNITS, 4);UFS_GEOMETRY_DESC_PARAM (enh4_memory_capacity_adjustment_factor, _ENM4_CAP_ADJ_FCTR,2 ); +UFS_GEOMETRY_DESC_PARAM (hpb_region_size, _HPB_REGION_SIZE,1 ); +UFS_GEOMETRY_DESC_PARAM (hpb_number_lu, _HPB_NUMBER_LU,1 ); +UFS_GEOMETRY_DESC_PARAM (hpb_subregion_size, _HPB_SUBREGION_SIZE,1 ); +UFS_GEOMETRY_DESC_PARAM (hpb_max_active_regions, _HPB_MAX_ACTIVE_REGS,2 );UFS_GEOMETRY_DESC_PARAM (wb_max_alloc_units, _WB_MAX_ALLOC_UNITS,4 );UFS_GEOMETRY_DESC_PARAM (wb_max_wb_luns, _WB_MAX_WB_LUNS,1 );UFS_GEOMETRY_DESC_PARAM (wb_buff_cap_adj, _WB_BUFF_CAP_ADJ,1 );
@@ -426,6 +434,10 @@ static struct attribute *ufs_sysfs_geometry_descriptor[] = { &dev_attr_enh3_memory_capacity_adjustment_factor.attr, &dev_attr_enh4_memory_max_alloc_units.attr, &dev_attr_enh4_memory_capacity_adjustment_factor.attr, + &dev_attr_hpb_region_size.attr, + &dev_attr_hpb_number_lu.attr, + &dev_attr_hpb_subregion_size.attr, + &dev_attr_hpb_max_active_regions.attr, &dev_attr_wb_max_alloc_units.attr, &dev_attr_wb_max_wb_luns.attr, &dev_attr_wb_buff_cap_adj.attr,
@@ -808,6 +820,9 @@ UFS_UNIT_DESC_PARAM(provisioning_type, _PROVISIONING_TYPE, 1);UFS_UNIT_DESC_PARAM (physical_memory_resourse_count, _PHY_MEM_RSRC_CNT,8 );UFS_UNIT_DESC_PARAM (context_capabilities, _CTX_CAPABILITIES,2 );UFS_UNIT_DESC_PARAM (large_unit_granularity, _LARGE_UNIT_SIZE_M1,1 ); +UFS_UNIT_DESC_PARAM (hpb_lu_max_active_regions, _HPB_LU_MAX_ACTIVE_RGNS,2 ); +UFS_UNIT_DESC_PARAM (hpb_pinned_region_start_offset, _HPB_PIN_RGN_START_OFF,2 ); +UFS_UNIT_DESC_PARAM (hpb_number_pinned_regions, _HPB_NUM_PIN_RGNS,2 );UFS_UNIT_DESC_PARAM (wb_buf_alloc_units, _WB_BUF_ALLOC_UNITS,4 );
@@ -825,6 +840,9 @@ static struct attribute *ufs_sysfs_unit_descriptor[] = { &dev_attr_physical_memory_resourse_count.attr, &dev_attr_context_capabilities.attr, &dev_attr_large_unit_granularity.attr, + &dev_attr_hpb_lu_max_active_regions.attr, + &dev_attr_hpb_pinned_region_start_offset.attr, + &dev_attr_hpb_number_pinned_regions.attr, &dev_attr_wb_buf_alloc_units.attr, NULL, };
drivers/scsi/ufs/ufs.h +13 -0
@@ -122,6 +122,7 @@ enum flag_idn {QUERY_FLAG_IDN_WB_EN =0x0E ,QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN =0x0F ,QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 =0x10 , + QUERY_FLAG_IDN_HPB_RESET = 0x11, };/* Attribute idn for Query requests */
@@ -195,6 +196,9 @@ enum unit_desc_param {UNIT_DESC_PARAM_PHY_MEM_RSRC_CNT =0x18 ,UNIT_DESC_PARAM_CTX_CAPABILITIES =0x20 ,UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 =0x22 , +UNIT_DESC_PARAM_HPB_LU_MAX_ACTIVE_RGNS =0x23 , +UNIT_DESC_PARAM_HPB_PIN_RGN_START_OFF =0x25 , +UNIT_DESC_PARAM_HPB_NUM_PIN_RGNS =0x27 , UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS = 0x29, };
@@ -235,6 +239,8 @@ enum device_desc_param {DEVICE_DESC_PARAM_PSA_MAX_DATA =0x25 ,DEVICE_DESC_PARAM_PSA_TMT =0x29 ,DEVICE_DESC_PARAM_PRDCT_REV =0x2A , +DEVICE_DESC_PARAM_HPB_VER =0x40 , +DEVICE_DESC_PARAM_HPB_CONTROL =0x42 ,DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP =0x4F ,DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN =0x53 , DEVICE_DESC_PARAM_WB_TYPE = 0x54,
@@ -283,6 +289,10 @@ enum geometry_desc_param {GEOMETRY_DESC_PARAM_ENM4_MAX_NUM_UNITS =0x3E ,GEOMETRY_DESC_PARAM_ENM4_CAP_ADJ_FCTR =0x42 ,GEOMETRY_DESC_PARAM_OPT_LOG_BLK_SIZE =0x44 , +GEOMETRY_DESC_PARAM_HPB_REGION_SIZE =0x48 , +GEOMETRY_DESC_PARAM_HPB_NUMBER_LU =0x49 , +GEOMETRY_DESC_PARAM_HPB_SUBREGION_SIZE =0x4A , +GEOMETRY_DESC_PARAM_HPB_MAX_ACTIVE_REGS =0x4B ,GEOMETRY_DESC_PARAM_WB_MAX_ALLOC_UNITS =0x4F ,GEOMETRY_DESC_PARAM_WB_MAX_WB_LUNS =0x53 , GEOMETRY_DESC_PARAM_WB_BUFF_CAP_ADJ = 0x54,
@@ -327,8 +337,10 @@ enum {/* Possible values for dExtendedUFSFeaturesSupport */ enum { +UFS_DEV_HPB_SUPPORT =BIT (7 ),UFS_DEV_WRITE_BOOSTER_SUP =BIT (8 ), }; +#define UFS_DEV_HPB_SUPPORT_VERSION 0x310#define POWER_DESC_MAX_SIZE 0x62#define POWER_DESC_MAX_ACTV_ICC_LVLS 16
@@ -537,6 +549,7 @@ struct ufs_dev_info {u8 *model;u16 wspecversion;u32 clk_gating_wait_us; +u8 b_ufs_feature_sup;u32 d_ext_ufs_feature_sup;u8 b_wb_buffer_type;u32 d_wb_alloc_units;
drivers/scsi/ufs/ufshcd.c +48 -0
135 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +22 -1
@@ -601,6 +601,25 @@ struct ufs_hba_variant_params {u32 wb_flush_threshold; }; +#ifdef CONFIG_SCSI_UFS_HPB +/** +* struct ufshpb_dev_info - UFSHPB device related info +* @num_lu: the number of user logical unit to check whether all lu finished +* initialization +* @rgn_size: device reported HPB region size +* @srgn_size: device reported HPB sub-region size +* @slave_conf_cnt: counter to check all lu finished initialization +* @hpb_disabled: flag to check if HPB is disabled +*/ +struct ufshpb_dev_info { +int num_lu; +int rgn_size; +int srgn_size; +atomic_t slave_conf_cnt; +bool hpb_disabled; +}; +#endif +/** * struct ufs_hba - per adapter private structure * @mmio_base: UFSHCI base register address
@@ -784,7 +803,9 @@ struct ufs_hba {bool wb_buf_flush_enabled;bool wb_enabled;struct delayed_work rpm_dev_flush_recheck_work; - +#ifdef CONFIG_SCSI_UFS_HPB +struct ufshpb_dev_info ufshpb_dev; +#endif #ifdef CONFIG_SCSI_UFS_CRYPTO union ufs_crypto_capabilities crypto_capabilities;union ufs_crypto_cap_entry *crypto_cap_array;
drivers/scsi/ufs/ufshpb.c new file +583 -0
583 lines not on this page · raw message
drivers/scsi/ufs/ufshpb.h new file +167 -0
167 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v13 1/3] scsi: ufs: Introduce HPB feature
Quoted 2 lines · Daejun Park
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.
Quoted 61 lines
Reviewed-by Bart Van Assche <[email protected]>Acked-by Avri Altman <[email protected]>Tested-by Bean Huo <[email protected]>Signed-off-by Daejun Park <[email protected]>--- 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.hdrivers/scsi/ufs/Kconfig +9
-0@@ -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.drivers/scsi/ufs/Makefile +1
-0@@ -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.odrivers/scsi/ufs/ufs-sysfs.c +2
-0@@ -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 );
drivers/scsi/ufs/ufs-sysfs.c static struct attribute *ufs_sysfs_device_descriptor[] = { · line 322
Quoted 5 lines
drivers/scsi/ufs/ufs-sysfs.c +2
-0@@ -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.
drivers/scsi/ufs/ufshpb.c line 1
Quoted 4 lines
drivers/scsi/ufs/ufshpb.c new file +1
-0@@ -0,0 +1,583 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
Do you really mean "or later"? I have to ask, sorry.
drivers/scsi/ufs/ufshpb.c line 5
Quoted 4 lines
drivers/scsi/ufs/ufshpb.c new file +4
-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 :(
Quoted 38 lines
drivers/scsi/ufs/ufshpb.c new file +38
-0+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 )); +
drivers/scsi/ufs/ufshpb.c line 113
Quoted 10 lines
drivers/scsi/ufs/ufshpb.c new file +10
-0+ 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?
drivers/scsi/ufs/ufshpb.c line 201
Quoted 10 lines
drivers/scsi/ufs/ufshpb.c new file +10
-0+/* 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?
drivers/scsi/ufs/ufshpb.c line 203
Quoted 2 lines
drivers/scsi/ufs/ufshpb.c new file +2
-0+return snprintf (buf,PAGE_SIZE ,"%d\n" , \ +atomic_read (&hpb->stats.__name)); \
sysfs_emit() is nicer to use now, please use that.
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?
drivers/scsi/ufs/ufshpb.c line 340
Quoted 6 lines
drivers/scsi/ufs/ufshpb.c new file +6
-0+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.
drivers/scsi/ufs/ufshpb.c line 583
Quoted 3 lines
drivers/scsi/ufs/ufshpb.c new file +3
-0+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...
drivers/scsi/ufs/ufshpb.h line 1
Quoted 7 lines
drivers/scsi/ufs/ufshpb.h new file +1
-0@@ -0,0 +1,167 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
Same license question as before.
drivers/scsi/ufs/ufshpb.h line 5
Quoted 4 lines
drivers/scsi/ufs/ufshpb.h new file +4
-0+/* +* Universal Flash Storage Host Performance Booster +* +* Copyright (C) 2017-2018 Samsung Electronics Co., Ltd.
Again, date?
drivers/scsi/ufs/ufshpb.h line 17
Quoted 12 lines
drivers/scsi/ufs/ufshpb.h new file +12
-0+* +* Authors: +* Yongmyung Lee <[email protected]> +* Jinyoung Choi <[email protected]> +*/ + +#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?
thanks,
greg k-h
RE: Re: [PATCH v13 1/3] scsi: ufs: Introduce HPB feature
Hi Greg,
Quoted 11 lines
Quoted 2 lines
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.
===
Quoted 63 lines
Quoted 63 lines
Reviewed-by Bart Van Assche <[email protected]>Acked-by Avri Altman <[email protected]>Tested-by Bean Huo <[email protected]>Signed-off-by Daejun Park <[email protected]>--- 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.hdrivers/scsi/ufs/Kconfig +9
-0@@ -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.drivers/scsi/ufs/Makefile +1
-0@@ -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.odrivers/scsi/ufs/ufs-sysfs.c +2
-0@@ -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,
Quoted 8 lines
drivers/scsi/ufs/ufs-sysfs.c static struct attribute *ufs_sysfs_device_descriptor[] = { · line 322
Quoted 3 lines
drivers/scsi/ufs/ufs-sysfs.c +2
-0&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.
Quoted 6 lines
drivers/scsi/ufs/ufshpb.c line 1
Quoted 4 lines
drivers/scsi/ufs/ufshpb.c new file +1
-0@@ -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"
Quoted 7 lines
drivers/scsi/ufs/ufshpb.c line 5
Quoted 4 lines
drivers/scsi/ufs/ufshpb.c new file +4
-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".
Quoted 44 lines
Quoted 44 lines
drivers/scsi/ufs/ufshpb.c new file +44
-0+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);
Quoted 8 lines
drivers/scsi/ufs/ufshpb.c line 113
Quoted 4 lines
drivers/scsi/ufs/ufshpb.c new file +4
-0+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.
Quoted 4 lines
Quoted 4 lines
drivers/scsi/ufs/ufshpb.c new file +4
-0+/* SYSFS functions */ +#define ufshpb_sysfs_attr_show_func (__name) \ +static ssize_t __name##_show(struct device *dev, \ + struct device_attribute *attr, char *buf) \
Quoted 8 lines
drivers/scsi/ufs/ufshpb.c line 201
Quoted 6 lines
drivers/scsi/ufs/ufshpb.c new file +6
-0+{ \ +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.
Quoted 4 lines
drivers/scsi/ufs/ufshpb.c line 203
Quoted 2 lines
drivers/scsi/ufs/ufshpb.c new file +2
-0+return snprintf (buf,PAGE_SIZE ,"%d\n" , \ +atomic_read (&hpb->stats.__name)); \
sysfs_emit()is nicer to use now, please use that.
OK,
Quoted 2 lines
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.
Quoted 9 lines
drivers/scsi/ufs/ufshpb.c line 340
Quoted 6 lines
drivers/scsi/ufs/ufshpb.c new file +6
-0+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.
Quoted 6 lines
drivers/scsi/ufs/ufshpb.c line 583
Quoted 3 lines
drivers/scsi/ufs/ufshpb.c new file +3
-0+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.
Quoted 9 lines
drivers/scsi/ufs/ufshpb.h line 1
Quoted 7 lines
drivers/scsi/ufs/ufshpb.h new file +1
-0@@ -0,0 +1,167 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ Same license question as before.
OK,
Quoted 6 lines
drivers/scsi/ufs/ufshpb.h line 5
Quoted 4 lines
drivers/scsi/ufs/ufshpb.h new file +4
-0+/* +* Universal Flash Storage Host Performance Booster +* +* Copyright (C) 2017-2018 Samsung Electronics Co., Ltd. Again, date?
OK,
Quoted 6 lines
Quoted 6 lines
drivers/scsi/ufs/ufshpb.h new file +6
-0+* +* Authors: +* Yongmyung Lee <[email protected]> +* Jinyoung Choi <[email protected]> +*/ +
Quoted 8 lines
drivers/scsi/ufs/ufshpb.h line 17
Quoted 6 lines
drivers/scsi/ufs/ufshpb.h new file +6
-0+#ifndef _UFSHPB_H_ +#define _UFSHPB_H_ + +/* hpb response UPIU macro */ +#define HPB_RSP_NONE 0x0 +#define HPB_RSP_REQ_REGION_UPDATE 0x1Why a tab after "define" on only 1 line?
I will fix it.
Thanks,
Daejun
PATCH v13 2/3 scsi: ufs: L2P map management for HPB read
In reply to Daejun ParkThis is a patch for managing L2P map in HPB module.
The HPB divides logical addresses into several regions. A region consists of several sub-regions. The sub-region is a basic unit where L2P mapping is managed. The driver loads L2P mapping data of each sub-region. The loaded sub-region is called active-state. The HPB driver unloads L2P mapping data as region unit. The unloaded region is called inactive-state.
Sub-region/region candidates to be loaded and unloaded are delivered from the UFS device. The UFS device delivers the recommended active sub-region and inactivate region to the driver using sensedata.
The HPB module performs L2P mapping management on the host through the delivered information.
A pinned region is a pre-set regions on the UFS device that is always activate-state.
The data structure for map data request and L2P map uses mempool API, minimizing allocation overhead while avoiding static allocation.
The mininum size of the memory pool used in the HPB is implemented as a module parameter, so that it can be configurable by the user.
To gurantee a minimum memory pool size of 4MB: ufshpb_host_map_kbytes=4096
The map_work manages active/inactive by 2 "to-do" lists. Each hpb lun maintains 2 "to-do" lists:
hpb->lh_inact_rgn - regions to be inactivated, and hpb->lh_act_srgn - subregions to be activated
Those lists are maintained on IO completion.
--- drivers/scsi/ufs/ufs.h | 36 ++ drivers/scsi/ufs/ufshcd.c | 3 + drivers/scsi/ufs/ufshpb.c | 999 +++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshpb.h | 61 +++ 4 files changed, 1084 insertions(+), 15 deletions(-)
drivers/scsi/ufs/ufs.h +36 -0
@@ -472,6 +472,41 @@ struct utp_cmd_rsp {u8 sense_data[UFS_SENSE_SIZE ]; }; +struct ufshpb_active_field { +__be16 active_rgn; +__be16 active_srgn; +}; +#define HPB_ACT_FIELD_SIZE 4 + +/** +* struct utp_hpb_rsp - Response UPIU structure +* @residual_transfer_count: Residual transfer count DW-3 +* @reserved1: Reserved double words DW-4 to DW-7 +* @sense_data_len: Sense data length DW-8 U16 +* @desc_type: Descriptor type of sense data +* @additional_len: Additional length of sense data +* @hpb_op: HPB operation type +* @reserved2: Reserved field +* @active_rgn_cnt: Active region count +* @inactive_rgn_cnt: Inactive region count +* @hpb_active_field: Recommended to read HPB region and subregion +* @hpb_inactive_field: To be inactivated HPB region and subregion +*/ +struct utp_hpb_rsp { +__be32 residual_transfer_count; +__be32 reserved1[4 ]; +__be16 sense_data_len; +u8 desc_type; +u8 additional_len; +u8 hpb_op; +u8 reserved2; +u8 active_rgn_cnt; +u8 inactive_rgn_cnt; +struct ufshpb_active_field hpb_active_field[2 ]; +__be16 hpb_inactive_field[2 ]; +}; +#define UTP_HPB_RSP_SIZE 40 +/** * struct utp_upiu_rsp - general upiu response structure * @header: UPIU header structure DW-0 to DW-2
@@ -482,6 +517,7 @@ struct utp_upiu_rsp {struct utp_upiu_header header;union {struct utp_cmd_rsp sr; +struct utp_hpb_rsp hr;struct utp_upiu_query qr; }; };
drivers/scsi/ufs/ufshcd.c +3 -0
@@ -4865,6 +4865,9 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)*/ pm_runtime_get_noresume (hba->dev); } + +if (scsi_status ==SAM_STAT_GOOD ) +ufshpb_rsp_upiu (hba, lrbp);break ;case UPIU_TRANSACTION_REJECT_UPIU :/* TODO: handle Reject UPIU Response */
drivers/scsi/ufs/ufshpb.c +984 -15
1,167 lines not on this page · raw message
drivers/scsi/ufs/ufshpb.h +61 -0
101 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v13 3/3 scsi: ufs: Prepare HPB read for cached sub-region
In reply to Daejun ParkThis patch changes the read I/O to the HPB read I/O.
If the logical address of the read I/O belongs to active sub-region, the HPB driver modifies the read I/O command to HPB read. It modifies the UPIU command of UFS instead of modifying the existing SCSI command.
In the HPB version 1.0, the maximum read I/O size that can be converted to HPB read is 4KB.
The dirty map of the active sub-region prevents an incorrect HPB read that has stale physical page number which is updated by previous write I/O.
--- drivers/scsi/ufs/ufshcd.c | 2 + drivers/scsi/ufs/ufshpb.c | 232 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshpb.h | 2 + 3 files changed, 236 insertions(+)
drivers/scsi/ufs/ufshcd.c +2 -0
@@ -2555,6 +2555,8 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)ufshcd_comp_scsi_upiu (hba, lrbp); +ufshpb_prep (hba, lrbp); + err =ufshcd_map_sg (hba, lrbp);if (err) { lrbp->cmd =NULL ;
drivers/scsi/ufs/ufshpb.c +232 -0
244 lines not on this page · raw message
drivers/scsi/ufs/ufshpb.h +2 -0
@@ -197,6 +197,7 @@ struct ufs_hba;struct ufshcd_lrb ;#ifndef CONFIG_SCSI_UFS_HPB +static void ufshpb_prep (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) {}static void ufshpb_rsp_upiu (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) {}static void ufshpb_resume (struct ufs_hba *hba) {}static void ufshpb_suspend (struct ufs_hba *hba) {}
@@ -210,6 +211,7 @@ static bool ufshpb_is_allowed(struct ufs_hba *hba) { return false; }static void ufshpb_get_geo_info (struct ufs_hba *hba,u8 *geo_buf) {}static void ufshpb_get_dev_info (struct ufs_hba *hba,u8 *desc_buf) {}#else +void ufshpb_prep (struct ufs_hba *hba,struct ufshcd_lrb *lrbp);void ufshpb_rsp_upiu (struct ufs_hba *hba,struct ufshcd_lrb *lrbp);void ufshpb_resume (struct ufs_hba *hba);void ufshpb_suspend (struct ufs_hba *hba);
Signature · 1 line
2.25.1
Quoted 7 lines · Daejun Park
Changelog:
v12 -> v13
1. Cleanup codes by comments from Can Guo.
2. Add HPB related descriptor/flag/attributes in sysfs.
3. Change base commit from 5.10/scsi-queue to 5.11/scsi-queue.
If you have changed the code based by comments left on Google gerrit, here is
Quoted 103 lines
v11 -> v12
1. Fixed to return error value when HPB fails to initialize pinned active region.
2. Fixed to disable HPB feature if HPB fails to allocate essential memory and workqueue.
3. Fixed to change proper sub-region state when region is already evicted.v10 -> v11
Add a newline at end the last line onKconfigfile.v9 -> v10
1. Fixed 64-bit division error
2. Fixed problems commentted in Bart's review.v8 -> v9
1. Change sysfs initialization.
2. Change reading descriptor during HPB initialization
3. Fixed problems commentted in Bart's review.
4. Change base commit from 5.9/scsi-queue to 5.10/scsi-queue.v7 -> v8
Remove wrongly added tags.v6 -> v7
1. Remove UFS feature layer.
2. Cleanup for sparse error.v5 -> v6
Change base commit tob53293fa662e28ae0cdd40828dc641c09f133405v4 -> v5
Delete unused macro define.v3 -> v4
1. Cleanup.v2 -> v3
1. Add checking input module parameter value.
2. Change base commit from 5.8/scsi-queue to 5.9/scsi-queue.
3. Cleanup for unused variables and label.v1 -> v2
1. Change the full boilerplate text to SPDX style.
2. Adopt dynamic allocation for sub-region data structure.
3. Cleanup.NAND flash memory-based storage devices use Flash Translation Layer (FTL) to translate logical addresses of I/O requests to corresponding flash memory addresses. Mobile storage devices typically have RAM with constrained size, thus lack in memory to keep the whole mapping table. Therefore, mapping tables are partially retrieved from NAND flash on demand, causing random-read performance degradation.
To improve random read performance, JESD220-3 (HPB v1.0) proposes HPB (Host Performance Booster) which uses host system memory as a cache for the FTL mapping table. By using HPB, FTL data can be read from host memory faster than from NAND flash memory.
The current version only supports the DCM (device control mode). This patch consists of 3 parts to support HPB feature.
1) HPB probe and initialization process
2) READ -> HPB READ using cached map information
3) L2P (logical to physical) map managementIn the HPB probe and init process, the device information of the UFS is queried. After checking supported features, the data structure for the HPB is initialized according to the device information.
A read I/O in the active sub-region where the map is cached is changed to HPB READ by the HPB.
The HPB manages the L2P map using information received from the device. For active sub-region, the HPB caches through
ufshpb_maprequest. For the in-active region, the HPB discards the L2P map. When a write I/O occurs in an active sub-region area, associated dirty bitmap checked as dirty for preventing stale read.HPB is shown to have a performance improvement of 58 - 67% for random read workload. [1]
This series patches are based on the 5.11/scsi-queue branch.
[1]:
https://www.usenix.org/conference/hotstorage17/program/presentation/jeongDaejun park (3):
scsi: ufs: Introduce HPB feature
scsi: ufs: L2P map management for HPB read
scsi: ufs: Prepare HPB read for cached sub-regiondrivers/scsi/ufs/Kconfig | 9 + drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/ufs-sysfs.c | 18 + drivers/scsi/ufs/ufs.h | 49 + drivers/scsi/ufs/ufshcd.c | 53 ++ drivers/scsi/ufs/ufshcd.h | 23 +- drivers/scsi/ufs/ufshpb.c | 1784 +++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshpb.h | 230 +++++ 8 files changed, 2166 insertions(+), 1 deletion(-)created mode 100644
drivers/scsi/ufs/ufshpb.c
created mode 100644drivers/scsi/ufs/ufshpb.h
Quoted 6 lines · Daejun Park
Changelog:
v12 -> v13
1. Cleanup codes by comments from Can Guo.
2. Add HPB related descriptor/flag/attributes in sysfs.
3. Change base commit from 5.10/scsi-queue to 5.11/scsi-queue.
What ever happened to this patchset? Did it get merged into a scsi tree for 5.11-rc1, or is there something still pending that needs to be done on it to make it acceptable?
thanks,
greg k-h
Quoted 11 lines · Greg KH
Quoted 6 lines · Daejun Park
Changelog:
v12 -> v13
1. Cleanup codes by comments from Can Guo.
2. Add HPB related descriptor/flag/attributes in sysfs.
3. Change base commit from 5.10/scsi-queue to 5.11/scsi-queue.What ever happened to this patchset? Did it get merged into a scsi tree for 5.11-rc1, or is there something still pending that needs to be done on it to make it acceptable?
I think the problem here is not the code, but that the features is fundamentally a bad idea, and one that so far has not even shown to help real workloads vs the usual benchmarketing.
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Greg KH
Quoted 6 lines · Daejun Park
Changelog:
v12 -> v13
1. Cleanup codes by comments from Can Guo.
2. Add HPB related descriptor/flag/attributes in sysfs.
3. Change base commit from 5.10/scsi-queue to 5.11/scsi-queue.
Quoted 7 lines
Quoted 3 lines
What ever happened to this patchset? Did it get merged into a scsi tree for 5.11-rc1, or is there something still pending that needs to be done on it to make it acceptable?
I think the problem here is not the code, but that the features is fundamentally a bad idea, and one that so far has not even shown to help real workloads vs the usual benchmarketing.
What "real workload" test can be run on this to help show if it is useful or not? These vendors seem to think it helps for some reason, otherwise they wouldn't have added it to their silicon :)
Should they run fio? If so, any hints on a config that would be good to show any performance increases?
thanks,
greg k-h
Quoted 6 lines · Greg KH
What "real workload" test can be run on this to help show if it is useful or not? These vendors seem to think it helps for some reason, otherwise they wouldn't have added it to their silicon :)
Should they run fio? If so, any hints on a config that would be good to show any performance increases?
A real actual workload that matters. Then again that was Martins request to even justify it. I don't think the broken addressing that breaks a whole in the SCSI addressing has absolutely not business being supported in Linux ever. The vendors should have thought about the design before committing transistors to something that fundamentally does not make sense.
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Greg KH
What "real workload" test can be run on this to help show if it is useful or not? These vendors seem to think it helps for some reason, otherwise they wouldn't have added it to their silicon :)
Should they run fio? If so, any hints on a config that would be good to show any performance increases?
Quoted 6 lines
A real actual workload that matters. Then again that was Martins request to even justify it. I don't think the broken addressing that breaks a whole in the SCSI addressing has absolutely not business being supported in Linux ever. The vendors should have thought about the design before committing transistors to something that fundamentally does not make sense.
So "time to boot an android system with this enabled and disabled" would be a valid workload, right? I'm guessing that's what the vendors here actually care about, otherwise there is no real stress-test on a UFS system that I know of.
thanks,
greg k-h
Quoted 16 lines · Greg KH
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Greg KH
What "real workload" test can be run on this to help show if it is useful or not? These vendors seem to think it helps for some reason, otherwise they wouldn't have added it to their silicon :)
Should they run fio? If so, any hints on a config that would be good to show any performance increases?
Quoted 6 lines
A real actual workload that matters. Then again that was Martins request to even justify it. I don't think the broken addressing that breaks a whole in the SCSI addressing has absolutely not business being supported in Linux ever. The vendors should have thought about the design before committing transistors to something that fundamentally does not make sense.
Quoted 4 lines
So "time to boot an android system with this enabled and disabled" would be a valid workload, right? I'm guessing that's what the vendors here actually care about, otherwise there is no real stress-test on a UFS system that I know of.
Oh, and "supporting stupid hardware specs" is what we do here all the time, you know that :)
If someone is foolish enough to build it, we usually have to support the thing, especially if someone else here is willing to do that. I don't see where the addressing is "broken", which patch causes that to happen?
thanks,
greg k-h
Quoted 9 lines · Greg KH
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Greg KH
What "real workload" test can be run on this to help show if it is useful or not? These vendors seem to think it helps for some reason, otherwise they wouldn't have added it to their silicon :)
Should they run fio? If so, any hints on a config that would be good to show any performance increases?
Quoted 6 lines
Quoted 6 lines
A real actual workload that matters. Then again that was Martins request to even justify it. I don't think the broken addressing that breaks a whole in the SCSI addressing has absolutely not business being supported in Linux ever. The vendors should have thought about the design before committing transistors to something that fundamentally does not make sense.
Actually, that's not the way it works: vendors add commands because standards mandate. That's why people who want weird commands go and join standard committees. Unfortunately this means that a lot of the commands the standard mandates end up not being very useful in practice. For instance in SCSI we really only implement a fraction of the commands in the standard.
In this case, the industry already tried a very similar approach with GEN 1 hybrid drives and it turned into a complete disaster, which is why the mode became optional in shingle drives and much better modes, which didn't have the huge shared state problem, superseded it. Plus truncating the LBA of a READ 16 to 4 bytes is asking for capacity problems down the line, so even the actual implementation seems to be problematic.
All in all, this looks like a short term fix which will go away when the drive capacity improves and thus all the effort changing the driver will eventually be wasted.
Quoted 4 lines
So "time to boot an android system with this enabled and disabled" would be a valid workload, right? I'm guessing that's what the vendors here actually care about, otherwise there is no real stress- test on a UFS system that I know of.
Um, does it? I don't believe even the UFS people have claimed this. The problem is that HPB creates a shared state between the driver and the device. That shared state has to be populated, which has to happen at start of day, so it's entirely unclear if this is a win or a slow down for boot.
James
Quoted 32 lines · James Bottomley
Quoted 9 lines · Greg KH
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Greg KH
What "real workload" test can be run on this to help show if it is useful or not? These vendors seem to think it helps for some reason, otherwise they wouldn't have added it to their silicon :)
Should they run fio? If so, any hints on a config that would be good to show any performance increases?
Quoted 6 lines
Quoted 6 lines
A real actual workload that matters. Then again that was Martins request to even justify it. I don't think the broken addressing that breaks a whole in the SCSI addressing has absolutely not business being supported in Linux ever. The vendors should have thought about the design before committing transistors to something that fundamentally does not make sense.
Actually, that's not the way it works: vendors add commands because standards mandate. That's why people who want weird commands go and join standard committees. Unfortunately this means that a lot of the commands the standard mandates end up not being very useful in practice. For instance in SCSI we really only implement a fraction of the commands in the standard.
In this case, the industry already tried a very similar approach with GEN 1 hybrid drives and it turned into a complete disaster, which is why the mode became optional in shingle drives and much better modes, which didn't have the huge shared state problem, superseded it. Plus truncating the LBA of a READ 16 to 4 bytes is asking for capacity problems down the line, so even the actual implementation seems to be problematic.
Quoted 3 lines
All in all, this looks like a short term fix which will go away when the drive capacity improves and thus all the effort changing the driver will eventually be wasted.
"short term" in the embedded world means "this device is stuck with this chip for the next 8 years", it's not like a storage device you can replace, so this might be different than the shingle drive mess. Also, I see many old SoCs still showing up in brand new devices many many years after they were first introduced, on-chip storage controllers is something we need to support well if we don't want to see huge out-of-tree patchsets like UFS traditionally has been lugging around for many years.
Quoted 10 lines
Quoted 4 lines
So "time to boot an android system with this enabled and disabled" would be a valid workload, right? I'm guessing that's what the vendors here actually care about, otherwise there is no real stress- test on a UFS system that I know of.
Um, does it? I don't believe even the UFS people have claimed this. The problem is that HPB creates a shared state between the driver and the device. That shared state has to be populated, which has to happen at start of day, so it's entirely unclear if this is a win or a slow down for boot.
Ok, showing that this actually matters is a good rule, Daejun, can you provide that if you resubmit this patchset?
thanks,
greg k-h
Quoted 50 lines
Quoted 32 lines · Greg KH
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Greg KH
Quoted 6 lines
What "real workload" test can be run on this to help show if it is useful or not? These vendors seem to think it helps for some reason, otherwise they wouldn't have added it to their silicon :)
Should they run fio? If so, any hints on a config that would be good to show any performance increases?
Quoted 6 lines
Quoted 6 lines
A real actual workload that matters. Then again that was Martins request to even justify it. I don't think the broken addressing that breaks a whole in the SCSI addressing has absolutely not business being supported in Linux ever. The vendors should have thought about the design before committing transistors to something that fundamentally does not make sense.
Actually, that's not the way it works: vendors add commands because standards mandate. That's why people who want weird commands go and join standard committees. Unfortunately this means that a lot of the commands the standard mandates end up not being very useful in practice. For instance in SCSI we really only implement a fraction of the commands in the standard.
In this case, the industry already tried a very similar approach with GEN 1 hybrid drives and it turned into a complete disaster, which is why the mode became optional in shingle drives and much better modes, which didn't have the huge shared state problem, superseded it. Plus truncating the LBA of a READ 16 to 4 bytes is asking for capacity problems down the line, so even the actual implementation seems to be problematic.
Quoted 3 lines
All in all, this looks like a short term fix which will go away when the drive capacity improves and thus all the effort changing the driver will eventually be wasted.
"short term" in the embedded world means "this device is stuck with this chip for the next 8 years", it's not like a storage device you can replace, so this might be different than the shingle drive mess. Also, I see many old SoCs still showing up in brand new devices many many years after they were first introduced, on-chip storage controllers is something we need to support well if we don't want to see huge out-of-tree patchsets like UFS traditionally has been lugging around for many years.
Quoted 5 lines
Quoted 4 lines
So "time to boot an android system with this enabled and disabled" would be a valid workload, right? I'm guessing that's what the vendors here actually care about, otherwise there is no real stress- test on a UFS system that I know of.
Quoted 9 lines
Quoted 5 lines
Um, does it? I don't believe even the UFS people have claimed this. The problem is that HPB creates a shared state between the driver and the device. That shared state has to be populated, which has to happen at start of day, so it's entirely unclear if this is a win or a slow down for boot.
Ok, showing that this actually matters is a good rule, Daejun, can you provide that if you resubmit this patchset?
Sure, I will find out the case which has performance benefit by HPB.
Thanks,
Daejun