WriteBooster Feature Support
Subsystems (2)
cover WriteBooster Feature Support
RFC -> v1:
- Added platform capability for WriteBooster
RFC-:
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 | 8 ++ drivers/scsi/ufs/ufs-sysfs.c | 39 ++++++- drivers/scsi/ufs/ufs.h | 37 ++++++- drivers/scsi/ufs/ufshcd.c | 241 ++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 43 ++++++++ 5 files changed, 362 insertions(+), 6 deletions(-)
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH 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 | 240 +++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 21 ++++ 3 files changed, 288 insertions(+), 4 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 +237 -3
302 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +21 -0
@@ -344,6 +344,7 @@ struct ufs_hba_variant_ops {void (*config_scaling_param)(struct ufs_hba *hba,struct devfreq_dev_profile *profile,void *data); +u32 (*wb_get_user_cap_mode)(struct ufs_hba *hba); };/* clock gating state */
@@ -555,6 +556,13 @@ enum ufshcd_caps {* for userspace to control the power management. */ UFSHCD_CAP_RPM_AUTOSUSPEND =1 <<6 , + +/* +* This capability allows the host controller driver to turn-on +* WriteBooster, if the underlying device supports it and is +* provisioned to be used. This would increase the write performance. +*/ + UFSHCD_CAP_WB_EN = (1 << 7), };/**
@@ -727,6 +735,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 */
@@ -775,6 +785,11 @@ static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)return FIELD_GET (UFSHCI_AHIBERN8_TIMER_MASK , hba->ahit) ? true : false; } +static inline bool ufshcd_is_wb_allowed (struct ufs_hba *hba) +{ +return hba->caps &UFSHCD_CAP_WB_EN ; +} +#define ufshcd_writel (hba, val, reg) \ writel((val), (hba)->mmio_base + (reg))#define ufshcd_readl (hba, reg) \
@@ -1130,4 +1145,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.
RE: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Hi,
drivers/scsi/ufs/ufs.h enum desc_header_offset { · line 203
Quoted 6 lines
enum
ufs_desc_def_size{drivers/scsi/ufs/ufs.h +1
-1-QUERY_DESC_DEVICE_DEF_SIZE =0x40 , +QUERY_DESC_DEVICE_DEF_SIZE =0x59 ,QUERY_DESC_CONFIGURATION_DEF_SIZE =0x90 , QUERY_DESC_UNIT_DEF_SIZE = 0x23,
Might as well update the unit descriptor size - its 0x2D now, As you are adding its new fields
Quoted 10 lines
QUERY_DESC_INTERCONNECT_DEF_SIZE = 0x06,drivers/scsi/ufs/ufs.h +1
-0@@ -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*/
drivers/scsi/ufs/ufs.h enum device_desc_param { · line 269
Quoted 4 lines
drivers/scsi/ufs/ufs.h +1
-0@@ -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_USER_TYPE = 0x53,
drivers/scsi/ufs/ufs.h enum ufs_dev_pwr_mode { · line 474
Quoted 10 lines
drivers/scsi/ufs/ufs.h +6
-0+DEVICE_DESC_PARAM_WB_TYPE =0x54 , + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, }; +enum ufs_dev_wb_buf_user_cap_config { +UFS_WB_BUFF_PRESERVE_USER_SPACE =1 , +UFS_WB_BUFF_USER_SPACE_RED_EN =2 , +};
Maybe better to follow the spec here:
Reduced - 0
Preserve - 1
drivers/scsi/ufs/ufshcd.c static inline void ufshcd_disable_irq(struct ufs_hba *hba) · line 291
Quoted 8 lines
drivers/scsi/ufs/ufshcd.c +8
-0+static inline void ufshcd_wb_config (struct ufs_hba *hba) +{ +int ret; + +if (!ufshcd_wb_sup (hba)) +return ; + + ret =ufshcd_wb_ctrl (hba, true);
Why are you setting WB on init?
drivers/scsi/ufs/ufshcd.c static inline void ufshcd_disable_irq(struct ufs_hba *hba) · line 300
Quoted 9 lines
drivers/scsi/ufs/ufshcd.c +9
-0+if (ret) +dev_err (hba->dev,"%s: Enable WB failed: %d\n" , __func__, ret); +else +dev_info (hba->dev,"%s: Write Booster Configured\n" , __func__); + ret =ufshcd_wb_toggle_flush_during_h8 (hba, true); +if (ret) +dev_err (hba->dev,"%s: En WB flush during H8: failed: %d\n" , + __func__, ret); +ufshcd_wb_toggle_flush (hba, true);
Why set explicit flush on init?
Quoted 27 lines
drivers/scsi/ufs/ufshcd.c +21
-0+ + +static bool ufshcd_wb_keep_vcc_on (struct ufs_hba *hba) +{ +int ret; +u32 cur_buf, avail_buf; + +if (!ufshcd_wb_sup (hba)) +return false; +/* +* The ufs device needs the vcc to be ON to flush. +* With user-space reduction enabled, it's enough to enable flush +* by checking only the available buffer. The threshold +* defined here is > 90% full. +* With user-space preserved enabled, the current-buffer +* should be checked too because the wb buffer size can reduce +* when disk tends to be full. This info is provided by current +* buffer (dCurrentWriteBoosterBufferSize). There's no point in +* keeping vcc on when current buffer is empty. +*/ + ret = ufshcd_query_attr_retry(hba,
UPIU_QUERY_OPCODE_READ_ATTR,drivers/scsi/ufs/ufshcd.c +4
-0+QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE , + 0, 0, &avail_buf); +if (ret) { + dev_warn(hba->dev, "%s dAvailableWriteBoosterBufferSize readfailed %d\n",
drivers/scsi/ufs/ufshcd.c static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) · line 5320
Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +5
-0+ __func__, ret); +return false; + } + + ret =ufshcd_vops_get_user_cap_mode (hba);
The Preserve User Space mode should be read from - bWriteBoosterBufferPreserveUserSpaceEn of the device descriptor - 0ffset 0x53. The driver should have no judgement here.
Based on what is configured, better to attach a helper pointer that will perform the below check, e.g. ufshcd_wb_preserve_keep_vcc_on() and ufshcd_wb_reduced_keep_vcc_on().
Which will simplify the logic here and make it much more readable.
This makes the preparations you made for ufshcd_vops_get_user_cap_mode,
and your second patch unneeded.
Quoted 18 lines
/**
*ufshcd_exception_event_handler- handle exceptions raised by device
* @work: pointer to work datadrivers/scsi/ufs/ufshcd.c +10
-0@@ -6632,6 +6829,28 @@ static int ufs_get_device_desc(struct ufs_hba *hba) desc_buf[DEVICE_DESC_PARAM_SPEC_VER +1 ]; model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME ]; +/* Enable WB only for UFS-3.1 */ +if (dev_info->wspecversion >=0x310 ) { + hba->dev_info.d_ext_ufs_feature_sup = +get_unaligned_be32 (desc_buf + +DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP ); +/* +* WB may be supported but not configured while provisioning. +* The spec says, in dedicated wb buffer mode, +* a max of 1 lun would have wb buffer configured. +* Now only shared buffer mode is supported.
drivers/scsi/ufs/ufshcd.c static int ufs_get_device_desc(struct ufs_hba · line 6852
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +10
-0+*/ + hba->dev_info.b_wb_buffer_type = + desc_buf[DEVICE_DESC_PARAM_WB_TYPE ]; + +if (!hba->dev_info.b_wb_buffer_type) + goto skip_alloc_unit; + hba->dev_info.d_wb_alloc_units = +get_unaligned_be32 (desc_buf + +DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS ); + }
Maybe pack the above code in a wb_probe() designated helper, which will establish if WB is supported or not.
If one of your validation tests fails, maybe you can just hba->caps &= ~UFSHCD_CAP_WB_EN;
which will further simplify your ufshcd_wb_sup()
drivers/scsi/ufs/ufshcd.c static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 8172
Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +2
-2if ((req_dev_pwr_mode != hba->curr_dev_pwr_mode) && - ((ufshcd_is_runtime_pm (pm_op) && !hba->auto_bkops_enabled) || - !ufshcd_is_runtime_pm (pm_op))) { + ((ufshcd_is_runtime_pm (pm_op) && !hba->auto_bkops_enabled) || + !ufshcd_is_runtime_pm (pm_op))) {
Redundant space removal
Thanks,
Avri
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Quoted 33 lines · Avri Altman
Hi,
drivers/scsi/ufs/ufs.h enum desc_header_offset { · line 203
Quoted 6 lines
enum ufs_desc_def_size {drivers/scsi/ufs/ufs.h +1
-1-QUERY_DESC_DEVICE_DEF_SIZE =0x40 , +QUERY_DESC_DEVICE_DEF_SIZE =0x59 ,QUERY_DESC_CONFIGURATION_DEF_SIZE =0x90 , QUERY_DESC_UNIT_DEF_SIZE = 0x23,Might as well update the unit descriptor size - its
0x2Dnow, As you are adding its new fieldsQuoted 10 lines
QUERY_DESC_INTERCONNECT_DEF_SIZE = 0x06,drivers/scsi/ufs/ufs.h +1
-0@@ -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*/ drivers/scsi/ufs/ufs.h enum device_desc_param { · line 269
Quoted 4 lines
drivers/scsi/ufs/ufs.h +1
-0@@ -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_USER_TYPE=0x53,Quoted 4 lines
drivers/scsi/ufs/ufs.h +2
-0+DEVICE_DESC_PARAM_WB_TYPE =0x54 , + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, };
Quoted 8 lines
drivers/scsi/ufs/ufs.h enum ufs_dev_pwr_mode { · line 474
Quoted 4 lines
drivers/scsi/ufs/ufs.h +4
-0+enum ufs_dev_wb_buf_user_cap_config { +UFS_WB_BUFF_PRESERVE_USER_SPACE =1 , +UFS_WB_BUFF_USER_SPACE_RED_EN =2 , +};Maybe better to follow the spec here:
Reduced - 0
Preserve - 1
I don't think these enums would be needed. Let me check and remove these otherwise.
Quoted 9 lines
drivers/scsi/ufs/ufshcd.c static inline void ufshcd_disable_irq(struct ufs_hba *hba) · line 291
Quoted 8 lines
drivers/scsi/ufs/ufshcd.c +8
-0+static inline void ufshcd_wb_config (struct ufs_hba *hba) +{ +int ret; + +if (!ufshcd_wb_sup (hba)) +return ; + + ret =ufshcd_wb_ctrl (hba, true);Why are you setting WB on init?
During init the clocks are scaled-up. Hence, WB is set at init.
It gets disabled when the clocks are scaled down, which is almost immediate anyway.
Quoted 11 lines
drivers/scsi/ufs/ufshcd.c static inline void ufshcd_disable_irq(struct ufs_hba *hba) · line 300
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +9
-0+if (ret) +dev_err (hba->dev,"%s: Enable WB failed: %d\n" , __func__, ret); +else +dev_info (hba->dev,"%s: Write Booster Configured\n" , __func__); + ret =ufshcd_wb_toggle_flush_during_h8 (hba, true); +if (ret) +dev_err (hba->dev,"%s: En WB flush during H8: failed: %d\n" , + __func__, ret); +ufshcd_wb_toggle_flush (hba, true);Why set explicit flush on init?
The design is to enable flush and let the device handle flush when DB's are empty on its own. Hence I'm setting flush at init itself.
Quoted 34 lines
Quoted 29 lines
drivers/scsi/ufs/ufshcd.c +21
-0+ + +static bool ufshcd_wb_keep_vcc_on (struct ufs_hba *hba) +{ +int ret; +u32 cur_buf, avail_buf; + +if (!ufshcd_wb_sup (hba)) +return false; +/* +* The ufs device needs the vcc to be ON to flush. +* With user-space reduction enabled, it's enough to enable flush +* by checking only the available buffer. The threshold +* defined here is > 90% full. +* With user-space preserved enabled, the current-buffer +* should be checked too because the wb buffer size can reduce +* when disk tends to be full. This info is provided by current +* buffer (dCurrentWriteBoosterBufferSize). There's no point in +* keeping vcc on when current buffer is empty. +*/ + ret = ufshcd_query_attr_retry(hba,
UPIU_QUERY_OPCODE_READ_ATTR,drivers/scsi/ufs/ufshcd.c +4
-0+QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE , + 0, 0, &avail_buf); +if (ret) { + dev_warn(hba->dev, "%s dAvailableWriteBoosterBufferSize readfailed %d\n",
drivers/scsi/ufs/ufshcd.c static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) · line 5320
Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +5
-0+ __func__, ret); +return false; + } + + ret =ufshcd_vops_get_user_cap_mode (hba);
Quoted 8 lines
The Preserve User Space mode should be read from - bWriteBoosterBufferPreserveUserSpaceEn of the device descriptor - 0ffset
0x53. The driver should have no judgement here.
Based on what is configured, better to attach a helper pointer that will perform the below check, e.g.ufshcd_wb_preserve_keep_vcc_on()andufshcd_wb_reduced_keep_vcc_on().
Which will simplify the logic here and make it much more readable.
This makes the preparations you made forufshcd_vops_get_user_cap_mode,
and your second patch unneeded.
Thanks, that makes sense.
Quoted 27 lines
Quoted 27 lines
/**
*ufshcd_exception_event_handler- handle exceptions raised by device
* @work: pointer to work datadrivers/scsi/ufs/ufshcd.c +17
-0@@ -6632,6 +6829,28 @@ static int ufs_get_device_desc(struct ufs_hba *hba) desc_buf[DEVICE_DESC_PARAM_SPEC_VER +1 ]; model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME ]; +/* Enable WB only for UFS-3.1 */ +if (dev_info->wspecversion >=0x310 ) { + hba->dev_info.d_ext_ufs_feature_sup = +get_unaligned_be32 (desc_buf + +DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP ); +/* +* WB may be supported but not configured while provisioning. +* The spec says, in dedicated wb buffer mode, +* a max of 1 lun would have wb buffer configured. +* Now only shared buffer mode is supported. +*/ + hba->dev_info.b_wb_buffer_type = + desc_buf[DEVICE_DESC_PARAM_WB_TYPE ]; + +if (!hba->dev_info.b_wb_buffer_type) + goto skip_alloc_unit; + hba->dev_info.d_wb_alloc_units =
Quoted 9 lines
drivers/scsi/ufs/ufshcd.c static int ufs_get_device_desc(struct ufs_hba *hba) · line 6851
Quoted 3 lines
drivers/scsi/ufs/ufshcd.c +3
-0+get_unaligned_be32 (desc_buf + +DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS ); + }Maybe pack the above code in a
wb_probe()designated helper, which will establish if WB is supported or not.
If one of your validation tests fails, maybe you can justhba->caps&= ~UFSHCD_CAP_WB_EN;
which will further simplify yourufshcd_wb_sup()
Good idea.
Quoted 13 lines
drivers/scsi/ufs/ufshcd.c static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 8172
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +2
-2if ((req_dev_pwr_mode != hba->curr_dev_pwr_mode) && - ((ufshcd_is_runtime_pm (pm_op) && !hba->auto_bkops_enabled) || - !ufshcd_is_runtime_pm (pm_op))) { + ((ufshcd_is_runtime_pm (pm_op) && !hba->auto_bkops_enabled) || + !ufshcd_is_runtime_pm (pm_op))) {Redundant space removal
Thanks,
Avri
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
In reply to Asutosh DasQuoted 6 lines · Asutosh Das
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.
Quoted 8 lines
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.
btw, in v5.8-rc1 (plus handful of remaining patches for lenovo c630 laptop (sdm850)), I'm seeing a lot of:
ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute,
opcode 6, idn 14, failed with error 253 after 3 retires
ufshcd-qcom 1d84000.ufshc: ufshcd_wb_ctrl write booster enable failed 253
and at least subjectively, compiling mesa seems slower, which seems like it might be related?
not sure if that is a known issue?
BR,
-R
Quoted 479 lines
To keep the endurance of the WriteBooster Buffer at a maximum, this load based toggling is adopted.
Signed-off-by Asutosh Das <[email protected]>Signed-off-by Subhash Jadavani <[email protected]>--- drivers/scsi/ufs/ufs.h | 31 +++++- drivers/scsi/ufs/ufshcd.c | 240 +++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 21 ++++ 3 files changed, 288 insertions(+), 4 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 +237
-3@@ -48,6 +48,8 @@#include "unipro.h" #include "ufs-sysfs.h" #include "ufs_bsg.h" +#include <linux/blkdev.h> +#include <asm/unaligned.h> #define CREATE_TRACE_POINTS #include <trace/events/ufs.h> @@ -251,6 +253,13 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up);static irqreturn_t ufshcd_intr (int irq,void *__hba);static int ufshcd_change_power_mode (struct ufs_hba *hba,struct ufs_pa_layer_attr *pwr_mode); +static bool ufshcd_wb_sup (struct ufs_hba *hba); +static int ufshcd_wb_buf_flush_enable (struct ufs_hba *hba); +static int ufshcd_wb_buf_flush_disable (struct ufs_hba *hba); +static int ufshcd_wb_ctrl (struct ufs_hba *hba,bool enable); +static int ufshcd_wb_toggle_flush_during_h8 (struct ufs_hba *hba,bool set); +static inline void ufshcd_wb_toggle_flush (struct ufs_hba *hba,bool enable); +static inline bool ufshcd_valid_tag (struct ufs_hba *hba,int tag) {return tag >=0 && tag < hba->nutrs;@@ -272,6 +281,25 @@ static inline void ufshcd_disable_irq(struct ufs_hba *hba) } } +static inline void ufshcd_wb_config (struct ufs_hba *hba) +{ +int ret; + +if (!ufshcd_wb_sup (hba)) +return ; + + ret =ufshcd_wb_ctrl (hba, true); +if (ret) +dev_err (hba->dev,"%s: Enable WB failed: %d\n" , __func__, ret); +else +dev_info (hba->dev,"%s: Write Booster Configured\n" , __func__); + ret =ufshcd_wb_toggle_flush_during_h8 (hba, true); +if (ret) +dev_err (hba->dev,"%s: En WB flush during H8: failed: %d\n" , + __func__, ret); +ufshcd_wb_toggle_flush (hba, true); +} +static void ufshcd_scsi_unblock_requests (struct ufs_hba *hba) {if (atomic_dec_and_test (&hba->scsi_block_reqs_cnt))@@ -1154,6 +1182,13 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)ufshcd_scale_clks (hba, false); } +/* Enable Write Booster if we have scaled up else disable it */ +if (!ret) { +up_write (&hba->clk_scaling_lock); +ufshcd_wb_ctrl (hba, scale_up); +down_write (&hba->clk_scaling_lock); + } + out_unprepare:ufshcd_clock_scaling_unprepare (hba); out:@@ -5154,6 +5189,168 @@ static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) __func__, err); } +static bool ufshcd_wb_sup (struct ufs_hba *hba) +{ +return (ufshcd_is_wb_allowed (hba) && + (hba->dev_info.d_ext_ufs_feature_sup & +UFS_DEV_WRITE_BOOSTER_SUP ) && + hba->dev_info.b_wb_buffer_type && + hba->dev_info.d_wb_alloc_units); +} + +static int ufshcd_wb_ctrl (struct ufs_hba *hba,bool enable) +{ +int ret; +enum query_opcode opcode; + +if (!ufshcd_wb_sup (hba)) +return 0 ; + +if (!(enable ^ hba->wb_enabled)) +return 0 ; +if (enable) + opcode =UPIU_QUERY_OPCODE_SET_FLAG ; +else + opcode =UPIU_QUERY_OPCODE_CLEAR_FLAG ; + + ret =ufshcd_query_flag_retry (hba, opcode, +QUERY_FLAG_IDN_WB_EN ,NULL ); +if (ret) { +dev_err (hba->dev,"%s write booster %s failed %d\n" , + __func__, enable ?"enable" :"disable" , ret); +return ret; + } + + hba->wb_enabled = enable; +dev_dbg (hba->dev,"%s write booster %s %d\n" , + __func__, enable ?"enable" :"disable" , ret); + +return ret; +} + +static int ufshcd_wb_toggle_flush_during_h8 (struct ufs_hba *hba,bool set) +{ +int val; + +if (set) + val =UPIU_QUERY_OPCODE_SET_FLAG ; +else + val =UPIU_QUERY_OPCODE_CLEAR_FLAG ; + +return ufshcd_query_flag_retry (hba, val, +QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 , +NULL ); +} + +static inline void ufshcd_wb_toggle_flush (struct ufs_hba *hba,bool enable) +{ +if (enable) +ufshcd_wb_buf_flush_enable (hba); +else +ufshcd_wb_buf_flush_disable (hba); + +} + +static int ufshcd_wb_buf_flush_enable (struct ufs_hba *hba) +{ +int ret; + +if (!ufshcd_wb_sup (hba) || hba->wb_buf_flush_enabled) +return 0 ; + + ret =ufshcd_query_flag_retry (hba,UPIU_QUERY_OPCODE_SET_FLAG , +QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN ,NULL ); +if (ret) +dev_err (hba->dev,"%s WB - buf flush enable failed %d\n" , + __func__, ret); +else + hba->wb_buf_flush_enabled = true; + +dev_dbg (hba->dev,"WB - Flush enabled: %d\n" , ret); +return ret; +} + +static int ufshcd_wb_buf_flush_disable (struct ufs_hba *hba) +{ +int ret; + +if (!ufshcd_wb_sup (hba) || !hba->wb_buf_flush_enabled) +return 0 ; + + ret =ufshcd_query_flag_retry (hba,UPIU_QUERY_OPCODE_CLEAR_FLAG , +QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN ,NULL ); +if (ret) { +dev_warn (hba->dev,"%s: WB - buf flush disable failed %d\n" , + __func__, ret); + }else { + hba->wb_buf_flush_enabled = false; +dev_dbg (hba->dev,"WB - Flush disabled: %d\n" , ret); + } + +return ret; +} + +static bool ufshcd_wb_keep_vcc_on (struct ufs_hba *hba) +{ +int ret; +u32 cur_buf, avail_buf; + +if (!ufshcd_wb_sup (hba)) +return false; +/* +* The ufs device needs the vcc to be ON to flush. +* With user-space reduction enabled, it's enough to enable flush +* by checking only the available buffer. The threshold +* defined here is > 90% full. +* With user-space preserved enabled, the current-buffer +* should be checked too because the wb buffer size can reduce +* when disk tends to be full. This info is provided by current +* buffer (dCurrentWriteBoosterBufferSize). There's no point in +* keeping vcc on when current buffer is empty. +*/ + ret =ufshcd_query_attr_retry (hba,UPIU_QUERY_OPCODE_READ_ATTR , +QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE , +0 ,0 , &avail_buf); +if (ret) { +dev_warn (hba->dev,"%s dAvailableWriteBoosterBufferSize read failed %d\n" , + __func__, ret); +return false; + } + + ret =ufshcd_vops_get_user_cap_mode (hba); +if (ret <=0 ) { +dev_dbg (hba->dev,"Get user-cap reduction mode: failed: %d\n" , + ret); +/* Most commonly used */ + ret =UFS_WB_BUFF_PRESERVE_USER_SPACE ; + } + +if (ret ==UFS_WB_BUFF_USER_SPACE_RED_EN ) { +if (avail_buf <=UFS_WB_10_PERCENT_BUF_REMAIN ) +return true; +return false; + }else if (ret ==UFS_WB_BUFF_PRESERVE_USER_SPACE ) { + ret =ufshcd_query_attr_retry (hba,UPIU_QUERY_OPCODE_READ_ATTR , +QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE , +0 ,0 , &cur_buf); +if (ret) { +dev_err (hba->dev,"%s dCurWriteBoosterBufferSize read failed %d\n" , + __func__, ret); +return false; + } + +if (!cur_buf) { +dev_info (hba->dev,"dCurWBBuf: %d WB disabled until free-space is available\n" , + cur_buf); +return false; + } +/* Let it continue to flush when >60% full */ +if (avail_buf <UFS_WB_40_PERCENT_BUF_REMAIN ) +return true; + } +return false; +} +/** * ufshcd_exception_event_handler - handle exceptions raised by device * @work: pointer to work data @@ -6632,6 +6829,28 @@ static int ufs_get_device_desc(struct ufs_hba *hba) desc_buf[DEVICE_DESC_PARAM_SPEC_VER +1 ]; model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME ]; +/* Enable WB only for UFS-3.1 */ +if (dev_info->wspecversion >=0x310 ) { + hba->dev_info.d_ext_ufs_feature_sup = +get_unaligned_be32 (desc_buf + +DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP ); +/* +* WB may be supported but not configured while provisioning. +* The spec says, in dedicated wb buffer mode, +* a max of 1 lun would have wb buffer configured. +* Now only shared buffer mode is supported. +*/ + hba->dev_info.b_wb_buffer_type = + desc_buf[DEVICE_DESC_PARAM_WB_TYPE ]; + +if (!hba->dev_info.b_wb_buffer_type) + goto skip_alloc_unit; + hba->dev_info.d_wb_alloc_units = +get_unaligned_be32 (desc_buf + +DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS ); + } + +skip_alloc_unit: err =ufshcd_read_string_desc (hba, model_index, &dev_info->model,SD_ASCII_STD );if (err <0 ) {@@ -7142,6 +7361,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool async)/* set the state as operational after switching to desired gear */ hba->ufshcd_state =UFSHCD_STATE_OPERATIONAL ; +ufshcd_wb_config (hba);/* Enable Auto-Hibernate if configured */ ufshcd_auto_hibern8_enable (hba);@@ -7802,12 +8022,16 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba)* * Ignore the error returned by ufshcd_toggle_vreg() as device is anyway * in low power state which would save some power. +* +* If Write Booster is enabled and the device needs to flush the WB +* buffer OR if bkops status is urgent for WB, keep Vcc on. */ if (ufshcd_is_ufs_dev_poweroff (hba) &&ufshcd_is_link_off (hba) && !hba->dev_info.is_lu_power_on_wp) {ufshcd_setup_vreg (hba, false); }else if (!ufshcd_is_ufs_dev_active (hba)) { -ufshcd_toggle_vreg (hba->dev, hba->vreg_info.vcc, false); +if (!hba->dev_info.keep_vcc_on) +ufshcd_toggle_vreg (hba->dev, hba->vreg_info.vcc, false);if (!ufshcd_is_link_active (hba)) {ufshcd_config_vreg_lpm (hba, hba->vreg_info.vccq);ufshcd_config_vreg_lpm (hba, hba->vreg_info.vccq2);@@ -7931,11 +8155,21 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)/* make sure that auto bkops is disabled */ ufshcd_disable_auto_bkops (hba); } +/* +* With wb enabled, if the bkops is enabled or if the +* configured WB type is 70% full, keep vcc ON +* for the device to flush the wb buffer +*/ +if ((hba->auto_bkops_enabled &&ufshcd_wb_sup (hba)) || +ufshcd_wb_keep_vcc_on (hba)) + hba->dev_info.keep_vcc_on = true; + }else if (!ufshcd_is_runtime_pm (pm_op)) { + hba->dev_info.keep_vcc_on = false; }if ((req_dev_pwr_mode != hba->curr_dev_pwr_mode) && - ((ufshcd_is_runtime_pm (pm_op) && !hba->auto_bkops_enabled) || - !ufshcd_is_runtime_pm (pm_op))) { + ((ufshcd_is_runtime_pm (pm_op) && !hba->auto_bkops_enabled) || + !ufshcd_is_runtime_pm (pm_op))) {/* ensure that bkops is disabled */ ufshcd_disable_auto_bkops (hba); ret =ufshcd_set_dev_pwr_mode (hba, req_dev_pwr_mode);drivers/scsi/ufs/ufshcd.h +21
-1@@ -344,6 +344,7 @@ struct ufs_hba_variant_ops {void (*config_scaling_param)(struct ufs_hba *hba,struct devfreq_dev_profile *profile,void *data); +u32 (*wb_get_user_cap_mode)(struct ufs_hba *hba); };/* clock gating state */ @@ -555,6 +556,13 @@ enum ufshcd_caps {* for userspace to control the power management. */ UFSHCD_CAP_RPM_AUTOSUSPEND =1 <<6 , + +/* +* This capability allows the host controller driver to turn-on +* WriteBooster, if the underlying device supports it and is +* provisioned to be used. This would increase the write performance. +*/ + UFSHCD_CAP_WB_EN = (1 << 7), };/** @@ -727,6 +735,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 */ @@ -775,6 +785,11 @@ static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)return FIELD_GET (UFSHCI_AHIBERN8_TIMER_MASK , hba->ahit) ? true : false; } +static inline bool ufshcd_is_wb_allowed (struct ufs_hba *hba) +{ +return hba->caps &UFSHCD_CAP_WB_EN ; +} +#define ufshcd_writel (hba, val, reg) \ writel((val), (hba)->mmio_base + (reg))#define ufshcd_readl (hba, reg) \@@ -1130,4 +1145,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 */ --Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
RE: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Quoted 30 lines
Quoted 6 lines · Asutosh Das
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.
Quoted 8 lines
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.
btw, in v5.8-rc1 (plus handful of remaining patches for lenovo c630 laptop (sdm850)), I'm seeing a lot of:
ufshcd-qcom 1d84000.ufshc:
ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag_retry: query attribute,
opcode 6, idn 14, failed with error 253 after 3 retires
ufshcd-qcom 1d84000.ufshc:ufshcd_wb_ctrlwrite booster enable failed 253
Quoted 2 lines
and at least subjectively, compiling mesa seems slower, which seems like it might be related?
This looks like a device issue to be taken with the flash vendor:
The device reports that it supports wd, but returns inalid idn for flag 0xe...
Thanks,
Avri
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Quoted 30 lines · Avri Altman
Quoted 30 lines
Quoted 6 lines · Asutosh Das
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.
Quoted 8 lines
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.
btw, in v5.8-rc1 (plus handful of remaining patches for lenovo c630 laptop (sdm850)), I'm seeing a lot of:
ufshcd-qcom 1d84000.ufshc:
ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag_retry: query attribute,
opcode 6, idn 14, failed with error 253 after 3 retires
ufshcd-qcom 1d84000.ufshc:ufshcd_wb_ctrlwrite booster enable failed 253
Quoted 3 lines
Quoted 2 lines
and at least subjectively, compiling mesa seems slower, which seems like it might be related?
This looks like a device issue to be taken with the flash vendor:
There's no way for a end-user to file a bug report with the flash vendor on a device bought from an OEM and even if they would accept the bug report they wouldn't re-provision the flash in an shipped device.
So you will have to work around this in the driver.
Regards,
Bjorn
Quoted 4 lines
The device reports that it supports wd, but returns inalid idn for flag
0xe...Thanks,
Avri
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Quoted 35 lines · Bjorn Andersson
Quoted 32 lines · Avri Altman
Quoted 32 lines
Quoted 6 lines · Asutosh Das
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.
Quoted 8 lines
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.
btw, in v5.8-rc1 (plus handful of remaining patches for lenovo c630 laptop (sdm850)), I'm seeing a lot of:
ufshcd-qcom 1d84000.ufshc:
ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag: Sending flag query for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag_retry: query attribute,
opcode 6, idn 14, failed with error 253 after 3 retires
ufshcd-qcom 1d84000.ufshc:ufshcd_wb_ctrlwrite booster enable failed 253and at least subjectively, compiling mesa seems slower, which seems like it might be related?
Quoted 7 lines
Quoted 1 line
This looks like a device issue to be taken with the flash vendor:
There's no way for a end-user to file a bug report with the flash vendor on a device bought from an OEM and even if they would accept the bug report they wouldn't re-provision the flash in an shipped device.
So you will have to work around this in the driver.
oh, ugg.. well I think these msgs from dmesg identify the part if we end up needing to use a denylist:
scsi 0:0:0:49488: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:49476: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:49456: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:0: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:1: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6
sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks: (122 GB/114 GiB) sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 32 00 10
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
sd 0:0:0:0: [sda] Optimal transfer size 786432 bytes
scsi 0:0:0:2: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:3: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6
(otoh I guess the driver could just notice that writeboost keeps failing and stop trying to use it)
BR,
-R
Quoted 7 lines
Regards,
BjornQuoted 4 lines
The device reports that it supports wd, but returns inalid idn for flag
0xe...Thanks,
Avri
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Quoted 24 lines · Rob Clark
This looks like a device issue to be taken with the flash vendor:
Quoted 5 lines
There's no way for a end-user to file a bug report with the flash vendor on a device bought from an OEM and even if they would accept the bug report they wouldn't re-provision the flash in an shipped device.
So you will have to work around this in the driver.
oh, ugg.. well I think these msgs from dmesg identify the part if we end up needing to use a denylist:
scsi 0:0:0:49488: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:49476: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:49456: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:0: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:1: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks: (122 GB/114 GiB) sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 32 00 10
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
sd 0:0:0:0: [sda] Optimal transfer size 786432 bytesscsi 0:0:0:2: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6 scsi 0:0:0:3: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI: 6
Quoted 5 lines
(otoh I guess the driver could just notice that writeboost keeps failing and stop trying to use it)
BR,
-R
FWIW, I see this on my c630 as well, but my LUN shows up as
scsi 0:0:0:49488: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ:
0 ANSI: 6
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
In reply to Rob ClarkHi Rob,
Quoted 64 lines · Rob Clark
Quoted 39 lines · Bjorn Andersson
Quoted 36 lines · Avri Altman
Quoted 36 lines
Quoted 6 lines · Asutosh Das
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.
Quoted 8 lines
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.
btw, in v5.8-rc1 (plus handful of remaining patches for lenovo c630 laptop (sdm850)), I'm seeing a lot of:
ufshcd-qcom 1d84000.ufshc:
ufshcd_query_flag: Sending flag query
for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag: Sending flag query
for
idn 14 failed, err = 253
ufshcd-qcom 1d84000.ufshc:ufshcd_query_flag_retry: query
attribute,
opcode 6, idn 14, failed with error 253 after 3 retires
ufshcd-qcom 1d84000.ufshc:ufshcd_wb_ctrlwrite booster enable
failed 253and at least subjectively, compiling mesa seems slower, which seems like it might be related?
Quoted 7 lines
Quoted 1 line
This looks like a device issue to be taken with the flash vendor:
There's no way for a end-user to file a bug report with the flash vendor on a device bought from an OEM and even if they would accept the bug report they wouldn't re-provision the flash in an shipped device.
So you will have to work around this in the driver.
oh, ugg.. well I think these msgs from dmesg identify the part if we end up needing to use a denylist:
scsi 0:0:0:49488: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0
ANSI: 6
scsi 0:0:0:49476: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0
ANSI: 6
scsi 0:0:0:49456: Well-known LUN SKhynix H28S8Q302CMR A102 PQ: 0
ANSI: 6
scsi 0:0:0:0: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI:
6
scsi 0:0:0:1: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI:
6
sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks: (122 GB/114 GiB) sd 0:0:0:0: [sda] Write Protect is off
Quoted 9 lines
sd 0:0:0:0: [sda] Mode Sense: 00 32 00 10
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
sd 0:0:0:0: [sda] Optimal transfer size 786432 bytes
scsi 0:0:0:2: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI:
6
scsi 0:0:0:3: Direct-Access SKhynix H28S8Q302CMR A102 PQ: 0 ANSI:
6
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and ufshcd_wb_config function's called without device capability check.
ufshcd_wb_config
-> ufshcd_is_wb_allowed
-> only check about hba caps with writebooster
Asutosh's first patch already check about device's capability in here.
IMO, it would be need to fixing in ufshcd_probe_hba or ufshcd_wb_config.
Quoted 17 lines
(otoh I guess the driver could just notice that writeboost keeps failing and stop trying to use it)
BR,
-RQuoted 8 lines
Regards,
BjornQuoted 5 lines
The device reports that it supports wd, but returns inalid idn for flag
0xe...Thanks,
Avri
RE: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Quoted 5 lines
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and
ufshcd_wb_configfunction's called without device capability check.
Please grep ufshcd_wb_probe.
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Hi Avri,
Quoted 7 lines · Avri Altman
Quoted 5 lines
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and
ufshcd_wb_configfunction's called without device capability check.Please grep
ufshcd_wb_probe.
I got your point, but as I mentioned, this device not support wb, this is old products.
I'm not sure ufshcd_wb_probe are called or not in Rob and Steev's platform. If it's called, hba->caps are setted with wb diable and this error not occured. But (it looks) not called, same query error will be occured in ufshcd_wb_config/ctrl.
BR,
Kyuho Choi
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Quoted 12 lines · Kyuho Choi
Hi Avri,
Quoted 6 lines · Avri Altman
Quoted 4 lines
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and
ufshcd_wb_configfunction's called without device capability check.Please grep
ufshcd_wb_probe.I got your point, but as I mentioned, this device not support wb, this is old products.
Quoted 7 lines
I'm not sure
ufshcd_wb_probeare called or not in Rob and Steev's platform. If it's called,hba->capsare setted with wb diable and this error not occured. But (it looks) not called, same query error will be occured in ufshcd_wb_config/ctrl.BR,
Kyuho Choi
I do show ufshcd_wb_probe in my sources - I'm based on 5.8-rc2 with a few extra patches for the c630, and the inline encryption patches.
I this is the output that I see -
1.
[ 0.702501] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg:
Unable to find vdd-hba-supply regulator, assuming enabled
2.
[ 0.702506] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg:
Unable to find vccq-supply regulator, assuming enabled
3.
[ 0.702508] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg:
Unable to find vccq2-supply regulator, assuming enabled
4.
[ 0.703296] ufshcd-qcom 1d84000.ufshc: Found QC Inline Crypto
Engine (ICE) v3.1.75
5.
[ 0.705121] scsi host0: ufshcd
6.
[ 0.720163] ALSA device list:
7.
[ 0.720171] No soundcards found.
8.
[ 0.731393] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX,
TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE],
rate = 0
9.
[ 0.893738] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX,
TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 210.
[ 0.894703] ufshcd-qcom 1d84000.ufshc:
ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0
11.
[ 0.896032] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253
12.
[ 0.896919] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253
13.
[ 0.897798] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253
14.
[ 0.898227] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry:
query attribute, opcode 6, idn 14, failed with error 253 after 3 retires
15.
[ 0.898798] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_ctrl write booster enable failed 253
16.
[ 0.899150] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: Enable
WB failed: 25317.
[ 0.899918] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253
18.
[ 0.900448] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253
19.
[ 0.901290] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253
20.
[ 0.901749] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry:
query attribute, opcode 6, idn 16, failed with error 253 after 3 retires
21.
[ 0.902285] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: En WB flush during H8: failed: 253
22.
[ 0.903105] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253
23.
[ 0.903988] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253
24.
[ 0.904866] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253
25.
[ 0.905294] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry:
query attribute, opcode 6, idn 15, failed with error 253 after 3 retires
26.
[ 0.905859] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_buf_flush_enable WB - buf flush enable failed 253
27.
[ 0.907659] scsi 0:0:0:49488: Well-known LUN SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
28.
[ 0.911082] scsi 0:0:0:49476: Well-known LUN SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
29.
[ 0.913268] scsi 0:0:0:49456: Well-known LUN SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
30.
[ 0.914580] scsi 0:0:0:0: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
31.
[ 0.915156] sd 0:0:0:0: Power-on or device reset occurred
32.
[ 0.915311] scsi 0:0:0:1: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
33.
[ 0.916104] scsi 0:0:0:2: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
34.
[ 0.916318] sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks:
(122 GB/114 GiB)
35.
[ 0.916417] sd 0:0:0:0: [sda] Write Protect is off
36.
[ 0.916424] sd 0:0:0:0: [sda] Mode Sense: 00 32 00 1037.
[ 0.916589] sd 0:0:0:0: [sda] Write cache: enabled, read cache:
enabled, supports DPO and FUA
38.
[ 0.916667] sd 0:0:0:0: [sda] Optimal transfer size 8192 bytes
39.
[ 0.916897] sd 0:0:0:1: Power-on or device reset occurred
40.
[ 0.917131] scsi 0:0:0:3: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
41.
[ 0.917498] sd 0:0:0:2: Power-on or device reset occurred
42.
[ 0.917994] sd 0:0:0:3: Power-on or device reset occurred
43.
[ 0.919301] scsi 0:0:0:4: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
44.
[ 0.920207] sd 0:0:0:2: [sdc] 1024 4096-byte logical blocks:
(4.19 MB/4.00 MiB)
45.
[ 0.920310] sd 0:0:0:3: [sdd] 32768 4096-byte logical blocks:
(134 MB/128 MiB)
46.
[ 0.920312] sd 0:0:0:2: [sdc] Write Protect is off
47.
[ 0.920317] sd 0:0:0:2: [sdc] Mode Sense: 00 32 00 10
48.
[ 0.920405] sd 0:0:0:3: [sdd] Write Protect is off
49.
[ 0.920410] sd 0:0:0:3: [sdd] Mode Sense: 00 32 00 1050.
[ 0.920642] sd 0:0:0:2: [sdc] Write cache: enabled, read cache:
enabled, supports DPO and FUA
51.
[ 0.921151] sd 0:0:0:2: [sdc] Optimal transfer size 8192 bytes
52.
[ 0.921212] sd 0:0:0:3: [sdd] Write cache: enabled, read cache:
enabled, supports DPO and FUA
53.
[ 0.921526] sd 0:0:0:3: [sdd] Optimal transfer size 8192 bytes
54.
[ 0.922585] sd 0:0:0:4: Power-on or device reset occurred
55.
[ 0.922983] scsi 0:0:0:5: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
56.
[ 0.923490] sd 0:0:0:1: [sdb] 1024 4096-byte logical blocks:
(4.19 MB/4.00 MiB)
57.
[ 0.928867] sd 0:0:0:1: [sdb] Write Protect is off
58.
[ 0.928870] sd 0:0:0:1: [sdb] Mode Sense: 00 32 00 10
59.
[ 0.930887] sd 0:0:0:4: [sde] 1048576 4096-byte logical blocks:
(4.29 GB/4.00 GiB)60.
[ 0.931179] sd 0:0:0:1: [sdb] Write cache: enabled, read cache:
enabled, supports DPO and FUA
61.
[ 0.932015] random: fast init done
62.
[ 0.932022] sd 0:0:0:5: Power-on or device reset occurred
63.
[ 0.935289] sd 0:0:0:4: [sde] Write Protect is off
64.
[ 0.935293] sd 0:0:0:4: [sde] Mode Sense: 00 32 00 10
65.
[ 0.935396] sda: sda1 sda2 sda3 sda4 sda5
66.
[ 0.936047] sd 0:0:0:1: [sdb] Optimal transfer size 8192 bytes67.
[ 0.936358] sd 0:0:0:4: [sde] Write cache: enabled, read cache:
enabled, supports DPO and FUA
68.
[ 0.936865] sd 0:0:0:4: [sde] Optimal transfer size 8192 bytes
69.
[ 0.938448] sdc: sdc1 sdc2
70.
[ 0.939470] sd 0:0:0:5: [sdf] 393216 4096-byte logical blocks:
(1.61 GB/1.50 GiB)
71.
[ 0.939743] sd 0:0:0:5: [sdf] Write Protect is off
72.
[ 0.939747] sd 0:0:0:5: [sdf] Mode Sense: 00 32 00 1073.
[ 0.940609] sd 0:0:0:5: [sdf] Write cache: enabled, read cache:
enabled, supports DPO and FUA
74.
[ 0.940837] sd 0:0:0:5: [sdf] Optimal transfer size 8192 bytes
75.
[ 0.940984] sd 0:0:0:0: [sda] Attached SCSI disk
76.
[ 0.941150] sd 0:0:0:2: [sdc] Attached SCSI disk
77.
[ 0.945814] sdd: sdd2 sdd3
78.
[ 0.945983] sdf: sdf2 sdf3 sdf4 sdf5
79.
[ 0.946701] sde: sde1 sde2 sde3 sde4 sde5 sde6 sde7 sde8 sde9
sde10 sde11 sde12 sde13 sde14 sde15 sde16 sde17 sde18 sde19 sde20
sde21 sde22 sde23 sde24 sde25 sde26 sde27
80.
[ 0.953610] sdb: sdb1 sdb2
81.
[ 0.954035] sd 0:0:0:5: [sdf] Attached SCSI disk
82.
[ 0.954131] sd 0:0:0:4: [sde] Attached SCSI disk
83.
[ 0.954177] sd 0:0:0:3: [sdd] Attached SCSI disk
84.
[ 0.955316] sd 0:0:0:1: [sdb] Attached SCSI diskFull dmesg output at https://pastebin.com/azWahunu
-- Steev
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Hi Steev,
Quoted 95 lines · Steev Klimaszewski
Quoted 12 lines · Kyuho Choi
Hi Avri,
Quoted 6 lines · Avri Altman
Quoted 4 lines
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and
ufshcd_wb_configfunction's called without device capability check.Please grep
ufshcd_wb_probe.I got your point, but as I mentioned, this device not support wb, this is old products.
Quoted 7 lines
I'm not sure
ufshcd_wb_probeare called or not in Rob and Steev's platform. If it's called,hba->capsare setted with wb diable and this error not occured. But (it looks) not called, same query error will be occured in ufshcd_wb_config/ctrl.BR,
Kyuho ChoiI do show
ufshcd_wb_probein my sources - I'm based on 5.8-rc2 with a few extra patches for the c630, and the inline encryption patches.I this is the output that I see -
1.
[ 0.702501] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled 2. [ 0.702506] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled 3. [ 0.702508] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled 4. [ 0.703296] ufshcd-qcom 1d84000.ufshc: Found QC Inline Crypto Engine (ICE) v3.1.75 5. [ 0.705121] scsi host0: ufshcd 6. [ 0.720163] ALSA device list: 7. [ 0.720171] No soundcards found. 8. [ 0.731393] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 9. [ 0.893738] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 10. [ 0.894703] ufshcd-qcom 1d84000.ufshc: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0 11. [ 0.896032] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 12. [ 0.896919] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 13. [ 0.897798] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 14. [ 0.898227] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 14, failed with error 253 after 3 retires 15. [ 0.898798] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_ctrl write booster enable failed 253 16. [ 0.899150] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: Enable WB failed: 253 17. [ 0.899918] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 18. [ 0.900448] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 19. [ 0.901290] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 20. [ 0.901749] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 16, failed with error 253 after 3 retires 21. [ 0.902285] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: En WB flush during H8: failed: 253 22. [ 0.903105] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 23. [ 0.903988] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 25324.
Quoted 8 lines
[ 0.904866] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending
flag query for idn 15 failed, err = 253
25.
[ 0.905294] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry:
query attribute, opcode 6, idn 15, failed with error 253 after 3 retires
26.
[ 0.905859] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_buf_flush_enable
WB - buf flush enable failed 253Please help try below simple patch to see if above WriteBooster messages can be eliminated.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/ufs/ufshcd.c +0 -0
@@ -6985,6 +6985,8 @@ static int ufs_get_device_desc(struct ufs_hba
*hba)
dev_info->wspecversion == 0x220 ||
(hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES))
ufshcd_wb_probe(hba, desc_buf);
+ else
+ hba->caps &= ~UFSHCD_CAP_WB_EN;
/*
* ufshcd_read_string_desc returns size of the string
Quoted 145 lines
27.
[ 0.907659] scsi 0:0:0:49488: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 28. [ 0.911082] scsi 0:0:0:49476: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 29. [ 0.913268] scsi 0:0:0:49456: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 30. [ 0.914580] scsi 0:0:0:0: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 31. [ 0.915156] sd 0:0:0:0: Power-on or device reset occurred 32. [ 0.915311] scsi 0:0:0:1: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 33. [ 0.916104] scsi 0:0:0:2: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 34. [ 0.916318] sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks: (122 GB/114 GiB) 35. [ 0.916417] sd 0:0:0:0: [sda] Write Protect is off 36. [ 0.916424] sd 0:0:0:0: [sda] Mode Sense: 00 32 00 10 37. [ 0.916589] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA 38. [ 0.916667] sd 0:0:0:0: [sda] Optimal transfer size 8192 bytes 39. [ 0.916897] sd 0:0:0:1: Power-on or device reset occurred 40. [ 0.917131] scsi 0:0:0:3: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 41. [ 0.917498] sd 0:0:0:2: Power-on or device reset occurred 42. [ 0.917994] sd 0:0:0:3: Power-on or device reset occurred 43. [ 0.919301] scsi 0:0:0:4: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 44. [ 0.920207] sd 0:0:0:2: [sdc] 1024 4096-byte logical blocks: (4.19 MB/4.00 MiB) 45. [ 0.920310] sd 0:0:0:3: [sdd] 32768 4096-byte logical blocks: (134 MB/128 MiB) 46. [ 0.920312] sd 0:0:0:2: [sdc] Write Protect is off 47. [ 0.920317] sd 0:0:0:2: [sdc] Mode Sense: 00 32 00 10 48. [ 0.920405] sd 0:0:0:3: [sdd] Write Protect is off 49. [ 0.920410] sd 0:0:0:3: [sdd] Mode Sense: 00 32 00 10 50. [ 0.920642] sd 0:0:0:2: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA 51. [ 0.921151] sd 0:0:0:2: [sdc] Optimal transfer size 8192 bytes 52. [ 0.921212] sd 0:0:0:3: [sdd] Write cache: enabled, read cache: enabled, supports DPO and FUA 53. [ 0.921526] sd 0:0:0:3: [sdd] Optimal transfer size 8192 bytes 54. [ 0.922585] sd 0:0:0:4: Power-on or device reset occurred 55. [ 0.922983] scsi 0:0:0:5: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 56. [ 0.923490] sd 0:0:0:1: [sdb] 1024 4096-byte logical blocks: (4.19 MB/4.00 MiB) 57. [ 0.928867] sd 0:0:0:1: [sdb] Write Protect is off 58. [ 0.928870] sd 0:0:0:1: [sdb] Mode Sense: 00 32 00 10 59. [ 0.930887] sd 0:0:0:4: [sde] 1048576 4096-byte logical blocks: (4.29 GB/4.00 GiB) 60. [ 0.931179] sd 0:0:0:1: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA 61. [ 0.932015] random: fast init done 62. [ 0.932022] sd 0:0:0:5: Power-on or device reset occurred 63. [ 0.935289] sd 0:0:0:4: [sde] Write Protect is off 64. [ 0.935293] sd 0:0:0:4: [sde] Mode Sense: 00 32 00 10 65. [ 0.935396] sda: sda1 sda2 sda3 sda4 sda5 66. [ 0.936047] sd 0:0:0:1: [sdb] Optimal transfer size 8192 bytes 67. [ 0.936358] sd 0:0:0:4: [sde] Write cache: enabled, read cache: enabled, supports DPO and FUA 68. [ 0.936865] sd 0:0:0:4: [sde] Optimal transfer size 8192 bytes 69. [ 0.938448] sdc: sdc1 sdc2 70. [ 0.939470] sd 0:0:0:5: [sdf] 393216 4096-byte logical blocks: (1.61 GB/1.50 GiB) 71. [ 0.939743] sd 0:0:0:5: [sdf] Write Protect is off 72. [ 0.939747] sd 0:0:0:5: [sdf] Mode Sense: 00 32 00 10 73. [ 0.940609] sd 0:0:0:5: [sdf] Write cache: enabled, read cache: enabled, supports DPO and FUA 74. [ 0.940837] sd 0:0:0:5: [sdf] Optimal transfer size 8192 bytes 75. [ 0.940984] sd 0:0:0:0: [sda] Attached SCSI disk 76. [ 0.941150] sd 0:0:0:2: [sdc] Attached SCSI disk 77. [ 0.945814] sdd: sdd2 sdd3 78. [ 0.945983] sdf: sdf2 sdf3 sdf4 sdf5 79. [ 0.946701] sde: sde1 sde2 sde3 sde4 sde5 sde6 sde7 sde8 sde9 sde10 sde11 sde12 sde13 sde14 sde15 sde16 sde17 sde18 sde19 sde20 sde21 sde22 sde23 sde24 sde25 sde26 sde27 80. [ 0.953610] sdb: sdb1 sdb2 81. [ 0.954035] sd 0:0:0:5: [sdf] Attached SCSI disk 82. [ 0.954131] sd 0:0:0:4: [sde] Attached SCSI disk 83. [ 0.954177] sd 0:0:0:3: [sdd] Attached SCSI disk 84. [ 0.955316] sd 0:0:0:1: [sdb] Attached SCSI diskFull dmesg output at https://pastebin.com/azWahunu
-- Steev
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Hi Stanley,
Quoted 125 lines · Stanley Chu
Hi Steev,
Quoted 100 lines · Steev Klimaszewski
Quoted 19 lines · Kyuho Choi
Hi Avri,
Quoted 6 lines · Avri Altman
Quoted 4 lines
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and
ufshcd_wb_configfunction's called without device capability check.Please grep
ufshcd_wb_probe.I got your point, but as I mentioned, this device not support wb, this is old products.
I'm not sure
ufshcd_wb_probeare called or not in Rob and Steev's platform.
If it's called,hba->capsare setted with wb diable and this error not occured.
But (it looks) not called, same query error will be occured in ufshcd_wb_config/ctrl.Quoted 2 lines
BR,
Kyuho ChoiI do show
ufshcd_wb_probein my sources - I'm based on 5.8-rc2 with a few extra patches for the c630, and the inline encryption patches.I this is the output that I see -
1.
[ 0.702501] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled 2. [ 0.702506] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled 3. [ 0.702508] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled 4. [ 0.703296] ufshcd-qcom 1d84000.ufshc: Found QC Inline Crypto Engine (ICE) v3.1.75 5. [ 0.705121] scsi host0: ufshcd 6. [ 0.720163] ALSA device list: 7. [ 0.720171] No soundcards found. 8. [ 0.731393] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 9. [ 0.893738] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 10. [ 0.894703] ufshcd-qcom 1d84000.ufshc: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0 11. [ 0.896032] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 12. [ 0.896919] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 13. [ 0.897798] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 14. [ 0.898227] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 14, failed with error 253 after 3 retires 15. [ 0.898798] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_ctrl write booster enable failed 253 16. [ 0.899150] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: Enable WB failed: 253 17. [ 0.899918] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 18. [ 0.900448] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 19. [ 0.901290] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 20. [ 0.901749] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 16, failed with error 253 after 3 retires 21. [ 0.902285] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: En WB flush during H8: failed: 253 22. [ 0.903105] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 23. [ 0.903988] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 24. [ 0.904866] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: SendingQuoted 8 lines
flag query for idn 15 failed, err = 253 25. [ 0.905294] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 15, failed with error 253 after 3 retires 26. [ 0.905859] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_buf_flush_enable WB - buf flush enable failed 253Please help try below simple patch to see if above WriteBooster messages can be eliminated.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)drivers/scsi/ufs/ufshcd.c +0
-0
drivers/scsi/ufs/ufshcd.c static int ufs_get_device_desc(struct ufs_hba · line 6990
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +2
-0@@ -6985,6 +6985,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba) dev_info->wspecversion == 0x220 || (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES))ufshcd_wb_probe (hba, desc_buf); + else + hba->caps &= ~UFSHCD_CAP_WB_EN;
IMO, hba->caps about WB_EN is already set in ufs-vendor.c. So for writebooster didn't support ufs devices, need to clear this caps.
Quoted 154 lines
drivers/scsi/ufs/ufshcd.c +0
-1/* * ufshcd_read_string_desc returns size of the string -- Quoted 148 lines
27.
[ 0.907659] scsi 0:0:0:49488: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 28. [ 0.911082] scsi 0:0:0:49476: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 29. [ 0.913268] scsi 0:0:0:49456: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 30. [ 0.914580] scsi 0:0:0:0: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 31. [ 0.915156] sd 0:0:0:0: Power-on or device reset occurred 32. [ 0.915311] scsi 0:0:0:1: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 33. [ 0.916104] scsi 0:0:0:2: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 34. [ 0.916318] sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks: (122 GB/114 GiB) 35. [ 0.916417] sd 0:0:0:0: [sda] Write Protect is off 36. [ 0.916424] sd 0:0:0:0: [sda] Mode Sense: 00 32 00 10 37. [ 0.916589] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA 38. [ 0.916667] sd 0:0:0:0: [sda] Optimal transfer size 8192 bytes 39. [ 0.916897] sd 0:0:0:1: Power-on or device reset occurred 40. [ 0.917131] scsi 0:0:0:3: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 41. [ 0.917498] sd 0:0:0:2: Power-on or device reset occurred 42. [ 0.917994] sd 0:0:0:3: Power-on or device reset occurred 43. [ 0.919301] scsi 0:0:0:4: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 44. [ 0.920207] sd 0:0:0:2: [sdc] 1024 4096-byte logical blocks: (4.19 MB/4.00 MiB) 45. [ 0.920310] sd 0:0:0:3: [sdd] 32768 4096-byte logical blocks: (134 MB/128 MiB) 46. [ 0.920312] sd 0:0:0:2: [sdc] Write Protect is off 47. [ 0.920317] sd 0:0:0:2: [sdc] Mode Sense: 00 32 00 10 48. [ 0.920405] sd 0:0:0:3: [sdd] Write Protect is off 49. [ 0.920410] sd 0:0:0:3: [sdd] Mode Sense: 00 32 00 10 50. [ 0.920642] sd 0:0:0:2: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA 51. [ 0.921151] sd 0:0:0:2: [sdc] Optimal transfer size 8192 bytes 52. [ 0.921212] sd 0:0:0:3: [sdd] Write cache: enabled, read cache: enabled, supports DPO and FUA 53. [ 0.921526] sd 0:0:0:3: [sdd] Optimal transfer size 8192 bytes 54. [ 0.922585] sd 0:0:0:4: Power-on or device reset occurred 55. [ 0.922983] scsi 0:0:0:5: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 56. [ 0.923490] sd 0:0:0:1: [sdb] 1024 4096-byte logical blocks: (4.19 MB/4.00 MiB) 57. [ 0.928867] sd 0:0:0:1: [sdb] Write Protect is off 58. [ 0.928870] sd 0:0:0:1: [sdb] Mode Sense: 00 32 00 10 59. [ 0.930887] sd 0:0:0:4: [sde] 1048576 4096-byte logical blocks: (4.29 GB/4.00 GiB) 60. [ 0.931179] sd 0:0:0:1: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA 61. [ 0.932015] random: fast init done 62. [ 0.932022] sd 0:0:0:5: Power-on or device reset occurred 63. [ 0.935289] sd 0:0:0:4: [sde] Write Protect is off 64. [ 0.935293] sd 0:0:0:4: [sde] Mode Sense: 00 32 00 10 65. [ 0.935396] sda: sda1 sda2 sda3 sda4 sda5 66. [ 0.936047] sd 0:0:0:1: [sdb] Optimal transfer size 8192 bytes 67. [ 0.936358] sd 0:0:0:4: [sde] Write cache: enabled, read cache: enabled, supports DPO and FUA 68. [ 0.936865] sd 0:0:0:4: [sde] Optimal transfer size 8192 bytes 69. [ 0.938448] sdc: sdc1 sdc2 70. [ 0.939470] sd 0:0:0:5: [sdf] 393216 4096-byte logical blocks: (1.61 GB/1.50 GiB) 71. [ 0.939743] sd 0:0:0:5: [sdf] Write Protect is off 72. [ 0.939747] sd 0:0:0:5: [sdf] Mode Sense: 00 32 00 10 73. [ 0.940609] sd 0:0:0:5: [sdf] Write cache: enabled, read cache: enabled, supports DPO and FUA 74. [ 0.940837] sd 0:0:0:5: [sdf] Optimal transfer size 8192 bytes 75. [ 0.940984] sd 0:0:0:0: [sda] Attached SCSI disk 76. [ 0.941150] sd 0:0:0:2: [sdc] Attached SCSI disk 77. [ 0.945814] sdd: sdd2 sdd3 78. [ 0.945983] sdf: sdf2 sdf3 sdf4 sdf5 79. [ 0.946701] sde: sde1 sde2 sde3 sde4 sde5 sde6 sde7 sde8 sde9 sde10 sde11 sde12 sde13 sde14 sde15 sde16 sde17 sde18 sde19 sde20 sde21 sde22 sde23 sde24 sde25 sde26 sde27 80. [ 0.953610] sdb: sdb1 sdb2 81. [ 0.954035] sd 0:0:0:5: [sdf] Attached SCSI disk 82. [ 0.954131] sd 0:0:0:4: [sde] Attached SCSI disk 83. [ 0.954177] sd 0:0:0:3: [sdd] Attached SCSI disk 84. [ 0.955316] sd 0:0:0:1: [sdb] Attached SCSI diskFull dmesg output at https://pastebin.com/azWahunu
-- Steev
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Hi Kyuho,
Quoted 123 lines · Kyuho Choi
Hi Stanley,
Quoted 120 lines · Stanley Chu
Hi Steev,
Quoted 100 lines · Steev Klimaszewski
Quoted 19 lines · Kyuho Choi
Hi Avri,
Quoted 6 lines · Avri Altman
Quoted 4 lines
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and
ufshcd_wb_configfunction's called without device capability check.Please grep
ufshcd_wb_probe.I got your point, but as I mentioned, this device not support wb, this is old products.
I'm not sure
ufshcd_wb_probeare called or not in Rob and Steev's platform.
If it's called,hba->capsare setted with wb diable and this error not occured.
But (it looks) not called, same query error will be occured in ufshcd_wb_config/ctrl.Quoted 2 lines
BR,
Kyuho ChoiI do show
ufshcd_wb_probein my sources - I'm based on 5.8-rc2 with a few extra patches for the c630, and the inline encryption patches.I this is the output that I see -
1.
[ 0.702501] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled 2. [ 0.702506] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled 3. [ 0.702508] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled 4. [ 0.703296] ufshcd-qcom 1d84000.ufshc: Found QC Inline Crypto Engine (ICE) v3.1.75 5. [ 0.705121] scsi host0: ufshcd 6. [ 0.720163] ALSA device list: 7. [ 0.720171] No soundcards found. 8. [ 0.731393] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 9. [ 0.893738] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 10. [ 0.894703] ufshcd-qcom 1d84000.ufshc: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0 11. [ 0.896032] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 12. [ 0.896919] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 13. [ 0.897798] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 14. [ 0.898227] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 14, failed with error 253 after 3 retires 15. [ 0.898798] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_ctrl write booster enable failed 253 16. [ 0.899150] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: Enable WB failed: 253 17. [ 0.899918] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 18. [ 0.900448] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 19. [ 0.901290] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 20. [ 0.901749] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 16, failed with error 253 after 3 retires 21. [ 0.902285] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: En WB flush during H8: failed: 253 22. [ 0.903105] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 23. [ 0.903988] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 24. [ 0.904866] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: SendingQuoted 8 lines
flag query for idn 15 failed, err = 253 25. [ 0.905294] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 15, failed with error 253 after 3 retires 26. [ 0.905859] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_buf_flush_enable WB - buf flush enable failed 253Please help try below simple patch to see if above WriteBooster messages can be eliminated.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 16 lines
drivers/scsi/ufs/ufshcd.c static int ufs_get_device_desc(struct ufs_hba · line 6990
Quoted 11 lines
drivers/scsi/ufs/ufshcd.c +2
-0@@ -6985,6 +6985,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba) dev_info->wspecversion == 0x220 || (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES))ufshcd_wb_probe (hba, desc_buf); + else + hba->caps &= ~UFSHCD_CAP_WB_EN;IMO,
hba->capsaboutWB_ENis already set inufs-vendor.c. So for writebooster didn't support ufs devices, need to clear this caps.Quoted 1 line
Thanks for the ack. Then I'll send it as a formal patch.
Thank you,
Stanley Chu
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
In reply to Stanley ChuQuoted 23 lines · Stanley Chu
Hi Steev,
Please help try below simple patch to see if above WriteBooster messages can be eliminated.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)drivers/scsi/ufs/ufshcd.c +2
-0@@ -6985,6 +6985,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba) dev_info->wspecversion == 0x220 || (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES))ufshcd_wb_probe (hba, desc_buf); + else + hba->caps &= ~UFSHCD_CAP_WB_EN;/*
Quoted 1 line
*
ufshcd_read_string_descreturns size of the string
Hi Stanley,
That worked.
1.
[ 0.704775] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg:
Unable to find vdd-hba-supply regulator, assuming enabled
2.
[ 0.704781] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg:
Unable to find vccq-supply regulator, assuming enabled
3.
[ 0.704783] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg:
Unable to find vccq2-supply regulator, assuming enabled
4.
[ 0.705618] ufshcd-qcom 1d84000.ufshc: Found QC Inline Crypto
Engine (ICE) v3.1.75
5.
[ 0.707496] scsi host0: ufshcd
6.
[ 0.720415] ALSA device list:
7.
[ 0.720422] No soundcards found.
8.
[ 0.734245] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX,
TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE],
rate = 0
9.
[ 0.845159] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX,
TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 210.
[ 0.846399] ufshcd-qcom 1d84000.ufshc:
ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0
11.
[ 0.849258] scsi 0:0:0:49488: Well-known LUN SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
12.
[ 0.853372] scsi 0:0:0:49476: Well-known LUN SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
13.
[ 0.855135] scsi 0:0:0:49456: Well-known LUN SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
14.
[ 0.857050] scsi 0:0:0:0: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
15.
[ 0.858297] sd 0:0:0:0: Power-on or device reset occurred
16.
[ 0.859985] scsi 0:0:0:1: Direct-Access SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6
17.
[ 0.860702] sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks:
(122 GB/114 GiB)(full dmesg output at https://pastebin.com/Pvfqe42P )
I guess you can throw my Tested-by on there.
Thanks
--Steev
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
Hi Steev,
Quoted 81 lines · Steev Klimaszewski
Quoted 23 lines · Stanley Chu
Hi Steev,
Please help try below simple patch to see if above WriteBooster messages can be eliminated.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)drivers/scsi/ufs/ufshcd.c +2
-0@@ -6985,6 +6985,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba) dev_info->wspecversion == 0x220 || (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES))ufshcd_wb_probe (hba, desc_buf); + else + hba->caps &= ~UFSHCD_CAP_WB_EN;/* Quoted 1 line
*
ufshcd_read_string_descreturns size of the stringHi Stanley,
That worked.
1.
[ 0.704775] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled 2. [ 0.704781] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled 3. [ 0.704783] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled 4. [ 0.705618] ufshcd-qcom 1d84000.ufshc: Found QC Inline Crypto Engine (ICE) v3.1.75 5. [ 0.707496] scsi host0: ufshcd 6. [ 0.720415] ALSA device list: 7. [ 0.720422] No soundcards found. 8. [ 0.734245] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 9. [ 0.845159] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 10. [ 0.846399] ufshcd-qcom 1d84000.ufshc: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0 11. [ 0.849258] scsi 0:0:0:49488: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 12. [ 0.853372] scsi 0:0:0:49476: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 13. [ 0.855135] scsi 0:0:0:49456: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 14. [ 0.857050] scsi 0:0:0:0: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 15. [ 0.858297] sd 0:0:0:0: Power-on or device reset occurred 16. [ 0.859985] scsi 0:0:0:1: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 17. [ 0.860702] sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks: (122 GB/114 GiB)
Quoted 4 lines
(full dmesg output at https://pastebin.com/Pvfqe42P )
I guess you can throw my Tested-by on there.
Thanks so much for the test!
I have re-sent the patch with your "Tested-By" tag : )
Thanks a lot,
Stanley Chu
Re: [PATCH v1 1/3] scsi: ufs: add write booster feature support
In reply to Steev KlimaszewskiHi Steev,
Thanks for share log!.
Quoted 69 lines · Steev Klimaszewski
Quoted 19 lines · Kyuho Choi
Hi Avri,
Quoted 6 lines · Avri Altman
Quoted 4 lines
AFAIK, this device are ufs 2.1. It's not support writebooster.
I'd check latest linux scsi branch and
ufshcd_wb_configfunction's called without device capability check.Please grep
ufshcd_wb_probe.I got your point, but as I mentioned, this device not support wb, this is old products.
I'm not sure
ufshcd_wb_probeare called or not in Rob and Steev's platform.
If it's called,hba->capsare setted with wb diable and this error not occured.
But (it looks) not called, same query error will be occured in ufshcd_wb_config/ctrl.Quoted 2 lines
BR,
Kyuho ChoiI do show
ufshcd_wb_probein my sources - I'm based on 5.8-rc2 with a few extra patches for the c630, and the inline encryption patches.I this is the output that I see -
1.
[ 0.702501] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vdd-hba-supply regulator, assuming enabled 2. [ 0.702506] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq-supply regulator, assuming enabled 3. [ 0.702508] ufshcd-qcom 1d84000.ufshc: ufshcd_populate_vreg: Unable to find vccq2-supply regulator, assuming enabled 4. [ 0.703296] ufshcd-qcom 1d84000.ufshc: Found QC Inline Crypto Engine (ICE) v3.1.75 5. [ 0.705121] scsi host0: ufshcd 6. [ 0.720163] ALSA device list: 7. [ 0.720171] No soundcards found. 8. [ 0.731393] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 9. [ 0.893738] ufshcd-qcom 1d84000.ufshc: ufshcd_print_pwr_info:[RX, TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 10. [ 0.894703] ufshcd-qcom 1d84000.ufshc: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0 11. [ 0.896032] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 12. [ 0.896919] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 13. [ 0.897798] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 253 14. [ 0.898227] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry:
Quoted 8 lines
query attribute, opcode 6, idn 14, failed with error 253 after 3
retires
15.
[ 0.898798] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_ctrl write
booster enable failed 253
16.
[ 0.899150] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: Enable
WB failed: 253Like here, as I mentioned in last. Some of UFS 2.1 device maybe got a query fail like this.
Quoted 27 lines
17.
[ 0.899918] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 18. [ 0.900448] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 19. [ 0.901290] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 16 failed, err = 253 20. [ 0.901749] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry: query attribute, opcode 6, idn 16, failed with error 253 after 3 retires 21. [ 0.902285] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_config: En WB flush during H8: failed: 253 22. [ 0.903105] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 23. [ 0.903988] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 24. [ 0.904866] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag: Sending flag query for idn 15 failed, err = 253 25. [ 0.905294] ufshcd-qcom 1d84000.ufshc: ufshcd_query_flag_retry:
Quoted 8 lines
query attribute, opcode 6, idn 15, failed with error 253 after 3
retires
26.
[ 0.905859] ufshcd-qcom 1d84000.ufshc: ufshcd_wb_buf_flush_enable
WB - buf flush enable failed 253
27.
[ 0.907659] scsi 0:0:0:49488: Well-known LUN SAMSUNG
KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6I'd searching this ufs device part no and it's ufs 2.1 too.
Quoted 137 lines
28.
[ 0.911082] scsi 0:0:0:49476: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 29. [ 0.913268] scsi 0:0:0:49456: Well-known LUN SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 30. [ 0.914580] scsi 0:0:0:0: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 31. [ 0.915156] sd 0:0:0:0: Power-on or device reset occurred 32. [ 0.915311] scsi 0:0:0:1: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 33. [ 0.916104] scsi 0:0:0:2: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 34. [ 0.916318] sd 0:0:0:0: [sda] 29765632 4096-byte logical blocks: (122 GB/114 GiB) 35. [ 0.916417] sd 0:0:0:0: [sda] Write Protect is off 36. [ 0.916424] sd 0:0:0:0: [sda] Mode Sense: 00 32 00 10 37. [ 0.916589] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA 38. [ 0.916667] sd 0:0:0:0: [sda] Optimal transfer size 8192 bytes 39. [ 0.916897] sd 0:0:0:1: Power-on or device reset occurred 40. [ 0.917131] scsi 0:0:0:3: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 41. [ 0.917498] sd 0:0:0:2: Power-on or device reset occurred 42. [ 0.917994] sd 0:0:0:3: Power-on or device reset occurred 43. [ 0.919301] scsi 0:0:0:4: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 44. [ 0.920207] sd 0:0:0:2: [sdc] 1024 4096-byte logical blocks: (4.19 MB/4.00 MiB) 45. [ 0.920310] sd 0:0:0:3: [sdd] 32768 4096-byte logical blocks: (134 MB/128 MiB) 46. [ 0.920312] sd 0:0:0:2: [sdc] Write Protect is off 47. [ 0.920317] sd 0:0:0:2: [sdc] Mode Sense: 00 32 00 10 48. [ 0.920405] sd 0:0:0:3: [sdd] Write Protect is off 49. [ 0.920410] sd 0:0:0:3: [sdd] Mode Sense: 00 32 00 10 50. [ 0.920642] sd 0:0:0:2: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA 51. [ 0.921151] sd 0:0:0:2: [sdc] Optimal transfer size 8192 bytes 52. [ 0.921212] sd 0:0:0:3: [sdd] Write cache: enabled, read cache: enabled, supports DPO and FUA 53. [ 0.921526] sd 0:0:0:3: [sdd] Optimal transfer size 8192 bytes 54. [ 0.922585] sd 0:0:0:4: Power-on or device reset occurred 55. [ 0.922983] scsi 0:0:0:5: Direct-Access SAMSUNG KLUDG4U1EA-B0C1 0500 PQ: 0 ANSI: 6 56. [ 0.923490] sd 0:0:0:1: [sdb] 1024 4096-byte logical blocks: (4.19 MB/4.00 MiB) 57. [ 0.928867] sd 0:0:0:1: [sdb] Write Protect is off 58. [ 0.928870] sd 0:0:0:1: [sdb] Mode Sense: 00 32 00 10 59. [ 0.930887] sd 0:0:0:4: [sde] 1048576 4096-byte logical blocks: (4.29 GB/4.00 GiB) 60. [ 0.931179] sd 0:0:0:1: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA 61. [ 0.932015] random: fast init done 62. [ 0.932022] sd 0:0:0:5: Power-on or device reset occurred 63. [ 0.935289] sd 0:0:0:4: [sde] Write Protect is off 64. [ 0.935293] sd 0:0:0:4: [sde] Mode Sense: 00 32 00 10 65. [ 0.935396] sda: sda1 sda2 sda3 sda4 sda5 66. [ 0.936047] sd 0:0:0:1: [sdb] Optimal transfer size 8192 bytes 67. [ 0.936358] sd 0:0:0:4: [sde] Write cache: enabled, read cache: enabled, supports DPO and FUA 68. [ 0.936865] sd 0:0:0:4: [sde] Optimal transfer size 8192 bytes 69. [ 0.938448] sdc: sdc1 sdc2 70. [ 0.939470] sd 0:0:0:5: [sdf] 393216 4096-byte logical blocks: (1.61 GB/1.50 GiB) 71. [ 0.939743] sd 0:0:0:5: [sdf] Write Protect is off 72. [ 0.939747] sd 0:0:0:5: [sdf] Mode Sense: 00 32 00 10 73. [ 0.940609] sd 0:0:0:5: [sdf] Write cache: enabled, read cache: enabled, supports DPO and FUA 74. [ 0.940837] sd 0:0:0:5: [sdf] Optimal transfer size 8192 bytes 75. [ 0.940984] sd 0:0:0:0: [sda] Attached SCSI disk 76. [ 0.941150] sd 0:0:0:2: [sdc] Attached SCSI disk 77. [ 0.945814] sdd: sdd2 sdd3 78. [ 0.945983] sdf: sdf2 sdf3 sdf4 sdf5 79. [ 0.946701] sde: sde1 sde2 sde3 sde4 sde5 sde6 sde7 sde8 sde9 sde10 sde11 sde12 sde13 sde14 sde15 sde16 sde17 sde18 sde19 sde20 sde21 sde22 sde23 sde24 sde25 sde26 sde27 80. [ 0.953610] sdb: sdb1 sdb2 81. [ 0.954035] sd 0:0:0:5: [sdf] Attached SCSI disk 82. [ 0.954131] sd 0:0:0:4: [sde] Attached SCSI disk 83. [ 0.954177] sd 0:0:0:3: [sdd] Attached SCSI disk 84. [ 0.955316] sd 0:0:0:1: [sdb] Attached SCSI disk
Quoted 6 lines
Full dmesg output at https://pastebin.com/azWahunu
-- Steev
BR,
Kyuho Choi
PATCH 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.
Enable WB for Qualcomm platform.
--- drivers/scsi/ufs/ufs-qcom.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/ufs/ufs-qcom.c +8 -0
@@ -1071,6 +1071,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) hba->caps |=UFSHCD_CAP_CLK_GATING |UFSHCD_CAP_HIBERN8_WITH_CLK_GATING ; hba->caps |=UFSHCD_CAP_CLK_SCALING ; hba->caps |=UFSHCD_CAP_AUTO_BKOPS_SUSPEND ; + hba->caps |=UFSHCD_CAP_WB_EN ;if (host->hw_ver.major >=0x2 ) { host->caps = UFS_QCOM_CAP_QUNIPRO |
@@ -1713,6 +1714,12 @@ static void ufs_qcom_config_scaling_param(struct ufs_hba *hba, }#endif +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 *
@@ -1735,6 +1742,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .dbg_register_dump = ufs_qcom_dump_dbg_regs, .device_reset = ufs_qcom_device_reset, .config_scaling_param = ufs_qcom_config_scaling_param, + .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 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
@@ -276,6 +276,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,
@@ -304,6 +308,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, };
@@ -373,6 +381,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,
@@ -404,6 +418,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, };
@@ -616,7 +635,7 @@ static ssize_t _name##_show(struct device *dev, \pm_runtime_put_sync (hba->dev); \if (ret) \return -EINVAL ; \ -return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ +return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ } \static DEVICE_ATTR_RO (_name)
@@ -628,6 +647,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,
@@ -638,6 +660,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, };
@@ -679,6 +704,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,
@@ -697,6 +727,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, };
@@ -748,6 +782,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,
@@ -763,6 +799,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.
PATCH v2 1/3 scsi: ufs: add write booster feature support
In reply to Asutosh DasThe 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 | 248 +++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 14 +++ 3 files changed, 288 insertions(+), 5 deletions(-)
drivers/scsi/ufs/ufs.h +29 -2
@@ -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,9 +198,9 @@ 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_UNIT_DEF_SIZE =0x2D ,QUERY_DESC_INTERCONNECT_DEF_SIZE =0x06 ,QUERY_DESC_GEOMETRY_DEF_SIZE =0x48 ,QUERY_DESC_POWER_DEF_SIZE =0x62 ,
@@ -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,10 @@ 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_PRESRV_USRSPC_EN =0x53 , +DEVICE_DESC_PARAM_WB_TYPE =0x54 , + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, };/* Interconnect descriptor parameters offsets in bytes*/
@@ -333,6 +345,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 +464,11 @@ 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 , +}; +/** * struct utp_cmd_rsp - Response UPIU structure * @residual_transfer_count: Residual transfer count DW-3
@@ -537,6 +559,11 @@ 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; +u8 b_presrv_uspc_en; };/**
drivers/scsi/ufs/ufshcd.c +245 -3
316 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +14 -0
@@ -555,6 +555,13 @@ enum ufshcd_caps {* for userspace to control the power management. */ UFSHCD_CAP_RPM_AUTOSUSPEND =1 <<6 , + +/* +* This capability allows the host controller driver to turn-on +* WriteBooster, if the underlying device supports it and is +* provisioned to be used. This would increase the write performance. +*/ + UFSHCD_CAP_WB_EN = 1 << 7, };/**
@@ -727,6 +734,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 */
@@ -775,6 +784,11 @@ static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)return FIELD_GET (UFSHCI_AHIBERN8_TIMER_MASK , hba->ahit) ? true : false; } +static inline bool ufshcd_is_wb_allowed (struct ufs_hba *hba) +{ +return hba->caps &UFSHCD_CAP_WB_EN ; +} +#define ufshcd_writel (hba, val, reg) \ writel((val), (hba)->mmio_base + (reg))#define ufshcd_readl (hba, reg) \
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
RE: [PATCH v2 1/3] scsi: ufs: add write booster feature support
drivers/scsi/ufs/ufshcd.c static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) · line 5352
Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +4
-0+ +if (!hba->dev_info.b_presrv_uspc_en && + (avail_buf <=UFS_WB_10_PERCENT_BUF_REMAIN )) +return true;
If you are in reduced mode, but avail_buf > 10%, you still get into ufshcd_wb_presrv_usrspc_keep_vcc_on(), Which you don't want.
drivers/scsi/ufs/ufshcd.c static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) · line 5356
Quoted 4 lines
drivers/scsi/ufs/ufshcd.c +4
-0+ +return ufshcd_wb_presrv_usrspc_keep_vcc_on (hba, avail_buf); +} +
Thanks,
Avri
RE: [PATCH v2 1/3] scsi: ufs: add write booster feature support
In reply to Asutosh Dasdrivers/scsi/ufs/ufshcd.c static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up) · line 1190
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +6
-0+/* Enable Write Booster if we have scaled up else disable it */ +if (!ret) { +up_write (&hba->clk_scaling_lock); +ufshcd_wb_ctrl (hba, scale_up); +down_write (&hba->clk_scaling_lock); + }
Maybe add "goto out_unprepare" if ufshcd_scale_gear() in the clause above, Instead of checking !ret, to follow the function flow.
Thanks,
Avri
PATCH v2 2/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 | 5 +++++ 2 files changed, 43 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufs-sysfs.c +38 -1
@@ -276,6 +276,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_PRESRV_USRSPC_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,
@@ -304,6 +308,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, };
@@ -373,6 +381,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,
@@ -404,6 +418,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, };
@@ -616,7 +635,7 @@ static ssize_t _name##_show(struct device *dev, \pm_runtime_put_sync (hba->dev); \if (ret) \return -EINVAL ; \ -return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ +return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ } \static DEVICE_ATTR_RO (_name)
@@ -628,6 +647,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,
@@ -638,6 +660,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, };
@@ -679,6 +704,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,
@@ -697,6 +727,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, };
@@ -748,6 +782,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,
@@ -763,6 +799,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 +5 -0
@@ -314,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.
RE: [PATCH v2 2/3] ufs: sysfs: add sysfs entries for write booster
Quoted 6 lines
Adds unit, device, geometry descriptor sysfs entries. Adds flags sysfs entries for write booster.
Signed-off-by Asutosh Das <[email protected]>
PATCH v2 3/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.
Enable WB for Qualcomm platform.
--- drivers/scsi/ufs/ufs-qcom.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufs-qcom.c +1 -0
@@ -1071,6 +1071,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) hba->caps |=UFSHCD_CAP_CLK_GATING |UFSHCD_CAP_HIBERN8_WITH_CLK_GATING ; hba->caps |=UFSHCD_CAP_CLK_SCALING ; hba->caps |=UFSHCD_CAP_AUTO_BKOPS_SUSPEND ; + hba->caps |=UFSHCD_CAP_WB_EN ;if (host->hw_ver.major >=0x2 ) { host->caps = UFS_QCOM_CAP_QUNIPRO |
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
RE: [PATCH v2 3/3] ufs-qcom: scsi: configure write booster type
Quoted 5 lines
Configure the WriteBooster type to preserve user-space mode. This would ensure that no user-space capacity is reduced when write booster is enabled.
The above does no longer apply - leftover from previous patch?
Thanks,
Avri
Quoted 24 lines
Enable WB for Qualcomm platform.
Signed-off-by Asutosh Das <[email protected]>--- drivers/scsi/ufs/ufs-qcom.c | 1 + 1 file changed, 1 insertion(+)drivers/scsi/ufs/ufs-qcom.c +1
-0@@ -1071,6 +1071,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) hba->caps |=UFSHCD_CAP_CLK_GATING |UFSHCD_CAP_HIBERN8_WITH_CLK_GATING ; hba->caps |=UFSHCD_CAP_CLK_SCALING ; hba->caps |=UFSHCD_CAP_AUTO_BKOPS_SUSPEND ; + hba->caps |=UFSHCD_CAP_WB_EN ;if (host->hw_ver.major >= 0x2) { host->caps = UFS_QCOM_CAP_QUNIPRO |--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v3 1/3 scsi: ufs: add write booster feature support
In reply to Asutosh DasThe 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 | 252 +++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 14 +++ 3 files changed, 291 insertions(+), 6 deletions(-)
drivers/scsi/ufs/ufs.h +29 -2
@@ -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,9 +198,9 @@ 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_UNIT_DEF_SIZE =0x2D ,QUERY_DESC_INTERCONNECT_DEF_SIZE =0x06 ,QUERY_DESC_GEOMETRY_DEF_SIZE =0x48 ,QUERY_DESC_POWER_DEF_SIZE =0x62 ,
@@ -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,10 @@ 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_PRESRV_USRSPC_EN =0x53 , +DEVICE_DESC_PARAM_WB_TYPE =0x54 , + DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS = 0x55, };/* Interconnect descriptor parameters offsets in bytes*/
@@ -333,6 +345,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 +464,11 @@ 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 , +}; +/** * struct utp_cmd_rsp - Response UPIU structure * @residual_transfer_count: Residual transfer count DW-3
@@ -537,6 +559,11 @@ 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; +u8 b_presrv_uspc_en; };/**
drivers/scsi/ufs/ufshcd.c +248 -4
323 lines not on this page · raw message
drivers/scsi/ufs/ufshcd.h +14 -0
@@ -555,6 +555,13 @@ enum ufshcd_caps {* for userspace to control the power management. */ UFSHCD_CAP_RPM_AUTOSUSPEND =1 <<6 , + +/* +* This capability allows the host controller driver to turn-on +* WriteBooster, if the underlying device supports it and is +* provisioned to be used. This would increase the write performance. +*/ + UFSHCD_CAP_WB_EN = 1 << 7, };/**
@@ -727,6 +734,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 */
@@ -775,6 +784,11 @@ static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)return FIELD_GET (UFSHCI_AHIBERN8_TIMER_MASK , hba->ahit) ? true : false; } +static inline bool ufshcd_is_wb_allowed (struct ufs_hba *hba) +{ +return hba->caps &UFSHCD_CAP_WB_EN ; +} +#define ufshcd_writel (hba, val, reg) \ writel((val), (hba)->mmio_base + (reg))#define ufshcd_readl (hba, reg) \
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v3 2/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 | 5 +++++ 2 files changed, 43 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufs-sysfs.c +38 -1
@@ -276,6 +276,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_PRESRV_USRSPC_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,
@@ -304,6 +308,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, };
@@ -373,6 +381,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,
@@ -404,6 +418,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, };
@@ -616,7 +635,7 @@ static ssize_t _name##_show(struct device *dev, \pm_runtime_put_sync (hba->dev); \if (ret) \return -EINVAL ; \ -return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ +return sprintf (buf,"%s\n" , flag ?"true" :"false" ); \ } \static DEVICE_ATTR_RO (_name)
@@ -628,6 +647,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,
@@ -638,6 +660,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, };
@@ -679,6 +704,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,
@@ -697,6 +727,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, };
@@ -748,6 +782,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,
@@ -763,6 +799,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 +5 -0
@@ -314,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.
PATCH v3 3/3 ufs-qcom: scsi: configure write booster type
In reply to Asutosh DasEnable WriteBooster for Qualcomm platform.
--- drivers/scsi/ufs/ufs-qcom.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufs-qcom.c +1 -0
@@ -1071,6 +1071,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) hba->caps |=UFSHCD_CAP_CLK_GATING |UFSHCD_CAP_HIBERN8_WITH_CLK_GATING ; hba->caps |=UFSHCD_CAP_CLK_SCALING ; hba->caps |=UFSHCD_CAP_AUTO_BKOPS_SUSPEND ; + hba->caps |=UFSHCD_CAP_WB_EN ;if (host->hw_ver.major >=0x2 ) { host->caps = UFS_QCOM_CAP_QUNIPRO |
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Looks good.
Thanks,
Avri
Quoted 49 lines
v2 -> v3:
- Addressed Comments on refactoring
- Corrected the commit messagev1 -> v2:
- Refactor WriteBooster initialization, introduceufshcd_wb_probe()
- Refactorufshcd_wb_keep_vcc_on()and introduce a new functionufshcd_wb_presrv_usrspc_keep_vcc_on()
- Get the WriteBooster configuration by reading bWriteBoosterBufferPreserveUserSpaceEnRFC -> v1:
- Added platform capability for WriteBoosterRFC-:
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 | 8 ++ drivers/scsi/ufs/ufs-sysfs.c | 39 ++++++- drivers/scsi/ufs/ufs.h | 37 ++++++- drivers/scsi/ufs/ufshcd.c | 241 ++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufshcd.h | 43 ++++++++ 5 files changed, 362 insertions(+), 6 deletions(-)--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Martin K. Petersen
AppliedOn Wed, 8 Apr 2020 14:48:38 -0700, Asutosh Das wrote:
Applied to 5.8/scsi-queue, thanks!
[1/3] scsi: ufs: Add write booster feature support
https://git.kernel.org/mkp/scsi/c/3d17b9b5ab11 [2/3] scsi: ufs: sysfs: Add sysfs entries for write booster https://git.kernel.org/mkp/scsi/c/c14e7adf3a6a [3/3] scsi: ufs-qcom: Configure write booster type https://git.kernel.org/mkp/scsi/c/04ee8a01abf8
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering