From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "jaegeuk@kernel.org" <jaegeuk@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: "jaegeuk@google.com" <jaegeuk@google.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 2/2] scsi: ufs: use sysfs entry for health info
Date: Tue, 19 Dec 2017 21:07:31 +0000 [thread overview]
Message-ID: <1513717650.2535.13.camel@wdc.com> (raw)
In-Reply-To: <20171219200254.23120-2-jaegeuk@kernel.org>
On Tue, 2017-12-19 at 12:02 -0800, Jaegeuk Kim wrote:
> This patch introduces sysfs entries to show the information.
What information does "the information" refer to?
Regarding the patch title: I think this patch introduces new sysfs attributes
instead of using existing sysfs entries. If so, please reflect this in the patch
title.
> # cat /sys/devices/soc/1da4000.ufshc/health/eol
> # cat /sys/devices/soc/1da4000.ufshc/health/length
> # cat /sys/devices/soc/1da4000.ufshc/health/lifetimeA
> # cat /sys/devices/soc/1da4000.ufshc/health/lifetimeB
> # cat /sys/devices/soc/1da4000.ufshc/health/type
What is the meaning of the above shell commands in the context of the patch
description?
> struct desc_field_offset health_desc_field_name[] = {
> {"bLength", 0x00, BYTE},
> {"bDescriptorType", 0x01, BYTE},
> {"bPreEOLInfo", 0x02, BYTE},
> {"bDeviceLifeTimeEstA", 0x03, BYTE},
> {"bDeviceLifeTimeEstB", 0x04, BYTE}
> };
Why has the above data been mentioned in the patch description?
> bPreEOLInfo
> - 00h: Not defined
> - 01h: Normal
> - 02h: Warning
> - 03h: Critical
>
> bDeviceLifeTimeEstA
> - 00h: Not defined
> - 01h: 0% ~ 10% device life time used
> - 02h: 10% ~ 20% device life time used
> - 03h: 20% ~ 30% device life time used
> - 04h: 30% ~ 40% device life time used
> - 05h: 40% ~ 50% device life time used
> - 06h: 50% ~ 60% device life time used
> - 07h: 60% ~ 70% device life time used
> - 08h: 70% ~ 80% device life time used
> - 09h: 80% ~ 90% device life time used
> - 0Ah: 90% ~ 100% device life time used
> - 0Bh: Exceeded its maximum estimated device life time
Again, why has the above information been mentioned in the patch description?
> +static ssize_t health_attr_show(struct device *dev,
> + struct health_attr *attr, char *buf)
> +{
> + struct ufs_hba *hba = dev_get_drvdata(dev);
> + int buff_len = hba->desc_size.health_desc;
> + u8 desc_buf[hba->desc_size.health_desc];
Is desc_buf[] a variable-length array? If so, how big can
hba->desc_size.health_desc be? Can that number have a negative value?
> + return scnprintf(buf, PAGE_SIZE, "0x%02x", desc_buf[attr->bytes]);
Please check whether attr->bytes falls inside the bounds of the desc_buf[] array
before using that value as an index.
> +#define HEALTH_ATTR_RO(_name, _bytes) \
> +static struct health_attr ufs_health_##_name = { \
> + .attr = {.name = __stringify(_name), .mode = 0444}, \
> + .show = health_attr_show, \
> + .bytes = _bytes, \
> +}
> +
> +HEALTH_ATTR_RO(length, 0);
> +HEALTH_ATTR_RO(type, 1);
> +HEALTH_ATTR_RO(eol, 2);
> +HEALTH_ATTR_RO(lifetimeA, 3);
> +HEALTH_ATTR_RO(lifetimeB, 4);
The above makes clear that the value stored in the structure member with the name
"bytes" represents an array index. Please choose a better name for that structure
member.
Additionally, since this patch introduces new sysfs attributes, why doesn't it
add any documentation under Documentation/ABI/?
Thanks,
Bart.
next prev parent reply other threads:[~2017-12-19 21:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-19 20:02 [PATCH 1/2] scsi: ufs: introduce static sysfs entries Jaegeuk Kim
2017-12-19 20:02 ` [PATCH 2/2] scsi: ufs: use sysfs entry for health info Jaegeuk Kim
2017-12-19 21:07 ` Bart Van Assche [this message]
2017-12-19 22:45 ` [PATCH 2/2 v2] " Jaegeuk Kim
2017-12-19 22:46 ` Jaegeuk Kim
2017-12-19 23:53 ` Bart Van Assche
2017-12-20 9:26 ` gregkh
2017-12-20 19:33 ` Jaegeuk Kim
2017-12-20 8:02 ` [PATCH 1/2] scsi: ufs: introduce static sysfs entries Greg KH
2017-12-20 19:46 ` Jaegeuk Kim
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=1513717650.2535.13.camel@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=gregkh@linuxfoundation.org \
--cc=jaegeuk@google.com \
--cc=jaegeuk@kernel.org \
--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