|
|
0670da |
libndctl, intel: Indicate supported smart-inject types
|
|
|
0670da |
|
|
|
0670da |
BZ:
|
|
|
0670da |
Brew:
|
|
|
0670da |
|
|
|
0670da |
commit edcd9b7e10b3b33a9660e412a2db1beab30936d3
|
|
|
0670da |
Author: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
|
0670da |
Date: Tue Jan 25 02:07:35 2022 +0530
|
|
|
0670da |
|
|
|
0670da |
libndctl, intel: Indicate supported smart-inject types
|
|
|
0670da |
|
|
|
0670da |
Presently the inject-smart code assumes support for injecting all
|
|
|
0670da |
smart-errors namely media-temperature, controller-temperature,
|
|
|
0670da |
spares-remaining, fatal-health and unsafe-shutdown. This assumption
|
|
|
0670da |
may break in case of other non-Intel NVDIMM types namely PAPR NVDIMMs
|
|
|
0670da |
which presently only have support for injecting unsafe-shutdown and
|
|
|
0670da |
fatal health events.
|
|
|
0670da |
|
|
|
0670da |
Trying to inject-smart errors on PAPR NVDIMMs causes problems as
|
|
|
0670da |
smart_inject() prematurely exits when trying to inject
|
|
|
0670da |
media-temperature smart-error errors out.
|
|
|
0670da |
|
|
|
0670da |
To fix this issue the patch proposes extending the definition of
|
|
|
0670da |
dimm_op 'smart_inject_supported' to return bitmap of flags indicating
|
|
|
0670da |
the type of smart-error injections supported by an NVDIMM. These types
|
|
|
0670da |
are indicated by the newly introduced defines ND_SMART_INJECT_* . A
|
|
|
0670da |
dimm-ops provide can return an bitmap composed of these flags back
|
|
|
0670da |
from its implementation of 'smart_inject_supported' to indicate to
|
|
|
0670da |
dimm_inject_smart() which type of smart-error injection it
|
|
|
0670da |
supports. In case of an error the dimm-op is still expected to return
|
|
|
0670da |
a negative error code back to the caller.
|
|
|
0670da |
|
|
|
0670da |
The patch updates intel_dimm_smart_inject_supported() to return a
|
|
|
0670da |
bitmap composed of all ND_SMART_INJECT_* flags to indicate support for
|
|
|
0670da |
all smart-error types.
|
|
|
0670da |
|
|
|
0670da |
Finally the patch also updates smart_inject() to test for specific
|
|
|
0670da |
ND_START_INJECT_* flags before sending a smart-inject command via
|
|
|
0670da |
dimm-provider.
|
|
|
0670da |
|
|
|
0670da |
Link: https://lore.kernel.org/r/20220124203735.1490186-1-vaibhav@linux.ibm.com
|
|
|
0670da |
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
|
|
|
0670da |
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
|
0670da |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
0670da |
|
|
|
0670da |
diff --git a/ndctl/inject-smart.c b/ndctl/inject-smart.c
|
|
|
0670da |
index 2b9d7e8..bd8c01e 100644
|
|
|
0670da |
--- a/ndctl/inject-smart.c
|
|
|
0670da |
+++ b/ndctl/inject-smart.c
|
|
|
0670da |
@@ -395,18 +395,26 @@ out:
|
|
|
0670da |
} \
|
|
|
0670da |
}
|
|
|
0670da |
|
|
|
0670da |
-static int smart_inject(struct ndctl_dimm *dimm)
|
|
|
0670da |
+static int smart_inject(struct ndctl_dimm *dimm, unsigned int inject_types)
|
|
|
0670da |
{
|
|
|
0670da |
const char *name = ndctl_dimm_get_devname(dimm);
|
|
|
0670da |
struct ndctl_cmd *si_cmd = NULL;
|
|
|
0670da |
int rc = -EOPNOTSUPP;
|
|
|
0670da |
|
|
|
0670da |
- send_inject_val(media_temperature)
|
|
|
0670da |
- send_inject_val(ctrl_temperature)
|
|
|
0670da |
- send_inject_val(spares)
|
|
|
0670da |
- send_inject_bool(fatal)
|
|
|
0670da |
- send_inject_bool(unsafe_shutdown)
|
|
|
0670da |
+ if (inject_types & ND_SMART_INJECT_MEDIA_TEMPERATURE)
|
|
|
0670da |
+ send_inject_val(media_temperature);
|
|
|
0670da |
|
|
|
0670da |
+ if (inject_types & ND_SMART_INJECT_CTRL_TEMPERATURE)
|
|
|
0670da |
+ send_inject_val(ctrl_temperature);
|
|
|
0670da |
+
|
|
|
0670da |
+ if (inject_types & ND_SMART_INJECT_SPARES_REMAINING)
|
|
|
0670da |
+ send_inject_val(spares);
|
|
|
0670da |
+
|
|
|
0670da |
+ if (inject_types & ND_SMART_INJECT_HEALTH_STATE)
|
|
|
0670da |
+ send_inject_bool(fatal);
|
|
|
0670da |
+
|
|
|
0670da |
+ if (inject_types & ND_SMART_INJECT_UNCLEAN_SHUTDOWN)
|
|
|
0670da |
+ send_inject_bool(unsafe_shutdown);
|
|
|
0670da |
out:
|
|
|
0670da |
ndctl_cmd_unref(si_cmd);
|
|
|
0670da |
return rc;
|
|
|
0670da |
@@ -417,6 +425,7 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
|
|
|
0670da |
struct json_object *jhealth;
|
|
|
0670da |
struct json_object *jdimms;
|
|
|
0670da |
struct json_object *jdimm;
|
|
|
0670da |
+ unsigned int supported_types;
|
|
|
0670da |
int rc;
|
|
|
0670da |
|
|
|
0670da |
rc = ndctl_dimm_smart_inject_supported(dimm);
|
|
|
0670da |
@@ -433,6 +442,14 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
|
|
|
0670da |
error("%s: smart injection not supported by either platform firmware or the kernel.",
|
|
|
0670da |
ndctl_dimm_get_devname(dimm));
|
|
|
0670da |
return rc;
|
|
|
0670da |
+ default:
|
|
|
0670da |
+ if (rc < 0) {
|
|
|
0670da |
+ error("%s: Unknown error %d while checking for smart injection support",
|
|
|
0670da |
+ ndctl_dimm_get_devname(dimm), rc);
|
|
|
0670da |
+ return rc;
|
|
|
0670da |
+ }
|
|
|
0670da |
+ supported_types = rc;
|
|
|
0670da |
+ break;
|
|
|
0670da |
}
|
|
|
0670da |
|
|
|
0670da |
if (sctx.op_mask & (1 << OP_SET)) {
|
|
|
0670da |
@@ -441,7 +458,7 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
|
|
|
0670da |
goto out;
|
|
|
0670da |
}
|
|
|
0670da |
if (sctx.op_mask & (1 << OP_INJECT)) {
|
|
|
0670da |
- rc = smart_inject(dimm);
|
|
|
0670da |
+ rc = smart_inject(dimm, supported_types);
|
|
|
0670da |
if (rc)
|
|
|
0670da |
goto out;
|
|
|
0670da |
}
|
|
|
0670da |
diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c
|
|
|
0670da |
index a3df26e..1314854 100644
|
|
|
0670da |
--- a/ndctl/lib/intel.c
|
|
|
0670da |
+++ b/ndctl/lib/intel.c
|
|
|
0670da |
@@ -455,7 +455,12 @@ static int intel_dimm_smart_inject_supported(struct ndctl_dimm *dimm)
|
|
|
0670da |
return -EIO;
|
|
|
0670da |
}
|
|
|
0670da |
|
|
|
0670da |
- return 0;
|
|
|
0670da |
+ /* Indicate all smart injection types are supported */
|
|
|
0670da |
+ return ND_SMART_INJECT_SPARES_REMAINING |
|
|
|
0670da |
+ ND_SMART_INJECT_MEDIA_TEMPERATURE |
|
|
|
0670da |
+ ND_SMART_INJECT_CTRL_TEMPERATURE |
|
|
|
0670da |
+ ND_SMART_INJECT_HEALTH_STATE |
|
|
|
0670da |
+ ND_SMART_INJECT_UNCLEAN_SHUTDOWN;
|
|
|
0670da |
}
|
|
|
0670da |
|
|
|
0670da |
static const char *intel_cmd_desc(int fn)
|
|
|
0670da |
diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
|
|
|
0670da |
index b59026c..4d5cdbf 100644
|
|
|
0670da |
--- a/ndctl/libndctl.h
|
|
|
0670da |
+++ b/ndctl/libndctl.h
|
|
|
0670da |
@@ -69,6 +69,13 @@ extern "C" {
|
|
|
0670da |
#define ND_EVENT_HEALTH_STATE (1 << 3)
|
|
|
0670da |
#define ND_EVENT_UNCLEAN_SHUTDOWN (1 << 4)
|
|
|
0670da |
|
|
|
0670da |
+/* Flags indicating support for various smart injection types */
|
|
|
0670da |
+#define ND_SMART_INJECT_SPARES_REMAINING (1 << 0)
|
|
|
0670da |
+#define ND_SMART_INJECT_MEDIA_TEMPERATURE (1 << 1)
|
|
|
0670da |
+#define ND_SMART_INJECT_CTRL_TEMPERATURE (1 << 2)
|
|
|
0670da |
+#define ND_SMART_INJECT_HEALTH_STATE (1 << 3)
|
|
|
0670da |
+#define ND_SMART_INJECT_UNCLEAN_SHUTDOWN (1 << 4)
|
|
|
0670da |
+
|
|
|
0670da |
size_t ndctl_min_namespace_size(void);
|
|
|
0670da |
size_t ndctl_sizeof_namespace_index(void);
|
|
|
0670da |
size_t ndctl_sizeof_namespace_label(void);
|
|
|
0670da |
@@ -311,6 +318,7 @@ int ndctl_cmd_smart_inject_spares(struct ndctl_cmd *cmd, bool enable,
|
|
|
0670da |
unsigned int spares);
|
|
|
0670da |
int ndctl_cmd_smart_inject_fatal(struct ndctl_cmd *cmd, bool enable);
|
|
|
0670da |
int ndctl_cmd_smart_inject_unsafe_shutdown(struct ndctl_cmd *cmd, bool enable);
|
|
|
0670da |
+/* Returns a bitmap of ND_SMART_INJECT_* supported */
|
|
|
0670da |
int ndctl_dimm_smart_inject_supported(struct ndctl_dimm *dimm);
|
|
|
0670da |
|
|
|
0670da |
struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(struct ndctl_dimm *dimm,
|