linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ufs: core: print capabilities in controller's sysfs node
@ 2022-07-28  4:49 Daniil Lunev
  2022-07-28  6:50 ` Greg Kroah-Hartman
  2022-07-28 13:37 ` Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: Daniil Lunev @ 2022-07-28  4:49 UTC (permalink / raw)
  To: Adrian Hunter, Bart Van Assche
  Cc: Daniil Lunev, Alim Akhtar, Avri Altman, Bean Huo, Daejun Park,
	Greg Kroah-Hartman, James E.J. Bottomley, Martin K. Petersen,
	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>

---

 drivers/ufs/core/ufs-sysfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

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] 5+ messages in thread

* Re: [PATCH] ufs: core: print capabilities in controller's sysfs node
  2022-07-28  4:49 [PATCH] ufs: core: print capabilities in controller's sysfs node Daniil Lunev
@ 2022-07-28  6:50 ` Greg Kroah-Hartman
  2022-07-28 13:37 ` Bart Van Assche
  1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-28  6:50 UTC (permalink / raw)
  To: Daniil Lunev
  Cc: Adrian Hunter, Bart Van Assche, Alim Akhtar, Avri Altman,
	Bean Huo, Daejun Park, James E.J. Bottomley, Martin K. Petersen,
	linux-kernel, linux-scsi

On Thu, Jul 28, 2022 at 02:49:25PM +1000, Daniil Lunev wrote:
> Allows userspace to check supported by the controller/device
> functionality, e.g. write booster.
> 
> Signed-off-by: Daniil Lunev <dlunev@chromium.org>

You have to also document this in Documentation/ABI/ when you add a new
sysfs file.  Please do so here.

thanks,

greg k-h

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

* Re: [PATCH] ufs: core: print capabilities in controller's sysfs node
  2022-07-28  4:49 [PATCH] ufs: core: print capabilities in controller's sysfs node Daniil Lunev
  2022-07-28  6:50 ` Greg Kroah-Hartman
@ 2022-07-28 13:37 ` Bart Van Assche
  2022-07-28 23:08   ` Daniil Lunev
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2022-07-28 13:37 UTC (permalink / raw)
  To: Daniil Lunev, Adrian Hunter
  Cc: Alim Akhtar, Avri Altman, Bean Huo, Daejun Park,
	Greg Kroah-Hartman, James E.J. Bottomley, Martin K. Petersen,
	linux-kernel, linux-scsi

On 7/27/22 21:49, Daniil Lunev wrote:
> +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);
> +}

This code change includes all of the UFSHCD_CAP_* constants in the 
kernel ABI. Is that really what we want? I'm wondering whether it 
perhaps would be better only to export those capabilities to user space 
that user space needs to know about.

Thanks,

Bart.

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

* Re: [PATCH] ufs: core: print capabilities in controller's sysfs node
  2022-07-28 13:37 ` Bart Van Assche
@ 2022-07-28 23:08   ` Daniil Lunev
  2022-07-28 23:21     ` Bart Van Assche
  0 siblings, 1 reply; 5+ messages in thread
From: Daniil Lunev @ 2022-07-28 23:08 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Adrian Hunter, Alim Akhtar, Avri Altman, Bean Huo, Daejun Park,
	Greg Kroah-Hartman, James E.J. Bottomley, Martin K. Petersen,
	linux-kernel, linux-scsi

On Thu, Jul 28, 2022 at 11:37 PM Bart Van Assche <bvanassche@acm.org> wrote:
> This code change includes all of the UFSHCD_CAP_* constants in the
> kernel ABI. Is that really what we want? I'm wondering whether it
> perhaps would be better only to export those capabilities to user space
> that user space needs to know about.
Adding the filtering would introduce an extra maintenance burden and
will likely go out
of sync. I don't see harm in exposing all capabilities, both intrinsic
to the controller and
negotiated with the device. Do you see any scenario where that would be harmful?
--Daniil

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

* Re: [PATCH] ufs: core: print capabilities in controller's sysfs node
  2022-07-28 23:08   ` Daniil Lunev
@ 2022-07-28 23:21     ` Bart Van Assche
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2022-07-28 23:21 UTC (permalink / raw)
  To: Daniil Lunev
  Cc: Adrian Hunter, Alim Akhtar, Avri Altman, Bean Huo, Daejun Park,
	Greg Kroah-Hartman, James E.J. Bottomley, Martin K. Petersen,
	linux-kernel, linux-scsi

On 7/28/22 16:08, Daniil Lunev wrote:
> On Thu, Jul 28, 2022 at 11:37 PM Bart Van Assche <bvanassche@acm.org> wrote:
>> This code change includes all of the UFSHCD_CAP_* constants in the
>> kernel ABI. Is that really what we want? I'm wondering whether it
>> perhaps would be better only to export those capabilities to user space
>> that user space needs to know about.
> Adding the filtering would introduce an extra maintenance burden and
> will likely go out
> of sync. I don't see harm in exposing all capabilities, both intrinsic
> to the controller and
> negotiated with the device. Do you see any scenario where that would be harmful?

Please only export what you need instead of exporting all capabilities.

Thanks,

Bart.


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

end of thread, other threads:[~2022-07-28 23:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28  4:49 [PATCH] ufs: core: print capabilities in controller's sysfs node Daniil Lunev
2022-07-28  6:50 ` Greg Kroah-Hartman
2022-07-28 13:37 ` Bart Van Assche
2022-07-28 23:08   ` Daniil Lunev
2022-07-28 23:21     ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).