[RFC PATCH 5/6] powerpc/papr_scm: Implement support for DSM_PAPR_SCM_HEALTH
Vaibhav Jain
vaibhav at linux.ibm.com
Thu Jan 30 02:28:43 AEDT 2020
The DSM 'DSM_PAPR_SCM_HEALTH' should return the health-bitmap and
health-valid-bitmap information for a dimm back to userspace in
response to ND_CMD_CALL.
This patch implements this DSM by implementing a new function
papr_scm_get_health() that queries the DIMM health information and
then copies these bitmaps to the package payload whose layout is
defined by 'struct papr_scm_ndctl_health'.
Signed-off-by: Vaibhav Jain <vaibhav at linux.ibm.com>
---
arch/powerpc/platforms/pseries/papr_scm.c | 46 +++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
index e1a2c0e61077..6c0bc8f027db 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -33,9 +33,16 @@
*/
enum {
DSM_PAPR_MIN = 0x10000,
+ DSM_PAPR_SCM_HEALTH,
DSM_PAPR_MAX,
};
+/* Struct as returned by kernel in response to PAPR_DSM_PAPR_SMART_HEALTH */
+struct papr_scm_ndctl_health {
+ __be64 health_bitmap;
+ __be64 health_bitmap_valid;
+} __packed;
+
/* Payload expected with ND_CMD_CALL ioctl from libnvdimm */
struct nd_pkg_papr_scm {
struct nd_cmd_pkg hdr; /* Package header containing sub-cmd */
@@ -369,6 +376,40 @@ static int cmd_to_func(struct nvdimm *nvdimm, unsigned int cmd, void *buf,
return pkg->hdr.nd_command;
}
+/* Fetch the DIMM health info and populate it in provided papr_scm package */
+static int papr_scm_get_health(struct papr_scm_priv *p,
+ struct nd_pkg_papr_scm *pkg)
+{
+ int rc;
+ struct papr_scm_ndctl_health *health =
+ (struct papr_scm_ndctl_health *)pkg->payload;
+
+ pkg->hdr.nd_fw_size = sizeof(struct papr_scm_ndctl_health);
+
+ if (pkg->hdr.nd_size_out < sizeof(struct papr_scm_ndctl_health)) {
+ rc = -ENOSPC;
+ goto out;
+ }
+
+ rc = drc_pmem_query_health(p);
+ if (rc)
+ goto out;
+
+ /* Copy the health data to the payload */
+ health->health_bitmap = p->health_bitmap;
+ health->health_bitmap_valid = p->health_bitmap_valid;
+
+out:
+ /*
+ * Put the error in out package and return success from function
+ * so that errors if any are propogated back to userspace.
+ */
+ pkg->cmd_status = rc;
+ dev_dbg(&p->pdev->dev, "%s completion code = %d\n", __func__, rc);
+
+ return 0;
+}
+
int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc)
{
@@ -414,6 +455,11 @@ int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
*cmd_rc = 0;
break;
+ case DSM_PAPR_SCM_HEALTH:
+ call_pkg = (struct nd_pkg_papr_scm *) buf;
+ *cmd_rc = papr_scm_get_health(p, call_pkg);
+ break;
+
default:
dev_dbg(&p->pdev->dev, "Unknown command = %d\n", cmd_in);
*cmd_rc = -EINVAL;
--
2.24.1
More information about the Linuxppc-dev
mailing list