|
|
e0018b |
From aa990008f48f21121474a411d829f24e832c89a2 Mon Sep 17 00:00:00 2001
|
|
|
e0018b |
From: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
|
e0018b |
Date: Tue, 25 Jan 2022 00:26:05 +0530
|
|
|
e0018b |
Subject: [PATCH 125/217] libndctl/papr: Add support for reporting
|
|
|
e0018b |
shutdown-count
|
|
|
e0018b |
|
|
|
e0018b |
Add support for reporting dirty-shutdown-count (DSC) for PAPR based
|
|
|
e0018b |
NVDIMMs. The sysfs attribute exposing this value is located at
|
|
|
e0018b |
nmemX/papr/dirty_shutdown.
|
|
|
e0018b |
|
|
|
e0018b |
This counter is also returned in payload for PAPR_PDSM_HEALTH as newly
|
|
|
e0018b |
introduced member 'dimm_dsc' in 'struct nd_papr_pdsm_health'. Presence
|
|
|
e0018b |
of 'DSC' is indicated by the PDSM_DIMM_DSC_VALID extension flag.
|
|
|
e0018b |
|
|
|
e0018b |
The patch implements 'ndctl_dimm_ops.smart_get_shutdown_count'
|
|
|
e0018b |
callback in implemented as papr_smart_get_shutdown_count().
|
|
|
e0018b |
|
|
|
e0018b |
Kernel side changes to support reporting DSC have been merged to linux kernel
|
|
|
e0018b |
via patch proposed at [1]. With updated kernel 'ndctl list -DH' reports
|
|
|
e0018b |
following output on PPC64:
|
|
|
e0018b |
|
|
|
e0018b |
$ sudo ndctl list -DH
|
|
|
e0018b |
[
|
|
|
e0018b |
{
|
|
|
e0018b |
"dev":"nmem0",
|
|
|
e0018b |
"health":{
|
|
|
e0018b |
"health_state":"ok",
|
|
|
e0018b |
"life_used_percentage":50,
|
|
|
e0018b |
"shutdown_state":"clean",
|
|
|
e0018b |
"shutdown_count":10
|
|
|
e0018b |
}
|
|
|
e0018b |
}
|
|
|
e0018b |
]
|
|
|
e0018b |
|
|
|
e0018b |
[1] http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210624080621.252038-1-vaibhav@linux.ibm.com
|
|
|
e0018b |
|
|
|
e0018b |
Link: https://lore.kernel.org/r/20220124185605.1465681-1-vaibhav@linux.ibm.com
|
|
|
e0018b |
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
|
e0018b |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
---
|
|
|
e0018b |
ndctl/lib/libndctl.c | 6 +++++-
|
|
|
e0018b |
ndctl/lib/papr.c | 23 +++++++++++++++++++++++
|
|
|
e0018b |
ndctl/lib/papr_pdsm.h | 6 ++++++
|
|
|
e0018b |
3 files changed, 34 insertions(+), 1 deletion(-)
|
|
|
e0018b |
|
|
|
e0018b |
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
|
|
|
e0018b |
index 47a234c..5979a92 100644
|
|
|
e0018b |
--- a/ndctl/lib/libndctl.c
|
|
|
e0018b |
+++ b/ndctl/lib/libndctl.c
|
|
|
e0018b |
@@ -1819,8 +1819,12 @@ static int add_papr_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
|
|
|
e0018b |
|
|
|
e0018b |
/* Allocate monitor mode fd */
|
|
|
e0018b |
dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
|
|
|
e0018b |
- rc = 0;
|
|
|
e0018b |
+ /* Get the dirty shutdown counter value */
|
|
|
e0018b |
+ sprintf(path, "%s/papr/dirty_shutdown", dimm_base);
|
|
|
e0018b |
+ if (sysfs_read_attr(ctx, path, buf) == 0)
|
|
|
e0018b |
+ dimm->dirty_shutdown = strtoll(buf, NULL, 0);
|
|
|
e0018b |
|
|
|
e0018b |
+ rc = 0;
|
|
|
e0018b |
} else if (strcmp(buf, "nvdimm_test") == 0) {
|
|
|
e0018b |
/* probe via common populate_dimm_attributes() */
|
|
|
e0018b |
rc = populate_dimm_attributes(dimm, dimm_base, "papr");
|
|
|
e0018b |
diff --git a/ndctl/lib/papr.c b/ndctl/lib/papr.c
|
|
|
e0018b |
index 43b8412..46cf9c1 100644
|
|
|
e0018b |
--- a/ndctl/lib/papr.c
|
|
|
e0018b |
+++ b/ndctl/lib/papr.c
|
|
|
e0018b |
@@ -165,6 +165,9 @@ static unsigned int papr_smart_get_flags(struct ndctl_cmd *cmd)
|
|
|
e0018b |
if (health.extension_flags & PDSM_DIMM_HEALTH_RUN_GAUGE_VALID)
|
|
|
e0018b |
flags |= ND_SMART_USED_VALID;
|
|
|
e0018b |
|
|
|
e0018b |
+ if (health.extension_flags & PDSM_DIMM_DSC_VALID)
|
|
|
e0018b |
+ flags |= ND_SMART_SHUTDOWN_COUNT_VALID;
|
|
|
e0018b |
+
|
|
|
e0018b |
return flags;
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
@@ -236,6 +239,25 @@ static unsigned int papr_smart_get_life_used(struct ndctl_cmd *cmd)
|
|
|
e0018b |
(100 - health.dimm_fuel_gauge) : 0;
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
+static unsigned int papr_smart_get_shutdown_count(struct ndctl_cmd *cmd)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+
|
|
|
e0018b |
+ struct nd_papr_pdsm_health health;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ /* Ignore in case of error or invalid pdsm */
|
|
|
e0018b |
+ if (!cmd_is_valid(cmd) ||
|
|
|
e0018b |
+ to_pdsm(cmd)->cmd_status != 0 ||
|
|
|
e0018b |
+ to_pdsm_cmd(cmd) != PAPR_PDSM_HEALTH)
|
|
|
e0018b |
+ return 0;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ /* get the payload from command */
|
|
|
e0018b |
+ health = to_payload(cmd)->health;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ return (health.extension_flags & PDSM_DIMM_DSC_VALID) ?
|
|
|
e0018b |
+ (health.dimm_dsc) : 0;
|
|
|
e0018b |
+
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
struct ndctl_dimm_ops * const papr_dimm_ops = &(struct ndctl_dimm_ops) {
|
|
|
e0018b |
.cmd_is_supported = papr_cmd_is_supported,
|
|
|
e0018b |
.smart_get_flags = papr_smart_get_flags,
|
|
|
e0018b |
@@ -245,4 +267,5 @@ struct ndctl_dimm_ops * const papr_dimm_ops = &(struct ndctl_dimm_ops) {
|
|
|
e0018b |
.smart_get_health = papr_smart_get_health,
|
|
|
e0018b |
.smart_get_shutdown_state = papr_smart_get_shutdown_state,
|
|
|
e0018b |
.smart_get_life_used = papr_smart_get_life_used,
|
|
|
e0018b |
+ .smart_get_shutdown_count = papr_smart_get_shutdown_count,
|
|
|
e0018b |
};
|
|
|
e0018b |
diff --git a/ndctl/lib/papr_pdsm.h b/ndctl/lib/papr_pdsm.h
|
|
|
e0018b |
index 1bac8a7..f45b1e4 100644
|
|
|
e0018b |
--- a/ndctl/lib/papr_pdsm.h
|
|
|
e0018b |
+++ b/ndctl/lib/papr_pdsm.h
|
|
|
e0018b |
@@ -75,6 +75,9 @@
|
|
|
e0018b |
/* Indicate that the 'dimm_fuel_gauge' field is valid */
|
|
|
e0018b |
#define PDSM_DIMM_HEALTH_RUN_GAUGE_VALID 1
|
|
|
e0018b |
|
|
|
e0018b |
+/* Indicate that the 'dimm_dsc' field is valid */
|
|
|
e0018b |
+#define PDSM_DIMM_DSC_VALID 2
|
|
|
e0018b |
+
|
|
|
e0018b |
/*
|
|
|
e0018b |
* Struct exchanged between kernel & ndctl in for PAPR_PDSM_HEALTH
|
|
|
e0018b |
* Various flags indicate the health status of the dimm.
|
|
|
e0018b |
@@ -103,6 +106,9 @@ struct nd_papr_pdsm_health {
|
|
|
e0018b |
|
|
|
e0018b |
/* Extension flag PDSM_DIMM_HEALTH_RUN_GAUGE_VALID */
|
|
|
e0018b |
__u16 dimm_fuel_gauge;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ /* Extension flag PDSM_DIMM_DSC_VALID */
|
|
|
e0018b |
+ __u64 dimm_dsc;
|
|
|
e0018b |
};
|
|
|
e0018b |
__u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
|
|
|
e0018b |
};
|
|
|
e0018b |
--
|
|
|
e0018b |
2.27.0
|
|
|
e0018b |
|