lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230911055810.879-4-luhongfei@vivo.com>
Date:   Mon, 11 Sep 2023 13:57:08 +0800
From:   Lu Hongfei <luhongfei@...o.com>
To:     Alim Akhtar <alim.akhtar@...sung.com>,
        Avri Altman <avri.altman@....com>,
        Bart Van Assche <bvanassche@....org>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Lu Hongfei <luhongfei@...o.com>, Bean Huo <beanhuo@...ron.com>,
        Can Guo <quic_cang@...cinc.com>,
        Arthur Simchaev <arthur.simchaev@....com>,
        Stanley Chu <stanley.chu@...iatek.com>,
        Manivannan Sadhasivam <mani@...nel.org>,
        Asutosh Das <quic_asutoshd@...cinc.com>,
        "Bao D. Nguyen" <quic_nguyenb@...cinc.com>,
        Po-Wen Kao <powen.kao@...iatek.com>,
        Eric Biggers <ebiggers@...gle.com>,
        Keoseong Park <keosung.park@...sung.com>,
        linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org
Cc:     opensource.kernel@...o.com
Subject: [PATCH v3 3/3] scsi: ufs: core: Add sysfs attributes to get the hint information and status of WB buffer resize

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@...o.com>
---
 Documentation/ABI/testing/sysfs-driver-ufs | 35 ++++++++++++++++++++
 drivers/ufs/core/ufs-sysfs.c               | 38 ++++++++++++++++++++++
 2 files changed, 73 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs
index b8bd7e844cb0..4b03f4b8cd49 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -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@...o.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@...o.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@...omium.org>
 What:		/sys/bus/platform/drivers/ufshcd/*/capabilities/
 What:		/sys/bus/platform/devices/*.ufs/capabilities/
diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index c14da6770316..e416b9802ad3 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -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
 };
 
-- 
2.39.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ