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