From: Can Guo <can.guo@oss.qualcomm.com>
To: Bart Van Assche <bvanassche@acm.org>, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Peter Wang <peter.wang@mediatek.com>,
Huan Tang <tanghuan@vivo.com>,
"Bao D. Nguyen" <quic_nguyenb@quicinc.com>,
Daniel Lee <chullee@google.com>, Liu Song <liu.song13@zte.com.cn>,
Ram Kumar Dwivedi <ram.dwivedi@oss.qualcomm.com>,
Bean Huo <huobean@gmail.com>,
Adrian Hunter <adrian.hunter@intel.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] scsi: ufs: core: Add a sysfs entry for ufshcd_state
Date: Sun, 1 Mar 2026 20:40:23 +0800 [thread overview]
Message-ID: <8b486c76-6597-4b44-bf4a-bddc98aec6e8@oss.qualcomm.com> (raw)
In-Reply-To: <7782e4fe-ddc5-4ef4-b632-5c137b31ed73@acm.org>
Hi Bart,
On 2/26/2026 2:59 AM, Bart Van Assche wrote:
> On 2/24/26 6:29 PM, Can Guo wrote:
>> +What: /sys/bus/platform/drivers/ufshcd/*/ufshcd_state
>> +What: /sys/bus/platform/devices/*.ufs/ufshcd_state
>> +Date: February 2026
>> +Contact: Can Guo <can.guo@oss.qualcomm.com>
>> +Description:
>> + This attribute shows the state of ufshcd.
>> +
>> + The attribute is read only.
>
> Please expand "state of ufshcd", e.g. into "state of the UFS host
> controller driver".
>
>> +static const char * const ufshcd_states[] = {
>> + [UFSHCD_STATE_RESET] = "reset",
>> + [UFSHCD_STATE_OPERATIONAL] = "operational",
>> + [UFSHCD_STATE_EH_SCHEDULED_NON_FATAL] =
>> "eh_scheduled_non_fatal",
>> + [UFSHCD_STATE_EH_SCHEDULED_FATAL] = "eh_scheduled_fatal",
>> + [UFSHCD_STATE_ERROR] = "error",
>> +};
>
> Please follow the kernel coding style with regard to spaces around "*".
>
>> +static ssize_t ufshcd_state_show(struct device *dev,
>> + struct device_attribute *attr, char *buf)
>> +{
>> + struct ufs_hba *hba = dev_get_drvdata(dev);
>> +
>> + return sysfs_emit(buf, "%s\n", ufshcd_states[hba->ufshcd_state]);
>> +}
>
> In the above function, please check that hba->ufshcd_state does not
> exceed the bounds of the ufshcd_states[] array and also that
> ufshcd_states[hba->ufshcd_state] is not NULL.
>
>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
>> index c6c7de7a0603..32a508e1582e 100644
>> --- a/drivers/ufs/core/ufshcd.c
>> +++ b/drivers/ufs/core/ufshcd.c
>> @@ -7917,6 +7917,8 @@ static void ufshcd_process_probe_result(struct
>> ufs_hba *hba,
>> hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
>> spin_unlock_irqrestore(hba->host->host_lock, flags);
>> + sysfs_notify(&hba->dev->kobj, NULL, "ufshcd_state");
>> +
>> trace_ufshcd_init(hba, ret,
>> ktime_to_us(ktime_sub(ktime_get(), probe_start)),
>> hba->curr_dev_pwr_mode, hba->uic_link_state);
>
> Shouldn't there be one sysfs_notify(&hba->dev->kobj, NULL,
> "ufshcd_state") call after every hba->ufshcd_state change?
Thanks for your review. My first thinking was to indicate to userspace
that DME QoS monitor has been reset by host. But on second thought, it
would be much simpler if I just use Bit[0] in dme_qos_nofitication
attribute to communicate that information to userspace, because DME QoS
events are mapped to Bit[3:1], meaning Bit[0] is free anyways. I am
dropping this change in next version.
Thanks,
Can Guo.
>
> Thanks,
>
> Bart.
prev parent reply other threads:[~2026-03-01 12:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260225022942.345564-1-can.guo@oss.qualcomm.com>
2026-02-25 2:29 ` [PATCH v2 1/2] scsi: ufs: core: Add support to notify userspace of UniPro QoS events Can Guo
2026-02-25 18:48 ` Bart Van Assche
2026-03-01 9:09 ` Can Guo
2026-02-25 2:29 ` [PATCH v2 2/2] scsi: ufs: core: Add a sysfs entry for ufshcd_state Can Guo
2026-02-25 18:59 ` Bart Van Assche
2026-03-01 12:40 ` Can Guo [this message]
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=8b486c76-6597-4b44-bf4a-bddc98aec6e8@oss.qualcomm.com \
--to=can.guo@oss.qualcomm.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=chullee@google.com \
--cc=huobean@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liu.song13@zte.com.cn \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=quic_nguyenb@quicinc.com \
--cc=ram.dwivedi@oss.qualcomm.com \
--cc=tanghuan@vivo.com \
/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®