Skip to contentSkip to conversation

ufs: sysfs: Add WB partial flush mode support

PATCH New Daniel Lee 1 participant 1 message Nov 17

Subsystems (2)
lore
Share & tools
lore

Daniel Lee

author
#0 lore raw

PATCH v4 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.

Assisted-by Gemini:gemini-3.1

---
v4:
- Update ABI documentation (Date, units, granularity, and value formats).
- Use index 0 for device-level (Type "D") WB attributes and flags.
- Support 64-bit attributes in ufs_sysfs_attr_store().
- Check Extended WB capability bits and return -EOPNOTSUPP if unsupported.
- Fix QUERY_ATTR_IDN_PINNED_WB_CUMULATIVE_WS spelling.
v3:
- Fold ufs_wb_pfm_to_string() into wb_partial_flush_mode_show().
- Propagate actual error codes for non-OCS error (ret < 0), while keeping -EINVAL for OCS errors (ret > 0).
- Clean up blank lines.
v2:
- Change wb_partial_flush_mode attribute to accept and report strings instead of numbers for better usability.
- Order local variable declarations from longest to shortest in new functions.

 Documentation/ABI/testing/sysfs-driver-ufs |  89 +++++
 drivers/ufs/core/ufs-sysfs.c               | 384 +++++++++++++++++----
 include/ufs/ufs.h                          |  19 +
 3 files changed, 431 insertions(+), 61 deletions(-)
Documentation/ABI/testing/sysfs-driver-ufs +89 -0
index 3c422aac7..caa11276c 100644
@@ -1791,3 +1791,92 @@ 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:		November 2026
+Contact:	Daniel Lee <[email protected]>
+Description:	This entry controls Extended WriteBooster partial flush modes.
+
+		======  ==============================
+		none    No partial flush
+		fifo    FIFO mode
+		pinned  Pinned mode
+		======  ==============================
+
+		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:		November 2026
+Contact:	Daniel Lee <[email protected]>
+Description:	This entry configures the maximum size in Allocation Units reserved for the
+		WriteBooster FIFO Buffer.
+		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:		November 2026
+Contact:	Daniel Lee <[email protected]>
+Description:	This entry shows the current size in Allocation Units of the WriteBooster FIFO
+		Buffer.
+		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:		November 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:		November 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:		November 2026
+Contact:	Daniel Lee <[email protected]>
+Description:	This entry shows the percentage of available space remaining in the
+		Pinned WriteBooster buffer in 10% granularity (0x0: 0%,
+		0x1..0x9: 10%..90%, 0xA: 100%).
+		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:		November 2026
+Contact:	Daniel Lee <[email protected]>
+Description:	This entry shows the total cumulative size of data written to the
+		Pinned WriteBooster buffer in units of 10 MB (saturates at
+		0xFFFFFFFF).
+		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:		November 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:		November 2026
+Contact:	Daniel Lee <[email protected]>
+Description:	This entry controls the Pinned WriteBooster unpin enable flag (fUnpinEn).
+		Reading returns "false" or "true". Writing accepts standard
+		kstrtobool() strings (e.g. 0/1, false/true, n/y, off/on).
+
+		=====  ==============================================================
+		false  Unpin Disable: pinned data is not flushed by WriteBooster
+		       Buffer flush operation.
+		true   Unpin Enable: pinned data is flushed by WriteBooster
+		       Buffer flush operation.
+		=====  ==============================================================
+
+		The attribute is read-write.
drivers/ufs/core/ufs-sysfs.c +323 -61

446 lines not on this page · raw message

include/ufs/ufs.h +19 -0
index b0207e694..49534bb9d 100644
@@ -151,6 +151,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 */
@@ -196,6 +197,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_CUMULATIVE_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,
 };
@@ -404,6 +413,16 @@ enum {
 /* Possible values for wExtendedWriteBoosterSupport */
 enum {
 	UFS_DEV_WB_BUF_RESIZE	= BIT(0),
+	UFS_DEV_WB_FIFO_PFM	= BIT(1),
+	UFS_DEV_WB_PINNED_PFM	= BIT(2),
+};
+
+/* Possible values for bWriteBoosterBufferPartialFlushMode */
+enum wb_partial_flush_mode {
+	WB_PARTIAL_FLUSH_NONE		= 0,
+	WB_PARTIAL_FLUSH_FIFO		= 1,
+	WB_PARTIAL_FLUSH_PINNED		= 2,
+	NUM_WB_PARTIAL_FLUSH_MODES	= 3,
 };
 
 /* Possible values for dExtendedUFSFeaturesSupport */
Signature · 1 line
2.56.0.611.g1030f0b940-goog