* [PATCH] Don't treat DSM commands as NFIT specific
@ 2020-08-17 4:55 Santosh Sivaraj
0 siblings, 0 replies; only message in thread
From: Santosh Sivaraj @ 2020-08-17 4:55 UTC (permalink / raw)
To: Linux NVDIMM; +Cc: Aneesh Kumar K.V, Vaibhav Jain
The DSM commands are treated exclusively as NFIT commands, remove NFIT
dependency on using DSM commands.
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
ndctl/lib/inject.c | 6 +++---
ndctl/lib/libndctl.c | 29 ++++++++++++++++++++++-------
ndctl/lib/libndctl.sym | 4 ++++
ndctl/lib/nfit.c | 35 +++++++++--------------------------
ndctl/lib/private.h | 2 +-
ndctl/libndctl-nfit.h | 8 --------
ndctl/libndctl.h | 9 +++++++++
7 files changed, 48 insertions(+), 45 deletions(-)
diff --git a/ndctl/lib/inject.c b/ndctl/lib/inject.c
index 815f254..ab0bee5 100644
--- a/ndctl/lib/inject.c
+++ b/ndctl/lib/inject.c
@@ -26,9 +26,9 @@ NDCTL_EXPORT int ndctl_bus_has_error_injection(struct ndctl_bus *bus)
if (!bus || !ndctl_bus_has_nfit(bus))
return 0;
- if (ndctl_bus_is_nfit_cmd_supported(bus, NFIT_CMD_ARS_INJECT_SET) &&
- ndctl_bus_is_nfit_cmd_supported(bus, NFIT_CMD_ARS_INJECT_GET) &&
- ndctl_bus_is_nfit_cmd_supported(bus, NFIT_CMD_ARS_INJECT_CLEAR))
+ if (ndctl_bus_is_dsm_supported(bus, DSM_CMD_ARS_INJECT_SET) &&
+ ndctl_bus_is_dsm_supported(bus, DSM_CMD_ARS_INJECT_GET) &&
+ ndctl_bus_is_dsm_supported(bus, DSM_CMD_ARS_INJECT_CLEAR))
return 1;
return 0;
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 952192c..410fd16 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -884,12 +884,6 @@ static void *add_bus(void *parent, int id, const char *ctl_base)
else
bus->has_of_node = 1;
- sprintf(path, "%s/device/nfit/dsm_mask", ctl_base);
- if (sysfs_read_attr(ctx, path, buf) < 0)
- bus->nfit_dsm_mask = 0;
- else
- bus->nfit_dsm_mask = strtoul(buf, NULL, 0);
-
sprintf(path, "%s/device/provider", ctl_base);
if (sysfs_read_attr(ctx, path, buf) < 0)
goto err_read;
@@ -898,12 +892,20 @@ static void *add_bus(void *parent, int id, const char *ctl_base)
if (!bus->provider)
goto err_read;
+ sprintf(path, "%s/device/%s/dsm_mask", ctl_base,
+ ndctl_bus_has_nfit(bus) ? "nfit" : bus->provider);
+ if (sysfs_read_attr(ctx, path, buf) < 0)
+ bus->dsm_mask = 0;
+ else
+ bus->dsm_mask = strtoul(buf, NULL, 0);
+
sprintf(path, "%s/device/wait_probe", ctl_base);
bus->wait_probe_path = strdup(path);
if (!bus->wait_probe_path)
goto err_read;
- sprintf(path, "%s/device/nfit/scrub", ctl_base);
+ sprintf(path, "%s/device/%s/scrub", ctl_base,
+ ndctl_bus_has_nfit(bus) ? "nfit" : bus->provider);
bus->scrub_path = strdup(path);
if (!bus->scrub_path)
goto err_read;
@@ -1236,6 +1238,19 @@ NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus,
return !!(bus->cmd_mask & (1ULL << cmd));
}
+/**
+ * ndctl_bus_is_cmd_supported - ask if command is supported on @bus.
+ * @bus: ndctl_bus instance
+ * @cmd: command number (defined as NFIT_CMD_XXX in libndctl-nfit.h)
+ *
+ * Return 1: command is supported. Return 0: command is not supported.
+ *
+ */
+NDCTL_EXPORT int ndctl_bus_is_dsm_supported(struct ndctl_bus *bus, int cmd)
+{
+ return !!(bus->dsm_mask & (1ULL << cmd));
+}
+
NDCTL_EXPORT unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus)
{
return bus->revision;
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index 7ba1dcc..640342c 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -437,3 +437,7 @@ LIBNDCTL_24 {
ndctl_bus_is_papr_scm;
ndctl_region_has_numa;
} LIBNDCTL_23;
+
+LIBNDCTL_25 {
+ ndctl_bus_is_dsm_supported;
+} LIBNDCTL_24;
diff --git a/ndctl/lib/nfit.c b/ndctl/lib/nfit.c
index f9fbe73..be252e0 100644
--- a/ndctl/lib/nfit.c
+++ b/ndctl/lib/nfit.c
@@ -20,39 +20,22 @@ static u32 bus_get_firmware_status(struct ndctl_cmd *cmd)
struct nd_cmd_bus *cmd_bus = cmd->cmd_bus;
switch (cmd_bus->gen.nd_command) {
- case NFIT_CMD_TRANSLATE_SPA:
+ case DSM_CMD_TRANSLATE_SPA:
return cmd_bus->xlat_spa.status;
- case NFIT_CMD_ARS_INJECT_SET:
+ case DSM_CMD_ARS_INJECT_SET:
return cmd_bus->err_inj.status;
- case NFIT_CMD_ARS_INJECT_CLEAR:
+ case DSM_CMD_ARS_INJECT_CLEAR:
return cmd_bus->err_inj_clr.status;
- case NFIT_CMD_ARS_INJECT_GET:
+ case DSM_CMD_ARS_INJECT_GET:
return cmd_bus->err_inj_stat.status;
}
return -1U;
}
-/**
- * ndctl_bus_is_nfit_cmd_supported - ask nfit command is supported on @bus.
- * @bus: ndctl_bus instance
- * @cmd: nfit command number (defined as NFIT_CMD_XXX in libndctl-nfit.h)
- *
- * Return 1: command is supported. Return 0: command is not supported.
- *
- */
-NDCTL_EXPORT int ndctl_bus_is_nfit_cmd_supported(struct ndctl_bus *bus,
- int cmd)
-{
- return !!(bus->nfit_dsm_mask & (1ULL << cmd));
-}
-
static int bus_has_translate_spa(struct ndctl_bus *bus)
{
- if (!ndctl_bus_has_nfit(bus))
- return 0;
-
- return ndctl_bus_is_nfit_cmd_supported(bus, NFIT_CMD_TRANSLATE_SPA);
+ return ndctl_bus_is_dsm_supported(bus, DSM_CMD_TRANSLATE_SPA);
}
static struct ndctl_cmd *ndctl_bus_cmd_new_translate_spa(struct ndctl_bus *bus)
@@ -76,7 +59,7 @@ static struct ndctl_cmd *ndctl_bus_cmd_new_translate_spa(struct ndctl_bus *bus)
cmd->size = size;
cmd->status = 1;
pkg = &cmd->cmd_bus->gen;
- pkg->nd_command = NFIT_CMD_TRANSLATE_SPA;
+ pkg->nd_command = DSM_CMD_TRANSLATE_SPA;
pkg->nd_size_in = sizeof(unsigned long long);
pkg->nd_size_out = spa_length;
pkg->nd_fw_size = spa_length;
@@ -181,7 +164,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj(struct ndctl_bus *bus)
cmd->size = size;
cmd->status = 1;
pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0];
- pkg->nd_command = NFIT_CMD_ARS_INJECT_SET;
+ pkg->nd_command = DSM_CMD_ARS_INJECT_SET;
pkg->nd_size_in = offsetof(struct nd_cmd_ars_err_inj, status);
pkg->nd_size_out = cmd_length - pkg->nd_size_in;
pkg->nd_fw_size = pkg->nd_size_out;
@@ -208,7 +191,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_clr(struct ndctl_bus *bus)
cmd->size = size;
cmd->status = 1;
pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0];
- pkg->nd_command = NFIT_CMD_ARS_INJECT_CLEAR;
+ pkg->nd_command = DSM_CMD_ARS_INJECT_CLEAR;
pkg->nd_size_in = offsetof(struct nd_cmd_ars_err_inj_clr, status);
pkg->nd_size_out = cmd_length - pkg->nd_size_in;
pkg->nd_fw_size = pkg->nd_size_out;
@@ -237,7 +220,7 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_stat(struct ndctl_bus *bus,
cmd->size = size;
cmd->status = 1;
pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0];
- pkg->nd_command = NFIT_CMD_ARS_INJECT_GET;
+ pkg->nd_command = DSM_CMD_ARS_INJECT_GET;
pkg->nd_size_in = 0;
pkg->nd_size_out = cmd_length + buf_size;
pkg->nd_fw_size = pkg->nd_size_out;
diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h
index c3d5fd7..a498542 100644
--- a/ndctl/lib/private.h
+++ b/ndctl/lib/private.h
@@ -175,7 +175,7 @@ struct ndctl_bus {
char *wait_probe_path;
char *scrub_path;
unsigned long cmd_mask;
- unsigned long nfit_dsm_mask;
+ unsigned long dsm_mask;
};
/**
diff --git a/ndctl/libndctl-nfit.h b/ndctl/libndctl-nfit.h
index 8c4f72d..9c91d4a 100644
--- a/ndctl/libndctl-nfit.h
+++ b/ndctl/libndctl-nfit.h
@@ -23,14 +23,6 @@
* libndctl-nfit.h : definitions for NFIT related commands/functions.
*/
-/* nfit command numbers which are called via ND_CMD_CALL */
-enum {
- NFIT_CMD_TRANSLATE_SPA = 5,
- NFIT_CMD_ARS_INJECT_SET = 7,
- NFIT_CMD_ARS_INJECT_CLEAR = 8,
- NFIT_CMD_ARS_INJECT_GET = 9,
-};
-
/* error number of Translate SPA by firmware */
#define ND_TRANSLATE_SPA_STATUS_INVALID_SPA 2
diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
index dd21e2e..6390b2a 100644
--- a/ndctl/libndctl.h
+++ b/ndctl/libndctl.h
@@ -128,6 +128,7 @@ struct ndctl_bus *ndctl_bus_get_by_provider(struct ndctl_ctx *ctx,
const char *provider);
const char *ndctl_bus_get_cmd_name(struct ndctl_bus *bus, int cmd);
int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus, int cmd);
+int ndctl_bus_is_dsm_supported(struct ndctl_bus *bus, int cmd);
unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus);
unsigned int ndctl_bus_get_id(struct ndctl_bus *bus);
const char *ndctl_bus_get_provider(struct ndctl_bus *bus);
@@ -740,6 +741,14 @@ int ndctl_dimm_master_secure_erase(struct ndctl_dimm *dimm, long key);
#define NUMA_NO_NODE (-1)
#define NUMA_NO_ATTR (-2)
+/* DSM numbers which are called via ND_CMD_CALL */
+enum {
+ DSM_CMD_TRANSLATE_SPA = 5,
+ DSM_CMD_ARS_INJECT_SET = 7,
+ DSM_CMD_ARS_INJECT_CLEAR = 8,
+ DSM_CMD_ARS_INJECT_GET = 9,
+};
+
#ifdef __cplusplus
} /* extern "C" */
#endif
--
2.26.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-17 4:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 4:55 [PATCH] Don't treat DSM commands as NFIT specific Santosh Sivaraj
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).