@@ -1454,6 +1454,41 @@ Description:
The file is write only.
+What: /sys/bus/platform/drivers/ufshcd/*/wb_buf_resize_hint
+What: /sys/bus/platform/devices/*.ufs/wb_buf_resize_hint
+Date: Sept 2023
+Contact: Lu Hongfei <luhongfei@vivo.com>
+Description:
+ wb_buf_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 file is read only.
+
+What: /sys/bus/platform/drivers/ufshcd/*/wb_buf_resize_status
+What: /sys/bus/platform/devices/*.ufs/wb_buf_resize_status
+Date: Sept 2023
+Contact: Lu Hongfei <luhongfei@vivo.com>
+Description:
+ The host can check the Resize operation status of the WriteBooster Buffer
+ by reading this file.
+
+ ====== ========================================
+ 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 file is read only.
+
Contact: Daniil Lunev <dlunev@chromium.org>
What: /sys/bus/platform/drivers/ufshcd/*/capabilities/
What: /sys/bus/platform/devices/*.ufs/capabilities/
@@ -359,6 +359,40 @@ static ssize_t wb_buf_resize_control_store(struct device *dev,
return count;
}
+static ssize_t wb_buf_resize_hint_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+ u32 value;
+ u8 index = ufshcd_wb_get_query_index(hba);
+
+ if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
+ QUERY_ATTR_IDN_WB_BUF_RESIZE_HINT, index, 0, &value)) {
+ dev_err(hba->dev, "Read WB Buffer Resize Hint info failed\n");
+ return -EINVAL;
+ }
+
+ return sysfs_emit(buf, "%u\n", value);
+}
+
+static ssize_t wb_buf_resize_status_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+ u32 value;
+ u8 index = ufshcd_wb_get_query_index(hba);
+
+ if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
+ QUERY_ATTR_IDN_WB_BUF_RESIZE_STATUS, index, 0, &value)) {
+ dev_err(hba->dev, "Read WB Buffer Resize Status info failed\n");
+ return -EINVAL;
+ }
+
+ return sysfs_emit(buf, "%u\n", value);
+}
+
static DEVICE_ATTR_RW(rpm_lvl);
static DEVICE_ATTR_RO(rpm_target_dev_state);
static DEVICE_ATTR_RO(rpm_target_link_state);
@@ -370,6 +404,8 @@ static DEVICE_ATTR_RW(wb_on);
static DEVICE_ATTR_RW(enable_wb_buf_flush);
static DEVICE_ATTR_RW(wb_flush_threshold);
static DEVICE_ATTR_WO(wb_buf_resize_control);
+static DEVICE_ATTR_RO(wb_buf_resize_hint);
+static DEVICE_ATTR_RO(wb_buf_resize_status);
static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
&dev_attr_rpm_lvl.attr,
@@ -383,6 +419,8 @@ static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
&dev_attr_enable_wb_buf_flush.attr,
&dev_attr_wb_flush_threshold.attr,
&dev_attr_wb_buf_resize_control.attr,
+ &dev_attr_wb_buf_resize_hint.attr,
+ &dev_attr_wb_buf_resize_status.attr,
NULL
};
The host can get the hint information and status of WB buffer resize through sysfs. To achieve this goal, two sysfs nodes have been added: 1. wb_buf_resize_hint 2. wb_buf_resize_status The host can read wb_buf_resize_hint, obtain the hint information about which type of resize for wb buffer, and enable wb buffer resize based on the hint information. Considering that this process may take a long time, the host can confirm the resize status by reading wb_buf_resize_status. The detailed definition of the two nodes can be found in the sysfs documentation. Signed-off-by: Lu Hongfei <luhongfei@vivo.com> --- Documentation/ABI/testing/sysfs-driver-ufs | 35 ++++++++++++++++++++ drivers/ufs/core/ufs-sysfs.c | 38 ++++++++++++++++++++++ 2 files changed, 73 insertions(+)