Commit ed78f56e authored by Vaibhav Jain's avatar Vaibhav Jain Committed by Michael Ellerman

powerpc/papr_scm: Make 'perf_stats' invisible if perf-stats unavailable

In case performance stats for an nvdimm are not available, reading the
'perf_stats' sysfs file returns an -ENOENT error. A better approach is
to make the 'perf_stats' file entirely invisible to indicate that
performance stats for an nvdimm are unavailable.

So this patch updates 'papr_nd_attribute_group' to add a 'is_visible'
callback implemented as newly introduced 'papr_nd_attribute_visible()'
that returns an appropriate mode in case performance stats aren't
supported in a given nvdimm.

Also the initialization of 'papr_scm_priv.stat_buffer_len' is moved
from papr_scm_nvdimm_init() to papr_scm_probe() so that it value is
available when 'papr_nd_attribute_visible()' is called during nvdimm
initialization.

Even though 'perf_stats' attribute is available since v5.9, there are
no known user-space tools/scripts that are dependent on presence of its
sysfs file. Hence I dont expect any user-space breakage with this
patch.

Fixes: 2d02bf83 ("powerpc/papr_scm: Fetch nvdimm performance stats from PHYP")
Signed-off-by: default avatarVaibhav Jain <vaibhav@linux.ibm.com>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210513092349.285021-1-vaibhav@linux.ibm.com
parent 511eea5e
...@@ -39,9 +39,11 @@ KernelVersion: v5.9 ...@@ -39,9 +39,11 @@ KernelVersion: v5.9
Contact: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>, nvdimm@lists.linux.dev, Contact: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>, nvdimm@lists.linux.dev,
Description: Description:
(RO) Report various performance stats related to papr-scm NVDIMM (RO) Report various performance stats related to papr-scm NVDIMM
device. Each stat is reported on a new line with each line device. This attribute is only available for NVDIMM devices
composed of a stat-identifier followed by it value. Below are that support reporting NVDIMM performance stats. Each stat is
currently known dimm performance stats which are reported: reported on a new line with each line composed of a
stat-identifier followed by it value. Below are currently known
dimm performance stats which are reported:
* "CtlResCt" : Controller Reset Count * "CtlResCt" : Controller Reset Count
* "CtlResTm" : Controller Reset Elapsed Time * "CtlResTm" : Controller Reset Elapsed Time
......
...@@ -908,6 +908,20 @@ static ssize_t flags_show(struct device *dev, ...@@ -908,6 +908,20 @@ static ssize_t flags_show(struct device *dev,
} }
DEVICE_ATTR_RO(flags); DEVICE_ATTR_RO(flags);
static umode_t papr_nd_attribute_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct device *dev = kobj_to_dev(kobj);
struct nvdimm *nvdimm = to_nvdimm(dev);
struct papr_scm_priv *p = nvdimm_provider_data(nvdimm);
/* For if perf-stats not available remove perf_stats sysfs */
if (attr == &dev_attr_perf_stats.attr && p->stat_buffer_len == 0)
return 0;
return attr->mode;
}
/* papr_scm specific dimm attributes */ /* papr_scm specific dimm attributes */
static struct attribute *papr_nd_attributes[] = { static struct attribute *papr_nd_attributes[] = {
&dev_attr_flags.attr, &dev_attr_flags.attr,
...@@ -917,6 +931,7 @@ static struct attribute *papr_nd_attributes[] = { ...@@ -917,6 +931,7 @@ static struct attribute *papr_nd_attributes[] = {
static struct attribute_group papr_nd_attribute_group = { static struct attribute_group papr_nd_attribute_group = {
.name = "papr", .name = "papr",
.is_visible = papr_nd_attribute_visible,
.attrs = papr_nd_attributes, .attrs = papr_nd_attributes,
}; };
...@@ -932,7 +947,6 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) ...@@ -932,7 +947,6 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
struct nd_region_desc ndr_desc; struct nd_region_desc ndr_desc;
unsigned long dimm_flags; unsigned long dimm_flags;
int target_nid, online_nid; int target_nid, online_nid;
ssize_t stat_size;
p->bus_desc.ndctl = papr_scm_ndctl; p->bus_desc.ndctl = papr_scm_ndctl;
p->bus_desc.module = THIS_MODULE; p->bus_desc.module = THIS_MODULE;
...@@ -1017,16 +1031,6 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) ...@@ -1017,16 +1031,6 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
list_add_tail(&p->region_list, &papr_nd_regions); list_add_tail(&p->region_list, &papr_nd_regions);
mutex_unlock(&papr_ndr_lock); mutex_unlock(&papr_ndr_lock);
/* Try retriving the stat buffer and see if its supported */
stat_size = drc_pmem_query_stats(p, NULL, 0);
if (stat_size > 0) {
p->stat_buffer_len = stat_size;
dev_dbg(&p->pdev->dev, "Max perf-stat size %lu-bytes\n",
p->stat_buffer_len);
} else {
dev_info(&p->pdev->dev, "Dimm performance stats unavailable\n");
}
return 0; return 0;
err: nvdimm_bus_unregister(p->bus); err: nvdimm_bus_unregister(p->bus);
...@@ -1104,6 +1108,7 @@ static int papr_scm_probe(struct platform_device *pdev) ...@@ -1104,6 +1108,7 @@ static int papr_scm_probe(struct platform_device *pdev)
struct papr_scm_priv *p; struct papr_scm_priv *p;
u8 uuid_raw[UUID_SIZE]; u8 uuid_raw[UUID_SIZE];
const char *uuid_str; const char *uuid_str;
ssize_t stat_size;
uuid_t uuid; uuid_t uuid;
int rc; int rc;
...@@ -1188,6 +1193,14 @@ static int papr_scm_probe(struct platform_device *pdev) ...@@ -1188,6 +1193,14 @@ static int papr_scm_probe(struct platform_device *pdev)
p->res.name = pdev->name; p->res.name = pdev->name;
p->res.flags = IORESOURCE_MEM; p->res.flags = IORESOURCE_MEM;
/* Try retrieving the stat buffer and see if its supported */
stat_size = drc_pmem_query_stats(p, NULL, 0);
if (stat_size > 0) {
p->stat_buffer_len = stat_size;
dev_dbg(&p->pdev->dev, "Max perf-stat size %lu-bytes\n",
p->stat_buffer_len);
}
rc = papr_scm_nvdimm_init(p); rc = papr_scm_nvdimm_init(p);
if (rc) if (rc)
goto err2; goto err2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment