Skip to contentSkip to conversation

scsi: ufs: add UFS Host Performance Booster(HPB) driver

PATCH Superseded [email protected] 2 participants 10 messages Mar 21, 2020 SCSI

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover scsi: ufs: add UFS Host Performance Booster(HPB) driver

From: Bean Huo <[email protected]>

I disclose my development/changes on UFS HPB (UFS Host Performance Booster) to the community, as this would enable more UFS developers to test and start an iterative review and update process.

The HPB is defined in Jedec Standard Universal Flash (UFS) Host Performance Booster(HPB) Extension Version 1.0, which is designed to improve a read performance by utilizing the host side memory. Based on our testing, the HPB can increase the random read performance by up to about 46% in random read.

The original HPB driver is from [1]. Based on it, I did some optimizations, simplications, fixed several reliability issues, implemented HPB host control mode and make it much more readable. There are still some FIXME need to do, but this doesn't stop disclosure of patches to community to let you review.

To avoid touching the traditional SCSI core, the HPB driver in this version series HPB patch chooses to develop under SCSI, and sits the same layer with UFSHCD. At the same time, in order to minimize changes on UFSHCD driver, the HPB driver inserts HPB READ BUFFER and HPB WRITE BUFFER requests into the scsi_device->request_queueu to execute, rather than that directly go through raw UPIU request path.

[1] https://github.com/OpenMPDK/HPBDriver

Bean Huo (5):
scsi; ufs: add device descriptor for Host Performance Booster
scsi: ufs: make ufshcd_read_unit_desc_param() non-static func
scsi: ufs: add ufs_features parameter in structure ufs_dev_info
scsi: ufs: add unit and geometry parameters for HPB
scsi: ufs: UFS Host Performance Booster(HPB) driver

 drivers/scsi/ufs/Kconfig  |   34 +
 drivers/scsi/ufs/Makefile |    1 +
 drivers/scsi/ufs/ufs.h    |   19 +
 drivers/scsi/ufs/ufshcd.c |   66 +-
 drivers/scsi/ufs/ufshcd.h |   14 +-
 drivers/scsi/ufs/ufshpb.c | 3322 +++++++++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshpb.h |  421 +++++
 7 files changed, 3870 insertions(+), 7 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshpb.c
 create mode 100644 drivers/scsi/ufs/ufshpb.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/5 scsi; ufs: add device descriptor for Host Performance Booster

From: Bean Huo <[email protected]>

HPB support is specified by Bit7 of bUFSFeatureSupport, HPB version is indicated by wHPBVersion and the HPB Control Mode is specified by bHPBControl in UFS device descriptor.

---
 drivers/scsi/ufs/ufs.h    | 10 ++++++++++
 drivers/scsi/ufs/ufshcd.c | 11 +++++++++++
 2 files changed, 21 insertions(+)
drivers/scsi/ufs/ufs.h +10 -0
index b7fec5c73688..31011d86610b 100644
@@ -258,6 +258,12 @@ 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_CTRL_MODE		= 0x42,
+	DEVICE_DESC_PARAM_EXT_UFS_FEAT		= 0x4F,
+	DEVICE_DESC_PARAM_WBB_USER_SPEC_EN	= 0x53,
+	DEVICE_DESC_PARAM_WBB_TYPE		= 0x54,
+	DEVICE_DESC_PARAM_WBB_SHARED_NUM	= 0x55,
 };
 
 /* Interconnect descriptor parameters offsets in bytes*/
@@ -537,6 +543,10 @@ struct ufs_dev_info {
 	u8 *model;
 	u16 wspecversion;
 	u32 clk_gating_wait_us;
+	/* HPB Version */
+	u16 hpb_ver;
+	/* bHPBControl */
+	u8 hpb_control_mode;
 };
 
 /**
drivers/scsi/ufs/ufshcd.c +11 -0
index 2a2a63b68a67..492e4685e587 100644
@@ -6559,6 +6559,17 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
 		goto out;
 	}
 
+	if (desc_buf[DEVICE_DESC_PARAM_UFS_FEAT] & 0x80) {
+		hba->dev_info.hpb_control_mode =
+			desc_buf[DEVICE_DESC_PARAM_HPB_CTRL_MODE];
+		hba->dev_info.hpb_ver =
+			(u16) (desc_buf[DEVICE_DESC_PARAM_HPB_VER] << 8) |
+			desc_buf[DEVICE_DESC_PARAM_HPB_VER + 1];
+		dev_info(hba->dev, "HPB Version: 0x%2x\n",
+			 hba->dev_info.hpb_ver);
+		dev_info(hba->dev, "HPB control mode: %d\n",
+			 hba->dev_info.hpb_control_mode);
+	}
 	/*
 	 * getting vendor (manufacturerID) and Bank Index in big endian
 	 * format
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/5 scsi: ufs: make ufshcd_read_unit_desc_param() non-static func

In reply to [email protected]

From: Bean Huo <[email protected]>

HPB driver needs to read unit descriptors through ufshcd_read_unit_desc_param(), make it an extern Function.

---
 drivers/scsi/ufs/ufshcd.c | 8 +++-----
 drivers/scsi/ufs/ufshcd.h | 5 ++++-
 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/scsi/ufs/ufshcd.c +3 -5
index 492e4685e587..a40023ad1336 100644
@@ -3276,11 +3276,9 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
  *
  * Return 0 in case of success, non-zero otherwise
  */
-static inline int ufshcd_read_unit_desc_param(struct ufs_hba *hba,
-					      int lun,
-					      enum unit_desc_param param_offset,
-					      u8 *param_read_buf,
-					      u32 param_size)
+int ufshcd_read_unit_desc_param(struct ufs_hba *hba, int lun,
+				enum unit_desc_param param_offset,
+				u8 *param_read_buf, u32 param_size)
 {
 	/*
 	 * Unit descriptors are only available for general purpose LUs (LUN id
drivers/scsi/ufs/ufshcd.h +4 -1
index d45a04444191..2fa9b880e228 100644
@@ -838,7 +838,10 @@ extern int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
 extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
 			       u32 *mib_val, u8 peer);
 extern int ufshcd_config_pwr_mode(struct ufs_hba *hba,
-			struct ufs_pa_layer_attr *desired_pwr_mode);
+				  struct ufs_pa_layer_attr *desired_pwr_mode);
+extern int ufshcd_read_unit_desc_param(struct ufs_hba *hba, int lun,
+				       enum unit_desc_param param_offset,
+				       u8 *param_read_buf, u32 param_size);
 
 /* UIC command interfaces for DME primitives */
 #define DME_LOCAL	0
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/5 scsi: ufs: add ufs_features parameter in structure ufs_dev_info

In reply to [email protected]

From: Bean Huo <[email protected]>

Make a copy of bUFSFeaturesSupport, name it ufs_features, add it to structure ufs_dev_info.

---
 drivers/scsi/ufs/ufs.h    | 2 ++
 drivers/scsi/ufs/ufshcd.c | 2 ++
 2 files changed, 4 insertions(+)
drivers/scsi/ufs/ufs.h +2 -0
index 31011d86610b..1a0053133a04 100644
@@ -547,6 +547,8 @@ struct ufs_dev_info {
 	u16 hpb_ver;
 	/* bHPBControl */
 	u8 hpb_control_mode;
+	/* bUFSFeaturesSupport */
+	u8 ufs_features;
 };
 
 /**
drivers/scsi/ufs/ufshcd.c +2 -0
index a40023ad1336..8c7a89c73188 100644
@@ -6557,6 +6557,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
 		goto out;
 	}
 
+	dev_info->ufs_features = desc_buf[DEVICE_DESC_PARAM_UFS_FEAT];
+
 	if (desc_buf[DEVICE_DESC_PARAM_UFS_FEAT] & 0x80) {
 		hba->dev_info.hpb_control_mode =
 			desc_buf[DEVICE_DESC_PARAM_HPB_CTRL_MODE];
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/5 scsi: ufs: add unit and geometry parameters for HPB

In reply to [email protected]

From: Bean Huo <[email protected]>

Add HPB related parameters introduced in Unit Descriptor and Geometry Descriptor.

---
 drivers/scsi/ufs/ufs.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/scsi/ufs/ufs.h +7 -0
index 1a0053133a04..1617d000a60e 100644
@@ -219,6 +219,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_MAX_ACTIVE_REGIONS	= 0x23,
+	UNIT_DESC_PARAM_HPB_PIN_REGION_START_OFFSET	= 0x25,
+	UNIT_DESC_PARAM_HPB_NUM_PIN_REGIONS             = 0x27,
 };
 
 /* Device descriptor parameters offsets in bytes*/
@@ -308,6 +311,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_REGIONS = 0x4B,
 };
 
 /* Health descriptor parameters offsets in bytes*/
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/5 scsi: ufs: UFS Host Performance Booster(HPB) driver

In reply to [email protected]

From: Bean Huo <[email protected]>

This patch is to add support for the UFS Host Performance Booster (HPB v1.0), which is used to improve UFS read performance, especially for the random read.

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. Traditionally this L2P mapping data is loaded to the internal SRAM in the storage controller. When the capacity of storage is larger, a larger size of SRAM for the L2P map data is required. Since increased SRAM size affects the manufacturing cost significantly, it is not cost-effective to allocate all the amount of SRAM needed to keep all the Logical-address to Physical-address (L2P) map data. Therefore, 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 HPB is a software solution for the above issue, which uses the host’s system memory as a cache for the FTL L2P mapping table. It does not need additional hardware support from the host side. By using HPB, the L2P mapping table can be read from host memory and stored in host-side memory. while reading the operation, the corresponding L2P information will be sent to the UFS device along with the reading request. Since the L2P entry is provided in the read request, UFS device does not have to load L2P entry from flash memory. This will significantly improve random read performance.

---
 drivers/scsi/ufs/Kconfig  |   34 +
 drivers/scsi/ufs/Makefile |    1 +
 drivers/scsi/ufs/ufshcd.c |   55 +-
 drivers/scsi/ufs/ufshcd.h |    9 +
 drivers/scsi/ufs/ufshpb.c | 3322 +++++++++++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshpb.h |  421 +++++
 6 files changed, 3836 insertions(+), 6 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshpb.c
 create mode 100644 drivers/scsi/ufs/ufshpb.h
drivers/scsi/ufs/Kconfig +34 -0
index e2005aeddc2d..9ad0d3ecf271 100644
@@ -160,3 +160,37 @@ config SCSI_UFS_BSG
 
 	  Select this if you need a bsg device node for your UFS controller.
 	  If unsure, say N.
+
+config SCSI_UFSHPB
+	bool "UFS Host Performance Booster (EXPERIMENTAL)"
+	depends on SCSI_UFSHCD
+	help
+	  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. Traditionally this L2P
+	  mapping data is loaded to the internal SRAM in the storage controller.
+	  When the capacity of storage is larger, a larger size of SRAM for the
+	  L2P map data is required. Since increased SRAM size affects the
+	  manufacturing cost significantly, it is not cost-effective to allocate
+	  all the amount of SRAM needed to keep all the Logical-address to
+	  Physical-address (L2P) map data. Therefore, 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.
+
+	  UFS Host Performance Booster (HPB) is a software solution for the
+	  above problem, which uses the host side system memory as a cache for
+	  the FTL L2P mapping table. It does not need additional hardware
+	  support from the host side. By using HPB, the L2P mapping table can be
+	  read from host memory and stored in host-side memory. while reading
+	  the operation, the corresponding L2P information will be sent to the
+	  UFS device along with the reading request. Since the L2P entry is
+	  provided in the read request, UFS device does not have to load L2P
+	  entry from flash memory. This will significantly improve the read
+	  performance.
+
+	  Select this if you need HPB to random read performance improvement.
+	  If unsure, say N.
+
drivers/scsi/ufs/Makefile +1 -0
index 94c6c5d7334b..24d9b69eab0c 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 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_UFSHPB) += 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/ufshcd.c +49 -6

114 lines not on this page · raw message

drivers/scsi/ufs/ufshcd.h +9 -0
index 2fa9b880e228..a58bed94ea53 100644
@@ -69,6 +69,7 @@
 
 #include "ufs.h"
 #include "ufshci.h"
+#include "ufshpb.h"
 
 #define UFSHCD "ufshcd"
 #define UFSHCD_DRIVER_VERSION "0.2"
@@ -711,6 +712,14 @@ struct ufs_hba {
 
 	struct device		bsg_dev;
 	struct request_queue	*bsg_queue;
+
+#if defined(CONFIG_SCSI_UFSHPB)
+	enum UFSHPB_STATE ufshpb_state;
+	struct ufshpb_lu *ufshpb_lup[32];
+	struct delayed_work ufshpb_init_work;
+	struct work_struct ufshpb_eh_work;
+	struct scsi_device *sdev_ufs_lu[32];
+#endif
 };
 
 /* Returns true if clocks can be gated. Otherwise false */
drivers/scsi/ufs/ufshpb.c new file +3322 -0

2,821 lines not on this page · raw message

drivers/scsi/ufs/ufshpb.h new file +421 -0

421 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#6 lore raw

Re: [PATCH v1 5/5] scsi: ufs: UFS Host Performance Booster(HPB) driver

Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on scsi/for-next next-20200320]
[cannot apply to v5.6-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/huobean-gmail-com/scsi-ufs-add-UFS-Host-Performance-Booster-HPB-driver/20200321-084331
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: parisc-allyesconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=parisc

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers/scsi/ufs/ufshpb.c: In function 'ufshpb_mctx_mempool_remove':

>> drivers/scsi/ufs/ufshpb.c:1767:3: error: implicit declaration of function 'vfree'; did you mean 'kvfree'? [-Werror=implicit-function-declaration]
    1767 |   vfree(mctx->ppn_dirty);
         |   ^~~~~
         |   kvfree
   drivers/scsi/ufs/ufshpb.c: In function 'ufshpb_mctx_mempool_init':
>> drivers/scsi/ufs/ufshpb.c:1794:21: error: implicit declaration of function 'vzalloc'; did you mean 'kvzalloc'? [-Werror=implicit-function-declaration]
    1794 |   mctx->ppn_dirty = vzalloc(entry_count >> bits_per_byte_shift);
         |                     ^~~~~~~
         |                     kvzalloc
>> drivers/scsi/ufs/ufshpb.c:1794:19: warning: assignment to 'unsigned int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    1794 |   mctx->ppn_dirty = vzalloc(entry_count >> bits_per_byte_shift);
         |                   ^
   In file included from include/linux/printk.h:7,
                    from include/linux/kernel.h:15,
                    from arch/parisc/include/asm/bug.h:5,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:12,
                    from include/asm-generic/current.h:5,
                    from ./arch/parisc/include/generated/asm/current.h:1,
                    from include/linux/sched.h:12,
                    from include/linux/blkdev.h:5,
                    from drivers/scsi/ufs/ufshpb.c:12:
   drivers/scsi/ufs/ufshpb.c: In function 'ufshpb_lu_init':
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'unsigned int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
      14 | #define KERN_INFO KERN_SOH "6" /* informational */
         |                   ^~~~~~~~
   include/linux/printk.h:310:9: note: in expansion of macro 'KERN_INFO'
     310 |  printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~
   drivers/scsi/ufs/ufshpb.h:28:2: note: in expansion of macro 'pr_info'
      28 |  pr_info("%s:" fmt, DRIVER_NAME, ##__VA_ARGS__)
         |  ^~~~~~~
   drivers/scsi/ufs/ufshpb.c:2034:2: note: in expansion of macro 'hpb_info'
    2034 |  hpb_info("LU%d region table size: %lu bytes\n", lun,
         |  ^~~~~~~~
   drivers/scsi/ufs/ufshpb.c:2034:38: note: format string is defined here
    2034 |  hpb_info("LU%d region table size: %lu bytes\n", lun,
         |                                    ~~^
         |                                      |
         |                                      long unsigned int
         |                                    %u
   In file included from include/linux/printk.h:7,
                    from include/linux/kernel.h:15,
                    from arch/parisc/include/asm/bug.h:5,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:12,
                    from include/asm-generic/current.h:5,
                    from ./arch/parisc/include/generated/asm/current.h:1,
                    from include/linux/sched.h:12,
                    from include/linux/blkdev.h:5,
                    from drivers/scsi/ufs/ufshpb.c:12:
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'unsigned int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
      14 | #define KERN_INFO KERN_SOH "6" /* informational */
         |                   ^~~~~~~~
   include/linux/printk.h:310:9: note: in expansion of macro 'KERN_INFO'
     310 |  printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~
   drivers/scsi/ufs/ufshpb.h:28:2: note: in expansion of macro 'pr_info'
      28 |  pr_info("%s:" fmt, DRIVER_NAME, ##__VA_ARGS__)
         |  ^~~~~~~
   drivers/scsi/ufs/ufshpb.c:2111:2: note: in expansion of macro 'hpb_info'
    2111 |  hpb_info("LU%d subregions info table takes memory %lu bytes\n", lun,
         |  ^~~~~~~~
   drivers/scsi/ufs/ufshpb.c:2111:54: note: format string is defined here
    2111 |  hpb_info("LU%d subregions info table takes memory %lu bytes\n", lun,
         |                                                    ~~^
         |                                                      |
         |                                                      long unsigned int
         |                                                    %u

cc1: some warnings being treated as errors

vim +1767 drivers/scsi/ufs/ufshpb.c

1757
1758 static void ufshpb_mctx_mempool_remove(struct ufshpb_lu *hpb)
1759 {
1760 struct ufshpb_map_ctx *mctx, *next;
1761 int i;
1762
1763 list_for_each_entry_safe(mctx, next, &hpb->lh_map_ctx, list_table) {
1764 for (i = 0; i < hpb->mpages_per_subregion; i++)
1765 __free_page(mctx->m_page[i]);
1766

> 1767			vfree(mctx->ppn_dirty);
  1768			kfree(mctx->m_page);
  1769			kfree(mctx);
  1770			alloc_mctx--;
  1771		}
  1772	}
  1773	
  1774	static int ufshpb_mctx_mempool_init(struct ufshpb_lu *hpb, int num_regions,
  1775					    int subregions_per_region, int entry_count,
  1776					    int entry_byte)
  1777	{
  1778		int i, j, k;
  1779		struct ufshpb_map_ctx *mctx = NULL;
  1780	
  1781		INIT_LIST_HEAD(&hpb->lh_map_ctx);
  1782	
  1783		for (i = 0; i < num_regions * subregions_per_region; i++) {
  1784			mctx = kzalloc(sizeof(struct ufshpb_map_ctx), GFP_KERNEL);
  1785			if (!mctx)
  1786				goto release_mem;
  1787	
  1788			mctx->m_page = kcalloc(hpb->mpages_per_subregion,
  1789					       sizeof(struct page *),
  1790					       GFP_KERNEL);
  1791			if (!mctx->m_page)
  1792				goto release_mem;
  1793	
> 1794			mctx->ppn_dirty = vzalloc(entry_count >> bits_per_byte_shift);

1795 if (!mctx->ppn_dirty)
1796 goto release_mem;
1797
1798 for (j = 0; j < hpb->mpages_per_subregion; j++) {
1799 mctx->m_page[j] = alloc_page(GFP_KERNEL | __GFP_ZERO);
1800 if (!mctx->m_page[j]) {
1801 for (k = 0; k < j; k++)
1802 kfree(mctx->m_page[k]);
1803 goto release_mem;
1804 }
1805 }
1806
1807 INIT_LIST_HEAD(&mctx->list_table);
1808 list_add(&mctx->list_table, &hpb->lh_map_ctx);
1809 hpb->free_mctx++;
1810 }
1811
1812 alloc_mctx = num_regions * subregions_per_region;
1813 hpb_info("LU%d amount of mctx %d\n", hpb->lun, hpb->free_mctx);
1814 return 0;
1815
1816 release_mem:
1817 /*
1818 * mctxs already added in lh_map_ctx will be removed
1819 * in the caller function.
1820 */
1821 if (mctx) {
1822 kfree(mctx->m_page);
1823 vfree(mctx->ppn_dirty);
1824 kfree(mctx);
1825 }
1826 return -ENOMEM;
1827 }
1828

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#7 lore raw

Re: [PATCH v1 5/5] scsi: ufs: UFS Host Performance Booster(HPB) driver

In reply to [email protected]
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on scsi/for-next next-20200320]
[cannot apply to v5.6-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/huobean-gmail-com/scsi-ufs-add-UFS-Host-Performance-Booster-HPB-driver/20200321-084331
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=m68k

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

>> ERROR: "__udivdi3" [drivers/scsi/ufs/ufshcd-core.ko] undefined!
>> ERROR: "__umoddi3" [drivers/scsi/ufs/ufshcd-core.ko] undefined!

--
In file included from include/linux/printk.h:7,
from include/linux/kernel.h:15,
from include/linux/list.h:9,
from include/linux/rculist.h:10,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/blkdev.h:5,
from drivers/scsi/ufs/ufshpb.c:12:
drivers/scsi/ufs/ufshpb.c: In function 'ufshpb_lu_init':
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'unsigned int' [-Wformat=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~
include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
14 | #define KERN_INFO KERN_SOH "6" /* informational */
| ^~~~~~~~
include/linux/printk.h:310:9: note: in expansion of macro 'KERN_INFO'

     310 |  printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~
>> drivers/scsi/ufs/ufshpb.h:28:2: note: in expansion of macro 'pr_info'
      28 |  pr_info("%s:" fmt, DRIVER_NAME, ##__VA_ARGS__)
         |  ^~~~~~~
>> drivers/scsi/ufs/ufshpb.c:2034:2: note: in expansion of macro 'hpb_info'
    2034 |  hpb_info("LU%d region table size: %lu bytes\n", lun,
         |  ^~~~~~~~
   drivers/scsi/ufs/ufshpb.c:2034:38: note: format string is defined here
    2034 |  hpb_info("LU%d region table size: %lu bytes\n", lun,
         |                                    ~~^
         |                                      |
         |                                      long unsigned int
         |                                    %u
   In file included from include/linux/printk.h:7,
                    from include/linux/kernel.h:15,
                    from include/linux/list.h:9,
                    from include/linux/rculist.h:10,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/blkdev.h:5,
                    from drivers/scsi/ufs/ufshpb.c:12:
   include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'unsigned int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/kern_levels.h:14:19: note: in expansion of macro 'KERN_SOH'
      14 | #define KERN_INFO KERN_SOH "6" /* informational */
         |                   ^~~~~~~~
   include/linux/printk.h:310:9: note: in expansion of macro 'KERN_INFO'
     310 |  printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~~
>> drivers/scsi/ufs/ufshpb.h:28:2: note: in expansion of macro 'pr_info'
      28 |  pr_info("%s:" fmt, DRIVER_NAME, ##__VA_ARGS__)
         |  ^~~~~~~
   drivers/scsi/ufs/ufshpb.c:2111:2: note: in expansion of macro 'hpb_info'
    2111 |  hpb_info("LU%d subregions info table takes memory %lu bytes\n", lun,
         |  ^~~~~~~~
   drivers/scsi/ufs/ufshpb.c:2111:54: note: format string is defined here
    2111 |  hpb_info("LU%d subregions info table takes memory %lu bytes\n", lun,
         |                                                    ~~^
         |                                                      |
         |                                                      long unsigned int
         |                                                    %u

vim +/pr_info +28 drivers/scsi/ufs/ufshpb.h

    20	
    21	#define UFSHPB_VER			0x0100
    22	#define DRIVER_NAME			"UFSHPB"
    23	#define hpb_warn(fmt, ...)					\
    24		pr_warn("%s:" fmt, DRIVER_NAME, ##__VA_ARGS__)
    25	#define hpb_notice(fmt, ...)					\
    26		pr_notice("%s:" fmt, DRIVER_NAME, ##__VA_ARGS__)
    27	#define hpb_info(fmt, ...)					\
  > 28		pr_info("%s:" fmt, DRIVER_NAME, ##__VA_ARGS__)
    29	#define hpb_err(fmt, ...)					\
    30		pr_err("%s: %s:" fmt, __func__, DRIVER_NAME,		\
    31						##__VA_ARGS__)
    32	#define hpb_dbg(level, hpb, fmt, ...)				\
    33	do {								\
    34		if (hpb == NULL)					\
    35			break;						\
    36		if (hpb->debug >= HPB_DBG_MAX || hpb->debug == level)	\
    37			pr_notice("%s: %s():" fmt,			\
    38				DRIVER_NAME, __func__, ##__VA_ARGS__);	\
    39	} while (0)
    40	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#8 lore raw

Re: [PATCH v1 5/5] scsi: ufs: UFS Host Performance Booster(HPB) driver

In reply to [email protected]
Thank you for the patch! Perhaps something to improve:

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next next-20200320]
[cannot apply to v5.6-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/huobean-gmail-com/scsi-ufs-add-UFS-Host-Performance-Booster-HPB-driver/20200321-084331
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-187-gbff9b106-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag

sparse warnings: (new ones prefixed by >>)

>> drivers/scsi/ufs/ufshpb.c:32:5: sparse: sparse: symbol 'alloc_mctx' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#9 lore raw

[RFC PATCH] scsi: ufs: alloc_mctx can be static

In reply to [email protected]
Fixes: 161f01e2ffea ("scsi: ufs: UFS Host Performance Booster(HPB) driver")
Fixes 161f01e2ffea ("scsi: ufs: UFS Host Performance Booster(HPB) driver")
---
 ufshpb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshpb.c +1 -1
index 137d0e3cf7261..ee77c7db668e7 100644
@@ -29,7 +29,7 @@
 /*
  * debug variables
  */
-int alloc_mctx;
+static int alloc_mctx;
 
 /*
  * define global constants