WriteBooster Feature Support
Subsystems (2)
cover WriteBooster Feature Support
Still a RFC patch, because I'm still expecting some comments on the design.
v1 -> v2:
- Addressed comments on v1
- Supports shared buffer mode only
- Didn't use exception event as suggested.
The reason being while testing I saw that the WriteBooster available buffer remains at 0x1 for a longer time if flush is enabled all the time as compared to an event-based enablement. This essentially means that writes go to the WriteBooster buffer more. Spec says that the if flush is enabled, the device would flush when it sees the command queue empty. So I guess that'd trigger flush more than an event based approach.
Anyway the Vcc would be turned-off during system suspend, so flush would stop anyway.
In this patchset, I never turn-off flush.
Hence the RFC.
Asutosh Das (3):
scsi: ufs: add write booster feature support
ufs-qcom: scsi: configure write booster type
ufs: sysfs: add sysfs entries for write booster
drivers/scsi/ufs/ufs-qcom.c | 7 ++ drivers/scsi/ufs/ufs-sysfs.c | 39 ++++++- drivers/scsi/ufs/ufs.h | 37 ++++++- drivers/scsi/ufs/ufshcd.c | 238 ++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 9 ++ 5 files changed, 324 insertions(+), 6 deletions(-)
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND 1/3 scsi: ufs: add write booster feature support
The write performance of TLC NAND is considerably lower than SLC NAND. Using SLC NAND as a WriteBooster Buffer enables the write request to be processed with lower latency and improves the overall write performance.
Adds support for shared-buffer mode WriteBooster.
WriteBooster enable: SW enables it when clocks are scaled up, thus it's enabled only in high load conditions.
WriteBooster disable: SW will disable the feature, when clocks are scaled down. Thus writes would go as normal writes.
To keep the endurance of the WriteBooster Buffer at a maximum, this load based toggling is adopted.
--- drivers/scsi/ufs/ufs.h | 31 +++++- drivers/scsi/ufs/ufshcd.c | 238 +++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 9 ++ 3 files changed, 273 insertions(+), 5 deletions(-)
drivers/scsi/ufs/ufs.h +30 -1
@@ -140,6 +140,9 @@ enum flag_idn {QUERY_FLAG_IDN_BUSY_RTC =0x09 ,QUERY_FLAG_IDN_RESERVED3 =0x0A ,QUERY_FLAG_IDN_PERMANENTLY_DISABLE_FW_UPDATE =0x0B , +QUERY_FLAG_IDN_WB_EN =0x0E , +QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN =0x0F , + QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 = 0x10, };/* Attribute idn for Query requests */
@@ -168,6 +171,10 @@ enum attr_idn {QUERY_ATTR_IDN_PSA_STATE =0x15 ,QUERY_ATTR_IDN_PSA_DATA_SIZE =0x16 ,QUERY_ATTR_IDN_REF_CLK_GATING_WAIT_TIME =0x17 , +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, };/* Descriptor idn for Query requests */
@@ -191,7 +198,7 @@ enum desc_header_offset { };enum ufs_desc_def_size { -QUERY_DESC_DEVICE_DEF_SIZE =0x40 , +QUERY_DESC_DEVICE_DEF_SIZE =0x59 ,QUERY_DESC_CONFIGURATION_DEF_SIZE =0x90 ,QUERY_DESC_UNIT_DEF_SIZE =0x23 ,QUERY_DESC_INTERCONNECT_DEF_SIZE =0x06 ,
@@ -219,6 +226,7 @@ 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_WB_BUF_ALLOC_UNITS = 0x29, };/* Device descriptor parameters offsets in bytes*/
@@ -258,6 +266,9 @@ 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_EXT_UFS_FEATURE_SUP =0x4F , +DEVICE_DESC_PARAM_WB_TYPE =0x54 , + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, };/* Interconnect descriptor parameters offsets in bytes*/
@@ -333,6 +344,11 @@ enum { UFSHCD_AMP = 3, }; +/* Possible values for dExtendedUFSFeaturesSupport */ +enum { +UFS_DEV_WRITE_BOOSTER_SUP =BIT (8 ), +}; +#define POWER_DESC_MAX_SIZE 0x62#define POWER_DESC_MAX_ACTV_ICC_LVLS 16
@@ -447,6 +463,15 @@ enum ufs_dev_pwr_mode { UFS_POWERDOWN_PWR_MODE = 3, }; +enum ufs_dev_wb_buf_avail_size { +UFS_WB_10_PERCENT_BUF_REMAIN =0x1 , +UFS_WB_40_PERCENT_BUF_REMAIN =0x4 , +}; + +enum ufs_dev_wb_buf_user_cap_config { +UFS_WB_BUFF_PRESERVE_USER_SPACE =1 , +UFS_WB_BUFF_USER_SPACE_RED_EN =2 , +};/** * struct utp_cmd_rsp - Response UPIU structure * @residual_transfer_count: Residual transfer count DW-3
@@ -537,6 +562,10 @@ struct ufs_dev_info {u8 *model;u16 wspecversion;u32 clk_gating_wait_us; +u32 d_ext_ufs_feature_sup; +u8 b_wb_buffer_type; +u32 d_wb_alloc_units; +bool keep_vcc_on; };/**
drivers/scsi/ufs/ufshcd.c +234 -4
300 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +9 -0
@@ -327,6 +327,7 @@ struct ufs_hba_variant_ops {void (*dbg_register_dump)(struct ufs_hba *hba);int (*phy_initialization)(struct ufs_hba *);void (*device_reset)(struct ufs_hba *hba); +u32 (*wb_get_user_cap_mode)(struct ufs_hba *hba); };/* clock gating state */
@@ -711,6 +712,8 @@ struct ufs_hba {struct device bsg_dev;struct request_queue *bsg_queue; +bool wb_buf_flush_enabled; +bool wb_enabled; };/* Returns true if clocks can be gated. Otherwise false */
@@ -1103,4 +1106,10 @@ static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun)int ufshcd_dump_regs (struct ufs_hba *hba,size_t offset,size_t len,const char *prefix); +static inline unsigned int ufshcd_vops_get_user_cap_mode (struct ufs_hba *hba) +{ +if (hba->vops && hba->vops->wb_get_user_cap_mode) +return hba->vops->wb_get_user_cap_mode (hba); +return 0 ; +}#endif /* End of Header */
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND 2/3 ufs-qcom: scsi: configure write booster type
In reply to Asutosh DasConfigure the WriteBooster type to preserve user-space mode. This would ensure that no user-space capacity is reduced when write booster is enabled.
--- drivers/scsi/ufs/ufs-qcom.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/scsi/ufs/ufs-qcom.c +7 -0
@@ -1689,6 +1689,12 @@ static void ufs_qcom_device_reset(struct ufs_hba *hba)usleep_range (10 ,15 ); } +static u32 ufs_qcom_wb_get_user_cap_mode (struct ufs_hba *hba) +{ +/* QCom prefers no user-space reduction mode */ +return UFS_WB_BUFF_PRESERVE_USER_SPACE ; +} +/** * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations *
@@ -1710,6 +1716,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .resume = ufs_qcom_resume, .dbg_register_dump = ufs_qcom_dump_dbg_regs, .device_reset = ufs_qcom_device_reset, + .wb_get_user_cap_mode = ufs_qcom_wb_get_user_cap_mode, };/**
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH RESEND 3/3 ufs: sysfs: add sysfs entries for write booster
In reply to Asutosh DasAdds unit, device, geometry descriptor sysfs entries. Adds flags sysfs entries for write booster.
--- drivers/scsi/ufs/ufs-sysfs.c | 39 ++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufs.h | 6 ++++++ 2 files changed, 44 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufs-sysfs.c +38 -1
@@ -274,6 +274,10 @@ 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 (ext_feature_sup, _EXT_UFS_FEATURE_SUP,4 ); +UFS_DEVICE_DESC_PARAM (wb_presv_us_en, _WB_US_RED_EN,1 ); +UFS_DEVICE_DESC_PARAM (wb_type, _WB_TYPE,1 ); +UFS_DEVICE_DESC_PARAM (wb_shared_alloc_units, _WB_SHARED_ALLOC_UNITS,4 );static struct attribute *ufs_sysfs_device_descriptor[] = { &dev_attr_device_type.attr,
@@ -302,6 +306,10 @@ 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_ext_feature_sup.attr, + &dev_attr_wb_presv_us_en.attr, + &dev_attr_wb_type.attr, + &dev_attr_wb_shared_alloc_units.attr, NULL, };
@@ -371,6 +379,12 @@ 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 (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 ); +UFS_GEOMETRY_DESC_PARAM (wb_sup_red_type, _WB_SUP_RED_TYPE,1 ); +UFS_GEOMETRY_DESC_PARAM (wb_sup_wb_type, _WB_SUP_WB_TYPE,1 ); +static struct attribute *ufs_sysfs_geometry_descriptor[] = { &dev_attr_raw_device_capacity.attr,
@@ -402,6 +416,11 @@ 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_wb_max_alloc_units.attr, + &dev_attr_wb_max_wb_luns.attr, + &dev_attr_wb_buff_cap_adj.attr, + &dev_attr_wb_sup_red_type.attr, + &dev_attr_wb_sup_wb_type.attr, NULL, };
@@ -608,7 +627,7 @@ static ssize_t _name##_show(struct device *dev, \if (ufshcd_query_flag (hba,UPIU_QUERY_OPCODE_READ_FLAG , \ QUERY_FLAG_IDN##_uname, &flag)) \return -EINVAL ; \ -return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ +return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ } \static DEVICE_ATTR_RO (_name)
@@ -620,6 +639,9 @@ UFS_FLAG(life_span_mode_enable, _LIFE_SPAN_MODE_ENABLE);UFS_FLAG (phy_resource_removal, _FPHYRESOURCEREMOVAL);UFS_FLAG (busy_rtc, _BUSY_RTC);UFS_FLAG (disable_fw_update, _PERMANENTLY_DISABLE_FW_UPDATE); +UFS_FLAG (wb_enable, _WB_EN); +UFS_FLAG (wb_flush_en, _WB_BUFF_FLUSH_EN); +UFS_FLAG (wb_flush_during_h8, _WB_BUFF_FLUSH_DURING_HIBERN8);static struct attribute *ufs_sysfs_device_flags[] = { &dev_attr_device_init.attr,
@@ -630,6 +652,9 @@ static struct attribute *ufs_sysfs_device_flags[] = { &dev_attr_phy_resource_removal.attr, &dev_attr_busy_rtc.attr, &dev_attr_disable_fw_update.attr, + &dev_attr_wb_enable.attr, + &dev_attr_wb_flush_en.attr, + &dev_attr_wb_flush_during_h8.attr, NULL, };
@@ -667,6 +692,11 @@ UFS_ATTRIBUTE(exception_event_status, _EE_STATUS);UFS_ATTRIBUTE (ffu_status, _FFU_STATUS);UFS_ATTRIBUTE (psa_state, _PSA_STATE);UFS_ATTRIBUTE (psa_data_size, _PSA_DATA_SIZE); +UFS_ATTRIBUTE (wb_flush_status, _WB_FLUSH_STATUS); +UFS_ATTRIBUTE (wb_avail_buf, _AVAIL_WB_BUFF_SIZE); +UFS_ATTRIBUTE (wb_life_time_est, _WB_BUFF_LIFE_TIME_EST); +UFS_ATTRIBUTE (wb_cur_buf, _CURR_WB_BUFF_SIZE); +static struct attribute *ufs_sysfs_attributes[] = { &dev_attr_boot_lun_enabled.attr,
@@ -685,6 +715,10 @@ static struct attribute *ufs_sysfs_attributes[] = { &dev_attr_ffu_status.attr, &dev_attr_psa_state.attr, &dev_attr_psa_data_size.attr, + &dev_attr_wb_flush_status.attr, + &dev_attr_wb_avail_buf.attr, + &dev_attr_wb_life_time_est.attr, + &dev_attr_wb_cur_buf.attr, NULL, };
@@ -736,6 +770,8 @@ 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 (wb_buf_alloc_units, _WB_BUF_ALLOC_UNITS,4 ); +static struct attribute *ufs_sysfs_unit_descriptor[] = { &dev_attr_boot_lun_id.attr,
@@ -751,6 +787,7 @@ 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_wb_buf_alloc_units.attr, NULL, };
drivers/scsi/ufs/ufs.h +6 -0
@@ -267,6 +267,7 @@ enum device_desc_param {DEVICE_DESC_PARAM_PSA_TMT =0x29 ,DEVICE_DESC_PARAM_PRDCT_REV =0x2A ,DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP =0x4F , +DEVICE_DESC_PARAM_WB_US_RED_EN =0x53 ,DEVICE_DESC_PARAM_WB_TYPE =0x54 , DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, };
@@ -313,6 +314,11 @@ 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_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, };/* Health descriptor parameters offsets in bytes*/
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi,
The code looks good to me and I encourage you to submit your patches.
I just want to make some general remarks:
- The way you use the clock scaling to set WB on/off, is IMO, an elegant design choice.
- You should add a platform capability for WB
- As for setting user space configuration options - I think you've got it wrong. You should read it from bSupportedWriteBoosterBufferUserSpaceReductionTypes (offset 0x55 in the device descriptor).
This is a configurable parameter that the chipset vendor control and can set during provisioning.
- I agree with your approach toward flush during runtime suspend (keep-vcc-on):
it is the host's interest to assist the device with some extra idle time if needed for WB flush. This way you will assure consistent write performance.
Thanks,
Avri
Quoted 39 lines
Still a RFC patch, because I'm still expecting some comments on the design.
v1 -> v2:
- Addressed comments on v1- Supports shared buffer mode only
- Didn't use exception event as suggested.
The reason being while testing I saw that the WriteBooster available buffer remains at0x1for a longer time if flush is enabled all the time as compared to an event-based enablement. This essentially means that writes go to the WriteBooster buffer more. Spec says that the if flush is enabled, the device would flush when it sees the command queue empty. So I guess that'd trigger flush more than an event based approach.
Anyway the Vcc would be turned-off during system suspend, so flush would stop anyway.
In this patchset, I never turn-off flush.
Hence the RFC.Asutosh Das (3):
scsi: ufs: add write booster feature support
ufs-qcom: scsi: configure write booster type
ufs: sysfs: add sysfs entries for write boosterdrivers/scsi/ufs/ufs-qcom.c | 7 ++ drivers/scsi/ufs/ufs-sysfs.c | 39 ++++++- drivers/scsi/ufs/ufs.h | 37 ++++++- drivers/scsi/ufs/ufshcd.c | 238 ++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 9 ++ 5 files changed, 324 insertions(+), 6 deletions(-)--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.