2020-06-06 04:05:19 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-02-29 14:41:50 +08:00
|
|
|
/*
|
|
|
|
* Universal Flash Storage Host controller driver
|
2013-02-26 00:14:32 +08:00
|
|
|
* Copyright (C) 2011-2013 Samsung India Software Operations
|
2012-02-29 14:41:50 +08:00
|
|
|
*
|
2013-02-26 00:14:32 +08:00
|
|
|
* Authors:
|
|
|
|
* Santosh Yaraganavi <santosh.sy@samsung.com>
|
|
|
|
* Vinayak Holikatti <h.vinayak@samsung.com>
|
2012-02-29 14:41:50 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UFS_H
|
|
|
|
#define _UFS_H
|
|
|
|
|
2013-07-30 03:05:57 +08:00
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/types.h>
|
2018-10-07 22:30:34 +08:00
|
|
|
#include <uapi/scsi/scsi_bsg_ufs.h>
|
2013-07-30 03:05:57 +08:00
|
|
|
|
2018-10-07 22:30:36 +08:00
|
|
|
#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req))
|
2014-06-29 14:40:17 +08:00
|
|
|
#define QUERY_DESC_MAX_SIZE 255
|
|
|
|
#define QUERY_DESC_MIN_SIZE 2
|
2016-03-10 23:37:09 +08:00
|
|
|
#define QUERY_DESC_HDR_SIZE 2
|
2013-07-30 03:05:58 +08:00
|
|
|
#define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \
|
|
|
|
(sizeof(struct utp_upiu_header)))
|
2018-11-23 02:04:56 +08:00
|
|
|
#define UFS_SENSE_SIZE 18
|
2012-02-29 14:41:50 +08:00
|
|
|
|
|
|
|
#define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
|
2013-07-30 03:05:57 +08:00
|
|
|
cpu_to_be32((byte3 << 24) | (byte2 << 16) |\
|
2012-02-29 14:41:50 +08:00
|
|
|
(byte1 << 8) | (byte0))
|
2014-09-25 20:32:29 +08:00
|
|
|
/*
|
|
|
|
* UFS device may have standard LUs and LUN id could be from 0x00 to
|
|
|
|
* 0x7F. Standard LUs use "Peripheral Device Addressing Format".
|
|
|
|
* UFS device may also have the Well Known LUs (also referred as W-LU)
|
|
|
|
* which again could be from 0x00 to 0x7F. For W-LUs, device only use
|
|
|
|
* the "Extended Addressing Format" which means the W-LUNs would be
|
|
|
|
* from 0xc100 (SCSI_W_LUN_BASE) onwards.
|
|
|
|
* This means max. LUN number reported from UFS device could be 0xC17F.
|
|
|
|
*/
|
|
|
|
#define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F
|
|
|
|
#define UFS_MAX_LUNS (SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID)
|
|
|
|
#define UFS_UPIU_WLUN_ID (1 << 7)
|
2020-06-03 17:19:59 +08:00
|
|
|
#define UFS_RPMB_UNIT 0xC4
|
2014-09-25 20:32:25 +08:00
|
|
|
|
2020-05-08 16:01:13 +08:00
|
|
|
/* WriteBooster buffer is available only for the logical unit from 0 to 7 */
|
|
|
|
#define UFS_UPIU_MAX_WB_LUN_ID 8
|
|
|
|
|
2022-01-27 11:00:25 +08:00
|
|
|
/*
|
|
|
|
* WriteBooster buffer lifetime has a limit setted by vendor.
|
|
|
|
* If it is over the limit, WriteBooster feature will be disabled.
|
|
|
|
*/
|
|
|
|
#define UFS_WB_EXCEED_LIFETIME 0x0B
|
|
|
|
|
2014-09-25 20:32:29 +08:00
|
|
|
/* Well known logical unit id in LUN field of UPIU */
|
|
|
|
enum {
|
|
|
|
UFS_UPIU_REPORT_LUNS_WLUN = 0x81,
|
|
|
|
UFS_UPIU_UFS_DEVICE_WLUN = 0xD0,
|
|
|
|
UFS_UPIU_BOOT_WLUN = 0xB0,
|
|
|
|
UFS_UPIU_RPMB_WLUN = 0xC4,
|
|
|
|
};
|
|
|
|
|
2012-02-29 14:41:50 +08:00
|
|
|
/*
|
|
|
|
* UFS Protocol Information Unit related definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Task management functions */
|
|
|
|
enum {
|
|
|
|
UFS_ABORT_TASK = 0x01,
|
|
|
|
UFS_ABORT_TASK_SET = 0x02,
|
|
|
|
UFS_CLEAR_TASK_SET = 0x04,
|
|
|
|
UFS_LOGICAL_RESET = 0x08,
|
|
|
|
UFS_QUERY_TASK = 0x80,
|
|
|
|
UFS_QUERY_TASK_SET = 0x81,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* UTP UPIU Transaction Codes Initiator to Target */
|
|
|
|
enum {
|
|
|
|
UPIU_TRANSACTION_NOP_OUT = 0x00,
|
|
|
|
UPIU_TRANSACTION_COMMAND = 0x01,
|
|
|
|
UPIU_TRANSACTION_DATA_OUT = 0x02,
|
|
|
|
UPIU_TRANSACTION_TASK_REQ = 0x04,
|
2013-07-30 03:05:58 +08:00
|
|
|
UPIU_TRANSACTION_QUERY_REQ = 0x16,
|
2012-02-29 14:41:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* UTP UPIU Transaction Codes Target to Initiator */
|
|
|
|
enum {
|
|
|
|
UPIU_TRANSACTION_NOP_IN = 0x20,
|
|
|
|
UPIU_TRANSACTION_RESPONSE = 0x21,
|
|
|
|
UPIU_TRANSACTION_DATA_IN = 0x22,
|
|
|
|
UPIU_TRANSACTION_TASK_RSP = 0x24,
|
|
|
|
UPIU_TRANSACTION_READY_XFER = 0x31,
|
|
|
|
UPIU_TRANSACTION_QUERY_RSP = 0x36,
|
2013-07-30 03:05:57 +08:00
|
|
|
UPIU_TRANSACTION_REJECT_UPIU = 0x3F,
|
2012-02-29 14:41:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* UPIU Read/Write flags */
|
|
|
|
enum {
|
|
|
|
UPIU_CMD_FLAGS_NONE = 0x00,
|
|
|
|
UPIU_CMD_FLAGS_WRITE = 0x20,
|
|
|
|
UPIU_CMD_FLAGS_READ = 0x40,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* UPIU Task Attributes */
|
|
|
|
enum {
|
|
|
|
UPIU_TASK_ATTR_SIMPLE = 0x00,
|
|
|
|
UPIU_TASK_ATTR_ORDERED = 0x01,
|
|
|
|
UPIU_TASK_ATTR_HEADQ = 0x02,
|
|
|
|
UPIU_TASK_ATTR_ACA = 0x03,
|
|
|
|
};
|
|
|
|
|
2013-07-30 03:05:58 +08:00
|
|
|
/* UPIU Query request function */
|
2012-02-29 14:41:50 +08:00
|
|
|
enum {
|
2013-07-30 03:05:58 +08:00
|
|
|
UPIU_QUERY_FUNC_STANDARD_READ_REQUEST = 0x01,
|
|
|
|
UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST = 0x81,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Flag idn for Query Requests*/
|
|
|
|
enum flag_idn {
|
2018-02-15 20:14:10 +08:00
|
|
|
QUERY_FLAG_IDN_FDEVICEINIT = 0x01,
|
|
|
|
QUERY_FLAG_IDN_PERMANENT_WPE = 0x02,
|
|
|
|
QUERY_FLAG_IDN_PWR_ON_WPE = 0x03,
|
|
|
|
QUERY_FLAG_IDN_BKOPS_EN = 0x04,
|
|
|
|
QUERY_FLAG_IDN_LIFE_SPAN_MODE_ENABLE = 0x05,
|
|
|
|
QUERY_FLAG_IDN_PURGE_ENABLE = 0x06,
|
|
|
|
QUERY_FLAG_IDN_RESERVED2 = 0x07,
|
|
|
|
QUERY_FLAG_IDN_FPHYRESOURCEREMOVAL = 0x08,
|
|
|
|
QUERY_FLAG_IDN_BUSY_RTC = 0x09,
|
|
|
|
QUERY_FLAG_IDN_RESERVED3 = 0x0A,
|
|
|
|
QUERY_FLAG_IDN_PERMANENTLY_DISABLE_FW_UPDATE = 0x0B,
|
2020-04-23 05:41:42 +08:00
|
|
|
QUERY_FLAG_IDN_WB_EN = 0x0E,
|
|
|
|
QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN = 0x0F,
|
|
|
|
QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 = 0x10,
|
scsi: ufs: ufshpb: Introduce Host Performance Buffer feature
Implement Host Performance Buffer (HPB) initialization and add function
calls to UFS core driver.
NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of I/O requests to the corresponding physical
addresses of the flash storage. In UFS, logical-to-physical-address (L2P)
map data, which is required to identify the physical address for the
requested I/Os, 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 regular 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, HPB parameters are
configured in the device.
Total start-up time of popular applications was measured and the difference
observed between HPB being enabled and disabled. Popular applications are
12 game apps and 24 non-game apps. Each test cycle consists of running 36
applications in sequence. We repeated the cycle for observing performance
improvement by L2P mapping cache hit in HPB.
The following is the test environment:
- kernel version: 4.4.0
- RAM: 8GB
- UFS 2.1 (64GB)
Results:
+-------+----------+----------+-------+
| cycle | baseline | with HPB | diff |
+-------+----------+----------+-------+
| 1 | 272.4 | 264.9 | -7.5 |
| 2 | 250.4 | 248.2 | -2.2 |
| 3 | 226.2 | 215.6 | -10.6 |
| 4 | 230.6 | 214.8 | -15.8 |
| 5 | 232.0 | 218.1 | -13.9 |
| 6 | 231.9 | 212.6 | -19.3 |
+-------+----------+----------+-------+
We also measured HPB performance using iozone:
$ iozone -r 4k -+n -i2 -ecI -t 16 -l 16 -u 16 -s $IO_RANGE/16 -F \
mnt/tmp_1 mnt/tmp_2 mnt/tmp_3 mnt/tmp_4 mnt/tmp_5 mnt/tmp_6 mnt/tmp_7 \
mnt/tmp_8 mnt/tmp_9 mnt/tmp_10 mnt/tmp_11 mnt/tmp_12 mnt/tmp_13 \
mnt/tmp_14 mnt/tmp_15 mnt/tmp_16
Results:
+----------+--------+---------+
| IO range | HPB on | HPB off |
+----------+--------+---------+
| 1 GB | 294.8 | 300.87 |
| 4 GB | 293.51 | 179.35 |
| 8 GB | 294.85 | 162.52 |
| 16 GB | 293.45 | 156.26 |
| 32 GB | 277.4 | 153.25 |
+----------+--------+---------+
Link: https://lore.kernel.org/r/20210712085830epcms2p8c1288b7f7a81b044158a18232617b572@epcms2p8
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Tested-by: Can Guo <cang@codeaurora.org>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12 16:58:30 +08:00
|
|
|
QUERY_FLAG_IDN_HPB_RESET = 0x11,
|
2021-07-12 17:00:25 +08:00
|
|
|
QUERY_FLAG_IDN_HPB_EN = 0x12,
|
2013-07-30 03:05:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Attribute idn for Query requests */
|
|
|
|
enum attr_idn {
|
2018-02-15 20:14:11 +08:00
|
|
|
QUERY_ATTR_IDN_BOOT_LU_EN = 0x00,
|
2021-07-12 17:00:25 +08:00
|
|
|
QUERY_ATTR_IDN_MAX_HPB_SINGLE_CMD = 0x01,
|
2018-02-15 20:14:11 +08:00
|
|
|
QUERY_ATTR_IDN_POWER_MODE = 0x02,
|
|
|
|
QUERY_ATTR_IDN_ACTIVE_ICC_LVL = 0x03,
|
|
|
|
QUERY_ATTR_IDN_OOO_DATA_EN = 0x04,
|
|
|
|
QUERY_ATTR_IDN_BKOPS_STATUS = 0x05,
|
|
|
|
QUERY_ATTR_IDN_PURGE_STATUS = 0x06,
|
|
|
|
QUERY_ATTR_IDN_MAX_DATA_IN = 0x07,
|
|
|
|
QUERY_ATTR_IDN_MAX_DATA_OUT = 0x08,
|
|
|
|
QUERY_ATTR_IDN_DYN_CAP_NEEDED = 0x09,
|
|
|
|
QUERY_ATTR_IDN_REF_CLK_FREQ = 0x0A,
|
|
|
|
QUERY_ATTR_IDN_CONF_DESC_LOCK = 0x0B,
|
|
|
|
QUERY_ATTR_IDN_MAX_NUM_OF_RTT = 0x0C,
|
|
|
|
QUERY_ATTR_IDN_EE_CONTROL = 0x0D,
|
|
|
|
QUERY_ATTR_IDN_EE_STATUS = 0x0E,
|
|
|
|
QUERY_ATTR_IDN_SECONDS_PASSED = 0x0F,
|
|
|
|
QUERY_ATTR_IDN_CNTX_CONF = 0x10,
|
|
|
|
QUERY_ATTR_IDN_CORR_PRG_BLK_NUM = 0x11,
|
|
|
|
QUERY_ATTR_IDN_RESERVED2 = 0x12,
|
|
|
|
QUERY_ATTR_IDN_RESERVED3 = 0x13,
|
|
|
|
QUERY_ATTR_IDN_FFU_STATUS = 0x14,
|
|
|
|
QUERY_ATTR_IDN_PSA_STATE = 0x15,
|
|
|
|
QUERY_ATTR_IDN_PSA_DATA_SIZE = 0x16,
|
2020-02-11 11:40:49 +08:00
|
|
|
QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME = 0x17,
|
2021-09-15 14:04:06 +08:00
|
|
|
QUERY_ATTR_IDN_CASE_ROUGH_TEMP = 0x18,
|
|
|
|
QUERY_ATTR_IDN_HIGH_TEMP_BOUND = 0x19,
|
|
|
|
QUERY_ATTR_IDN_LOW_TEMP_BOUND = 0x1A,
|
2020-04-23 05:41:42 +08:00
|
|
|
QUERY_ATTR_IDN_WB_FLUSH_STATUS = 0x1C,
|
|
|
|
QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE = 0x1D,
|
|
|
|
QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E,
|
|
|
|
QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F,
|
2013-07-30 03:05:59 +08:00
|
|
|
};
|
|
|
|
|
2014-06-29 14:40:17 +08:00
|
|
|
/* Descriptor idn for Query requests */
|
|
|
|
enum desc_idn {
|
|
|
|
QUERY_DESC_IDN_DEVICE = 0x0,
|
2017-02-23 17:05:30 +08:00
|
|
|
QUERY_DESC_IDN_CONFIGURATION = 0x1,
|
2014-06-29 14:40:17 +08:00
|
|
|
QUERY_DESC_IDN_UNIT = 0x2,
|
|
|
|
QUERY_DESC_IDN_RFU_0 = 0x3,
|
|
|
|
QUERY_DESC_IDN_INTERCONNECT = 0x4,
|
|
|
|
QUERY_DESC_IDN_STRING = 0x5,
|
|
|
|
QUERY_DESC_IDN_RFU_1 = 0x6,
|
|
|
|
QUERY_DESC_IDN_GEOMETRY = 0x7,
|
|
|
|
QUERY_DESC_IDN_POWER = 0x8,
|
2018-02-15 20:14:05 +08:00
|
|
|
QUERY_DESC_IDN_HEALTH = 0x9,
|
2014-09-25 20:32:25 +08:00
|
|
|
QUERY_DESC_IDN_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum desc_header_offset {
|
|
|
|
QUERY_DESC_LENGTH_OFFSET = 0x00,
|
|
|
|
QUERY_DESC_DESC_TYPE_OFFSET = 0x01,
|
|
|
|
};
|
|
|
|
|
2014-06-29 14:40:19 +08:00
|
|
|
/* Unit descriptor parameters offsets in bytes*/
|
|
|
|
enum unit_desc_param {
|
|
|
|
UNIT_DESC_PARAM_LEN = 0x0,
|
|
|
|
UNIT_DESC_PARAM_TYPE = 0x1,
|
|
|
|
UNIT_DESC_PARAM_UNIT_INDEX = 0x2,
|
|
|
|
UNIT_DESC_PARAM_LU_ENABLE = 0x3,
|
|
|
|
UNIT_DESC_PARAM_BOOT_LUN_ID = 0x4,
|
|
|
|
UNIT_DESC_PARAM_LU_WR_PROTECT = 0x5,
|
|
|
|
UNIT_DESC_PARAM_LU_Q_DEPTH = 0x6,
|
2018-02-15 20:14:09 +08:00
|
|
|
UNIT_DESC_PARAM_PSA_SENSITIVE = 0x7,
|
2014-06-29 14:40:19 +08:00
|
|
|
UNIT_DESC_PARAM_MEM_TYPE = 0x8,
|
|
|
|
UNIT_DESC_PARAM_DATA_RELIABILITY = 0x9,
|
|
|
|
UNIT_DESC_PARAM_LOGICAL_BLK_SIZE = 0xA,
|
|
|
|
UNIT_DESC_PARAM_LOGICAL_BLK_COUNT = 0xB,
|
|
|
|
UNIT_DESC_PARAM_ERASE_BLK_SIZE = 0x13,
|
|
|
|
UNIT_DESC_PARAM_PROVISIONING_TYPE = 0x17,
|
|
|
|
UNIT_DESC_PARAM_PHY_MEM_RSRC_CNT = 0x18,
|
|
|
|
UNIT_DESC_PARAM_CTX_CAPABILITIES = 0x20,
|
|
|
|
UNIT_DESC_PARAM_LARGE_UNIT_SIZE_M1 = 0x22,
|
scsi: ufs: ufshpb: Introduce Host Performance Buffer feature
Implement Host Performance Buffer (HPB) initialization and add function
calls to UFS core driver.
NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of I/O requests to the corresponding physical
addresses of the flash storage. In UFS, logical-to-physical-address (L2P)
map data, which is required to identify the physical address for the
requested I/Os, 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 regular 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, HPB parameters are
configured in the device.
Total start-up time of popular applications was measured and the difference
observed between HPB being enabled and disabled. Popular applications are
12 game apps and 24 non-game apps. Each test cycle consists of running 36
applications in sequence. We repeated the cycle for observing performance
improvement by L2P mapping cache hit in HPB.
The following is the test environment:
- kernel version: 4.4.0
- RAM: 8GB
- UFS 2.1 (64GB)
Results:
+-------+----------+----------+-------+
| cycle | baseline | with HPB | diff |
+-------+----------+----------+-------+
| 1 | 272.4 | 264.9 | -7.5 |
| 2 | 250.4 | 248.2 | -2.2 |
| 3 | 226.2 | 215.6 | -10.6 |
| 4 | 230.6 | 214.8 | -15.8 |
| 5 | 232.0 | 218.1 | -13.9 |
| 6 | 231.9 | 212.6 | -19.3 |
+-------+----------+----------+-------+
We also measured HPB performance using iozone:
$ iozone -r 4k -+n -i2 -ecI -t 16 -l 16 -u 16 -s $IO_RANGE/16 -F \
mnt/tmp_1 mnt/tmp_2 mnt/tmp_3 mnt/tmp_4 mnt/tmp_5 mnt/tmp_6 mnt/tmp_7 \
mnt/tmp_8 mnt/tmp_9 mnt/tmp_10 mnt/tmp_11 mnt/tmp_12 mnt/tmp_13 \
mnt/tmp_14 mnt/tmp_15 mnt/tmp_16
Results:
+----------+--------+---------+
| IO range | HPB on | HPB off |
+----------+--------+---------+
| 1 GB | 294.8 | 300.87 |
| 4 GB | 293.51 | 179.35 |
| 8 GB | 294.85 | 162.52 |
| 16 GB | 293.45 | 156.26 |
| 32 GB | 277.4 | 153.25 |
+----------+--------+---------+
Link: https://lore.kernel.org/r/20210712085830epcms2p8c1288b7f7a81b044158a18232617b572@epcms2p8
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Tested-by: Can Guo <cang@codeaurora.org>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12 16:58:30 +08:00
|
|
|
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,
|
2020-04-23 05:41:42 +08:00
|
|
|
UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS = 0x29,
|
2014-06-29 14:40:19 +08:00
|
|
|
};
|
|
|
|
|
2016-03-10 23:37:10 +08:00
|
|
|
/* Device descriptor parameters offsets in bytes*/
|
|
|
|
enum device_desc_param {
|
|
|
|
DEVICE_DESC_PARAM_LEN = 0x0,
|
|
|
|
DEVICE_DESC_PARAM_TYPE = 0x1,
|
|
|
|
DEVICE_DESC_PARAM_DEVICE_TYPE = 0x2,
|
|
|
|
DEVICE_DESC_PARAM_DEVICE_CLASS = 0x3,
|
|
|
|
DEVICE_DESC_PARAM_DEVICE_SUB_CLASS = 0x4,
|
|
|
|
DEVICE_DESC_PARAM_PRTCL = 0x5,
|
|
|
|
DEVICE_DESC_PARAM_NUM_LU = 0x6,
|
|
|
|
DEVICE_DESC_PARAM_NUM_WLU = 0x7,
|
|
|
|
DEVICE_DESC_PARAM_BOOT_ENBL = 0x8,
|
|
|
|
DEVICE_DESC_PARAM_DESC_ACCSS_ENBL = 0x9,
|
|
|
|
DEVICE_DESC_PARAM_INIT_PWR_MODE = 0xA,
|
|
|
|
DEVICE_DESC_PARAM_HIGH_PR_LUN = 0xB,
|
|
|
|
DEVICE_DESC_PARAM_SEC_RMV_TYPE = 0xC,
|
|
|
|
DEVICE_DESC_PARAM_SEC_LU = 0xD,
|
|
|
|
DEVICE_DESC_PARAM_BKOP_TERM_LT = 0xE,
|
|
|
|
DEVICE_DESC_PARAM_ACTVE_ICC_LVL = 0xF,
|
|
|
|
DEVICE_DESC_PARAM_SPEC_VER = 0x10,
|
|
|
|
DEVICE_DESC_PARAM_MANF_DATE = 0x12,
|
|
|
|
DEVICE_DESC_PARAM_MANF_NAME = 0x14,
|
|
|
|
DEVICE_DESC_PARAM_PRDCT_NAME = 0x15,
|
|
|
|
DEVICE_DESC_PARAM_SN = 0x16,
|
|
|
|
DEVICE_DESC_PARAM_OEM_ID = 0x17,
|
|
|
|
DEVICE_DESC_PARAM_MANF_ID = 0x18,
|
|
|
|
DEVICE_DESC_PARAM_UD_OFFSET = 0x1A,
|
|
|
|
DEVICE_DESC_PARAM_UD_LEN = 0x1B,
|
|
|
|
DEVICE_DESC_PARAM_RTT_CAP = 0x1C,
|
|
|
|
DEVICE_DESC_PARAM_FRQ_RTC = 0x1D,
|
2018-02-15 20:14:02 +08:00
|
|
|
DEVICE_DESC_PARAM_UFS_FEAT = 0x1F,
|
|
|
|
DEVICE_DESC_PARAM_FFU_TMT = 0x20,
|
|
|
|
DEVICE_DESC_PARAM_Q_DPTH = 0x21,
|
|
|
|
DEVICE_DESC_PARAM_DEV_VER = 0x22,
|
|
|
|
DEVICE_DESC_PARAM_NUM_SEC_WPA = 0x24,
|
|
|
|
DEVICE_DESC_PARAM_PSA_MAX_DATA = 0x25,
|
|
|
|
DEVICE_DESC_PARAM_PSA_TMT = 0x29,
|
|
|
|
DEVICE_DESC_PARAM_PRDCT_REV = 0x2A,
|
scsi: ufs: ufshpb: Introduce Host Performance Buffer feature
Implement Host Performance Buffer (HPB) initialization and add function
calls to UFS core driver.
NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of I/O requests to the corresponding physical
addresses of the flash storage. In UFS, logical-to-physical-address (L2P)
map data, which is required to identify the physical address for the
requested I/Os, 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 regular 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, HPB parameters are
configured in the device.
Total start-up time of popular applications was measured and the difference
observed between HPB being enabled and disabled. Popular applications are
12 game apps and 24 non-game apps. Each test cycle consists of running 36
applications in sequence. We repeated the cycle for observing performance
improvement by L2P mapping cache hit in HPB.
The following is the test environment:
- kernel version: 4.4.0
- RAM: 8GB
- UFS 2.1 (64GB)
Results:
+-------+----------+----------+-------+
| cycle | baseline | with HPB | diff |
+-------+----------+----------+-------+
| 1 | 272.4 | 264.9 | -7.5 |
| 2 | 250.4 | 248.2 | -2.2 |
| 3 | 226.2 | 215.6 | -10.6 |
| 4 | 230.6 | 214.8 | -15.8 |
| 5 | 232.0 | 218.1 | -13.9 |
| 6 | 231.9 | 212.6 | -19.3 |
+-------+----------+----------+-------+
We also measured HPB performance using iozone:
$ iozone -r 4k -+n -i2 -ecI -t 16 -l 16 -u 16 -s $IO_RANGE/16 -F \
mnt/tmp_1 mnt/tmp_2 mnt/tmp_3 mnt/tmp_4 mnt/tmp_5 mnt/tmp_6 mnt/tmp_7 \
mnt/tmp_8 mnt/tmp_9 mnt/tmp_10 mnt/tmp_11 mnt/tmp_12 mnt/tmp_13 \
mnt/tmp_14 mnt/tmp_15 mnt/tmp_16
Results:
+----------+--------+---------+
| IO range | HPB on | HPB off |
+----------+--------+---------+
| 1 GB | 294.8 | 300.87 |
| 4 GB | 293.51 | 179.35 |
| 8 GB | 294.85 | 162.52 |
| 16 GB | 293.45 | 156.26 |
| 32 GB | 277.4 | 153.25 |
+----------+--------+---------+
Link: https://lore.kernel.org/r/20210712085830epcms2p8c1288b7f7a81b044158a18232617b572@epcms2p8
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Tested-by: Can Guo <cang@codeaurora.org>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12 16:58:30 +08:00
|
|
|
DEVICE_DESC_PARAM_HPB_VER = 0x40,
|
|
|
|
DEVICE_DESC_PARAM_HPB_CONTROL = 0x42,
|
2020-04-23 05:41:42 +08:00
|
|
|
DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP = 0x4F,
|
|
|
|
DEVICE_DESC_PARAM_WB_PRESRV_USRSPC_EN = 0x53,
|
|
|
|
DEVICE_DESC_PARAM_WB_TYPE = 0x54,
|
|
|
|
DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55,
|
2016-03-10 23:37:10 +08:00
|
|
|
};
|
|
|
|
|
2018-02-15 20:14:03 +08:00
|
|
|
/* Interconnect descriptor parameters offsets in bytes*/
|
|
|
|
enum interconnect_desc_param {
|
|
|
|
INTERCONNECT_DESC_PARAM_LEN = 0x0,
|
|
|
|
INTERCONNECT_DESC_PARAM_TYPE = 0x1,
|
|
|
|
INTERCONNECT_DESC_PARAM_UNIPRO_VER = 0x2,
|
|
|
|
INTERCONNECT_DESC_PARAM_MPHY_VER = 0x4,
|
|
|
|
};
|
|
|
|
|
2018-02-15 20:14:04 +08:00
|
|
|
/* Geometry descriptor parameters offsets in bytes*/
|
|
|
|
enum geometry_desc_param {
|
|
|
|
GEOMETRY_DESC_PARAM_LEN = 0x0,
|
|
|
|
GEOMETRY_DESC_PARAM_TYPE = 0x1,
|
|
|
|
GEOMETRY_DESC_PARAM_DEV_CAP = 0x4,
|
|
|
|
GEOMETRY_DESC_PARAM_MAX_NUM_LUN = 0xC,
|
|
|
|
GEOMETRY_DESC_PARAM_SEG_SIZE = 0xD,
|
|
|
|
GEOMETRY_DESC_PARAM_ALLOC_UNIT_SIZE = 0x11,
|
|
|
|
GEOMETRY_DESC_PARAM_MIN_BLK_SIZE = 0x12,
|
|
|
|
GEOMETRY_DESC_PARAM_OPT_RD_BLK_SIZE = 0x13,
|
|
|
|
GEOMETRY_DESC_PARAM_OPT_WR_BLK_SIZE = 0x14,
|
|
|
|
GEOMETRY_DESC_PARAM_MAX_IN_BUF_SIZE = 0x15,
|
|
|
|
GEOMETRY_DESC_PARAM_MAX_OUT_BUF_SIZE = 0x16,
|
|
|
|
GEOMETRY_DESC_PARAM_RPMB_RW_SIZE = 0x17,
|
|
|
|
GEOMETRY_DESC_PARAM_DYN_CAP_RSRC_PLC = 0x18,
|
|
|
|
GEOMETRY_DESC_PARAM_DATA_ORDER = 0x19,
|
|
|
|
GEOMETRY_DESC_PARAM_MAX_NUM_CTX = 0x1A,
|
|
|
|
GEOMETRY_DESC_PARAM_TAG_UNIT_SIZE = 0x1B,
|
|
|
|
GEOMETRY_DESC_PARAM_TAG_RSRC_SIZE = 0x1C,
|
|
|
|
GEOMETRY_DESC_PARAM_SEC_RM_TYPES = 0x1D,
|
|
|
|
GEOMETRY_DESC_PARAM_MEM_TYPES = 0x1E,
|
|
|
|
GEOMETRY_DESC_PARAM_SCM_MAX_NUM_UNITS = 0x20,
|
|
|
|
GEOMETRY_DESC_PARAM_SCM_CAP_ADJ_FCTR = 0x24,
|
|
|
|
GEOMETRY_DESC_PARAM_NPM_MAX_NUM_UNITS = 0x26,
|
|
|
|
GEOMETRY_DESC_PARAM_NPM_CAP_ADJ_FCTR = 0x2A,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM1_MAX_NUM_UNITS = 0x2C,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM1_CAP_ADJ_FCTR = 0x30,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM2_MAX_NUM_UNITS = 0x32,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM2_CAP_ADJ_FCTR = 0x36,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM3_MAX_NUM_UNITS = 0x38,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM3_CAP_ADJ_FCTR = 0x3C,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM4_MAX_NUM_UNITS = 0x3E,
|
|
|
|
GEOMETRY_DESC_PARAM_ENM4_CAP_ADJ_FCTR = 0x42,
|
|
|
|
GEOMETRY_DESC_PARAM_OPT_LOG_BLK_SIZE = 0x44,
|
scsi: ufs: ufshpb: Introduce Host Performance Buffer feature
Implement Host Performance Buffer (HPB) initialization and add function
calls to UFS core driver.
NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of I/O requests to the corresponding physical
addresses of the flash storage. In UFS, logical-to-physical-address (L2P)
map data, which is required to identify the physical address for the
requested I/Os, 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 regular 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, HPB parameters are
configured in the device.
Total start-up time of popular applications was measured and the difference
observed between HPB being enabled and disabled. Popular applications are
12 game apps and 24 non-game apps. Each test cycle consists of running 36
applications in sequence. We repeated the cycle for observing performance
improvement by L2P mapping cache hit in HPB.
The following is the test environment:
- kernel version: 4.4.0
- RAM: 8GB
- UFS 2.1 (64GB)
Results:
+-------+----------+----------+-------+
| cycle | baseline | with HPB | diff |
+-------+----------+----------+-------+
| 1 | 272.4 | 264.9 | -7.5 |
| 2 | 250.4 | 248.2 | -2.2 |
| 3 | 226.2 | 215.6 | -10.6 |
| 4 | 230.6 | 214.8 | -15.8 |
| 5 | 232.0 | 218.1 | -13.9 |
| 6 | 231.9 | 212.6 | -19.3 |
+-------+----------+----------+-------+
We also measured HPB performance using iozone:
$ iozone -r 4k -+n -i2 -ecI -t 16 -l 16 -u 16 -s $IO_RANGE/16 -F \
mnt/tmp_1 mnt/tmp_2 mnt/tmp_3 mnt/tmp_4 mnt/tmp_5 mnt/tmp_6 mnt/tmp_7 \
mnt/tmp_8 mnt/tmp_9 mnt/tmp_10 mnt/tmp_11 mnt/tmp_12 mnt/tmp_13 \
mnt/tmp_14 mnt/tmp_15 mnt/tmp_16
Results:
+----------+--------+---------+
| IO range | HPB on | HPB off |
+----------+--------+---------+
| 1 GB | 294.8 | 300.87 |
| 4 GB | 293.51 | 179.35 |
| 8 GB | 294.85 | 162.52 |
| 16 GB | 293.45 | 156.26 |
| 32 GB | 277.4 | 153.25 |
+----------+--------+---------+
Link: https://lore.kernel.org/r/20210712085830epcms2p8c1288b7f7a81b044158a18232617b572@epcms2p8
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Tested-by: Can Guo <cang@codeaurora.org>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12 16:58:30 +08:00
|
|
|
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,
|
2020-04-23 05:41:43 +08:00
|
|
|
GEOMETRY_DESC_PARAM_WB_MAX_ALLOC_UNITS = 0x4F,
|
|
|
|
GEOMETRY_DESC_PARAM_WB_MAX_WB_LUNS = 0x53,
|
|
|
|
GEOMETRY_DESC_PARAM_WB_BUFF_CAP_ADJ = 0x54,
|
|
|
|
GEOMETRY_DESC_PARAM_WB_SUP_RED_TYPE = 0x55,
|
|
|
|
GEOMETRY_DESC_PARAM_WB_SUP_WB_TYPE = 0x56,
|
2018-02-15 20:14:04 +08:00
|
|
|
};
|
|
|
|
|
2018-02-15 20:14:05 +08:00
|
|
|
/* Health descriptor parameters offsets in bytes*/
|
|
|
|
enum health_desc_param {
|
|
|
|
HEALTH_DESC_PARAM_LEN = 0x0,
|
|
|
|
HEALTH_DESC_PARAM_TYPE = 0x1,
|
|
|
|
HEALTH_DESC_PARAM_EOL_INFO = 0x2,
|
|
|
|
HEALTH_DESC_PARAM_LIFE_TIME_EST_A = 0x3,
|
|
|
|
HEALTH_DESC_PARAM_LIFE_TIME_EST_B = 0x4,
|
|
|
|
};
|
|
|
|
|
2020-05-08 16:01:13 +08:00
|
|
|
/* WriteBooster buffer mode */
|
|
|
|
enum {
|
|
|
|
WB_BUF_MODE_LU_DEDICATED = 0x0,
|
|
|
|
WB_BUF_MODE_SHARED = 0x1,
|
|
|
|
};
|
|
|
|
|
2014-09-25 20:32:30 +08:00
|
|
|
/*
|
|
|
|
* Logical Unit Write Protect
|
|
|
|
* 00h: LU not write protected
|
|
|
|
* 01h: LU write protected when fPowerOnWPEn =1
|
|
|
|
* 02h: LU permanently write protected when fPermanentWPEn =1
|
|
|
|
*/
|
|
|
|
enum ufs_lu_wp_type {
|
|
|
|
UFS_LU_NO_WP = 0x00,
|
|
|
|
UFS_LU_POWER_ON_WP = 0x01,
|
|
|
|
UFS_LU_PERM_WP = 0x02,
|
|
|
|
};
|
|
|
|
|
2014-09-25 20:32:27 +08:00
|
|
|
/* bActiveICCLevel parameter current units */
|
|
|
|
enum {
|
|
|
|
UFSHCD_NANO_AMP = 0,
|
|
|
|
UFSHCD_MICRO_AMP = 1,
|
|
|
|
UFSHCD_MILI_AMP = 2,
|
|
|
|
UFSHCD_AMP = 3,
|
|
|
|
};
|
|
|
|
|
2020-04-23 05:41:42 +08:00
|
|
|
/* Possible values for dExtendedUFSFeaturesSupport */
|
|
|
|
enum {
|
2021-09-15 14:04:06 +08:00
|
|
|
UFS_DEV_LOW_TEMP_NOTIF = BIT(4),
|
|
|
|
UFS_DEV_HIGH_TEMP_NOTIF = BIT(5),
|
|
|
|
UFS_DEV_EXT_TEMP_NOTIF = BIT(6),
|
scsi: ufs: ufshpb: Introduce Host Performance Buffer feature
Implement Host Performance Buffer (HPB) initialization and add function
calls to UFS core driver.
NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of I/O requests to the corresponding physical
addresses of the flash storage. In UFS, logical-to-physical-address (L2P)
map data, which is required to identify the physical address for the
requested I/Os, 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 regular 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, HPB parameters are
configured in the device.
Total start-up time of popular applications was measured and the difference
observed between HPB being enabled and disabled. Popular applications are
12 game apps and 24 non-game apps. Each test cycle consists of running 36
applications in sequence. We repeated the cycle for observing performance
improvement by L2P mapping cache hit in HPB.
The following is the test environment:
- kernel version: 4.4.0
- RAM: 8GB
- UFS 2.1 (64GB)
Results:
+-------+----------+----------+-------+
| cycle | baseline | with HPB | diff |
+-------+----------+----------+-------+
| 1 | 272.4 | 264.9 | -7.5 |
| 2 | 250.4 | 248.2 | -2.2 |
| 3 | 226.2 | 215.6 | -10.6 |
| 4 | 230.6 | 214.8 | -15.8 |
| 5 | 232.0 | 218.1 | -13.9 |
| 6 | 231.9 | 212.6 | -19.3 |
+-------+----------+----------+-------+
We also measured HPB performance using iozone:
$ iozone -r 4k -+n -i2 -ecI -t 16 -l 16 -u 16 -s $IO_RANGE/16 -F \
mnt/tmp_1 mnt/tmp_2 mnt/tmp_3 mnt/tmp_4 mnt/tmp_5 mnt/tmp_6 mnt/tmp_7 \
mnt/tmp_8 mnt/tmp_9 mnt/tmp_10 mnt/tmp_11 mnt/tmp_12 mnt/tmp_13 \
mnt/tmp_14 mnt/tmp_15 mnt/tmp_16
Results:
+----------+--------+---------+
| IO range | HPB on | HPB off |
+----------+--------+---------+
| 1 GB | 294.8 | 300.87 |
| 4 GB | 293.51 | 179.35 |
| 8 GB | 294.85 | 162.52 |
| 16 GB | 293.45 | 156.26 |
| 32 GB | 277.4 | 153.25 |
+----------+--------+---------+
Link: https://lore.kernel.org/r/20210712085830epcms2p8c1288b7f7a81b044158a18232617b572@epcms2p8
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Tested-by: Can Guo <cang@codeaurora.org>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12 16:58:30 +08:00
|
|
|
UFS_DEV_HPB_SUPPORT = BIT(7),
|
2020-04-23 05:41:42 +08:00
|
|
|
UFS_DEV_WRITE_BOOSTER_SUP = BIT(8),
|
|
|
|
};
|
scsi: ufs: ufshpb: Introduce Host Performance Buffer feature
Implement Host Performance Buffer (HPB) initialization and add function
calls to UFS core driver.
NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of I/O requests to the corresponding physical
addresses of the flash storage. In UFS, logical-to-physical-address (L2P)
map data, which is required to identify the physical address for the
requested I/Os, 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 regular 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, HPB parameters are
configured in the device.
Total start-up time of popular applications was measured and the difference
observed between HPB being enabled and disabled. Popular applications are
12 game apps and 24 non-game apps. Each test cycle consists of running 36
applications in sequence. We repeated the cycle for observing performance
improvement by L2P mapping cache hit in HPB.
The following is the test environment:
- kernel version: 4.4.0
- RAM: 8GB
- UFS 2.1 (64GB)
Results:
+-------+----------+----------+-------+
| cycle | baseline | with HPB | diff |
+-------+----------+----------+-------+
| 1 | 272.4 | 264.9 | -7.5 |
| 2 | 250.4 | 248.2 | -2.2 |
| 3 | 226.2 | 215.6 | -10.6 |
| 4 | 230.6 | 214.8 | -15.8 |
| 5 | 232.0 | 218.1 | -13.9 |
| 6 | 231.9 | 212.6 | -19.3 |
+-------+----------+----------+-------+
We also measured HPB performance using iozone:
$ iozone -r 4k -+n -i2 -ecI -t 16 -l 16 -u 16 -s $IO_RANGE/16 -F \
mnt/tmp_1 mnt/tmp_2 mnt/tmp_3 mnt/tmp_4 mnt/tmp_5 mnt/tmp_6 mnt/tmp_7 \
mnt/tmp_8 mnt/tmp_9 mnt/tmp_10 mnt/tmp_11 mnt/tmp_12 mnt/tmp_13 \
mnt/tmp_14 mnt/tmp_15 mnt/tmp_16
Results:
+----------+--------+---------+
| IO range | HPB on | HPB off |
+----------+--------+---------+
| 1 GB | 294.8 | 300.87 |
| 4 GB | 293.51 | 179.35 |
| 8 GB | 294.85 | 162.52 |
| 16 GB | 293.45 | 156.26 |
| 32 GB | 277.4 | 153.25 |
+----------+--------+---------+
Link: https://lore.kernel.org/r/20210712085830epcms2p8c1288b7f7a81b044158a18232617b572@epcms2p8
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Tested-by: Can Guo <cang@codeaurora.org>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12 16:58:30 +08:00
|
|
|
#define UFS_DEV_HPB_SUPPORT_VERSION 0x310
|
2020-04-23 05:41:42 +08:00
|
|
|
|
2014-09-25 20:32:27 +08:00
|
|
|
#define POWER_DESC_MAX_ACTV_ICC_LVLS 16
|
|
|
|
|
|
|
|
/* Attribute bActiveICCLevel parameter bit masks definitions */
|
|
|
|
#define ATTR_ICC_LVL_UNIT_OFFSET 14
|
|
|
|
#define ATTR_ICC_LVL_UNIT_MASK (0x3 << ATTR_ICC_LVL_UNIT_OFFSET)
|
|
|
|
#define ATTR_ICC_LVL_VALUE_MASK 0x3FF
|
|
|
|
|
|
|
|
/* Power descriptor parameters offsets in bytes */
|
|
|
|
enum power_desc_param_offset {
|
|
|
|
PWR_DESC_LEN = 0x0,
|
|
|
|
PWR_DESC_TYPE = 0x1,
|
|
|
|
PWR_DESC_ACTIVE_LVLS_VCC_0 = 0x2,
|
|
|
|
PWR_DESC_ACTIVE_LVLS_VCCQ_0 = 0x22,
|
|
|
|
PWR_DESC_ACTIVE_LVLS_VCCQ2_0 = 0x42,
|
|
|
|
};
|
|
|
|
|
2013-07-30 03:05:59 +08:00
|
|
|
/* Exception event mask values */
|
|
|
|
enum {
|
2021-02-09 14:24:35 +08:00
|
|
|
MASK_EE_STATUS = 0xFFFF,
|
|
|
|
MASK_EE_DYNCAP_EVENT = BIT(0),
|
|
|
|
MASK_EE_SYSPOOL_EVENT = BIT(1),
|
|
|
|
MASK_EE_URGENT_BKOPS = BIT(2),
|
|
|
|
MASK_EE_TOO_HIGH_TEMP = BIT(3),
|
|
|
|
MASK_EE_TOO_LOW_TEMP = BIT(4),
|
|
|
|
MASK_EE_WRITEBOOSTER_EVENT = BIT(5),
|
|
|
|
MASK_EE_PERFORMANCE_THROTTLING = BIT(6),
|
2013-07-30 03:05:59 +08:00
|
|
|
};
|
2021-09-15 14:04:06 +08:00
|
|
|
#define MASK_EE_URGENT_TEMP (MASK_EE_TOO_HIGH_TEMP | MASK_EE_TOO_LOW_TEMP)
|
2013-07-30 03:05:59 +08:00
|
|
|
|
|
|
|
/* Background operation status */
|
2014-09-25 20:32:30 +08:00
|
|
|
enum bkops_status {
|
2013-07-30 03:05:59 +08:00
|
|
|
BKOPS_STATUS_NO_OP = 0x0,
|
|
|
|
BKOPS_STATUS_NON_CRITICAL = 0x1,
|
|
|
|
BKOPS_STATUS_PERF_IMPACT = 0x2,
|
|
|
|
BKOPS_STATUS_CRITICAL = 0x3,
|
2014-09-25 20:32:30 +08:00
|
|
|
BKOPS_STATUS_MAX = BKOPS_STATUS_CRITICAL,
|
2013-07-30 03:05:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* UTP QUERY Transaction Specific Fields OpCode */
|
|
|
|
enum query_opcode {
|
2012-02-29 14:41:50 +08:00
|
|
|
UPIU_QUERY_OPCODE_NOP = 0x0,
|
|
|
|
UPIU_QUERY_OPCODE_READ_DESC = 0x1,
|
|
|
|
UPIU_QUERY_OPCODE_WRITE_DESC = 0x2,
|
|
|
|
UPIU_QUERY_OPCODE_READ_ATTR = 0x3,
|
|
|
|
UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4,
|
|
|
|
UPIU_QUERY_OPCODE_READ_FLAG = 0x5,
|
|
|
|
UPIU_QUERY_OPCODE_SET_FLAG = 0x6,
|
|
|
|
UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7,
|
|
|
|
UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8,
|
|
|
|
};
|
|
|
|
|
2018-10-16 16:59:41 +08:00
|
|
|
/* bRefClkFreq attribute values */
|
|
|
|
enum ufs_ref_clk_freq {
|
|
|
|
REF_CLK_FREQ_19_2_MHZ = 0,
|
|
|
|
REF_CLK_FREQ_26_MHZ = 1,
|
|
|
|
REF_CLK_FREQ_38_4_MHZ = 2,
|
|
|
|
REF_CLK_FREQ_52_MHZ = 3,
|
|
|
|
REF_CLK_FREQ_INVAL = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ufs_ref_clk {
|
|
|
|
unsigned long freq_hz;
|
|
|
|
enum ufs_ref_clk_freq val;
|
|
|
|
};
|
|
|
|
|
2013-07-30 03:05:58 +08:00
|
|
|
/* Query response result code */
|
|
|
|
enum {
|
|
|
|
QUERY_RESULT_SUCCESS = 0x00,
|
|
|
|
QUERY_RESULT_NOT_READABLE = 0xF6,
|
|
|
|
QUERY_RESULT_NOT_WRITEABLE = 0xF7,
|
|
|
|
QUERY_RESULT_ALREADY_WRITTEN = 0xF8,
|
|
|
|
QUERY_RESULT_INVALID_LENGTH = 0xF9,
|
|
|
|
QUERY_RESULT_INVALID_VALUE = 0xFA,
|
|
|
|
QUERY_RESULT_INVALID_SELECTOR = 0xFB,
|
|
|
|
QUERY_RESULT_INVALID_INDEX = 0xFC,
|
|
|
|
QUERY_RESULT_INVALID_IDN = 0xFD,
|
|
|
|
QUERY_RESULT_INVALID_OPCODE = 0xFE,
|
|
|
|
QUERY_RESULT_GENERAL_FAILURE = 0xFF,
|
|
|
|
};
|
|
|
|
|
2012-02-29 14:41:50 +08:00
|
|
|
/* UTP Transfer Request Command Type (CT) */
|
|
|
|
enum {
|
|
|
|
UPIU_COMMAND_SET_TYPE_SCSI = 0x0,
|
|
|
|
UPIU_COMMAND_SET_TYPE_UFS = 0x1,
|
|
|
|
UPIU_COMMAND_SET_TYPE_QUERY = 0x2,
|
|
|
|
};
|
|
|
|
|
2013-07-30 03:05:57 +08:00
|
|
|
/* UTP Transfer Request Command Offset */
|
|
|
|
#define UPIU_COMMAND_TYPE_OFFSET 28
|
|
|
|
|
|
|
|
/* Offset of the response code in the UPIU header */
|
|
|
|
#define UPIU_RSP_CODE_OFFSET 8
|
|
|
|
|
2012-02-29 14:41:50 +08:00
|
|
|
enum {
|
2013-07-30 03:05:58 +08:00
|
|
|
MASK_SCSI_STATUS = 0xFF,
|
|
|
|
MASK_TASK_RESPONSE = 0xFF00,
|
|
|
|
MASK_RSP_UPIU_RESULT = 0xFFFF,
|
|
|
|
MASK_QUERY_DATA_SEG_LEN = 0xFFFF,
|
2013-09-01 00:10:19 +08:00
|
|
|
MASK_RSP_UPIU_DATA_SEG_LEN = 0xFFFF,
|
2013-07-30 03:05:59 +08:00
|
|
|
MASK_RSP_EXCEPTION_EVENT = 0x10000,
|
2016-09-09 07:22:22 +08:00
|
|
|
MASK_TM_SERVICE_RESP = 0xFF,
|
2018-10-07 22:30:37 +08:00
|
|
|
MASK_TM_FUNC = 0xFF,
|
2012-02-29 14:41:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Task management service response */
|
|
|
|
enum {
|
|
|
|
UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00,
|
|
|
|
UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04,
|
|
|
|
UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08,
|
|
|
|
UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05,
|
|
|
|
UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09,
|
|
|
|
};
|
2014-09-25 20:32:30 +08:00
|
|
|
|
|
|
|
/* UFS device power modes */
|
|
|
|
enum ufs_dev_pwr_mode {
|
|
|
|
UFS_ACTIVE_PWR_MODE = 1,
|
|
|
|
UFS_SLEEP_PWR_MODE = 2,
|
|
|
|
UFS_POWERDOWN_PWR_MODE = 3,
|
2020-11-03 22:14:02 +08:00
|
|
|
UFS_DEEPSLEEP_PWR_MODE = 4,
|
2014-09-25 20:32:30 +08:00
|
|
|
};
|
|
|
|
|
2020-05-09 17:37:15 +08:00
|
|
|
#define UFS_WB_BUF_REMAIN_PERCENT(val) ((val) / 10)
|
2020-04-23 05:41:42 +08:00
|
|
|
|
2013-07-30 03:05:57 +08:00
|
|
|
/**
|
|
|
|
* struct utp_cmd_rsp - Response UPIU structure
|
2012-02-29 14:41:50 +08:00
|
|
|
* @residual_transfer_count: Residual transfer count DW-3
|
|
|
|
* @reserved: Reserved double words DW-4 to DW-7
|
|
|
|
* @sense_data_len: Sense data length DW-8 U16
|
|
|
|
* @sense_data: Sense data field DW-8 to DW-12
|
|
|
|
*/
|
2013-07-30 03:05:57 +08:00
|
|
|
struct utp_cmd_rsp {
|
2014-05-26 13:29:10 +08:00
|
|
|
__be32 residual_transfer_count;
|
|
|
|
__be32 reserved[4];
|
|
|
|
__be16 sense_data_len;
|
2018-11-23 02:04:56 +08:00
|
|
|
u8 sense_data[UFS_SENSE_SIZE];
|
2012-02-29 14:41:50 +08:00
|
|
|
};
|
|
|
|
|
2021-07-12 16:58:59 +08:00
|
|
|
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
|
|
|
|
* @lun: LUN of response UPIU
|
|
|
|
* @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 lun;
|
|
|
|
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
|
|
|
|
|
2013-07-30 03:05:57 +08:00
|
|
|
/**
|
|
|
|
* struct utp_upiu_rsp - general upiu response structure
|
|
|
|
* @header: UPIU header structure DW-0 to DW-2
|
|
|
|
* @sr: fields structure for scsi command DW-3 to DW-12
|
2013-07-30 03:05:58 +08:00
|
|
|
* @qr: fields structure for query request DW-3 to DW-7
|
2013-07-30 03:05:57 +08:00
|
|
|
*/
|
|
|
|
struct utp_upiu_rsp {
|
|
|
|
struct utp_upiu_header header;
|
2013-07-30 03:05:58 +08:00
|
|
|
union {
|
|
|
|
struct utp_cmd_rsp sr;
|
2021-07-12 16:58:59 +08:00
|
|
|
struct utp_hpb_rsp hr;
|
2013-07-30 03:05:58 +08:00
|
|
|
struct utp_upiu_query qr;
|
|
|
|
};
|
2013-07-30 03:05:57 +08:00
|
|
|
};
|
|
|
|
|
2013-07-30 03:05:58 +08:00
|
|
|
/**
|
|
|
|
* struct ufs_query_req - parameters for building a query request
|
|
|
|
* @query_func: UPIU header query function
|
|
|
|
* @upiu_req: the query request data
|
|
|
|
*/
|
|
|
|
struct ufs_query_req {
|
|
|
|
u8 query_func;
|
|
|
|
struct utp_upiu_query upiu_req;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct ufs_query_resp - UPIU QUERY
|
|
|
|
* @response: device response code
|
|
|
|
* @upiu_res: query response data
|
|
|
|
*/
|
|
|
|
struct ufs_query_res {
|
|
|
|
u8 response;
|
|
|
|
struct utp_upiu_query upiu_res;
|
|
|
|
};
|
|
|
|
|
2014-09-25 20:32:22 +08:00
|
|
|
#define UFS_VREG_VCC_MIN_UV 2700000 /* uV */
|
|
|
|
#define UFS_VREG_VCC_MAX_UV 3600000 /* uV */
|
|
|
|
#define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */
|
|
|
|
#define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */
|
2019-11-26 14:53:31 +08:00
|
|
|
#define UFS_VREG_VCCQ_MIN_UV 1140000 /* uV */
|
|
|
|
#define UFS_VREG_VCCQ_MAX_UV 1260000 /* uV */
|
|
|
|
#define UFS_VREG_VCCQ2_MIN_UV 1700000 /* uV */
|
2014-09-25 20:32:22 +08:00
|
|
|
#define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */
|
|
|
|
|
2014-09-25 20:32:30 +08:00
|
|
|
/*
|
|
|
|
* VCCQ & VCCQ2 current requirement when UFS device is in sleep state
|
|
|
|
* and link is in Hibern8 state.
|
|
|
|
*/
|
|
|
|
#define UFS_VREG_LPM_LOAD_UA 1000 /* uA */
|
|
|
|
|
2014-09-25 20:32:22 +08:00
|
|
|
struct ufs_vreg {
|
|
|
|
struct regulator *reg;
|
|
|
|
const char *name;
|
2020-12-07 13:49:54 +08:00
|
|
|
bool always_on;
|
2014-09-25 20:32:22 +08:00
|
|
|
bool enabled;
|
|
|
|
int min_uV;
|
|
|
|
int max_uV;
|
|
|
|
int max_uA;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ufs_vreg_info {
|
|
|
|
struct ufs_vreg *vcc;
|
|
|
|
struct ufs_vreg *vccq;
|
|
|
|
struct ufs_vreg *vccq2;
|
2014-09-25 20:32:24 +08:00
|
|
|
struct ufs_vreg *vdd_hba;
|
2014-09-25 20:32:22 +08:00
|
|
|
};
|
|
|
|
|
2014-09-25 20:32:30 +08:00
|
|
|
struct ufs_dev_info {
|
2021-01-20 00:38:46 +08:00
|
|
|
bool f_power_on_wp_en;
|
2014-09-25 20:32:30 +08:00
|
|
|
/* Keeps information if any of the LU is power on write protected */
|
2021-01-20 00:38:46 +08:00
|
|
|
bool is_lu_power_on_wp;
|
2020-01-20 21:08:19 +08:00
|
|
|
/* Maximum number of general LU supported by the UFS device */
|
2021-01-20 00:38:46 +08:00
|
|
|
u8 max_lu_supported;
|
|
|
|
u16 wmanufacturerid;
|
2020-01-20 21:08:14 +08:00
|
|
|
/*UFS device Product Name */
|
2021-01-20 00:38:46 +08:00
|
|
|
u8 *model;
|
|
|
|
u16 wspecversion;
|
|
|
|
u32 clk_gating_wait_us;
|
|
|
|
|
scsi: ufs: ufshpb: Introduce Host Performance Buffer feature
Implement Host Performance Buffer (HPB) initialization and add function
calls to UFS core driver.
NAND flash-based storage devices, including UFS, have mechanisms to
translate logical addresses of I/O requests to the corresponding physical
addresses of the flash storage. In UFS, logical-to-physical-address (L2P)
map data, which is required to identify the physical address for the
requested I/Os, 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 regular 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, HPB parameters are
configured in the device.
Total start-up time of popular applications was measured and the difference
observed between HPB being enabled and disabled. Popular applications are
12 game apps and 24 non-game apps. Each test cycle consists of running 36
applications in sequence. We repeated the cycle for observing performance
improvement by L2P mapping cache hit in HPB.
The following is the test environment:
- kernel version: 4.4.0
- RAM: 8GB
- UFS 2.1 (64GB)
Results:
+-------+----------+----------+-------+
| cycle | baseline | with HPB | diff |
+-------+----------+----------+-------+
| 1 | 272.4 | 264.9 | -7.5 |
| 2 | 250.4 | 248.2 | -2.2 |
| 3 | 226.2 | 215.6 | -10.6 |
| 4 | 230.6 | 214.8 | -15.8 |
| 5 | 232.0 | 218.1 | -13.9 |
| 6 | 231.9 | 212.6 | -19.3 |
+-------+----------+----------+-------+
We also measured HPB performance using iozone:
$ iozone -r 4k -+n -i2 -ecI -t 16 -l 16 -u 16 -s $IO_RANGE/16 -F \
mnt/tmp_1 mnt/tmp_2 mnt/tmp_3 mnt/tmp_4 mnt/tmp_5 mnt/tmp_6 mnt/tmp_7 \
mnt/tmp_8 mnt/tmp_9 mnt/tmp_10 mnt/tmp_11 mnt/tmp_12 mnt/tmp_13 \
mnt/tmp_14 mnt/tmp_15 mnt/tmp_16
Results:
+----------+--------+---------+
| IO range | HPB on | HPB off |
+----------+--------+---------+
| 1 GB | 294.8 | 300.87 |
| 4 GB | 293.51 | 179.35 |
| 8 GB | 294.85 | 162.52 |
| 16 GB | 293.45 | 156.26 |
| 32 GB | 277.4 | 153.25 |
+----------+--------+---------+
Link: https://lore.kernel.org/r/20210712085830epcms2p8c1288b7f7a81b044158a18232617b572@epcms2p8
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Tested-by: Can Guo <cang@codeaurora.org>
Tested-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12 16:58:30 +08:00
|
|
|
/* UFS HPB related flag */
|
|
|
|
bool hpb_enabled;
|
|
|
|
|
2021-01-20 00:38:46 +08:00
|
|
|
/* UFS WB related flags */
|
|
|
|
bool wb_enabled;
|
|
|
|
bool wb_buf_flush_enabled;
|
|
|
|
u8 wb_dedicated_lu;
|
|
|
|
u8 wb_buffer_type;
|
|
|
|
|
|
|
|
bool b_rpm_dev_flush_capable;
|
|
|
|
u8 b_presrv_uspc_en;
|
2017-01-05 16:45:12 +08:00
|
|
|
};
|
|
|
|
|
scsi: ufs: Use __print_symbolic() for UFS trace string print
__print_symbolic() is designed for exporting the print formatting table to
userspace and allows parsing tool, such as trace-cmd and perf, to analyze
trace log according to this print formatting table, meanwhile, by using
__print_symbolic()s, save space in the trace ring buffer.
original print format:
print fmt: "%s: %s: HDR:%s, CDB:%s", __get_str(str), __get_str(dev_name),
__print_hex(REC->hdr, sizeof(REC->hdr)),
__print_hex(REC->tsf, sizeof(REC->tsf))
after this change:
print fmt: "%s: %s: HDR:%s, CDB:%s",
print_symbolic(REC->str_t, {0, "send"},
{1, "complete"},
{2, "dev_complete"},
{3, "query_send"},
{4, "query_complete"},
{5, "query_complete_err"},
{6, "tm_send"},
{7, "tm_complete"},
{8, "tm_complete_err"}),
__get_str(dev_name), __print_hex(REC->hdr, sizeof(REC->hdr)),
__print_hex(REC->tsf, sizeof(REC->tsf))
Note: This patch just converts current __get_str(str) to __print_symbolic(),
the original tracing log will not be affected by this change, so it
doesn't break what current parsers expect.
Link: https://lore.kernel.org/r/20210105113446.16027-3-huobean@gmail.com
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-05 19:34:42 +08:00
|
|
|
/*
|
|
|
|
* This enum is used in string mapping in include/trace/events/ufs.h.
|
|
|
|
*/
|
|
|
|
enum ufs_trace_str_t {
|
|
|
|
UFS_CMD_SEND, UFS_CMD_COMP, UFS_DEV_COMP,
|
|
|
|
UFS_QUERY_SEND, UFS_QUERY_COMP, UFS_QUERY_ERR,
|
|
|
|
UFS_TM_SEND, UFS_TM_COMP, UFS_TM_ERR
|
|
|
|
};
|
|
|
|
|
2021-01-05 19:34:46 +08:00
|
|
|
/*
|
|
|
|
* Transaction Specific Fields (TSF) type in the UPIU package, this enum is
|
|
|
|
* used in include/trace/events/ufs.h for UFS command trace.
|
|
|
|
*/
|
|
|
|
enum ufs_trace_tsf_t {
|
|
|
|
UFS_TSF_CDB, UFS_TSF_OSF, UFS_TSF_TM_INPUT, UFS_TSF_TM_OUTPUT
|
|
|
|
};
|
scsi: ufs: Use __print_symbolic() for UFS trace string print
__print_symbolic() is designed for exporting the print formatting table to
userspace and allows parsing tool, such as trace-cmd and perf, to analyze
trace log according to this print formatting table, meanwhile, by using
__print_symbolic()s, save space in the trace ring buffer.
original print format:
print fmt: "%s: %s: HDR:%s, CDB:%s", __get_str(str), __get_str(dev_name),
__print_hex(REC->hdr, sizeof(REC->hdr)),
__print_hex(REC->tsf, sizeof(REC->tsf))
after this change:
print fmt: "%s: %s: HDR:%s, CDB:%s",
print_symbolic(REC->str_t, {0, "send"},
{1, "complete"},
{2, "dev_complete"},
{3, "query_send"},
{4, "query_complete"},
{5, "query_complete_err"},
{6, "tm_send"},
{7, "tm_complete"},
{8, "tm_complete_err"}),
__get_str(dev_name), __print_hex(REC->hdr, sizeof(REC->hdr)),
__print_hex(REC->tsf, sizeof(REC->tsf))
Note: This patch just converts current __get_str(str) to __print_symbolic(),
the original tracing log will not be affected by this change, so it
doesn't break what current parsers expect.
Link: https://lore.kernel.org/r/20210105113446.16027-3-huobean@gmail.com
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-01-05 19:34:42 +08:00
|
|
|
|
2018-02-15 20:14:09 +08:00
|
|
|
/**
|
|
|
|
* ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
|
2020-01-20 21:08:20 +08:00
|
|
|
* @dev_info: pointer of instance of struct ufs_dev_info
|
2018-02-15 20:14:09 +08:00
|
|
|
* @lun: LU number to check
|
|
|
|
* @return: true if the lun has a matching unit descriptor, false otherwise
|
|
|
|
*/
|
2020-01-20 21:08:20 +08:00
|
|
|
static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
|
2021-01-11 17:59:27 +08:00
|
|
|
u8 lun, u8 param_offset)
|
2018-02-15 20:14:09 +08:00
|
|
|
{
|
2020-01-20 21:08:20 +08:00
|
|
|
if (!dev_info || !dev_info->max_lu_supported) {
|
2020-01-22 17:12:50 +08:00
|
|
|
pr_err("Max General LU supported by UFS isn't initialized\n");
|
2020-01-20 21:08:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
2021-01-11 17:59:27 +08:00
|
|
|
/* WB is available only for the logical unit from 0 to 7 */
|
|
|
|
if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
|
|
|
|
return lun < UFS_UPIU_MAX_WB_LUN_ID;
|
2020-01-20 21:08:20 +08:00
|
|
|
return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported);
|
2018-02-15 20:14:09 +08:00
|
|
|
}
|
|
|
|
|
2012-02-29 14:41:50 +08:00
|
|
|
#endif /* End of Header */
|