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