ndctl: clear error support for v52
Subsystems (2)
cover ndctl: clear error support for v52
Add libndctl support for the new "clear error" command based on section 9.20.7.6 "Function Index 4 - Clear Uncorrectable Error" from the ACPI 6.1 specification. This uncovered some minor address-range-scrub command fixups.
---
Dan Williams (3):
ndctl: fix ndctl_bus_cmd_new_ars_status() input validation
ndctl: disable nfit_test regions after test
ndctl: add 'clear error' command support
configure.ac | 19 +++++++ lib/libndctl-ars.c | 127 ++++++++++++++++++++++++++++++++++++++++++------ lib/libndctl-private.h | 5 ++ lib/libndctl.c | 3 + lib/libndctl.sym | 3 + lib/ndctl/libndctl.h | 41 +++++++++++++++ ndctl.h | 13 +++++ test/libndctl.c | 68 +++++++++++++++++++++++++- 8 files changed, 259 insertions(+), 20 deletions(-)
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 1/3 ndctl: fix ndctl_bus_cmd_new_ars_status() input validation
Check that ars_status, rather than ars_cap, commands are supported and validate that the reference ars_cap passed in is indeed and ars_cap command.
--- lib/libndctl-ars.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/libndctl-ars.c +3 -3
@@ -55,7 +55,7 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_start(struct ndctl_cmd *arsdbg (ctx,"unsupported cmd\n" );return NULL ; } -if (ars_cap->status !=0 ) { +if (ars_cap->type !=ND_CMD_ARS_CAP || ars_cap->status !=0 ) {dbg (ctx,"expected sucessfully completed ars_cap command\n" );return NULL ; }
@@ -94,11 +94,11 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *arstruct ndctl_cmd *cmd;size_t size; -if (!ndctl_bus_is_cmd_supported (bus,ND_CMD_ARS_CAP )) { +if (!ndctl_bus_is_cmd_supported (bus,ND_CMD_ARS_STATUS )) {dbg (ctx,"unsupported cmd\n" );return NULL ; } -if (ars_cap->status !=0 ) { +if (ars_cap->type !=ND_CMD_ARS_CAP || ars_cap->status !=0 ) {dbg (ctx,"expected sucessfully completed ars_cap command\n" );return NULL ; }
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [ndctl PATCH 1/3] ndctl: fix ndctl_bus_cmd_new_ars_status() input validation
Quoted 2 lines · Dan Williams
Check that
ars_status, rather thanars_cap, commands are supported and validate that the referencears_cappassed in is indeed andars_cap
s/and/an/
Quoted 29 lines
command.
Cc Vishal Verma <[email protected]>Signed-off-by Dan Williams <[email protected]>---
lib/libndctl-ars.c | 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)lib/libndctl-ars.c +1
-1@@ -55,7 +55,7 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_start(struct ndctl_cmd *ars dbg(ctx, "unsupported cmd\n"); return NULL; } -if (ars_cap->status !=0 ) { +if (ars_cap->type !=ND_CMD_ARS_CAP || ars_cap->status !=0 ) {
dbg(ctx, "expected sucessfully completed ars_cap command\n");
return NULL;
}lib/libndctl-ars.c +0
-0@@ -94,11 +94,11 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ar struct ndctl_cmd *cmd; size_t size;
lib/libndctl-ars.c NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ar · line 97
Quoted 2 lines
lib/libndctl-ars.c +1
-1-if (!ndctl_bus_is_cmd_supported (bus,ND_CMD_ARS_CAP )) { +if (!ndctl_bus_is_cmd_supported (bus,ND_CMD_ARS_STATUS )) {
Good catch :)
Quoted 11 lines
dbg(ctx, "unsupported cmd\n");
return NULL;
}lib/libndctl-ars.c +1
-1-if (ars_cap->status !=0 ) { +if (ars_cap->type !=ND_CMD_ARS_CAP || ars_cap->status !=0 ){
dbg(ctx, "expected sucessfully completed ars_cap command\n");
return NULL;
}
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 2/3 ndctl: disable nfit_test regions after test
In reply to Dan WilliamsEnsure that all nfit_test regions are disabled after a successful test so the module can be removed. Otherwise test/libndctl will not run back-to-back runs in the case of "make TESTS=test/libndctl check".
--- test/libndctl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
test/libndctl.c +5 -1
@@ -482,11 +482,11 @@ static int check_btts(struct ndctl_region *region, struct btt **btts);static int check_regions (struct ndctl_bus *bus,struct region *regions,int n,enum ns_mode mode) { +struct ndctl_region *region;int i, rc =0 ;for (i =0 ; i < n; i++) {struct ndctl_interleave_set *iset; -struct ndctl_region *region;char devname[50 ];if (strcmp (regions[i].type,"pmem" ) ==0 )
@@ -566,6 +566,10 @@ static int check_regions(struct ndctl_bus *bus, struct region *regions, int n,break ; } +if (rc ==0 ) + ndctl_region_foreach(bus, region) +ndctl_region_disable_invalidate (region); +return rc; }
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 3/3 ndctl: add 'clear error' command support
In reply to Dan WilliamsImport the clear error command definition from the latest kernel, wire it up with a new ndctl_bus_cmd_new_clear_error() api, and add an invocation to the unit test.
Since, the unit test requires the ability to recall the range of an ars_cap command a new ndctl_cmd_ars_cap_get_range() api is added.
--- configure.ac | 19 +++++++ lib/libndctl-ars.c | 125 +++++++++++++++++++++++++++++++++++++++++++----- lib/libndctl-private.h | 5 ++ lib/libndctl.c | 3 + lib/libndctl.sym | 3 + lib/ndctl/libndctl.h | 41 +++++++++++++++- ndctl.h | 13 +++++ test/libndctl.c | 62 +++++++++++++++++++++++- 8 files changed, 253 insertions(+), 18 deletions(-)
configure.ac +19 -0
@@ -125,6 +125,25 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ) AM_CONDITIONAL([ENABLE_ARS], [test "x$enable_ars" = "xyes"]) +AC_MSG_CHECKING([for CLEAR ERR support]) +AC_LANG(C) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #ifdef HAVE_NDCTL_H + #include <linux/ndctl.h> + #else + #include "ndctl.h" + #endif + ]], [[ + int x = ND_CMD_CLEAR_ERROR; + ]] + )], [AC_MSG_RESULT([yes]) + enable_clear_err=yes + AC_DEFINE([HAVE_NDCTL_CLEAR_ERROR], [1], + [Define to 1 if ndctl.h has CLEAR ERR support.]) + ], [AC_MSG_RESULT([no])] +) +AM_CONDITIONAL([ENABLE_CLEAR_ERROR], [test "x$enable_clear_err" = "xyes"]) + AC_CHECK_HEADERS_ONCE([linux/version.h]) AC_CHECK_FUNCS([ \
lib/libndctl-ars.c +111 -14
154 lines not on this page · raw message
lib/libndctl-private.h +5 -0
@@ -159,9 +159,14 @@ struct ndctl_cmd { } iter;struct ndctl_cmd *source;union { +#ifdef HAVE_NDCTL_ARS struct nd_cmd_ars_cap ars_cap[0 ];struct nd_cmd_ars_start ars_start[0 ];struct nd_cmd_ars_status ars_status[0 ]; +#endif +#ifdef HAVE_NDCTL_CLEAR_ERROR +struct nd_cmd_clear_error clear_err[0 ]; +#endif struct nd_cmd_get_config_size get_size[0 ];struct nd_cmd_get_config_data_hdr get_data[0 ];struct nd_cmd_set_config_hdr set_data[0 ];
lib/libndctl.c +2 -1
@@ -809,7 +809,7 @@ static int to_dsm_index(const char *name, int dimm) end_cmd =ND_CMD_VENDOR ; cmd_name_fn = nvdimm_cmd_name; }else { - end_cmd =ND_CMD_ARS_STATUS ; + end_cmd =ND_CMD_CLEAR_ERROR ; cmd_name_fn = nvdimm_bus_cmd_name; }
@@ -2103,6 +2103,7 @@ static int to_ioctl_cmd(int cmd, int dimm)case ND_CMD_ARS_CAP :return ND_IOCTL_ARS_CAP ;case ND_CMD_ARS_START :return ND_IOCTL_ARS_START ;case ND_CMD_ARS_STATUS :return ND_IOCTL_ARS_STATUS ; +case ND_CMD_CLEAR_ERROR :return ND_IOCTL_CLEAR_ERROR ;default :return 0 ; };
lib/libndctl.sym +3 -0
@@ -69,10 +69,13 @@ global: ndctl_bus_cmd_new_ars_start; ndctl_bus_cmd_new_ars_status; ndctl_cmd_ars_cap_get_size; + ndctl_cmd_ars_cap_get_range; ndctl_cmd_ars_in_progress; ndctl_cmd_ars_num_records; ndctl_cmd_ars_get_record_addr; ndctl_cmd_ars_get_record_len; + ndctl_bus_cmd_new_clear_error; + ndctl_cmd_clear_error_get_cleared; ndctl_dimm_cmd_new_vendor_specific; ndctl_cmd_vendor_set_input; ndctl_cmd_vendor_get_output_size;
lib/ndctl/libndctl.h +40 -1
66 lines not on this page · raw message
ndctl.h +13 -0
@@ -98,6 +98,14 @@ struct nd_cmd_ars_status { } __attribute__((packed)) records[0]; } __attribute__((packed)); +struct nd_cmd_clear_error { +__u64 address; +__u64 length; +__u32 status; +__u8 reserved[4 ]; +__u64 cleared; +} __attribute__((packed)); +enum {ND_CMD_IMPLEMENTED =0 ,
@@ -105,6 +113,7 @@ enum {ND_CMD_ARS_CAP =1 ,ND_CMD_ARS_START =2 ,ND_CMD_ARS_STATUS =3 , +ND_CMD_CLEAR_ERROR =4 ,/* per-dimm commands */ ND_CMD_SMART = 1,
@@ -129,6 +138,7 @@ static __inline__ const char *nvdimm_bus_cmd_name(unsigned cmd) [ND_CMD_ARS_CAP] = "ars_cap", [ND_CMD_ARS_START] = "ars_start", [ND_CMD_ARS_STATUS] = "ars_status", + [ND_CMD_CLEAR_ERROR] = "clear_error", };if (cmd <ARRAY_SIZE (names) && names[cmd])
@@ -187,6 +197,9 @@ static __inline__ const char *nvdimm_cmd_name(unsigned cmd)#define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS,\ struct nd_cmd_ars_status) +#define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR,\ + struct nd_cmd_ars_status) +#define ND_DEVICE_DIMM 1/* nd_dimm: container for "config data" */ #define ND_DEVICE_REGION_PMEM 2/* nd_region: (parent of PMEM namespaces) */ #define ND_DEVICE_REGION_BLK 3/* nd_region: (parent of BLK namespaces) */
test/libndctl.c +60 -2
92 lines not on this page · raw message
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [ndctl PATCH 3/3] ndctl: add 'clear error' command support
Quoted 19 lines · Dan Williams
Import the clear error command definition from the latest kernel, wire it up with a new
ndctl_bus_cmd_new_clear_error()api, and add an invocation to the unit test.Since, the unit test requires the ability to recall the range of an
ars_capcommand a newndctl_cmd_ars_cap_get_range()api is added.Reported-by Vishal Verma <[email protected]>Signed-off-by Dan Williams <[email protected]>---
configure.ac | 19 +++++++ lib/libndctl-ars.c | 125
+++++++++++++++++++++++++++++++++++++++++++-----
lib/libndctl-private.h | 5 ++ lib/libndctl.c | 3 + lib/libndctl.sym | 3 + lib/ndctl/libndctl.h | 41 +++++++++++++++- ndctl.h | 13 +++++ test/libndctl.c | 62 +++++++++++++++++++++++-
Quoted 3 lines
8 files changed, 253 insertions(+), 18 deletions(-)
<>
Quoted 44 lines
ndctl.h +0
-0@@ -98,6 +98,14 @@ struct nd_cmd_ars_status { } __attribute__((packed)) records[0]; } __attribute__((packed));ndctl.h +8
-0+struct nd_cmd_clear_error { +__u64 address; +__u64 length; +__u32 status; +__u8 reserved[4 ]; +__u64 cleared; +} __attribute__((packed)); +enum {
ND_CMD_IMPLEMENTED= 0,ndctl.h +1
-0@@ -105,6 +113,7 @@ enum { ND_CMD_ARS_CAP = 1, ND_CMD_ARS_START = 2, ND_CMD_ARS_STATUS = 3, + ND_CMD_CLEAR_ERROR = 4,
/* per-dimm commands */
ND_CMD_SMART= 1,ndctl.h +1
-0@@ -129,6 +138,7 @@ static __inline__ const char *nvdimm_bus_cmd_name(unsigned cmd) [ND_CMD_ARS_CAP] = "ars_cap", [ND_CMD_ARS_START] = "ars_start", [ND_CMD_ARS_STATUS] = "ars_status", + [ND_CMD_CLEAR_ERROR] = "clear_error", };
if (cmd <ARRAY_SIZE(names)&& names[cmd])ndctl.h +0
-0@@ -187,6 +197,9 @@ static __inline__ const char *nvdimm_cmd_name(unsigned cmd) #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL,ND_CMD_ARS_STATUS ,\ struct nd_cmd_ars_status)
+#defineND_IOCTL_CLEAR_ERROR_IOWR(ND_IOCTL,
ND_CMD_CLEAR_ERROR,\
ndctl.h static __inline__ const char *nvdimm_cmd_name(unsigned cmd) · line 202
Quoted 2 lines
ndctl.h +2
-0+ struct nd_cmd_ars_status) +
Did you copy from the old version of this kernel header with the copy- paste error :)
Rest of it looks good,
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [ndctl PATCH 3/3] ndctl: add 'clear error' command support
Quoted 68 lines · Vishal L
Quoted 9 lines · Dan Williams
Import the clear error command definition from the latest kernel, wire it up with a new
ndctl_bus_cmd_new_clear_error()api, and add an invocation to the unit test.Since, the unit test requires the ability to recall the range of an
ars_capcommand a newndctl_cmd_ars_cap_get_range()api is added.Reported-by Vishal Verma <[email protected]>Signed-off-by Dan Williams <[email protected]>Quoted 13 lines
--- configure.ac | 19 +++++++ lib/libndctl-ars.c | 125 +++++++++++++++++++++++++++++++++++++++++++----- lib/libndctl-private.h | 5 ++ lib/libndctl.c | 3 + lib/libndctl.sym | 3 + lib/ndctl/libndctl.h | 41 +++++++++++++++- ndctl.h | 13 +++++ test/libndctl.c | 62 +++++++++++++++++++++++- 8 files changed, 253 insertions(+), 18 deletions(-)<>
Quoted 42 lines
ndctl.h +10
-0@@ -98,6 +98,14 @@ struct nd_cmd_ars_status { } __attribute__((packed)) records[0]; } __attribute__((packed)); +struct nd_cmd_clear_error { +__u64 address; +__u64 length; +__u32 status; +__u8 reserved[4 ]; +__u64 cleared; +} __attribute__((packed)); +enum {ND_CMD_IMPLEMENTED =0 ,@@ -105,6 +113,7 @@ enum {ND_CMD_ARS_CAP =1 ,ND_CMD_ARS_START =2 ,ND_CMD_ARS_STATUS =3 , +ND_CMD_CLEAR_ERROR =4 ,/* per-dimm commands */ ND_CMD_SMART = 1,@@ -129,6 +138,7 @@ static __inline__ const char *nvdimm_bus_cmd_name(unsigned cmd) [ND_CMD_ARS_CAP] = "ars_cap", [ND_CMD_ARS_START] = "ars_start", [ND_CMD_ARS_STATUS] = "ars_status", + [ND_CMD_CLEAR_ERROR] = "clear_error", };if (cmd < ARRAY_SIZE(names) && names[cmd])ndctl.h +0
-0@@ -187,6 +197,9 @@ static __inline__ const char *nvdimm_cmd_name(unsigned cmd)#define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL,ND_CMD_ARS_STATUS ,\ struct nd_cmd_ars_status)
Quoted 8 lines
ndctl.h static __inline__ const char *nvdimm_cmd_name(unsigned cmd) · line 202
Quoted 4 lines
ndctl.h +3
-0+#define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL,ND_CMD_CLEAR_ERROR ,\ + struct nd_cmd_ars_status) +Did you copy from the old version of this kernel header with the copy- paste error :)
If I said "no" I don't think you'd believe me.
Quoted 2 lines
Rest of it looks good,
Reviewed-by Vishal Verma <[email protected]>
Thanks!
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm