public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiaming Li <lijiaming3@xiaomi.corp-partner.google.com>
To: alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	lijiaming3 <lijiaming3@xiaomi.com>
Subject: [RESEND PATCH 2/4] scsi:ufs:add File-Based Optimization descriptor
Date: Wed,  2 Nov 2022 13:30:56 +0800	[thread overview]
Message-ID: <20221102053058.21021-3-lijiaming3@xiaomi.corp-partner.google.com> (raw)
In-Reply-To: <20221102053058.21021-1-lijiaming3@xiaomi.corp-partner.google.com>

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


  parent reply	other threads:[~2022-11-02  5:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02  5:30 [RESEND PATCH 0/4] Implement File-Based optimization functionality Jiaming Li
2022-11-02  5:30 ` [RESEND PATCH 1/4] scsi:ufs:remove sanity check Jiaming Li
2022-11-02  7:23   ` Avri Altman
2022-11-02  5:30 ` Jiaming Li [this message]
2022-11-02  7:46   ` [RESEND PATCH 2/4] scsi:ufs:add File-Based Optimization descriptor Avri Altman
2022-11-02  5:30 ` [RESEND PATCH 3/4] scsi:ufs:add FBO module Jiaming Li
2022-11-02  8:11   ` Avri Altman
2022-11-14 21:21   ` kernel test robot
2022-11-02  5:30 ` [RESEND PATCH 4/4] scsi:ufs:add fbo functionality Jiaming Li
2022-11-02  8:53   ` Avri Altman
2022-11-02 20:26   ` kernel test robot
2022-11-02  8:47 ` [RESEND PATCH 0/4] Implement File-Based optimization functionality Christoph Hellwig
2022-11-03  6:11   ` Juhyung Park
2022-11-04 12:37     ` Matias Bjørling
2022-11-05  5:22       ` Juhyung Park
2022-11-09 12:31     ` Christoph Hellwig
2022-11-02 15:24 ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102053058.21021-3-lijiaming3@xiaomi.corp-partner.google.com \
    --to=lijiaming3@xiaomi.corp-partner.google.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=lijiaming3@xiaomi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox