[RESEND PATCH 2/4] scsi:ufs:add File-Based Optimization descriptor

Jiaming Li posted 4 patches 3 years, 5 months ago
[RESEND PATCH 2/4] scsi:ufs:add File-Based Optimization descriptor
Posted by Jiaming Li 3 years, 5 months ago
From: lijiaming3 <lijiaming3@xiaomi.com>

The full information about the descriptor could be found
at UFS specifications - FBO extension.

Signed-off-by: lijiaming3 <lijiaming3@xiaomi.com>
---
 Documentation/ABI/testing/sysfs-driver-ufs | 65 ++++++++++++++++++++++
 drivers/ufs/core/ufs-sysfs.c               | 26 +++++++++
 include/ufs/ufs.h                          | 13 +++++
 3 files changed, 104 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs
index 228aa43e14ed..63daccbf7a8d 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -1710,3 +1710,68 @@ Contact:	Avri Altman <avri.altman@wdc.com>
 Description:	In host control mode the host is the originator of map requests.
 		To avoid flooding the device with map requests, use a simple throttling
 		mechanism that limits the number of inflight map requests.
+
+What:		/sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_version
+What:		/sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_version
+Date:		November 2022
+Contact:	li jiaming <lijiaming3@xiaomi.com>
+Description:	This file shows the version of UFS file-based optimization. This
+		is one of the UFS fbo descriptor parameters. The full information about
+		the descriptor could be found at UFS specifications - FBO extension.
+
+		The file is read only.
+
+What:		/sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_rec_lrs
+What:		/sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_rec_lrs
+Date:		November 2022
+Contact:	li jiaming <lijiaming3@xiaomi.com>
+Description:	This file shows the recommended LBA range size of UFS file-based
+		optimization to be used by the host. This is one of the UFS fbo descriptor
+		parameters. The full information about the descriptor could be found at UFS
+		specifications - FBO extension.
+
+		The file is read only.
+
+What:		/sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_max_lrs
+What:		/sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_max_lrs
+Date:		November 2022
+Contact:	li jiaming <lijiaming3@xiaomi.com>
+Description:	This file shows the max LBA range size of UFS file-based
+		optimization to be used by the host. This is one of the UFS fbo descriptor
+		parameters. The full information about the descriptor could be found at UFS
+		specifications - FBO extension.
+
+		The file is read only.
+
+What:		/sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_min_lrs
+What:		/sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_min_lrs
+Date:		November 2022
+Contact:	li jiaming <lijiaming3@xiaomi.com>
+Description:	This file shows the min LBA range size of UFS file-based
+		optimization to be used by the host. This is one of the UFS fbo descriptor
+		parameters. The full information about the descriptor could be found at UFS
+		specifications - FBO extension.
+
+		The file is read only.
+
+What:		/sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_max_lrc
+What:		/sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_max_lrc
+Date:		November 2022
+Contact:	li jiaming <lijiaming3@xiaomi.com>
+Description:	This file shows the max number of LBA ranges supported by read/write
+		buffer command of UFS file-based optimization. This is one of the UFS fbo
+		descriptor parameters. The full information about the descriptor could be
+		found at UFS specifications - FBO extension.
+
+		The file is read only.
+
+What:		/sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_lra
+What:		/sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_lra
+Date:		November 2022
+Contact:	li jiaming <lijiaming3@xiaomi.com>
+Description:	This file shows the alignment requirement of UFS file-based
+		optimization. This is one of the UFS fbo descriptor parameters. The
+		full information about the descriptor could be found at UFS
+		specifications - FBO extension.
+
+		The file is read only.
diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index 53aea56d1de1..006d99b15be0 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -871,6 +871,31 @@ static const struct attribute_group ufs_sysfs_health_descriptor_group = {
 	.attrs = ufs_sysfs_health_descriptor,
 };
 
+#define UFS_FBO_DESC_PARAM(_name, _uname, _size)			\
+	UFS_DESC_PARAM(_name, _uname, FBO, _size)
+
+UFS_FBO_DESC_PARAM(fbo_version, _VERSION, 2);
+UFS_FBO_DESC_PARAM(fbo_rec_lrs, _REC_LBA_RANGE_SIZE, 4);
+UFS_FBO_DESC_PARAM(fbo_max_lrs, _MAX_LBA_RANGE_SIZE, 4);
+UFS_FBO_DESC_PARAM(fbo_min_lrs, _MIN_LBA_RANGE_SIZE, 4);
+UFS_FBO_DESC_PARAM(fbo_max_lrc, _MAX_LBA_RANGE_CONUT, 1);
+UFS_FBO_DESC_PARAM(fbo_lra, _MAX_LBA_RANGE_ALIGNMENT, 2);
+
+static struct attribute *ufs_sysfs_fbo_descriptor[] = {
+	&dev_attr_fbo_version.attr,
+	&dev_attr_fbo_rec_lrs.attr,
+	&dev_attr_fbo_max_lrs.attr,
+	&dev_attr_fbo_min_lrs.attr,
+	&dev_attr_fbo_max_lrc.attr,
+	&dev_attr_fbo_lra.attr,
+	NULL,
+};
+
+static const struct attribute_group ufs_sysfs_fbo_descriptor_group = {
+	.name = "fbo_descriptor",
+	.attrs = ufs_sysfs_fbo_descriptor,
+};
+
 #define UFS_POWER_DESC_PARAM(_name, _uname, _index)			\
 static ssize_t _name##_index##_show(struct device *dev,			\
 	struct device_attribute *attr, char *buf)			\
@@ -1220,6 +1245,7 @@ static const struct attribute_group *ufs_sysfs_groups[] = {
 	&ufs_sysfs_interconnect_descriptor_group,
 	&ufs_sysfs_geometry_descriptor_group,
 	&ufs_sysfs_health_descriptor_group,
+	&ufs_sysfs_fbo_descriptor_group,
 	&ufs_sysfs_power_descriptor_group,
 	&ufs_sysfs_string_descriptors_group,
 	&ufs_sysfs_flags_group,
diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h
index 1bba3fead2ce..c3fd954ce005 100644
--- a/include/ufs/ufs.h
+++ b/include/ufs/ufs.h
@@ -179,6 +179,7 @@ enum desc_idn {
 	QUERY_DESC_IDN_GEOMETRY		= 0x7,
 	QUERY_DESC_IDN_POWER		= 0x8,
 	QUERY_DESC_IDN_HEALTH           = 0x9,
+	QUERY_DESC_IDN_FBO		= 0xA,
 	QUERY_DESC_IDN_MAX,
 };
 
@@ -319,6 +320,17 @@ enum health_desc_param {
 	HEALTH_DESC_PARAM_LIFE_TIME_EST_B	= 0x4,
 };
 
+/* File-based Optimization descriptor parameters offsets in bytes */
+enum fbo_desc_param {
+	FBO_DESC_PARAM_LEN			= 0x0,
+	FBO_DESC_PARAM_VERSION			= 0x1,
+	FBO_DESC_PARAM_REC_LBA_RANGE_SIZE	= 0x3,
+	FBO_DESC_PARAM_MAX_LBA_RANGE_SIZE	= 0x7,
+	FBO_DESC_PARAM_MIN_LBA_RANGE_SIZE	= 0xB,
+	FBO_DESC_PARAM_MAX_LBA_RANGE_CONUT	= 0xF,
+	FBO_DESC_PARAM_MAX_LBA_RANGE_ALIGNMENT	= 0x10,
+};
+
 /* WriteBooster buffer mode */
 enum {
 	WB_BUF_MODE_LU_DEDICATED	= 0x0,
@@ -352,6 +364,7 @@ enum {
 	UFS_DEV_EXT_TEMP_NOTIF		= BIT(6),
 	UFS_DEV_HPB_SUPPORT		= BIT(7),
 	UFS_DEV_WRITE_BOOSTER_SUP	= BIT(8),
+	UFS_DEV_FBO_SUP			= BIT(17),
 };
 #define UFS_DEV_HPB_SUPPORT_VERSION		0x310
 
-- 
2.38.1
RE: [RESEND PATCH 2/4] scsi:ufs:add File-Based Optimization descriptor
Posted by Avri Altman 3 years, 5 months ago
> From: lijiaming3 <lijiaming3@xiaomi.com>
> 
> The full information about the descriptor could be found at UFS
> specifications - FBO extension.
> 
> Signed-off-by: lijiaming3 <lijiaming3@xiaomi.com>
For some reason there are spaces missing in the patch header: scsi: ufs: Add....
Other than that:
Reviewed-by: Avri Altman <avri.altman@wdc.com>

> ---
>  Documentation/ABI/testing/sysfs-driver-ufs | 65 ++++++++++++++++++++++
>  drivers/ufs/core/ufs-sysfs.c               | 26 +++++++++
>  include/ufs/ufs.h                          | 13 +++++
>  3 files changed, 104 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-ufs
> b/Documentation/ABI/testing/sysfs-driver-ufs
> index 228aa43e14ed..63daccbf7a8d 100644
> --- a/Documentation/ABI/testing/sysfs-driver-ufs
> +++ b/Documentation/ABI/testing/sysfs-driver-ufs
> @@ -1710,3 +1710,68 @@ Contact: Avri Altman <avri.altman@wdc.com>
>  Description:   In host control mode the host is the originator of map
> requests.
>                 To avoid flooding the device with map requests, use a simple
> throttling
>                 mechanism that limits the number of inflight map requests.
> +
> +What:
> /sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_version
> +What:          /sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_version
> +Date:          November 2022
> +Contact:       li jiaming <lijiaming3@xiaomi.com>
> +Description:   This file shows the version of UFS file-based optimization. This
> +               is one of the UFS fbo descriptor parameters. The full information
> about
> +               the descriptor could be found at UFS specifications - FBO extension.
> +
> +               The file is read only.
> +
> +What:          /sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_rec_lrs
> +What:          /sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_rec_lrs
> +Date:          November 2022
> +Contact:       li jiaming <lijiaming3@xiaomi.com>
> +Description:   This file shows the recommended LBA range size of UFS file-
> based
> +               optimization to be used by the host. This is one of the UFS fbo
> descriptor
> +               parameters. The full information about the descriptor could be
> found at UFS
> +               specifications - FBO extension.
> +
> +               The file is read only.
> +
> +What:
> /sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_max_lrs
> +What:          /sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_max_lrs
> +Date:          November 2022
> +Contact:       li jiaming <lijiaming3@xiaomi.com>
> +Description:   This file shows the max LBA range size of UFS file-based
> +               optimization to be used by the host. This is one of the UFS fbo
> descriptor
> +               parameters. The full information about the descriptor could be
> found at UFS
> +               specifications - FBO extension.
> +
> +               The file is read only.
> +
> +What:
> /sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_min_lrs
> +What:          /sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_min_lrs
> +Date:          November 2022
> +Contact:       li jiaming <lijiaming3@xiaomi.com>
> +Description:   This file shows the min LBA range size of UFS file-based
> +               optimization to be used by the host. This is one of the UFS fbo
> descriptor
> +               parameters. The full information about the descriptor could be
> found at UFS
> +               specifications - FBO extension.
> +
> +               The file is read only.
> +
> +What:
> /sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_max_lrc
> +What:          /sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_max_lrc
> +Date:          November 2022
> +Contact:       li jiaming <lijiaming3@xiaomi.com>
> +Description:   This file shows the max number of LBA ranges supported by
> read/write
> +               buffer command of UFS file-based optimization. This is one of the
> UFS fbo
> +               descriptor parameters. The full information about the descriptor
> could be
> +               found at UFS specifications - FBO extension.
> +
> +               The file is read only.
> +
> +What:          /sys/bus/platform/drivers/ufshcd/*/fbo_descriptor/fbo_lra
> +What:          /sys/bus/platform/devices/*.ufs/fbo_descriptor/fbo_lra
> +Date:          November 2022
> +Contact:       li jiaming <lijiaming3@xiaomi.com>
> +Description:   This file shows the alignment requirement of UFS file-based
> +               optimization. This is one of the UFS fbo descriptor parameters. The
> +               full information about the descriptor could be found at UFS
> +               specifications - FBO extension.
> +
> +               The file is read only.
> diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index
> 53aea56d1de1..006d99b15be0 100644
> --- a/drivers/ufs/core/ufs-sysfs.c
> +++ b/drivers/ufs/core/ufs-sysfs.c
> @@ -871,6 +871,31 @@ static const struct attribute_group
> ufs_sysfs_health_descriptor_group = {
>         .attrs = ufs_sysfs_health_descriptor,  };
> 
> +#define UFS_FBO_DESC_PARAM(_name, _uname, _size)                       \
> +       UFS_DESC_PARAM(_name, _uname, FBO, _size)
> +
> +UFS_FBO_DESC_PARAM(fbo_version, _VERSION, 2);
> +UFS_FBO_DESC_PARAM(fbo_rec_lrs, _REC_LBA_RANGE_SIZE, 4);
> +UFS_FBO_DESC_PARAM(fbo_max_lrs, _MAX_LBA_RANGE_SIZE, 4);
> +UFS_FBO_DESC_PARAM(fbo_min_lrs, _MIN_LBA_RANGE_SIZE, 4);
> +UFS_FBO_DESC_PARAM(fbo_max_lrc, _MAX_LBA_RANGE_CONUT, 1);
> +UFS_FBO_DESC_PARAM(fbo_lra, _MAX_LBA_RANGE_ALIGNMENT, 2);
> +
> +static struct attribute *ufs_sysfs_fbo_descriptor[] = {
> +       &dev_attr_fbo_version.attr,
> +       &dev_attr_fbo_rec_lrs.attr,
> +       &dev_attr_fbo_max_lrs.attr,
> +       &dev_attr_fbo_min_lrs.attr,
> +       &dev_attr_fbo_max_lrc.attr,
> +       &dev_attr_fbo_lra.attr,
> +       NULL,
> +};
> +
> +static const struct attribute_group ufs_sysfs_fbo_descriptor_group = {
> +       .name = "fbo_descriptor",
> +       .attrs = ufs_sysfs_fbo_descriptor, };
> +
>  #define UFS_POWER_DESC_PARAM(_name, _uname, _index)                    \
>  static ssize_t _name##_index##_show(struct device *dev,                        \
>         struct device_attribute *attr, char *buf)                       \
> @@ -1220,6 +1245,7 @@ static const struct attribute_group
> *ufs_sysfs_groups[] = {
>         &ufs_sysfs_interconnect_descriptor_group,
>         &ufs_sysfs_geometry_descriptor_group,
>         &ufs_sysfs_health_descriptor_group,
> +       &ufs_sysfs_fbo_descriptor_group,
>         &ufs_sysfs_power_descriptor_group,
>         &ufs_sysfs_string_descriptors_group,
>         &ufs_sysfs_flags_group,
> diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h index
> 1bba3fead2ce..c3fd954ce005 100644
> --- a/include/ufs/ufs.h
> +++ b/include/ufs/ufs.h
> @@ -179,6 +179,7 @@ enum desc_idn {
>         QUERY_DESC_IDN_GEOMETRY         = 0x7,
>         QUERY_DESC_IDN_POWER            = 0x8,
>         QUERY_DESC_IDN_HEALTH           = 0x9,
> +       QUERY_DESC_IDN_FBO              = 0xA,
>         QUERY_DESC_IDN_MAX,
>  };
> 
> @@ -319,6 +320,17 @@ enum health_desc_param {
>         HEALTH_DESC_PARAM_LIFE_TIME_EST_B       = 0x4,
>  };
> 
> +/* File-based Optimization descriptor parameters offsets in bytes */
> +enum fbo_desc_param {
> +       FBO_DESC_PARAM_LEN                      = 0x0,
> +       FBO_DESC_PARAM_VERSION                  = 0x1,
> +       FBO_DESC_PARAM_REC_LBA_RANGE_SIZE       = 0x3,
> +       FBO_DESC_PARAM_MAX_LBA_RANGE_SIZE       = 0x7,
> +       FBO_DESC_PARAM_MIN_LBA_RANGE_SIZE       = 0xB,
> +       FBO_DESC_PARAM_MAX_LBA_RANGE_CONUT      = 0xF,
> +       FBO_DESC_PARAM_MAX_LBA_RANGE_ALIGNMENT  = 0x10, };
> +
>  /* WriteBooster buffer mode */
>  enum {
>         WB_BUF_MODE_LU_DEDICATED        = 0x0,
> @@ -352,6 +364,7 @@ enum {
>         UFS_DEV_EXT_TEMP_NOTIF          = BIT(6),
>         UFS_DEV_HPB_SUPPORT             = BIT(7),
>         UFS_DEV_WRITE_BOOSTER_SUP       = BIT(8),
> +       UFS_DEV_FBO_SUP                 = BIT(17),
>  };
>  #define UFS_DEV_HPB_SUPPORT_VERSION            0x310
> 
> --
> 2.38.1