Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752686AbdLSVHj (ORCPT ); Tue, 19 Dec 2017 16:07:39 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:5604 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751461AbdLSVHf (ORCPT ); Tue, 19 Dec 2017 16:07:35 -0500 X-IronPort-AV: E=Sophos;i="5.45,428,1508774400"; d="scan'208";a="66191475" From: Bart Van Assche To: "jaegeuk@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" CC: "jaegeuk@google.com" , "gregkh@linuxfoundation.org" Subject: Re: [PATCH 2/2] scsi: ufs: use sysfs entry for health info Thread-Topic: [PATCH 2/2] scsi: ufs: use sysfs entry for health info Thread-Index: AQHTeQR3YHXxyvYD2kKll5j3lHDaLqNLKLkA Date: Tue, 19 Dec 2017 21:07:31 +0000 Message-ID: <1513717650.2535.13.camel@wdc.com> References: <20171219200254.23120-1-jaegeuk@kernel.org> <20171219200254.23120-2-jaegeuk@kernel.org> In-Reply-To: <20171219200254.23120-2-jaegeuk@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR0401MB1534;20:UPuGUHDneow1G7IFDkTsyDqkQWpWpi/R1vMa5BF7D27JRRHXykO7c+YMCcnlMkv+may/EsBF8OIKlwmLJiAzRDEN/Bset0U+0PMfYQKUejWsXoGAUfJg6A+tD7WlNMYPbQGeM0wBL4mXDos2L/3ehQ50mp6WC3W8gsX8Hq7ce/Y= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 260ceb1e-8f43-425e-44cd-08d547248523 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060);SRVR:CY1PR0401MB1534; x-ms-traffictypediagnostic: CY1PR0401MB1534: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(3231023)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(20161123562025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(6072148)(201708071742011);SRVR:CY1PR0401MB1534;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY1PR0401MB1534; x-forefront-prvs: 052670E5A4 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(366004)(39860400002)(346002)(396003)(376002)(199004)(189003)(24454002)(377424004)(68736007)(3280700002)(3660700001)(81166006)(77096006)(6486002)(229853002)(8936002)(6436002)(2906002)(6512007)(316002)(105586002)(110136005)(76176011)(106356001)(54906003)(66066001)(53936002)(7736002)(8676002)(36756003)(2501003)(4326008)(25786009)(305945005)(6246003)(478600001)(6506007)(81156014)(59450400001)(2900100001)(103116003)(14454004)(102836003)(6116002)(86362001)(3846002)(4001150100001)(2950100002)(72206003)(97736004)(99286004)(5660300001)(2201001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0401MB1534;H:CY1PR0401MB1536.namprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <2019607DEF07F648AC99EA7E290603B5@namprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 260ceb1e-8f43-425e-44cd-08d547248523 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2017 21:07:31.9150 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1534 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vBJL7hQR024857 Content-Length: 2989 Lines: 88 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.