|
|
e0018b |
From e423b467e10e3405e6e09260b7669e7022b5f5f7 Mon Sep 17 00:00:00 2001
|
|
|
e0018b |
From: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Date: Wed, 5 Jan 2022 13:31:50 -0800
|
|
|
e0018b |
Subject: [PATCH 070/217] ndctl/test: Prepare for BLK-aperture support removal
|
|
|
e0018b |
|
|
|
e0018b |
The kernel is dropping its support for the BLK-aperture access method. The
|
|
|
e0018b |
primary side effect of this for nfit_test is that NVDIMM namespace labeling
|
|
|
e0018b |
will not be enabled by default. Update the unit tests to initialize the
|
|
|
e0018b |
label index area in this scenario.
|
|
|
e0018b |
|
|
|
e0018b |
Link: https://lore.kernel.org/r/164141830999.3990253.5021445352398348657.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
|
e0018b |
Tested-by: Alison Schofield <alison.schofield@intel.com>
|
|
|
e0018b |
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
|
e0018b |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
|
e0018b |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
---
|
|
|
e0018b |
test/core.c | 31 ++++++++++++++++++++++++++++---
|
|
|
e0018b |
test/libndctl.c | 49 +++++++++++++++++++++++++++++++++++--------------
|
|
|
e0018b |
2 files changed, 63 insertions(+), 17 deletions(-)
|
|
|
e0018b |
|
|
|
e0018b |
diff --git a/test/core.c b/test/core.c
|
|
|
e0018b |
index 2b03aa9..93e1dae 100644
|
|
|
e0018b |
--- a/test/core.c
|
|
|
e0018b |
+++ b/test/core.c
|
|
|
e0018b |
@@ -261,8 +261,8 @@ retry:
|
|
|
e0018b |
ndctl_bus_foreach(nd_ctx, bus) {
|
|
|
e0018b |
struct ndctl_region *region;
|
|
|
e0018b |
|
|
|
e0018b |
- if (strncmp(ndctl_bus_get_provider(bus),
|
|
|
e0018b |
- "nfit_test", 9) != 0)
|
|
|
e0018b |
+ if (strcmp(ndctl_bus_get_provider(bus),
|
|
|
e0018b |
+ "nfit_test.0") != 0)
|
|
|
e0018b |
continue;
|
|
|
e0018b |
ndctl_region_foreach(bus, region)
|
|
|
e0018b |
ndctl_region_disable_invalidate(region);
|
|
|
e0018b |
@@ -280,5 +280,30 @@ retry:
|
|
|
e0018b |
NULL, NULL, NULL, NULL);
|
|
|
e0018b |
if (rc)
|
|
|
e0018b |
kmod_unref(*ctx);
|
|
|
e0018b |
- return rc;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (!nd_ctx)
|
|
|
e0018b |
+ return rc;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ ndctl_bus_foreach (nd_ctx, bus) {
|
|
|
e0018b |
+ struct ndctl_region *region;
|
|
|
e0018b |
+ struct ndctl_dimm *dimm;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ if (strcmp(ndctl_bus_get_provider(bus), "nfit_test.0") != 0)
|
|
|
e0018b |
+ continue;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ ndctl_region_foreach (bus, region)
|
|
|
e0018b |
+ ndctl_region_disable_invalidate(region);
|
|
|
e0018b |
+
|
|
|
e0018b |
+ ndctl_dimm_foreach (bus, dimm) {
|
|
|
e0018b |
+ ndctl_dimm_read_label_index(dimm);
|
|
|
e0018b |
+ ndctl_dimm_init_labels(dimm, NDCTL_NS_VERSION_1_2);
|
|
|
e0018b |
+ ndctl_dimm_disable(dimm);
|
|
|
e0018b |
+ ndctl_dimm_enable(dimm);
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
+ ndctl_region_foreach (bus, region)
|
|
|
e0018b |
+ ndctl_region_enable(region);
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
+ return 0;
|
|
|
e0018b |
}
|
|
|
e0018b |
diff --git a/test/libndctl.c b/test/libndctl.c
|
|
|
e0018b |
index d9b50f4..c0e4b4c 100644
|
|
|
e0018b |
--- a/test/libndctl.c
|
|
|
e0018b |
+++ b/test/libndctl.c
|
|
|
e0018b |
@@ -2587,17 +2587,41 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
|
|
|
e0018b |
return 0;
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
-static void reset_bus(struct ndctl_bus *bus)
|
|
|
e0018b |
+enum dimm_reset {
|
|
|
e0018b |
+ DIMM_INIT,
|
|
|
e0018b |
+ DIMM_ZERO,
|
|
|
e0018b |
+};
|
|
|
e0018b |
+
|
|
|
e0018b |
+static int reset_dimms(struct ndctl_bus *bus, enum dimm_reset reset)
|
|
|
e0018b |
{
|
|
|
e0018b |
- struct ndctl_region *region;
|
|
|
e0018b |
struct ndctl_dimm *dimm;
|
|
|
e0018b |
+ int rc = 0;
|
|
|
e0018b |
+
|
|
|
e0018b |
+ ndctl_dimm_foreach(bus, dimm) {
|
|
|
e0018b |
+ if (reset == DIMM_ZERO)
|
|
|
e0018b |
+ ndctl_dimm_zero_labels(dimm);
|
|
|
e0018b |
+ else {
|
|
|
e0018b |
+ ndctl_dimm_read_label_index(dimm);
|
|
|
e0018b |
+ ndctl_dimm_init_labels(dimm, NDCTL_NS_VERSION_1_2);
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+ ndctl_dimm_disable(dimm);
|
|
|
e0018b |
+ rc = ndctl_dimm_enable(dimm);
|
|
|
e0018b |
+ if (rc)
|
|
|
e0018b |
+ break;
|
|
|
e0018b |
+ }
|
|
|
e0018b |
+
|
|
|
e0018b |
+ return rc;
|
|
|
e0018b |
+}
|
|
|
e0018b |
+
|
|
|
e0018b |
+static void reset_bus(struct ndctl_bus *bus, enum dimm_reset reset)
|
|
|
e0018b |
+{
|
|
|
e0018b |
+ struct ndctl_region *region;
|
|
|
e0018b |
|
|
|
e0018b |
/* disable all regions so that set_config_data commands are permitted */
|
|
|
e0018b |
ndctl_region_foreach(bus, region)
|
|
|
e0018b |
ndctl_region_disable_invalidate(region);
|
|
|
e0018b |
|
|
|
e0018b |
- ndctl_dimm_foreach(bus, dimm)
|
|
|
e0018b |
- ndctl_dimm_zero_labels(dimm);
|
|
|
e0018b |
+ reset_dimms(bus, reset);
|
|
|
e0018b |
|
|
|
e0018b |
/* set regions back to their default state */
|
|
|
e0018b |
ndctl_region_foreach(bus, region)
|
|
|
e0018b |
@@ -2608,7 +2632,6 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
|
|
|
e0018b |
{
|
|
|
e0018b |
struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
|
|
|
e0018b |
struct ndctl_region *region;
|
|
|
e0018b |
- struct ndctl_dimm *dimm;
|
|
|
e0018b |
int rc;
|
|
|
e0018b |
|
|
|
e0018b |
if (!bus)
|
|
|
e0018b |
@@ -2625,13 +2648,10 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
|
|
|
e0018b |
if (rc)
|
|
|
e0018b |
return rc;
|
|
|
e0018b |
|
|
|
e0018b |
- ndctl_dimm_foreach(bus, dimm) {
|
|
|
e0018b |
- rc = ndctl_dimm_zero_labels(dimm);
|
|
|
e0018b |
- if (rc < 0) {
|
|
|
e0018b |
- fprintf(stderr, "failed to zero %s\n",
|
|
|
e0018b |
- ndctl_dimm_get_devname(dimm));
|
|
|
e0018b |
- return rc;
|
|
|
e0018b |
- }
|
|
|
e0018b |
+ rc = reset_dimms(bus, DIMM_INIT);
|
|
|
e0018b |
+ if (rc < 0) {
|
|
|
e0018b |
+ fprintf(stderr, "failed to reset dimms\n");
|
|
|
e0018b |
+ return rc;
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
/*
|
|
|
e0018b |
@@ -2649,14 +2669,14 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
|
|
|
e0018b |
rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), DAX);
|
|
|
e0018b |
if (rc)
|
|
|
e0018b |
return rc;
|
|
|
e0018b |
- reset_bus(bus);
|
|
|
e0018b |
+ reset_bus(bus, DIMM_INIT);
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
if (ndctl_test_attempt(test, KERNEL_VERSION(4, 8, 0))) {
|
|
|
e0018b |
rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), PFN);
|
|
|
e0018b |
if (rc)
|
|
|
e0018b |
return rc;
|
|
|
e0018b |
- reset_bus(bus);
|
|
|
e0018b |
+ reset_bus(bus, DIMM_INIT);
|
|
|
e0018b |
}
|
|
|
e0018b |
|
|
|
e0018b |
return check_regions(bus, regions0, ARRAY_SIZE(regions0), BTT);
|
|
|
e0018b |
@@ -2671,6 +2691,7 @@ static int do_test1(struct ndctl_ctx *ctx, struct ndctl_test *test)
|
|
|
e0018b |
return -ENXIO;
|
|
|
e0018b |
|
|
|
e0018b |
ndctl_bus_wait_probe(bus);
|
|
|
e0018b |
+ reset_bus(bus, DIMM_ZERO);
|
|
|
e0018b |
|
|
|
e0018b |
/*
|
|
|
e0018b |
* Starting with v4.10 the dimm on nfit_test.1 gets a unique
|
|
|
e0018b |
--
|
|
|
e0018b |
2.27.0
|
|
|
e0018b |
|