ufs: sysfs: Add WB partial flush mode support
Subsystems (2)
PATCH 1/1 ufs: sysfs: Add WB partial flush mode support
Expose the following JEDEC UFS 4.1 Extended WriteBooster attributes and flags to sysfs to support FIFO and Pinned partial flush modes:
- wb_partial_flush_mode
- wb_max_fifo_size
- wb_cur_fifo_size
- wb_pinned_cur_size
- wb_pinned_avail_pct
- wb_pinned_cumulative_write_size
- wb_pinned_size
- wb_non_pinned_min_size
- wb_unpin_enable
Introduce UFS_ATTRIBUTE_RW and UFS_FLAG_RW to support writable attributes and flags.
Document the new entries under Documentation/ABI/testing/sysfs-driver-ufs.
--- Documentation/ABI/testing/sysfs-driver-ufs | 86 +++++++ drivers/ufs/core/ufs-sysfs.c | 258 ++++++++++++++++----- include/ufs/ufs.h | 9 + 3 files changed, 290 insertions(+), 63 deletions(-)
Documentation/ABI/testing/sysfs-driver-ufs +86 -0
@@ -1791,3 +1791,89 @@ Description: will be rejected. The attribute is read/write. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_partial_flush_mode +What: /sys/bus/platform/devices/*.ufs/attributes/wb_partial_flush_mode +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry controls Extended WriteBooster partial flush modes. + + ====== ============================== + 0 No partial flush + 1 FIFO (first-in-first-out) mode + 2 Pinned mode + Others Reserved + ====== ============================== + + The attribute is read-write. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_max_fifo_size +What: /sys/bus/platform/devices/*.ufs/attributes/wb_max_fifo_size +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry configures the maximum size in Allocation Units reserved for the + WriteBooster FIFO Buffer size. + The attribute is read-write. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_cur_fifo_size +What: /sys/bus/platform/devices/*.ufs/attributes/wb_cur_fifo_size +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry shows the current size in Allocation Units of the WriteBooster FIFO + Buffer size. + The attribute is read only. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_pinned_size +What: /sys/bus/platform/devices/*.ufs/attributes/wb_pinned_size +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry configures the allocated size in Allocation Units for the UFS + Pinned WriteBooster buffer. + The attribute is read-write. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_pinned_cur_size +What: /sys/bus/platform/devices/*.ufs/attributes/wb_pinned_cur_size +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry shows the current allocated size in Allocation Units for the UFS + Pinned WriteBooster buffer. + The attribute is read-only. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_pinned_avail_pct +What: /sys/bus/platform/devices/*.ufs/attributes/wb_pinned_avail_pct +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry shows the percentage of available space remaining in the + Pinned WriteBooster buffer. + The attribute is read-only. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_pinned_cumulative_write_size +What: /sys/bus/platform/devices/*.ufs/attributes/wb_pinned_cumulative_write_size +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry shows the total cumulative size of data written to the + Pinned WriteBooster buffer. + The attribute is read-only. + +What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_non_pinned_min_size +What: /sys/bus/platform/devices/*.ufs/attributes/wb_non_pinned_min_size +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry configures the minimum size in Allocation Units for the + Non-Pinned WriteBooster Buffer area when Pinned partial flush mode is active. + The attribute is read-write. + +What: /sys/bus/platform/drivers/ufshcd/*/flags/wb_unpin_enable +What: /sys/bus/platform/devices/*.ufs/flags/wb_unpin_enable +Date: June 2026 +Contact: Daniel Lee <[email protected]> +Description: This entry controls the Pinned WriteBooster unpin enable flag (fUnpinEn). + + ====== ============================================================== + 0 Unpin Disable: pinned data is not flushed by WriteBooster + Buffer flush operation. + 1 Unpin Enable: pinned data is flushed by WriteBooster + Buffer flush operation. + ====== ============================================================== + + The attribute is read-write.
drivers/ufs/core/ufs-sysfs.c +195 -63
318 lines not on this page · raw message
include/ufs/ufs.h +9 -0
@@ -146,6 +146,7 @@ enum flag_idn {QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8 =0x10 ,QUERY_FLAG_IDN_HPB_RESET =0x11 ,QUERY_FLAG_IDN_HPB_EN =0x12 , + QUERY_FLAG_IDN_WB_UNPIN_EN = 0x13, };/* Attribute idn for Query requests */
@@ -191,6 +192,14 @@ enum attr_idn {QUERY_ATTR_IDN_WB_BUF_RESIZE_HINT =0x3C ,QUERY_ATTR_IDN_WB_BUF_RESIZE_EN =0x3D ,QUERY_ATTR_IDN_WB_BUF_RESIZE_STATUS =0x3E , +QUERY_ATTR_IDN_WB_PFM =0x3F , +QUERY_ATTR_IDN_MAX_FIFO_SIZE_WB_PFM =0x40 , +QUERY_ATTR_IDN_CURRENT_FIFO_SIZE_WB_PFM =0x41 , +QUERY_ATTR_IDN_PINNED_WB_CURRENT_SIZE =0x42 , +QUERY_ATTR_IDN_PINNED_WB_AVAIL_PERC =0x43 , +QUERY_ATTR_IDN_PINNED_WB_CUMMULATIVE_WS =0x44 , +QUERY_ATTR_IDN_PINNED_WB_SIZE =0x45 , +QUERY_ATTR_IDN_NON_PINNED_WB_MIN_SIZE =0x46 ,QUERY_ATTR_IDN_TX_EQ_GN_SETTINGS =0x47 , QUERY_ATTR_IDN_TX_EQ_GN_SETTINGS_EXT = 0x48, };
Signature · 1 line
2.54.0.1032.g2f8565e1d1-goog
Bart Van Assche
reviewerQuoted 4 lines · Daniel Lee
Documentation/ABI/testing/sysfs-driver-ufs +4
-0+What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_partial_flush_mode +What: /sys/bus/platform/devices/*.ufs/attributes/wb_partial_flush_mode +Date: June 2026 +Contact: Daniel Lee <[email protected]>
Documentation/ABI/testing/sysfs-driver-ufs Description: · line 1808
Quoted 10 lines
Documentation/ABI/testing/sysfs-driver-ufs +10
-0+Description: This entry controls Extended WriteBooster partial flush modes. + + ====== ============================== + 0 No partial flush + 1 FIFO (first-in-first-out) mode + 2 Pinned mode + Others Reserved + ====== ============================== + + The attribute is read-write.
Please change this attribute such that it accepts and reports strings instead of numbers. This is more user-friendly and also will make shell scripts that read from or write into this sysfs attribute much easier to read. This will make this attribute follow the design philosophy of self-documenting interfaces.
drivers/ufs/core/ufs-sysfs.c static const struct attribute_group ufs_sysfs_string_descriptors_group = { · line 1541
Quoted 7 lines
drivers/ufs/core/ufs-sysfs.c +7
-0+static ssize_t ufs_sysfs_flag_show (struct device *dev, +struct device_attribute *attr,char *buf,enum flag_idn idn) +{ +bool flag; +u8 index =0 ; +int ret; +struct ufs_hba *hba =dev_get_drvdata (dev);
In new code, please order declarations from longest to shortest.
drivers/ufs/core/ufs-sysfs.c static const struct attribute_group ufs_sysfs_string_descriptors_group = { · line 1571
Quoted 8 lines
drivers/ufs/core/ufs-sysfs.c +8
-0+static ssize_t ufs_sysfs_flag_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count, +enum flag_idn idn) +{ +bool value; +u8 index =0 ; +int ret; +struct ufs_hba *hba =dev_get_drvdata (dev);
Also here, please order declarations from longest to shortest.
Thanks,
Bart.