ufs: core: Add WB buffer resize support
Subsystems (2)
PATCH v4 1/1 ufs: core: Add WB buffer resize support
Support WB buffer resize function through sysfs, the host can obtain resize hint and resize status and enable the resize operation. To achieve this goals, three sysfs nodes have been added:
1. wb_toggle_buf_resize
2. wb_buf_resize_hint
3. wb_buf_resize_status
The detailed definition of the three nodes can be found in the sysfs documentation.
Changelog
===
v3 - > v4:
1.modify three attributes name and description in document 2.add enum wb_resize_en in ufs.h
3.modify function name and parameters in ufs-sysfs.c, ufshcd.h, ufshcd.c
v2 - > v3:
remove needless code:
drivers/ufs/core/ufs-sysfs.c:441:2:
index = ufshcd_wb_get_query_index(hba)
v1 - > v2:
remove unused variable "u8 index", drivers/ufs/core/ufs-sysfs.c:419:12: warning: variable 'index' set but not used.
v1
https://lore.kernel.org/all/[email protected]/ v2 https://lore.kernel.org/all/[email protected]/ v3 https://lore.kernel.org/all/[email protected]/
--- Documentation/ABI/testing/sysfs-driver-ufs | 51 ++++++++++++++++++++++ drivers/ufs/core/ufs-sysfs.c | 43 ++++++++++++++++++ drivers/ufs/core/ufshcd.c | 15 +++++++ include/ufs/ufs.h | 12 ++++- include/ufs/ufshcd.h | 1 + 5 files changed, 121 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-driver-ufs +51 -0
@@ -1559,3 +1559,54 @@ Description: Symbol - HCMID. This file shows the UFSHCD manufacturer id. The Manufacturer ID is defined by JEDEC in JEDEC-JEP106. The file is read only. + +What: /sys/bus/platform/drivers/ufshcd/*/wb_resize_enable +What: /sys/bus/platform/devices/*.ufs/wb_resize_enable +Date: Nov 2024 +Contact: Huan Tang <[email protected]> +Description: + The host can decrease or increase the WriteBooster Buffer size by setting + this attribute. + + ====== ====================================== + 01h Decrease WriteBooster Buffer Size + 02h Increase WriteBooster Buffer Size + Others Reserved + ====== ====================================== + + The attribute is write only. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_resize_hint +What: /sys/bus/platform/devices/*.ufs/attributes/wb_resize_hint +Date: Nov 2024 +Contact: Huan Tang <[email protected]> +Description: + wb_resize_hint indicates hint information about which type of resize for + WriteBooster Buffer is recommended by the device. + + ====== ====================================== + 00h Recommend keep the buffer size + 01h Recommend to decrease the buffer size + 02h Recommend to increase the buffer size + Others: Reserved + ====== ====================================== + + The attribute is read only. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_resize_status +What: /sys/bus/platform/devices/*.ufs/attributes/wb_resize_status +Date: Nov 2024 +Contact: Huan Tang <[email protected]> +Description: + The host can check the Resize operation status of the WriteBooster Buffer + by reading this attribute. + + ====== ======================================== + 00h Idle (resize operation is not issued) + 01h Resize operation in progress + 02h Resize operation completed successfully + 03h Resize operation general failure + Others Reserved + ====== ======================================== + + The attribute is read only.
drivers/ufs/core/ufs-sysfs.c +43 -0
73 lines not on this page · raw message
drivers/ufs/core/ufshcd.c +15 -0
@@ -6167,6 +6167,21 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba)return ufshcd_wb_presrv_usrspc_keep_vcc_on (hba, avail_buf); } +int ufshcd_wb_set_resize_en (struct ufs_hba *hba,enum wb_resize_en en) +{ +int ret; +u8 index; + + index =ufshcd_wb_get_query_index (hba); + ret =ufshcd_query_attr_retry (hba,UPIU_QUERY_OPCODE_WRITE_ATTR , +QUERY_ATTR_IDN_WB_BUF_RESIZE_EN , index,0 , &en); +if (ret) +dev_err (hba->dev,"%s: Enable WB buf resize operation failed %d\n" , + __func__, ret); + +return ret; +} +static void ufshcd_rpm_dev_flush_recheck_work (struct work_struct *work) { struct ufs_hba *hba = container_of(to_delayed_work(work),
include/ufs/ufs.h +11 -1
@@ -181,7 +181,10 @@ enum attr_idn {QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST =0x1E ,QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE =0x1F ,QUERY_ATTR_IDN_EXT_IID_EN =0x2A , - QUERY_ATTR_IDN_TIMESTAMP = 0x30 +QUERY_ATTR_IDN_TIMESTAMP =0x30 , +QUERY_ATTR_IDN_WB_BUF_RESIZE_HINT =0x3C , +QUERY_ATTR_IDN_WB_BUF_RESIZE_EN =0x3D , + QUERY_ATTR_IDN_WB_BUF_RESIZE_STATUS = 0x3E, };/* Descriptor idn for Query requests */
@@ -455,6 +458,13 @@ enum ufs_ref_clk_freq { REF_CLK_FREQ_INVAL = -1, }; +/* bWriteBoosterBufferResizeEn attribute */ +enum wb_resize_en { +WB_RESIZE_EN_IDLE =0 , +WB_RESIZE_EN_DECREASE =1 , +WB_RESIZE_EN_INCREASE =2 , +}; +/* Query response result code */ enum {QUERY_RESULT_SUCCESS =0x00 ,
include/ufs/ufshcd.h +1 -0
@@ -1454,6 +1454,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r struct scatterlist *sg_list, enum dma_data_direction dir);int ufshcd_wb_toggle (struct ufs_hba *hba,bool enable);int ufshcd_wb_toggle_buf_flush (struct ufs_hba *hba,bool enable); +int ufshcd_wb_set_resize_en (struct ufs_hba *hba,enum wb_resize_en en);int ufshcd_suspend_prepare (struct device *dev);int __ufshcd_suspend_prepare (struct device *dev,bool rpm_ok_for_spm);void ufshcd_resume_complete (struct device *dev);
Signature · 1 line
2.39.0