powerpc/papr_scm: Make 'perf_stats' invisible if perf-stats unavailable
authorVaibhav Jain <vaibhav@linux.ibm.com>
Thu, 13 May 2021 09:23:49 +0000 (14:53 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 25 Jun 2021 04:47:18 +0000 (14:47 +1000)
commited78f56e1271f108e8af61baeba383dcd77adbec
tree24025b13edabaa71a1b86d240e9c394df4705d60
parent511eea5e2ccdfdbf3d626bde0314e551f247dd18
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: 2d02bf835e57 ("powerpc/papr_scm: Fetch nvdimm performance stats from PHYP")
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210513092349.285021-1-vaibhav@linux.ibm.com
Documentation/ABI/testing/sysfs-bus-papr-pmem
arch/powerpc/platforms/pseries/papr_scm.c