* [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute
@ 2023-06-13 2:22 Lu Hongfei
2023-06-13 14:03 ` Bart Van Assche
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lu Hongfei @ 2023-06-13 2:22 UTC (permalink / raw)
To: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
Martin K. Petersen, Jinyoung Choi, Daniil Lunev, Lu Hongfei,
Bean Huo, Peter Wang, open list,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
Cc: opensource.kernel
There are three flags that control Write Booster Feature:
1. WB ON/OFF
2. WB Hibern Flush ON/OFF (implicitly)
3. WB Flush ON/OFF (explicit)
In the case of "Hibern Flush", one of the conditions for flush WB buffer is
that avail_wb_buff < wb_flush_threshold.
As we know, different users have different requirements for power
consumption and performance. Therefore, we need the ability to manually
set wb_flush_threshold, so that users can easily and flexibly adjust
the wb_flush_threshold value, thereby achieving a balance between power
consumption and performance.
So the sysfs attribute that controls this is necessary.
wb_flush_threshold represents the threshold for flushing WB buffer,
whose value expressed in unit of 10% granularity, such as '1'
representing 10%, '2' representing 20%, and so on.
Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
---
The modifications made compared to the previous version are as follows:
1. Optimize the description of wb_flush_threshold in sysfs documentation
to make the meaning clearer and more accurate
Documentation/ABI/testing/sysfs-driver-ufs | 11 ++++++++
drivers/ufs/core/ufs-sysfs.c | 33 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs
index 228aa43e14ed..d5f44fc5b9dc
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -1426,6 +1426,17 @@ Description: This entry shows the status of WriteBooster buffer flushing
If flushing is enabled, the device executes the flush
operation when the command queue is empty.
+What: /sys/bus/platform/drivers/ufshcd/*/wb_flush_threshold
+What: /sys/bus/platform/devices/*.ufs/wb_flush_threshold
+Date: June 2023
+Contact: Lu Hongfei <luhongfei@vivo.com>
+Description:
+ wb_flush_threshold represents the threshold for flushing WriteBooster buffer,
+ whose value expressed in unit of 10% granularity, such as '1' representing 10%,
+ '2' representing 20%, and so on.
+ If avail_wb_buff < wb_flush_threshold, it indicates that WriteBooster buffer needs to
+ be flushed, otherwise it is not necessary.
+
What: /sys/bus/platform/drivers/ufshcd/*/device_descriptor/hpb_version
What: /sys/bus/platform/devices/*.ufs/device_descriptor/hpb_version
Date: June 2021
diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index cdf3d5f2b77b..347207f4e8ee 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -298,6 +298,37 @@ static ssize_t enable_wb_buf_flush_store(struct device *dev,
return res < 0 ? res : count;
}
+static ssize_t wb_flush_threshold_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%u\n", hba->vps->wb_flush_threshold);
+}
+
+static ssize_t wb_flush_threshold_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+ unsigned int wb_flush_threshold;
+
+ if (kstrtouint(buf, 0, &wb_flush_threshold))
+ return -EINVAL;
+
+ /* The range of values for wb_flush_threshold is (0,10] */
+ if (wb_flush_threshold > UFS_WB_BUF_REMAIN_PERCENT(100) ||
+ wb_flush_threshold == 0) {
+ dev_err(dev, "The value of wb_flush_threshold is invalid!\n");
+ return -EINVAL;
+ }
+
+ hba->vps->wb_flush_threshold = wb_flush_threshold;
+
+ return count;
+}
+
static DEVICE_ATTR_RW(rpm_lvl);
static DEVICE_ATTR_RO(rpm_target_dev_state);
static DEVICE_ATTR_RO(rpm_target_link_state);
@@ -307,6 +338,7 @@ static DEVICE_ATTR_RO(spm_target_link_state);
static DEVICE_ATTR_RW(auto_hibern8);
static DEVICE_ATTR_RW(wb_on);
static DEVICE_ATTR_RW(enable_wb_buf_flush);
+static DEVICE_ATTR_RW(wb_flush_threshold);
static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
&dev_attr_rpm_lvl.attr,
@@ -318,6 +350,7 @@ static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
&dev_attr_auto_hibern8.attr,
&dev_attr_wb_on.attr,
&dev_attr_enable_wb_buf_flush.attr,
+ &dev_attr_wb_flush_threshold.attr,
NULL
};
--
2.39.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute
2023-06-13 2:22 [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute Lu Hongfei
@ 2023-06-13 14:03 ` Bart Van Assche
2023-06-15 1:51 ` Martin K. Petersen
2023-06-22 1:26 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2023-06-13 14:03 UTC (permalink / raw)
To: Lu Hongfei, Alim Akhtar, Avri Altman, James E.J. Bottomley,
Martin K. Petersen, Jinyoung Choi, Daniil Lunev, Bean Huo,
Peter Wang, open list,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
Cc: opensource.kernel
On 6/12/23 19:22, Lu Hongfei wrote:
> + /* The range of values for wb_flush_threshold is (0,10] */
> + if (wb_flush_threshold > UFS_WB_BUF_REMAIN_PERCENT(100) ||
> + wb_flush_threshold == 0) {
For future patches, please align split lines as is done elsewhere in the
kernel. This means aligning "wb_flush_threshold == 0" with
"wb_flush_threshold > ...". Anyway:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute
2023-06-13 2:22 [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute Lu Hongfei
2023-06-13 14:03 ` Bart Van Assche
@ 2023-06-15 1:51 ` Martin K. Petersen
2023-06-22 1:26 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-06-15 1:51 UTC (permalink / raw)
To: Lu Hongfei
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
Martin K. Petersen, Jinyoung Choi, Daniil Lunev, Bean Huo,
Peter Wang, open list,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
opensource.kernel
Lu,
> There are three flags that control Write Booster Feature:
Applied to 6.5/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute
2023-06-13 2:22 [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute Lu Hongfei
2023-06-13 14:03 ` Bart Van Assche
2023-06-15 1:51 ` Martin K. Petersen
@ 2023-06-22 1:26 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-06-22 1:26 UTC (permalink / raw)
To: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
Jinyoung Choi, Daniil Lunev, Bean Huo, Peter Wang, linux-kernel,
linux-scsi, Lu Hongfei
Cc: Martin K . Petersen, opensource.kernel
On Tue, 13 Jun 2023 10:22:34 +0800, Lu Hongfei wrote:
> There are three flags that control Write Booster Feature:
>
> 1. WB ON/OFF
> 2. WB Hibern Flush ON/OFF (implicitly)
> 3. WB Flush ON/OFF (explicit)
>
> In the case of "Hibern Flush", one of the conditions for flush WB buffer is
> that avail_wb_buff < wb_flush_threshold.
>
> [...]
Applied to 6.5/scsi-queue, thanks!
[1/1] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute
https://git.kernel.org/mkp/scsi/c/e3d55626cff3
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-22 1:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 2:22 [PATCH v5] scsi: ufs: wb: Add explicit flush_threshold sysfs attribute Lu Hongfei
2023-06-13 14:03 ` Bart Van Assche
2023-06-15 1:51 ` Martin K. Petersen
2023-06-22 1:26 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®