All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ufs: core: print capabilities in controller's sysfs node
@ 2022-07-28 23:05 Daniil Lunev
  2022-07-28 23:23 ` Bart Van Assche
  0 siblings, 1 reply; 4+ messages in thread
From: Daniil Lunev @ 2022-07-28 23:05 UTC (permalink / raw)
  To: Adrian Hunter, Bart Van Assche, Greg Kroah-Hartman
  Cc: Daniil Lunev, Alim Akhtar, Avri Altman, Bean Huo, Daejun Park,
	James E.J. Bottomley, Martin K. Petersen, Mauro Carvalho Chehab,
	Sohaib Mohamed, Stanley Chu, linux-kernel, linux-scsi

Allows userspace to check supported by the controller/device
functionality, e.g. write booster.

Signed-off-by: Daniil Lunev <dlunev@chromium.org>

---

Changes in v2:
* Add documentation entry for the new sysfs node.

 Documentation/ABI/testing/sysfs-driver-ufs |  9 +++++++++
 drivers/ufs/core/ufs-sysfs.c               | 10 ++++++++++
 2 files changed, 19 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs
index 6b248abb1bd71..97e42e4763eaf 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -1591,6 +1591,15 @@ Description:	This entry shows the status of HPB.
 
 		The file is read only.
 
+What:		/sys/bus/platform/drivers/ufshcd/*/caps
+What:		/sys/bus/platform/devices/*.ufs/caps
+Date:		July 2022
+Contact:	Daniil Lunev <dlunev@chromium.org>
+Description:	Read-only attribute. Enabled capabilities of the UFS driver. The
+		enabled capabilities are determined by what is supported by the
+		host controller and the UFS device.
+		Format: 0x%08llx
+
 What:		/sys/class/scsi_device/*/device/hpb_param_sysfs/activation_thld
 Date:		February 2021
 Contact:	Avri Altman <avri.altman@wdc.com>
diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index 0a088b47d5570..b0c294c367519 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -254,6 +254,14 @@ static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr,
 	return res < 0 ? res : count;
 }
 
+static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
+			 char *buf)
+{
+	struct ufs_hba *hba = dev_get_drvdata(dev);
+
+	return sysfs_emit(buf, "0x%08llx\n", hba->caps);
+}
+
 static DEVICE_ATTR_RW(rpm_lvl);
 static DEVICE_ATTR_RO(rpm_target_dev_state);
 static DEVICE_ATTR_RO(rpm_target_link_state);
@@ -262,6 +270,7 @@ static DEVICE_ATTR_RO(spm_target_dev_state);
 static DEVICE_ATTR_RO(spm_target_link_state);
 static DEVICE_ATTR_RW(auto_hibern8);
 static DEVICE_ATTR_RW(wb_on);
+static DEVICE_ATTR_RO(caps);
 
 static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
 	&dev_attr_rpm_lvl.attr,
@@ -272,6 +281,7 @@ static struct attribute *ufs_sysfs_ufshcd_attrs[] = {
 	&dev_attr_spm_target_link_state.attr,
 	&dev_attr_auto_hibern8.attr,
 	&dev_attr_wb_on.attr,
+	&dev_attr_caps.attr,
 	NULL
 };
 
-- 
2.31.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ufs: core: print capabilities in controller's sysfs node
  2022-07-28 23:05 [PATCH v2] ufs: core: print capabilities in controller's sysfs node Daniil Lunev
@ 2022-07-28 23:23 ` Bart Van Assche
  2022-07-29  7:20   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Van Assche @ 2022-07-28 23:23 UTC (permalink / raw)
  To: Daniil Lunev, Adrian Hunter, Greg Kroah-Hartman
  Cc: Alim Akhtar, Avri Altman, Bean Huo, Daejun Park,
	James E.J. Bottomley, Martin K. Petersen, Mauro Carvalho Chehab,
	Sohaib Mohamed, Stanley Chu, linux-kernel, linux-scsi

On 7/28/22 16:05, Daniil Lunev wrote:
> +What:		/sys/bus/platform/drivers/ufshcd/*/caps
> +What:		/sys/bus/platform/devices/*.ufs/caps
> +Date:		July 2022
> +Contact:	Daniil Lunev <dlunev@chromium.org>
> +Description:	Read-only attribute. Enabled capabilities of the UFS driver. The
> +		enabled capabilities are determined by what is supported by the
> +		host controller and the UFS device.
> +		Format: 0x%08llx

This documentation is useless since the meaning of the individual bits 
has not been documented.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ufs: core: print capabilities in controller's sysfs node
  2022-07-28 23:23 ` Bart Van Assche
@ 2022-07-29  7:20   ` Greg Kroah-Hartman
  2022-07-29  7:47     ` Daniil Lunev
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-29  7:20 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Daniil Lunev, Adrian Hunter, Alim Akhtar, Avri Altman, Bean Huo,
	Daejun Park, James E.J. Bottomley, Martin K. Petersen,
	Mauro Carvalho Chehab, Sohaib Mohamed, Stanley Chu, linux-kernel,
	linux-scsi

On Thu, Jul 28, 2022 at 04:23:16PM -0700, Bart Van Assche wrote:
> On 7/28/22 16:05, Daniil Lunev wrote:
> > +What:		/sys/bus/platform/drivers/ufshcd/*/caps
> > +What:		/sys/bus/platform/devices/*.ufs/caps
> > +Date:		July 2022
> > +Contact:	Daniil Lunev <dlunev@chromium.org>
> > +Description:	Read-only attribute. Enabled capabilities of the UFS driver. The
> > +		enabled capabilities are determined by what is supported by the
> > +		host controller and the UFS device.
> > +		Format: 0x%08llx
> 
> This documentation is useless since the meaning of the individual bits has
> not been documented.

Yeah, that's not ok, where are these bits coming from and what userspace
tools will be using them?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ufs: core: print capabilities in controller's sysfs node
  2022-07-29  7:20   ` Greg Kroah-Hartman
@ 2022-07-29  7:47     ` Daniil Lunev
  0 siblings, 0 replies; 4+ messages in thread
From: Daniil Lunev @ 2022-07-29  7:47 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Bart Van Assche, Adrian Hunter, Alim Akhtar, Avri Altman,
	Bean Huo, Daejun Park, James E.J. Bottomley, Martin K. Petersen,
	Mauro Carvalho Chehab, Sohaib Mohamed, Stanley Chu, linux-kernel,
	linux-scsi

> Yeah, that's not ok, where are these bits coming from
There has been a few more iterations on the patch, in the latest state only
Clock Scaling and Write Booster are exposed as individual nodes.

> what userspace tools will be using them?
In ChromeOS we want to explicitly control WriteBooster state, but for that
the user space needs to know when it is supported but off, and when it is
not supported at all. On top of it, Clock Scaling complicates the story since
it disables the control via wb_on node. That is something I need to figure
out separately.

--Daniil

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-29  7:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 23:05 [PATCH v2] ufs: core: print capabilities in controller's sysfs node Daniil Lunev
2022-07-28 23:23 ` Bart Van Assche
2022-07-29  7:20   ` Greg Kroah-Hartman
2022-07-29  7:47     ` Daniil Lunev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.