From: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>
To: Bart Van Assche <bvanassche@acm.org>, <quic_cang@quicinc.com>,
<quic_nitirawa@quicinc.com>, <avri.altman@wdc.com>,
<peter.wang@mediatek.com>, <manivannan.sadhasivam@linaro.org>,
<minwoo.im@samsung.com>, <adrian.hunter@intel.com>,
<martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Bean Huo <beanhuo@micron.com>,
Ziqi Chen <quic_ziqichen@quicinc.com>,
Keoseong Park <keosung.park@samsung.com>,
Gwendal Grignou <gwendal@chromium.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Eric Biggers <ebiggers@google.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 1/1] scsi: ufs: core: add device level exception support
Date: Thu, 13 Mar 2025 14:36:14 -0700 [thread overview]
Message-ID: <4c83f8c3-6cfd-81a0-afeb-3e8854fa1efc@quicinc.com> (raw)
In-Reply-To: <41678800-470f-4ea2-802c-f9f4d21817f6@acm.org>
On 3/13/2025 11:14 AM, Bart Van Assche wrote:
> On 3/6/25 9:31 AM, Bao D. Nguyen wrote:
>> +What: /sys/bus/platform/drivers/ufshcd/*/device_lvl_exception
>> +What: /sys/bus/platform/devices/*.ufs/device_lvl_exception
>> +Date: March 2025
>> +Contact: Bao D. Nguyen <quic_nguyenb@quicinc.com>
>> +Description:
>> + The device_lvl_exception is a counter indicating the number
>> + of times the device level exceptions have occurred since the
>> + last time this variable is reset. Read the
>> device_lvl_exception_id
>> + sysfs node to know more information about the exception.
>> + The file is read only.
>
> Shouldn't this sysfs attribute have a "_count" suffix to make it clear
> that it represents a count?
Thank you, Bart. I agree. Will make the change.
>
> Additionally, here and below, please change "file" into "attribute".
>
>> +What: /sys/bus/platform/drivers/ufshcd/*/device_lvl_exception_id
>> +What: /sys/bus/platform/devices/*.ufs/device_lvl_exception_id
>> +Date: March 2025
>> +Contact: Bao D. Nguyen <quic_nguyenb@quicinc.com>
>> +Description:
>> + Reading the device_lvl_exception_id returns the device JEDEC
>> + standard's qDeviceLevelExceptionID attribute. The definition
>> of the
>> + qDeviceLevelExceptionID is the ufs device vendor specific
>> design.
>> + Refer to the device manufacturer datasheet for more information
>> + on the meaning of the qDeviceLevelExceptionID attribute value.
>> + The file is read only.
>
> I'm not sure it is useful to export vendor-specific information to
> sysfs.
Because each ufs vendor defines the data differently according to the
device spec, we probably can't have a defined handling on this event in
the kernel. For some applications such as automobile, the information is
useful. If you have suggestions for the user applications to access this
data, I am all ears.
>
>> diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
>> index 90b5ab6..0248288a 100644
>> --- a/drivers/ufs/core/ufs-sysfs.c
>> +++ b/drivers/ufs/core/ufs-sysfs.c
>> @@ -466,6 +466,56 @@ static ssize_t critical_health_show(struct device
>> *dev,
>> return sysfs_emit(buf, "%d\n", hba->critical_health_count);
>> }
>> +static ssize_t device_lvl_exception_show(struct device *dev,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>> + struct ufs_hba *hba = dev_get_drvdata(dev);
>> +
>> + if (hba->dev_info.wspecversion < 0x410)
>> + return -EOPNOTSUPP;
>> +
>> + return sysfs_emit(buf, "%u\n", hba->dev_lvl_exception_count);
>> +}
>
> The preferred approach for sysfs attributes that are not supported is to
> make these invisible rather than returning an error code.I was thinking it would be useful for the user application to know the
ufs device does not support this feature, so that it would not keep
trying to read the data.
>
>> +static ssize_t device_lvl_exception_id_show(struct device *dev,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>> + struct ufs_hba *hba = dev_get_drvdata(dev);
>> + u64 exception_id;
>> + int err;
>> +
>> + ufshcd_rpm_get_sync(hba);
>> + err = ufshcd_read_device_lvl_exception_id(hba, &exception_id);
>> + ufshcd_rpm_put_sync(hba);
>> +
>> + if (err)
>> + return err;
>> +
>> + hba->dev_lvl_exception_id = exception_id;
>> + return sysfs_emit(buf, "%llu\n", exception_id);
>> +}
>
> Just like device_lvl_exception, this attribute shouldn't be visible if
> device level exceptions are not supported.
Same reasoning, to inform the user application the feature is not
supported so that it does not keep trying.
>
>> + if (status & hba->ee_drv_mask & MASK_EE_DEV_LVL_EXCEPTION) {
>> + hba->dev_lvl_exception_count++;
>> + sysfs_notify(&hba->dev->kobj, NULL, "device_lvl_exception");
>> + }
>
> sysfs_notify() may sleep and hence must not be called from an interrupt
> handler.
I will look into this.
Thanks, Bao
>
> Thanks,
>
> Bart.
next prev parent reply other threads:[~2025-03-13 21:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 17:31 Bao D. Nguyen
2025-03-13 17:28 ` Manivannan Sadhasivam
2025-03-13 21:09 ` Bao D. Nguyen
2025-03-13 18:14 ` Bart Van Assche
2025-03-13 21:36 ` Bao D. Nguyen [this message]
2025-03-14 7:09 ` Avri Altman
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=4c83f8c3-6cfd-81a0-afeb-3e8854fa1efc@quicinc.com \
--to=quic_nguyenb@quicinc.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=ebiggers@google.com \
--cc=gwendal@chromium.org \
--cc=keosung.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martin.petersen@oracle.com \
--cc=minwoo.im@samsung.com \
--cc=peter.wang@mediatek.com \
--cc=quic_cang@quicinc.com \
--cc=quic_nitirawa@quicinc.com \
--cc=quic_ziqichen@quicinc.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®