All of lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl PATCH v3 00/16] ndctl: Meson support
@ 2022-01-05 21:31 Dan Williams
  2022-01-05 21:31 ` [ndctl PATCH v3 01/16] ndctl/docs: Clarify update-firwmware activation 'overflow' conditions Dan Williams
                   ` (18 more replies)
  0 siblings, 19 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:31 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: Vaibhav Jain, nvdimm, linux-cxl

Changes since v2 [1]:

- Rebase on v72
  - Add Meson support for the new config file directory definitions.
  - Add Meson support for landing the daxctl udev rule
    daxdev-reconfigure service in the right directories
- Include the deprecation of BLK Aperture test infrastructure
- Include a miscellaneous doc clarification for 'ndctl update-firmware'
- Fix the tests support for moving the build directory out-of-line
- Include a fix for the deprectation of the dax_pmem_compat module
  pending in the libnvdimm-for-next tree.

[1]: https://lore.kernel.org/r/163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com

---

As mentioned in patch 14 the motiviation for converting to Meson is
primarily driven by speed (an order of magnitude in some scenarios), but
Meson also includes better test and debug-build support. The build
language is easier to read, write, and debug. Meson is all around better
suited to the next phase of the ndctl project that will include all
things "device memory" related (ndctl, daxctl, and cxl).

In order to simplify the conversion the old BLK-aperture test
infrastructure is jettisoned and it will also be removed upstream. Some
other refactorings and fixups are included as well to better organize
the utilty infrastructure between truly common and sub-tool specific.

Vishal,

In preparation for ndctl-v73 please consider pulling in this series
early mainly for my own sanity of not needing to forward port more
updates to the autotools infrastructure.

---

Dan Williams (16):
      ndctl/docs: Clarify update-firwmware activation 'overflow' conditions
      ndctl/test: Prepare for BLK-aperture support removal
      ndctl/test: Move 'reset()' to function in 'common'
      ndctl/test: Initialize the label area by default
      ndctl/test: Skip BLK flags checks
      ndctl/test: Move sector-mode to a different region
      ndctl: Deprecate BLK aperture support
      ndctl/test: Fix support for missing dax_pmem_compat module
      util: Distribute 'filter' and 'json' helpers to per-tool objects
      Documentation: Drop attrs.adoc include
      build: Drop unnecessary $tool/config.h includes
      test: Prepare out of line builds
      ndctl: Drop executable bit for bash-completion script
      build: Add meson build infrastructure
      build: Add meson rpmbuild support
      ndctl: Jettison autotools


 .gitignore                                         |   64 -
 Documentation/cxl/Makefile.am                      |   61 -
 Documentation/cxl/lib/Makefile.am                  |   58 -
 Documentation/cxl/lib/meson.build                  |   79 +
 Documentation/cxl/meson.build                      |   84 +
 Documentation/daxctl/Makefile.am                   |   75 -
 Documentation/daxctl/daxctl-reconfigure-device.txt |    2 
 Documentation/daxctl/meson.build                   |   94 +
 Documentation/ndctl/Makefile.am                    |  106 -
 Documentation/ndctl/intel-nvdimm-security.txt      |    2 
 Documentation/ndctl/labels-description.txt         |    5 
 Documentation/ndctl/meson.build                    |  124 ++
 Documentation/ndctl/ndctl-create-namespace.txt     |   29 
 Documentation/ndctl/ndctl-init-labels.txt          |    7 
 Documentation/ndctl/ndctl-list.txt                 |    4 
 Documentation/ndctl/ndctl-load-keys.txt            |    2 
 Documentation/ndctl/ndctl-monitor.txt              |    2 
 Documentation/ndctl/ndctl-sanitize-dimm.txt        |    2 
 Documentation/ndctl/ndctl-setup-passphrase.txt     |    2 
 Documentation/ndctl/ndctl-update-firmware.txt      |   64 +
 Documentation/ndctl/ndctl-update-passphrase.txt    |    2 
 Documentation/ndctl/region-description.txt         |   10 
 Makefile.am                                        |  103 -
 Makefile.am.in                                     |   49 -
 README.md                                          |    1 
 autogen.sh                                         |   28 
 clean_config.sh                                    |    2 
 config.h.meson                                     |  151 ++
 configure.ac                                       |  270 ----
 contrib/meson.build                                |   28 
 contrib/ndctl                                      |    0 
 contrib/nfit_test_depmod.conf                      |    1 
 cxl/Makefile.am                                    |   22 
 cxl/filter.c                                       |   25 
 cxl/filter.h                                       |    7 
 cxl/json.c                                         |  214 +++
 cxl/json.h                                         |    8 
 cxl/lib/Makefile.am                                |   32 
 cxl/lib/meson.build                                |   35 
 cxl/list.c                                         |    4 
 cxl/memdev.c                                       |    3 
 cxl/meson.build                                    |   25 
 daxctl/Makefile.am                                 |   40 -
 daxctl/device.c                                    |    5 
 daxctl/filter.c                                    |   43 +
 daxctl/filter.h                                    |   12 
 daxctl/json.c                                      |  245 +++
 daxctl/json.h                                      |   18 
 daxctl/lib/Makefile.am                             |   42 -
 daxctl/lib/meson.build                             |   44 +
 daxctl/list.c                                      |    4 
 daxctl/meson.build                                 |   35 
 daxctl/migrate.c                                   |    1 
 meson.build                                        |  286 ++++
 meson_options.txt                                  |   25 
 ndctl.spec.in                                      |   15 
 ndctl/Makefile.am                                  |   84 -
 ndctl/bat.c                                        |    5 
 ndctl/bus.c                                        |    4 
 ndctl/check.c                                      |    2 
 ndctl/dimm.c                                       |    6 
 ndctl/filter.c                                     |   60 -
 ndctl/filter.h                                     |   12 
 ndctl/inject-error.c                               |    6 
 ndctl/inject-smart.c                               |    6 
 ndctl/json-smart.c                                 |    5 
 ndctl/json.c                                       | 1114 ++++++++++++++
 ndctl/json.h                                       |   24 
 ndctl/keys.c                                       |    6 
 ndctl/keys.h                                       |    0 
 ndctl/lib/Makefile.am                              |   58 -
 ndctl/lib/libndctl.c                               |    2 
 ndctl/lib/meson.build                              |   48 +
 ndctl/lib/papr.c                                   |    4 
 ndctl/lib/private.h                                |    4 
 ndctl/list.c                                       |    5 
 ndctl/load-keys.c                                  |    7 
 ndctl/meson.build                                  |   82 +
 ndctl/monitor.c                                    |    5 
 ndctl/namespace.c                                  |    6 
 ndctl/region.c                                     |    3 
 ndctl/test.c                                       |   11 
 rhel/meson.build                                   |   22 
 rpmbuild.sh                                        |    5 
 sles/meson.build                                   |   35 
 test.h                                             |    3 
 test/Makefile.am                                   |  192 --
 test/ack-shutdown-count-set.c                      |    2 
 test/blk-exhaust.sh                                |   32 
 test/blk_namespaces.c                              |  357 -----
 test/btt-check.sh                                  |    7 
 test/btt-errors.sh                                 |   16 
 test/btt-pad-compat.sh                             |    9 
 test/clear.sh                                      |    4 
 test/common                                        |   59 +
 test/core.c                                        |   57 +
 test/create.sh                                     |   17 
 test/dax-pmd.c                                     |   11 
 test/dax.sh                                        |    6 
 test/daxctl-create.sh                              |    4 
 test/daxdev-errors.c                               |    2 
 test/daxdev-errors.sh                              |    8 
 test/device-dax-fio.sh                             |    2 
 test/device-dax.c                                  |    2 
 test/dm.sh                                         |    4 
 test/dpa-alloc.c                                   |  326 ----
 test/dsm-fail.c                                    |    4 
 test/firmware-update.sh                            |    8 
 test/inject-error.sh                               |    7 
 test/inject-smart.sh                               |    2 
 test/label-compat.sh                               |    2 
 test/libndctl.c                                    |  253 +--
 test/list-smart-dimm.c                             |    6 
 test/max_available_extent_ns.sh                    |    9 
 test/meson.build                                   |  237 +++
 test/mmap.sh                                       |    6 
 test/monitor.sh                                    |   17 
 test/multi-dax.sh                                  |    4 
 test/multi-pmem.c                                  |  285 ----
 test/parent-uuid.c                                 |  254 ---
 test/pfn-meta-errors.sh                            |    4 
 test/pmem-errors.sh                                |   12 
 test/pmem_namespaces.c                             |    2 
 test/rescan-partitions.sh                          |    7 
 test/revoke-devmem.c                               |    2 
 test/sector-mode.sh                                |   17 
 test/sub-section.sh                                |    4 
 test/track-uuid.sh                                 |    6 
 tools/meson-vcs-tag.sh                             |   18 
 util/help.c                                        |    2 
 util/json.c                                        | 1542 --------------------
 util/json.h                                        |   39 -
 util/meson.build                                   |   16 
 version.h.in                                       |    2 
 134 files changed, 3561 insertions(+), 4658 deletions(-)
 delete mode 100644 Documentation/cxl/Makefile.am
 delete mode 100644 Documentation/cxl/lib/Makefile.am
 create mode 100644 Documentation/cxl/lib/meson.build
 create mode 100644 Documentation/cxl/meson.build
 delete mode 100644 Documentation/daxctl/Makefile.am
 create mode 100644 Documentation/daxctl/meson.build
 delete mode 100644 Documentation/ndctl/Makefile.am
 create mode 100644 Documentation/ndctl/meson.build
 delete mode 100644 Makefile.am
 delete mode 100644 Makefile.am.in
 delete mode 100755 autogen.sh
 create mode 100755 clean_config.sh
 create mode 100644 config.h.meson
 delete mode 100644 configure.ac
 create mode 100644 contrib/meson.build
 mode change 100755 => 100644 contrib/ndctl
 delete mode 100644 cxl/Makefile.am
 create mode 100644 cxl/filter.c
 create mode 100644 cxl/filter.h
 create mode 100644 cxl/json.c
 create mode 100644 cxl/json.h
 delete mode 100644 cxl/lib/Makefile.am
 create mode 100644 cxl/lib/meson.build
 create mode 100644 cxl/meson.build
 delete mode 100644 daxctl/Makefile.am
 create mode 100644 daxctl/filter.c
 create mode 100644 daxctl/filter.h
 create mode 100644 daxctl/json.c
 create mode 100644 daxctl/json.h
 delete mode 100644 daxctl/lib/Makefile.am
 create mode 100644 daxctl/lib/meson.build
 create mode 100644 daxctl/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 delete mode 100644 ndctl/Makefile.am
 rename util/filter.c => ndctl/filter.c (88%)
 rename util/filter.h => ndctl/filter.h (89%)
 rename ndctl/{util/json-smart.c => json-smart.c} (99%)
 create mode 100644 ndctl/json.c
 create mode 100644 ndctl/json.h
 rename ndctl/{util/keys.c => keys.c} (99%)
 rename ndctl/{util/keys.h => keys.h} (100%)
 delete mode 100644 ndctl/lib/Makefile.am
 create mode 100644 ndctl/lib/meson.build
 create mode 100644 ndctl/meson.build
 create mode 100644 rhel/meson.build
 create mode 100644 sles/meson.build
 delete mode 100644 test/Makefile.am
 delete mode 100755 test/blk-exhaust.sh
 delete mode 100644 test/blk_namespaces.c
 delete mode 100644 test/dpa-alloc.c
 create mode 100644 test/meson.build
 delete mode 100644 test/multi-pmem.c
 delete mode 100644 test/parent-uuid.c
 create mode 100755 tools/meson-vcs-tag.sh
 create mode 100644 util/meson.build
 create mode 100644 version.h.in

base-commit: 25062cf34c70012f5d42ce1fef7e2dc129807c10

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 01/16] ndctl/docs: Clarify update-firwmware activation 'overflow' conditions
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
@ 2022-01-05 21:31 ` Dan Williams
  2022-01-05 21:31 ` [ndctl PATCH v3 02/16] ndctl/test: Prepare for BLK-aperture support removal Dan Williams
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:31 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

Give examples and remediation for "overflow" events, i.e. where the
estimated time to complete activation exceeds the platform advertised
maximum. When that happens forced activation can lead to undefined results.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Documentation/ndctl/ndctl-update-firmware.txt |   64 +++++++++++++++++++++++++
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/Documentation/ndctl/ndctl-update-firmware.txt b/Documentation/ndctl/ndctl-update-firmware.txt
index 1080d62a20b9..61664575f5b1 100644
--- a/Documentation/ndctl/ndctl-update-firmware.txt
+++ b/Documentation/ndctl/ndctl-update-firmware.txt
@@ -58,7 +58,69 @@ include::xable-bus-options.txt[]
 	Arm a device for firmware activation. This is enabled by default
 	when a firmware image is specified. Specify --no-arm to disable
 	this default. Otherwise, without a firmware image, this option can be
-	used to manually arm a device for firmware activate.
+	used to manually arm a device for firmware activate. When a
+	device transitions from unarmed to armed the platform recalculates the
+	firmware activation time and compares it against the maximum platform
+	supported time. If the activation time would exceed the platform maximum the
+	arm attempt is aborted:
+
+[verse]
+ndctl update-firmware --arm --bus=nfit_test.0 all
+  Error: update firmware: nmem4: arm aborted, tripped overflow
+[
+  {
+    "dev":"nmem1",
+    "id":"cdab-0a-07e0-ffffffff",
+    "handle":"0",
+    "phys_id":"0",
+    "security":"disabled",
+    "firmware":{
+      "current_version":"0",
+      "can_update":true
+    }
+  },
+  {
+    "dev":"nmem3",
+    "id":"cdab-0a-07e0-fffeffff",
+    "handle":"0x100",
+    "phys_id":"0x2",
+    "security":"disabled",
+    "firmware":{
+      "current_version":"0",
+      "can_update":true
+    }
+  },
+  {
+    "dev":"nmem2",
+    "id":"cdab-0a-07e0-feffffff",
+    "handle":"0x1",
+    "phys_id":"0x1",
+    "security":"disabled",
+    "firmware":{
+      "current_version":"0",
+      "can_update":true
+    }
+  }
+]
+updated 3 nmems.
+
+	It is possible, but not recommended, to ignore timeout overflows
+	with the --force option. At any point to view the 'armed' state of the
+	bus do:
+
+[verse]
+ndctl list -BF -b nfit_test.0
+[
+  {
+    "provider":"nfit_test.0",
+    "dev":"ndbus2",
+    "scrub_state":"idle",
+    "firmware":{
+      "activate_method":"suspend",
+      "activate_state":"overflow"
+    }
+  }
+]
 
 -D::
 --disarm::


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 02/16] ndctl/test: Prepare for BLK-aperture support removal
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
  2022-01-05 21:31 ` [ndctl PATCH v3 01/16] ndctl/docs: Clarify update-firwmware activation 'overflow' conditions Dan Williams
@ 2022-01-05 21:31 ` Dan Williams
  2022-01-05 21:31 ` [ndctl PATCH v3 03/16] ndctl/test: Move 'reset()' to function in 'common' Dan Williams
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:31 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

The kernel is dropping its support for the BLK-aperture access method. The
primary side effect of this for nfit_test is that NVDIMM namespace labeling
will not be enabled by default. Update the unit tests to initialize the
label index area in this scenario.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/core.c     |   31 ++++++++++++++++++++++++++++---
 test/libndctl.c |   49 +++++++++++++++++++++++++++++++++++--------------
 2 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/test/core.c b/test/core.c
index 2b03aa9b3f2a..93e1dae5a144 100644
--- a/test/core.c
+++ b/test/core.c
@@ -261,8 +261,8 @@ retry:
 		ndctl_bus_foreach(nd_ctx, bus) {
 			struct ndctl_region *region;
 
-			if (strncmp(ndctl_bus_get_provider(bus),
-						"nfit_test", 9) != 0)
+			if (strcmp(ndctl_bus_get_provider(bus),
+				   "nfit_test.0") != 0)
 				continue;
 			ndctl_region_foreach(bus, region)
 				ndctl_region_disable_invalidate(region);
@@ -280,5 +280,30 @@ retry:
 			NULL, NULL, NULL, NULL);
 	if (rc)
 		kmod_unref(*ctx);
-	return rc;
+
+	if (!nd_ctx)
+		return rc;
+
+	ndctl_bus_foreach (nd_ctx, bus) {
+		struct ndctl_region *region;
+		struct ndctl_dimm *dimm;
+
+		if (strcmp(ndctl_bus_get_provider(bus), "nfit_test.0") != 0)
+			continue;
+
+		ndctl_region_foreach (bus, region)
+			ndctl_region_disable_invalidate(region);
+
+		ndctl_dimm_foreach (bus, dimm) {
+			ndctl_dimm_read_label_index(dimm);
+			ndctl_dimm_init_labels(dimm, NDCTL_NS_VERSION_1_2);
+			ndctl_dimm_disable(dimm);
+			ndctl_dimm_enable(dimm);
+		}
+
+		ndctl_region_foreach (bus, region)
+			ndctl_region_enable(region);
+	}
+
+	return 0;
 }
diff --git a/test/libndctl.c b/test/libndctl.c
index 391b94086dae..0d6b9dd5b04b 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2588,17 +2588,41 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
 	return 0;
 }
 
-static void reset_bus(struct ndctl_bus *bus)
+enum dimm_reset {
+	DIMM_INIT,
+	DIMM_ZERO,
+};
+
+static int reset_dimms(struct ndctl_bus *bus, enum dimm_reset reset)
 {
-	struct ndctl_region *region;
 	struct ndctl_dimm *dimm;
+	int rc = 0;
+
+	ndctl_dimm_foreach(bus, dimm) {
+		if (reset == DIMM_ZERO)
+			ndctl_dimm_zero_labels(dimm);
+		else {
+			ndctl_dimm_read_label_index(dimm);
+			ndctl_dimm_init_labels(dimm, NDCTL_NS_VERSION_1_2);
+		}
+		ndctl_dimm_disable(dimm);
+		rc = ndctl_dimm_enable(dimm);
+		if (rc)
+			break;
+	}
+
+	return rc;
+}
+
+static void reset_bus(struct ndctl_bus *bus, enum dimm_reset reset)
+{
+	struct ndctl_region *region;
 
 	/* disable all regions so that set_config_data commands are permitted */
 	ndctl_region_foreach(bus, region)
 		ndctl_region_disable_invalidate(region);
 
-	ndctl_dimm_foreach(bus, dimm)
-		ndctl_dimm_zero_labels(dimm);
+	reset_dimms(bus, reset);
 
 	/* set regions back to their default state */
 	ndctl_region_foreach(bus, region)
@@ -2609,7 +2633,6 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
 {
 	struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
 	struct ndctl_region *region;
-	struct ndctl_dimm *dimm;
 	int rc;
 
 	if (!bus)
@@ -2626,13 +2649,10 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
 	if (rc)
 		return rc;
 
-	ndctl_dimm_foreach(bus, dimm) {
-		rc = ndctl_dimm_zero_labels(dimm);
-		if (rc < 0) {
-			fprintf(stderr, "failed to zero %s\n",
-					ndctl_dimm_get_devname(dimm));
-			return rc;
-		}
+	rc = reset_dimms(bus, DIMM_INIT);
+	if (rc < 0) {
+		fprintf(stderr, "failed to reset dimms\n");
+		return rc;
 	}
 
 	/*
@@ -2650,14 +2670,14 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
 		rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), DAX);
 		if (rc)
 			return rc;
-		reset_bus(bus);
+		reset_bus(bus, DIMM_INIT);
 	}
 
 	if (ndctl_test_attempt(test, KERNEL_VERSION(4, 8, 0))) {
 		rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), PFN);
 		if (rc)
 			return rc;
-		reset_bus(bus);
+		reset_bus(bus, DIMM_INIT);
 	}
 
 	return check_regions(bus, regions0, ARRAY_SIZE(regions0), BTT);
@@ -2672,6 +2692,7 @@ static int do_test1(struct ndctl_ctx *ctx, struct ndctl_test *test)
 		return -ENXIO;
 
 	ndctl_bus_wait_probe(bus);
+	reset_bus(bus, DIMM_ZERO);
 
 	/*
 	 * Starting with v4.10 the dimm on nfit_test.1 gets a unique


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 03/16] ndctl/test: Move 'reset()' to function in 'common'
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
  2022-01-05 21:31 ` [ndctl PATCH v3 01/16] ndctl/docs: Clarify update-firwmware activation 'overflow' conditions Dan Williams
  2022-01-05 21:31 ` [ndctl PATCH v3 02/16] ndctl/test: Prepare for BLK-aperture support removal Dan Williams
@ 2022-01-05 21:31 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 04/16] ndctl/test: Initialize the label area by default Dan Williams
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:31 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

When BLK mode is removed, tests that expect the nfit_test region to allow
pmem namespace creation will need to 'init' rather than 'zero' labels. In
preparation, take the time opportunity to move reset() to a common
function. So that 'ndctl zero-labels' can be replaced with 'ndctl
init-labels' in one central location.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/blk-exhaust.sh             |    4 +---
 test/btt-check.sh               |    7 -------
 test/btt-errors.sh              |   12 +++---------
 test/btt-pad-compat.sh          |    7 -------
 test/clear.sh                   |    4 +---
 test/common                     |   15 +++++++++++++++
 test/create.sh                  |    4 +---
 test/daxctl-create.sh           |    4 ++--
 test/daxdev-errors.sh           |    4 +---
 test/firmware-update.sh         |    8 +++-----
 test/inject-error.sh            |    7 -------
 test/max_available_extent_ns.sh |    9 +--------
 test/monitor.sh                 |   11 ++---------
 test/multi-dax.sh               |    4 +---
 test/pfn-meta-errors.sh         |    4 +---
 test/pmem-errors.sh             |    4 +---
 test/rescan-partitions.sh       |    7 -------
 test/sector-mode.sh             |    9 ++-------
 test/track-uuid.sh              |    4 +---
 19 files changed, 36 insertions(+), 92 deletions(-)

diff --git a/test/blk-exhaust.sh b/test/blk-exhaust.sh
index 09c4aae146a6..b6d3808969f1 100755
--- a/test/blk-exhaust.sh
+++ b/test/blk-exhaust.sh
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 # if the kernel accounting is correct we should be able to create two
 # pmem and two blk namespaces on nfit_test.0
diff --git a/test/btt-check.sh b/test/btt-check.sh
index 8e0b489a8eca..65b5c58bb236 100755
--- a/test/btt-check.sh
+++ b/test/btt-check.sh
@@ -39,13 +39,6 @@ create()
 	[ $size -gt 0 ] || err "$LINENO"
 }
 
-reset()
-{
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
 # re-enable the BTT namespace, and do IO to it in an attempt to
 # verify it still comes up ok, and functions as expected
 post_repair_test()
diff --git a/test/btt-errors.sh b/test/btt-errors.sh
index 4e59f57aea7c..5a20d26fe6d5 100755
--- a/test/btt-errors.sh
+++ b/test/btt-errors.sh
@@ -45,9 +45,7 @@ trap 'err $LINENO cleanup' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 rc=1
 
@@ -126,9 +124,7 @@ dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1
 
 # reset everything to get a clean log
 if grep -q "$MNT" /proc/mounts; then umount $MNT; fi
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 dev="x"
 json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector)
 eval "$(echo "$json" | json2var)"
@@ -148,9 +144,7 @@ force_raw 0
 dd if=/dev/$blockdev of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || true
 
 # done, exit
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 cleanup
 _cleanup
 exit 0
diff --git a/test/btt-pad-compat.sh b/test/btt-pad-compat.sh
index bf1ea54af9d2..be538b761151 100755
--- a/test/btt-pad-compat.sh
+++ b/test/btt-pad-compat.sh
@@ -37,13 +37,6 @@ create()
 	fi
 }
 
-reset()
-{
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
 verify_idx()
 {
 	idx0="$1"
diff --git a/test/clear.sh b/test/clear.sh
index fb9d52c837d4..c4d02d54714d 100755
--- a/test/clear.sh
+++ b/test/clear.sh
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 rc=1
 
diff --git a/test/common b/test/common
index 6bcefcad9bf9..3c54d633251f 100644
--- a/test/common
+++ b/test/common
@@ -46,6 +46,21 @@ err()
 	exit $rc
 }
 
+reset()
+{
+	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
+	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
+	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+}
+
+reset1()
+{
+	$NDCTL disable-region -b $NFIT_TEST_BUS1 all
+	$NDCTL zero-labels -b $NFIT_TEST_BUS1 all
+	$NDCTL enable-region -b $NFIT_TEST_BUS1 all
+}
+
+
 # check_min_kver
 # $1: Supported kernel version. format: X.Y
 #
diff --git a/test/create.sh b/test/create.sh
index b0fd99f1e7b1..e9baaa075a28 100755
--- a/test/create.sh
+++ b/test/create.sh
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 rc=1
 
diff --git a/test/daxctl-create.sh b/test/daxctl-create.sh
index 198779a851b4..d319a3939ac5 100755
--- a/test/daxctl-create.sh
+++ b/test/daxctl-create.sh
@@ -10,7 +10,7 @@ trap 'cleanup $LINENO' ERR
 cleanup()
 {
 	printf "Error at line %d\n" "$1"
-	[[ $testdev ]] && reset
+	[[ $testdev ]] && reset_dax
 	exit $rc
 }
 
@@ -70,7 +70,7 @@ reset_dev()
 	"$DAXCTL" enable-device "$testdev"
 }
 
-reset()
+reset_dax()
 {
 	test -n "$testdev"
 
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
index 9547d781162b..e13453dfaa73 100755
--- a/test/daxdev-errors.sh
+++ b/test/daxdev-errors.sh
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 rc=1
 
diff --git a/test/firmware-update.sh b/test/firmware-update.sh
index 8cc9c41b57ca..93ce166e6255 100755
--- a/test/firmware-update.sh
+++ b/test/firmware-update.sh
@@ -10,11 +10,9 @@ image="update-fw.img"
 
 trap 'err $LINENO' ERR
 
-reset()
+fwupd_reset()
 {
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+	reset
 	if [ -f $image ]; then
 		rm -f $image
 	fi
@@ -73,7 +71,7 @@ do_tests()
 check_min_kver "4.16" || do_skip "may lack firmware update test handling"
 
 modprobe nfit_test
-reset
+fwupd_reset
 detect
 rc=1
 do_tests
diff --git a/test/inject-error.sh b/test/inject-error.sh
index 7d0b8269f5db..fd823b6cfa13 100755
--- a/test/inject-error.sh
+++ b/test/inject-error.sh
@@ -37,13 +37,6 @@ create()
 	[ $size -gt 0 ] || err "$LINENO"
 }
 
-reset()
-{
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
 check_status()
 {
 	local sector="$1"
diff --git a/test/max_available_extent_ns.sh b/test/max_available_extent_ns.sh
index 343f3c9eac49..47a921f5edf2 100755
--- a/test/max_available_extent_ns.sh
+++ b/test/max_available_extent_ns.sh
@@ -11,13 +11,6 @@ trap 'err $LINENO' ERR
 check_min_kver "4.19" || do_skip "kernel $KVER may not support max_available_size"
 check_prereq "jq"
 
-init()
-{
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
 do_test()
 {
 	region=$($NDCTL list -b $NFIT_TEST_BUS0 -R -t pmem | jq -r 'sort_by(-.size) | .[].dev' | head -1)
@@ -40,7 +33,7 @@ do_test()
 
 modprobe nfit_test
 rc=1
-init
+reset
 do_test
 _cleanup
 exit 0
diff --git a/test/monitor.sh b/test/monitor.sh
index 28c55415c819..14450a7b23e3 100755
--- a/test/monitor.sh
+++ b/test/monitor.sh
@@ -19,13 +19,6 @@ trap 'err $LINENO' ERR
 
 check_min_kver "4.15" || do_skip "kernel $KVER may not support monitor service"
 
-init()
-{
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
 start_monitor()
 {
 	logfile=$(mktemp)
@@ -112,7 +105,7 @@ test_filter_region()
 
 test_filter_namespace()
 {
-	init
+	reset
 	monitor_namespace=$($NDCTL create-namespace -b $smart_supported_bus | jq -r .dev)
 	monitor_dimms=$(get_monitor_dimm "-n $monitor_namespace")
 	start_monitor "-n $monitor_namespace"
@@ -170,7 +163,7 @@ do_tests()
 
 modprobe nfit_test
 rc=1
-init
+reset
 set_smart_supported_bus
 do_tests
 _cleanup
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
index b343a3869f9c..04070adb18e4 100755
--- a/test/multi-dax.sh
+++ b/test/multi-dax.sh
@@ -17,9 +17,7 @@ ALIGN_SIZE=`getconf PAGESIZE`
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 rc=1
 
 query=". | sort_by(.available_size) | reverse | .[0].dev"
diff --git a/test/pfn-meta-errors.sh b/test/pfn-meta-errors.sh
index 0ade2e52a8ad..631489797087 100755
--- a/test/pfn-meta-errors.sh
+++ b/test/pfn-meta-errors.sh
@@ -29,9 +29,7 @@ trap 'err $LINENO' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 rc=1
 
diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh
index 4225c3bce0c7..20657801fc0e 100755
--- a/test/pmem-errors.sh
+++ b/test/pmem-errors.sh
@@ -28,9 +28,7 @@ trap 'err $LINENO cleanup' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 rc=1
 
diff --git a/test/rescan-partitions.sh b/test/rescan-partitions.sh
index 1686de3552f1..51bbd731fb55 100755
--- a/test/rescan-partitions.sh
+++ b/test/rescan-partitions.sh
@@ -25,13 +25,6 @@ check_min_kver "4.16" || do_skip "may not contain fixes for partition rescanning
 check_prereq "parted"
 check_prereq "blockdev"
 
-reset()
-{
-	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
 test_mode()
 {
 	local mode="$1"
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
index 7a2faeae8a2d..439ef331adaf 100755
--- a/test/sector-mode.sh
+++ b/test/sector-mode.sh
@@ -15,13 +15,8 @@ ALIGN_SIZE=`getconf PAGESIZE`
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-
-$NDCTL disable-region -b $NFIT_TEST_BUS1 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS1 all
-$NDCTL enable-region -b $NFIT_TEST_BUS1 all
+reset
+reset1
 
 rc=1
 query=". | sort_by(.size) | reverse | .[0].dev"
diff --git a/test/track-uuid.sh b/test/track-uuid.sh
index be3cf9c07a0a..3bacd2c24787 100755
--- a/test/track-uuid.sh
+++ b/test/track-uuid.sh
@@ -12,9 +12,7 @@ trap 'err $LINENO' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
 
 rc=1
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 04/16] ndctl/test: Initialize the label area by default
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (2 preceding siblings ...)
  2022-01-05 21:31 ` [ndctl PATCH v3 03/16] ndctl/test: Move 'reset()' to function in 'common' Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 05/16] ndctl/test: Skip BLK flags checks Dan Williams
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

The removal of BLK-mode support causes nfit_test regions to not be
'aliased' by default, which means that the only way to enable labels is to
initialize the namespace label index block. In support of that the common
'reset()' helper is updated to initialize v1.1 labels instead of zero them.
Additionally, it highlighted that some btt tests have silent assumptions of
v1.1 vs v1.2 label support. Add a 'resetV()' alternative to the common
'reset()' function that initializes the label area to v1.2.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/btt-errors.sh     |    4 ++--
 test/btt-pad-compat.sh |    2 +-
 test/common            |   11 +++++++++--
 test/label-compat.sh   |    2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/test/btt-errors.sh b/test/btt-errors.sh
index 5a20d26fe6d5..6e69178cc3cf 100755
--- a/test/btt-errors.sh
+++ b/test/btt-errors.sh
@@ -45,7 +45,7 @@ trap 'err $LINENO cleanup' ERR
 
 # setup (reset nfit_test dimms)
 modprobe nfit_test
-reset
+resetV
 
 rc=1
 
@@ -124,7 +124,7 @@ dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1
 
 # reset everything to get a clean log
 if grep -q "$MNT" /proc/mounts; then umount $MNT; fi
-reset
+resetV
 dev="x"
 json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector)
 eval "$(echo "$json" | json2var)"
diff --git a/test/btt-pad-compat.sh b/test/btt-pad-compat.sh
index be538b761151..005316a205c8 100755
--- a/test/btt-pad-compat.sh
+++ b/test/btt-pad-compat.sh
@@ -148,7 +148,7 @@ do_tests()
 	verify_idx 0 1
 
 	# do the same with an old format namespace
-	reset
+	resetV
 	create_oldfmt_ns
 	verify_idx 0 2
 
diff --git a/test/common b/test/common
index 3c54d633251f..b6d47128f209 100644
--- a/test/common
+++ b/test/common
@@ -49,14 +49,21 @@ err()
 reset()
 {
 	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
+	$NDCTL init-labels -f -b $NFIT_TEST_BUS0 all
+	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+}
+
+resetV()
+{
+	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
+	$NDCTL init-labels -f -V 1.2 -b $NFIT_TEST_BUS0 all
 	$NDCTL enable-region -b $NFIT_TEST_BUS0 all
 }
 
 reset1()
 {
 	$NDCTL disable-region -b $NFIT_TEST_BUS1 all
-	$NDCTL zero-labels -b $NFIT_TEST_BUS1 all
+	$NDCTL init-labels -f -b $NFIT_TEST_BUS1 all
 	$NDCTL enable-region -b $NFIT_TEST_BUS1 all
 }
 
diff --git a/test/label-compat.sh b/test/label-compat.sh
index 8ab285878d84..7ae4d5efd0ff 100755
--- a/test/label-compat.sh
+++ b/test/label-compat.sh
@@ -17,7 +17,7 @@ trap 'err $LINENO' ERR
 # setup (reset nfit_test dimms)
 modprobe nfit_test
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
+$NDCTL init-labels -f -b $NFIT_TEST_BUS0 all
 
 # grab the largest pmem region on -b $NFIT_TEST_BUS0
 query=". | sort_by(.available_size) | reverse | .[0].dev"


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 05/16] ndctl/test: Skip BLK flags checks
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (3 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 04/16] ndctl/test: Initialize the label area by default Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 06/16] ndctl/test: Move sector-mode to a different region Dan Williams
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

With the removal of BLK-mode support, test/libndctl will fail to detect the
JEDEC format on the nfit_test bus. Report + skip that check rather than
fail the test when that happens.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/libndctl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/libndctl.c b/test/libndctl.c
index 0d6b9dd5b04b..aa624289c708 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2536,7 +2536,7 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
 				fprintf(stderr, "dimm%d expected formats: %d got: %d\n",
 						i, dimms[i].formats,
 						ndctl_dimm_get_formats(dimm));
-				return -ENXIO;
+				fprintf(stderr, "continuing...\n");
 			}
 			for (j = 0; j < dimms[i].formats; j++) {
 				if (ndctl_dimm_get_formatN(dimm, j) != dimms[i].format[j]) {
@@ -2544,7 +2544,7 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
 						"dimm%d expected format[%d]: %d got: %d\n",
 							i, j, dimms[i].format[j],
 							ndctl_dimm_get_formatN(dimm, j));
-					return -ENXIO;
+					fprintf(stderr, "continuing...\n");
 				}
 			}
 		}


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 06/16] ndctl/test: Move sector-mode to a different region
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (4 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 05/16] ndctl/test: Skip BLK flags checks Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 07/16] ndctl: Deprecate BLK aperture support Dan Williams
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

Previously the largest region on the nfit_test.1 bus belonged to a BLK-mode
region. With the removal of BLK-mode support update the test to instead
find a suitable PMEM region to perform the checkout.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/sector-mode.sh |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/sector-mode.sh b/test/sector-mode.sh
index 439ef331adaf..f70b0f1786f4 100755
--- a/test/sector-mode.sh
+++ b/test/sector-mode.sh
@@ -19,11 +19,11 @@ reset
 reset1
 
 rc=1
-query=". | sort_by(.size) | reverse | .[0].dev"
-NAMESPACE=$($NDCTL list -b $NFIT_TEST_BUS1 -N | jq -r "$query")
-REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r "(.[]) | .dev")
+query=". | sort_by(.available_size) | reverse | .[0].dev"
+REGION=$($NDCTL list -R -b $NFIT_TEST_BUS1 | jq -r "$query")
 echo 0 > /sys/bus/nd/devices/$REGION/read_only
-$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
+echo $ALIGN_SIZE > /sys/bus/nd/devices/$REGION/align
+NAMESPACE=$($NDCTL create-namespace --no-autolabel -r $REGION -m sector -f -l 4K | jq -r ".dev")
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE
 $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 07/16] ndctl: Deprecate BLK aperture support
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (5 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 06/16] ndctl/test: Move sector-mode to a different region Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 08/16] ndctl/test: Fix support for missing dax_pmem_compat module Dan Williams
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

The kernel is dropping its BLK aperture support, so deprecate the same in
ndctl. The options will still be supported, and the library calls will not
be deleted in case code needs them to compile. However the documentation
and the tests for BLK mode can be removed.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 .gitignore                                     |    4 
 Documentation/ndctl/labels-description.txt     |    5 
 Documentation/ndctl/ndctl-create-namespace.txt |   29 +-
 Documentation/ndctl/ndctl-init-labels.txt      |    7 
 Documentation/ndctl/ndctl-list.txt             |    4 
 Documentation/ndctl/region-description.txt     |   10 -
 README.md                                      |    1 
 contrib/nfit_test_depmod.conf                  |    1 
 ndctl/Makefile.am                              |    6 
 ndctl/bat.c                                    |    5 
 ndctl/test.c                                   |   11 -
 test.h                                         |    3 
 test/Makefile.am                               |   31 --
 test/blk-exhaust.sh                            |   30 --
 test/blk_namespaces.c                          |  357 ------------------------
 test/core.c                                    |    1 
 test/create.sh                                 |   13 -
 test/dpa-alloc.c                               |  326 ----------------------
 test/libndctl.c                                |  198 ++-----------
 test/multi-pmem.c                              |  285 -------------------
 test/parent-uuid.c                             |  254 -----------------
 21 files changed, 51 insertions(+), 1530 deletions(-)
 delete mode 100755 test/blk-exhaust.sh
 delete mode 100644 test/blk_namespaces.c
 delete mode 100644 test/dpa-alloc.c
 delete mode 100644 test/multi-pmem.c
 delete mode 100644 test/parent-uuid.c

diff --git a/.gitignore b/.gitignore
index 6468c7a91f06..6b19d90a12f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,20 +42,16 @@ cscope*.out
 tags
 test/*.log
 test/*.trs
-test/blk-ns
 test/dax-dev
 test/dax-errors
 test/dax-pmd
 test/daxdev-errors
 test/device-dax
-test/dpa-alloc
 test/dsm-fail
 test/hugetlb
 test/image
 test/libndctl
 test/mmap
-test/multi-pmem
-test/parent-uuid
 test/pmem-ns
 test/smart-listen
 test/smart-notify
diff --git a/Documentation/ndctl/labels-description.txt b/Documentation/ndctl/labels-description.txt
index 6244a49a9d3f..a246edcd369b 100644
--- a/Documentation/ndctl/labels-description.txt
+++ b/Documentation/ndctl/labels-description.txt
@@ -3,6 +3,5 @@
 DESCRIPTION
 -----------
 The namespace label area is a small persistent partition of capacity
-available on some NVDIMM devices.  The label area is used to resolve
-aliasing between 'pmem' and 'blk' capacity by delineating namespace
-boundaries.
+available on some NVDIMM devices.  The label area is used to provision
+one, or more, namespaces from regions.
diff --git a/Documentation/ndctl/ndctl-create-namespace.txt b/Documentation/ndctl/ndctl-create-namespace.txt
index 92a89dd71e82..afb085efc6e7 100644
--- a/Documentation/ndctl/ndctl-create-namespace.txt
+++ b/Documentation/ndctl/ndctl-create-namespace.txt
@@ -28,27 +28,17 @@ ndctl create-namespace -f -e namespace0.0 --mode=sector
 
 OPTIONS
 -------
--t::
---type=::
-	Create a 'pmem' or 'blk' namespace (subject to available
-	capacity).  A pmem namespace supports the dax (direct access)
-	capability to linkndctl:mmap[2] persistent memory directly into
-	a process address space.  A blk namespace access persistent
-	memory through a block-window-aperture.  Compared to pmem it
-	supports a traditional storage error model (EIO on error rather
-	than a cpu exception on a bad memory access), but it does not
-	support dax.
-
 -m::
 --mode=::
 	- "raw": expose the namespace capacity directly with
-	  limitations.  Neither a raw pmem namepace nor raw blk
-	  namespace support sector atomicity by default (see "sector"
-	  mode below).  A raw pmem namespace may have limited to no dax
-	  support depending the kernel. In other words operations like
-	  direct-I/O targeting a dax buffer may fail for a pmem
-	  namespace in raw mode or indirect through a page-cache buffer.
-	  See "fsdax" and "devdax" mode for dax operation.
+	  limitations. A raw pmem namepace namespace does not support
+	  sector atomicity (see "sector" mode below). A raw pmem
+	  namespace may have limited to no dax support depending the
+	  kernel. In other words operations like direct-I/O targeting a
+	  dax buffer may fail for a pmem namespace in raw mode or
+	  indirect through a page-cache buffer.  See "fsdax" and
+	  "devdax" mode for dax operation.
+
 
 	- "sector": persistent memory, given that it is byte
 	  addressable, does not support sector atomicity.  The
@@ -206,8 +196,7 @@ OPTIONS
 	  * NVDIMM does not support labels
 
 	  * The NVDIMM supports labels, but the Label Index Block (see
-	    UEFI 2.7) is not present and there is no capacity aliasing
-	    between 'blk' and 'pmem' regions.
+	    UEFI 2.7) is not present.
 
 	- In the latter case the configuration can be upgraded to
 	  labelled operation by writing an index block on all DIMMs in a
diff --git a/Documentation/ndctl/ndctl-init-labels.txt b/Documentation/ndctl/ndctl-init-labels.txt
index 733ef0ebddfa..73685b3336b3 100644
--- a/Documentation/ndctl/ndctl-init-labels.txt
+++ b/Documentation/ndctl/ndctl-init-labels.txt
@@ -13,10 +13,9 @@ SYNOPSIS
 'ndctl init-labels' <nmem0> [<nmem1>..<nmemN>] [<options>]
 
 include::labels-description.txt[]
-By default, and in kernels prior to v4.10, the kernel only honors labels
-when a DIMM aliases PMEM and BLK capacity. Starting with v4.10 the
-kernel will honor labels for sub-dividing PMEM if all the DIMMs in an
-interleave set / region have a valid namespace index block.
+Starting with v4.10 the kernel will honor labels for sub-dividing PMEM
+if all the DIMMs in an interleave set / region have a valid namespace
+index block.
 
 This command can be used to initialize the namespace index block if it
 is missing or reinitialize it if it is damaged.  Note that
diff --git a/Documentation/ndctl/ndctl-list.txt b/Documentation/ndctl/ndctl-list.txt
index b8d517d784b4..2922f10e06c7 100644
--- a/Documentation/ndctl/ndctl-list.txt
+++ b/Documentation/ndctl/ndctl-list.txt
@@ -82,10 +82,6 @@ include::xable-bus-options.txt[]
 	'X.Y'. Limit the namespace list to the single identified device
 	if present.
 
--t::
---type=::
-	Filter listing by region type ('pmem' or 'blk')
-
 -m::
 --mode=::
 	Filter listing by the mode ('raw', 'fsdax', 'sector' or 'devdax')
diff --git a/Documentation/ndctl/region-description.txt b/Documentation/ndctl/region-description.txt
index c14416a3be69..ce268a015b83 100644
--- a/Documentation/ndctl/region-description.txt
+++ b/Documentation/ndctl/region-description.txt
@@ -2,9 +2,7 @@
 
 DESCRIPTION
 -----------
-A generic REGION device is registered for each PMEM range or
-BLK-aperture set.  LIBNVDIMM provides a built-in driver for these REGION
-devices.  This driver is responsible for reconciling the aliased DPA
-mappings across all regions, parsing the LABEL, if present, and then
-emitting NAMESPACE devices with the resolved/exclusive DPA-boundaries
-for the nd_pmem or nd_blk device driver to consume.
+A generic REGION device is registered for each PMEM range /
+interleave-set. LIBNVDIMM provides a built-in driver for these REGION
+devices. This driver is responsible for parsing namespace labels and
+instantiating PMEM namespaces for each coherent set of labels.
diff --git a/README.md b/README.md
index 89dfc8798603..6f36a6d9410c 100644
--- a/README.md
+++ b/README.md
@@ -110,7 +110,6 @@ override dax_pmem * extra
 override dax_pmem_core * extra
 override dax_pmem_compat * extra
 override libnvdimm * extra
-override nd_blk * extra
 override nd_btt * extra
 override nd_e820 * extra
 override nd_pmem * extra
diff --git a/contrib/nfit_test_depmod.conf b/contrib/nfit_test_depmod.conf
index 9f8498e58ff3..0e0574e03670 100644
--- a/contrib/nfit_test_depmod.conf
+++ b/contrib/nfit_test_depmod.conf
@@ -5,7 +5,6 @@ override dax_pmem * extra
 override dax_pmem_core * extra
 override dax_pmem_compat * extra
 override libnvdimm * extra
-override nd_blk * extra
 override nd_btt * extra
 override nd_e820 * extra
 override nd_pmem * extra
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
index 4e995108e96a..93b682e8b202 100644
--- a/ndctl/Makefile.am
+++ b/ndctl/Makefile.am
@@ -45,8 +45,7 @@ endif
 EXTRA_DIST += keys.readme monitor.conf ndctl-monitor.service ndctl.conf
 
 if ENABLE_DESTRUCTIVE
-ndctl_SOURCES += ../test/blk_namespaces.c \
-		 ../test/pmem_namespaces.c
+ndctl_SOURCES += ../test/pmem_namespaces.c
 ndctl_SOURCES += bat.c
 endif
 
@@ -67,9 +66,6 @@ if ENABLE_TEST
 ndctl_SOURCES += ../test/libndctl.c \
 		 ../test/dsm-fail.c \
 		 ../util/sysfs.c \
-		 ../test/dpa-alloc.c \
-		 ../test/parent-uuid.c \
-		 ../test/multi-pmem.c \
 		 ../test/core.c \
 		 test.c
 endif
diff --git a/ndctl/bat.c b/ndctl/bat.c
index ef00a3ba3d0b..13e964dc17cf 100644
--- a/ndctl/bat.c
+++ b/ndctl/bat.c
@@ -41,11 +41,6 @@ int cmd_bat(int argc, const char **argv, struct ndctl_ctx *ctx)
 		return EXIT_FAILURE;
 	}
 
-	rc = test_blk_namespaces(loglevel, test, ctx);
-	fprintf(stderr, "test_blk_namespaces: %s\n", rc ? "FAIL" : "PASS");
-	if (rc && rc != 77)
-		return rc;
-
 	rc = test_pmem_namespaces(loglevel, test, ctx);
 	fprintf(stderr, "test_pmem_namespaces: %s\n", rc ? "FAIL" : "PASS");
 	return ndctl_test_result(test, rc);
diff --git a/ndctl/test.c b/ndctl/test.c
index 6a05d8d62e46..a0f5bc95ae1d 100644
--- a/ndctl/test.c
+++ b/ndctl/test.c
@@ -58,16 +58,5 @@ int cmd_test(int argc, const char **argv, struct ndctl_ctx *ctx)
 	if (rc && rc != 77)
 		return rc;
 
-	rc = test_dpa_alloc(loglevel, test, ctx);
-	fprintf(stderr, "test-dpa-alloc: %s\n", result(rc));
-	if (rc && rc != 77)
-		return rc;
-
-	rc = test_parent_uuid(loglevel, test, ctx);
-	fprintf(stderr, "test-parent-uuid: %s\n", result(rc));
-
-	rc = test_multi_pmem(loglevel, test, ctx);
-	fprintf(stderr, "test-multi-pmem: %s\n", result(rc));
-
 	return ndctl_test_result(test, rc);
 }
diff --git a/test.h b/test.h
index 7de13fe33ea3..b2267e669911 100644
--- a/test.h
+++ b/test.h
@@ -26,7 +26,6 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 
 struct ndctl_ctx;
 int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
-int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
 int test_dax_directio(int dax_fd, unsigned long align, void *dax_addr, off_t offset);
 int test_dax_remap(struct ndctl_test *test, int dax_fd, unsigned long align, void *dax_addr,
 		off_t offset, bool fsdax);
@@ -40,9 +39,7 @@ static inline int test_dax_poison(struct ndctl_test *test, int dax_fd,
 	return 0;
 }
 #endif
-int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
 int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
 int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
-int test_blk_namespaces(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
 int test_pmem_namespaces(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
 #endif /* __TEST_H__ */
diff --git a/test/Makefile.am b/test/Makefile.am
index c5b8764389ea..a5a54df4f260 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -3,9 +3,6 @@ include $(top_srcdir)/Makefile.am.in
 TESTS =\
 	libndctl \
 	dsm-fail \
-	dpa-alloc \
-	parent-uuid \
-	multi-pmem \
 	create.sh \
 	clear.sh \
 	pmem-errors.sh \
@@ -13,7 +10,6 @@ TESTS =\
 	multi-dax.sh \
 	btt-check.sh \
 	label-compat.sh \
-	blk-exhaust.sh \
 	sector-mode.sh \
 	inject-error.sh \
 	btt-errors.sh \
@@ -35,9 +31,6 @@ EXTRA_DIST += $(TESTS) common \
 check_PROGRAMS =\
 	libndctl \
 	dsm-fail \
-	dpa-alloc \
-	parent-uuid \
-	multi-pmem \
 	dax-errors \
 	smart-notify \
 	smart-listen \
@@ -48,7 +41,6 @@ check_PROGRAMS =\
 
 if ENABLE_DESTRUCTIVE
 TESTS +=\
-	blk-ns \
 	pmem-ns \
 	sub-section.sh \
 	dax-dev \
@@ -68,7 +60,6 @@ TESTS += security.sh
 endif
 
 check_PROGRAMS +=\
-	blk-ns \
 	pmem-ns \
 	dax-dev \
 	dax-pmd \
@@ -108,18 +99,9 @@ ack_shutdown_count_set_SOURCES =\
 
 ack_shutdown_count_set_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
 
-blk_ns_SOURCES = blk_namespaces.c $(testcore)
-blk_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
-
 pmem_ns_SOURCES = pmem_namespaces.c $(testcore)
 pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
 
-dpa_alloc_SOURCES = dpa-alloc.c $(testcore)
-dpa_alloc_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
-
-parent_uuid_SOURCES = parent-uuid.c $(testcore)
-parent_uuid_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
-
 dax_dev_SOURCES = dax-dev.c $(testcore)
 dax_dev_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
 
@@ -169,19 +151,6 @@ smart_notify_LDADD = $(LIBNDCTL_LIB)
 smart_listen_SOURCES = smart-listen.c
 smart_listen_LDADD = $(LIBNDCTL_LIB)
 
-multi_pmem_SOURCES = \
-		multi-pmem.c \
-		$(testcore) \
-		../ndctl/namespace.c \
-		../ndctl/check.c \
-		../util/json.c
-multi_pmem_LDADD = \
-		$(LIBNDCTL_LIB) \
-		$(JSON_LIBS) \
-		$(UUID_LIBS) \
-		$(KMOD_LIBS) \
-		../libutil.a
-
 list_smart_dimm_SOURCES = \
 		list-smart-dimm.c \
 		../util/json.c
diff --git a/test/blk-exhaust.sh b/test/blk-exhaust.sh
deleted file mode 100755
index b6d3808969f1..000000000000
--- a/test/blk-exhaust.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash -x
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
-
-set -e
-
-rc=77
-
-. $(dirname $0)/common
-
-check_min_kver "4.11" || do_skip "may lack blk-exhaustion fix"
-
-trap 'err $LINENO' ERR
-
-# setup (reset nfit_test dimms)
-modprobe nfit_test
-reset
-
-# if the kernel accounting is correct we should be able to create two
-# pmem and two blk namespaces on nfit_test.0
-rc=1
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw
-$NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw
-
-# clearnup and exit
-_cleanup
-
-exit 0
diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
deleted file mode 100644
index f076e853ddda..000000000000
--- a/test/blk_namespaces.c
+++ /dev/null
@@ -1,357 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1
-// Copyright (C) 2015-2020, Intel Corporation. All rights reserved.
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/fs.h>
-#include <ndctl/libndctl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <syslog.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <ndctl.h>
-#include <unistd.h>
-#include <uuid/uuid.h>
-#include <linux/version.h>
-#include <test.h>
-#include <libkmod.h>
-#include <ccan/array_size/array_size.h>
-
-/* The purpose of this test is to verify that we can successfully do I/O to
- * multiple nd_blk namespaces that have discontiguous segments.  It first
- * sets up two namespaces, each 1/2 the total size of the NVDIMM and each with
- * two discontiguous segments, arranged like this:
- *
- * +-------+-------+-------+-------+
- * |  nd0  |  nd1  |  nd0  |  nd1  |
- * +-------+-------+-------+-------+
- *
- * It then runs some I/O to the beginning, middle and end of each of these
- * namespaces, checking data integrity.  The I/O to the middle of the
- * namespace will hit two pages, one on either side of the segment boundary.
- */
-#define err(msg)\
-	fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
-
-static struct ndctl_namespace *create_blk_namespace(int region_fraction,
-		struct ndctl_region *region)
-{
-	struct ndctl_namespace *ndns, *seed_ns = NULL;
-	unsigned long long size;
-	uuid_t uuid;
-
-	ndctl_region_set_align(region, sysconf(_SC_PAGESIZE));
-	ndctl_namespace_foreach(region, ndns)
-		if (ndctl_namespace_get_size(ndns) == 0) {
-			seed_ns = ndns;
-			break;
-		}
-
-	if (!seed_ns)
-		return NULL;
-
-	uuid_generate(uuid);
-	size = ndctl_region_get_size(region)/region_fraction;
-
-	if (ndctl_namespace_set_uuid(seed_ns, uuid) < 0)
-		return NULL;
-
-	if (ndctl_namespace_set_size(seed_ns, size) < 0)
-		return NULL;
-
-	if (ndctl_namespace_set_sector_size(seed_ns, 512) < 0)
-		return NULL;
-
-	if (ndctl_namespace_enable(seed_ns) < 0)
-		return NULL;
-
-	return seed_ns;
-}
-
-static int disable_blk_namespace(struct ndctl_namespace *ndns)
-{
-	if (ndctl_namespace_disable_invalidate(ndns) < 0)
-		return -ENODEV;
-
-	if (ndctl_namespace_delete(ndns) < 0)
-		return -ENODEV;
-
-	return 0;
-}
-
-static int ns_do_io(const char *bdev)
-{
-	int fd, i;
-	int rc = 0;
-	const int page_size = 4096;
-	const int num_pages = 4;
-	unsigned long num_dev_pages, num_blocks;
-	off_t addr;
-
-	void *random_page[num_pages];
-	void *blk_page[num_pages];
-
-	rc = posix_memalign(random_page, page_size, page_size * num_pages);
-	if (rc) {
-		fprintf(stderr, "posix_memalign failure\n");
-		return rc;
-	}
-
-	rc = posix_memalign(blk_page, page_size, page_size * num_pages);
-	if (rc) {
-		fprintf(stderr, "posix_memalign failure\n");
-		goto err_free_blk;
-	}
-
-	for (i = 1; i < num_pages; i++) {
-		random_page[i] = (char*)random_page[0] + page_size * i;
-		blk_page[i] = (char*)blk_page[0] + page_size * i;
-	}
-
-	/* read random data into random_page */
-	if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
-		err("open");
-		rc = -ENODEV;
-		goto err_free_all;
-	}
-
-	rc = read(fd, random_page[0], page_size * num_pages);
-	if (rc < 0) {
-		err("read");
-		close(fd);
-		goto err_free_all;
-	}
-
-	close(fd);
-
-	if ((fd = open(bdev, O_RDWR|O_DIRECT)) < 0) {
-		err("open");
-		rc = -ENODEV;
-		goto err_free_all;
-	}
-
-	ioctl(fd, BLKGETSIZE, &num_blocks);
-	num_dev_pages = num_blocks / 8;
-
-	/* write the random data out to each of the segments */
-	rc = pwrite(fd, random_page[0], page_size, 0);
-	if (rc < 0) {
-		err("write");
-		goto err_close;
-	}
-
-	/* two pages that span the region discontinuity */
-	addr = page_size * (num_dev_pages/2 - 1);
-	rc = pwrite(fd, random_page[1], page_size*2, addr);
-	if (rc < 0) {
-		err("write");
-		goto err_close;
-	}
-
-	addr = page_size * (num_dev_pages - 1);
-	rc = pwrite(fd, random_page[3], page_size, addr);
-	if (rc < 0) {
-		err("write");
-		goto err_close;
-	}
-
-	/* read back the random data into blk_page */
-	rc = pread(fd, blk_page[0], page_size, 0);
-	if (rc < 0) {
-		err("read");
-		goto err_close;
-	}
-
-	/* two pages that span the region discontinuity */
-	addr = page_size * (num_dev_pages/2 - 1);
-	rc = pread(fd, blk_page[1], page_size*2, addr);
-	if (rc < 0) {
-		err("read");
-		goto err_close;
-	}
-
-	addr = page_size * (num_dev_pages - 1);
-	rc = pread(fd, blk_page[3], page_size, addr);
-	if (rc < 0) {
-		err("read");
-		goto err_close;
-	}
-
-	/* verify the data */
-	if (memcmp(random_page[0], blk_page[0], page_size * num_pages)) {
-		fprintf(stderr, "Block data miscompare\n");
-		rc = -EIO;
-		goto err_close;
-	}
-
-	rc = 0;
- err_close:
-	close(fd);
- err_free_all:
-	free(random_page[0]);
- err_free_blk:
-	free(blk_page[0]);
-	return rc;
-}
-
-static const char *comm = "test-blk-namespaces";
-
-int test_blk_namespaces(int log_level, struct ndctl_test *test,
-		struct ndctl_ctx *ctx)
-{
-	char bdev[50];
-	int rc = -ENXIO;
-	struct ndctl_bus *bus;
-	struct ndctl_dimm *dimm;
-	struct kmod_module *mod = NULL;
-	struct kmod_ctx *kmod_ctx = NULL;
-	struct ndctl_namespace *ndns[2];
-	struct ndctl_region *region, *blk_region = NULL;
-
-	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
-		return 77;
-
-	ndctl_set_log_priority(ctx, log_level);
-
-	bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT");
-	if (bus) {
-		/* skip this bus if no BLK regions */
-		ndctl_region_foreach(bus, region)
-			if (ndctl_region_get_nstype(region)
-					== ND_DEVICE_NAMESPACE_BLK)
-				break;
-		if (!region)
-			bus = NULL;
-	}
-
-	if (!bus) {
-		fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
-		rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test);
-		ndctl_invalidate(ctx);
-		bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
-		if (rc < 0 || !bus) {
-			ndctl_test_skip(test);
-			fprintf(stderr, "nfit_test unavailable skipping tests\n");
-			return 77;
-		}
-	}
-
-	fprintf(stderr, "%s: found provider: %s\n", comm,
-			ndctl_bus_get_provider(bus));
-
-	/* get the system to a clean state */
-        ndctl_region_foreach(bus, region)
-                ndctl_region_disable_invalidate(region);
-
-        ndctl_dimm_foreach(bus, dimm) {
-                rc = ndctl_dimm_zero_labels(dimm);
-                if (rc < 0) {
-                        fprintf(stderr, "failed to zero %s\n",
-                                        ndctl_dimm_get_devname(dimm));
-			goto err_module;
-                }
-        }
-
-	/* create our config */
-	ndctl_region_foreach(bus, region)
-		if (strcmp(ndctl_region_get_type_name(region), "blk") == 0) {
-			blk_region = region;
-			break;
-		}
-
-	if (!blk_region || ndctl_region_enable(blk_region) < 0) {
-		fprintf(stderr, "%s: failed to find block region\n", comm);
-		rc = -ENODEV;
-		goto err_cleanup;
-	}
-
-	rc = -ENODEV;
-	ndns[0] = create_blk_namespace(4, blk_region);
-	if (!ndns[0]) {
-		fprintf(stderr, "%s: failed to create block namespace\n", comm);
-		goto err_cleanup;
-	}
-
-	ndns[1] = create_blk_namespace(4, blk_region);
-	if (!ndns[1]) {
-		fprintf(stderr, "%s: failed to create block namespace\n", comm);
-		goto err_cleanup;
-	}
-
-	rc = disable_blk_namespace(ndns[0]);
-	if (rc < 0) {
-		fprintf(stderr, "%s: failed to disable block namespace\n", comm);
-		goto err_cleanup;
-	}
-
-	ndns[0] = create_blk_namespace(2, blk_region);
-	if (!ndns[0]) {
-		fprintf(stderr, "%s: failed to create block namespace\n", comm);
-		rc = -ENODEV;
-		goto err_cleanup;
-	}
-
-	rc = disable_blk_namespace(ndns[1]);
-	if (rc < 0) {
-		fprintf(stderr, "%s: failed to disable block namespace\n", comm);
-		goto err_cleanup;
-	}
-
-	rc = -ENODEV;
-	ndns[1] = create_blk_namespace(2, blk_region);
-	if (!ndns[1]) {
-		fprintf(stderr, "%s: failed to create block namespace\n", comm);
-		goto err_cleanup;
-	}
-
-	/* okay, all set up, do some I/O */
-	rc = -EIO;
-	sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns[0]));
-	if (ns_do_io(bdev))
-		goto err_cleanup;
-	sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns[1]));
-	if (ns_do_io(bdev))
-		goto err_cleanup;
-	rc = 0;
-
- err_cleanup:
-	/* unload nfit_test */
-	bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
-	if (bus)
-		ndctl_region_foreach(bus, region)
-			ndctl_region_disable_invalidate(region);
-	bus = ndctl_bus_get_by_provider(ctx, "nfit_test.1");
-	if (bus)
-		ndctl_region_foreach(bus, region)
-			ndctl_region_disable_invalidate(region);
-	if (mod)
-		kmod_module_remove_module(mod, 0);
-
- err_module:
-	if (kmod_ctx)
-		kmod_unref(kmod_ctx);
-	return rc;
-}
-
-int __attribute__((weak)) main(int argc, char *argv[])
-{
-	struct ndctl_test *test = ndctl_test_new(0);
-	struct ndctl_ctx *ctx;
-	int rc;
-
-	comm = argv[0];
-	if (!test) {
-		fprintf(stderr, "failed to initialize test\n");
-		return EXIT_FAILURE;
-	}
-
-	rc = ndctl_new(&ctx);
-	if (rc)
-		return ndctl_test_result(test, rc);
-
-	rc = test_blk_namespaces(LOG_DEBUG, test, ctx);
-	ndctl_unref(ctx);
-	return ndctl_test_result(test, rc);
-}
diff --git a/test/core.c b/test/core.c
index 93e1dae5a144..dc1405d75c49 100644
--- a/test/core.c
+++ b/test/core.c
@@ -123,7 +123,6 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 		"dax_pmem_core",
 		"dax_pmem_compat",
 		"libnvdimm",
-		"nd_blk",
 		"nd_btt",
 		"nd_e820",
 		"nd_pmem",
diff --git a/test/create.sh b/test/create.sh
index e9baaa075a28..9a6f3733939e 100755
--- a/test/create.sh
+++ b/test/create.sh
@@ -40,19 +40,6 @@ eval $(echo $json | json2var)
 # free capacity for blk creation
 $NDCTL destroy-namespace -f $dev
 
-# create blk
-dev="x"
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t blk -m raw -v)
-eval $(echo $json | json2var)
-[ $dev = "x" ] && echo "fail: $LINENO" && exit 1
-[ $mode != "raw" ] && echo "fail: $LINENO" &&  exit 1
-
-# convert blk to sector mode
-json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev)
-eval $(echo $json | json2var)
-[ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" &&  exit 1
-[ $mode != "sector" ] && echo "fail: $LINENO" &&  exit 1
-
 _cleanup
 
 exit 0
diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c
deleted file mode 100644
index 59185cf8cf3b..000000000000
--- a/test/dpa-alloc.c
+++ /dev/null
@@ -1,326 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1
-// Copyright (C) 2014-2020, Intel Corporation. All rights reserved.
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <errno.h>
-#include <unistd.h>
-#include <limits.h>
-#include <syslog.h>
-#include <libkmod.h>
-#include <uuid/uuid.h>
-
-#include <test.h>
-#include <ndctl.h>
-#include <util/size.h>
-#include <linux/version.h>
-#include <ndctl/libndctl.h>
-#include <ccan/array_size/array_size.h>
-
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
-static const char *NFIT_PROVIDER1 = "nfit_test.1";
-#define NUM_NAMESPACES 4
-
-struct test_dpa_namespace {
-	struct ndctl_namespace *ndns;
-	unsigned long long size;
-	uuid_t uuid;
-} namespaces[NUM_NAMESPACES];
-
-#define MIN_SIZE SZ_4M
-
-static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test)
-{
-	unsigned int default_available_slots, available_slots, i;
-	struct ndctl_region *region, *blk_region = NULL;
-	struct ndctl_namespace *ndns;
-	struct ndctl_dimm *dimm;
-	unsigned long size, page_size;
-	struct ndctl_bus *bus;
-	char uuid_str[40];
-	int round;
-	int rc;
-
-	page_size = sysconf(_SC_PAGESIZE);
-	/* disable nfit_test.1, not used in this test */
-	bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
-	if (!bus)
-		return -ENXIO;
-	ndctl_region_foreach(bus, region) {
-		ndctl_region_disable_invalidate(region);
-		ndctl_region_set_align(region, sysconf(_SC_PAGESIZE)
-				* ndctl_region_get_interleave_ways(region));
-	}
-
-	/* init nfit_test.0 */
-	bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
-	if (!bus)
-		return -ENXIO;
-	ndctl_region_foreach(bus, region) {
-		ndctl_region_disable_invalidate(region);
-		ndctl_region_set_align(region, sysconf(_SC_PAGESIZE)
-				* ndctl_region_get_interleave_ways(region));
-	}
-
-	ndctl_dimm_foreach(bus, dimm) {
-		rc = ndctl_dimm_zero_labels(dimm);
-		if (rc < 0) {
-			fprintf(stderr, "failed to zero %s\n",
-					ndctl_dimm_get_devname(dimm));
-			return rc;
-		}
-	}
-
-	/*
-	 * Find a guineapig BLK region, we know that the dimm with
-	 * handle==0 from nfit_test.0 always allocates from highest DPA
-	 * to lowest with no excursions into BLK only ranges.
-	 */
-	ndctl_region_foreach(bus, region) {
-		if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
-			continue;
-		dimm = ndctl_region_get_first_dimm(region);
-		if (!dimm)
-			continue;
-		if (ndctl_dimm_get_handle(dimm) == 0) {
-			blk_region = region;
-			break;
-		}
-	}
-	if (!blk_region || ndctl_region_enable(blk_region) < 0) {
-		fprintf(stderr, "failed to find a usable BLK region\n");
-		return -ENXIO;
-	}
-	region = blk_region;
-
-	if (ndctl_region_get_available_size(region) / MIN_SIZE < NUM_NAMESPACES) {
-		fprintf(stderr, "%s insufficient available_size\n",
-				ndctl_region_get_devname(region));
-		return -ENXIO;
-	}
-
-	default_available_slots = ndctl_dimm_get_available_labels(dimm);
-
-	/* grow namespaces */
-	for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
-		uuid_t uuid;
-
-		ndns = ndctl_region_get_namespace_seed(region);
-		if (!ndns) {
-			fprintf(stderr, "%s: failed to get seed: %d\n",
-					ndctl_region_get_devname(region), i);
-			return -ENXIO;
-		}
-		uuid_generate_random(uuid);
-		ndctl_namespace_set_uuid(ndns, uuid);
-		ndctl_namespace_set_sector_size(ndns, 512);
-		ndctl_namespace_set_size(ndns, MIN_SIZE);
-		rc = ndctl_namespace_enable(ndns);
-		if (rc) {
-			fprintf(stderr, "failed to enable %s: %d\n",
-					ndctl_namespace_get_devname(ndns), rc);
-			return rc;
-		}
-		ndctl_namespace_disable_invalidate(ndns);
-		rc = ndctl_namespace_set_size(ndns, page_size);
-		if (rc) {
-			fprintf(stderr, "failed to init %s to size: %lu\n",
-					ndctl_namespace_get_devname(ndns),
-					page_size);
-			return rc;
-		}
-		namespaces[i].ndns = ndns;
-		ndctl_namespace_get_uuid(ndns, namespaces[i].uuid);
-	}
-
-	available_slots = ndctl_dimm_get_available_labels(dimm);
-	if (available_slots != default_available_slots
-			- ARRAY_SIZE(namespaces)) {
-		fprintf(stderr, "expected %ld slots available\n",
-				default_available_slots
-				- ARRAY_SIZE(namespaces));
-		return -ENOSPC;
-	}
-
-	/* exhaust label space, by round-robin allocating 4K */
-	round = 1;
-	for (i = 0; i < available_slots; i++) {
-		ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
-		if (i % ARRAY_SIZE(namespaces) == 0)
-			round++;
-		size = page_size * round;
-		rc = ndctl_namespace_set_size(ndns, size);
-		if (rc) {
-			fprintf(stderr, "%s: set_size: %lx failed: %d\n",
-				ndctl_namespace_get_devname(ndns), size, rc);
-			return rc;
-		}
-	}
-
-	/*
-	 * The last namespace we updated should still be modifiable via
-	 * the kernel's reserve label
-	 */
-	i--;
-	round++;
-	ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
-	size = page_size * round;
-	rc = ndctl_namespace_set_size(ndns, size);
-	if (rc) {
-		fprintf(stderr, "%s failed to update while labels full\n",
-				ndctl_namespace_get_devname(ndns));
-		return rc;
-	}
-
-	round--;
-	size = page_size * round;
-	rc = ndctl_namespace_set_size(ndns, size);
-	if (rc) {
-		fprintf(stderr, "%s failed to reduce size while labels full\n",
-				ndctl_namespace_get_devname(ndns));
-		return rc;
-	}
-
-	/* do the allocations survive a region cycle? */
-	for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
-		ndns = namespaces[i].ndns;
-		namespaces[i].size = ndctl_namespace_get_size(ndns);
-		namespaces[i].ndns = NULL;
-	}
-
-	ndctl_region_disable_invalidate(region);
-	rc = ndctl_region_enable(region);
-	if (rc) {
-		fprintf(stderr, "failed to re-enable %s: %d\n",
-				ndctl_region_get_devname(region), rc);
-		return rc;
-	}
-
-	ndctl_namespace_foreach(region, ndns) {
-		uuid_t uuid;
-
-		ndctl_namespace_get_uuid(ndns, uuid);
-		for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
-			if (uuid_compare(uuid, namespaces[i].uuid) == 0) {
-				namespaces[i].ndns = ndns;
-				break;
-			}
-		}
-	}
-
-	/* validate that they all came back */
-	for (i = 0; i < ARRAY_SIZE(namespaces); i++) {
-		ndns = namespaces[i].ndns;
-		size = ndns ? ndctl_namespace_get_size(ndns) : 0;
-
-		if (ndns && size == namespaces[i].size)
-			continue;
-		uuid_unparse(namespaces[i].uuid, uuid_str);
-		fprintf(stderr, "failed to recover %s\n", uuid_str);
-		return -ENODEV;
-	}
-
-	/* test deletion and merging */
-	ndns = namespaces[0].ndns;
-	for (i = 1; i < ARRAY_SIZE(namespaces); i++) {
-		struct ndctl_namespace *victim = namespaces[i].ndns;
-
-		uuid_unparse(namespaces[i].uuid, uuid_str);
-		size = ndctl_namespace_get_size(victim);
-		rc = ndctl_namespace_disable(victim);
-		if (rc) {
-			fprintf(stderr, "failed to disable %s\n", uuid_str);
-			return rc;
-		}
-		rc = ndctl_namespace_delete(victim);
-		if (rc) {
-			fprintf(stderr, "failed to delete %s\n", uuid_str);
-			return rc;
-		}
-		size += ndctl_namespace_get_size(ndns);
-		rc = ndctl_namespace_set_size(ndns, size);
-		if (rc) {
-			fprintf(stderr, "failed to merge %s\n", uuid_str);
-			return rc;
-		}
-	}
-
-	/* there can be only one */
-	i = 0;
-	ndctl_namespace_foreach(region, ndns) {
-		unsigned long long sz = ndctl_namespace_get_size(ndns);
-
-		if (sz) {
-			i++;
-			if (sz == size)
-				continue;
-			fprintf(stderr, "%s size: %llx expected %lx\n",
-					ndctl_namespace_get_devname(ndns),
-					sz, size);
-			return -ENXIO;
-		}
-	}
-	if (i != 1) {
-		fprintf(stderr, "failed to delete namespaces\n");
-		return -ENXIO;
-	}
-
-	available_slots = ndctl_dimm_get_available_labels(dimm);
-	if (available_slots != default_available_slots - 1) {
-		fprintf(stderr, "mishandled slot count\n");
-		return -ENXIO;
-	}
-
-	ndctl_region_foreach(bus, region)
-		ndctl_region_disable_invalidate(region);
-
-	return 0;
-}
-
-int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
-{
-	struct kmod_module *mod;
-	struct kmod_ctx *kmod_ctx;
-	int err, result = EXIT_FAILURE;
-
-	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
-		return 77;
-
-	ndctl_set_log_priority(ctx, loglevel);
-	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
-	if (err < 0) {
-		ndctl_test_skip(test);
-		fprintf(stderr, "nfit_test unavailable skipping tests\n");
-		return 77;
-	}
-
-	err = do_test(ctx, test);
-	if (err == 0)
-		result = EXIT_SUCCESS;
-	kmod_module_remove_module(mod, 0);
-	kmod_unref(kmod_ctx);
-	return result;
-}
-
-int __attribute__((weak)) main(int argc, char *argv[])
-{
-	struct ndctl_test *test = ndctl_test_new(0);
-	struct ndctl_ctx *ctx;
-	int rc;
-
-	if (!test) {
-		fprintf(stderr, "failed to initialize test\n");
-		return EXIT_FAILURE;
-	}
-
-	rc = ndctl_new(&ctx);
-	if (rc)
-		return ndctl_test_result(test, rc);
-
-	rc = test_dpa_alloc(LOG_DEBUG, test, ctx);
-	ndctl_unref(ctx);
-	return ndctl_test_result(test, rc);
-}
diff --git a/test/libndctl.c b/test/libndctl.c
index aa624289c708..0bee06b93787 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -30,46 +30,35 @@
 /*
  * Kernel provider "nfit_test.0" produces an NFIT with the following attributes:
  *
- *                              (a)               (b)           DIMM   BLK-REGION
- *           +-------------------+--------+--------+--------+
- * +------+  |       pm0.0       | blk2.0 | pm1.0  | blk2.1 |    0      region2
- * | imc0 +--+- - - region0- - - +--------+        +--------+
- * +--+---+  |       pm0.0       | blk3.0 | pm1.0  | blk3.1 |    1      region3
- *    |      +-------------------+--------v        v--------+
- * +--+---+                               |                 |
- * | cpu0 |                                     region1
- * +--+---+                               |                 |
- *    |      +----------------------------^        ^--------+
- * +--+---+  |           blk4.0           | pm1.0  | blk4.0 |    2      region4
- * | imc1 +--+----------------------------|        +--------+
- * +------+  |           blk5.0           | pm1.0  | blk5.0 |    3      region5
- *           +----------------------------+--------+--------+
+ *                               (a)               (b)           DIMM
+ *            +-------------------+--------+--------+--------+
+ *  +------+  |       pm0.0       |  free  | pm1.0  |  free  |    0
+ *  | imc0 +--+- - - region0- - - +--------+        +--------+
+ *  +--+---+  |       pm0.0       |  free  | pm1.0  |  free  |    1
+ *     |      +-------------------+--------v        v--------+
+ *  +--+---+                               |                 |
+ *  | cpu0 |                                     region1
+ *  +--+---+                               |                 |
+ *     |      +----------------------------^        ^--------+
+ *  +--+---+  |           free             | pm1.0  |  free  |    2
+ *  | imc1 +--+----------------------------|        +--------+
+ *  +------+  |           free             | pm1.0  |  free  |    3
+ *            +----------------------------+--------+--------+
  *
- * *) In this layout we have four dimms and two memory controllers in one
- *    socket.  Each unique interface ("blk" or "pmem") to DPA space
- *    is identified by a region device with a dynamically assigned id.
+ * In this platform we have four DIMMs and two memory controllers in one
+ * socket.  Each PMEM interleave set is identified by a region device with
+ * a dynamically assigned id.
  *
- * *) The first portion of dimm0 and dimm1 are interleaved as REGION0.
- *    A single "pmem" namespace is created in the REGION0-"spa"-range
- *    that spans dimm0 and dimm1 with a user-specified name of "pm0.0".
- *    Some of that interleaved "spa" range is reclaimed as "bdw"
- *    accessed space starting at offset (a) into each dimm.  In that
- *    reclaimed space we create two "bdw" "namespaces" from REGION2 and
- *    REGION3 where "blk2.0" and "blk3.0" are just human readable names
- *    that could be set to any user-desired name in the label.
+ *    1. The first portion of DIMM0 and DIMM1 are interleaved as REGION0. A
+ *       single PMEM namespace is created in the REGION0-SPA-range that spans most
+ *       of DIMM0 and DIMM1 with a user-specified name of "pm0.0". Some of that
+ *       interleaved system-physical-address range is left free for
+ *       another PMEM namespace to be defined.
  *
- * *) In the last portion of dimm0 and dimm1 we have an interleaved
- *    "spa" range, REGION1, that spans those two dimms as well as dimm2
- *    and dimm3.  Some of REGION1 allocated to a "pmem" namespace named
- *    "pm1.0" the rest is reclaimed in 4 "bdw" namespaces (for each
- *    dimm in the interleave set), "blk2.1", "blk3.1", "blk4.0", and
- *    "blk5.0".
- *
- * *) The portion of dimm2 and dimm3 that do not participate in the
- *    REGION1 interleaved "spa" range (i.e. the DPA address below
- *    offset (b) are also included in the "blk4.0" and "blk5.0"
- *    namespaces.  Note, that this example shows that "bdw" namespaces
- *    don't need to be contiguous in DPA-space.
+ *    2. In the last portion of DIMM0 and DIMM1 we have an interleaved
+ *       system-physical-address range, REGION1, that spans those two DIMMs as
+ *       well as DIMM2 and DIMM3.  Some of REGION1 is allocated to a PMEM namespace
+ *       named "pm1.0".
  *
  * Kernel provider "nfit_test.1" produces an NFIT with the following attributes:
  *
@@ -127,10 +116,10 @@ struct dimm {
 	(((n & 0xfff) << 16) | ((s & 0xf) << 12) | ((i & 0xf) << 8) \
 	 | ((c & 0xf) << 4) | (d & 0xf))
 static struct dimm dimms0[] = {
-	{ DIMM_HANDLE(0, 0, 0, 0, 0), 0, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
-	{ DIMM_HANDLE(0, 0, 0, 0, 1), 1, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
-	{ DIMM_HANDLE(0, 0, 1, 0, 0), 2, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
-	{ DIMM_HANDLE(0, 0, 1, 0, 1), 3, 0, 2016, 10, 42, { 0 }, 2, { 0x201, 0x301, }, },
+	{ DIMM_HANDLE(0, 0, 0, 0, 0), 0, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
+	{ DIMM_HANDLE(0, 0, 0, 0, 1), 1, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
+	{ DIMM_HANDLE(0, 0, 1, 0, 0), 2, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
+	{ DIMM_HANDLE(0, 0, 1, 0, 1), 3, 0, 2016, 10, 42, { 0 }, 1, { 0x201, }, },
 };
 
 static struct dimm dimms1[] = {
@@ -240,7 +229,6 @@ struct namespace {
 };
 
 static uuid_t null_uuid;
-static unsigned long blk_sector_sizes[] = { 512, 520, 528, 4096, 4104, 4160, 4224, };
 static unsigned long pmem_sector_sizes[] = { 512, 4096 };
 static unsigned long io_sector_sizes[] = { 0 };
 
@@ -262,60 +250,6 @@ static struct namespace namespace1_pmem0 = {
 	ARRAY_SIZE(pmem_sector_sizes), pmem_sector_sizes,
 };
 
-static struct namespace namespace2_blk0 = {
-	0, "namespace_blk", NULL, NULL, NULL, SZ_7M,
-	{ 3, 3, 3, 3,
-	  3, 3, 3, 3,
-	  3, 3, 3, 3,
-	  3, 3, 3, 3, }, 1, 1, 0,
-	ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
-};
-
-static struct namespace namespace2_blk1 = {
-	1, "namespace_blk", NULL, NULL, NULL, SZ_11M,
-	{ 4, 4, 4, 4,
-	  4, 4, 4, 4,
-	  4, 4, 4, 4,
-	  4, 4, 4, 4, }, 1, 1, 0,
-	ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
-};
-
-static struct namespace namespace3_blk0 = {
-	0, "namespace_blk", NULL, NULL, NULL, SZ_7M,
-	{ 5, 5, 5, 5,
-	  5, 5, 5, 5,
-	  5, 5, 5, 5,
-	  5, 5, 5, 5, }, 1, 1, 0,
-	ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
-};
-
-static struct namespace namespace3_blk1 = {
-	1, "namespace_blk", NULL, NULL, NULL, SZ_11M,
-	{ 6, 6, 6, 6,
-	  6, 6, 6, 6,
-	  6, 6, 6, 6,
-	  6, 6, 6, 6, }, 1, 1, 0,
-	ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
-};
-
-static struct namespace namespace4_blk0 = {
-	0, "namespace_blk", &btt_settings, NULL, NULL, SZ_27M,
-	{ 7, 7, 7, 7,
-	  7, 7, 7, 7,
-	  7, 7, 7, 7,
-	  7, 7, 7, 7, }, 1, 1, 0,
-	ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
-};
-
-static struct namespace namespace5_blk0 = {
-	0, "namespace_blk", &btt_settings, NULL, NULL, SZ_27M,
-	{ 8, 8, 8, 8,
-	  8, 8, 8, 8,
-	  8, 8, 8, 8,
-	  8, 8, 8, 8, }, 1, 1, 0,
-	ARRAY_SIZE(blk_sector_sizes), blk_sector_sizes,
-};
-
 static struct region regions0[] = {
 	{ { 1 }, 2, 1, "pmem", SZ_32M, SZ_32M, { 1 },
 		.namespaces = {
@@ -339,40 +273,6 @@ static struct region regions0[] = {
 			[0] = &default_pfn,
 		},
 	},
-	{ { DIMM_HANDLE(0, 0, 0, 0, 0) }, 1, 1, "blk", SZ_18M, SZ_32M,
-		.namespaces = {
-			[0] = &namespace2_blk0,
-			[1] = &namespace2_blk1,
-		},
-		.btts = {
-			[0] = &default_btt,
-		},
-	},
-	{ { DIMM_HANDLE(0, 0, 0, 0, 1) }, 1, 1, "blk", SZ_18M, SZ_32M,
-		.namespaces = {
-			[0] = &namespace3_blk0,
-			[1] = &namespace3_blk1,
-		},
-		.btts = {
-			[0] = &default_btt,
-		},
-	},
-	{ { DIMM_HANDLE(0, 0, 1, 0, 0) }, 1, 1, "blk", SZ_27M, SZ_32M,
-		.namespaces = {
-			[0] = &namespace4_blk0,
-		},
-		.btts = {
-			[0] = &default_btt,
-		},
-	},
-	{ { DIMM_HANDLE(0, 0, 1, 0, 1) }, 1, 1, "blk", SZ_27M, SZ_32M,
-		.namespaces = {
-			[0] = &namespace5_blk0,
-		},
-		.btts = {
-			[0] = &default_btt,
-		},
-	},
 };
 
 static struct namespace namespace1 = {
@@ -485,26 +385,6 @@ static struct ndctl_region *get_pmem_region_by_range_index(struct ndctl_bus *bus
 	return NULL;
 }
 
-static struct ndctl_region *get_blk_region_by_dimm_handle(struct ndctl_bus *bus,
-		unsigned int handle)
-{
-	struct ndctl_region *region;
-
-	ndctl_region_foreach(bus, region) {
-		struct ndctl_mapping *map;
-
-		if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
-			continue;
-		ndctl_mapping_foreach(region, map) {
-			struct ndctl_dimm *dimm = ndctl_mapping_get_dimm(map);
-
-			if (ndctl_dimm_get_handle(dimm) == handle)
-				return region;
-		}
-	}
-	return NULL;
-}
-
 enum ns_mode {
 	BTT, PFN, DAX,
 };
@@ -522,11 +402,8 @@ static int check_regions(struct ndctl_bus *bus, struct region *regions, int n,
 		struct ndctl_interleave_set *iset;
 		char devname[50];
 
-		if (strcmp(regions[i].type, "pmem") == 0)
-			region = get_pmem_region_by_range_index(bus, regions[i].range_index);
-		else
-			region = get_blk_region_by_dimm_handle(bus, regions[i].handle);
-
+		region = get_pmem_region_by_range_index(bus,
+							regions[i].range_index);
 		if (!region) {
 			fprintf(stderr, "failed to find region type: %s ident: %x\n",
 					regions[i].type, regions[i].handle);
@@ -1065,7 +942,6 @@ static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace
 		return -ENXIO;
 
 	for (i = 0; i < btt_s->num_sector_sizes; i++) {
-		struct ndctl_namespace *ns_seed = ndctl_region_get_namespace_seed(region);
 		struct ndctl_btt *btt_seed = ndctl_region_get_btt_seed(region);
 		enum ndctl_namespace_mode mode;
 
@@ -1115,16 +991,6 @@ static int check_btt_create(struct ndctl_region *region, struct ndctl_namespace
 			goto err;
 		}
 
-		/* check new seed creation for BLK regions */
-		if (ndctl_region_get_type(region) == ND_DEVICE_REGION_BLK) {
-			if (ns_seed == ndctl_region_get_namespace_seed(region)
-					&& ndns == ns_seed) {
-				fprintf(stderr, "%s: failed to advance namespace seed\n",
-						ndctl_region_get_devname(region));
-				goto err;
-			}
-		}
-
 		if (namespace->ro) {
 			ndctl_region_set_ro(region, 0);
 			rc = ndctl_btt_enable(btt);
diff --git a/test/multi-pmem.c b/test/multi-pmem.c
deleted file mode 100644
index 3ea08cc43f9a..000000000000
--- a/test/multi-pmem.c
+++ /dev/null
@@ -1,285 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-// Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <libkmod.h>
-#include <uuid/uuid.h>
-#include <sys/types.h>
-#include <util/size.h>
-#include <linux/falloc.h>
-#include <linux/version.h>
-#include <ndctl/libndctl.h>
-#include <ccan/array_size/array_size.h>
-
-#include <ndctl.h>
-#include <builtin.h>
-#include <test.h>
-
-#define NUM_NAMESPACES 4
-#define SZ_NAMESPACE SZ_16M
-
-static int setup_namespace(struct ndctl_region *region)
-{
-	struct ndctl_ctx *ctx = ndctl_region_get_ctx(region);
-	const char *argv[] = {
-		"__func__", "-v", "-m", "raw", "-s", "16M", "-r", "",
-	};
-	int argc = ARRAY_SIZE(argv);
-
-	argv[argc - 1] = ndctl_region_get_devname(region);
-	builtin_xaction_namespace_reset();
-	return cmd_create_namespace(argc, argv, ctx);
-}
-
-static void destroy_namespace(struct ndctl_namespace *ndns)
-{
-	struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
-	const char *argv[] = {
-		"__func__", "-v", "-f", "",
-	};
-	int argc = ARRAY_SIZE(argv);
-
-	argv[argc - 1] = ndctl_namespace_get_devname(ndns);
-	builtin_xaction_namespace_reset();
-	cmd_destroy_namespace(argc, argv, ctx);
-}
-
-/* Check that the namespace device is gone (if it wasn't the seed) */
-static int check_deleted(struct ndctl_region *region, const char *devname,
-		struct ndctl_test *test)
-{
-	struct ndctl_namespace *ndns;
-
-	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 10, 0)))
-		return 0;
-
-	ndctl_namespace_foreach(region, ndns) {
-		if (strcmp(devname, ndctl_namespace_get_devname(ndns)))
-			continue;
-		if (ndns == ndctl_region_get_namespace_seed(region))
-			continue;
-		fprintf(stderr, "multi-pmem: expected %s to be deleted\n",
-				devname);
-		return -ENXIO;
-	}
-
-	return 0;
-}
-
-static int do_multi_pmem(struct ndctl_ctx *ctx, struct ndctl_test *test)
-{
-	int i;
-	char devname[100];
-	struct ndctl_bus *bus;
-	uuid_t uuid[NUM_NAMESPACES];
-	struct ndctl_namespace *ndns;
-	struct ndctl_dimm *dimm_target, *dimm;
-	struct ndctl_region *region, *target = NULL;
-	struct ndctl_namespace *namespaces[NUM_NAMESPACES];
-	unsigned long long blk_avail, blk_avail_orig, expect;
-
-	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 9, 0))) {
-		ndctl_test_skip(test);
-		return 77;
-	}
-
-	bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
-	if (!bus)
-		return -ENXIO;
-
-	/* disable all regions so that set_config_data commands are permitted */
-	ndctl_region_foreach(bus, region)
-		ndctl_region_disable_invalidate(region);
-
-	ndctl_dimm_foreach(bus, dimm) {
-		int rc = ndctl_dimm_zero_labels(dimm);
-
-		if (rc < 0) {
-			fprintf(stderr, "failed to zero %s\n",
-					ndctl_dimm_get_devname(dimm));
-			return rc;
-		}
-	}
-
-	/*
-	 * Set regions back to their default state and find our target
-	 * region.
-	 */
-	ndctl_region_foreach(bus, region) {
-		ndctl_region_enable(region);
-		if (ndctl_region_get_available_size(region)
-				== SZ_NAMESPACE * NUM_NAMESPACES)
-			target = region;
-	}
-
-	if (!target) {
-		fprintf(stderr, "multi-pmem: failed to find target region\n");
-		return -ENXIO;
-	}
-	region = target;
-
-	for (i = 0; i < (int) ARRAY_SIZE(uuid); i++) {
-		if (setup_namespace(region) != 0) {
-			fprintf(stderr, "multi-pmem: failed to setup namespace: %d\n", i);
-			return -ENXIO;
-		}
-		sprintf(devname, "namespace%d.%d",
-				ndctl_region_get_id(region), i);
-		ndctl_namespace_foreach(region, ndns)
-			if (strcmp(ndctl_namespace_get_devname(ndns), devname) == 0
-					&& ndctl_namespace_is_enabled(ndns))
-				break;
-		if (!ndns) {
-			fprintf(stderr, "multi-pmem: failed to find namespace: %s\n",
-					devname);
-			return -ENXIO;
-		}
-		ndctl_namespace_get_uuid(ndns, uuid[i]);
-	}
-
-	/* bounce the region and verify everything came back as expected */
-	ndctl_region_disable_invalidate(region);
-	ndctl_region_enable(region);
-
-	for (i = 0; i < (int) ARRAY_SIZE(uuid); i++) {
-		char uuid_str1[40], uuid_str2[40];
-		uuid_t uuid_check;
-
-		sprintf(devname, "namespace%d.%d",
-				ndctl_region_get_id(region), i);
-		ndctl_namespace_foreach(region, ndns)
-			if (strcmp(ndctl_namespace_get_devname(ndns), devname) == 0
-					&& ndctl_namespace_is_enabled(ndns))
-				break;
-		if (!ndns) {
-			fprintf(stderr, "multi-pmem: failed to restore namespace: %s\n",
-					devname);
-			return -ENXIO;
-		}
-
-		ndctl_namespace_get_uuid(ndns, uuid_check);
-		uuid_unparse(uuid_check, uuid_str2);
-		uuid_unparse(uuid[i], uuid_str1);
-		if (uuid_compare(uuid_check, uuid[i]) != 0) {
-			fprintf(stderr, "multi-pmem: expected uuid[%d]: %s, got %s\n",
-					i, uuid_str1, uuid_str2);
-			return -ENXIO;
-		}
-		namespaces[i] = ndns;
-	}
-
-	/*
-	 * Check that aliased blk capacity does not increase until the
-	 * highest dpa pmem-namespace is deleted.
-	 */
-	dimm_target = ndctl_region_get_first_dimm(region);
-	if (!dimm_target) {
-		fprintf(stderr, "multi-pmem: failed to retrieve dimm from %s\n",
-				ndctl_region_get_devname(region));
-		return -ENXIO;
-	}
-
-	dimm = NULL;
-	ndctl_region_foreach(bus, region) {
-		if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
-			continue;
-		ndctl_dimm_foreach_in_region(region, dimm)
-			if (dimm == dimm_target)
-				break;
-		if (dimm)
-			break;
-	}
-
-	blk_avail_orig = ndctl_region_get_available_size(region);
-	for (i = 1; i < NUM_NAMESPACES - 1; i++) {
-		ndns = namespaces[i];
-		sprintf(devname, "%s", ndctl_namespace_get_devname(ndns));
-		destroy_namespace(ndns);
-		blk_avail = ndctl_region_get_available_size(region);
-		if (blk_avail != blk_avail_orig) {
-			fprintf(stderr, "multi-pmem: destroy %s %llx avail, expect %llx\n",
-					devname, blk_avail, blk_avail_orig);
-			return -ENXIO;
-		}
-
-		if (check_deleted(target, devname, test) != 0)
-			return -ENXIO;
-	}
-
-	ndns = namespaces[NUM_NAMESPACES - 1];
-	sprintf(devname, "%s", ndctl_namespace_get_devname(ndns));
-	destroy_namespace(ndns);
-	blk_avail = ndctl_region_get_available_size(region);
-	expect = (SZ_NAMESPACE / ndctl_region_get_interleave_ways(target))
-		* (NUM_NAMESPACES - 1) + blk_avail_orig;
-	if (blk_avail != expect) {
-		fprintf(stderr, "multi-pmem: destroy %s %llx avail, expect %llx\n",
-				devname, blk_avail, expect);
-		return -ENXIO;
-	}
-
-	if (check_deleted(target, devname, test) != 0)
-		return -ENXIO;
-
-	ndctl_bus_foreach(ctx, bus) {
-		if (strncmp(ndctl_bus_get_provider(bus), "nfit_test", 9) != 0)
-			continue;
-		ndctl_region_foreach(bus, region)
-			ndctl_region_disable_invalidate(region);
-	}
-
-	return 0;
-}
-
-int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
-{
-	struct kmod_module *mod;
-	struct kmod_ctx *kmod_ctx;
-	int err, result = EXIT_FAILURE;
-
-	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
-		return 77;
-
-	ndctl_set_log_priority(ctx, loglevel);
-
-	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
-	if (err < 0) {
-		result = 77;
-		ndctl_test_skip(test);
-		fprintf(stderr, "%s unavailable skipping tests\n",
-				"nfit_test");
-		return result;
-	}
-
-	result = do_multi_pmem(ctx, test);
-
-	kmod_module_remove_module(mod, 0);
-	kmod_unref(kmod_ctx);
-	return result;
-}
-
-int __attribute__((weak)) main(int argc, char *argv[])
-{
-	struct ndctl_test *test = ndctl_test_new(0);
-	struct ndctl_ctx *ctx;
-	int rc;
-
-	if (!test) {
-		fprintf(stderr, "failed to initialize test\n");
-		return EXIT_FAILURE;
-	}
-
-	rc = ndctl_new(&ctx);
-	if (rc)
-		return ndctl_test_result(test, rc);
-	rc = test_multi_pmem(LOG_DEBUG, test, ctx);
-	ndctl_unref(ctx);
-	return ndctl_test_result(test, rc);
-}
diff --git a/test/parent-uuid.c b/test/parent-uuid.c
deleted file mode 100644
index bded33afbf23..000000000000
--- a/test/parent-uuid.c
+++ /dev/null
@@ -1,254 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1
-// Copyright (C) 2015-2020, Intel Corporation. All rights reserved.
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <errno.h>
-#include <unistd.h>
-#include <limits.h>
-#include <syslog.h>
-#include <libkmod.h>
-#include <uuid/uuid.h>
-#include <linux/version.h>
-#include <test.h>
-
-#include <ndctl/libndctl.h>
-
-static const char *PROVIDER = "nfit_test.0";
-
-static struct ndctl_bus *get_bus_by_provider(struct ndctl_ctx *ctx,
-		const char *provider)
-{
-	struct ndctl_bus *bus;
-
-        ndctl_bus_foreach(ctx, bus)
-		if (strcmp(provider, ndctl_bus_get_provider(bus)) == 0)
-			return bus;
-
-	return NULL;
-}
-
-static struct ndctl_btt *get_idle_btt(struct ndctl_region *region)
-{
-	struct ndctl_btt *btt;
-
-	ndctl_btt_foreach(region, btt)
-		if (!ndctl_btt_is_enabled(btt)
-				&& !ndctl_btt_is_configured(btt))
-			return btt;
-	return NULL;
-}
-
-static struct ndctl_namespace *create_blk_namespace(int region_fraction,
-		struct ndctl_region *region, unsigned long long req_size,
-		uuid_t uuid)
-{
-	struct ndctl_namespace *ndns, *seed_ns = NULL;
-	unsigned long long size;
-
-	ndctl_region_set_align(region, sysconf(_SC_PAGESIZE));
-	ndctl_namespace_foreach(region, ndns)
-		if (ndctl_namespace_get_size(ndns) == 0) {
-			seed_ns = ndns;
-			break;
-		}
-
-	if (!seed_ns)
-		return NULL;
-
-	size = ndctl_region_get_size(region)/region_fraction;
-	if (req_size)
-		size = req_size;
-
-	if (ndctl_namespace_set_uuid(seed_ns, uuid) < 0)
-		return NULL;
-
-	if (ndctl_namespace_set_size(seed_ns, size) < 0)
-		return NULL;
-
-	if (ndctl_namespace_set_sector_size(seed_ns, 512) < 0)
-		return NULL;
-
-	if (ndctl_namespace_enable(seed_ns) < 0)
-		return NULL;
-
-	return seed_ns;
-}
-
-static int disable_blk_namespace(struct ndctl_namespace *ndns)
-{
-	if (ndctl_namespace_disable_invalidate(ndns) < 0)
-		return -ENODEV;
-
-	if (ndctl_namespace_delete(ndns) < 0)
-		return -ENODEV;
-
-	return 0;
-}
-
-static struct ndctl_btt *check_valid_btt(struct ndctl_region *region,
-		struct ndctl_namespace *ndns, uuid_t btt_uuid)
-{
-	struct ndctl_btt *btt = NULL;
-	ndctl_btt_foreach(region, btt) {
-		struct ndctl_namespace *btt_ndns;
-		uuid_t uu;
-
-		ndctl_btt_get_uuid(btt, uu);
-		if (uuid_compare(uu, btt_uuid) != 0)
-			continue;
-		if (!ndctl_btt_is_enabled(btt))
-			continue;
-		btt_ndns = ndctl_btt_get_namespace(btt);
-		if (!btt_ndns || strcmp(ndctl_namespace_get_devname(btt_ndns),
-				ndctl_namespace_get_devname(ndns)) != 0)
-			continue;
-		return btt;
-	}
-	return NULL;
-}
-
-static int do_test(struct ndctl_ctx *ctx)
-{
-	int rc;
-	struct ndctl_bus *bus;
-	struct ndctl_btt *btt, *found = NULL, *_btt;
-	struct ndctl_region *region, *blk_region = NULL;
-	struct ndctl_namespace *ndns, *_ndns;
-	unsigned long long ns_size = 18874368;
-	uuid_t uuid = {0,  1,  2,  3,  4,  5,  6,  7, 8, 9, 10, 11, 12, 13, 14, 16};
-	uuid_t btt_uuid;
-
-	bus = get_bus_by_provider(ctx, PROVIDER);
-	if (!bus) {
-		fprintf(stderr, "failed to find NFIT-provider: %s\n", PROVIDER);
-		return -ENODEV;
-	}
-
-	ndctl_region_foreach(bus, region)
-		if (strcmp(ndctl_region_get_type_name(region), "blk") == 0) {
-			blk_region = region;
-			break;
-		}
-
-	if (!blk_region) {
-		fprintf(stderr, "failed to find block region\n");
-		return -ENODEV;
-	}
-
-	/* create a blk namespace */
-	ndns = create_blk_namespace(1, blk_region, ns_size, uuid);
-	if (!ndns) {
-		fprintf(stderr, "failed to create block namespace\n");
-		return -ENXIO;
-	}
-
-	/* create a btt for this namespace */
-	uuid_generate(btt_uuid);
-	btt = get_idle_btt(region);
-	if (!btt)
-		return -ENXIO;
-
-	ndctl_namespace_disable_invalidate(ndns);
-	ndctl_btt_set_uuid(btt, btt_uuid);
-	ndctl_btt_set_sector_size(btt, 512);
-	ndctl_btt_set_namespace(btt, ndns);
-	rc = ndctl_btt_enable(btt);
-	if (rc) {
-		fprintf(stderr, "failed to create btt 0\n");
-		return rc;
-	}
-
-	/* re-create the namespace - this should auto-enable the btt */
-	disable_blk_namespace(ndns);
-	ndns = create_blk_namespace(1, blk_region, ns_size, uuid);
-	if (!ndns) {
-		fprintf(stderr, "failed to re-create block namespace\n");
-		return -ENXIO;
-	}
-
-	/* Verify btt was auto-created */
-	found = check_valid_btt(blk_region, ndns, btt_uuid);
-	if (!found)
-		return -ENXIO;
-	btt = found;
-
-	/*disable the btt and namespace again */
-	ndctl_btt_delete(btt);
-	disable_blk_namespace(ndns);
-
-	/* recreate the namespace with a different uuid */
-	uuid_generate(uuid);
-	ndns = create_blk_namespace(1, blk_region, ns_size, uuid);
-	if (!ndns) {
-		fprintf(stderr, "failed to re-create block namespace\n");
-		return -ENXIO;
-	}
-
-	/* make sure there is no btt on this namespace */
-	found = check_valid_btt(blk_region, ndns, btt_uuid);
-	if (found) {
-		fprintf(stderr, "found a stale btt\n");
-		return -ENXIO;
-	}
-
-	ndctl_btt_foreach_safe(blk_region, btt, _btt)
-		ndctl_btt_delete(btt);
-
-	ndctl_namespace_foreach_safe(blk_region, ndns, _ndns)
-		if (ndctl_namespace_get_size(ndns) != 0)
-			disable_blk_namespace(ndns);
-
-	ndctl_region_foreach(bus, region)
-		ndctl_region_disable_invalidate(region);
-
-	return 0;
-}
-
-int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
-{
-	struct kmod_module *mod;
-	struct kmod_ctx *kmod_ctx;
-	int err, result = EXIT_FAILURE;
-
-	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 3, 0)))
-		return 77;
-
-	ndctl_set_log_priority(ctx, loglevel);
-	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
-	if (err < 0) {
-		ndctl_test_skip(test);
-		fprintf(stderr, "nfit_test unavailable skipping tests\n");
-		return 77;
-	}
-
-	err = do_test(ctx);
-	if (err == 0)
-		result = EXIT_SUCCESS;
-	kmod_module_remove_module(mod, 0);
-	kmod_unref(kmod_ctx);
-	return result;
-}
-
-int __attribute__((weak)) main(int argc, char *argv[])
-{
-	struct ndctl_test *test = ndctl_test_new(0);
-	struct ndctl_ctx *ctx;
-	int rc;
-
-	if (!test) {
-		fprintf(stderr, "failed to initialize test\n");
-		return EXIT_FAILURE;
-	}
-
-	rc = ndctl_new(&ctx);
-	if (rc)
-		return ndctl_test_result(test, rc);
-
-	rc = test_parent_uuid(LOG_DEBUG, test, ctx);
-	ndctl_unref(ctx);
-	return ndctl_test_result(test, rc);
-}


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 08/16] ndctl/test: Fix support for missing dax_pmem_compat module
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (6 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 07/16] ndctl: Deprecate BLK aperture support Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 09/16] util: Distribute 'filter' and 'json' helpers to per-tool objects Dan Williams
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

The kernel is moving to drop CONFIG_DEV_DAX_PMEM_COMPAT. Update
ndctl_test_init() to not error out if dax_pmem_compat is missing. It seems
that the original implementation of support for missing dax_pmem_compat was
broken, or since that time newer versions of kmod_module_new_from_name() no
longer fail when the module is missing.

Fixes: b7991dbc22f3 ("ndctl/test: Relax dax_pmem_compat requirement")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/core.c |   25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/test/core.c b/test/core.c
index dc1405d75c49..5d1aa23723f1 100644
--- a/test/core.c
+++ b/test/core.c
@@ -120,7 +120,6 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 		"nfit",
 		"device_dax",
 		"dax_pmem",
-		"dax_pmem_core",
 		"dax_pmem_compat",
 		"libnvdimm",
 		"nd_btt",
@@ -180,29 +179,27 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 		/*
 		 * Skip device-dax bus-model modules on pre-v5.1
 		 */
-		if ((strcmp(name, "dax_pmem_core") == 0
-				|| strcmp(name, "dax_pmem_compat") == 0)
-				&& !ndctl_test_attempt(test,
-					KERNEL_VERSION(5, 1, 0)))
+		if ((strcmp(name, "dax_pmem_compat") == 0) &&
+		    !ndctl_test_attempt(test, KERNEL_VERSION(5, 1, 0)))
 			continue;
 
 retry:
 		rc = kmod_module_new_from_name(*ctx, name, mod);
-
-		/*
-		 * dax_pmem_compat is not required, missing is ok,
-		 * present-but-production is not ok.
-		 */
-		if (rc && strcmp(name, "dax_pmem_compat") == 0)
-			continue;
-
 		if (rc) {
-			log_err(&log_ctx, "%s.ko: missing\n", name);
+			log_err(&log_ctx, "failed to interrogate %s.ko\n",
+				name);
 			break;
 		}
 
 		path = kmod_module_get_path(*mod);
 		if (!path) {
+			/*
+			 * dax_pmem_compat is not required, missing is
+			 * ok, present-but-production is not ok.
+			 */
+			if (strcmp(name, "dax_pmem_compat") == 0)
+				continue;
+
 			if (family != NVDIMM_FAMILY_INTEL &&
 			    (strcmp(name, "nfit") == 0 ||
 			     strcmp(name, "nd_e820") == 0))


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 09/16] util: Distribute 'filter' and 'json' helpers to per-tool objects
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (7 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 08/16] ndctl/test: Fix support for missing dax_pmem_compat module Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 10/16] Documentation: Drop attrs.adoc include Dan Williams
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

In preparation for switching build systems, fix the long standing wart
of mixing ndctl, daxctl, and cxl 'filter' and 'json' utilities in the
top-level util/filter.[ch]. Distribute them to their respective
{ndctl,daxctl,cxl}/filter.{c,h} locations.

This also removes the naming collisions for util/json.h between util/
and ndct/util/. I.e. <util/json.h> is no longer ambiguous or subject to
being shadowed by the tool local "util" directory.

Unfortunately unwinding this caused a lot of code to move all at once.
The benefit is that now it is clear that ndctl is the only tool that
reaches across into the 'filter' and 'json' functionality of another
tool (daxctl).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Makefile.am                   |    1 
 Makefile.am.in                |    3 
 cxl/Makefile.am               |    3 
 cxl/filter.c                  |   25 +
 cxl/filter.h                  |    7 
 cxl/json.c                    |  214 ++++++
 cxl/json.h                    |    8 
 cxl/list.c                    |    4 
 cxl/memdev.c                  |    3 
 daxctl/Makefile.am            |    5 
 daxctl/device.c               |    4 
 daxctl/filter.c               |   43 +
 daxctl/filter.h               |   12 
 daxctl/json.c                 |  245 +++++++
 daxctl/json.h                 |   18 
 daxctl/list.c                 |    4 
 ndctl/Makefile.am             |   16 
 ndctl/bus.c                   |    4 
 ndctl/check.c                 |    2 
 ndctl/dimm.c                  |    6 
 ndctl/filter.c                |   60 --
 ndctl/filter.h                |   12 
 ndctl/inject-error.c          |    6 
 ndctl/inject-smart.c          |    6 
 ndctl/json-smart.c            |    5 
 ndctl/json.c                  | 1114 ++++++++++++++++++++++++++++++
 ndctl/json.h                  |   24 +
 ndctl/keys.c                  |    5 
 ndctl/keys.h                  |    0 
 ndctl/lib/libndctl.c          |    2 
 ndctl/lib/papr.c              |    4 
 ndctl/lib/private.h           |    4 
 ndctl/list.c                  |    5 
 ndctl/load-keys.c             |    7 
 ndctl/monitor.c               |    4 
 ndctl/namespace.c             |    6 
 ndctl/region.c                |    3 
 test/Makefile.am              |   22 -
 test/ack-shutdown-count-set.c |    2 
 test/daxdev-errors.c          |    2 
 test/device-dax.c             |    2 
 test/dsm-fail.c               |    4 
 test/libndctl.c               |    2 
 test/list-smart-dimm.c        |    6 
 test/pmem_namespaces.c        |    2 
 test/revoke-devmem.c          |    2 
 util/help.c                   |    2 
 util/json.c                   | 1542 -----------------------------------------
 util/json.h                   |   39 -
 49 files changed, 1820 insertions(+), 1701 deletions(-)
 create mode 100644 cxl/filter.c
 create mode 100644 cxl/filter.h
 create mode 100644 cxl/json.c
 create mode 100644 cxl/json.h
 create mode 100644 daxctl/filter.c
 create mode 100644 daxctl/filter.h
 create mode 100644 daxctl/json.c
 create mode 100644 daxctl/json.h
 rename util/filter.c => ndctl/filter.c (88%)
 rename util/filter.h => ndctl/filter.h (89%)
 rename ndctl/{util/json-smart.c => json-smart.c} (99%)
 create mode 100644 ndctl/json.c
 create mode 100644 ndctl/json.h
 rename ndctl/{util/keys.c => keys.c} (99%)
 rename ndctl/{util/keys.h => keys.h} (100%)

diff --git a/Makefile.am b/Makefile.am
index 269d891f7cd4..daea39f5d41e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -86,7 +86,6 @@ libutil_a_SOURCES = \
 	util/help.c \
 	util/strbuf.c \
 	util/wrapper.c \
-	util/filter.c \
 	util/bitmap.c \
 	util/abspath.c \
 	util/iomem.c \
diff --git a/Makefile.am.in b/Makefile.am.in
index 9c2c4dfbc021..d6b126986bb4 100644
--- a/Makefile.am.in
+++ b/Makefile.am.in
@@ -9,9 +9,6 @@ AM_CPPFLAGS = \
 	-DLIBEXECDIR=\""$(libexecdir)"\" \
 	-DPREFIX=\""$(prefix)"\" \
 	-DNDCTL_MAN_PATH=\""$(mandir)"\" \
-	-I${top_srcdir}/ndctl/lib \
-	-I${top_srcdir}/ndctl \
-	-I${top_srcdir}/cxl \
 	-I${top_srcdir}/ \
 	$(KMOD_CFLAGS) \
 	$(UDEV_CFLAGS) \
diff --git a/cxl/Makefile.am b/cxl/Makefile.am
index da9f91d8fd05..ee8488900a3b 100644
--- a/cxl/Makefile.am
+++ b/cxl/Makefile.am
@@ -12,6 +12,9 @@ cxl_SOURCES =\
 		list.c \
 		memdev.c \
 		../util/json.c \
+		json.c \
+		filter.c \
+		filter.h \
 		builtin.h
 
 cxl_LDADD =\
diff --git a/cxl/filter.c b/cxl/filter.c
new file mode 100644
index 000000000000..21322ed4b4d0
--- /dev/null
+++ b/cxl/filter.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
+#include <stdio.h>
+#include <string.h>
+#include <cxl/libcxl.h>
+#include "filter.h"
+
+struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
+                                         const char *ident)
+{
+       int memdev_id;
+
+       if (!ident || strcmp(ident, "all") == 0)
+               return memdev;
+
+       if (strcmp(ident, cxl_memdev_get_devname(memdev)) == 0)
+               return memdev;
+
+       if ((sscanf(ident, "%d", &memdev_id) == 1
+                       || sscanf(ident, "mem%d", &memdev_id) == 1)
+                       && cxl_memdev_get_id(memdev) == memdev_id)
+               return memdev;
+
+       return NULL;
+}
diff --git a/cxl/filter.h b/cxl/filter.h
new file mode 100644
index 000000000000..da800336b528
--- /dev/null
+++ b/cxl/filter.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2015-2020 Intel Corporation. All rights reserved. */
+#ifndef _CXL_UTIL_FILTER_H_
+#define _CXL_UTIL_FILTER_H_
+struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
+		const char *ident);
+#endif /* _CXL_UTIL_FILTER_H_ */
diff --git a/cxl/json.c b/cxl/json.c
new file mode 100644
index 000000000000..e562502d9116
--- /dev/null
+++ b/cxl/json.c
@@ -0,0 +1,214 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
+#include <util/json.h>
+#include <uuid/uuid.h>
+#include <cxl/libcxl.h>
+#include <json-c/json.h>
+#include <json-c/printbuf.h>
+#include <ccan/short_types/short_types.h>
+
+#include "json.h"
+
+static struct json_object *util_cxl_memdev_health_to_json(
+		struct cxl_memdev *memdev, unsigned long flags)
+{
+	struct json_object *jhealth;
+	struct json_object *jobj;
+	struct cxl_cmd *cmd;
+	u32 field;
+	int rc;
+
+	jhealth = json_object_new_object();
+	if (!jhealth)
+		return NULL;
+	if (!memdev)
+		goto err_jobj;
+
+	cmd = cxl_cmd_new_get_health_info(memdev);
+	if (!cmd)
+		goto err_jobj;
+
+	rc = cxl_cmd_submit(cmd);
+	if (rc < 0)
+		goto err_cmd;
+	rc = cxl_cmd_get_mbox_status(cmd);
+	if (rc != 0)
+		goto err_cmd;
+
+	/* health_status fields */
+	rc = cxl_cmd_health_info_get_maintenance_needed(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "maintenance_needed", jobj);
+
+	rc = cxl_cmd_health_info_get_performance_degraded(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "performance_degraded", jobj);
+
+	rc = cxl_cmd_health_info_get_hw_replacement_needed(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "hw_replacement_needed", jobj);
+
+	/* media_status fields */
+	rc = cxl_cmd_health_info_get_media_normal(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_normal", jobj);
+
+	rc = cxl_cmd_health_info_get_media_not_ready(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_not_ready", jobj);
+
+	rc = cxl_cmd_health_info_get_media_persistence_lost(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_persistence_lost", jobj);
+
+	rc = cxl_cmd_health_info_get_media_data_lost(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_data_lost", jobj);
+
+	rc = cxl_cmd_health_info_get_media_powerloss_persistence_loss(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_powerloss_persistence_loss", jobj);
+
+	rc = cxl_cmd_health_info_get_media_shutdown_persistence_loss(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_shutdown_persistence_loss", jobj);
+
+	rc = cxl_cmd_health_info_get_media_persistence_loss_imminent(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_persistence_loss_imminent", jobj);
+
+	rc = cxl_cmd_health_info_get_media_powerloss_data_loss(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_powerloss_data_loss", jobj);
+
+	rc = cxl_cmd_health_info_get_media_shutdown_data_loss(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_shutdown_data_loss", jobj);
+
+	rc = cxl_cmd_health_info_get_media_data_loss_imminent(cmd);
+	jobj = json_object_new_boolean(rc);
+	if (jobj)
+		json_object_object_add(jhealth, "media_data_loss_imminent", jobj);
+
+	/* ext_status fields */
+	if (cxl_cmd_health_info_get_ext_life_used_normal(cmd))
+		jobj = json_object_new_string("normal");
+	else if (cxl_cmd_health_info_get_ext_life_used_warning(cmd))
+		jobj = json_object_new_string("warning");
+	else if (cxl_cmd_health_info_get_ext_life_used_critical(cmd))
+		jobj = json_object_new_string("critical");
+	else
+		jobj = json_object_new_string("unknown");
+	if (jobj)
+		json_object_object_add(jhealth, "ext_life_used", jobj);
+
+	if (cxl_cmd_health_info_get_ext_temperature_normal(cmd))
+		jobj = json_object_new_string("normal");
+	else if (cxl_cmd_health_info_get_ext_temperature_warning(cmd))
+		jobj = json_object_new_string("warning");
+	else if (cxl_cmd_health_info_get_ext_temperature_critical(cmd))
+		jobj = json_object_new_string("critical");
+	else
+		jobj = json_object_new_string("unknown");
+	if (jobj)
+		json_object_object_add(jhealth, "ext_temperature", jobj);
+
+	if (cxl_cmd_health_info_get_ext_corrected_volatile_normal(cmd))
+		jobj = json_object_new_string("normal");
+	else if (cxl_cmd_health_info_get_ext_corrected_volatile_warning(cmd))
+		jobj = json_object_new_string("warning");
+	else
+		jobj = json_object_new_string("unknown");
+	if (jobj)
+		json_object_object_add(jhealth, "ext_corrected_volatile", jobj);
+
+	if (cxl_cmd_health_info_get_ext_corrected_persistent_normal(cmd))
+		jobj = json_object_new_string("normal");
+	else if (cxl_cmd_health_info_get_ext_corrected_persistent_warning(cmd))
+		jobj = json_object_new_string("warning");
+	else
+		jobj = json_object_new_string("unknown");
+	if (jobj)
+		json_object_object_add(jhealth, "ext_corrected_persistent", jobj);
+
+	/* other fields */
+	field = cxl_cmd_health_info_get_life_used(cmd);
+	if (field != 0xff) {
+		jobj = json_object_new_int(field);
+		if (jobj)
+			json_object_object_add(jhealth, "life_used_percent", jobj);
+	}
+
+	field = cxl_cmd_health_info_get_temperature(cmd);
+	if (field != 0xffff) {
+		jobj = json_object_new_int(field);
+		if (jobj)
+			json_object_object_add(jhealth, "temperature", jobj);
+	}
+
+	field = cxl_cmd_health_info_get_dirty_shutdowns(cmd);
+	jobj = json_object_new_int64(field);
+	if (jobj)
+		json_object_object_add(jhealth, "dirty_shutdowns", jobj);
+
+	field = cxl_cmd_health_info_get_volatile_errors(cmd);
+	jobj = json_object_new_int64(field);
+	if (jobj)
+		json_object_object_add(jhealth, "volatile_errors", jobj);
+
+	field = cxl_cmd_health_info_get_pmem_errors(cmd);
+	jobj = json_object_new_int64(field);
+	if (jobj)
+		json_object_object_add(jhealth, "pmem_errors", jobj);
+
+	cxl_cmd_unref(cmd);
+	return jhealth;
+
+err_cmd:
+	cxl_cmd_unref(cmd);
+err_jobj:
+	json_object_put(jhealth);
+	return NULL;
+}
+
+struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
+		unsigned long flags)
+{
+	const char *devname = cxl_memdev_get_devname(memdev);
+	struct json_object *jdev, *jobj;
+
+	jdev = json_object_new_object();
+	if (!devname || !jdev)
+		return NULL;
+
+	jobj = json_object_new_string(devname);
+	if (jobj)
+		json_object_object_add(jdev, "memdev", jobj);
+
+	jobj = util_json_object_size(cxl_memdev_get_pmem_size(memdev), flags);
+	if (jobj)
+		json_object_object_add(jdev, "pmem_size", jobj);
+
+	jobj = util_json_object_size(cxl_memdev_get_ram_size(memdev), flags);
+	if (jobj)
+		json_object_object_add(jdev, "ram_size", jobj);
+
+	if (flags & UTIL_JSON_HEALTH) {
+		jobj = util_cxl_memdev_health_to_json(memdev, flags);
+		if (jobj)
+			json_object_object_add(jdev, "health", jobj);
+	}
+	return jdev;
+}
diff --git a/cxl/json.h b/cxl/json.h
new file mode 100644
index 000000000000..3abcfe6661bf
--- /dev/null
+++ b/cxl/json.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2015-2020 Intel Corporation. All rights reserved. */
+#ifndef __CXL_UTIL_JSON_H__
+#define __CXL_UTIL_JSON_H__
+struct cxl_memdev;
+struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
+		unsigned long flags);
+#endif /* __CXL_UTIL_JSON_H__ */
diff --git a/cxl/list.c b/cxl/list.c
index b1468b70f8c9..7f7a04d9a6e5 100644
--- a/cxl/list.c
+++ b/cxl/list.c
@@ -6,12 +6,14 @@
 #include <unistd.h>
 #include <limits.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
 #include <cxl/libcxl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
 
+#include "json.h"
+#include "filter.h"
+
 static struct {
 	bool memdevs;
 	bool idle;
diff --git a/cxl/memdev.c b/cxl/memdev.c
index 5ee38e51f4ee..d063d51cc571 100644
--- a/cxl/memdev.c
+++ b/cxl/memdev.c
@@ -6,12 +6,13 @@
 #include <unistd.h>
 #include <limits.h>
 #include <util/log.h>
-#include <util/filter.h>
 #include <cxl/libcxl.h>
 #include <util/parse-options.h>
 #include <ccan/minmax/minmax.h>
 #include <ccan/array_size/array_size.h>
 
+#include "filter.h"
+
 struct action_context {
 	FILE *f_out;
 	FILE *f_in;
diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am
index d1bf9fb25a7d..bbf764f8081f 100644
--- a/daxctl/Makefile.am
+++ b/daxctl/Makefile.am
@@ -18,6 +18,11 @@ daxctl_SOURCES =\
 		migrate.c \
 		device.c \
 		../util/json.c \
+		../util/json.h \
+		json.c \
+		json.h \
+		filter.c \
+		filter.h \
 		builtin.h
 
 daxctl_LDADD =\
diff --git a/daxctl/device.c b/daxctl/device.c
index c2ff0cc60b52..d202f02d07e7 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -11,7 +11,6 @@
 #include <sys/sysmacros.h>
 #include <util/size.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
 #include <json-c/json_util.h>
 #include <ndctl/libndctl.h>
@@ -20,6 +19,9 @@
 #include <util/parse-configs.h>
 #include <ccan/array_size/array_size.h>
 
+#include "filter.h"
+#include "json.h"
+
 static struct {
 	const char *dev;
 	const char *mode;
diff --git a/daxctl/filter.c b/daxctl/filter.c
new file mode 100644
index 000000000000..cecb808edade
--- /dev/null
+++ b/daxctl/filter.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
+#include <stdio.h>
+#include <string.h>
+#include <daxctl/libdaxctl.h>
+
+#include "filter.h"
+
+struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
+					  const char *ident)
+{
+	struct daxctl_region *region = daxctl_dev_get_region(dev);
+	int region_id, dev_id;
+
+	if (!ident || strcmp(ident, "all") == 0)
+		return dev;
+
+	if (strcmp(ident, daxctl_dev_get_devname(dev)) == 0)
+		return dev;
+
+	if (sscanf(ident, "%d.%d", &region_id, &dev_id) == 2 &&
+	    daxctl_region_get_id(region) == region_id &&
+	    daxctl_dev_get_id(dev) == dev_id)
+		return dev;
+
+	return NULL;
+}
+
+struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
+						const char *ident)
+{
+	int region_id;
+
+	if (!ident || strcmp(ident, "all") == 0)
+		return region;
+
+	if ((sscanf(ident, "%d", &region_id) == 1 ||
+	     sscanf(ident, "region%d", &region_id) == 1) &&
+	    daxctl_region_get_id(region) == region_id)
+		return region;
+
+	return NULL;
+}
diff --git a/daxctl/filter.h b/daxctl/filter.h
new file mode 100644
index 000000000000..234f2216e57e
--- /dev/null
+++ b/daxctl/filter.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2015-2020 Intel Corporation. All rights reserved. */
+#ifndef _DAXCTL_UTIL_FILTER_H_
+#define _DAXCTL_UTIL_FILTER_H_
+#include <stdbool.h>
+#include <ccan/list/list.h>
+
+struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
+		const char *ident);
+struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
+		const char *ident);
+#endif /* _DAXCTL_UTIL_FILTER_H_ */
diff --git a/daxctl/json.c b/daxctl/json.c
new file mode 100644
index 000000000000..66a795e2e544
--- /dev/null
+++ b/daxctl/json.c
@@ -0,0 +1,245 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
+#include <limits.h>
+#include <string.h>
+#include <util/json.h>
+#include <uuid/uuid.h>
+#include <json-c/json.h>
+#include <json-c/printbuf.h>
+#include <daxctl/libdaxctl.h>
+
+#include "filter.h"
+#include "json.h"
+
+struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev,
+		unsigned long flags)
+{
+	struct daxctl_memory *mem = daxctl_dev_get_memory(dev);
+	const char *devname = daxctl_dev_get_devname(dev);
+	struct json_object *jdev, *jobj, *jmappings = NULL;
+	struct daxctl_mapping *mapping = NULL;
+	int node, movable, align;
+
+	jdev = json_object_new_object();
+	if (!devname || !jdev)
+		return NULL;
+
+	jobj = json_object_new_string(devname);
+	if (jobj)
+		json_object_object_add(jdev, "chardev", jobj);
+
+	jobj = util_json_object_size(daxctl_dev_get_size(dev), flags);
+	if (jobj)
+		json_object_object_add(jdev, "size", jobj);
+
+	node = daxctl_dev_get_target_node(dev);
+	if (node >= 0) {
+		jobj = json_object_new_int(node);
+		if (jobj)
+			json_object_object_add(jdev, "target_node", jobj);
+	}
+
+	align = daxctl_dev_get_align(dev);
+	if (align > 0) {
+		jobj = util_json_object_size(daxctl_dev_get_align(dev), flags);
+		if (jobj)
+			json_object_object_add(jdev, "align", jobj);
+	}
+
+	if (mem)
+		jobj = json_object_new_string("system-ram");
+	else
+		jobj = json_object_new_string("devdax");
+	if (jobj)
+		json_object_object_add(jdev, "mode", jobj);
+
+	if (mem && daxctl_dev_get_resource(dev) != 0) {
+		int num_sections = daxctl_memory_num_sections(mem);
+		int num_online = daxctl_memory_is_online(mem);
+
+		jobj = json_object_new_int(num_online);
+		if (jobj)
+			json_object_object_add(jdev, "online_memblocks", jobj);
+
+		jobj = json_object_new_int(num_sections);
+		if (jobj)
+			json_object_object_add(jdev, "total_memblocks", jobj);
+
+		movable = daxctl_memory_is_movable(mem);
+		if (movable == 1)
+			jobj = json_object_new_boolean(true);
+		else if (movable == 0)
+			jobj = json_object_new_boolean(false);
+		else
+			jobj = NULL;
+		if (jobj)
+			json_object_object_add(jdev, "movable", jobj);
+	}
+
+	if (!daxctl_dev_is_enabled(dev)) {
+		jobj = json_object_new_string("disabled");
+		if (jobj)
+			json_object_object_add(jdev, "state", jobj);
+	}
+
+	if (!(flags & UTIL_JSON_DAX_MAPPINGS))
+		return jdev;
+
+	daxctl_mapping_foreach(dev, mapping) {
+		struct json_object *jmapping;
+
+		if (!jmappings) {
+			jmappings = json_object_new_array();
+			if (!jmappings)
+				continue;
+
+			json_object_object_add(jdev, "mappings", jmappings);
+		}
+
+		jmapping = util_daxctl_mapping_to_json(mapping, flags);
+		if (!jmapping)
+			continue;
+		json_object_array_add(jmappings, jmapping);
+	}
+	return jdev;
+}
+
+struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region,
+		struct json_object *jdevs, const char *ident,
+		unsigned long flags)
+{
+	struct daxctl_dev *dev;
+
+	daxctl_dev_foreach(region, dev) {
+		struct json_object *jdev;
+
+		if (!util_daxctl_dev_filter(dev, ident))
+			continue;
+
+		if (!(flags & (UTIL_JSON_IDLE|UTIL_JSON_CONFIGURED))
+				&& !daxctl_dev_get_size(dev))
+			continue;
+
+		if (!jdevs) {
+			jdevs = json_object_new_array();
+			if (!jdevs)
+				return NULL;
+		}
+
+		jdev = util_daxctl_dev_to_json(dev, flags);
+		if (!jdev) {
+			json_object_put(jdevs);
+			return NULL;
+		}
+
+		json_object_array_add(jdevs, jdev);
+	}
+
+	return jdevs;
+}
+
+struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
+		const char *ident, unsigned long flags)
+{
+	unsigned long align;
+	struct json_object *jregion, *jobj;
+	unsigned long long available_size, size;
+
+	jregion = json_object_new_object();
+	if (!jregion)
+		return NULL;
+
+	/*
+	 * The flag indicates when we are being called by an agent that
+	 * already knows about the parent device information.
+	 */
+	if (!(flags & UTIL_JSON_DAX)) {
+		/* trim off the redundant /sys/devices prefix */
+		const char *path = daxctl_region_get_path(region);
+		int len = strlen("/sys/devices");
+		const char *trim = &path[len];
+
+		if (strncmp(path, "/sys/devices", len) != 0)
+			goto err;
+		jobj = json_object_new_string(trim);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jregion, "path", jobj);
+	}
+
+	jobj = json_object_new_int(daxctl_region_get_id(region));
+	if (!jobj)
+		goto err;
+	json_object_object_add(jregion, "id", jobj);
+
+	size = daxctl_region_get_size(region);
+	if (size < ULLONG_MAX) {
+		jobj = util_json_object_size(size, flags);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jregion, "size", jobj);
+	}
+
+	available_size = daxctl_region_get_available_size(region);
+	if (available_size) {
+		jobj = util_json_object_size(available_size, flags);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jregion, "available_size", jobj);
+	}
+
+	align = daxctl_region_get_align(region);
+	if (align < ULONG_MAX) {
+		jobj = json_object_new_int64(align);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jregion, "align", jobj);
+	}
+
+	if (!(flags & UTIL_JSON_DAX_DEVS))
+		return jregion;
+
+	jobj = util_daxctl_devs_to_list(region, NULL, ident, flags);
+	if (jobj)
+		json_object_object_add(jregion, "devices", jobj);
+
+	return jregion;
+ err:
+	json_object_put(jregion);
+	return NULL;
+}
+
+struct json_object *util_daxctl_mapping_to_json(struct daxctl_mapping *mapping,
+		unsigned long flags)
+{
+	struct json_object *jmapping = json_object_new_object();
+	struct json_object *jobj;
+
+	if (!jmapping)
+		return NULL;
+
+	jobj = util_json_object_hex(daxctl_mapping_get_offset(mapping), flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jmapping, "page_offset", jobj);
+
+	jobj = util_json_object_hex(daxctl_mapping_get_start(mapping), flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jmapping, "start", jobj);
+
+	jobj = util_json_object_hex(daxctl_mapping_get_end(mapping), flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jmapping, "end", jobj);
+
+	jobj = util_json_object_size(daxctl_mapping_get_size(mapping), flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jmapping, "size", jobj);
+
+	return jmapping;
+ err:
+	json_object_put(jmapping);
+	return NULL;
+}
diff --git a/daxctl/json.h b/daxctl/json.h
new file mode 100644
index 000000000000..fc82f06bd594
--- /dev/null
+++ b/daxctl/json.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2015-2020 Intel Corporation. All rights reserved. */
+#ifndef __DAXCTL_JSON_H__
+#define __DAXCTL_JSON_H__
+#include <daxctl/libdaxctl.h>
+
+struct json_object *util_daxctl_mapping_to_json(struct daxctl_mapping *mapping,
+		unsigned long flags);
+struct daxctl_region;
+struct daxctl_dev;
+struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
+		const char *ident, unsigned long flags);
+struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev,
+		unsigned long flags);
+struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region,
+		struct json_object *jdevs, const char *ident,
+		unsigned long flags);
+#endif /*  __CXL_UTIL_JSON_H__ */
diff --git a/daxctl/list.c b/daxctl/list.c
index cf93c2f7e8ed..aeff1967116b 100644
--- a/daxctl/list.c
+++ b/daxctl/list.c
@@ -6,12 +6,14 @@
 #include <unistd.h>
 #include <limits.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
 #include <daxctl/libdaxctl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
 
+#include "filter.h"
+#include "json.h"
+
 static struct {
 	bool devs;
 	bool regions;
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
index 93b682e8b202..5d5b1cacda9d 100644
--- a/ndctl/Makefile.am
+++ b/ndctl/Makefile.am
@@ -19,13 +19,19 @@ ndctl_SOURCES = ndctl.c \
 		region.c \
 		dimm.c \
 		../util/log.c \
-		../util/filter.c \
-		../util/filter.h \
+		../daxctl/filter.c \
+		../daxctl/filter.h \
+		filter.c \
+		filter.h \
 		list.c \
 		../util/json.c \
 		../util/json.h \
-		util/json-smart.c \
-		util/keys.h \
+		../daxctl/json.c \
+		../daxctl/json.h \
+		json.c \
+		json.h \
+		json-smart.c \
+		keys.h \
 		inject-error.c \
 		inject-smart.c \
 		monitor.c \
@@ -36,7 +42,7 @@ ndctl_SOURCES = ndctl.c \
 		firmware-update.h
 
 if ENABLE_KEYUTILS
-ndctl_SOURCES += util/keys.c \
+ndctl_SOURCES += keys.c \
 		load-keys.c
 keys_configdir = $(ndctl_keysdir)
 keys_config_DATA = $(ndctl_keysreadme)
diff --git a/ndctl/bus.c b/ndctl/bus.c
index 9bc1797e50eb..4fbb6bb505d1 100644
--- a/ndctl/bus.c
+++ b/ndctl/bus.c
@@ -8,12 +8,14 @@
 #include <syslog.h>
 #include <builtin.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
 
+#include "filter.h"
+#include "json.h"
+
 static struct {
 	bool verbose;
 	bool force;
diff --git a/ndctl/check.c b/ndctl/check.c
index b4e20657e1dd..523923745a33 100644
--- a/ndctl/check.c
+++ b/ndctl/check.c
@@ -8,7 +8,6 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <ndctl.h>
 #include <limits.h>
 #include <stdbool.h>
 #include <sys/mman.h>
@@ -20,6 +19,7 @@
 #include <util/util.h>
 #include <util/bitmap.h>
 #include <util/fletcher.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <ndctl/namespace.h>
 #include <ccan/endian/endian.h>
diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index 1d2d9a2b51d7..0f052644a46e 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -11,7 +11,6 @@
 #include <util/size.h>
 #include <uuid/uuid.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
 #include <util/fletcher.h>
 #include <ndctl/libndctl.h>
@@ -20,7 +19,10 @@
 #include <ccan/minmax/minmax.h>
 #include <ccan/array_size/array_size.h>
 #include <ndctl/firmware-update.h>
-#include <util/keys.h>
+
+#include "filter.h"
+#include "json.h"
+#include "keys.h"
 
 static const char *cmd_name = "dimm";
 static int err_count;
diff --git a/util/filter.c b/ndctl/filter.c
similarity index 88%
rename from util/filter.c
rename to ndctl/filter.c
index d81dadebd0d8..64d00ce87dd5 100644
--- a/util/filter.c
+++ b/ndctl/filter.c
@@ -9,10 +9,9 @@
 #include <util/util.h>
 #include <sys/types.h>
 #include <ndctl/ndctl.h>
-#include <util/filter.h>
 #include <ndctl/libndctl.h>
-#include <daxctl/libdaxctl.h>
-#include <cxl/libcxl.h>
+
+#include "filter.h"
 
 struct ndctl_bus *util_bus_filter(struct ndctl_bus *bus, const char *__ident)
 {
@@ -304,61 +303,6 @@ struct ndctl_region *util_region_filter_by_namespace(struct ndctl_region *region
 	return NULL;
 }
 
-struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
-		const char *ident)
-{
-	struct daxctl_region *region = daxctl_dev_get_region(dev);
-	int region_id, dev_id;
-
-	if (!ident || strcmp(ident, "all") == 0)
-		return dev;
-
-	if (strcmp(ident, daxctl_dev_get_devname(dev)) == 0)
-		return dev;
-
-	if (sscanf(ident, "%d.%d", &region_id, &dev_id) == 2
-			&& daxctl_region_get_id(region) == region_id
-			&& daxctl_dev_get_id(dev) == dev_id)
-		return dev;
-
-	return NULL;
-}
-
-struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
-		const char *ident)
-{
-	int region_id;
-
-	if (!ident || strcmp(ident, "all") == 0)
-		return region;
-
-	if ((sscanf(ident, "%d", &region_id) == 1
-			|| sscanf(ident, "region%d", &region_id) == 1)
-			&& daxctl_region_get_id(region) == region_id)
-		return region;
-
-	return NULL;
-}
-
-struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
-					  const char *ident)
-{
-	int memdev_id;
-
-	if (!ident || strcmp(ident, "all") == 0)
-		return memdev;
-
-	if (strcmp(ident, cxl_memdev_get_devname(memdev)) == 0)
-		return memdev;
-
-	if ((sscanf(ident, "%d", &memdev_id) == 1
-			|| sscanf(ident, "mem%d", &memdev_id) == 1)
-			&& cxl_memdev_get_id(memdev) == memdev_id)
-		return memdev;
-
-	return NULL;
-}
-
 enum ndctl_namespace_mode util_nsmode(const char *mode)
 {
 	if (!mode)
diff --git a/util/filter.h b/ndctl/filter.h
similarity index 89%
rename from util/filter.h
rename to ndctl/filter.h
index 9a80d65e8b23..9800cc230865 100644
--- a/util/filter.h
+++ b/ndctl/filter.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (C) 2015-2020 Intel Corporation. All rights reserved. */
-#ifndef _UTIL_FILTER_H_
-#define _UTIL_FILTER_H_
+#ifndef _NDCTL_UTIL_FILTER_H_
+#define _NDCTL_UTIL_FILTER_H_
 #include <stdbool.h>
 #include <ccan/list/list.h>
 
@@ -25,12 +25,6 @@ struct ndctl_dimm *util_dimm_filter_by_namespace(struct ndctl_dimm *dimm,
 		const char *ident);
 struct ndctl_region *util_region_filter_by_namespace(struct ndctl_region *region,
 		const char *ident);
-struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev,
-		const char *ident);
-struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,
-		const char *ident);
-struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
-		const char *ident);
 
 enum ndctl_namespace_mode util_nsmode(const char *mode);
 const char *util_nsmode_name(enum ndctl_namespace_mode mode);
@@ -89,4 +83,4 @@ struct util_filter_params {
 struct ndctl_ctx;
 int util_filter_walk(struct ndctl_ctx *ctx, struct util_filter_ctx *fctx,
 		struct util_filter_params *param);
-#endif
+#endif /* _NDCTL_UTIL_FILTER_H_ */
diff --git a/ndctl/inject-error.c b/ndctl/inject-error.c
index 05c1a22fc36c..f595cec0033d 100644
--- a/ndctl/inject-error.c
+++ b/ndctl/inject-error.c
@@ -12,12 +12,11 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
-#include <ndctl.h>
 #include <util/log.h>
 #include <util/size.h>
 #include <util/json.h>
 #include <json-c/json.h>
-#include <util/filter.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
@@ -26,6 +25,9 @@
 #include <builtin.h>
 #include <test.h>
 
+#include "filter.h"
+#include "json.h"
+
 static bool verbose;
 static struct parameters {
 	const char *bus;
diff --git a/ndctl/inject-smart.c b/ndctl/inject-smart.c
index 9077bca256e4..2b9d7e85241c 100644
--- a/ndctl/inject-smart.c
+++ b/ndctl/inject-smart.c
@@ -13,12 +13,11 @@
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
-#include <ndctl.h>
 #include <util/log.h>
 #include <util/size.h>
 #include <util/json.h>
 #include <json-c/json.h>
-#include <util/filter.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
@@ -27,6 +26,9 @@
 #include <builtin.h>
 #include <test.h>
 
+#include "filter.h"
+#include "json.h"
+
 static struct parameters {
 	const char *bus;
 	const char *dimm;
diff --git a/ndctl/util/json-smart.c b/ndctl/json-smart.c
similarity index 99%
rename from ndctl/util/json-smart.c
rename to ndctl/json-smart.c
index e598e04420cd..400f60b0a710 100644
--- a/ndctl/util/json-smart.c
+++ b/ndctl/json-smart.c
@@ -1,12 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
 #include <limits.h>
-#include <util/json.h>
 #include <uuid/uuid.h>
 #include <json-c/json.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <ccan/array_size/array_size.h>
-#include <ndctl.h>
+
+#include "json.h"
 
 static void smart_threshold_to_json(struct ndctl_dimm *dimm,
 		struct json_object *jhealth)
diff --git a/ndctl/json.c b/ndctl/json.c
new file mode 100644
index 000000000000..c62e6cae01a9
--- /dev/null
+++ b/ndctl/json.c
@@ -0,0 +1,1114 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
+#include <limits.h>
+#include <string.h>
+#include <util/json.h>
+#include <uuid/uuid.h>
+#include <json-c/json.h>
+#include <ndctl/libndctl.h>
+#include <json-c/printbuf.h>
+
+#include "json.h"
+#include "ndctl.h"
+#include "../daxctl/json.h"
+
+struct json_object *util_bus_to_json(struct ndctl_bus *bus, unsigned long flags)
+{
+	struct json_object *jbus = json_object_new_object();
+	struct json_object *jobj, *fw_obj = NULL;
+	int scrub;
+
+	if (!jbus)
+		return NULL;
+
+	jobj = json_object_new_string(ndctl_bus_get_provider(bus));
+	if (!jobj)
+		goto err;
+	json_object_object_add(jbus, "provider", jobj);
+
+	jobj = json_object_new_string(ndctl_bus_get_devname(bus));
+	if (!jobj)
+		goto err;
+	json_object_object_add(jbus, "dev", jobj);
+
+	scrub = ndctl_bus_get_scrub_state(bus);
+	if (scrub < 0)
+		return jbus;
+
+	jobj = json_object_new_string(scrub ? "active" : "idle");
+	if (!jobj)
+		goto err;
+	json_object_object_add(jbus, "scrub_state", jobj);
+
+	if (flags & UTIL_JSON_FIRMWARE) {
+		struct ndctl_dimm *dimm;
+
+		/*
+		 * Skip displaying firmware activation capability if no
+		 * DIMMs support firmware update.
+		 */
+		ndctl_dimm_foreach(bus, dimm)
+			if (ndctl_dimm_fw_update_supported(dimm) == 0) {
+				fw_obj = json_object_new_object();
+				break;
+			}
+	}
+
+	if (fw_obj) {
+		enum ndctl_fwa_state state;
+		enum ndctl_fwa_method method;
+
+		jobj = NULL;
+		method = ndctl_bus_get_fw_activate_method(bus);
+		if (method == NDCTL_FWA_METHOD_RESET)
+			jobj = json_object_new_string("reset");
+		if (method == NDCTL_FWA_METHOD_SUSPEND)
+			jobj = json_object_new_string("suspend");
+		if (method == NDCTL_FWA_METHOD_LIVE)
+			jobj = json_object_new_string("live");
+		if (jobj)
+			json_object_object_add(fw_obj, "activate_method", jobj);
+
+		jobj = NULL;
+		state = ndctl_bus_get_fw_activate_state(bus);
+		if (state == NDCTL_FWA_ARMED)
+			jobj = json_object_new_string("armed");
+		if (state == NDCTL_FWA_IDLE)
+			jobj = json_object_new_string("idle");
+		if (state == NDCTL_FWA_ARM_OVERFLOW)
+			jobj = json_object_new_string("overflow");
+		if (jobj)
+			json_object_object_add(fw_obj, "activate_state", jobj);
+
+		json_object_object_add(jbus, "firmware", fw_obj);
+	}
+
+	return jbus;
+ err:
+	json_object_put(jbus);
+	return NULL;
+}
+
+
+
+struct json_object *util_dimm_firmware_to_json(struct ndctl_dimm *dimm,
+		unsigned long flags)
+{
+	struct json_object *jfirmware = json_object_new_object();
+	bool can_update, need_powercycle;
+	enum ndctl_fwa_result result;
+	enum ndctl_fwa_state state;
+	struct json_object *jobj;
+	struct ndctl_cmd *cmd;
+	uint64_t run, next;
+	int rc;
+
+	if (!jfirmware)
+		return NULL;
+
+	cmd = ndctl_dimm_cmd_new_fw_get_info(dimm);
+	if (!cmd)
+		goto err;
+
+	rc = ndctl_cmd_submit(cmd);
+	if ((rc < 0) || ndctl_cmd_fw_xlat_firmware_status(cmd) != FW_SUCCESS) {
+		jobj = util_json_object_hex(-1, flags);
+		if (jobj)
+			json_object_object_add(jfirmware, "current_version",
+					jobj);
+		goto out;
+	}
+
+	run = ndctl_cmd_fw_info_get_run_version(cmd);
+	if (run == ULLONG_MAX) {
+		jobj = util_json_object_hex(-1, flags);
+		if (jobj)
+			json_object_object_add(jfirmware, "current_version",
+					jobj);
+		goto out;
+	}
+
+	jobj = util_json_object_hex(run, flags);
+	if (jobj)
+		json_object_object_add(jfirmware, "current_version", jobj);
+
+	rc = ndctl_dimm_fw_update_supported(dimm);
+	can_update = rc == 0;
+	jobj = json_object_new_boolean(can_update);
+	if (jobj)
+		json_object_object_add(jfirmware, "can_update", jobj);
+
+
+	next = ndctl_cmd_fw_info_get_updated_version(cmd);
+	if (next == ULLONG_MAX) {
+		jobj = util_json_object_hex(-1, flags);
+		if (jobj)
+			json_object_object_add(jfirmware, "next_version",
+					jobj);
+		goto out;
+	}
+
+	if (!next)
+		goto out;
+
+	jobj = util_json_object_hex(next, flags);
+	if (jobj)
+		json_object_object_add(jfirmware,
+				"next_version", jobj);
+
+	state = ndctl_dimm_get_fw_activate_state(dimm);
+	switch (state) {
+	case NDCTL_FWA_IDLE:
+		jobj = json_object_new_string("idle");
+		break;
+	case NDCTL_FWA_ARMED:
+		jobj = json_object_new_string("armed");
+		break;
+	case NDCTL_FWA_BUSY:
+		jobj = json_object_new_string("busy");
+		break;
+	default:
+		jobj = NULL;
+		break;
+	}
+	if (jobj)
+		json_object_object_add(jfirmware, "activate_state", jobj);
+
+	result = ndctl_dimm_get_fw_activate_result(dimm);
+	switch (result) {
+	case NDCTL_FWA_RESULT_NONE:
+	case NDCTL_FWA_RESULT_SUCCESS:
+	case NDCTL_FWA_RESULT_NOTSTAGED:
+		/*
+		 * If a 'next' firmware version is staged then this
+		 * result is stale, if the activation succeeds that is
+		 * indicated by not finding a 'next' entry.
+		 */
+		need_powercycle = false;
+		break;
+	case NDCTL_FWA_RESULT_NEEDRESET:
+	case NDCTL_FWA_RESULT_FAIL:
+	default:
+		/*
+		 * If the last activation failed, or if the activation
+		 * result is unavailable it is always the case that the
+		 * only remediation is powercycle.
+		 */
+		need_powercycle = true;
+		break;
+	}
+
+	if (need_powercycle) {
+		jobj = json_object_new_boolean(true);
+		if (!jobj)
+			goto out;
+		json_object_object_add(jfirmware, "need_powercycle", jobj);
+	}
+
+	ndctl_cmd_unref(cmd);
+	return jfirmware;
+
+err:
+	json_object_put(jfirmware);
+	jfirmware = NULL;
+out:
+	if (cmd)
+		ndctl_cmd_unref(cmd);
+	return jfirmware;
+}
+
+
+
+struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm,
+		unsigned long flags)
+{
+	struct json_object *jdimm = json_object_new_object();
+	const char *id = ndctl_dimm_get_unique_id(dimm);
+	unsigned int handle = ndctl_dimm_get_handle(dimm);
+	unsigned short phys_id = ndctl_dimm_get_phys_id(dimm);
+	struct json_object *jobj;
+	enum ndctl_security_state sstate;
+
+	if (!jdimm)
+		return NULL;
+
+	jobj = json_object_new_string(ndctl_dimm_get_devname(dimm));
+	if (!jobj)
+		goto err;
+	json_object_object_add(jdimm, "dev", jobj);
+
+	if (id) {
+		jobj = json_object_new_string(id);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "id", jobj);
+	}
+
+	if (handle < UINT_MAX) {
+		jobj = util_json_object_hex(handle, flags);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "handle", jobj);
+	}
+
+	if (phys_id < USHRT_MAX) {
+		jobj = util_json_object_hex(phys_id, flags);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "phys_id", jobj);
+	}
+
+	if (!ndctl_dimm_is_enabled(dimm)) {
+		jobj = json_object_new_string("disabled");
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "state", jobj);
+	}
+
+	if (ndctl_dimm_failed_map(dimm)) {
+		jobj = json_object_new_boolean(true);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "flag_failed_map", jobj);
+	}
+
+	if (ndctl_dimm_failed_save(dimm)) {
+		jobj = json_object_new_boolean(true);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "flag_failed_save", jobj);
+	}
+
+	if (ndctl_dimm_failed_arm(dimm)) {
+		jobj = json_object_new_boolean(true);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "flag_failed_arm", jobj);
+	}
+
+	if (ndctl_dimm_failed_restore(dimm)) {
+		jobj = json_object_new_boolean(true);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "flag_failed_restore", jobj);
+	}
+
+	if (ndctl_dimm_failed_flush(dimm)) {
+		jobj = json_object_new_boolean(true);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "flag_failed_flush", jobj);
+	}
+
+	if (ndctl_dimm_smart_pending(dimm)) {
+		jobj = json_object_new_boolean(true);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jdimm, "flag_smart_event", jobj);
+	}
+
+	sstate = ndctl_dimm_get_security(dimm);
+	if (sstate == NDCTL_SECURITY_DISABLED)
+		jobj = json_object_new_string("disabled");
+	else if (sstate == NDCTL_SECURITY_UNLOCKED)
+		jobj = json_object_new_string("unlocked");
+	else if (sstate == NDCTL_SECURITY_LOCKED)
+		jobj = json_object_new_string("locked");
+	else if (sstate == NDCTL_SECURITY_FROZEN)
+		jobj = json_object_new_string("frozen");
+	else if (sstate == NDCTL_SECURITY_OVERWRITE)
+		jobj = json_object_new_string("overwrite");
+	else
+		jobj = NULL;
+	if (jobj)
+		json_object_object_add(jdimm, "security", jobj);
+
+	if (ndctl_dimm_security_is_frozen(dimm)) {
+		jobj = json_object_new_boolean(true);
+		if (jobj)
+			json_object_object_add(jdimm, "security_frozen", jobj);
+	}
+
+	if (flags & UTIL_JSON_FIRMWARE) {
+		struct json_object *jfirmware;
+
+		jfirmware = util_dimm_firmware_to_json(dimm, flags);
+		if (jfirmware)
+			json_object_object_add(jdimm, "firmware", jfirmware);
+	}
+
+	return jdimm;
+ err:
+	json_object_put(jdimm);
+	return NULL;
+}
+
+#define _SZ(get_max, get_elem, type) \
+static struct json_object *util_##type##_build_size_array(struct ndctl_##type *arg)	\
+{								\
+	struct json_object *arr = json_object_new_array();	\
+	int i;							\
+								\
+	if (!arr)						\
+		return NULL;					\
+								\
+	for (i = 0; i < get_max(arg); i++) {			\
+		struct json_object *jobj;			\
+		int64_t align;					\
+								\
+		align = get_elem(arg, i);			\
+		jobj = json_object_new_int64(align);		\
+		if (!jobj)					\
+			goto err;				\
+		json_object_array_add(arr, jobj);		\
+	}							\
+								\
+	return arr;						\
+err:								\
+	json_object_put(arr);					\
+	return NULL;						\
+}
+#define SZ(type, kind) _SZ(ndctl_##type##_get_num_##kind##s, \
+			   ndctl_##type##_get_supported_##kind, type)
+SZ(pfn, alignment)
+SZ(dax, alignment)
+SZ(btt, sector_size)
+
+struct json_object *util_region_capabilities_to_json(struct ndctl_region *region)
+{
+	struct json_object *jcaps, *jcap, *jobj;
+	struct ndctl_btt *btt = ndctl_region_get_btt_seed(region);
+	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
+	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
+
+	if (!btt || !pfn || !dax)
+		return NULL;
+
+	jcaps = json_object_new_array();
+	if (!jcaps)
+		return NULL;
+
+	if (btt) {
+		jcap = json_object_new_object();
+		if (!jcap)
+			goto err;
+		json_object_array_add(jcaps, jcap);
+
+		jobj = json_object_new_string("sector");
+		if (!jobj)
+			goto err;
+		json_object_object_add(jcap, "mode", jobj);
+		jobj = util_btt_build_size_array(btt);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jcap, "sector_sizes", jobj);
+	}
+
+	if (pfn) {
+		jcap = json_object_new_object();
+		if (!jcap)
+			goto err;
+		json_object_array_add(jcaps, jcap);
+
+		jobj = json_object_new_string("fsdax");
+		if (!jobj)
+			goto err;
+		json_object_object_add(jcap, "mode", jobj);
+		jobj = util_pfn_build_size_array(pfn);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jcap, "alignments", jobj);
+	}
+
+	if (dax) {
+		jcap = json_object_new_object();
+		if (!jcap)
+			goto err;
+		json_object_array_add(jcaps, jcap);
+
+		jobj = json_object_new_string("devdax");
+		if (!jobj)
+			goto err;
+		json_object_object_add(jcap, "mode", jobj);
+		jobj = util_dax_build_size_array(dax);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jcap, "alignments", jobj);
+	}
+
+	return jcaps;
+err:
+	json_object_put(jcaps);
+	return NULL;
+}
+
+
+static int compare_dimm_number(const void *p1, const void *p2)
+{
+	struct ndctl_dimm *dimm1 = *(struct ndctl_dimm **)p1;
+	struct ndctl_dimm *dimm2 = *(struct ndctl_dimm **)p2;
+	const char *dimm1_name = ndctl_dimm_get_devname(dimm1);
+	const char *dimm2_name = ndctl_dimm_get_devname(dimm2);
+	int num1, num2;
+
+	if (sscanf(dimm1_name, "nmem%d", &num1) != 1)
+		num1 = 0;
+	if (sscanf(dimm2_name, "nmem%d", &num2) != 1)
+		num2 = 0;
+
+	return num1 - num2;
+}
+
+static struct json_object *badblocks_to_jdimms(struct ndctl_region *region,
+		unsigned long long addr, unsigned long len)
+{
+	struct ndctl_bus *bus = ndctl_region_get_bus(region);
+	int count = ndctl_region_get_interleave_ways(region);
+	unsigned long long end = addr + len;
+	struct json_object *jdimms, *jobj;
+	struct ndctl_dimm **dimms, *dimm;
+	int found, i;
+
+	jdimms = json_object_new_array();
+	if (!jdimms)
+		return NULL;
+
+	dimms = calloc(count, sizeof(struct ndctl_dimm *));
+	if (!dimms)
+		goto err_dimms;
+
+	for (found = 0; found < count && addr < end; addr += 512) {
+		dimm = ndctl_bus_get_dimm_by_physical_address(bus, addr);
+		if (!dimm)
+			continue;
+
+		for (i = 0; i < count; i++)
+			if (dimms[i] == dimm)
+				break;
+		if (i >= count)
+			dimms[found++] = dimm;
+	}
+
+	if (!found)
+		goto err_found;
+
+	qsort(dimms, found, sizeof(dimm), compare_dimm_number);
+
+	for (i = 0; i < found; i++) {
+		const char *devname = ndctl_dimm_get_devname(dimms[i]);
+
+		jobj = json_object_new_string(devname);
+		if (!jobj)
+			break;
+		json_object_array_add(jdimms, jobj);
+	}
+
+	if (!i)
+		goto err_found;
+	free(dimms);
+	return jdimms;
+
+err_found:
+	free(dimms);
+err_dimms:
+	json_object_put(jdimms);
+	return NULL;
+}
+
+struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
+		unsigned int *bb_count, unsigned long flags)
+{
+	struct json_object *jbb = NULL, *jbbs = NULL, *jobj;
+	struct badblock *bb;
+	int bbs = 0;
+
+	if (flags & UTIL_JSON_MEDIA_ERRORS) {
+		jbbs = json_object_new_array();
+		if (!jbbs)
+			return NULL;
+	}
+
+	ndctl_region_badblock_foreach(region, bb) {
+		struct json_object *jdimms;
+		unsigned long long addr;
+
+		bbs += bb->len;
+
+		/* recheck so we can still get the badblocks_count from above */
+		if (!(flags & UTIL_JSON_MEDIA_ERRORS))
+			continue;
+
+		/* get start address of region */
+		addr = ndctl_region_get_resource(region);
+		if (addr == ULLONG_MAX)
+			goto err_array;
+
+		/* get address of bad block */
+		addr += bb->offset << 9;
+
+		jbb = json_object_new_object();
+		if (!jbb)
+			goto err_array;
+
+		jobj = json_object_new_int64(bb->offset);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jbb, "offset", jobj);
+
+		jobj = json_object_new_int(bb->len);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jbb, "length", jobj);
+
+		jdimms = badblocks_to_jdimms(region, addr, bb->len << 9);
+		if (jdimms)
+			json_object_object_add(jbb, "dimms", jdimms);
+		json_object_array_add(jbbs, jbb);
+	}
+
+	*bb_count = bbs;
+
+	if (bbs)
+		return jbbs;
+
+ err:
+	json_object_put(jbb);
+ err_array:
+	json_object_put(jbbs);
+	return NULL;
+}
+
+static struct json_object *util_namespace_badblocks_to_json(
+			struct ndctl_namespace *ndns,
+			unsigned int *bb_count, unsigned long flags)
+{
+	struct json_object *jbb = NULL, *jbbs = NULL, *jobj;
+	struct badblock *bb;
+	int bbs = 0;
+
+	if (flags & UTIL_JSON_MEDIA_ERRORS) {
+		jbbs = json_object_new_array();
+		if (!jbbs)
+			return NULL;
+	} else
+		return NULL;
+
+	ndctl_namespace_badblock_foreach(ndns, bb) {
+		bbs += bb->len;
+
+		/* recheck so we can still get the badblocks_count from above */
+		if (!(flags & UTIL_JSON_MEDIA_ERRORS))
+			continue;
+
+		jbb = json_object_new_object();
+		if (!jbb)
+			goto err_array;
+
+		jobj = json_object_new_int64(bb->offset);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jbb, "offset", jobj);
+
+		jobj = json_object_new_int(bb->len);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jbb, "length", jobj);
+		json_object_array_add(jbbs, jbb);
+	}
+
+	*bb_count = bbs;
+
+	if (bbs)
+		return jbbs;
+
+ err:
+	json_object_put(jbb);
+ err_array:
+	json_object_put(jbbs);
+	return NULL;
+}
+
+static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
+		unsigned long long dev_begin, unsigned long long dev_size,
+		unsigned int *bb_count, unsigned long flags)
+{
+	struct json_object *jbb = NULL, *jbbs = NULL, *jobj;
+	unsigned long long region_begin, dev_end, offset;
+	unsigned int len, bbs = 0;
+	struct badblock *bb;
+
+	region_begin = ndctl_region_get_resource(region);
+	if (region_begin == ULLONG_MAX)
+		return NULL;
+
+	dev_end = dev_begin + dev_size - 1;
+
+	if (flags & UTIL_JSON_MEDIA_ERRORS) {
+		jbbs = json_object_new_array();
+		if (!jbbs)
+			return NULL;
+	}
+
+	ndctl_region_badblock_foreach(region, bb) {
+		unsigned long long bb_begin, bb_end, begin, end;
+		struct json_object *jdimms;
+
+		bb_begin = region_begin + (bb->offset << 9);
+		bb_end = bb_begin + (bb->len << 9) - 1;
+
+		if (bb_end <= dev_begin || bb_begin >= dev_end)
+			continue;
+
+		if (bb_begin < dev_begin)
+			begin = dev_begin;
+		else
+			begin = bb_begin;
+
+		if (bb_end > dev_end)
+			end = dev_end;
+		else
+			end = bb_end;
+
+		offset = (begin - dev_begin) >> 9;
+		len = (end - begin + 1) >> 9;
+
+		bbs += len;
+
+		/* recheck so we can still get the badblocks_count from above */
+		if (!(flags & UTIL_JSON_MEDIA_ERRORS))
+			continue;
+
+		jbb = json_object_new_object();
+		if (!jbb)
+			goto err_array;
+
+		jobj = json_object_new_int64(offset);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jbb, "offset", jobj);
+
+		jobj = json_object_new_int(len);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jbb, "length", jobj);
+
+		jdimms = badblocks_to_jdimms(region, begin, len << 9);
+		if (jdimms)
+			json_object_object_add(jbb, "dimms", jdimms);
+
+		json_object_array_add(jbbs, jbb);
+	}
+
+	*bb_count = bbs;
+
+	if (bbs)
+		return jbbs;
+
+ err:
+	json_object_put(jbb);
+ err_array:
+	json_object_put(jbbs);
+	return NULL;
+}
+
+static struct json_object *util_pfn_badblocks_to_json(struct ndctl_pfn *pfn,
+		unsigned int *bb_count, unsigned long flags)
+{
+	struct ndctl_region *region = ndctl_pfn_get_region(pfn);
+	unsigned long long pfn_begin, pfn_size;
+
+	pfn_begin = ndctl_pfn_get_resource(pfn);
+	if (pfn_begin == ULLONG_MAX) {
+		struct ndctl_namespace *ndns = ndctl_pfn_get_namespace(pfn);
+
+		return util_namespace_badblocks_to_json(ndns, bb_count, flags);
+	}
+
+	pfn_size = ndctl_pfn_get_size(pfn);
+	if (pfn_size == ULLONG_MAX)
+		return NULL;
+
+	return dev_badblocks_to_json(region, pfn_begin, pfn_size,
+			bb_count, flags);
+}
+
+static void util_btt_badblocks_to_json(struct ndctl_btt *btt,
+		unsigned int *bb_count)
+{
+	struct ndctl_region *region = ndctl_btt_get_region(btt);
+	struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt);
+	unsigned long long begin, size;
+
+	if (!ndns)
+		return;
+
+	begin = ndctl_namespace_get_resource(ndns);
+	if (begin == ULLONG_MAX)
+		return;
+
+	size = ndctl_namespace_get_size(ndns);
+	if (size == ULLONG_MAX)
+		return;
+
+	/*
+	 * The dev_badblocks_to_json() for BTT is not accurate with
+	 * respect to data vs metadata badblocks, and is only useful for
+	 * a potential bb_count.
+	 *
+	 * FIXME: switch to native BTT badblocks representation
+	 * when / if the kernel provides it.
+	 */
+	dev_badblocks_to_json(region, begin, size, bb_count, 0);
+}
+static struct json_object *util_dax_badblocks_to_json(struct ndctl_dax *dax,
+		unsigned int *bb_count, unsigned long flags)
+{
+	struct ndctl_region *region = ndctl_dax_get_region(dax);
+	unsigned long long dax_begin, dax_size;
+
+	dax_begin = ndctl_dax_get_resource(dax);
+	if (dax_begin == ULLONG_MAX)
+		return NULL;
+
+	dax_size = ndctl_dax_get_size(dax);
+	if (dax_size == ULLONG_MAX)
+		return NULL;
+
+	return dev_badblocks_to_json(region, dax_begin, dax_size,
+			bb_count, flags);
+}
+
+static struct json_object *util_raw_uuid(struct ndctl_namespace *ndns)
+{
+	char buf[40];
+	uuid_t raw_uuid;
+
+	ndctl_namespace_get_uuid(ndns, raw_uuid);
+	if (uuid_is_null(raw_uuid))
+		return NULL;
+	uuid_unparse(raw_uuid, buf);
+	return json_object_new_string(buf);
+}
+
+static void util_raw_uuid_to_json(struct ndctl_namespace *ndns,
+				  unsigned long flags,
+				  struct json_object *jndns)
+{
+	struct json_object *jobj;
+
+	if (!(flags & UTIL_JSON_VERBOSE))
+		return;
+
+	jobj = util_raw_uuid(ndns);
+	if (!jobj)
+		return;
+	json_object_object_add(jndns, "raw_uuid", jobj);
+}
+
+struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
+		unsigned long flags)
+{
+	struct json_object *jndns = json_object_new_object();
+	enum ndctl_pfn_loc loc = NDCTL_PFN_LOC_NONE;
+	struct json_object *jobj, *jbbs = NULL;
+	const char *locations[] = {
+		[NDCTL_PFN_LOC_NONE] = "none",
+		[NDCTL_PFN_LOC_RAM] = "mem",
+		[NDCTL_PFN_LOC_PMEM] = "dev",
+	};
+	unsigned long long size = ULLONG_MAX;
+	unsigned int sector_size = UINT_MAX;
+	enum ndctl_namespace_mode mode;
+	const char *bdev = NULL, *name;
+	unsigned int bb_count = 0;
+	struct ndctl_btt *btt;
+	struct ndctl_pfn *pfn;
+	struct ndctl_dax *dax;
+	unsigned long align = 0;
+	char buf[40];
+	uuid_t uuid;
+	int numa, target;
+
+	if (!jndns)
+		return NULL;
+
+	jobj = json_object_new_string(ndctl_namespace_get_devname(ndns));
+	if (!jobj)
+		goto err;
+	json_object_object_add(jndns, "dev", jobj);
+
+	btt = ndctl_namespace_get_btt(ndns);
+	dax = ndctl_namespace_get_dax(ndns);
+	pfn = ndctl_namespace_get_pfn(ndns);
+	mode = ndctl_namespace_get_mode(ndns);
+	switch (mode) {
+	case NDCTL_NS_MODE_MEMORY:
+		if (pfn) { /* dynamic memory mode */
+			size = ndctl_pfn_get_size(pfn);
+			loc = ndctl_pfn_get_location(pfn);
+		} else { /* native/static memory mode */
+			size = ndctl_namespace_get_size(ndns);
+			loc = NDCTL_PFN_LOC_RAM;
+		}
+		jobj = json_object_new_string("fsdax");
+		break;
+	case NDCTL_NS_MODE_DAX:
+		if (!dax)
+			goto err;
+		size = ndctl_dax_get_size(dax);
+		jobj = json_object_new_string("devdax");
+		loc = ndctl_dax_get_location(dax);
+		break;
+	case NDCTL_NS_MODE_SECTOR:
+		if (!btt)
+			goto err;
+		jobj = json_object_new_string("sector");
+		size = ndctl_btt_get_size(btt);
+		break;
+	case NDCTL_NS_MODE_RAW:
+		size = ndctl_namespace_get_size(ndns);
+		jobj = json_object_new_string("raw");
+		break;
+	default:
+		jobj = NULL;
+	}
+	if (jobj)
+		json_object_object_add(jndns, "mode", jobj);
+
+	if ((mode != NDCTL_NS_MODE_SECTOR) && (mode != NDCTL_NS_MODE_RAW)) {
+		jobj = json_object_new_string(locations[loc]);
+		if (jobj)
+			json_object_object_add(jndns, "map", jobj);
+	}
+
+	if (size < ULLONG_MAX) {
+		jobj = util_json_object_size(size, flags);
+		if (jobj)
+			json_object_object_add(jndns, "size", jobj);
+	}
+
+	if (btt) {
+		ndctl_btt_get_uuid(btt, uuid);
+		uuid_unparse(uuid, buf);
+		jobj = json_object_new_string(buf);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "uuid", jobj);
+		util_raw_uuid_to_json(ndns, flags, jndns);
+		bdev = ndctl_btt_get_block_device(btt);
+	} else if (pfn) {
+		align = ndctl_pfn_get_align(pfn);
+		ndctl_pfn_get_uuid(pfn, uuid);
+		uuid_unparse(uuid, buf);
+		jobj = json_object_new_string(buf);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "uuid", jobj);
+		util_raw_uuid_to_json(ndns, flags, jndns);
+		bdev = ndctl_pfn_get_block_device(pfn);
+	} else if (dax) {
+		struct daxctl_region *dax_region;
+
+		dax_region = ndctl_dax_get_daxctl_region(dax);
+		align = ndctl_dax_get_align(dax);
+		ndctl_dax_get_uuid(dax, uuid);
+		uuid_unparse(uuid, buf);
+		jobj = json_object_new_string(buf);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "uuid", jobj);
+		util_raw_uuid_to_json(ndns, flags, jndns);
+		if ((flags & UTIL_JSON_DAX) && dax_region) {
+			jobj = util_daxctl_region_to_json(dax_region, NULL,
+					flags);
+			if (jobj)
+				json_object_object_add(jndns, "daxregion", jobj);
+		} else if (dax_region) {
+			struct daxctl_dev *dev;
+
+			/*
+			 * We can only find/list these device-dax
+			 * details when the instance is enabled.
+			 */
+			dev = daxctl_dev_get_first(dax_region);
+			if (dev) {
+				name = daxctl_dev_get_devname(dev);
+				jobj = json_object_new_string(name);
+				if (!jobj)
+					goto err;
+				json_object_object_add(jndns, "chardev", jobj);
+			}
+		}
+	} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
+		ndctl_namespace_get_uuid(ndns, uuid);
+		uuid_unparse(uuid, buf);
+		jobj = json_object_new_string(buf);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "uuid", jobj);
+		bdev = ndctl_namespace_get_block_device(ndns);
+	} else
+		bdev = ndctl_namespace_get_block_device(ndns);
+
+	if (btt)
+		sector_size = ndctl_btt_get_sector_size(btt);
+	else if (!dax) {
+		sector_size = ndctl_namespace_get_sector_size(ndns);
+		if (!sector_size || sector_size == UINT_MAX)
+			sector_size = 512;
+	}
+
+	/*
+	 * The kernel will default to a 512 byte sector size on PMEM
+	 * namespaces that don't explicitly have a sector size. This
+	 * happens because they use pre-v1.2 labels or because they
+	 * don't have a label space (devtype=nd_namespace_io).
+	 */
+	if (sector_size < UINT_MAX) {
+		jobj = json_object_new_int(sector_size);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "sector_size", jobj);
+	}
+
+	if (align) {
+		jobj = json_object_new_int64(align);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "align", jobj);
+	}
+
+	if (bdev && bdev[0]) {
+		jobj = json_object_new_string(bdev);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "blockdev", jobj);
+	}
+
+	if (!ndctl_namespace_is_active(ndns)) {
+		jobj = json_object_new_string("disabled");
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "state", jobj);
+	}
+
+	name = ndctl_namespace_get_alt_name(ndns);
+	if (name && name[0]) {
+		jobj = json_object_new_string(name);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jndns, "name", jobj);
+	}
+
+	numa = ndctl_namespace_get_numa_node(ndns);
+	if (numa >= 0 && flags & UTIL_JSON_VERBOSE) {
+		jobj = json_object_new_int(numa);
+		if (jobj)
+			json_object_object_add(jndns, "numa_node", jobj);
+	}
+
+	target = ndctl_namespace_get_target_node(ndns);
+	if (target >= 0 && flags & UTIL_JSON_VERBOSE) {
+		jobj = json_object_new_int(target);
+		if (jobj)
+			json_object_object_add(jndns, "target_node", jobj);
+	}
+
+	if (pfn)
+		jbbs = util_pfn_badblocks_to_json(pfn, &bb_count, flags);
+	else if (dax)
+		jbbs = util_dax_badblocks_to_json(dax, &bb_count, flags);
+	else if (btt)
+		util_btt_badblocks_to_json(btt, &bb_count);
+	else {
+		jbbs = util_region_badblocks_to_json(
+				ndctl_namespace_get_region(ndns), &bb_count,
+				flags);
+		if (!jbbs)
+			jbbs = util_namespace_badblocks_to_json(ndns, &bb_count,
+					flags);
+	}
+
+	if (bb_count) {
+		jobj = json_object_new_int(bb_count);
+		if (!jobj) {
+			json_object_put(jbbs);
+			goto err;
+		}
+		json_object_object_add(jndns, "badblock_count", jobj);
+	}
+
+	if ((flags & UTIL_JSON_MEDIA_ERRORS) && jbbs)
+		json_object_object_add(jndns, "badblocks", jbbs);
+
+	return jndns;
+ err:
+	json_object_put(jndns);
+	return NULL;
+}
+
+
+struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping,
+		unsigned long flags)
+{
+	struct json_object *jmapping = json_object_new_object();
+	struct ndctl_dimm *dimm = ndctl_mapping_get_dimm(mapping);
+	struct json_object *jobj;
+	int position;
+
+	if (!jmapping)
+		return NULL;
+
+	jobj = json_object_new_string(ndctl_dimm_get_devname(dimm));
+	if (!jobj)
+		goto err;
+	json_object_object_add(jmapping, "dimm", jobj);
+
+	jobj = util_json_object_hex(ndctl_mapping_get_offset(mapping), flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jmapping, "offset", jobj);
+
+	jobj = util_json_object_hex(ndctl_mapping_get_length(mapping), flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jmapping, "length", jobj);
+
+	position = ndctl_mapping_get_position(mapping);
+	if (position >= 0) {
+		jobj = json_object_new_int(position);
+		if (!jobj)
+			goto err;
+		json_object_object_add(jmapping, "position", jobj);
+	}
+
+	return jmapping;
+ err:
+	json_object_put(jmapping);
+	return NULL;
+}
+
+struct json_object *util_badblock_rec_to_json(u64 block, u64 count,
+		unsigned long flags)
+{
+	struct json_object *jerr = json_object_new_object();
+	struct json_object *jobj;
+
+	if (!jerr)
+		return NULL;
+
+	jobj = util_json_object_hex(block, flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jerr, "block", jobj);
+
+	jobj = util_json_object_hex(count, flags);
+	if (!jobj)
+		goto err;
+	json_object_object_add(jerr, "count", jobj);
+
+	return jerr;
+ err:
+	json_object_put(jerr);
+	return NULL;
+}
diff --git a/ndctl/json.h b/ndctl/json.h
new file mode 100644
index 000000000000..f544b659ca1d
--- /dev/null
+++ b/ndctl/json.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2015-2020 Intel Corporation. All rights reserved. */
+#ifndef __NDCTL_UTIL_JSON_H__
+#define __NDCTL_UTIL_JSON_H__
+#include <ndctl/libndctl.h>
+#include <ccan/short_types/short_types.h>
+
+struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
+		unsigned long flags);
+struct json_object *util_badblock_rec_to_json(u64 block, u64 count,
+		unsigned long flags);
+struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
+		unsigned int *bb_count, unsigned long flags);
+struct json_object *util_bus_to_json(struct ndctl_bus *bus,
+		unsigned long flags);
+struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm,
+		unsigned long flags);
+struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping,
+		unsigned long flags);
+struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);
+struct json_object *util_dimm_firmware_to_json(struct ndctl_dimm *dimm,
+		unsigned long flags);
+struct json_object *util_region_capabilities_to_json(struct ndctl_region *region);
+#endif /* __NDCTL_UTIL_JSON_H__ */
diff --git a/ndctl/util/keys.c b/ndctl/keys.c
similarity index 99%
rename from ndctl/util/keys.c
rename to ndctl/keys.c
index 30cb4c884b98..876b34714b7e 100644
--- a/ndctl/util/keys.c
+++ b/ndctl/keys.c
@@ -13,10 +13,11 @@
 #include <keyutils.h>
 #include <syslog.h>
 
-#include <ndctl.h>
 #include <ndctl/config.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
-#include <util/keys.h>
+
+#include "keys.h"
 
 static int get_key_path(struct ndctl_dimm *dimm, char *path,
 		enum ndctl_key_type key_type)
diff --git a/ndctl/util/keys.h b/ndctl/keys.h
similarity index 100%
rename from ndctl/util/keys.h
rename to ndctl/keys.h
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index b4939138ed47..47a234ccc8ce 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -20,10 +20,10 @@
 #include <ccan/array_size/array_size.h>
 #include <ccan/build_assert/build_assert.h>
 
-#include <ndctl.h>
 #include <util/util.h>
 #include <util/size.h>
 #include <util/sysfs.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <ndctl/namespace.h>
 #include <daxctl/libdaxctl.h>
diff --git a/ndctl/lib/papr.c b/ndctl/lib/papr.c
index 9c6f2f045fc2..43b8412b2073 100644
--- a/ndctl/lib/papr.c
+++ b/ndctl/lib/papr.c
@@ -10,9 +10,9 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <util/log.h>
-#include <ndctl.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
-#include <lib/private.h>
+#include "private.h"
 #include "papr.h"
 
 /* Utility logging maros for simplify logging */
diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h
index d442e6c16e9a..4d8622978790 100644
--- a/ndctl/lib/private.h
+++ b/ndctl/lib/private.h
@@ -14,8 +14,9 @@
 #include <ccan/list/list.h>
 #include <ccan/array_size/array_size.h>
 
-#include <ndctl.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
+#include <ndctl/libndctl-nfit.h>
 #include <ccan/endian/endian.h>
 #include <ccan/short_types/short_types.h>
 #include "intel.h"
@@ -23,7 +24,6 @@
 #include "msft.h"
 #include "hyperv.h"
 #include "papr.h"
-#include "libndctl-nfit.h"
 
 struct nvdimm_data {
 	struct ndctl_cmd *cmd_read;
diff --git a/ndctl/list.c b/ndctl/list.c
index 0017f159c708..869edde4fc65 100644
--- a/ndctl/list.c
+++ b/ndctl/list.c
@@ -7,13 +7,14 @@
 #include <limits.h>
 
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
 
-#include <ndctl.h>
+#include "ndctl.h"
+#include "filter.h"
+#include "json.h"
 
 static struct {
 	bool buses;
diff --git a/ndctl/load-keys.c b/ndctl/load-keys.c
index 26648fe90fe6..d60e7eeb985d 100644
--- a/ndctl/load-keys.c
+++ b/ndctl/load-keys.c
@@ -12,13 +12,14 @@
 #include <fcntl.h>
 #include <keyutils.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
-#include <util/keys.h>
-#include <ndctl.h>
+
+#include "filter.h"
+#include "keys.h"
 
 static struct parameters {
 	const char *key_path;
diff --git a/ndctl/monitor.c b/ndctl/monitor.c
index 0e9b65cb2bc4..8b600a4e762b 100644
--- a/ndctl/monitor.c
+++ b/ndctl/monitor.c
@@ -7,7 +7,6 @@
 #include <time.h>
 #include <dirent.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <util/util.h>
 #include <util/parse-options.h>
 #include <util/parse-configs.h>
@@ -27,6 +26,9 @@
 #endif
 #include <util/log.h>
 
+#include "filter.h"
+#include "json.h"
+
 static struct monitor {
 	const char *log;
 	const char *configs;
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index c67c0861afac..257b58ce5917 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -9,7 +9,6 @@
 #include <limits.h>
 #include <syslog.h>
 
-#include <ndctl.h>
 #include "action.h"
 #include "namespace.h"
 #include <sys/stat.h>
@@ -20,11 +19,14 @@
 #include <util/size.h>
 #include <util/json.h>
 #include <json-c/json.h>
-#include <util/filter.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
 #include <ccan/minmax/minmax.h>
 
+#include "filter.h"
+#include "json.h"
+
 static bool verbose;
 static bool force;
 static bool repair;
diff --git a/ndctl/region.c b/ndctl/region.c
index 4552c4a33478..e49954660ebb 100644
--- a/ndctl/region.c
+++ b/ndctl/region.c
@@ -5,10 +5,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include "action.h"
-#include <util/filter.h>
 #include <util/parse-options.h>
 #include <ndctl/libndctl.h>
 
+#include "filter.h"
+
 static struct {
 	const char *bus;
 	const char *type;
diff --git a/test/Makefile.am b/test/Makefile.am
index a5a54df4f260..a2a4ee4a4335 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -80,12 +80,19 @@ testcore =\
 libndctl_SOURCES = libndctl.c $(testcore)
 libndctl_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
 
+namespace_core =\
+	../ndctl/namespace.c \
+	../ndctl/filter.c \
+	../ndctl/check.c \
+	../util/json.c \
+	../ndctl/json.c \
+	../daxctl/filter.c \
+	../daxctl/json.c
+
 dsm_fail_SOURCES =\
 	dsm-fail.c \
 	$(testcore) \
-	../ndctl/namespace.c \
-	../ndctl/check.c \
-	../util/json.c
+	$(namespace_core)
 
 dsm_fail_LDADD = $(LIBNDCTL_LIB) \
 		$(KMOD_LIBS) \
@@ -122,9 +129,7 @@ device_dax_SOURCES = \
 		dax-dev.c \
 		dax-pmd.c \
 		$(testcore) \
-		../ndctl/namespace.c \
-		../ndctl/check.c \
-		../util/json.c
+		$(namespace_core)
 
 if ENABLE_POISON
 dax_pmd_SOURCES += dax-poison.c
@@ -153,7 +158,10 @@ smart_listen_LDADD = $(LIBNDCTL_LIB)
 
 list_smart_dimm_SOURCES = \
 		list-smart-dimm.c \
-		../util/json.c
+		../ndctl/filter.c \
+		../util/json.c \
+		../ndctl/json.c
+
 list_smart_dimm_LDADD = \
 		$(LIBNDCTL_LIB) \
 		$(JSON_LIBS) \
diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c
index c561ff3416ea..a9e95c63b76c 100644
--- a/test/ack-shutdown-count-set.c
+++ b/test/ack-shutdown-count-set.c
@@ -15,7 +15,7 @@
 
 #include <ccan/array_size/array_size.h>
 #include <ndctl/libndctl.h>
-#include <ndctl.h>
+#include <ndctl/ndctl.h>
 #include <test.h>
 
 static int test_dimm(struct ndctl_dimm *dimm)
diff --git a/test/daxdev-errors.c b/test/daxdev-errors.c
index fbbea21448d8..706670767b1a 100644
--- a/test/daxdev-errors.c
+++ b/test/daxdev-errors.c
@@ -23,7 +23,7 @@
 #include <daxctl/libdaxctl.h>
 #include <ccan/array_size/array_size.h>
 #include <ndctl/libndctl.h>
-#include <ndctl.h>
+#include <ndctl/ndctl.h>
 
 #define fail() fprintf(stderr, "%s: failed at: %d\n", __func__, __LINE__)
 
diff --git a/test/device-dax.c b/test/device-dax.c
index aad8fa5f1cb1..49c9bc8b1748 100644
--- a/test/device-dax.c
+++ b/test/device-dax.c
@@ -20,7 +20,7 @@
 #include <daxctl/libdaxctl.h>
 #include <ccan/array_size/array_size.h>
 
-#include <builtin.h>
+#include <ndctl/builtin.h>
 #include <test.h>
 
 static sigjmp_buf sj_env;
diff --git a/test/dsm-fail.c b/test/dsm-fail.c
index 0a6383d49910..5b443dcd703d 100644
--- a/test/dsm-fail.c
+++ b/test/dsm-fail.c
@@ -14,8 +14,8 @@
 
 #include <ccan/array_size/array_size.h>
 #include <ndctl/libndctl.h>
-#include <builtin.h>
-#include <ndctl.h>
+#include <ndctl/builtin.h>
+#include <ndctl/ndctl.h>
 #include <test.h>
 
 #define DIMM_PATH "/sys/devices/platform/nfit_test.0/nfit_test_dimm/test_dimm0"
diff --git a/test/libndctl.c b/test/libndctl.c
index 0bee06b93787..75c15303fad4 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -21,7 +21,7 @@
 #include <ccan/array_size/array_size.h>
 #include <ndctl/libndctl.h>
 #include <daxctl/libdaxctl.h>
-#include <ndctl.h>
+#include <ndctl/ndctl.h>
 #include <test.h>
 
 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
diff --git a/test/list-smart-dimm.c b/test/list-smart-dimm.c
index 00c24e11bf24..47b711e63670 100644
--- a/test/list-smart-dimm.c
+++ b/test/list-smart-dimm.c
@@ -3,11 +3,13 @@
 #include <stdio.h>
 #include <errno.h>
 #include <util/json.h>
-#include <util/filter.h>
 #include <json-c/json.h>
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
-#include <ndctl.h>
+
+#include <ndctl/filter.h>
+#include <ndctl/ndctl.h>
+#include <ndctl/json.h>
 
 struct util_filter_params param;
 static int did_fail;
diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c
index a4db1ae3ecae..4bafff5164c8 100644
--- a/test/pmem_namespaces.c
+++ b/test/pmem_namespaces.c
@@ -3,6 +3,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <linux/fs.h>
+#include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -18,7 +19,6 @@
 #include <test.h>
 
 #include <ccan/array_size/array_size.h>
-#include <ndctl.h>
 
 #define err(msg)\
 	fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
diff --git a/test/revoke-devmem.c b/test/revoke-devmem.c
index bb8979e9a3d4..59d1a72df6ad 100644
--- a/test/revoke-devmem.c
+++ b/test/revoke-devmem.c
@@ -19,7 +19,7 @@
 #include <ndctl/libndctl.h>
 #include <ccan/array_size/array_size.h>
 
-#include <builtin.h>
+#include <ndctl/builtin.h>
 #include <test.h>
 
 static sigjmp_buf sj_env;
diff --git a/util/help.c b/util/help.c
index 6eebfe5143e1..da8408328771 100644
--- a/util/help.c
+++ b/util/help.c
@@ -14,7 +14,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include <builtin.h>
+#include <ndctl/builtin.h>
 #include <util/strbuf.h>
 #include <util/parse-options.h>
 
diff --git a/util/json.c b/util/json.c
index f97cf070b840..9f0a8e137caa 100644
--- a/util/json.c
+++ b/util/json.c
@@ -2,17 +2,10 @@
 // Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
 #include <limits.h>
 #include <string.h>
+#include <stdio.h>
 #include <util/json.h>
-#include <util/filter.h>
-#include <uuid/uuid.h>
 #include <json-c/json.h>
 #include <json-c/printbuf.h>
-#include <ndctl/libndctl.h>
-#include <daxctl/libdaxctl.h>
-#include <cxl/libcxl.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/short_types/short_types.h>
-#include <ndctl.h>
 
 /* adapted from mdadm::human_size_brief() */
 static int display_size(struct json_object *jobj, struct printbuf *pbuf,
@@ -112,1536 +105,3 @@ void util_display_json_array(FILE *f_out, struct json_object *jarray,
 	}
 	json_object_put(jarray);
 }
-
-struct json_object *util_bus_to_json(struct ndctl_bus *bus, unsigned long flags)
-{
-	struct json_object *jbus = json_object_new_object();
-	struct json_object *jobj, *fw_obj = NULL;
-	int scrub;
-
-	if (!jbus)
-		return NULL;
-
-	jobj = json_object_new_string(ndctl_bus_get_provider(bus));
-	if (!jobj)
-		goto err;
-	json_object_object_add(jbus, "provider", jobj);
-
-	jobj = json_object_new_string(ndctl_bus_get_devname(bus));
-	if (!jobj)
-		goto err;
-	json_object_object_add(jbus, "dev", jobj);
-
-	scrub = ndctl_bus_get_scrub_state(bus);
-	if (scrub < 0)
-		return jbus;
-
-	jobj = json_object_new_string(scrub ? "active" : "idle");
-	if (!jobj)
-		goto err;
-	json_object_object_add(jbus, "scrub_state", jobj);
-
-	if (flags & UTIL_JSON_FIRMWARE) {
-		struct ndctl_dimm *dimm;
-
-		/*
-		 * Skip displaying firmware activation capability if no
-		 * DIMMs support firmware update.
-		 */
-		ndctl_dimm_foreach(bus, dimm)
-			if (ndctl_dimm_fw_update_supported(dimm) == 0) {
-				fw_obj = json_object_new_object();
-				break;
-			}
-	}
-
-	if (fw_obj) {
-		enum ndctl_fwa_state state;
-		enum ndctl_fwa_method method;
-
-		jobj = NULL;
-		method = ndctl_bus_get_fw_activate_method(bus);
-		if (method == NDCTL_FWA_METHOD_RESET)
-			jobj = json_object_new_string("reset");
-		if (method == NDCTL_FWA_METHOD_SUSPEND)
-			jobj = json_object_new_string("suspend");
-		if (method == NDCTL_FWA_METHOD_LIVE)
-			jobj = json_object_new_string("live");
-		if (jobj)
-			json_object_object_add(fw_obj, "activate_method", jobj);
-
-		jobj = NULL;
-		state = ndctl_bus_get_fw_activate_state(bus);
-		if (state == NDCTL_FWA_ARMED)
-			jobj = json_object_new_string("armed");
-		if (state == NDCTL_FWA_IDLE)
-			jobj = json_object_new_string("idle");
-		if (state == NDCTL_FWA_ARM_OVERFLOW)
-			jobj = json_object_new_string("overflow");
-		if (jobj)
-			json_object_object_add(fw_obj, "activate_state", jobj);
-
-		json_object_object_add(jbus, "firmware", fw_obj);
-	}
-
-	return jbus;
- err:
-	json_object_put(jbus);
-	return NULL;
-}
-
-struct json_object *util_dimm_firmware_to_json(struct ndctl_dimm *dimm,
-		unsigned long flags)
-{
-	struct json_object *jfirmware = json_object_new_object();
-	bool can_update, need_powercycle;
-	enum ndctl_fwa_result result;
-	enum ndctl_fwa_state state;
-	struct json_object *jobj;
-	struct ndctl_cmd *cmd;
-	uint64_t run, next;
-	int rc;
-
-	if (!jfirmware)
-		return NULL;
-
-	cmd = ndctl_dimm_cmd_new_fw_get_info(dimm);
-	if (!cmd)
-		goto err;
-
-	rc = ndctl_cmd_submit(cmd);
-	if ((rc < 0) || ndctl_cmd_fw_xlat_firmware_status(cmd) != FW_SUCCESS) {
-		jobj = util_json_object_hex(-1, flags);
-		if (jobj)
-			json_object_object_add(jfirmware, "current_version",
-					jobj);
-		goto out;
-	}
-
-	run = ndctl_cmd_fw_info_get_run_version(cmd);
-	if (run == ULLONG_MAX) {
-		jobj = util_json_object_hex(-1, flags);
-		if (jobj)
-			json_object_object_add(jfirmware, "current_version",
-					jobj);
-		goto out;
-	}
-
-	jobj = util_json_object_hex(run, flags);
-	if (jobj)
-		json_object_object_add(jfirmware, "current_version", jobj);
-
-	rc = ndctl_dimm_fw_update_supported(dimm);
-	can_update = rc == 0;
-	jobj = json_object_new_boolean(can_update);
-	if (jobj)
-		json_object_object_add(jfirmware, "can_update", jobj);
-
-
-	next = ndctl_cmd_fw_info_get_updated_version(cmd);
-	if (next == ULLONG_MAX) {
-		jobj = util_json_object_hex(-1, flags);
-		if (jobj)
-			json_object_object_add(jfirmware, "next_version",
-					jobj);
-		goto out;
-	}
-
-	if (!next)
-		goto out;
-
-	jobj = util_json_object_hex(next, flags);
-	if (jobj)
-		json_object_object_add(jfirmware,
-				"next_version", jobj);
-
-	state = ndctl_dimm_get_fw_activate_state(dimm);
-	switch (state) {
-	case NDCTL_FWA_IDLE:
-		jobj = json_object_new_string("idle");
-		break;
-	case NDCTL_FWA_ARMED:
-		jobj = json_object_new_string("armed");
-		break;
-	case NDCTL_FWA_BUSY:
-		jobj = json_object_new_string("busy");
-		break;
-	default:
-		jobj = NULL;
-		break;
-	}
-	if (jobj)
-		json_object_object_add(jfirmware, "activate_state", jobj);
-
-	result = ndctl_dimm_get_fw_activate_result(dimm);
-	switch (result) {
-	case NDCTL_FWA_RESULT_NONE:
-	case NDCTL_FWA_RESULT_SUCCESS:
-	case NDCTL_FWA_RESULT_NOTSTAGED:
-		/*
-		 * If a 'next' firmware version is staged then this
-		 * result is stale, if the activation succeeds that is
-		 * indicated by not finding a 'next' entry.
-		 */
-		need_powercycle = false;
-		break;
-	case NDCTL_FWA_RESULT_NEEDRESET:
-	case NDCTL_FWA_RESULT_FAIL:
-	default:
-		/*
-		 * If the last activation failed, or if the activation
-		 * result is unavailable it is always the case that the
-		 * only remediation is powercycle.
-		 */
-		need_powercycle = true;
-		break;
-	}
-
-	if (need_powercycle) {
-		jobj = json_object_new_boolean(true);
-		if (!jobj)
-			goto out;
-		json_object_object_add(jfirmware, "need_powercycle", jobj);
-	}
-
-	ndctl_cmd_unref(cmd);
-	return jfirmware;
-
-err:
-	json_object_put(jfirmware);
-	jfirmware = NULL;
-out:
-	if (cmd)
-		ndctl_cmd_unref(cmd);
-	return jfirmware;
-}
-
-struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm,
-		unsigned long flags)
-{
-	struct json_object *jdimm = json_object_new_object();
-	const char *id = ndctl_dimm_get_unique_id(dimm);
-	unsigned int handle = ndctl_dimm_get_handle(dimm);
-	unsigned short phys_id = ndctl_dimm_get_phys_id(dimm);
-	struct json_object *jobj;
-	enum ndctl_security_state sstate;
-
-	if (!jdimm)
-		return NULL;
-
-	jobj = json_object_new_string(ndctl_dimm_get_devname(dimm));
-	if (!jobj)
-		goto err;
-	json_object_object_add(jdimm, "dev", jobj);
-
-	if (id) {
-		jobj = json_object_new_string(id);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "id", jobj);
-	}
-
-	if (handle < UINT_MAX) {
-		jobj = util_json_object_hex(handle, flags);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "handle", jobj);
-	}
-
-	if (phys_id < USHRT_MAX) {
-		jobj = util_json_object_hex(phys_id, flags);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "phys_id", jobj);
-	}
-
-	if (!ndctl_dimm_is_enabled(dimm)) {
-		jobj = json_object_new_string("disabled");
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "state", jobj);
-	}
-
-	if (ndctl_dimm_failed_map(dimm)) {
-		jobj = json_object_new_boolean(true);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "flag_failed_map", jobj);
-	}
-
-	if (ndctl_dimm_failed_save(dimm)) {
-		jobj = json_object_new_boolean(true);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "flag_failed_save", jobj);
-	}
-
-	if (ndctl_dimm_failed_arm(dimm)) {
-		jobj = json_object_new_boolean(true);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "flag_failed_arm", jobj);
-	}
-
-	if (ndctl_dimm_failed_restore(dimm)) {
-		jobj = json_object_new_boolean(true);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "flag_failed_restore", jobj);
-	}
-
-	if (ndctl_dimm_failed_flush(dimm)) {
-		jobj = json_object_new_boolean(true);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "flag_failed_flush", jobj);
-	}
-
-	if (ndctl_dimm_smart_pending(dimm)) {
-		jobj = json_object_new_boolean(true);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jdimm, "flag_smart_event", jobj);
-	}
-
-	sstate = ndctl_dimm_get_security(dimm);
-	if (sstate == NDCTL_SECURITY_DISABLED)
-		jobj = json_object_new_string("disabled");
-	else if (sstate == NDCTL_SECURITY_UNLOCKED)
-		jobj = json_object_new_string("unlocked");
-	else if (sstate == NDCTL_SECURITY_LOCKED)
-		jobj = json_object_new_string("locked");
-	else if (sstate == NDCTL_SECURITY_FROZEN)
-		jobj = json_object_new_string("frozen");
-	else if (sstate == NDCTL_SECURITY_OVERWRITE)
-		jobj = json_object_new_string("overwrite");
-	else
-		jobj = NULL;
-	if (jobj)
-		json_object_object_add(jdimm, "security", jobj);
-
-	if (ndctl_dimm_security_is_frozen(dimm)) {
-		jobj = json_object_new_boolean(true);
-		if (jobj)
-			json_object_object_add(jdimm, "security_frozen", jobj);
-	}
-
-	if (flags & UTIL_JSON_FIRMWARE) {
-		struct json_object *jfirmware;
-
-		jfirmware = util_dimm_firmware_to_json(dimm, flags);
-		if (jfirmware)
-			json_object_object_add(jdimm, "firmware", jfirmware);
-	}
-
-	return jdimm;
- err:
-	json_object_put(jdimm);
-	return NULL;
-}
-
-struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev,
-		unsigned long flags)
-{
-	struct daxctl_memory *mem = daxctl_dev_get_memory(dev);
-	const char *devname = daxctl_dev_get_devname(dev);
-	struct json_object *jdev, *jobj, *jmappings = NULL;
-	struct daxctl_mapping *mapping = NULL;
-	int node, movable, align;
-
-	jdev = json_object_new_object();
-	if (!devname || !jdev)
-		return NULL;
-
-	jobj = json_object_new_string(devname);
-	if (jobj)
-		json_object_object_add(jdev, "chardev", jobj);
-
-	jobj = util_json_object_size(daxctl_dev_get_size(dev), flags);
-	if (jobj)
-		json_object_object_add(jdev, "size", jobj);
-
-	node = daxctl_dev_get_target_node(dev);
-	if (node >= 0) {
-		jobj = json_object_new_int(node);
-		if (jobj)
-			json_object_object_add(jdev, "target_node", jobj);
-	}
-
-	align = daxctl_dev_get_align(dev);
-	if (align > 0) {
-		jobj = util_json_object_size(daxctl_dev_get_align(dev), flags);
-		if (jobj)
-			json_object_object_add(jdev, "align", jobj);
-	}
-
-	if (mem)
-		jobj = json_object_new_string("system-ram");
-	else
-		jobj = json_object_new_string("devdax");
-	if (jobj)
-		json_object_object_add(jdev, "mode", jobj);
-
-	if (mem && daxctl_dev_get_resource(dev) != 0) {
-		int num_sections = daxctl_memory_num_sections(mem);
-		int num_online = daxctl_memory_is_online(mem);
-
-		jobj = json_object_new_int(num_online);
-		if (jobj)
-			json_object_object_add(jdev, "online_memblocks", jobj);
-
-		jobj = json_object_new_int(num_sections);
-		if (jobj)
-			json_object_object_add(jdev, "total_memblocks", jobj);
-
-		movable = daxctl_memory_is_movable(mem);
-		if (movable == 1)
-			jobj = json_object_new_boolean(true);
-		else if (movable == 0)
-			jobj = json_object_new_boolean(false);
-		else
-			jobj = NULL;
-		if (jobj)
-			json_object_object_add(jdev, "movable", jobj);
-	}
-
-	if (!daxctl_dev_is_enabled(dev)) {
-		jobj = json_object_new_string("disabled");
-		if (jobj)
-			json_object_object_add(jdev, "state", jobj);
-	}
-
-	if (!(flags & UTIL_JSON_DAX_MAPPINGS))
-		return jdev;
-
-	daxctl_mapping_foreach(dev, mapping) {
-		struct json_object *jmapping;
-
-		if (!jmappings) {
-			jmappings = json_object_new_array();
-			if (!jmappings)
-				continue;
-
-			json_object_object_add(jdev, "mappings", jmappings);
-		}
-
-		jmapping = util_daxctl_mapping_to_json(mapping, flags);
-		if (!jmapping)
-			continue;
-		json_object_array_add(jmappings, jmapping);
-	}
-	return jdev;
-}
-
-struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region,
-		struct json_object *jdevs, const char *ident,
-		unsigned long flags)
-{
-	struct daxctl_dev *dev;
-
-	daxctl_dev_foreach(region, dev) {
-		struct json_object *jdev;
-
-		if (!util_daxctl_dev_filter(dev, ident))
-			continue;
-
-		if (!(flags & (UTIL_JSON_IDLE|UTIL_JSON_CONFIGURED))
-				&& !daxctl_dev_get_size(dev))
-			continue;
-
-		if (!jdevs) {
-			jdevs = json_object_new_array();
-			if (!jdevs)
-				return NULL;
-		}
-
-		jdev = util_daxctl_dev_to_json(dev, flags);
-		if (!jdev) {
-			json_object_put(jdevs);
-			return NULL;
-		}
-
-		json_object_array_add(jdevs, jdev);
-	}
-
-	return jdevs;
-}
-
-#define _SZ(get_max, get_elem, type) \
-static struct json_object *util_##type##_build_size_array(struct ndctl_##type *arg)	\
-{								\
-	struct json_object *arr = json_object_new_array();	\
-	int i;							\
-								\
-	if (!arr)						\
-		return NULL;					\
-								\
-	for (i = 0; i < get_max(arg); i++) {			\
-		struct json_object *jobj;			\
-		int64_t align;					\
-								\
-		align = get_elem(arg, i);			\
-		jobj = json_object_new_int64(align);		\
-		if (!jobj)					\
-			goto err;				\
-		json_object_array_add(arr, jobj);		\
-	}							\
-								\
-	return arr;						\
-err:								\
-	json_object_put(arr);					\
-	return NULL;						\
-}
-#define SZ(type, kind) _SZ(ndctl_##type##_get_num_##kind##s, \
-			   ndctl_##type##_get_supported_##kind, type)
-SZ(pfn, alignment)
-SZ(dax, alignment)
-SZ(btt, sector_size)
-
-struct json_object *util_region_capabilities_to_json(struct ndctl_region *region)
-{
-	struct json_object *jcaps, *jcap, *jobj;
-	struct ndctl_btt *btt = ndctl_region_get_btt_seed(region);
-	struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
-	struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
-
-	if (!btt || !pfn || !dax)
-		return NULL;
-
-	jcaps = json_object_new_array();
-	if (!jcaps)
-		return NULL;
-
-	if (btt) {
-		jcap = json_object_new_object();
-		if (!jcap)
-			goto err;
-		json_object_array_add(jcaps, jcap);
-
-		jobj = json_object_new_string("sector");
-		if (!jobj)
-			goto err;
-		json_object_object_add(jcap, "mode", jobj);
-		jobj = util_btt_build_size_array(btt);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jcap, "sector_sizes", jobj);
-	}
-
-	if (pfn) {
-		jcap = json_object_new_object();
-		if (!jcap)
-			goto err;
-		json_object_array_add(jcaps, jcap);
-
-		jobj = json_object_new_string("fsdax");
-		if (!jobj)
-			goto err;
-		json_object_object_add(jcap, "mode", jobj);
-		jobj = util_pfn_build_size_array(pfn);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jcap, "alignments", jobj);
-	}
-
-	if (dax) {
-		jcap = json_object_new_object();
-		if (!jcap)
-			goto err;
-		json_object_array_add(jcaps, jcap);
-
-		jobj = json_object_new_string("devdax");
-		if (!jobj)
-			goto err;
-		json_object_object_add(jcap, "mode", jobj);
-		jobj = util_dax_build_size_array(dax);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jcap, "alignments", jobj);
-	}
-
-	return jcaps;
-err:
-	json_object_put(jcaps);
-	return NULL;
-}
-
-struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
-		const char *ident, unsigned long flags)
-{
-	unsigned long align;
-	struct json_object *jregion, *jobj;
-	unsigned long long available_size, size;
-
-	jregion = json_object_new_object();
-	if (!jregion)
-		return NULL;
-
-	/*
-	 * The flag indicates when we are being called by an agent that
-	 * already knows about the parent device information.
-	 */
-	if (!(flags & UTIL_JSON_DAX)) {
-		/* trim off the redundant /sys/devices prefix */
-		const char *path = daxctl_region_get_path(region);
-		int len = strlen("/sys/devices");
-		const char *trim = &path[len];
-
-		if (strncmp(path, "/sys/devices", len) != 0)
-			goto err;
-		jobj = json_object_new_string(trim);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jregion, "path", jobj);
-	}
-
-	jobj = json_object_new_int(daxctl_region_get_id(region));
-	if (!jobj)
-		goto err;
-	json_object_object_add(jregion, "id", jobj);
-
-	size = daxctl_region_get_size(region);
-	if (size < ULLONG_MAX) {
-		jobj = util_json_object_size(size, flags);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jregion, "size", jobj);
-	}
-
-	available_size = daxctl_region_get_available_size(region);
-	if (available_size) {
-		jobj = util_json_object_size(available_size, flags);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jregion, "available_size", jobj);
-	}
-
-	align = daxctl_region_get_align(region);
-	if (align < ULONG_MAX) {
-		jobj = json_object_new_int64(align);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jregion, "align", jobj);
-	}
-
-	if (!(flags & UTIL_JSON_DAX_DEVS))
-		return jregion;
-
-	jobj = util_daxctl_devs_to_list(region, NULL, ident, flags);
-	if (jobj)
-		json_object_object_add(jregion, "devices", jobj);
-
-	return jregion;
- err:
-	json_object_put(jregion);
-	return NULL;
-}
-
-static int compare_dimm_number(const void *p1, const void *p2)
-{
-	struct ndctl_dimm *dimm1 = *(struct ndctl_dimm **)p1;
-	struct ndctl_dimm *dimm2 = *(struct ndctl_dimm **)p2;
-	const char *dimm1_name = ndctl_dimm_get_devname(dimm1);
-	const char *dimm2_name = ndctl_dimm_get_devname(dimm2);
-	int num1, num2;
-
-	if (sscanf(dimm1_name, "nmem%d", &num1) != 1)
-		num1 = 0;
-	if (sscanf(dimm2_name, "nmem%d", &num2) != 1)
-		num2 = 0;
-
-	return num1 - num2;
-}
-
-static struct json_object *badblocks_to_jdimms(struct ndctl_region *region,
-		unsigned long long addr, unsigned long len)
-{
-	struct ndctl_bus *bus = ndctl_region_get_bus(region);
-	int count = ndctl_region_get_interleave_ways(region);
-	unsigned long long end = addr + len;
-	struct json_object *jdimms, *jobj;
-	struct ndctl_dimm **dimms, *dimm;
-	int found, i;
-
-	jdimms = json_object_new_array();
-	if (!jdimms)
-		return NULL;
-
-	dimms = calloc(count, sizeof(struct ndctl_dimm *));
-	if (!dimms)
-		goto err_dimms;
-
-	for (found = 0; found < count && addr < end; addr += 512) {
-		dimm = ndctl_bus_get_dimm_by_physical_address(bus, addr);
-		if (!dimm)
-			continue;
-
-		for (i = 0; i < count; i++)
-			if (dimms[i] == dimm)
-				break;
-		if (i >= count)
-			dimms[found++] = dimm;
-	}
-
-	if (!found)
-		goto err_found;
-
-	qsort(dimms, found, sizeof(dimm), compare_dimm_number);
-
-	for (i = 0; i < found; i++) {
-		const char *devname = ndctl_dimm_get_devname(dimms[i]);
-
-		jobj = json_object_new_string(devname);
-		if (!jobj)
-			break;
-		json_object_array_add(jdimms, jobj);
-	}
-
-	if (!i)
-		goto err_found;
-	free(dimms);
-	return jdimms;
-
-err_found:
-	free(dimms);
-err_dimms:
-	json_object_put(jdimms);
-	return NULL;
-}
-
-struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
-		unsigned int *bb_count, unsigned long flags)
-{
-	struct json_object *jbb = NULL, *jbbs = NULL, *jobj;
-	struct badblock *bb;
-	int bbs = 0;
-
-	if (flags & UTIL_JSON_MEDIA_ERRORS) {
-		jbbs = json_object_new_array();
-		if (!jbbs)
-			return NULL;
-	}
-
-	ndctl_region_badblock_foreach(region, bb) {
-		struct json_object *jdimms;
-		unsigned long long addr;
-
-		bbs += bb->len;
-
-		/* recheck so we can still get the badblocks_count from above */
-		if (!(flags & UTIL_JSON_MEDIA_ERRORS))
-			continue;
-
-		/* get start address of region */
-		addr = ndctl_region_get_resource(region);
-		if (addr == ULLONG_MAX)
-			goto err_array;
-
-		/* get address of bad block */
-		addr += bb->offset << 9;
-
-		jbb = json_object_new_object();
-		if (!jbb)
-			goto err_array;
-
-		jobj = json_object_new_int64(bb->offset);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jbb, "offset", jobj);
-
-		jobj = json_object_new_int(bb->len);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jbb, "length", jobj);
-
-		jdimms = badblocks_to_jdimms(region, addr, bb->len << 9);
-		if (jdimms)
-			json_object_object_add(jbb, "dimms", jdimms);
-		json_object_array_add(jbbs, jbb);
-	}
-
-	*bb_count = bbs;
-
-	if (bbs)
-		return jbbs;
-
- err:
-	json_object_put(jbb);
- err_array:
-	json_object_put(jbbs);
-	return NULL;
-}
-
-static struct json_object *util_namespace_badblocks_to_json(
-			struct ndctl_namespace *ndns,
-			unsigned int *bb_count, unsigned long flags)
-{
-	struct json_object *jbb = NULL, *jbbs = NULL, *jobj;
-	struct badblock *bb;
-	int bbs = 0;
-
-	if (flags & UTIL_JSON_MEDIA_ERRORS) {
-		jbbs = json_object_new_array();
-		if (!jbbs)
-			return NULL;
-	} else
-		return NULL;
-
-	ndctl_namespace_badblock_foreach(ndns, bb) {
-		bbs += bb->len;
-
-		/* recheck so we can still get the badblocks_count from above */
-		if (!(flags & UTIL_JSON_MEDIA_ERRORS))
-			continue;
-
-		jbb = json_object_new_object();
-		if (!jbb)
-			goto err_array;
-
-		jobj = json_object_new_int64(bb->offset);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jbb, "offset", jobj);
-
-		jobj = json_object_new_int(bb->len);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jbb, "length", jobj);
-		json_object_array_add(jbbs, jbb);
-	}
-
-	*bb_count = bbs;
-
-	if (bbs)
-		return jbbs;
-
- err:
-	json_object_put(jbb);
- err_array:
-	json_object_put(jbbs);
-	return NULL;
-}
-
-static struct json_object *dev_badblocks_to_json(struct ndctl_region *region,
-		unsigned long long dev_begin, unsigned long long dev_size,
-		unsigned int *bb_count, unsigned long flags)
-{
-	struct json_object *jbb = NULL, *jbbs = NULL, *jobj;
-	unsigned long long region_begin, dev_end, offset;
-	unsigned int len, bbs = 0;
-	struct badblock *bb;
-
-	region_begin = ndctl_region_get_resource(region);
-	if (region_begin == ULLONG_MAX)
-		return NULL;
-
-	dev_end = dev_begin + dev_size - 1;
-
-	if (flags & UTIL_JSON_MEDIA_ERRORS) {
-		jbbs = json_object_new_array();
-		if (!jbbs)
-			return NULL;
-	}
-
-	ndctl_region_badblock_foreach(region, bb) {
-		unsigned long long bb_begin, bb_end, begin, end;
-		struct json_object *jdimms;
-
-		bb_begin = region_begin + (bb->offset << 9);
-		bb_end = bb_begin + (bb->len << 9) - 1;
-
-		if (bb_end <= dev_begin || bb_begin >= dev_end)
-			continue;
-
-		if (bb_begin < dev_begin)
-			begin = dev_begin;
-		else
-			begin = bb_begin;
-
-		if (bb_end > dev_end)
-			end = dev_end;
-		else
-			end = bb_end;
-
-		offset = (begin - dev_begin) >> 9;
-		len = (end - begin + 1) >> 9;
-
-		bbs += len;
-
-		/* recheck so we can still get the badblocks_count from above */
-		if (!(flags & UTIL_JSON_MEDIA_ERRORS))
-			continue;
-
-		jbb = json_object_new_object();
-		if (!jbb)
-			goto err_array;
-
-		jobj = json_object_new_int64(offset);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jbb, "offset", jobj);
-
-		jobj = json_object_new_int(len);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jbb, "length", jobj);
-
-		jdimms = badblocks_to_jdimms(region, begin, len << 9);
-		if (jdimms)
-			json_object_object_add(jbb, "dimms", jdimms);
-
-		json_object_array_add(jbbs, jbb);
-	}
-
-	*bb_count = bbs;
-
-	if (bbs)
-		return jbbs;
-
- err:
-	json_object_put(jbb);
- err_array:
-	json_object_put(jbbs);
-	return NULL;
-}
-
-static struct json_object *util_pfn_badblocks_to_json(struct ndctl_pfn *pfn,
-		unsigned int *bb_count, unsigned long flags)
-{
-	struct ndctl_region *region = ndctl_pfn_get_region(pfn);
-	unsigned long long pfn_begin, pfn_size;
-
-	pfn_begin = ndctl_pfn_get_resource(pfn);
-	if (pfn_begin == ULLONG_MAX) {
-		struct ndctl_namespace *ndns = ndctl_pfn_get_namespace(pfn);
-
-		return util_namespace_badblocks_to_json(ndns, bb_count, flags);
-	}
-
-	pfn_size = ndctl_pfn_get_size(pfn);
-	if (pfn_size == ULLONG_MAX)
-		return NULL;
-
-	return dev_badblocks_to_json(region, pfn_begin, pfn_size,
-			bb_count, flags);
-}
-
-static void util_btt_badblocks_to_json(struct ndctl_btt *btt,
-		unsigned int *bb_count)
-{
-	struct ndctl_region *region = ndctl_btt_get_region(btt);
-	struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt);
-	unsigned long long begin, size;
-
-	if (!ndns)
-		return;
-
-	begin = ndctl_namespace_get_resource(ndns);
-	if (begin == ULLONG_MAX)
-		return;
-
-	size = ndctl_namespace_get_size(ndns);
-	if (size == ULLONG_MAX)
-		return;
-
-	/*
-	 * The dev_badblocks_to_json() for BTT is not accurate with
-	 * respect to data vs metadata badblocks, and is only useful for
-	 * a potential bb_count.
-	 *
-	 * FIXME: switch to native BTT badblocks representation
-	 * when / if the kernel provides it.
-	 */
-	dev_badblocks_to_json(region, begin, size, bb_count, 0);
-}
-
-static struct json_object *util_dax_badblocks_to_json(struct ndctl_dax *dax,
-		unsigned int *bb_count, unsigned long flags)
-{
-	struct ndctl_region *region = ndctl_dax_get_region(dax);
-	unsigned long long dax_begin, dax_size;
-
-	dax_begin = ndctl_dax_get_resource(dax);
-	if (dax_begin == ULLONG_MAX)
-		return NULL;
-
-	dax_size = ndctl_dax_get_size(dax);
-	if (dax_size == ULLONG_MAX)
-		return NULL;
-
-	return dev_badblocks_to_json(region, dax_begin, dax_size,
-			bb_count, flags);
-}
-
-static struct json_object *util_raw_uuid(struct ndctl_namespace *ndns)
-{
-	char buf[40];
-	uuid_t raw_uuid;
-
-	ndctl_namespace_get_uuid(ndns, raw_uuid);
-	if (uuid_is_null(raw_uuid))
-		return NULL;
-	uuid_unparse(raw_uuid, buf);
-	return json_object_new_string(buf);
-}
-
-static void util_raw_uuid_to_json(struct ndctl_namespace *ndns,
-				  unsigned long flags,
-				  struct json_object *jndns)
-{
-	struct json_object *jobj;
-
-	if (!(flags & UTIL_JSON_VERBOSE))
-		return;
-
-	jobj = util_raw_uuid(ndns);
-	if (!jobj)
-		return;
-	json_object_object_add(jndns, "raw_uuid", jobj);
-}
-
-struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
-		unsigned long flags)
-{
-	struct json_object *jndns = json_object_new_object();
-	enum ndctl_pfn_loc loc = NDCTL_PFN_LOC_NONE;
-	struct json_object *jobj, *jbbs = NULL;
-	const char *locations[] = {
-		[NDCTL_PFN_LOC_NONE] = "none",
-		[NDCTL_PFN_LOC_RAM] = "mem",
-		[NDCTL_PFN_LOC_PMEM] = "dev",
-	};
-	unsigned long long size = ULLONG_MAX;
-	unsigned int sector_size = UINT_MAX;
-	enum ndctl_namespace_mode mode;
-	const char *bdev = NULL, *name;
-	unsigned int bb_count = 0;
-	struct ndctl_btt *btt;
-	struct ndctl_pfn *pfn;
-	struct ndctl_dax *dax;
-	unsigned long align = 0;
-	char buf[40];
-	uuid_t uuid;
-	int numa, target;
-
-	if (!jndns)
-		return NULL;
-
-	jobj = json_object_new_string(ndctl_namespace_get_devname(ndns));
-	if (!jobj)
-		goto err;
-	json_object_object_add(jndns, "dev", jobj);
-
-	btt = ndctl_namespace_get_btt(ndns);
-	dax = ndctl_namespace_get_dax(ndns);
-	pfn = ndctl_namespace_get_pfn(ndns);
-	mode = ndctl_namespace_get_mode(ndns);
-	switch (mode) {
-	case NDCTL_NS_MODE_MEMORY:
-		if (pfn) { /* dynamic memory mode */
-			size = ndctl_pfn_get_size(pfn);
-			loc = ndctl_pfn_get_location(pfn);
-		} else { /* native/static memory mode */
-			size = ndctl_namespace_get_size(ndns);
-			loc = NDCTL_PFN_LOC_RAM;
-		}
-		jobj = json_object_new_string("fsdax");
-		break;
-	case NDCTL_NS_MODE_DAX:
-		if (!dax)
-			goto err;
-		size = ndctl_dax_get_size(dax);
-		jobj = json_object_new_string("devdax");
-		loc = ndctl_dax_get_location(dax);
-		break;
-	case NDCTL_NS_MODE_SECTOR:
-		if (!btt)
-			goto err;
-		jobj = json_object_new_string("sector");
-		size = ndctl_btt_get_size(btt);
-		break;
-	case NDCTL_NS_MODE_RAW:
-		size = ndctl_namespace_get_size(ndns);
-		jobj = json_object_new_string("raw");
-		break;
-	default:
-		jobj = NULL;
-	}
-	if (jobj)
-		json_object_object_add(jndns, "mode", jobj);
-
-	if ((mode != NDCTL_NS_MODE_SECTOR) && (mode != NDCTL_NS_MODE_RAW)) {
-		jobj = json_object_new_string(locations[loc]);
-		if (jobj)
-			json_object_object_add(jndns, "map", jobj);
-	}
-
-	if (size < ULLONG_MAX) {
-		jobj = util_json_object_size(size, flags);
-		if (jobj)
-			json_object_object_add(jndns, "size", jobj);
-	}
-
-	if (btt) {
-		ndctl_btt_get_uuid(btt, uuid);
-		uuid_unparse(uuid, buf);
-		jobj = json_object_new_string(buf);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "uuid", jobj);
-		util_raw_uuid_to_json(ndns, flags, jndns);
-		bdev = ndctl_btt_get_block_device(btt);
-	} else if (pfn) {
-		align = ndctl_pfn_get_align(pfn);
-		ndctl_pfn_get_uuid(pfn, uuid);
-		uuid_unparse(uuid, buf);
-		jobj = json_object_new_string(buf);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "uuid", jobj);
-		util_raw_uuid_to_json(ndns, flags, jndns);
-		bdev = ndctl_pfn_get_block_device(pfn);
-	} else if (dax) {
-		struct daxctl_region *dax_region;
-
-		dax_region = ndctl_dax_get_daxctl_region(dax);
-		align = ndctl_dax_get_align(dax);
-		ndctl_dax_get_uuid(dax, uuid);
-		uuid_unparse(uuid, buf);
-		jobj = json_object_new_string(buf);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "uuid", jobj);
-		util_raw_uuid_to_json(ndns, flags, jndns);
-		if ((flags & UTIL_JSON_DAX) && dax_region) {
-			jobj = util_daxctl_region_to_json(dax_region, NULL,
-					flags);
-			if (jobj)
-				json_object_object_add(jndns, "daxregion", jobj);
-		} else if (dax_region) {
-			struct daxctl_dev *dev;
-
-			/*
-			 * We can only find/list these device-dax
-			 * details when the instance is enabled.
-			 */
-			dev = daxctl_dev_get_first(dax_region);
-			if (dev) {
-				name = daxctl_dev_get_devname(dev);
-				jobj = json_object_new_string(name);
-				if (!jobj)
-					goto err;
-				json_object_object_add(jndns, "chardev", jobj);
-			}
-		}
-	} else if (ndctl_namespace_get_type(ndns) != ND_DEVICE_NAMESPACE_IO) {
-		ndctl_namespace_get_uuid(ndns, uuid);
-		uuid_unparse(uuid, buf);
-		jobj = json_object_new_string(buf);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "uuid", jobj);
-		bdev = ndctl_namespace_get_block_device(ndns);
-	} else
-		bdev = ndctl_namespace_get_block_device(ndns);
-
-	if (btt)
-		sector_size = ndctl_btt_get_sector_size(btt);
-	else if (!dax) {
-		sector_size = ndctl_namespace_get_sector_size(ndns);
-		if (!sector_size || sector_size == UINT_MAX)
-			sector_size = 512;
-	}
-
-	/*
-	 * The kernel will default to a 512 byte sector size on PMEM
-	 * namespaces that don't explicitly have a sector size. This
-	 * happens because they use pre-v1.2 labels or because they
-	 * don't have a label space (devtype=nd_namespace_io).
-	 */
-	if (sector_size < UINT_MAX) {
-		jobj = json_object_new_int(sector_size);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "sector_size", jobj);
-	}
-
-	if (align) {
-		jobj = json_object_new_int64(align);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "align", jobj);
-	}
-
-	if (bdev && bdev[0]) {
-		jobj = json_object_new_string(bdev);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "blockdev", jobj);
-	}
-
-	if (!ndctl_namespace_is_active(ndns)) {
-		jobj = json_object_new_string("disabled");
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "state", jobj);
-	}
-
-	name = ndctl_namespace_get_alt_name(ndns);
-	if (name && name[0]) {
-		jobj = json_object_new_string(name);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jndns, "name", jobj);
-	}
-
-	numa = ndctl_namespace_get_numa_node(ndns);
-	if (numa >= 0 && flags & UTIL_JSON_VERBOSE) {
-		jobj = json_object_new_int(numa);
-		if (jobj)
-			json_object_object_add(jndns, "numa_node", jobj);
-	}
-
-	target = ndctl_namespace_get_target_node(ndns);
-	if (target >= 0 && flags & UTIL_JSON_VERBOSE) {
-		jobj = json_object_new_int(target);
-		if (jobj)
-			json_object_object_add(jndns, "target_node", jobj);
-	}
-
-	if (pfn)
-		jbbs = util_pfn_badblocks_to_json(pfn, &bb_count, flags);
-	else if (dax)
-		jbbs = util_dax_badblocks_to_json(dax, &bb_count, flags);
-	else if (btt)
-		util_btt_badblocks_to_json(btt, &bb_count);
-	else {
-		jbbs = util_region_badblocks_to_json(
-				ndctl_namespace_get_region(ndns), &bb_count,
-				flags);
-		if (!jbbs)
-			jbbs = util_namespace_badblocks_to_json(ndns, &bb_count,
-					flags);
-	}
-
-	if (bb_count) {
-		jobj = json_object_new_int(bb_count);
-		if (!jobj) {
-			json_object_put(jbbs);
-			goto err;
-		}
-		json_object_object_add(jndns, "badblock_count", jobj);
-	}
-
-	if ((flags & UTIL_JSON_MEDIA_ERRORS) && jbbs)
-		json_object_object_add(jndns, "badblocks", jbbs);
-
-	return jndns;
- err:
-	json_object_put(jndns);
-	return NULL;
-}
-
-struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping,
-		unsigned long flags)
-{
-	struct json_object *jmapping = json_object_new_object();
-	struct ndctl_dimm *dimm = ndctl_mapping_get_dimm(mapping);
-	struct json_object *jobj;
-	int position;
-
-	if (!jmapping)
-		return NULL;
-
-	jobj = json_object_new_string(ndctl_dimm_get_devname(dimm));
-	if (!jobj)
-		goto err;
-	json_object_object_add(jmapping, "dimm", jobj);
-
-	jobj = util_json_object_hex(ndctl_mapping_get_offset(mapping), flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jmapping, "offset", jobj);
-
-	jobj = util_json_object_hex(ndctl_mapping_get_length(mapping), flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jmapping, "length", jobj);
-
-	position = ndctl_mapping_get_position(mapping);
-	if (position >= 0) {
-		jobj = json_object_new_int(position);
-		if (!jobj)
-			goto err;
-		json_object_object_add(jmapping, "position", jobj);
-	}
-
-	return jmapping;
- err:
-	json_object_put(jmapping);
-	return NULL;
-}
-
-struct json_object *util_daxctl_mapping_to_json(struct daxctl_mapping *mapping,
-		unsigned long flags)
-{
-	struct json_object *jmapping = json_object_new_object();
-	struct json_object *jobj;
-
-	if (!jmapping)
-		return NULL;
-
-	jobj = util_json_object_hex(daxctl_mapping_get_offset(mapping), flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jmapping, "page_offset", jobj);
-
-	jobj = util_json_object_hex(daxctl_mapping_get_start(mapping), flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jmapping, "start", jobj);
-
-	jobj = util_json_object_hex(daxctl_mapping_get_end(mapping), flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jmapping, "end", jobj);
-
-	jobj = util_json_object_size(daxctl_mapping_get_size(mapping), flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jmapping, "size", jobj);
-
-	return jmapping;
- err:
-	json_object_put(jmapping);
-	return NULL;
-}
-
-struct json_object *util_badblock_rec_to_json(u64 block, u64 count,
-		unsigned long flags)
-{
-	struct json_object *jerr = json_object_new_object();
-	struct json_object *jobj;
-
-	if (!jerr)
-		return NULL;
-
-	jobj = util_json_object_hex(block, flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jerr, "block", jobj);
-
-	jobj = util_json_object_hex(count, flags);
-	if (!jobj)
-		goto err;
-	json_object_object_add(jerr, "count", jobj);
-
-	return jerr;
- err:
-	json_object_put(jerr);
-	return NULL;
-}
-
-static struct json_object *util_cxl_memdev_health_to_json(
-		struct cxl_memdev *memdev, unsigned long flags)
-{
-	struct json_object *jhealth;
-	struct json_object *jobj;
-	struct cxl_cmd *cmd;
-	u32 field;
-	int rc;
-
-	jhealth = json_object_new_object();
-	if (!jhealth)
-		return NULL;
-	if (!memdev)
-		goto err_jobj;
-
-	cmd = cxl_cmd_new_get_health_info(memdev);
-	if (!cmd)
-		goto err_jobj;
-
-	rc = cxl_cmd_submit(cmd);
-	if (rc < 0)
-		goto err_cmd;
-	rc = cxl_cmd_get_mbox_status(cmd);
-	if (rc != 0)
-		goto err_cmd;
-
-	/* health_status fields */
-	rc = cxl_cmd_health_info_get_maintenance_needed(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "maintenance_needed", jobj);
-
-	rc = cxl_cmd_health_info_get_performance_degraded(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "performance_degraded", jobj);
-
-	rc = cxl_cmd_health_info_get_hw_replacement_needed(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "hw_replacement_needed", jobj);
-
-	/* media_status fields */
-	rc = cxl_cmd_health_info_get_media_normal(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_normal", jobj);
-
-	rc = cxl_cmd_health_info_get_media_not_ready(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_not_ready", jobj);
-
-	rc = cxl_cmd_health_info_get_media_persistence_lost(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_persistence_lost", jobj);
-
-	rc = cxl_cmd_health_info_get_media_data_lost(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_data_lost", jobj);
-
-	rc = cxl_cmd_health_info_get_media_powerloss_persistence_loss(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_powerloss_persistence_loss", jobj);
-
-	rc = cxl_cmd_health_info_get_media_shutdown_persistence_loss(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_shutdown_persistence_loss", jobj);
-
-	rc = cxl_cmd_health_info_get_media_persistence_loss_imminent(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_persistence_loss_imminent", jobj);
-
-	rc = cxl_cmd_health_info_get_media_powerloss_data_loss(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_powerloss_data_loss", jobj);
-
-	rc = cxl_cmd_health_info_get_media_shutdown_data_loss(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_shutdown_data_loss", jobj);
-
-	rc = cxl_cmd_health_info_get_media_data_loss_imminent(cmd);
-	jobj = json_object_new_boolean(rc);
-	if (jobj)
-		json_object_object_add(jhealth, "media_data_loss_imminent", jobj);
-
-	/* ext_status fields */
-	if (cxl_cmd_health_info_get_ext_life_used_normal(cmd))
-		jobj = json_object_new_string("normal");
-	else if (cxl_cmd_health_info_get_ext_life_used_warning(cmd))
-		jobj = json_object_new_string("warning");
-	else if (cxl_cmd_health_info_get_ext_life_used_critical(cmd))
-		jobj = json_object_new_string("critical");
-	else
-		jobj = json_object_new_string("unknown");
-	if (jobj)
-		json_object_object_add(jhealth, "ext_life_used", jobj);
-
-	if (cxl_cmd_health_info_get_ext_temperature_normal(cmd))
-		jobj = json_object_new_string("normal");
-	else if (cxl_cmd_health_info_get_ext_temperature_warning(cmd))
-		jobj = json_object_new_string("warning");
-	else if (cxl_cmd_health_info_get_ext_temperature_critical(cmd))
-		jobj = json_object_new_string("critical");
-	else
-		jobj = json_object_new_string("unknown");
-	if (jobj)
-		json_object_object_add(jhealth, "ext_temperature", jobj);
-
-	if (cxl_cmd_health_info_get_ext_corrected_volatile_normal(cmd))
-		jobj = json_object_new_string("normal");
-	else if (cxl_cmd_health_info_get_ext_corrected_volatile_warning(cmd))
-		jobj = json_object_new_string("warning");
-	else
-		jobj = json_object_new_string("unknown");
-	if (jobj)
-		json_object_object_add(jhealth, "ext_corrected_volatile", jobj);
-
-	if (cxl_cmd_health_info_get_ext_corrected_persistent_normal(cmd))
-		jobj = json_object_new_string("normal");
-	else if (cxl_cmd_health_info_get_ext_corrected_persistent_warning(cmd))
-		jobj = json_object_new_string("warning");
-	else
-		jobj = json_object_new_string("unknown");
-	if (jobj)
-		json_object_object_add(jhealth, "ext_corrected_persistent", jobj);
-
-	/* other fields */
-	field = cxl_cmd_health_info_get_life_used(cmd);
-	if (field != 0xff) {
-		jobj = json_object_new_int(field);
-		if (jobj)
-			json_object_object_add(jhealth, "life_used_percent", jobj);
-	}
-
-	field = cxl_cmd_health_info_get_temperature(cmd);
-	if (field != 0xffff) {
-		jobj = json_object_new_int(field);
-		if (jobj)
-			json_object_object_add(jhealth, "temperature", jobj);
-	}
-
-	field = cxl_cmd_health_info_get_dirty_shutdowns(cmd);
-	jobj = json_object_new_int64(field);
-	if (jobj)
-		json_object_object_add(jhealth, "dirty_shutdowns", jobj);
-
-	field = cxl_cmd_health_info_get_volatile_errors(cmd);
-	jobj = json_object_new_int64(field);
-	if (jobj)
-		json_object_object_add(jhealth, "volatile_errors", jobj);
-
-	field = cxl_cmd_health_info_get_pmem_errors(cmd);
-	jobj = json_object_new_int64(field);
-	if (jobj)
-		json_object_object_add(jhealth, "pmem_errors", jobj);
-
-	cxl_cmd_unref(cmd);
-	return jhealth;
-
-err_cmd:
-	cxl_cmd_unref(cmd);
-err_jobj:
-	json_object_put(jhealth);
-	return NULL;
-}
-
-struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
-		unsigned long flags)
-{
-	const char *devname = cxl_memdev_get_devname(memdev);
-	struct json_object *jdev, *jobj;
-
-	jdev = json_object_new_object();
-	if (!devname || !jdev)
-		return NULL;
-
-	jobj = json_object_new_string(devname);
-	if (jobj)
-		json_object_object_add(jdev, "memdev", jobj);
-
-	jobj = util_json_object_size(cxl_memdev_get_pmem_size(memdev), flags);
-	if (jobj)
-		json_object_object_add(jdev, "pmem_size", jobj);
-
-	jobj = util_json_object_size(cxl_memdev_get_ram_size(memdev), flags);
-	if (jobj)
-		json_object_object_add(jdev, "ram_size", jobj);
-
-	if (flags & UTIL_JSON_HEALTH) {
-		jobj = util_cxl_memdev_health_to_json(memdev, flags);
-		if (jobj)
-			json_object_object_add(jdev, "health", jobj);
-	}
-	return jdev;
-}
diff --git a/util/json.h b/util/json.h
index ce575e6358f3..4ca2c890fa5c 100644
--- a/util/json.h
+++ b/util/json.h
@@ -1,12 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (C) 2015-2020 Intel Corporation. All rights reserved. */
-#ifndef __NDCTL_JSON_H__
-#define __NDCTL_JSON_H__
+#ifndef __UTIL_JSON_H__
+#define __UTIL_JSON_H__
 #include <stdio.h>
 #include <stdbool.h>
-#include <ndctl/libndctl.h>
-#include <daxctl/libdaxctl.h>
-#include <ccan/short_types/short_types.h>
 
 enum util_json_flags {
 	UTIL_JSON_IDLE		= (1 << 0),
@@ -25,38 +22,8 @@ enum util_json_flags {
 struct json_object;
 void util_display_json_array(FILE *f_out, struct json_object *jarray,
 		unsigned long flags);
-struct json_object *util_bus_to_json(struct ndctl_bus *bus,
-		unsigned long flags);
-struct json_object *util_dimm_to_json(struct ndctl_dimm *dimm,
-		unsigned long flags);
-struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping,
-		unsigned long flags);
-struct json_object *util_daxctl_mapping_to_json(struct daxctl_mapping *mapping,
-		unsigned long flags);
-struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
-		unsigned long flags);
-struct json_object *util_badblock_rec_to_json(u64 block, u64 count,
-		unsigned long flags);
-struct daxctl_region;
-struct daxctl_dev;
-struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
-		unsigned int *bb_count, unsigned long flags);
-struct json_object *util_daxctl_region_to_json(struct daxctl_region *region,
-		const char *ident, unsigned long flags);
-struct json_object *util_daxctl_dev_to_json(struct daxctl_dev *dev,
-		unsigned long flags);
-struct json_object *util_daxctl_devs_to_list(struct daxctl_region *region,
-		struct json_object *jdevs, const char *ident,
-		unsigned long flags);
 struct json_object *util_json_object_size(unsigned long long size,
 		unsigned long flags);
 struct json_object *util_json_object_hex(unsigned long long val,
 		unsigned long flags);
-struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);
-struct json_object *util_dimm_firmware_to_json(struct ndctl_dimm *dimm,
-		unsigned long flags);
-struct json_object *util_region_capabilities_to_json(struct ndctl_region *region);
-struct cxl_memdev;
-struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
-		unsigned long flags);
-#endif /* __NDCTL_JSON_H__ */
+#endif /* __UTIL_JSON_H__ */


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 10/16] Documentation: Drop attrs.adoc include
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (8 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 09/16] util: Distribute 'filter' and 'json' helpers to per-tool objects Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 11/16] build: Drop unnecessary $tool/config.h includes Dan Williams
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

In preparation for switching build systems, drop the attrs.adoc include for
communicating variables to asciidoc. Simply add the necessary variable
values to the invocation of the command using the --attribute argument.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 .gitignore                                         |    1 -
 Documentation/daxctl/Makefile.am                   |   17 +++++++----------
 Documentation/daxctl/daxctl-reconfigure-device.txt |    2 --
 Documentation/ndctl/Makefile.am                    |   17 +++++++----------
 Documentation/ndctl/intel-nvdimm-security.txt      |    2 --
 Documentation/ndctl/ndctl-load-keys.txt            |    2 --
 Documentation/ndctl/ndctl-monitor.txt              |    2 --
 Documentation/ndctl/ndctl-sanitize-dimm.txt        |    2 --
 Documentation/ndctl/ndctl-setup-passphrase.txt     |    2 --
 Documentation/ndctl/ndctl-update-passphrase.txt    |    2 --
 10 files changed, 14 insertions(+), 35 deletions(-)

diff --git a/.gitignore b/.gitignore
index 6b19d90a12f1..4ab393e71a89 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,7 +23,6 @@ Documentation/daxctl/asciidoctor-extensions.rb
 Documentation/ndctl/asciidoctor-extensions.rb
 Documentation/cxl/asciidoctor-extensions.rb
 Documentation/cxl/lib/asciidoctor-extensions.rb
-Documentation/ndctl/attrs.adoc
 .dirstamp
 daxctl/config.h
 daxctl/daxctl
diff --git a/Documentation/daxctl/Makefile.am b/Documentation/daxctl/Makefile.am
index 9c43e6176b28..78c47f5055c4 100644
--- a/Documentation/daxctl/Makefile.am
+++ b/Documentation/daxctl/Makefile.am
@@ -33,20 +33,11 @@ EXTRA_DIST = $(man1_MANS)
 
 CLEANFILES = $(man1_MANS)
 
-.ONESHELL:
-attrs.adoc: $(srcdir)/Makefile.am
-	$(AM_V_GEN) cat <<- EOF >$@
-		:daxctl_confdir: $(daxctl_confdir)
-		:daxctl_conf: $(daxctl_conf)
-		:ndctl_keysdir: $(ndctl_keysdir)
-		EOF
-
 XML_DEPS = \
 	../../version.m4 \
 	../copyright.txt \
 	Makefile \
-	$(CONFFILE) \
-	attrs.adoc
+	$(CONFFILE)
 
 RM ?= rm -f
 
@@ -57,6 +48,9 @@ if USE_ASCIIDOCTOR
 		$(ASCIIDOC) -b manpage -d manpage -acompat-mode \
 		-I. -rasciidoctor-extensions \
 		-amansource=daxctl -amanmanual="daxctl Manual" \
+		-adaxctl_confdir=$(daxctl_confdir) \
+		-adaxctl_conf=$(daxctl_conf) \
+		-andctl_keysdir=$(ndctl_keysdir) \
 		-andctl_version=$(VERSION) -o $@+ $< && \
 		mv $@+ $@
 
@@ -65,6 +59,9 @@ else
 %.xml: %.txt $(XML_DEPS)
 	$(AM_V_GEN)$(RM) $@+ $@ && \
 		$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
+		-adaxctl_confdir=$(daxctl_confdir) \
+		-adaxctl_conf=$(daxctl_conf) \
+		-andctl_keysdir=$(ndctl_keysdir) \
 		--unsafe -adaxctl_version=$(VERSION) -o $@+ $< && \
 		mv $@+ $@
 
diff --git a/Documentation/daxctl/daxctl-reconfigure-device.txt b/Documentation/daxctl/daxctl-reconfigure-device.txt
index b2184ec862bb..385c0c53931d 100644
--- a/Documentation/daxctl/daxctl-reconfigure-device.txt
+++ b/Documentation/daxctl/daxctl-reconfigure-device.txt
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-include::attrs.adoc[]
-
 daxctl-reconfigure-device(1)
 ============================
 
diff --git a/Documentation/ndctl/Makefile.am b/Documentation/ndctl/Makefile.am
index 37855cc0585d..203158c1dfaf 100644
--- a/Documentation/ndctl/Makefile.am
+++ b/Documentation/ndctl/Makefile.am
@@ -56,14 +56,6 @@ EXTRA_DIST = $(man1_MANS)
 
 CLEANFILES = $(man1_MANS)
 
-.ONESHELL:
-attrs.adoc: $(srcdir)/Makefile.am
-	$(AM_V_GEN) cat <<- EOF >$@
-		:ndctl_confdir: $(ndctl_confdir)
-		:ndctl_monitorconf: $(ndctl_monitorconf)
-		:ndctl_keysdir: $(ndctl_keysdir)
-		EOF
-
 XML_DEPS = \
 	../../version.m4 \
 	Makefile \
@@ -76,8 +68,7 @@ XML_DEPS = \
 	xable-namespace-options.txt \
 	ars-description.txt \
 	labels-description.txt \
-	labels-options.txt \
-	attrs.adoc
+	labels-options.txt
 
 RM ?= rm -f
 
@@ -88,6 +79,9 @@ if USE_ASCIIDOCTOR
 		$(ASCIIDOC) -b manpage -d manpage -acompat-mode \
 		-I. -rasciidoctor-extensions \
 		-amansource=ndctl -amanmanual="ndctl Manual" \
+		-andctl_confdir=$(ndctl_confdir) \
+		-andctl_monitorconf=$(ndctl_monitorconf) \
+		-andctl_keysdir=$(ndctl_keysdir) \
 		-andctl_version=$(VERSION) -o $@+ $< && \
 		mv $@+ $@
 
@@ -96,6 +90,9 @@ else
 %.xml: %.txt $(XML_DEPS)
 	$(AM_V_GEN)$(RM) $@+ $@ && \
 		$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
+		-andctl_confdir=$(ndctl_confdir) \
+		-andctl_monitorconf=$(ndctl_monitorconf) \
+		-andctl_keysdir=$(ndctl_keysdir) \
 		--unsafe -andctl_version=$(VERSION) -o $@+ $< && \
 		mv $@+ $@
 
diff --git a/Documentation/ndctl/intel-nvdimm-security.txt b/Documentation/ndctl/intel-nvdimm-security.txt
index 142b4603db69..88b305b81978 100644
--- a/Documentation/ndctl/intel-nvdimm-security.txt
+++ b/Documentation/ndctl/intel-nvdimm-security.txt
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-include::attrs.adoc[]
-
 THEORY OF OPERATION
 -------------------
 The Intel Device Specific Methods (DSM) specification v1.7 and v1.8 [1]
diff --git a/Documentation/ndctl/ndctl-load-keys.txt b/Documentation/ndctl/ndctl-load-keys.txt
index a064f97fd069..70db57441820 100644
--- a/Documentation/ndctl/ndctl-load-keys.txt
+++ b/Documentation/ndctl/ndctl-load-keys.txt
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-include::attrs.adoc[]
-
 ndctl-load-keys(1)
 ==================
 
diff --git a/Documentation/ndctl/ndctl-monitor.txt b/Documentation/ndctl/ndctl-monitor.txt
index 8c8c35b41ace..eca079d56a32 100644
--- a/Documentation/ndctl/ndctl-monitor.txt
+++ b/Documentation/ndctl/ndctl-monitor.txt
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-include::attrs.adoc[]
-
 ndctl-monitor(1)
 ================
 
diff --git a/Documentation/ndctl/ndctl-sanitize-dimm.txt b/Documentation/ndctl/ndctl-sanitize-dimm.txt
index b2e5fde9ecb3..e04467856ca4 100644
--- a/Documentation/ndctl/ndctl-sanitize-dimm.txt
+++ b/Documentation/ndctl/ndctl-sanitize-dimm.txt
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-include::attrs.adoc[]
-
 ndctl-sanitize-dimm(1)
 ======================
 
diff --git a/Documentation/ndctl/ndctl-setup-passphrase.txt b/Documentation/ndctl/ndctl-setup-passphrase.txt
index 1219279b4c66..96f709b468fc 100644
--- a/Documentation/ndctl/ndctl-setup-passphrase.txt
+++ b/Documentation/ndctl/ndctl-setup-passphrase.txt
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-include::attrs.adoc[]
-
 ndctl-setup-passphrase(1)
 =========================
 
diff --git a/Documentation/ndctl/ndctl-update-passphrase.txt b/Documentation/ndctl/ndctl-update-passphrase.txt
index c7c1bfc8ab0b..591ce44ebc3e 100644
--- a/Documentation/ndctl/ndctl-update-passphrase.txt
+++ b/Documentation/ndctl/ndctl-update-passphrase.txt
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-include::attrs.adoc[]
-
 ndctl-update-passphrase(1)
 ==========================
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 11/16] build: Drop unnecessary $tool/config.h includes
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (9 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 10/16] Documentation: Drop attrs.adoc include Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 12/16] test: Prepare out of line builds Dan Williams
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

In preparation for support for meson as the build infrastructure remove
some explicit config.h includes that will be replaced by a unified config.h
at the top of the project.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 daxctl/migrate.c |    1 -
 ndctl/keys.c     |    1 -
 ndctl/monitor.c  |    1 -
 3 files changed, 3 deletions(-)

diff --git a/daxctl/migrate.c b/daxctl/migrate.c
index 5fbe970fdaff..c51106625849 100644
--- a/daxctl/migrate.c
+++ b/daxctl/migrate.c
@@ -5,7 +5,6 @@
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <daxctl/config.h>
 #include <daxctl/libdaxctl.h>
 #include <util/parse-options.h>
 #include <ccan/array_size/array_size.h>
diff --git a/ndctl/keys.c b/ndctl/keys.c
index 876b34714b7e..2f33b8fb488c 100644
--- a/ndctl/keys.c
+++ b/ndctl/keys.c
@@ -13,7 +13,6 @@
 #include <keyutils.h>
 #include <syslog.h>
 
-#include <ndctl/config.h>
 #include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 
diff --git a/ndctl/monitor.c b/ndctl/monitor.c
index 8b600a4e762b..ae694c614593 100644
--- a/ndctl/monitor.c
+++ b/ndctl/monitor.c
@@ -11,7 +11,6 @@
 #include <util/parse-options.h>
 #include <util/parse-configs.h>
 #include <util/strbuf.h>
-#include <ndctl/config.h>
 #include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <sys/epoll.h>


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 12/16] test: Prepare out of line builds
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (10 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 11/16] build: Drop unnecessary $tool/config.h includes Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 13/16] ndctl: Drop executable bit for bash-completion script Dan Williams
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

In preparation for converting to meson prepare the unit tests to run out of
a build directory rather than out of the source directory. Introduce
TEST_PATH for the location of the test executables.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/btt-errors.sh     |    4 +---
 test/common            |   37 +++++++++++++++++++++----------------
 test/dax-pmd.c         |   11 +++++++++--
 test/dax.sh            |    6 +++---
 test/daxdev-errors.sh  |    4 ++--
 test/device-dax-fio.sh |    2 +-
 test/dm.sh             |    4 ++--
 test/inject-smart.sh   |    2 +-
 test/mmap.sh           |    6 +++---
 test/monitor.sh        |    6 +++---
 test/pmem-errors.sh    |    8 +++-----
 test/sub-section.sh    |    4 ++--
 test/track-uuid.sh     |    2 +-
 13 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/test/btt-errors.sh b/test/btt-errors.sh
index 6e69178cc3cf..18518d503e9c 100755
--- a/test/btt-errors.sh
+++ b/test/btt-errors.sh
@@ -11,14 +11,12 @@ rc=77
 
 cleanup()
 {
-	rm -f $FILE
-	rm -f $MNT/$FILE
 	if grep -q "$MNT" /proc/mounts; then
 		umount $MNT
 	else
 		rc=77
 	fi
-	rmdir $MNT
+	rm -rf $MNT
 }
 
 force_raw()
diff --git a/test/common b/test/common
index b6d47128f209..fb487958a29b 100644
--- a/test/common
+++ b/test/common
@@ -4,27 +4,32 @@
 # Global variables
 
 # NDCTL
-#
-if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then
-	export NDCTL=../ndctl/ndctl
-elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then
-	export NDCTL=./ndctl/ndctl
-else
-	echo "Couldn't find an ndctl binary"
-	exit 1
+if [ -z $NDCTL ]; then
+	if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then
+		export NDCTL=../ndctl/ndctl
+	elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then
+		export NDCTL=./ndctl/ndctl
+	else
+		echo "Couldn't find an ndctl binary"
+		exit 1
+	fi
 fi
 
 # DAXCTL
-#
-if [ -f "../daxctl/daxctl" ] && [ -x "../daxctl/daxctl" ]; then
-	export DAXCTL=../daxctl/daxctl
-elif [ -f "./daxctl/daxctl" ] && [ -x "./daxctl/daxctl" ]; then
-	export DAXCTL=./daxctl/daxctl
-else
-	echo "Couldn't find an daxctl binary"
-	exit 1
+if [ -z $DAXCTL ]; then
+	if [ -f "../daxctl/daxctl" ] && [ -x "../daxctl/daxctl" ]; then
+		export DAXCTL=../daxctl/daxctl
+	elif [ -f "./daxctl/daxctl" ] && [ -x "./daxctl/daxctl" ]; then
+		export DAXCTL=./daxctl/daxctl
+	else
+		echo "Couldn't find an daxctl binary"
+		exit 1
+	fi
 fi
 
+if [ -z $TEST_PATH ]; then
+	export TEST_PATH=.
+fi
 
 # NFIT_TEST_BUS[01]
 #
diff --git a/test/dax-pmd.c b/test/dax-pmd.c
index 7648e348b0a6..f8408759d51e 100644
--- a/test/dax-pmd.c
+++ b/test/dax-pmd.c
@@ -24,7 +24,8 @@
 	__func__, __LINE__, strerror(errno))
 #define faili(i) fprintf(stderr, "%s: failed at: %d: %d (%s)\n", \
 	__func__, __LINE__, i, strerror(errno))
-#define TEST_FILE "test_dax_data"
+#define TEST_DIR "test_dax_mnt"
+#define TEST_FILE TEST_DIR "/test_dax_data"
 
 #define REGION_MEM_SIZE 4096*4
 #define REGION_PM_SIZE        4096*512
@@ -171,8 +172,14 @@ int test_dax_directio(int dax_fd, unsigned long align, void *dax_addr, off_t off
 		}
 		rc = -ENXIO;
 
+		rc = mkdir(TEST_DIR, 0600);
+		if (rc < 0 && errno != EEXIST) {
+			faili(i);
+			munmap(addr, 2 * align);
+			break;
+		}
 		fd2 = open(TEST_FILE, O_CREAT|O_TRUNC|O_DIRECT|O_RDWR,
-				DEFFILEMODE);
+				0600);
 		if (fd2 < 0) {
 			faili(i);
 			munmap(addr, 2*align);
diff --git a/test/dax.sh b/test/dax.sh
index bcdd4e9bda27..bb9848b10ecc 100755
--- a/test/dax.sh
+++ b/test/dax.sh
@@ -15,13 +15,13 @@ cleanup() {
 	else
 		rc=77
 	fi
-	rmdir $MNT
+	rm -rf $MNT
 	exit $rc
 }
 
 run_test() {
 	rc=0
-	if ! trace-cmd record -e fs_dax:dax_pmd_fault_done ./dax-pmd $MNT/$FILE; then
+	if ! trace-cmd record -e fs_dax:dax_pmd_fault_done $TEST_PATH/dax-pmd $MNT/$FILE; then
 		rc=$?
 		if [ "$rc" -ne 77 ] && [ "$rc" -ne 0 ]; then
 			cleanup "$1"
@@ -104,7 +104,7 @@ set -e
 mkdir -p $MNT
 trap 'err $LINENO cleanup' ERR
 
-dev=$(./dax-dev)
+dev=$($TEST_PATH/dax-dev)
 json=$($NDCTL list -N -n $dev)
 eval $(json2var <<< "$json")
 rc=1
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
index e13453dfaa73..7f79718113d0 100755
--- a/test/daxdev-errors.sh
+++ b/test/daxdev-errors.sh
@@ -62,8 +62,8 @@ read sector len < /sys/bus/nd/devices/$region/badblocks
 echo "sector: $sector len: $len"
 
 # run the daxdev-errors test
-test -x ./daxdev-errors
-./daxdev-errors $busdev $region
+test -x $TEST_PATH/daxdev-errors
+$TEST_PATH/daxdev-errors $busdev $region
 
 # check badblocks, should be empty
 if read sector len < /sys/bus/platform/devices/nfit_test.0/$busdev/$region/badblocks; then
diff --git a/test/device-dax-fio.sh b/test/device-dax-fio.sh
index f57a9d266afc..c43ac058d2b0 100755
--- a/test/device-dax-fio.sh
+++ b/test/device-dax-fio.sh
@@ -18,7 +18,7 @@ if ! fio --enghelp | grep -q "dev-dax"; then
 	exit 77
 fi
 
-dev=$(./dax-dev)
+dev=$($TEST_PATH/dax-dev)
 for align in 4k 2m 1g
 do
 	json=$($NDCTL create-namespace -m devdax -a $align -f -e $dev)
diff --git a/test/dm.sh b/test/dm.sh
index 4656e5bfbebe..b780a65c27d2 100755
--- a/test/dm.sh
+++ b/test/dm.sh
@@ -8,7 +8,7 @@ SKIP=77
 FAIL=1
 SUCCESS=0
 
-. ./common
+. $(dirname $0)/common
 
 MNT=test_dax_mnt
 TEST_DM_PMEM=/dev/mapper/test_pmem
@@ -30,7 +30,7 @@ cleanup() {
 	if [ -L $TEST_DM_PMEM ]; then
 		dmsetup remove $TEST_DM_PMEM
 	fi
-	rmdir $MNT
+	rm -rf $MNT
 	# opportunistic cleanup, not fatal if these fail
 	namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev")
 	for i in $namespaces
diff --git a/test/inject-smart.sh b/test/inject-smart.sh
index 4ca83b8b2263..8b913601bdd2 100755
--- a/test/inject-smart.sh
+++ b/test/inject-smart.sh
@@ -170,7 +170,7 @@ check_prereq "jq"
 modprobe nfit_test
 rc=1
 
-jlist=$(./list-smart-dimm -b $bus)
+jlist=$($TEST_PATH/list-smart-dimm -b $bus)
 dimm="$(jq '.[]."dev"?, ."dev"?' <<< $jlist | sort | head -1 | xargs)"
 test -n "$dimm"
 
diff --git a/test/mmap.sh b/test/mmap.sh
index 50a1d34d0b75..760257dc7f93 100755
--- a/test/mmap.sh
+++ b/test/mmap.sh
@@ -7,7 +7,7 @@
 MNT=test_mmap_mnt
 FILE=image
 DEV=""
-TEST=./mmap
+TEST=$TEST_PATH/mmap
 rc=77
 
 cleanup() {
@@ -17,7 +17,7 @@ cleanup() {
 	else
 		rc=77
 	fi
-	rmdir $MNT
+	rm -rf $MNT
 	exit $rc
 }
 
@@ -49,7 +49,7 @@ set -e
 mkdir -p $MNT
 trap 'err $LINENO cleanup' ERR
 
-dev=$(./dax-dev)
+dev=$($TEST_PATH/dax-dev)
 json=$($NDCTL list -N -n $dev)
 eval $(json2var <<< "$json")
 DEV="/dev/${blockdev}"
diff --git a/test/monitor.sh b/test/monitor.sh
index 14450a7b23e3..ef04607d8eb0 100755
--- a/test/monitor.sh
+++ b/test/monitor.sh
@@ -31,7 +31,7 @@ start_monitor()
 set_smart_supported_bus()
 {
 	smart_supported_bus=$NFIT_TEST_BUS0
-	monitor_dimms=$(./list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev)
+	monitor_dimms=$($TEST_PATH/list-smart-dimm -b $smart_supported_bus | jq -r .[0].dev)
 	if [ -z $monitor_dimms ]; then
 		smart_supported_bus=$NFIT_TEST_BUS1
 	fi
@@ -39,14 +39,14 @@ set_smart_supported_bus()
 
 get_monitor_dimm()
 {
-	jlist=$(./list-smart-dimm -b $smart_supported_bus $1)
+	jlist=$($TEST_PATH/list-smart-dimm -b $smart_supported_bus $1)
 	monitor_dimms=$(jq '.[]."dev"?, ."dev"?' <<<$jlist | sort | uniq | xargs)
 	echo $monitor_dimms
 }
 
 call_notify()
 {
-	./smart-notify $smart_supported_bus
+	$TEST_PATH/smart-notify $smart_supported_bus
 	sync; sleep 3
 }
 
diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh
index 20657801fc0e..9a59c25d4a79 100755
--- a/test/pmem-errors.sh
+++ b/test/pmem-errors.sh
@@ -10,14 +10,12 @@ rc=77
 
 cleanup()
 {
-	rm -f $FILE
-	rm -f $MNT/$FILE
 	if [ -n "$blockdev" ]; then
 		umount /dev/$blockdev
 	else
 		rc=77
 	fi
-	rmdir $MNT
+	rm -rf $MNT
 }
 
 check_min_kver "4.7" || do_skip "may lack dax error handling"
@@ -82,8 +80,8 @@ echo $start_sect 8 > /sys/block/$blockdev/badblocks
 dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || true
 
 # run the dax-errors test
-test -x ./dax-errors
-./dax-errors $MNT/$FILE
+test -x $TEST_PATH/dax-errors
+$TEST_PATH/dax-errors $MNT/$FILE
 
 # TODO: disable this check till we have clear-on-write in the kernel
 #if read sector len < /sys/block/$blockdev/badblocks; then
diff --git a/test/sub-section.sh b/test/sub-section.sh
index 92ae816c448c..77b963355c8f 100755
--- a/test/sub-section.sh
+++ b/test/sub-section.sh
@@ -8,7 +8,7 @@ SKIP=77
 FAIL=1
 SUCCESS=0
 
-. ./common
+. $(dirname $0)/common
 
 check_min_kver "5.3" || do_skip "may lack align sub-section hotplug support"
 
@@ -30,7 +30,7 @@ cleanup() {
 	if mountpoint -q $MNT; then
 		umount $MNT
 	fi
-	rmdir $MNT
+	rm -rf $MNT
 	# opportunistic cleanup, not fatal if these fail
 	namespaces=$($NDCTL list -N | jq -r ".[] | select(.name==\"$NAME\") | .dev")
 	for i in $namespaces
diff --git a/test/track-uuid.sh b/test/track-uuid.sh
index 3bacd2c24787..a967d0e4691c 100755
--- a/test/track-uuid.sh
+++ b/test/track-uuid.sh
@@ -5,7 +5,7 @@
 blockdev=""
 rc=77
 
-. ./common
+. $(dirname $0)/common
 
 set -e
 trap 'err $LINENO' ERR


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 13/16] ndctl: Drop executable bit for bash-completion script
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (11 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 12/16] test: Prepare out of line builds Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 14/16] build: Add meson build infrastructure Dan Williams
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

The rpm build process warns:

*** WARNING: ./usr/share/bash-completion/completions/ndctl is executable but has no shebang, removing executable bit

Clear the unnecessary executable bit since completion helpers are sourced,
not executed.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 contrib/ndctl |    0 
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100755 => 100644 contrib/ndctl

diff --git a/contrib/ndctl b/contrib/ndctl
old mode 100755
new mode 100644


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 14/16] build: Add meson build infrastructure
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (12 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 13/16] ndctl: Drop executable bit for bash-completion script Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:32 ` [ndctl PATCH v3 15/16] build: Add meson rpmbuild support Dan Williams
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: Vaibhav Jain, nvdimm, linux-cxl

Build times improve from 10s of seconds to sub-second builds especially
when ccache gets involved and the only change is a git version bump. Recall
that every time the version changes with autotools it does a reconfigure.
With meson only the objects that depend on the version string are rebuilt.
So the primary motivation is to make the ndctl project more enjoyable to
develop.

Tools, libraries, documentation, and tests all seem to be working. The
remaining work is to redo the rpm build infrastructure, and validate that
installation is working as expected.

Given the long standing momentum on the old build system it is still kept
functional for now. The only compatibility hack when moving from an
autotools build to a meson build is to delete the config.h files generated
by the old system in favor of the unified configuration header build from
the config.h.meson template.

Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 .gitignore                        |    5 +
 Documentation/cxl/lib/meson.build |   79 ++++++++++
 Documentation/cxl/meson.build     |   84 +++++++++++
 Documentation/daxctl/meson.build  |   94 ++++++++++++
 Documentation/ndctl/meson.build   |  124 ++++++++++++++++
 clean_config.sh                   |    2 
 config.h.meson                    |  151 ++++++++++++++++++++
 contrib/meson.build               |   28 ++++
 cxl/lib/meson.build               |   35 +++++
 cxl/meson.build                   |   25 +++
 daxctl/device.c                   |    1 
 daxctl/lib/meson.build            |   44 ++++++
 daxctl/meson.build                |   35 +++++
 meson.build                       |  280 +++++++++++++++++++++++++++++++++++++
 meson_options.txt                 |   25 +++
 ndctl/lib/meson.build             |   48 ++++++
 ndctl/meson.build                 |   82 +++++++++++
 test/meson.build                  |  237 +++++++++++++++++++++++++++++++
 tools/meson-vcs-tag.sh            |   18 ++
 util/meson.build                  |   16 ++
 version.h.in                      |    2 
 21 files changed, 1414 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/cxl/lib/meson.build
 create mode 100644 Documentation/cxl/meson.build
 create mode 100644 Documentation/daxctl/meson.build
 create mode 100644 Documentation/ndctl/meson.build
 create mode 100755 clean_config.sh
 create mode 100644 config.h.meson
 create mode 100644 contrib/meson.build
 create mode 100644 cxl/lib/meson.build
 create mode 100644 cxl/meson.build
 create mode 100644 daxctl/lib/meson.build
 create mode 100644 daxctl/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 ndctl/lib/meson.build
 create mode 100644 ndctl/meson.build
 create mode 100644 test/meson.build
 create mode 100755 tools/meson-vcs-tag.sh
 create mode 100644 util/meson.build
 create mode 100644 version.h.in

diff --git a/.gitignore b/.gitignore
index 4ab393e71a89..91c5e37b7fef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,9 @@ Makefile.in
 /aclocal.m4
 /autom4te.cache
 /build-aux
-/config.*
+/config.h
+/config.log
+/config.status
 /configure
 /libtool
 /stamp-h1
@@ -24,6 +26,7 @@ Documentation/ndctl/asciidoctor-extensions.rb
 Documentation/cxl/asciidoctor-extensions.rb
 Documentation/cxl/lib/asciidoctor-extensions.rb
 .dirstamp
+build/
 daxctl/config.h
 daxctl/daxctl
 daxctl/lib/libdaxctl.la
diff --git a/Documentation/cxl/lib/meson.build b/Documentation/cxl/lib/meson.build
new file mode 100644
index 000000000000..4b3f59685447
--- /dev/null
+++ b/Documentation/cxl/lib/meson.build
@@ -0,0 +1,79 @@
+if get_option('asciidoctor').enabled()
+  asciidoc_conf = custom_target('asciidoctor-extensions.rb',
+    command : [
+      'sed', '-e', 's,@Utility@,Libcxl,g', '-e', 's,@utility@,cxl,g', '@INPUT@'
+    ],
+    input : '../../asciidoctor-extensions.rb.in',
+    output : 'asciidoctor-extensions.rb',
+    capture : true,
+  )
+else
+  asciidoc_conf = custom_target('asciidoc.conf',
+    command : [
+      'sed', '-e', 's,UTILITY,libcxl,g',
+    ],
+    input : '../../asciidoc.conf.in',
+    output : 'asciidoc.conf',
+    capture : true,
+  )
+endif
+
+filedeps = [
+        '../../copyright.txt',
+]
+
+libcxl_manpages = [
+  'libcxl.txt',
+  'cxl_new.txt',
+]
+
+foreach man : libcxl_manpages
+  name = man.split('.')[0]
+  output = name + '.3'
+  output_xml = name + '.xml'
+  if get_option('asciidoctor').enabled()
+    custom_target(name,
+      command : [
+        asciidoc,
+        '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@',
+        '-rasciidoctor-extensions', '-amansource=libcxl',
+        '-amanmanual=libcxl Manual',
+        '-andctl_version=@0@'.format(meson.project_version()),
+        '-o', '@OUTPUT@', '@INPUT@'
+      ],
+      input : man,
+      output : output,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man3'),
+    )
+  else
+    xml = custom_target(output_xml,
+      command : [
+        asciidoc,
+	'-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe',
+	'-andctl_version=@0@'.format(meson.project_version()),
+	'-o', '@OUTPUT@', '@INPUT@',
+      ],
+      input : man,
+      output : output_xml,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+    )
+
+    xsl = files('../../manpage-normal.xsl')
+
+    custom_target(name,
+      command : [
+        xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@'
+      ],
+      depends : xml,
+      depend_files : xsl,
+      input : xml,
+      output : output,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man3'),
+    )
+  endif
+endforeach
diff --git a/Documentation/cxl/meson.build b/Documentation/cxl/meson.build
new file mode 100644
index 000000000000..64ce13f59012
--- /dev/null
+++ b/Documentation/cxl/meson.build
@@ -0,0 +1,84 @@
+if get_option('asciidoctor').enabled()
+  asciidoc_conf = custom_target('asciidoctor-extensions.rb',
+    command : [
+      'sed', '-e', 's,@Utility@,Cxl,g', '-e', 's,@utility@,cxl,g', '@INPUT@'
+    ],
+    input : '../asciidoctor-extensions.rb.in',
+    output : 'asciidoctor-extensions.rb',
+    capture : true,
+  )
+else
+  asciidoc_conf = custom_target('asciidoc.conf',
+    command : [
+      'sed', '-e', 's,UTILITY,cxl,g',
+    ],
+    input : '../asciidoc.conf.in',
+    output : 'asciidoc.conf',
+    capture : true,
+  )
+endif
+
+filedeps = [
+        '../copyright.txt',
+]
+
+cxl_manpages = [
+  'cxl.txt',
+  'cxl-list.txt',
+  'cxl-read-labels.txt',
+  'cxl-write-labels.txt',
+  'cxl-zero-labels.txt',
+]
+
+foreach man : cxl_manpages
+  name = man.split('.')[0]
+  output = name + '.1'
+  output_xml = name + '.xml'
+  if get_option('asciidoctor').enabled()
+    custom_target(name,
+      command : [
+        asciidoc,
+        '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@',
+        '-rasciidoctor-extensions', '-amansource=cxl',
+        '-amanmanual=cxl Manual',
+        '-andctl_version=@0@'.format(meson.project_version()),
+        '-o', '@OUTPUT@', '@INPUT@'
+      ],
+      input : man,
+      output : output,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man1'),
+    )
+  else
+    xml = custom_target(output_xml,
+      command : [
+        asciidoc,
+	'-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe',
+	'-andctl_version=@0@'.format(meson.project_version()),
+	'-o', '@OUTPUT@', '@INPUT@',
+      ],
+      input : man,
+      output : output_xml,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+    )
+
+    xsl = files('../manpage-normal.xsl')
+
+    custom_target(name,
+      command : [
+        xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@'
+      ],
+      depends : xml,
+      depend_files : xsl,
+      input : xml,
+      output : output,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man1'),
+    )
+  endif
+endforeach
+
+subdir('lib')
diff --git a/Documentation/daxctl/meson.build b/Documentation/daxctl/meson.build
new file mode 100644
index 000000000000..7699e69c29be
--- /dev/null
+++ b/Documentation/daxctl/meson.build
@@ -0,0 +1,94 @@
+if get_option('asciidoctor').enabled()
+  asciidoc_conf = custom_target('asciidoctor-extensions.rb',
+    command : [
+      'sed', '-e', 's,@Utility@,Daxctl,g', '-e', 's,@utility@,daxctl,g', '@INPUT@'
+    ],
+    input : '../asciidoctor-extensions.rb.in',
+    output : 'asciidoctor-extensions.rb',
+    capture : true,
+  )
+else
+  asciidoc_conf = custom_target('asciidoc.conf',
+    command : [
+      'sed', '-e', 's,UTILITY,daxctl,g',
+    ],
+    input : '../asciidoc.conf.in',
+    output : 'asciidoc.conf',
+    capture : true,
+  )
+endif
+
+filedeps = [
+	'human-option.txt',
+        '../copyright.txt',
+]
+
+daxctl_manpages = [
+  'daxctl.txt',
+  'daxctl-list.txt',
+  'daxctl-migrate-device-model.txt',
+  'daxctl-reconfigure-device.txt',
+  'daxctl-online-memory.txt',
+  'daxctl-offline-memory.txt',
+  'daxctl-disable-device.txt',
+  'daxctl-enable-device.txt',
+  'daxctl-create-device.txt',
+  'daxctl-destroy-device.txt',
+]
+
+foreach man : daxctl_manpages
+  name = man.split('.')[0]
+  output = name + '.1'
+  output_xml = name + '.xml'
+  if get_option('asciidoctor').enabled()
+    custom_target(name,
+      command : [
+        asciidoc,
+        '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@',
+        '-rasciidoctor-extensions', '-amansource=daxctl',
+        '-amanmanual=daxctl Manual',
+	'-adaxctl_confdir=@0@'.format(daxctlconf_dir),
+	'-adaxctl_conf=@0@'.format(daxctlconf),
+	'-andctl_keysdir=@0@'.format(ndctlkeys_dir),
+        '-andctl_version=@0@'.format(meson.project_version()),
+        '-o', '@OUTPUT@', '@INPUT@'
+      ],
+      input : man,
+      output : output,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man1'),
+    )
+  else
+    xml = custom_target(output_xml,
+      command : [
+        asciidoc,
+	'-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe',
+	'-adaxctl_confdir=@0@'.format(daxctlconf_dir),
+	'-adaxctl_conf=@0@'.format(daxctlconf),
+	'-andctl_keysdir=@0@'.format(ndctlkeys_dir),
+	'-andctl_version=@0@'.format(meson.project_version()),
+	'-o', '@OUTPUT@', '@INPUT@',
+      ],
+      input : man,
+      output : output_xml,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+    )
+
+    xsl = files('../manpage-normal.xsl')
+
+    custom_target(name,
+      command : [
+        xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@'
+      ],
+      depends : xml,
+      depend_files : xsl,
+      input : xml,
+      output : output,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man1'),
+    )
+  endif
+endforeach
diff --git a/Documentation/ndctl/meson.build b/Documentation/ndctl/meson.build
new file mode 100644
index 000000000000..b82635a4cc4b
--- /dev/null
+++ b/Documentation/ndctl/meson.build
@@ -0,0 +1,124 @@
+if get_option('asciidoctor').enabled()
+  asciidoc_conf = custom_target('asciidoctor-extensions.rb',
+    command : [
+      'sed', '-e', 's,@Utility@,Ndctl,g', '-e', 's,@utility@,ndctl,g', '@INPUT@'
+    ],
+    input : '../asciidoctor-extensions.rb.in',
+    output : 'asciidoctor-extensions.rb',
+    capture : true,
+  )
+else
+  asciidoc_conf = custom_target('asciidoc.conf',
+    command : [
+      'sed', '-e', 's,UTILITY,ndctl,g',
+    ],
+    input : '../asciidoc.conf.in',
+    output : 'asciidoc.conf',
+    capture : true,
+  )
+endif
+
+filedeps = [
+        '../copyright.txt',
+        'region-description.txt',
+        'xable-region-options.txt',
+        'dimm-description.txt',
+        'xable-dimm-options.txt',
+        'xable-namespace-options.txt',
+        'ars-description.txt',
+        'labels-description.txt',
+        'labels-options.txt',
+]
+
+ndctl_manpages = [
+  'ndctl.txt',
+  'ndctl-wait-scrub.txt',
+  'ndctl-start-scrub.txt',
+  'ndctl-zero-labels.txt',
+  'ndctl-read-labels.txt',
+  'ndctl-write-labels.txt',
+  'ndctl-init-labels.txt',
+  'ndctl-check-labels.txt',
+  'ndctl-enable-region.txt',
+  'ndctl-disable-region.txt',
+  'ndctl-enable-dimm.txt',
+  'ndctl-disable-dimm.txt',
+  'ndctl-enable-namespace.txt',
+  'ndctl-disable-namespace.txt',
+  'ndctl-create-namespace.txt',
+  'ndctl-destroy-namespace.txt',
+  'ndctl-check-namespace.txt',
+  'ndctl-clear-errors.txt',
+  'ndctl-inject-error.txt',
+  'ndctl-inject-smart.txt',
+  'ndctl-update-firmware.txt',
+  'ndctl-list.txt',
+  'ndctl-monitor.txt',
+  'ndctl-setup-passphrase.txt',
+  'ndctl-update-passphrase.txt',
+  'ndctl-remove-passphrase.txt',
+  'ndctl-freeze-security.txt',
+  'ndctl-sanitize-dimm.txt',
+  'ndctl-load-keys.txt',
+  'ndctl-wait-overwrite.txt',
+  'ndctl-read-infoblock.txt',
+  'ndctl-write-infoblock.txt',
+  'ndctl-activate-firmware.txt',
+]
+
+foreach man : ndctl_manpages
+  name = man.split('.')[0]
+  output = name + '.1'
+  output_xml = name + '.xml'
+  if get_option('asciidoctor').enabled()
+    custom_target(name,
+      command : [
+        asciidoc,
+        '-b', 'manpage', '-d', 'manpage', '-acompat-mode', '-I', '@OUTDIR@',
+        '-rasciidoctor-extensions', '-amansource=ndctl',
+        '-amanmanual=ndctl Manual',
+	'-andctl_confdir=@0@'.format(ndctlconf_dir),
+	'-andctl_monitorconf=@0@'.format(ndctlconf),
+	'-andctl_keysdir=@0@'.format(ndctlkeys_dir),
+        '-andctl_version=@0@'.format(meson.project_version()),
+        '-o', '@OUTPUT@', '@INPUT@'
+      ],
+      input : man,
+      output : output,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man1'),
+    )
+  else
+    xml = custom_target(output_xml,
+      command : [
+        asciidoc,
+	'-b', 'docbook', '-d', 'manpage', '-f', asciidoc_conf, '--unsafe',
+	'-andctl_version=@0@'.format(meson.project_version()),
+	'-andctl_confdir=@0@'.format(ndctlconf_dir),
+	'-andctl_monitorconf=@0@'.format(ndctlconf),
+	'-andctl_keysdir=@0@'.format(ndctlkeys_dir),
+	'-o', '@OUTPUT@', '@INPUT@',
+      ],
+      input : man,
+      output : output_xml,
+      depend_files : filedeps,
+      depends : asciidoc_conf,
+    )
+
+    xsl = files('../manpage-normal.xsl')
+
+    custom_target(name,
+      command : [
+        xmlto, '-o', '@OUTDIR@', '-m', xsl, 'man', '@INPUT@'
+      ],
+      depends : xml,
+      depend_files : xsl,
+      input : xml,
+      output : output,
+      install : get_option('docs').enabled(),
+      install_dir : join_paths(get_option('mandir'), 'man1'),
+    )
+  endif
+endforeach
diff --git a/clean_config.sh b/clean_config.sh
new file mode 100755
index 000000000000..03ec04c5554b
--- /dev/null
+++ b/clean_config.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+git ls-files -o --exclude build | grep config.h\$ | xargs rm
diff --git a/config.h.meson b/config.h.meson
new file mode 100644
index 000000000000..98102251b494
--- /dev/null
+++ b/config.h.meson
@@ -0,0 +1,151 @@
+/* Debug messages. */
+#mesondefine ENABLE_DEBUG
+
+/* destructive functional tests support */
+#mesondefine ENABLE_DESTRUCTIVE
+
+/* Documentation / man pages. */
+#mesondefine ENABLE_DOCS
+
+/* Enable keyutils support */
+#mesondefine ENABLE_KEYUTILS
+
+/* System logging. */
+#mesondefine ENABLE_LOGGING
+
+/* ndctl test poison support */
+#mesondefine ENABLE_POISON
+
+/* ndctl test support */
+#mesondefine ENABLE_TEST
+
+/* Define to 1 if big-endian-arch */
+#mesondefine HAVE_BIG_ENDIAN
+
+/* Define to 1 if you have the declaration of `BUS_MCEERR_AR', and to 0 if you
+   don't. */
+#mesondefine HAVE_DECL_BUS_MCEERR_AR
+
+/* Define to 1 if you have the declaration of `MAP_SHARED_VALIDATE', and to 0
+   if you don't. */
+#mesondefine HAVE_DECL_MAP_SHARED_VALIDATE
+
+/* Define to 1 if you have the declaration of `MAP_SYNC', and to 0 if you
+   don't. */
+#mesondefine HAVE_DECL_MAP_SYNC
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#mesondefine HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#mesondefine HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <keyutils.h> header file. */
+#mesondefine HAVE_KEYUTILS_H
+
+/* Define to 1 if you have the <linux/version.h> header file. */
+#mesondefine HAVE_LINUX_VERSION_H
+
+/* Define to 1 if little-endian-arch */
+#mesondefine HAVE_LITTLE_ENDIAN
+
+/* Define to 1 if you have the <memory.h> header file. */
+#mesondefine HAVE_MEMORY_H
+
+/* Define to 1 if you have the `secure_getenv' function. */
+#mesondefine HAVE_SECURE_GETENV
+
+/* Define to 1 if you have statement expressions. */
+#mesondefine HAVE_STATEMENT_EXPR
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#mesondefine HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#mesondefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#mesondefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#mesondefine HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#mesondefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#mesondefine HAVE_SYS_TYPES_H
+
+/* Define to 1 if typeof works with your compiler. */
+#mesondefine HAVE_TYPEOF
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#mesondefine HAVE_UNISTD_H
+
+/* Define to 1 if using libuuid */
+#mesondefine HAVE_UUID
+
+/* Define to 1 if you have the `__secure_getenv' function. */
+#mesondefine HAVE___SECURE_GETENV
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#mesondefine LT_OBJDIR
+
+/* Name of package */
+#mesondefine PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#mesondefine PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#mesondefine PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#mesondefine PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#mesondefine PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#mesondefine PACKAGE_URL
+
+/* Define to the version of this package. */
+#mesondefine PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#mesondefine STDC_HEADERS
+
+/* Version number of package */
+#mesondefine VERSION
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#mesondefine _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#mesondefine _LARGE_FILES
+
+/* Define to 1 if on MINIX. */
+#mesondefine _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#mesondefine _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#mesondefine _POSIX_SOURCE
+
+/* Define to __typeof__ if your compiler spells it that way. */
+#mesondefine typeof
+
+/* Define to enable GNU Source Extensions */
+#mesondefine _GNU_SOURCE
+
+/* Locations to install configuration files, key config, man pages, etc.. */
+#mesondefine NDCTL_CONF_FILE
+#mesondefine NDCTL_CONF_DIR
+#mesondefine DAXCTL_CONF_DIR
+#mesondefine NDCTL_KEYS_DIR
+#mesondefine NDCTL_MAN_PATH
+#mesondefine DAXCTL_MODPROBE_DATA
+#mesondefine DAXCTL_MODPROBE_INSTALL
+#mesondefine PREFIX
diff --git a/contrib/meson.build b/contrib/meson.build
new file mode 100644
index 000000000000..4ed3c20165b4
--- /dev/null
+++ b/contrib/meson.build
@@ -0,0 +1,28 @@
+bashcompletiondir = get_option('bashcompletiondir')
+if bashcompletiondir == ''
+  bash_completion = dependency('bash-completion', required : false)
+  if bash_completion.found()
+      bashcompletiondir = bash_completion.get_pkgconfig_variable('completionsdir')
+  else
+    bashcompletiondir = datadir / 'bash-completion/completions'
+  endif
+endif
+
+if bashcompletiondir != 'no'
+  install_data('ndctl', install_dir : bashcompletiondir)
+
+# TODO Switch to symlinks once 0.61.0 is more widely available
+#  install_symlink('daxctl',
+#    install_dir : bashcompletiondir,
+#    pointing_to : 'ndctl'
+#  )
+#  install_symlink('cxl',
+#    install_dir : bashcompletiondir,
+#    pointing_to : 'ndctl'
+#  )
+  install_data('ndctl', rename : 'daxctl', install_dir : bashcompletiondir)
+  install_data('ndctl', rename : 'cxl', install_dir : bashcompletiondir)
+endif
+
+modprobedatadir = get_option('sysconfdir') + '/modprobe.d/'
+install_data('nvdimm-security.conf', install_dir : modprobedatadir)
diff --git a/cxl/lib/meson.build b/cxl/lib/meson.build
new file mode 100644
index 000000000000..eba0ce7278e7
--- /dev/null
+++ b/cxl/lib/meson.build
@@ -0,0 +1,35 @@
+libcxl_version = '@0@.@1@.@2@'.format(
+  LIBCXL_CURRENT - LIBCXL_AGE,
+  LIBCXL_REVISION,
+  LIBCXL_AGE)
+
+mapfile = files('libcxl.sym')
+vflag = '-Wl,--version-script,@0@/@1@'.format(project_source_root, mapfile[0])
+
+cxl = library('cxl',
+  '../../util/sysfs.c',
+  '../../util/log.c',
+  '../../util/log.h',
+  'libcxl.c',
+  include_directories : root_inc,
+  dependencies : [
+    uuid,
+    kmod,
+  ],
+  version : libcxl_version,
+  install : true,
+  install_dir : rootlibdir,
+  link_args : vflag,
+  link_depends : mapfile,
+)
+cxl_dep = declare_dependency(link_with : cxl)
+
+custom_target(
+  'libcxl.pc',
+  command : pkgconfig_script + [ '@INPUT@' ],
+  input : 'libcxl.pc.in',
+  output : 'libcxl.pc',
+  capture : true,
+  install : true,
+  install_dir : pkgconfiglibdir,
+)
diff --git a/cxl/meson.build b/cxl/meson.build
new file mode 100644
index 000000000000..805924b9df9b
--- /dev/null
+++ b/cxl/meson.build
@@ -0,0 +1,25 @@
+cxl_src = [
+  'cxl.c',
+  'list.c',
+  'memdev.c',
+  '../util/json.c',
+  'json.c',
+  'filter.c',
+]
+
+cxl_tool = executable('cxl',
+  cxl_src,
+  include_directories : root_inc,
+  dependencies : [
+    cxl_dep,
+    util_dep,
+    uuid,
+    kmod,
+    json,
+    versiondep,
+  ],
+  install : true,
+  install_dir : rootbindir,
+)
+
+install_headers('libcxl.h', subdir : 'cxl')
diff --git a/daxctl/device.c b/daxctl/device.c
index d202f02d07e7..d2d206b95cae 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -8,6 +8,7 @@
 #include <limits.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <uuid/uuid.h>
 #include <sys/sysmacros.h>
 #include <util/size.h>
 #include <util/json.h>
diff --git a/daxctl/lib/meson.build b/daxctl/lib/meson.build
new file mode 100644
index 000000000000..b79c6e591945
--- /dev/null
+++ b/daxctl/lib/meson.build
@@ -0,0 +1,44 @@
+libdaxctl_version = '@0@.@1@.@2@'.format(
+  LIBDAXCTL_CURRENT - LIBDAXCTL_AGE,
+  LIBDAXCTL_REVISION,
+  LIBDAXCTL_AGE,
+)
+
+mapfile = files('libdaxctl.sym')
+vflag = '-Wl,--version-script,@0@/@1@'.format(project_source_root, mapfile[0])
+
+libdaxctl_src = [
+  '../../util/iomem.c',
+  '../../util/sysfs.c',
+  '../../util/log.c',
+  'libdaxctl.c',
+]
+
+daxctl = library(
+ 'daxctl',
+  libdaxctl_src,
+  version : libdaxctl_version,
+  include_directories : root_inc,
+  dependencies : [
+    uuid,
+    kmod,
+  ],
+  install : true,
+  install_dir : rootlibdir,
+  link_args : vflag,
+  link_depends : mapfile,
+)
+
+daxctl_dep = declare_dependency(link_with : daxctl)
+
+custom_target(
+  'libdaxctl.pc',
+  command : pkgconfig_script + [ '@INPUT@' ],
+  input : 'libdaxctl.pc.in',
+  output : 'libdaxctl.pc',
+  capture : true,
+  install : true,
+  install_dir : pkgconfiglibdir,
+)
+
+install_data('daxctl.conf', install_dir : datadir / 'daxctl')
diff --git a/daxctl/meson.build b/daxctl/meson.build
new file mode 100644
index 000000000000..ec2e2b648d40
--- /dev/null
+++ b/daxctl/meson.build
@@ -0,0 +1,35 @@
+daxctl_src = [
+  'daxctl.c',
+  'acpi.c',
+  'list.c',
+  'migrate.c',
+  'device.c',
+  '../util/json.c',
+  'json.c',
+  'filter.c',
+]
+
+daxctl_tool = executable('daxctl',
+  daxctl_src,
+  include_directories : root_inc,
+  dependencies : [
+    daxctl_dep,
+    ndctl_dep,
+    iniparser,
+    util_dep,
+    uuid,
+    kmod,
+    json,
+    versiondep,
+  ],
+  install : true,
+  install_dir : rootbindir,
+)
+
+install_headers('libdaxctl.h', subdir : 'daxctl')
+
+install_data('daxctl.example.conf', install_dir : daxctlconf_dir )
+if get_option('systemd').enabled()
+  install_data('90-daxctl-device.rules', install_dir : udevrulesdir)
+  install_data('daxdev-reconfigure@.service', install_dir : systemdunitdir)
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 000000000000..272ac642c193
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,280 @@
+project('ndctl', 'c',
+  version : '72',
+  license : [
+    'GPL-2.0',
+    'LGPL-2.1',
+    'CC0-1.0',
+    'MIT',
+  ],
+  default_options : [
+    'c_std=gnu99',
+    'prefix=/usr',
+    'sysconfdir=/etc',
+    'localstatedir=/var',
+  ],
+)
+
+# rootprefixdir and rootlibdir setup copied from systemd:
+rootprefixdir = get_option('rootprefix')
+rootprefix_default = '/usr'
+if rootprefixdir == ''
+        rootprefixdir = rootprefix_default
+endif
+rootbindir = join_paths(rootprefixdir, 'bin')
+
+# join_paths ignores the preceding arguments if an absolute component is
+# encountered, so this should canonicalize various paths when they are
+# absolute or relative.
+prefixdir = get_option('prefix')
+if not prefixdir.startswith('/')
+        error('Prefix is not absolute: "@0@"'.format(prefixdir))
+endif
+if prefixdir != rootprefixdir and rootprefixdir != '/' and not prefixdir.strip('/').startswith(rootprefixdir.strip('/') + '/')
+  error('Prefix is not below root prefix (now rootprefix=@0@ prefix=@1@)'.format(
+	rootprefixdir, prefixdir))
+endif
+
+libdir = join_paths(prefixdir, get_option('libdir'))
+rootlibdir = get_option('rootlibdir')
+if rootlibdir == ''
+  rootlibdir = join_paths(rootprefixdir, libdir.split('/')[-1])
+endif
+datadir = prefixdir / get_option('datadir')
+includedir = prefixdir / get_option('includedir')
+
+pkgconfiglibdir = get_option('pkgconfiglibdir') != '' ? get_option('pkgconfiglibdir') : libdir / 'pkgconfig'
+
+datadir = prefixdir / get_option('datadir')
+includedir = prefixdir / get_option('includedir')
+sysconfdir =  get_option('sysconfdir')
+
+pkgconfig_script = '''
+sed -e s,@VERSION@,@0@,g
+    -e s,@prefix@,@1@,g
+    -e s,@exec_prefix@,@1@,g
+    -e s,@libdir@,@2@,g
+    -e s,@includedir@,@3@,g
+'''.format(meson.project_version(), prefixdir, libdir, includedir).split()
+
+cc_flags = [
+  '-Wall',
+  '-Wchar-subscripts',
+  '-Wformat-security',
+  '-Wmissing-declarations',
+  '-Wmissing-prototypes',
+  '-Wnested-externs ',
+  '-Wshadow',
+  '-Wsign-compare',
+  '-Wstrict-prototypes',
+  '-Wtype-limits',
+  '-Wmaybe-uninitialized',
+  '-Wdeclaration-after-statement',
+  '-Wunused-result',
+  '-D_FORTIFY_SOURCE=2',
+  '-O2',
+]
+cc = meson.get_compiler('c')
+add_project_arguments(cc.get_supported_arguments(cc_flags), language : 'c')
+
+project_source_root = meson.current_source_dir()
+
+# Remove this after the conversion to meson has been completed
+# Cleanup the leftover config.h files to avoid conflicts with the meson
+# generated config.h
+git = find_program('git', required : false)
+if git.found()
+  run_command('clean_config.sh',
+    env : 'GIT_DIR=@0@/.git'.format(project_source_root),
+  )
+endif
+
+version_tag = get_option('version-tag')
+if version_tag != ''
+  vcs_data = configuration_data()
+  vcs_data.set('VCS_TAG', version_tag)
+  version_h = configure_file(
+    configuration : vcs_data,
+    input : 'version.h.in',
+    output : 'version.h'
+  )
+else
+  vcs_tagger = [
+    project_source_root + '/tools/meson-vcs-tag.sh',
+    project_source_root,
+    meson.project_version()
+  ]
+
+  version_h = vcs_tag(
+      input : 'version.h.in',
+      output : 'version.h',
+      command: vcs_tagger
+  )
+endif
+
+versiondep = declare_dependency(
+  compile_args: ['-include', 'version.h'],
+  sources: version_h
+)
+
+kmod = dependency('libkmod')
+libudev = dependency('libudev')
+uuid = dependency('uuid')
+json = dependency('json-c')
+if get_option('docs').enabled()
+  if get_option('asciidoctor').enabled()
+    asciidoc = find_program('asciidoctor', required : true)
+  else
+    asciidoc = find_program('asciidoc', required : true)
+    xmlto = find_program('xmlto', required : true)
+  endif
+endif
+
+if get_option('systemd').enabled()
+  systemd = dependency('systemd', required : true)
+  systemdunitdir = systemd.get_pkgconfig_variable('systemd_system_unit_dir')
+  udev = dependency('udev', required : true)
+  udevdir = udev.get_pkgconfig_variable('udevdir')
+  udevrulesdir = udevdir / 'rules.d'
+endif
+
+cc = meson.get_compiler('c')
+
+# keyutils and iniparser lack pkgconfig
+keyutils = cc.find_library('keyutils', required : get_option('keyutils'))
+iniparser = cc.find_library('iniparser', required : true)
+
+conf = configuration_data()
+check_headers = [
+  ['HAVE_DLFCN_H', 'dlfcn.h'],
+  ['HAVE_INTTYPES_H', 'inttypes.h'],
+  ['HAVE_KEYUTILS_H', 'keyutils.h'],
+  ['HAVE_LINUX_VERSION_H', 'linux/version.h'],
+  ['HAVE_MEMORY_H', 'memory.h'],
+  ['HAVE_STDINT_H', 'stdint.h'],
+  ['HAVE_STDLIB_H', 'stdlib.h'],
+  ['HAVE_STRINGS_H', 'strings.h'],
+  ['HAVE_STRING_H', 'string.h'],
+  ['HAVE_SYS_STAT_H', 'sys/stat.h'],
+  ['HAVE_SYS_TYPES_H', 'sys/types.h'],
+  ['HAVE_UNISTD_H', 'unistd.h'],
+]
+
+foreach h : check_headers
+  if cc.has_header(h.get(1))
+    conf.set(h.get(0), 1)
+  endif
+endforeach
+
+map_sync_symbols = [
+  [ 'signal.h', 'BUS_MCEERR_AR' ],
+  [ 'linux/mman.h', 'MAP_SHARED_VALIDATE' ],
+  [ 'linux/mman.h', 'MAP_SYNC' ],
+]
+
+count = 0
+foreach symbol : map_sync_symbols
+  if cc.has_header_symbol(symbol[0], symbol[1])
+    conf.set('HAVE_DECL_@0@'.format(symbol[1].to_upper()), 1)
+    count = count + 1
+  endif
+endforeach
+
+poison_enabled = false
+if get_option('poison').enabled() and count == 3
+  poison_enabled = true
+endif
+
+conf.set('ENABLE_POISON', poison_enabled)
+conf.set('ENABLE_KEYUTILS', get_option('keyutils').enabled())
+conf.set('ENABLE_TEST', get_option('test').enabled())
+conf.set('ENABLE_DESTRUCTIVE', get_option('destructive').enabled())
+conf.set('ENABLE_LOGGING', get_option('logging').enabled())
+conf.set('ENABLE_DEBUG', get_option('dbg').enabled())
+
+typeof = cc.run('''
+  int main() {
+    struct {
+      char a[16];
+    } x;
+    typeof(x) y;
+
+    return sizeof(x) == sizeof(y);
+  }
+  '''
+)
+
+if typeof.compiled() and typeof.returncode() == 1
+  conf.set('HAVE_TYPEOF', 1)
+  conf.set('HAVE_STATEMENT_EXPR', 1)
+endif
+
+if target_machine.endian() == 'big'
+  conf.set('HAVE_BIG_ENDIAN', 1)
+else
+  conf.set('HAVE_LITTLE_ENDIAN', 1)
+endif
+
+conf.set('_GNU_SOURCE', true)
+conf.set_quoted('PREFIX', get_option('prefix'))
+conf.set_quoted('NDCTL_MAN_PATH', get_option('mandir'))
+
+foreach ident : ['secure_getenv', '__secure_getenv']
+  conf.set10('HAVE_' + ident.to_upper(), cc.has_function(ident))
+endforeach
+
+
+ndctlconf_dir = sysconfdir / 'ndctl.conf.d'
+ndctlconf = ndctlconf_dir / 'monitor.conf'
+conf.set_quoted('NDCTL_CONF_FILE', ndctlconf)
+conf.set_quoted('NDCTL_CONF_DIR', ndctlconf_dir)
+
+ndctlkeys_dir = sysconfdir / 'ndctl' / 'keys'
+conf.set_quoted('NDCTL_KEYS_DIR', ndctlkeys_dir)
+
+daxctlconf_dir = sysconfdir / 'daxctl.conf.d'
+daxctlconf = daxctlconf_dir / 'dax.conf'
+conf.set_quoted('DAXCTL_CONF_DIR', daxctlconf_dir)
+
+conf.set_quoted('DAXCTL_MODPROBE_DATA', datadir / 'daxctl/daxctl.conf')
+conf.set_quoted('DAXCTL_MODPROBE_INSTALL', sysconfdir / 'modprobe.d/daxctl.conf')
+
+config_h = configure_file(
+  input : 'config.h.meson',
+  output : 'config.h',
+  configuration : conf
+)
+add_project_arguments('-include', 'config.h', language : 'c')
+
+LIBNDCTL_CURRENT=25
+LIBNDCTL_REVISION=1
+LIBNDCTL_AGE=19
+
+LIBDAXCTL_CURRENT=6
+LIBDAXCTL_REVISION=0
+LIBDAXCTL_AGE=5
+
+LIBCXL_CURRENT=1
+LIBCXL_REVISION=0
+LIBCXL_AGE=0
+
+root_inc = include_directories(['.', 'ndctl', ])
+
+ccan = static_library('ccan',
+  [ 'ccan/str/str.c', 'ccan/list/list.c' ],
+)
+ccan_dep = declare_dependency(link_with : ccan)
+
+subdir('daxctl/lib')
+subdir('ndctl/lib')
+subdir('cxl/lib')
+subdir('util')
+subdir('ndctl')
+subdir('daxctl')
+subdir('cxl')
+if get_option('docs').enabled()
+  subdir('Documentation/ndctl')
+  subdir('Documentation/daxctl')
+  subdir('Documentation/cxl')
+endif
+subdir('test')
+subdir('contrib')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 000000000000..95312bfcb0d3
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,25 @@
+option('version-tag', type : 'string',
+       description : 'override the git version string')
+option('docs', type : 'feature', value : 'enabled')
+option('asciidoctor', type : 'feature', value : 'disabled')
+option('systemd', type : 'feature', value : 'enabled')
+option('keyutils', type : 'feature', value : 'enabled',
+  description : 'enable nvdimm device passphrase management')
+option('test', type : 'feature', value : 'disabled',
+  description : 'enable shipping tests in ndctl')
+option('destructive', type : 'feature', value : 'disabled',
+  description : 'enable tests that may clobber live system resources')
+option('poison', type : 'feature', value : 'enabled',
+  description : 'enable tests that inject poison / memory-failure')
+option('logging', type : 'feature', value : 'enabled',
+  description : 'enable log infrastructure')
+option('dbg', type : 'feature', value : 'enabled',
+  description : 'enable dbg messages')
+option('rootprefix', type : 'string',
+       description : '''override the root prefix [default '/' if split-usr and '/usr' otherwise]''')
+option('rootlibdir', type : 'string',
+       description : '''[/usr]/lib/x86_64-linux-gnu or such''')
+option('pkgconfiglibdir', type : 'string', value : '',
+       description : 'directory for standard pkg-config files')
+option('bashcompletiondir', type : 'string',
+       description : '''${datadir}/bash-completion/completions''')
diff --git a/ndctl/lib/meson.build b/ndctl/lib/meson.build
new file mode 100644
index 000000000000..abce87948cf2
--- /dev/null
+++ b/ndctl/lib/meson.build
@@ -0,0 +1,48 @@
+libndctl_version = '@0@.@1@.@2@'.format(
+  LIBNDCTL_CURRENT - LIBNDCTL_AGE,
+  LIBNDCTL_REVISION,
+  LIBNDCTL_AGE)
+
+mapfile = files('libndctl.sym')
+vflag = '-Wl,--version-script,@0@/@1@'.format(project_source_root, mapfile[0])
+
+ndctl = library(
+ 'ndctl',
+  '../../util/log.c',
+  '../../util/sysfs.c',
+  'dimm.c',
+  'inject.c',
+  'nfit.c',
+  'smart.c',
+  'intel.c',
+  'hpe1.c',
+  'msft.c',
+  'hyperv.c',
+  'papr.c',
+  'ars.c',
+  'firmware.c',
+  'libndctl.c',
+  dependencies : [
+    daxctl_dep,
+    libudev,
+    uuid,
+    kmod,
+  ],
+  include_directories : root_inc,
+  version : libndctl_version,
+  install : true,
+  install_dir : rootlibdir,
+  link_args : vflag,
+  link_depends : mapfile,
+)
+ndctl_dep = declare_dependency(link_with : ndctl)
+
+custom_target(
+  'libndctl.pc',
+  command : pkgconfig_script + [ '@INPUT@' ],
+  input : 'libndctl.pc.in',
+  output : 'libndctl.pc',
+  capture : true,
+  install : true,
+  install_dir : pkgconfiglibdir,
+)
diff --git a/ndctl/meson.build b/ndctl/meson.build
new file mode 100644
index 000000000000..6a3d0e5348c2
--- /dev/null
+++ b/ndctl/meson.build
@@ -0,0 +1,82 @@
+ndctl_src = [
+  'ndctl.c',
+  'bus.c',
+  'create-nfit.c',
+  'namespace.c',
+  'check.c',
+  'region.c',
+  'dimm.c',
+  '../util/log.c',
+  '../daxctl/filter.c',
+  'filter.c',
+  'list.c',
+  '../util/json.c',
+  '../daxctl/json.c',
+  'json.c',
+  'json-smart.c',
+  'inject-error.c',
+  'inject-smart.c',
+  'monitor.c',
+]
+
+deps = [
+  util_dep,
+  ndctl_dep,
+  daxctl_dep,
+  cxl_dep,
+  uuid,
+  kmod,
+  json,
+  iniparser,
+  versiondep,
+]
+
+if get_option('keyutils').enabled()
+  ndctl_src += [
+    'keys.c',
+    'load-keys.c',
+  ]
+  deps += keyutils
+endif
+
+if get_option('test').enabled()
+  ndctl_src += [
+  '../test/libndctl.c',
+  '../test/dsm-fail.c',
+  '../util/sysfs.c',
+  '../test/core.c',
+  'test.c',
+]
+endif
+
+if get_option('destructive').enabled()
+  if get_option('test').disabled()
+    error('\'-D=destructive=enabled\' requires \'-Dtest=enabled\'\n')
+  endif
+  ndctl_src += [
+    '../test/pmem_namespaces.c',
+    'bat.c',
+  ]
+endif
+
+if get_option('systemd').enabled()
+  install_data('ndctl-monitor.service', install_dir : systemdunitdir)
+endif
+install_data('monitor.conf', install_dir : ndctlconf_dir)
+install_data('ndctl.conf', install_dir : ndctlconf_dir)
+install_data('keys.readme', install_dir : ndctlkeys_dir)
+
+ndctl_tool = executable('ndctl', ndctl_src,
+  dependencies : deps,
+  install : true,
+  install_dir : rootbindir,
+  include_directories : root_inc,
+)
+
+install_headers(
+  [
+    'libndctl.h',
+    'ndctl.h'
+  ],
+  subdir : 'ndctl'
+)
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 000000000000..94287aaef85b
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,237 @@
+testcore = [
+  'core.c',
+  '../util/log.c',
+  '../util/sysfs.c',
+]
+
+libndctl_deps = [
+  ndctl_dep,
+  daxctl_dep,
+  uuid,
+  kmod,
+]
+
+ndctl_deps = libndctl_deps + [
+  json,
+  util_dep,
+  versiondep,
+]
+
+libndctl = executable('libndctl', testcore + [ 'libndctl.c'],
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+namespace_core = [
+  '../ndctl/namespace.c',
+  '../ndctl/filter.c',
+  '../ndctl/check.c',
+  '../util/json.c',
+  '../ndctl/json.c',
+  '../daxctl/filter.c',
+  '../daxctl/json.c',
+]
+
+dsm_fail = executable('dsm-fail', testcore + namespace_core + [ 'dsm-fail.c' ],
+  dependencies : ndctl_deps,
+  include_directories : root_inc,
+)
+
+hugetlb_src = testcore + [ 'hugetlb.c', 'dax-pmd.c' ]
+if poison_enabled
+  hugetlb_src += [ 'dax-poison.c' ]
+endif
+hugetlb = executable('hugetlb', hugetlb_src,
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+ack_shutdown_count = executable('ack-shutdown-count-set',
+  testcore + [ 'ack-shutdown-count-set.c' ],
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+dax_errors = executable('dax-errors',
+  'dax-errors.c',
+)
+
+smart_notify = executable('smart-notify', 'smart-notify.c',
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+smart_listen = executable('smart-listen', 'smart-listen.c',
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+daxdev_errors = executable('daxdev-errors', [
+    'daxdev-errors.c',
+    '../util/log.c',
+    '../util/sysfs.c',
+  ],
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+list_smart_dimm = executable('list-smart-dimm', [
+    'list-smart-dimm.c',
+    '../ndctl/filter.c',
+    '../util/json.c',
+    '../ndctl/json.c',
+    '../daxctl/json.c',
+    '../daxctl/filter.c',
+  ],
+  dependencies : ndctl_deps,
+  include_directories : root_inc,
+)
+
+pmem_ns = executable('pmem-ns', testcore + [ 'pmem_namespaces.c' ],
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+dax_dev = executable('dax-dev', testcore + [ 'dax-dev.c' ],
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+dax_pmd_src = testcore + [ 'dax-pmd.c' ]
+if poison_enabled
+  dax_pmd_src += [ 'dax-poison.c' ]
+endif
+
+dax_pmd = executable('dax-pmd', dax_pmd_src,
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+device_dax_src = testcore + namespace_core + [
+  'device-dax.c',
+  'dax-dev.c',
+  'dax-pmd.c',
+]
+
+if poison_enabled
+  device_dax_src += 'dax-poison.c'
+endif
+
+device_dax = executable('device-dax', device_dax_src,
+  dependencies : ndctl_deps,
+  include_directories : root_inc,
+)
+
+revoke_devmem = executable('revoke_devmem', testcore + [
+    'revoke-devmem.c',
+    'dax-dev.c',
+  ],
+  dependencies : libndctl_deps,
+  include_directories : root_inc,
+)
+
+mmap = executable('mmap', 'mmap.c',)
+
+create = find_program('create.sh')
+clear = find_program('clear.sh')
+pmem_errors = find_program('pmem-errors.sh')
+daxdev_errors_sh = find_program('daxdev-errors.sh')
+multi_dax = find_program('multi-dax.sh')
+btt_check = find_program('btt-check.sh')
+label_compat = find_program('label-compat.sh')
+sector_mode = find_program('sector-mode.sh')
+inject_error = find_program('inject-error.sh')
+btt_errors = find_program('btt-errors.sh')
+btt_pad_compat = find_program('btt-pad-compat.sh')
+firmware_update = find_program('firmware-update.sh')
+rescan_partitions = find_program('rescan-partitions.sh')
+inject_smart = find_program('inject-smart.sh')
+monitor = find_program('monitor.sh')
+max_extent = find_program('max_available_extent_ns.sh')
+pfn_meta_errors = find_program('pfn-meta-errors.sh')
+track_uuid = find_program('track-uuid.sh')
+
+tests = [
+  [ 'libndctl',               libndctl ],
+  [ 'dsm-fail',               dsm_fail ],
+  [ 'create.sh',              create ],
+  [ 'clear.sh',               clear ],
+  [ 'pmem-errors.sh',         pmem_errors ],
+  [ 'daxdev-errors.sh',       daxdev_errors_sh ],
+  [ 'multi-dax.sh',           multi_dax ],
+  [ 'btt-check.sh',           btt_check ],
+  [ 'label-compat.sh',        label_compat ],
+  [ 'sector-mode.sh',         sector_mode ],
+  [ 'inject-error.sh',        inject_error ],
+  [ 'btt-errors.sh',          btt_errors ],
+  [ 'hugetlb',                hugetlb ],
+  [ 'btt-pad-compat.sh',      btt_pad_compat ],
+  [ 'firmware-update.sh',     firmware_update ],
+  [ 'ack-shutdown-count-set', ack_shutdown_count ],
+  [ 'rescan-partitions.sh',   rescan_partitions ],
+  [ 'inject-smart.sh',        inject_smart ],
+  [ 'monitor.sh',             monitor ],
+  [ 'max_extent_ns',          max_extent ],
+  [ 'pfn-meta-errors.sh',     pfn_meta_errors ],
+  [ 'track-uuid.sh',          track_uuid ],
+]
+
+if get_option('destructive').enabled()
+  sub_section = find_program('sub-section.sh')
+  dax_ext4 = find_program('dax-ext4.sh')
+  dax_xfs = find_program('dax-xfs.sh')
+  align = find_program('align.sh')
+  device_dax_fio = find_program('device-dax-fio.sh')
+  daxctl_devices = find_program('daxctl-devices.sh')
+  daxctl_create = find_program('daxctl-create.sh')
+  dm = find_program('dm.sh')
+  mmap_test = find_program('mmap.sh')
+
+  tests += [
+    [ 'pmem-ns',           pmem_ns ],
+    [ 'sub-section.sh',    sub_section ],
+    [ 'dax-dev',           dax_dev ],
+    [ 'dax-ext4.sh',       dax_ext4 ],
+    [ 'dax-xfs.sh',        dax_xfs ],
+    [ 'align.sh',          align ],
+    [ 'device-dax',        device_dax ],
+    [ 'revoke-devmem',     revoke_devmem ],
+    [ 'device-dax-fio.sh', device_dax_fio ],
+    [ 'daxctl-devices.sh', daxctl_devices ],
+    [ 'daxctl-create.sh',  daxctl_create ],
+    [ 'dm.sh',             dm ],
+    [ 'mmap.sh',           mmap_test ],
+  ]
+endif
+
+if get_option('keyutils').enabled()
+  security = find_program('security.sh')
+  tests += [
+    [ 'security.sh', security ]
+  ]
+endif
+
+foreach t : tests
+  test(t[0], t[1],
+    is_parallel : false,
+    depends : [
+      ndctl_tool,
+      daxctl_tool,
+      cxl_tool,
+      smart_notify,
+      list_smart_dimm,
+      dax_pmd,
+      dax_errors,
+      daxdev_errors,
+      dax_dev,
+      mmap,
+    ],
+    timeout : 0,
+    env : [
+      'NDCTL=@0@'.format(ndctl_tool.full_path()),
+      'DAXCTL=@0@'.format(daxctl_tool.full_path()),
+      'TEST_PATH=@0@'.format(meson.current_build_dir()),
+      'DATA_PATH=@0@'.format(meson.current_source_dir()),
+    ],
+  )
+endforeach
diff --git a/tools/meson-vcs-tag.sh b/tools/meson-vcs-tag.sh
new file mode 100755
index 000000000000..9f21c37b7d26
--- /dev/null
+++ b/tools/meson-vcs-tag.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+set -eu
+set -o pipefail
+
+dir="${1:?}"
+fallback="${2:?}"
+
+# Apparently git describe has a bug where it always considers the work-tree
+# dirty when invoked with --git-dir (even though 'git status' is happy). Work
+# around this issue by cd-ing to the source directory.
+cd "$dir"
+# Check that we have either .git/ (a normal clone) or a .git file (a work-tree)
+# and that we don't get confused if a tarball is extracted in a higher-level
+# git repository.
+[ -e .git ] && git describe --abbrev=7 --dirty=+ 2>/dev/null | \
+	sed -e 's/^v//' -e 's/-/./g' || echo "$fallback"
diff --git a/util/meson.build b/util/meson.build
new file mode 100644
index 000000000000..784b27915649
--- /dev/null
+++ b/util/meson.build
@@ -0,0 +1,16 @@
+util = static_library('util', [
+  'parse-options.c',
+  'parse-configs.c',
+  'usage.c',
+  'size.c',
+  'main.c',
+  'help.c',
+  'strbuf.c',
+  'wrapper.c',
+  'bitmap.c',
+  'abspath.c',
+  'iomem.c',
+  ],
+  include_directories : root_inc,
+)
+util_dep = declare_dependency(link_with : util)
diff --git a/version.h.in b/version.h.in
new file mode 100644
index 000000000000..dedbaf95caf7
--- /dev/null
+++ b/version.h.in
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+#define VERSION "@VCS_TAG@"


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 15/16] build: Add meson rpmbuild support
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (13 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 14/16] build: Add meson build infrastructure Dan Williams
@ 2022-01-05 21:32 ` Dan Williams
  2022-01-05 21:33 ` [ndctl PATCH v3 16/16] ndctl: Jettison autotools Dan Williams
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:32 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

Beyond being a prerequisite for removing autotools support, this capability
served as validation that the meson conversion generated all the same files
as autotools and installed them to the same expected locations.

The procedure to use the rpmbuild.sh script is:

    meson setup build
    meson compile -C build rhel/ndctl.spec
    ./rpmbuild.sh build/rhel/ndctl.spec

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 .gitignore       |    2 +-
 Makefile.am      |    2 ++
 meson.build      |    6 ++++++
 ndctl.spec.in    |   23 +++++++++++++++++++++++
 rhel/meson.build |   23 +++++++++++++++++++++++
 rpmbuild.sh      |    5 ++++-
 sles/meson.build |   36 ++++++++++++++++++++++++++++++++++++
 7 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 rhel/meson.build
 create mode 100644 sles/meson.build

diff --git a/.gitignore b/.gitignore
index 91c5e37b7fef..df8245dc10d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,7 +35,7 @@ daxctl/lib/libdaxctl.pc
 ndctl/config.h
 ndctl/lib/libndctl.pc
 ndctl/ndctl
-rhel/
+rhel/ndctl.spec
 sles/ndctl.spec
 version.m4
 *.swp
diff --git a/Makefile.am b/Makefile.am
index daea39f5d41e..b78059b0b364 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,7 @@ noinst_SCRIPTS = rhel/ndctl.spec sles/ndctl.spec
 CLEANFILES += $(noinst_SCRIPTS)
 
 do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \
+            -e 's,MESON,0,g' \
             -e 's,DAX_DNAME,daxctl-devel,g' \
             -e 's,CXL_DNAME,cxl-devel,g' \
             -e 's,DNAME,ndctl-devel,g' \
@@ -31,6 +32,7 @@ do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \
 	    -e 's,LNAME,ndctl-libs,g'
 
 do_sles_subst = sed -e 's,VERSION,$(VERSION),g' \
+            -e 's,MESON,0,g' \
             -e 's,DAX_DNAME,libdaxctl-devel,g' \
             -e 's,CXL_DNAME,libcxl-devel,g' \
             -e 's,DNAME,libndctl-devel,g' \
diff --git a/meson.build b/meson.build
index 272ac642c193..b22fb2e57f6b 100644
--- a/meson.build
+++ b/meson.build
@@ -278,3 +278,9 @@ if get_option('docs').enabled()
 endif
 subdir('test')
 subdir('contrib')
+
+# only support spec file generation from git builds
+if version_tag == ''
+  subdir('rhel')
+  subdir('sles')
+endif
diff --git a/ndctl.spec.in b/ndctl.spec.in
index cb911194a2cb..9447267839d2 100644
--- a/ndctl.spec.in
+++ b/ndctl.spec.in
@@ -6,14 +6,20 @@ License:	GPLv2
 Url:		https://github.com/pmem/ndctl
 Source0:	https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
 
+%define with_meson MESON
 Requires:	LNAME%{?_isa} = %{version}-%{release}
 Requires:	DAX_LNAME%{?_isa} = %{version}-%{release}
 Requires:	CXL_LNAME%{?_isa} = %{version}-%{release}
 BuildRequires:	autoconf
 %if 0%{?rhel} < 9
 BuildRequires:	asciidoc
+%if !%{with_meson}
 %define asciidoc --disable-asciidoctor
+%endif
 %else
+%if %{with_meson}
+%define asciidoctor -Dasciidoctor=enabled
+%endif
 BuildRequires:	rubygem-asciidoctor
 %endif
 BuildRequires:	xmlto
@@ -30,6 +36,10 @@ BuildRequires:	keyutils-libs-devel
 BuildRequires:	systemd-rpm-macros
 BuildRequires:	iniparser-devel
 
+%if %{with_meson}
+BuildRequires:	meson
+%endif
+
 %description
 Utility library for managing the "libnvdimm" subsystem.  The "libnvdimm"
 subsystem defines a kernel device model and control message interface for
@@ -117,17 +127,30 @@ libcxl is a library for enumerating and communicating with CXL devices.
 %setup -q ndctl-%{version}
 
 %build
+%if %{with_meson}
+%meson %{?asciidoctor} -Dversion-tag=%{version}
+%meson_build
+%else
 echo %{version} > version
 ./autogen.sh
 %configure --disable-static --disable-silent-rules %{?asciidoc}
 make %{?_smp_mflags}
+%endif
 
 %install
+%if %{with_meson}
+%meson_install
+%else
 %make_install
 find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
+%endif
 
 %check
+%if %{with_meson}
+%meson_test
+%else
 make check
+%endif
 
 %ldconfig_scriptlets -n LNAME
 
diff --git a/rhel/meson.build b/rhel/meson.build
new file mode 100644
index 000000000000..8672098d84e1
--- /dev/null
+++ b/rhel/meson.build
@@ -0,0 +1,23 @@
+rhel_spec1 = vcs_tag(
+    input : '../ndctl.spec.in',
+    output : 'ndctl.spec.in',
+    command: vcs_tagger,
+    replace_string : 'VERSION',
+)
+
+rhel_spec2 = custom_target('ndctl.spec',
+  command : [
+    'sed', '-e', 's,MESON,1,g',
+	   '-e', 's,DAX_DNAME,daxctl-devel,g',
+	   '-e', 's,CXL_DNAME,cxl-devel,g',
+	   '-e', 's,DNAME,ndctl-devel,g',
+	   '-e', '/^%defattr.*/d',
+	   '-e', 's,DAX_LNAME,daxctl-libs,g',
+	   '-e', 's,CXL_LNAME,cxl-libs,g',
+	   '-e', 's,LNAME,ndctl-libs,g',
+	   '@INPUT@'
+  ],
+  input : rhel_spec1,
+  output : 'ndctl.spec',
+  capture : true,
+)
diff --git a/rpmbuild.sh b/rpmbuild.sh
index fe4154b6be9f..b1f4d9e5c0f3 100755
--- a/rpmbuild.sh
+++ b/rpmbuild.sh
@@ -1,6 +1,9 @@
 #!/bin/bash
+
+spec=${1:-$(dirname $0)/rhel/ndctl.spec)}
+
 pushd $(dirname $0) >/dev/null
 [ ! -d ~/rpmbuild/SOURCES ] && echo "rpmdev tree not found" && exit 1
 ./make-git-snapshot.sh
 popd > /dev/null
-rpmbuild -ba $(dirname $0)/rhel/ndctl.spec
+rpmbuild --nocheck -ba $spec
diff --git a/sles/meson.build b/sles/meson.build
new file mode 100644
index 000000000000..21c72cb4f5ec
--- /dev/null
+++ b/sles/meson.build
@@ -0,0 +1,36 @@
+sles_spec1 = vcs_tag(
+    input : '../ndctl.spec.in',
+    output : 'ndctl.spec.sles.in',
+    command: vcs_tagger,
+    replace_string : 'VERSION',
+)
+
+header = files('header')
+
+sles_spec2 = custom_target('ndctl.spec.in',
+  command : [
+    'cat', header, '@INPUT@',
+  ],
+  input : sles_spec1,
+  output : 'ndctl.spec.in',
+  capture : true,
+)
+
+sles_spec3 = custom_target('ndctl.spec',
+  command : [
+    'sed', '-e', 's,MESON,1,g',
+           '-e', 's,DAX_DNAME,libdaxctl-devel,g',
+           '-e', 's,CXL_DNAME,libcxl-devel,g',
+           '-e', 's,DNAME,libndctl-devel,g',
+           '-e', 's,%license,%doc,g',
+           '-e', 's,\(^License:.*GPL\)v2,\1-2.0,g',
+           '-e', 's,DAX_LNAME,libdaxctl@0@,g'.format(LIBDAXCTL_CURRENT - LIBDAXCTL_AGE),
+           '-e', 's,CXL_LNAME,libcxl@0@,g'.format(LIBCXL_CURRENT - LIBCXL_AGE),
+           '-e', 's,LNAME,libndctl@0@,g'.format(LIBNDCTL_CURRENT - LIBNDCTL_AGE),
+	   '@INPUT@'
+  ],
+
+  input : sles_spec2,
+  output : 'ndctl.spec',
+  capture : true,
+)


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [ndctl PATCH v3 16/16] ndctl: Jettison autotools
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (14 preceding siblings ...)
  2022-01-05 21:32 ` [ndctl PATCH v3 15/16] build: Add meson rpmbuild support Dan Williams
@ 2022-01-05 21:33 ` Dan Williams
  2022-01-12 13:54 ` [ndctl PATCH v3 00/16] ndctl: Meson support Vaibhav Jain
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 24+ messages in thread
From: Dan Williams @ 2022-01-05 21:33 UTC (permalink / raw)
  To: vishal.l.verma; +Cc: nvdimm, linux-cxl

Similar to several other projects, ndctl has run its course with autotools
and sees a better path forward with Meson. Now that the Meson conversion is
complete, remove the autotools infrastructure.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 .gitignore                        |   58 --------
 Documentation/cxl/Makefile.am     |   61 --------
 Documentation/cxl/lib/Makefile.am |   58 --------
 Documentation/daxctl/Makefile.am  |   72 ----------
 Documentation/ndctl/Makefile.am   |  103 --------------
 Makefile.am                       |  104 --------------
 Makefile.am.in                    |   46 ------
 autogen.sh                        |   28 ----
 configure.ac                      |  270 -------------------------------------
 cxl/Makefile.am                   |   25 ---
 cxl/lib/Makefile.am               |   32 ----
 daxctl/Makefile.am                |   45 ------
 daxctl/lib/Makefile.am            |   42 ------
 ndctl.spec.in                     |   28 ----
 ndctl/Makefile.am                 |   86 ------------
 ndctl/lib/Makefile.am             |   58 --------
 rhel/meson.build                  |    3 
 sles/meson.build                  |    3 
 test/Makefile.am                  |  169 -----------------------
 19 files changed, 4 insertions(+), 1287 deletions(-)
 delete mode 100644 Documentation/cxl/Makefile.am
 delete mode 100644 Documentation/cxl/lib/Makefile.am
 delete mode 100644 Documentation/daxctl/Makefile.am
 delete mode 100644 Documentation/ndctl/Makefile.am
 delete mode 100644 Makefile.am
 delete mode 100644 Makefile.am.in
 delete mode 100755 autogen.sh
 delete mode 100644 configure.ac
 delete mode 100644 cxl/Makefile.am
 delete mode 100644 cxl/lib/Makefile.am
 delete mode 100644 daxctl/Makefile.am
 delete mode 100644 daxctl/lib/Makefile.am
 delete mode 100644 ndctl/Makefile.am
 delete mode 100644 ndctl/lib/Makefile.am
 delete mode 100644 test/Makefile.am

diff --git a/.gitignore b/.gitignore
index df8245dc10d8..aa0ce8e400c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,63 +1,5 @@
-*.o
-*.lo
-*.xml
-.deps/
-.libs/
-Makefile
-!contrib/Makefile
-Makefile.in
-/aclocal.m4
-/autom4te.cache
-/build-aux
-/config.h
-/config.log
-/config.status
-/configure
-/libtool
-/stamp-h1
-*.1
-*.3
-Documentation/daxctl/asciidoc.conf
-Documentation/ndctl/asciidoc.conf
-Documentation/cxl/asciidoc.conf
-Documentation/cxl/lib/asciidoc.conf
-Documentation/daxctl/asciidoctor-extensions.rb
-Documentation/ndctl/asciidoctor-extensions.rb
-Documentation/cxl/asciidoctor-extensions.rb
-Documentation/cxl/lib/asciidoctor-extensions.rb
-.dirstamp
 build/
-daxctl/config.h
-daxctl/daxctl
-daxctl/lib/libdaxctl.la
-daxctl/lib/libdaxctl.pc
-*.a
-ndctl/config.h
-ndctl/lib/libndctl.pc
-ndctl/ndctl
 rhel/ndctl.spec
 sles/ndctl.spec
-version.m4
 *.swp
-cscope.files
-cscope*.out
 tags
-test/*.log
-test/*.trs
-test/dax-dev
-test/dax-errors
-test/dax-pmd
-test/daxdev-errors
-test/device-dax
-test/dsm-fail
-test/hugetlb
-test/image
-test/libndctl
-test/mmap
-test/pmem-ns
-test/smart-listen
-test/smart-notify
-test/fio.job
-test/local-write-0-verify.state
-test/ack-shutdown-count-set
-test/list-smart-dimm
diff --git a/Documentation/cxl/Makefile.am b/Documentation/cxl/Makefile.am
deleted file mode 100644
index efabaa37027f..000000000000
--- a/Documentation/cxl/Makefile.am
+++ /dev/null
@@ -1,61 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2020-2021 Intel Corporation. All rights reserved.
-
-if USE_ASCIIDOCTOR
-
-do_subst = sed -e 's,@Utility@,Cxl,g' -e's,@utility@,cxl,g'
-CONFFILE = asciidoctor-extensions.rb
-asciidoctor-extensions.rb: ../asciidoctor-extensions.rb.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-else
-
-do_subst = sed -e 's,UTILITY,cxl,g'
-CONFFILE = asciidoc.conf
-asciidoc.conf: ../asciidoc.conf.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-endif
-
-man1_MANS = \
-	cxl.1 \
-	cxl-list.1 \
-	cxl-read-labels.1 \
-	cxl-write-labels.1 \
-	cxl-zero-labels.1
-
-EXTRA_DIST = $(man1_MANS)
-
-CLEANFILES = $(man1_MANS)
-
-XML_DEPS = \
-	../../version.m4 \
-	../copyright.txt \
-	Makefile \
-	$(CONFFILE)
-
-RM ?= rm -f
-
-if USE_ASCIIDOCTOR
-
-%.1: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b manpage -d manpage -acompat-mode \
-		-I. -rasciidoctor-extensions \
-		-amansource=cxl -amanmanual="cxl Manual" \
-		-andctl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-else
-
-%.xml: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
-		--unsafe -acxl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-%.1: %.xml $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@ && \
-		$(XMLTO) -o . -m ../manpage-normal.xsl man $<
-
-endif
diff --git a/Documentation/cxl/lib/Makefile.am b/Documentation/cxl/lib/Makefile.am
deleted file mode 100644
index 41e3a5fc02b6..000000000000
--- a/Documentation/cxl/lib/Makefile.am
+++ /dev/null
@@ -1,58 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2020-2021 Intel Corporation. All rights reserved.
-
-if USE_ASCIIDOCTOR
-
-do_subst = sed -e 's,@Utility@,Libcxl,g' -e's,@utility@,libcxl,g'
-CONFFILE = asciidoctor-extensions.rb
-asciidoctor-extensions.rb: ../../asciidoctor-extensions.rb.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-else
-
-do_subst = sed -e 's,UTILITY,libcxl,g'
-CONFFILE = asciidoc.conf
-asciidoc.conf: ../../asciidoc.conf.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-endif
-
-man3_MANS = \
-	libcxl.3 \
-	cxl_new.3
-
-EXTRA_DIST = $(man3_MANS)
-
-CLEANFILES = $(man3_MANS)
-
-XML_DEPS = \
-	../../../version.m4 \
-	../../copyright.txt \
-	Makefile \
-	$(CONFFILE)
-
-RM ?= rm -f
-
-if USE_ASCIIDOCTOR
-
-%.3: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b manpage -d manpage -acompat-mode \
-		-I. -rasciidoctor-extensions \
-		-amansource=libcxl -amanmanual="libcxl Manual" \
-		-andctl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-else
-
-%.xml: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
-		--unsafe -alibcxl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-%.3: %.xml $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@ && \
-		$(XMLTO) -o . -m ../../manpage-normal.xsl man $<
-
-endif
diff --git a/Documentation/daxctl/Makefile.am b/Documentation/daxctl/Makefile.am
deleted file mode 100644
index 78c47f5055c4..000000000000
--- a/Documentation/daxctl/Makefile.am
+++ /dev/null
@@ -1,72 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
-
-if USE_ASCIIDOCTOR
-
-do_subst = sed -e 's,@Utility@,Daxctl,g' -e's,@utility@,daxctl,g'
-CONFFILE = asciidoctor-extensions.rb
-asciidoctor-extensions.rb: ../asciidoctor-extensions.rb.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-else
-
-do_subst = sed -e 's,UTILITY,daxctl,g'
-CONFFILE = asciidoc.conf
-asciidoc.conf: ../asciidoc.conf.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-endif
-
-man1_MANS = \
-	daxctl.1 \
-	daxctl-list.1 \
-	daxctl-migrate-device-model.1 \
-	daxctl-reconfigure-device.1 \
-	daxctl-online-memory.1 \
-	daxctl-offline-memory.1 \
-	daxctl-disable-device.1 \
-	daxctl-enable-device.1 \
-	daxctl-create-device.1 \
-	daxctl-destroy-device.1
-
-EXTRA_DIST = $(man1_MANS)
-
-CLEANFILES = $(man1_MANS)
-
-XML_DEPS = \
-	../../version.m4 \
-	../copyright.txt \
-	Makefile \
-	$(CONFFILE)
-
-RM ?= rm -f
-
-if USE_ASCIIDOCTOR
-
-%.1: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b manpage -d manpage -acompat-mode \
-		-I. -rasciidoctor-extensions \
-		-amansource=daxctl -amanmanual="daxctl Manual" \
-		-adaxctl_confdir=$(daxctl_confdir) \
-		-adaxctl_conf=$(daxctl_conf) \
-		-andctl_keysdir=$(ndctl_keysdir) \
-		-andctl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-else
-
-%.xml: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
-		-adaxctl_confdir=$(daxctl_confdir) \
-		-adaxctl_conf=$(daxctl_conf) \
-		-andctl_keysdir=$(ndctl_keysdir) \
-		--unsafe -adaxctl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-%.1: %.xml $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@ && \
-		$(XMLTO) -o . -m ../manpage-normal.xsl man $<
-
-endif
diff --git a/Documentation/ndctl/Makefile.am b/Documentation/ndctl/Makefile.am
deleted file mode 100644
index 203158c1dfaf..000000000000
--- a/Documentation/ndctl/Makefile.am
+++ /dev/null
@@ -1,103 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
-
-if USE_ASCIIDOCTOR
-
-do_subst = sed -e 's,@Utility@,Ndctl,g' -e's,@utility@,ndctl,g'
-CONFFILE = asciidoctor-extensions.rb
-asciidoctor-extensions.rb: ../asciidoctor-extensions.rb.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-else
-
-do_subst = sed -e 's,UTILITY,ndctl,g'
-CONFFILE = asciidoc.conf
-asciidoc.conf: ../asciidoc.conf.in
-	$(AM_V_GEN) $(do_subst) < $< > $@
-
-endif
-
-man1_MANS = \
-	ndctl.1 \
-	ndctl-wait-scrub.1 \
-	ndctl-start-scrub.1 \
-	ndctl-zero-labels.1 \
-	ndctl-read-labels.1 \
-	ndctl-write-labels.1 \
-	ndctl-init-labels.1 \
-	ndctl-check-labels.1 \
-	ndctl-enable-region.1 \
-	ndctl-disable-region.1 \
-	ndctl-enable-dimm.1 \
-	ndctl-disable-dimm.1 \
-	ndctl-enable-namespace.1 \
-	ndctl-disable-namespace.1 \
-	ndctl-create-namespace.1 \
-	ndctl-destroy-namespace.1 \
-	ndctl-check-namespace.1 \
-	ndctl-clear-errors.1 \
-	ndctl-inject-error.1 \
-	ndctl-inject-smart.1 \
-	ndctl-update-firmware.1 \
-	ndctl-list.1 \
-	ndctl-monitor.1 \
-	ndctl-setup-passphrase.1 \
-	ndctl-update-passphrase.1 \
-	ndctl-remove-passphrase.1 \
-	ndctl-freeze-security.1 \
-	ndctl-sanitize-dimm.1 \
-	ndctl-load-keys.1 \
-	ndctl-wait-overwrite.1 \
-	ndctl-read-infoblock.1 \
-	ndctl-write-infoblock.1 \
-	ndctl-activate-firmware.1
-
-EXTRA_DIST = $(man1_MANS)
-
-CLEANFILES = $(man1_MANS)
-
-XML_DEPS = \
-	../../version.m4 \
-	Makefile \
-	$(CONFFILE) \
-	../copyright.txt \
-	region-description.txt \
-	xable-region-options.txt \
-	dimm-description.txt \
-	xable-dimm-options.txt \
-	xable-namespace-options.txt \
-	ars-description.txt \
-	labels-description.txt \
-	labels-options.txt
-
-RM ?= rm -f
-
-if USE_ASCIIDOCTOR
-
-%.1: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b manpage -d manpage -acompat-mode \
-		-I. -rasciidoctor-extensions \
-		-amansource=ndctl -amanmanual="ndctl Manual" \
-		-andctl_confdir=$(ndctl_confdir) \
-		-andctl_monitorconf=$(ndctl_monitorconf) \
-		-andctl_keysdir=$(ndctl_keysdir) \
-		-andctl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-else
-
-%.xml: %.txt $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@+ $@ && \
-		$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
-		-andctl_confdir=$(ndctl_confdir) \
-		-andctl_monitorconf=$(ndctl_monitorconf) \
-		-andctl_keysdir=$(ndctl_keysdir) \
-		--unsafe -andctl_version=$(VERSION) -o $@+ $< && \
-		mv $@+ $@
-
-%.1: %.xml $(XML_DEPS)
-	$(AM_V_GEN)$(RM) $@ && \
-		$(XMLTO) -o . -m ../manpage-normal.xsl man $<
-
-endif
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index b78059b0b364..000000000000
--- a/Makefile.am
+++ /dev/null
@@ -1,104 +0,0 @@
-include Makefile.am.in
-
-ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-SUBDIRS = . cxl/lib daxctl/lib ndctl/lib cxl ndctl daxctl
-if ENABLE_DOCS
-SUBDIRS += Documentation/ndctl Documentation/daxctl Documentation/cxl
-SUBDIRS += Documentation/cxl/lib
-endif
-SUBDIRS += test
-
-BUILT_SOURCES = version.m4
-version.m4: FORCE
-	$(AM_V_GEN)$(top_srcdir)/git-version-gen
-
-FORCE:
-
-EXTRA_DIST += ndctl.spec.in \
-		sles/header \
-		contrib/nvdimm-security.conf
-
-noinst_SCRIPTS = rhel/ndctl.spec sles/ndctl.spec
-CLEANFILES += $(noinst_SCRIPTS)
-
-do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \
-            -e 's,MESON,0,g' \
-            -e 's,DAX_DNAME,daxctl-devel,g' \
-            -e 's,CXL_DNAME,cxl-devel,g' \
-            -e 's,DNAME,ndctl-devel,g' \
-            -e '/^%defattr.*/d' \
-	    -e 's,DAX_LNAME,daxctl-libs,g' \
-	    -e 's,CXL_LNAME,cxl-libs,g' \
-	    -e 's,LNAME,ndctl-libs,g'
-
-do_sles_subst = sed -e 's,VERSION,$(VERSION),g' \
-            -e 's,MESON,0,g' \
-            -e 's,DAX_DNAME,libdaxctl-devel,g' \
-            -e 's,CXL_DNAME,libcxl-devel,g' \
-            -e 's,DNAME,libndctl-devel,g' \
-            -e 's,%license,%doc,g' \
-            -e 's,\(^License:.*GPL\)v2,\1-2.0,g' \
-            -e "s,DAX_LNAME,libdaxctl$$(($(LIBDAXCTL_CURRENT) - $(LIBDAXCTL_AGE))),g" \
-            -e "s,CXL_LNAME,libcxl$$(($(LIBCXL_CURRENT) - $(LIBCXL_AGE))),g" \
-            -e "s,LNAME,libndctl$$(($(LIBNDCTL_CURRENT) - $(LIBNDCTL_AGE))),g"
-
-rhel/ndctl.spec: ndctl.spec.in Makefile.am version.m4
-	$(AM_V_GEN)$(MKDIR_P) rhel; $(do_rhel_subst) < $< > $@
-
-sles/ndctl.spec: sles/header ndctl.spec.in Makefile.am version.m4
-	$(AM_V_GEN)$(MKDIR_P) sles; cat sles/header $< | $(do_sles_subst) > $@
-
-if ENABLE_BASH_COMPLETION
-bashcompletiondir = $(BASH_COMPLETION_DIR)
-dist_bashcompletion_DATA = contrib/ndctl
-install-data-hook:
-	$(LN_S) -f $(BASH_COMPLETION_DIR)/ndctl $(DESTDIR)/$(BASH_COMPLETION_DIR)/daxctl
-	$(LN_S) -f $(BASH_COMPLETION_DIR)/ndctl $(DESTDIR)/$(BASH_COMPLETION_DIR)/cxl
-endif
-
-modprobe_file = contrib/nvdimm-security.conf
-modprobedir = $(sysconfdir)/modprobe.d/
-modprobe_DATA = $(modprobe_file)
-
-noinst_LIBRARIES = libccan.a
-libccan_a_SOURCES = \
-	ccan/str/str.h \
-	ccan/str/str_debug.h \
-	ccan/str/str.c \
-	ccan/str/debug.c \
-	ccan/list/list.h \
-	ccan/list/list.c \
-	ccan/container_of/container_of.h \
-	ccan/check_type/check_type.h \
-	ccan/build_assert/build_assert.h \
-	ccan/array_size/array_size.h \
-	ccan/minmax/minmax.h \
-	ccan/short_types/short_types.h \
-	ccan/endian/endian.h
-
-noinst_LIBRARIES += libutil.a
-libutil_a_SOURCES = \
-	util/parse-options.c \
-	util/parse-options.h \
-	util/parse-configs.c \
-	util/parse-configs.h \
-	util/usage.c \
-	util/size.c \
-	util/main.c \
-	util/help.c \
-	util/strbuf.c \
-	util/wrapper.c \
-	util/bitmap.c \
-	util/abspath.c \
-	util/iomem.c \
-	util/util.h \
-	util/strbuf.h \
-	util/size.h \
-	util/main.h \
-	util/filter.h \
-	util/bitmap.h
-
-nobase_include_HEADERS = \
-	daxctl/libdaxctl.h \
-	cxl/libcxl.h \
-	cxl/cxl_mem.h
diff --git a/Makefile.am.in b/Makefile.am.in
deleted file mode 100644
index d6b126986bb4..000000000000
--- a/Makefile.am.in
+++ /dev/null
@@ -1,46 +0,0 @@
-EXTRA_DIST =
-CLEANFILES =
-
-AM_MAKEFLAGS = --no-print-directory
-
-AM_CPPFLAGS = \
-	-include $(top_builddir)/config.h \
-	-DSYSCONFDIR=\""$(sysconfdir)"\" \
-	-DLIBEXECDIR=\""$(libexecdir)"\" \
-	-DPREFIX=\""$(prefix)"\" \
-	-DNDCTL_MAN_PATH=\""$(mandir)"\" \
-	-I${top_srcdir}/ \
-	$(KMOD_CFLAGS) \
-	$(UDEV_CFLAGS) \
-	$(UUID_CFLAGS) \
-	$(JSON_CFLAGS)
-
-AM_CFLAGS = ${my_CFLAGS} \
-	-fvisibility=hidden \
-	-ffunction-sections \
-	-fdata-sections
-
-AM_LDFLAGS = \
-	-Wl,--gc-sections \
-	-Wl,--as-needed
-
-SED_PROCESS = \
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
-	-e 's,@VERSION\@,$(VERSION),g' \
-	-e 's,@prefix\@,$(prefix),g' \
-	-e 's,@exec_prefix\@,$(exec_prefix),g' \
-	-e 's,@libdir\@,$(libdir),g' \
-	-e 's,@includedir\@,$(includedir),g' \
-	< $< > $@ || rm $@
-
-LIBNDCTL_CURRENT=26
-LIBNDCTL_REVISION=1
-LIBNDCTL_AGE=20
-
-LIBDAXCTL_CURRENT=7
-LIBDAXCTL_REVISION=0
-LIBDAXCTL_AGE=6
-
-LIBCXL_CURRENT=1
-LIBCXL_REVISION=0
-LIBCXL_AGE=0
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 2a52688bb403..000000000000
--- a/autogen.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh -e
-
-if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
-        cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
-        chmod +x .git/hooks/pre-commit && \
-        echo "Activated pre-commit hook."
-fi
-
-$(dirname $0)/git-version-gen
-reconf_args=''
-[ -n "$*" ] && reconf_args="$*"
-autoreconf --install --symlink $reconf_args
-
-libdir() {
-        echo $(cd $1/$(gcc -print-multi-os-directory); pwd)
-}
-
-args="--prefix=/usr \
---sysconfdir=/etc \
---libdir=$(libdir /usr/lib)"
-
-echo
-echo "----------------------------------------------------------------"
-echo "Initialized build system. For a common configuration please run:"
-echo "----------------------------------------------------------------"
-echo
-echo "./configure CFLAGS='-g -O2' $args"
-echo
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 1b18ed755c98..000000000000
--- a/configure.ac
+++ /dev/null
@@ -1,270 +0,0 @@
-AC_PREREQ(2.60)
-m4_include([version.m4])
-AC_INIT([ndctl],
-        GIT_VERSION,
-        [nvdimm@lists.linux.dev],
-        [ndctl],
-        [https://github.com/pmem/ndctl])
-AC_CONFIG_SRCDIR([ndctl/lib/libndctl.c])
-AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE([
-	foreign
-	1.11
-	-Wall
-	-Wno-portability
-	silent-rules
-	tar-pax
-	no-dist-gzip
-	dist-xz
-	subdir-objects
-])
-AC_PROG_CC_STDC
-AC_USE_SYSTEM_EXTENSIONS
-AC_SYS_LARGEFILE
-AC_CONFIG_MACRO_DIR([m4])
-AM_SILENT_RULES([yes])
-LT_INIT([
-	disable-static
-	pic-only
-])
-AC_PREFIX_DEFAULT([/usr])
-
-AC_PROG_SED
-AC_PROG_MKDIR_P
-AC_PROG_LN_S
-
-AC_ARG_ENABLE([docs],
-        AS_HELP_STRING([--disable-docs],
-	[disable documentation build @<:@default=enabled@:>@]),
-        [], enable_docs=yes)
-AS_IF([test "x$enable_docs" = "xyes"], [
-        AC_DEFINE(ENABLE_DOCS, [1], [Documentation / man pages.])
-])
-AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" = "xyes"])
-
-AC_ARG_ENABLE([asciidoctor],
-	AS_HELP_STRING([--enable-asciidoctor],
-	[use asciidoctor for documentation build]),
-	[], enable_asciidoctor=yes)
-AM_CONDITIONAL([USE_ASCIIDOCTOR], [test "x$enable_asciidoctor" = "xyes"])
-if test "x$enable_asciidoctor" = "xyes"; then
-	asciidoc="asciidoctor"
-else
-	asciidoc="asciidoc"
-fi
-AC_CHECK_PROG(ASCIIDOC, [$asciidoc], [$(which $asciidoc)], [missing])
-if test "x$ASCIIDOC" = xmissing -a "x$enable_docs" = "xyes"; then
-	AC_MSG_ERROR([$asciidoc needed to build documentation])
-fi
-AC_SUBST([ASCIIDOC])
-
-if test x"$asciidoc" = x"asciidoc"; then
-AC_CHECK_PROG(XMLTO, [xmlto], [$(which xmlto)], [missing])
-if test "x$XMLTO" = xmissing -a "x$enable_docs" = "xyes"; then
-       AC_MSG_ERROR([xmlto needed to build documentation])
-fi
-AC_SUBST([XMLTO])
-fi
-
-AC_C_TYPEOF
-AC_DEFINE([HAVE_STATEMENT_EXPR], 1, [Define to 1 if you have statement expressions.])
-
-AC_C_BIGENDIAN(
-	AC_DEFINE(HAVE_BIG_ENDIAN, 1, [Define to 1 if big-endian-arch]),
-	AC_DEFINE(HAVE_LITTLE_ENDIAN, 1, [Define to 1 if little-endian-arch]),
-	[], [])
-
-AC_ARG_ENABLE([logging],
-        AS_HELP_STRING([--disable-logging], [disable system logging @<:@default=enabled@:>@]),
-        [], enable_logging=yes)
-AS_IF([test "x$enable_logging" = "xyes"], [
-        AC_DEFINE(ENABLE_LOGGING, [1], [System logging.])
-])
-
-AC_ARG_ENABLE([debug],
-        AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
-        [], [enable_debug=no])
-AS_IF([test "x$enable_debug" = "xyes"], [
-        AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
-])
-
-AC_ARG_ENABLE([destructive],
-        AS_HELP_STRING([--enable-destructive], [enable destructive functional tests @<:@default=disabled@:>@]),
-        [], [enable_destructive=no])
-AS_IF([test "x$enable_destructive" = "xyes"],
-	[AC_DEFINE([ENABLE_DESTRUCTIVE], [1], [destructive functional tests support])])
-AM_CONDITIONAL([ENABLE_DESTRUCTIVE], [test "x$enable_destructive" = "xyes"])
-
-AC_ARG_ENABLE([test],
-        AS_HELP_STRING([--enable-test], [enable ndctl test command @<:@default=disabled@:>@]),
-        [], [enable_test=$enable_destructive])
-AS_IF([test "x$enable_test" = "xyes"],
-	[AC_DEFINE([ENABLE_TEST], [1], [ndctl test support])])
-AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = "xyes"])
-
-AC_CHECK_DECLS([BUS_MCEERR_AR], [enable_bus_mc_err=yes], [], [[#include <signal.h>]])
-AC_CHECK_DECLS([MAP_SHARED_VALIDATE], [kernel_map_shared_validate=yes], [], [[#include <linux/mman.h>]])
-AC_CHECK_DECLS([MAP_SYNC], [kernel_map_sync=yes], [], [[#include <linux/mman.h>]])
-AS_UNSET([ac_cv_have_decl_MAP_SHARED_VALIDATE])
-AS_UNSET([ac_cv_have_decl_MAP_SYNC])
-AC_CHECK_DECLS([MAP_SHARED_VALIDATE], [enable_map_shared_validate=yes], [], [[#include <sys/mman.h>]])
-AC_CHECK_DECLS([MAP_SYNC], [enable_map_sync=yes], [], [[#include <sys/mman.h>]])
-
-if test "x$kernel_map_shared_validate" = "xyes" -a "x$enable_map_shared_validate" != "xyes" ; then
-	AC_MSG_WARN([MAP_SHARED_VALIDATE supported by kernel but not by <sys/mman.h>, consider installing glibc-2.28 or later.])
-fi
-if test "x$kernel_map_shared_validate" != "xyes" -a "x$enable_map_shared_validate" != "xyes" ; then
-	AC_MSG_WARN([MAP_SHARED_VALIDATE not supported by kernel, consider installing kernel-4.15 or later.])
-fi
-if test "x$kernel_map_sync" = "xyes" -a "x$enable_map_sync" != "xyes" ; then
-	AC_MSG_WARN([MAP_SYNC supported by kernel but not by <sys/mman.h>, consider installing glibc-2.28 or later.])
-fi
-if test "x$kernel_map_sync" != "xyes" -a "x$enable_map_sync" != "xyes" ; then
-	AC_MSG_WARN([MAP_SYNC not supported by kernel or architecture, consider installing kernel-4.15 or later.])
-fi
-
-AS_IF([test "x$enable_bus_mc_err" = "xyes" -a "x$enable_map_sync" = "xyes" -a "x$enable_map_shared_validate" = "xyes"],
-	[AC_DEFINE([ENABLE_POISON], [1], [ndctl test poison support])])
-AM_CONDITIONAL([ENABLE_POISON],
-	[test "x$enable_bus_mc_err" = "xyes" -a "x$enable_map_sync" = "xyes" -a "x$enable_map_shared_validate" = "xyes"])
-
-PKG_CHECK_MODULES([KMOD], [libkmod])
-PKG_CHECK_MODULES([UDEV], [libudev])
-PKG_CHECK_MODULES([UUID], [uuid],
-	[AC_DEFINE([HAVE_UUID], [1], [Define to 1 if using libuuid])])
-PKG_CHECK_MODULES([JSON], [json-c])
-
-AC_ARG_WITH([bash],
-	AS_HELP_STRING([--with-bash],
-		[Enable bash auto-completion. @<:@default=yes@:>@]),
-	[],
-	[with_bash=yes])
-
-if test "x$with_bash" = "xyes"; then
-	PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
-		[BASH_COMPLETION_DIR=$($PKG_CONFIG --variable=completionsdir bash-completion)], [])
-fi
-
-AC_SUBST([BASH_COMPLETION_DIR])
-AM_CONDITIONAL([ENABLE_BASH_COMPLETION], [test "x$with_bash" = "xyes"])
-
-AC_ARG_ENABLE([local],
-        AS_HELP_STRING([--disable-local], [build against kernel ndctl.h @<:@default=system@:>@]),
-        [], [enable_local=yes])
-
-AC_CHECK_HEADERS_ONCE([linux/version.h])
-
-AC_CHECK_FUNCS([ \
-	__secure_getenv \
-	secure_getenv\
-])
-
-AC_ARG_WITH([systemd],
-	AS_HELP_STRING([--with-systemd],
-		[Enable systemd functionality. @<:@default=yes@:>@]),
-	[], [with_systemd=yes])
-
-if test "x$with_systemd" = "xyes"; then
-	PKG_CHECK_MODULES([SYSTEMD], [systemd],
-	[systemd_unitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)], [])
-fi
-
-AC_SUBST([systemd_unitdir])
-AM_CONDITIONAL([ENABLE_SYSTEMD_UNITS], [test "x$with_systemd" = "xyes"])
-
-ndctl_confdir=${sysconfdir}/ndctl.conf.d
-ndctl_conf=ndctl.conf
-ndctl_monitorconf=monitor.conf
-AC_SUBST([ndctl_confdir])
-AC_SUBST([ndctl_conf])
-AC_SUBST([ndctl_monitorconf])
-
-daxctl_confdir=${sysconfdir}/daxctl.conf.d
-AC_SUBST([daxctl_confdir])
-
-daxctl_modprobe_datadir=${datadir}/daxctl
-daxctl_modprobe_data=daxctl.conf
-AC_SUBST([daxctl_modprobe_datadir])
-AC_SUBST([daxctl_modprobe_data])
-
-AC_ARG_WITH(udevrulesdir,
-    [AS_HELP_STRING([--with-udevrulesdir=DIR], [udev rules.d directory])],
-    [UDEVRULESDIR="$withval"],
-    [UDEVRULESDIR='${prefix}/lib/udev/rules.d']
-)
-AC_SUBST(UDEVRULESDIR)
-
-AC_ARG_WITH([keyutils],
-	    AS_HELP_STRING([--with-keyutils],
-			[Enable keyutils functionality (security).  @<:@default=yes@:>@]), [], [with_keyutils=yes])
-
-if test "x$with_keyutils" = "xyes"; then
-	AC_CHECK_HEADERS([keyutils.h],,[
-		AC_MSG_ERROR([keyutils.h not found, consider installing the keyutils library development package (variously named keyutils-libs-devel, keyutils-devel, or libkeyutils-dev).])
-		])
-fi
-AS_IF([test "x$with_keyutils" = "xyes"],
-	[AC_DEFINE([ENABLE_KEYUTILS], [1], [Enable keyutils support])])
-AM_CONDITIONAL([ENABLE_KEYUTILS], [test "x$with_keyutils" = "xyes"])
-
-ndctl_keysdir=${sysconfdir}/ndctl/keys
-ndctl_keysreadme=keys.readme
-AC_SUBST([ndctl_keysdir])
-AC_SUBST([ndctl_keysreadme])
-
-AC_CHECK_HEADERS([iniparser.h],,[
-		  AC_MSG_ERROR([iniparser.h not found, install iniparser-devel, libiniparser-dev, or so])
-		 ])
-
-my_CFLAGS="\
--Wall \
--Wchar-subscripts \
--Wformat-security \
--Wmissing-declarations \
--Wmissing-prototypes \
--Wnested-externs \
--Wshadow \
--Wsign-compare \
--Wstrict-prototypes \
--Wtype-limits \
--Wmaybe-uninitialized \
--Wdeclaration-after-statement \
--Wunused-result \
--D_FORTIFY_SOURCE=2 \
--O2
-"
-AC_SUBST([my_CFLAGS])
-
-AC_CONFIG_HEADERS(config.h)
-AC_CONFIG_FILES([
-        Makefile
-        daxctl/lib/Makefile
-        cxl/lib/Makefile
-        ndctl/lib/Makefile
-        ndctl/Makefile
-        daxctl/Makefile
-        cxl/Makefile
-        test/Makefile
-        Documentation/ndctl/Makefile
-        Documentation/daxctl/Makefile
-        Documentation/cxl/Makefile
-        Documentation/cxl/lib/Makefile
-])
-
-AC_OUTPUT
-AC_MSG_RESULT([
-        $PACKAGE $VERSION
-        =====
-
-        prefix:                 ${prefix}
-        sysconfdir:             ${sysconfdir}
-        libdir:                 ${libdir}
-        includedir:             ${includedir}
-
-        compiler:               ${CC}
-        cflags:                 ${CFLAGS}
-        ldflags:                ${LDFLAGS}
-
-        logging:                ${enable_logging}
-        debug:                  ${enable_debug}
-])
diff --git a/cxl/Makefile.am b/cxl/Makefile.am
deleted file mode 100644
index ee8488900a3b..000000000000
--- a/cxl/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-include $(top_srcdir)/Makefile.am.in
-
-bin_PROGRAMS = cxl
-
-DISTCLEANFILES = config.h
-BUILT_SOURCES = config.h
-config.h: $(srcdir)/Makefile.am
-	$(AM_V_GEN) echo "/* Autogenerated by cxl/Makefile.am */" >$@
-
-cxl_SOURCES =\
-		cxl.c \
-		list.c \
-		memdev.c \
-		../util/json.c \
-		json.c \
-		filter.c \
-		filter.h \
-		builtin.h
-
-cxl_LDADD =\
-	lib/libcxl.la \
-	../libutil.a \
-	$(UUID_LIBS) \
-	$(KMOD_LIBS) \
-	$(JSON_LIBS)
diff --git a/cxl/lib/Makefile.am b/cxl/lib/Makefile.am
deleted file mode 100644
index 72c9ccdc3c49..000000000000
--- a/cxl/lib/Makefile.am
+++ /dev/null
@@ -1,32 +0,0 @@
-include $(top_srcdir)/Makefile.am.in
-
-%.pc: %.pc.in Makefile
-	$(SED_PROCESS)
-
-pkginclude_HEADERS = ../libcxl.h ../cxl_mem.h
-lib_LTLIBRARIES = libcxl.la
-
-libcxl_la_SOURCES =\
-	../libcxl.h \
-	private.h \
-	../../util/sysfs.c \
-	../../util/sysfs.h \
-	../../util/log.c \
-	../../util/log.h \
-	libcxl.c
-
-libcxl_la_LIBADD =\
-	$(UUID_LIBS) \
-	$(KMOD_LIBS)
-
-EXTRA_DIST += libcxl.sym
-
-libcxl_la_LDFLAGS = $(AM_LDFLAGS) \
-	-version-info $(LIBCXL_CURRENT):$(LIBCXL_REVISION):$(LIBCXL_AGE) \
-	-Wl,--version-script=$(top_srcdir)/cxl/lib/libcxl.sym
-libcxl_la_DEPENDENCIES = libcxl.sym
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libcxl.pc
-EXTRA_DIST += libcxl.pc.in
-CLEANFILES += libcxl.pc
diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am
deleted file mode 100644
index bbf764f8081f..000000000000
--- a/daxctl/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-include $(top_srcdir)/Makefile.am.in
-
-bin_PROGRAMS = daxctl
-
-DISTCLEANFILES = config.h
-BUILT_SOURCES = config.h
-config.h: $(srcdir)/Makefile.am
-	$(AM_V_GEN) echo "/* Autogenerated by daxctl/Makefile.am */" >$@ && \
-	echo '#define DAXCTL_MODPROBE_DATA \
-		"$(daxctl_modprobe_datadir)/$(daxctl_modprobe_data)"' >>$@ && \
-	echo '#define DAXCTL_MODPROBE_INSTALL \
-		"$(sysconfdir)/modprobe.d/$(daxctl_modprobe_data)"' >>$@
-
-daxctl_SOURCES =\
-		daxctl.c \
-		acpi.c \
-		list.c \
-		migrate.c \
-		device.c \
-		../util/json.c \
-		../util/json.h \
-		json.c \
-		json.h \
-		filter.c \
-		filter.h \
-		builtin.h
-
-daxctl_LDADD =\
-	lib/libdaxctl.la \
-	../ndctl/lib/libndctl.la \
-	../libutil.a \
-	$(UUID_LIBS) \
-	$(KMOD_LIBS) \
-	$(JSON_LIBS) \
-	-liniparser
-
-udevrulesdir = $(UDEVRULESDIR)
-udevrules_DATA = 90-daxctl-device.rules
-
-daxctl_configdir = $(daxctl_confdir)
-daxctl_config_DATA = daxctl.example.conf
-
-if ENABLE_SYSTEMD_UNITS
-systemd_unit_DATA = daxdev-reconfigure@.service
-endif
diff --git a/daxctl/lib/Makefile.am b/daxctl/lib/Makefile.am
deleted file mode 100644
index 3c47a4bbe580..000000000000
--- a/daxctl/lib/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-include $(top_srcdir)/Makefile.am.in
-
-%.pc: %.pc.in Makefile
-	$(SED_PROCESS)
-
-DISTCLEANFILES = config.h
-BUILT_SOURCES = config.h
-config.h: $(srcdir)/Makefile.am
-	$(AM_V_GEN) echo "/* Autogenerated by daxctl/Makefile.am */" >$@ && \
-		echo '#define DAXCTL_CONF_DIR  "$(daxctl_confdir)"' >>$@
-
-pkginclude_HEADERS = ../libdaxctl.h
-lib_LTLIBRARIES = libdaxctl.la
-
-libdaxctl_la_SOURCES =\
-	../libdaxctl.h \
-	libdaxctl-private.h \
-	../../util/iomem.c \
-	../../util/iomem.h \
-	../../util/sysfs.c \
-	../../util/sysfs.h \
-	../../util/log.c \
-	../../util/log.h \
-	libdaxctl.c
-
-libdaxctl_la_LIBADD =\
-	$(UUID_LIBS) \
-	$(KMOD_LIBS)
-
-daxctl_modprobe_data_DATA = daxctl.conf
-
-EXTRA_DIST += libdaxctl.sym daxctl.conf
-
-libdaxctl_la_LDFLAGS = $(AM_LDFLAGS) \
-	-version-info $(LIBDAXCTL_CURRENT):$(LIBDAXCTL_REVISION):$(LIBDAXCTL_AGE) \
-	-Wl,--version-script=$(top_srcdir)/daxctl/lib/libdaxctl.sym
-libdaxctl_la_DEPENDENCIES = libdaxctl.sym
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libdaxctl.pc
-EXTRA_DIST += libdaxctl.pc.in
-CLEANFILES += libdaxctl.pc
diff --git a/ndctl.spec.in b/ndctl.spec.in
index 9447267839d2..7e838f4bf199 100644
--- a/ndctl.spec.in
+++ b/ndctl.spec.in
@@ -6,21 +6,16 @@ License:	GPLv2
 Url:		https://github.com/pmem/ndctl
 Source0:	https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
 
-%define with_meson MESON
 Requires:	LNAME%{?_isa} = %{version}-%{release}
 Requires:	DAX_LNAME%{?_isa} = %{version}-%{release}
 Requires:	CXL_LNAME%{?_isa} = %{version}-%{release}
 BuildRequires:	autoconf
 %if 0%{?rhel} < 9
 BuildRequires:	asciidoc
-%if !%{with_meson}
-%define asciidoc --disable-asciidoctor
-%endif
+%define asciidoctor -Dasciidoctor=disabled
 %else
-%if %{with_meson}
-%define asciidoctor -Dasciidoctor=enabled
-%endif
 BuildRequires:	rubygem-asciidoctor
+%define asciidoctor -Dasciidoctor=enabled
 %endif
 BuildRequires:	xmlto
 BuildRequires:	automake
@@ -35,10 +30,7 @@ BuildRequires:	pkgconfig(systemd)
 BuildRequires:	keyutils-libs-devel
 BuildRequires:	systemd-rpm-macros
 BuildRequires:	iniparser-devel
-
-%if %{with_meson}
 BuildRequires:	meson
-%endif
 
 %description
 Utility library for managing the "libnvdimm" subsystem.  The "libnvdimm"
@@ -127,30 +119,14 @@ libcxl is a library for enumerating and communicating with CXL devices.
 %setup -q ndctl-%{version}
 
 %build
-%if %{with_meson}
 %meson %{?asciidoctor} -Dversion-tag=%{version}
 %meson_build
-%else
-echo %{version} > version
-./autogen.sh
-%configure --disable-static --disable-silent-rules %{?asciidoc}
-make %{?_smp_mflags}
-%endif
 
 %install
-%if %{with_meson}
 %meson_install
-%else
-%make_install
-find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
-%endif
 
 %check
-%if %{with_meson}
 %meson_test
-%else
-make check
-%endif
 
 %ldconfig_scriptlets -n LNAME
 
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
deleted file mode 100644
index 5d5b1cacda9d..000000000000
--- a/ndctl/Makefile.am
+++ /dev/null
@@ -1,86 +0,0 @@
-include $(top_srcdir)/Makefile.am.in
-
-bin_PROGRAMS = ndctl
-
-DISTCLEANFILES = config.h
-BUILT_SOURCES = config.h
-config.h: $(srcdir)/Makefile.am
-	$(AM_V_GEN) echo "/* Autogenerated by ndctl/Makefile.am */" >$@ && \
-	echo '#define NDCTL_CONF_FILE \
-		"$(ndctl_confdir)/$(ndctl_monitorconf)"' >>$@
-	$(AM_V_GEN) echo '#define NDCTL_KEYS_DIR  "$(ndctl_keysdir)"' >>$@
-
-ndctl_SOURCES = ndctl.c \
-		builtin.h \
-		bus.c \
-		create-nfit.c \
-		namespace.c \
-		check.c \
-		region.c \
-		dimm.c \
-		../util/log.c \
-		../daxctl/filter.c \
-		../daxctl/filter.h \
-		filter.c \
-		filter.h \
-		list.c \
-		../util/json.c \
-		../util/json.h \
-		../daxctl/json.c \
-		../daxctl/json.h \
-		json.c \
-		json.h \
-		json-smart.c \
-		keys.h \
-		inject-error.c \
-		inject-smart.c \
-		monitor.c \
-		namespace.h \
-		action.h \
-		../nfit.h \
-		../test.h \
-		firmware-update.h
-
-if ENABLE_KEYUTILS
-ndctl_SOURCES += keys.c \
-		load-keys.c
-keys_configdir = $(ndctl_keysdir)
-keys_config_DATA = $(ndctl_keysreadme)
-endif
-
-EXTRA_DIST += keys.readme monitor.conf ndctl-monitor.service ndctl.conf
-
-if ENABLE_DESTRUCTIVE
-ndctl_SOURCES += ../test/pmem_namespaces.c
-ndctl_SOURCES += bat.c
-endif
-
-ndctl_LDADD =\
-	lib/libndctl.la \
-	../daxctl/lib/libdaxctl.la \
-	../libutil.a \
-	$(UUID_LIBS) \
-	$(KMOD_LIBS) \
-	$(JSON_LIBS) \
-	-liniparser
-
-if ENABLE_KEYUTILS
-ndctl_LDADD += -lkeyutils
-endif
-
-if ENABLE_TEST
-ndctl_SOURCES += ../test/libndctl.c \
-		 ../test/dsm-fail.c \
-		 ../util/sysfs.c \
-		 ../test/core.c \
-		 test.c
-endif
-
-ndctl_configdir = $(ndctl_confdir)
-ndctl_config_DATA = $(ndctl_conf)
-monitor_configdir = $(ndctl_confdir)
-monitor_config_DATA = $(ndctl_monitorconf)
-
-if ENABLE_SYSTEMD_UNITS
-systemd_unit_DATA = ndctl-monitor.service
-endif
diff --git a/ndctl/lib/Makefile.am b/ndctl/lib/Makefile.am
deleted file mode 100644
index 0a52c01da347..000000000000
--- a/ndctl/lib/Makefile.am
+++ /dev/null
@@ -1,58 +0,0 @@
-include $(top_srcdir)/Makefile.am.in
-
-%.pc: %.pc.in Makefile
-	$(SED_PROCESS)
-
-DISTCLEANFILES = config.h
-BUILT_SOURCES = config.h
-config.h: $(srcdir)/Makefile.am
-	$(AM_V_GEN) echo "/* Autogenerated by ndctl/Makefile.am */" >$@ && \
-		echo '#define NDCTL_CONF_DIR  "$(ndctl_confdir)"' >>$@
-
-pkginclude_HEADERS = ../libndctl.h ../ndctl.h
-lib_LTLIBRARIES = libndctl.la
-
-libndctl_la_SOURCES =\
-	../libndctl.h \
-	private.h \
-	../../util/list.h \
-	../../util/log.c \
-	../../util/log.h \
-	../../util/sysfs.c \
-	../../util/sysfs.h \
-	../../util/fletcher.h \
-	dimm.c \
-	inject.c \
-	nfit.c \
-	smart.c \
-	intel.c \
-	hpe1.c \
-	msft.c \
-	hyperv.c \
-	papr.c \
-	ars.c \
-	firmware.c \
-	libndctl.c \
-	intel.h \
-	hpe1.h \
-	msft.h \
-	hyperv.h \
-	../../ndctl/libndctl-nfit.h
-
-libndctl_la_LIBADD =\
-	../../daxctl/lib/libdaxctl.la \
-	$(UDEV_LIBS) \
-	$(UUID_LIBS) \
-	$(KMOD_LIBS)
-
-EXTRA_DIST += libndctl.sym
-
-libndctl_la_LDFLAGS = $(AM_LDFLAGS) \
-	-version-info $(LIBNDCTL_CURRENT):$(LIBNDCTL_REVISION):$(LIBNDCTL_AGE) \
-	-Wl,--version-script=$(top_srcdir)/ndctl/lib/libndctl.sym
-libndctl_la_DEPENDENCIES = libndctl.sym
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libndctl.pc
-EXTRA_DIST += libndctl.pc.in
-CLEANFILES += libndctl.pc
diff --git a/rhel/meson.build b/rhel/meson.build
index 8672098d84e1..85b47bcd485a 100644
--- a/rhel/meson.build
+++ b/rhel/meson.build
@@ -7,8 +7,7 @@ rhel_spec1 = vcs_tag(
 
 rhel_spec2 = custom_target('ndctl.spec',
   command : [
-    'sed', '-e', 's,MESON,1,g',
-	   '-e', 's,DAX_DNAME,daxctl-devel,g',
+    'sed', '-e', 's,DAX_DNAME,daxctl-devel,g',
 	   '-e', 's,CXL_DNAME,cxl-devel,g',
 	   '-e', 's,DNAME,ndctl-devel,g',
 	   '-e', '/^%defattr.*/d',
diff --git a/sles/meson.build b/sles/meson.build
index 21c72cb4f5ec..8512774b6d20 100644
--- a/sles/meson.build
+++ b/sles/meson.build
@@ -18,8 +18,7 @@ sles_spec2 = custom_target('ndctl.spec.in',
 
 sles_spec3 = custom_target('ndctl.spec',
   command : [
-    'sed', '-e', 's,MESON,1,g',
-           '-e', 's,DAX_DNAME,libdaxctl-devel,g',
+    'sed', '-e', 's,DAX_DNAME,libdaxctl-devel,g',
            '-e', 's,CXL_DNAME,libcxl-devel,g',
            '-e', 's,DNAME,libndctl-devel,g',
            '-e', 's,%license,%doc,g',
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index a2a4ee4a4335..000000000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,169 +0,0 @@
-include $(top_srcdir)/Makefile.am.in
-
-TESTS =\
-	libndctl \
-	dsm-fail \
-	create.sh \
-	clear.sh \
-	pmem-errors.sh \
-	daxdev-errors.sh \
-	multi-dax.sh \
-	btt-check.sh \
-	label-compat.sh \
-	sector-mode.sh \
-	inject-error.sh \
-	btt-errors.sh \
-	hugetlb \
-	btt-pad-compat.sh \
-	firmware-update.sh \
-	ack-shutdown-count-set \
-	rescan-partitions.sh \
-	inject-smart.sh \
-	monitor.sh \
-	max_available_extent_ns.sh \
-	pfn-meta-errors.sh \
-	track-uuid.sh
-
-EXTRA_DIST += $(TESTS) common \
-		btt-pad-compat.xxd \
-		nmem1.bin nmem2.bin nmem3.bin nmem4.bin
-
-check_PROGRAMS =\
-	libndctl \
-	dsm-fail \
-	dax-errors \
-	smart-notify \
-	smart-listen \
-	hugetlb \
-	daxdev-errors \
-	ack-shutdown-count-set \
-	list-smart-dimm
-
-if ENABLE_DESTRUCTIVE
-TESTS +=\
-	pmem-ns \
-	sub-section.sh \
-	dax-dev \
-	dax-ext4.sh \
-	dax-xfs.sh \
-	align.sh \
-	device-dax \
-	revoke-devmem \
-	device-dax-fio.sh \
-	daxctl-devices.sh \
-	daxctl-create.sh \
-	dm.sh \
-	mmap.sh
-
-if ENABLE_KEYUTILS
-TESTS += security.sh
-endif
-
-check_PROGRAMS +=\
-	pmem-ns \
-	dax-dev \
-	dax-pmd \
-	device-dax \
-	revoke-devmem \
-	mmap
-endif
-
-LIBNDCTL_LIB =\
-       ../ndctl/lib/libndctl.la \
-       ../daxctl/lib/libdaxctl.la
-
-testcore =\
-	core.c \
-	../util/log.c \
-	../util/sysfs.c
-
-libndctl_SOURCES = libndctl.c $(testcore)
-libndctl_LDADD = $(LIBNDCTL_LIB) $(UUID_LIBS) $(KMOD_LIBS)
-
-namespace_core =\
-	../ndctl/namespace.c \
-	../ndctl/filter.c \
-	../ndctl/check.c \
-	../util/json.c \
-	../ndctl/json.c \
-	../daxctl/filter.c \
-	../daxctl/json.c
-
-dsm_fail_SOURCES =\
-	dsm-fail.c \
-	$(testcore) \
-	$(namespace_core)
-
-dsm_fail_LDADD = $(LIBNDCTL_LIB) \
-		$(KMOD_LIBS) \
-		$(JSON_LIBS) \
-		$(UUID_LIBS) \
-		../libutil.a
-
-ack_shutdown_count_set_SOURCES =\
-	ack-shutdown-count-set.c \
-	$(testcore)
-
-ack_shutdown_count_set_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
-
-pmem_ns_SOURCES = pmem_namespaces.c $(testcore)
-pmem_ns_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS) $(UUID_LIBS)
-
-dax_dev_SOURCES = dax-dev.c $(testcore)
-dax_dev_LDADD = $(LIBNDCTL_LIB) $(KMOD_LIBS)
-
-dax_pmd_SOURCES = dax-pmd.c \
-		$(testcore)
-
-hugetlb_SOURCES = hugetlb.c \
-		  dax-pmd.c
-
-mmap_SOURCES = mmap.c
-dax_errors_SOURCES = dax-errors.c
-daxdev_errors_SOURCES = daxdev-errors.c \
-			../util/log.c \
-			../util/sysfs.c
-daxdev_errors_LDADD = $(LIBNDCTL_LIB)
-device_dax_SOURCES = \
-		device-dax.c \
-		dax-dev.c \
-		dax-pmd.c \
-		$(testcore) \
-		$(namespace_core)
-
-if ENABLE_POISON
-dax_pmd_SOURCES += dax-poison.c
-hugetlb_SOURCES += dax-poison.c
-device_dax_SOURCES += dax-poison.c
-endif
-
-device_dax_LDADD = \
-		$(LIBNDCTL_LIB) \
-		$(KMOD_LIBS) \
-		$(JSON_LIBS) \
-                $(UUID_LIBS) \
-		../libutil.a
-
-revoke_devmem_SOURCES = \
-		revoke-devmem.c \
-		dax-dev.c \
-		$(testcore)
-
-revoke_devmem_LDADD = $(LIBNDCTL_LIB)
-
-smart_notify_SOURCES = smart-notify.c
-smart_notify_LDADD = $(LIBNDCTL_LIB)
-smart_listen_SOURCES = smart-listen.c
-smart_listen_LDADD = $(LIBNDCTL_LIB)
-
-list_smart_dimm_SOURCES = \
-		list-smart-dimm.c \
-		../ndctl/filter.c \
-		../util/json.c \
-		../ndctl/json.c
-
-list_smart_dimm_LDADD = \
-		$(LIBNDCTL_LIB) \
-		$(JSON_LIBS) \
-		$(UUID_LIBS) \
-		../libutil.a


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [ndctl PATCH v3 00/16] ndctl: Meson support
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (15 preceding siblings ...)
  2022-01-05 21:33 ` [ndctl PATCH v3 16/16] ndctl: Jettison autotools Dan Williams
@ 2022-01-12 13:54 ` Vaibhav Jain
  2022-01-13  1:23 ` Alison Schofield
  2022-01-14 16:04 ` Verma, Vishal L
  18 siblings, 0 replies; 24+ messages in thread
From: Vaibhav Jain @ 2022-01-12 13:54 UTC (permalink / raw)
  To: Dan Williams, vishal.l.verma; +Cc: nvdimm, linux-cxl, Shivaprasad G Bhat


Tested this series on a PPC64-LE guest with a vPMEM device. Generated
binaries for ndctl/daxctl passed the test suite located at
https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/memory/ndctl.py

Hence,

Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>

Dan Williams <dan.j.williams@intel.com> writes:
> Changes since v2 [1]:
>
> - Rebase on v72
>   - Add Meson support for the new config file directory definitions.
>   - Add Meson support for landing the daxctl udev rule
>     daxdev-reconfigure service in the right directories
> - Include the deprecation of BLK Aperture test infrastructure
> - Include a miscellaneous doc clarification for 'ndctl update-firmware'
> - Fix the tests support for moving the build directory out-of-line
> - Include a fix for the deprectation of the dax_pmem_compat module
>   pending in the libnvdimm-for-next tree.
>
> [1]: https://lore.kernel.org/r/163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com
>
> ---
>
> As mentioned in patch 14 the motiviation for converting to Meson is
> primarily driven by speed (an order of magnitude in some scenarios), but
> Meson also includes better test and debug-build support. The build
> language is easier to read, write, and debug. Meson is all around better
> suited to the next phase of the ndctl project that will include all
> things "device memory" related (ndctl, daxctl, and cxl).
>
> In order to simplify the conversion the old BLK-aperture test
> infrastructure is jettisoned and it will also be removed upstream. Some
> other refactorings and fixups are included as well to better organize
> the utilty infrastructure between truly common and sub-tool specific.
>
> Vishal,
>
> In preparation for ndctl-v73 please consider pulling in this series
> early mainly for my own sanity of not needing to forward port more
> updates to the autotools infrastructure.
>
> ---
>
> Dan Williams (16):
>       ndctl/docs: Clarify update-firwmware activation 'overflow' conditions
>       ndctl/test: Prepare for BLK-aperture support removal
>       ndctl/test: Move 'reset()' to function in 'common'
>       ndctl/test: Initialize the label area by default
>       ndctl/test: Skip BLK flags checks
>       ndctl/test: Move sector-mode to a different region
>       ndctl: Deprecate BLK aperture support
>       ndctl/test: Fix support for missing dax_pmem_compat module
>       util: Distribute 'filter' and 'json' helpers to per-tool objects
>       Documentation: Drop attrs.adoc include
>       build: Drop unnecessary $tool/config.h includes
>       test: Prepare out of line builds
>       ndctl: Drop executable bit for bash-completion script
>       build: Add meson build infrastructure
>       build: Add meson rpmbuild support
>       ndctl: Jettison autotools
>
>
>  .gitignore                                         |   64 -
>  Documentation/cxl/Makefile.am                      |   61 -
>  Documentation/cxl/lib/Makefile.am                  |   58 -
>  Documentation/cxl/lib/meson.build                  |   79 +
>  Documentation/cxl/meson.build                      |   84 +
>  Documentation/daxctl/Makefile.am                   |   75 -
>  Documentation/daxctl/daxctl-reconfigure-device.txt |    2 
>  Documentation/daxctl/meson.build                   |   94 +
>  Documentation/ndctl/Makefile.am                    |  106 -
>  Documentation/ndctl/intel-nvdimm-security.txt      |    2 
>  Documentation/ndctl/labels-description.txt         |    5 
>  Documentation/ndctl/meson.build                    |  124 ++
>  Documentation/ndctl/ndctl-create-namespace.txt     |   29 
>  Documentation/ndctl/ndctl-init-labels.txt          |    7 
>  Documentation/ndctl/ndctl-list.txt                 |    4 
>  Documentation/ndctl/ndctl-load-keys.txt            |    2 
>  Documentation/ndctl/ndctl-monitor.txt              |    2 
>  Documentation/ndctl/ndctl-sanitize-dimm.txt        |    2 
>  Documentation/ndctl/ndctl-setup-passphrase.txt     |    2 
>  Documentation/ndctl/ndctl-update-firmware.txt      |   64 +
>  Documentation/ndctl/ndctl-update-passphrase.txt    |    2 
>  Documentation/ndctl/region-description.txt         |   10 
>  Makefile.am                                        |  103 -
>  Makefile.am.in                                     |   49 -
>  README.md                                          |    1 
>  autogen.sh                                         |   28 
>  clean_config.sh                                    |    2 
>  config.h.meson                                     |  151 ++
>  configure.ac                                       |  270 ----
>  contrib/meson.build                                |   28 
>  contrib/ndctl                                      |    0 
>  contrib/nfit_test_depmod.conf                      |    1 
>  cxl/Makefile.am                                    |   22 
>  cxl/filter.c                                       |   25 
>  cxl/filter.h                                       |    7 
>  cxl/json.c                                         |  214 +++
>  cxl/json.h                                         |    8 
>  cxl/lib/Makefile.am                                |   32 
>  cxl/lib/meson.build                                |   35 
>  cxl/list.c                                         |    4 
>  cxl/memdev.c                                       |    3 
>  cxl/meson.build                                    |   25 
>  daxctl/Makefile.am                                 |   40 -
>  daxctl/device.c                                    |    5 
>  daxctl/filter.c                                    |   43 +
>  daxctl/filter.h                                    |   12 
>  daxctl/json.c                                      |  245 +++
>  daxctl/json.h                                      |   18 
>  daxctl/lib/Makefile.am                             |   42 -
>  daxctl/lib/meson.build                             |   44 +
>  daxctl/list.c                                      |    4 
>  daxctl/meson.build                                 |   35 
>  daxctl/migrate.c                                   |    1 
>  meson.build                                        |  286 ++++
>  meson_options.txt                                  |   25 
>  ndctl.spec.in                                      |   15 
>  ndctl/Makefile.am                                  |   84 -
>  ndctl/bat.c                                        |    5 
>  ndctl/bus.c                                        |    4 
>  ndctl/check.c                                      |    2 
>  ndctl/dimm.c                                       |    6 
>  ndctl/filter.c                                     |   60 -
>  ndctl/filter.h                                     |   12 
>  ndctl/inject-error.c                               |    6 
>  ndctl/inject-smart.c                               |    6 
>  ndctl/json-smart.c                                 |    5 
>  ndctl/json.c                                       | 1114 ++++++++++++++
>  ndctl/json.h                                       |   24 
>  ndctl/keys.c                                       |    6 
>  ndctl/keys.h                                       |    0 
>  ndctl/lib/Makefile.am                              |   58 -
>  ndctl/lib/libndctl.c                               |    2 
>  ndctl/lib/meson.build                              |   48 +
>  ndctl/lib/papr.c                                   |    4 
>  ndctl/lib/private.h                                |    4 
>  ndctl/list.c                                       |    5 
>  ndctl/load-keys.c                                  |    7 
>  ndctl/meson.build                                  |   82 +
>  ndctl/monitor.c                                    |    5 
>  ndctl/namespace.c                                  |    6 
>  ndctl/region.c                                     |    3 
>  ndctl/test.c                                       |   11 
>  rhel/meson.build                                   |   22 
>  rpmbuild.sh                                        |    5 
>  sles/meson.build                                   |   35 
>  test.h                                             |    3 
>  test/Makefile.am                                   |  192 --
>  test/ack-shutdown-count-set.c                      |    2 
>  test/blk-exhaust.sh                                |   32 
>  test/blk_namespaces.c                              |  357 -----
>  test/btt-check.sh                                  |    7 
>  test/btt-errors.sh                                 |   16 
>  test/btt-pad-compat.sh                             |    9 
>  test/clear.sh                                      |    4 
>  test/common                                        |   59 +
>  test/core.c                                        |   57 +
>  test/create.sh                                     |   17 
>  test/dax-pmd.c                                     |   11 
>  test/dax.sh                                        |    6 
>  test/daxctl-create.sh                              |    4 
>  test/daxdev-errors.c                               |    2 
>  test/daxdev-errors.sh                              |    8 
>  test/device-dax-fio.sh                             |    2 
>  test/device-dax.c                                  |    2 
>  test/dm.sh                                         |    4 
>  test/dpa-alloc.c                                   |  326 ----
>  test/dsm-fail.c                                    |    4 
>  test/firmware-update.sh                            |    8 
>  test/inject-error.sh                               |    7 
>  test/inject-smart.sh                               |    2 
>  test/label-compat.sh                               |    2 
>  test/libndctl.c                                    |  253 +--
>  test/list-smart-dimm.c                             |    6 
>  test/max_available_extent_ns.sh                    |    9 
>  test/meson.build                                   |  237 +++
>  test/mmap.sh                                       |    6 
>  test/monitor.sh                                    |   17 
>  test/multi-dax.sh                                  |    4 
>  test/multi-pmem.c                                  |  285 ----
>  test/parent-uuid.c                                 |  254 ---
>  test/pfn-meta-errors.sh                            |    4 
>  test/pmem-errors.sh                                |   12 
>  test/pmem_namespaces.c                             |    2 
>  test/rescan-partitions.sh                          |    7 
>  test/revoke-devmem.c                               |    2 
>  test/sector-mode.sh                                |   17 
>  test/sub-section.sh                                |    4 
>  test/track-uuid.sh                                 |    6 
>  tools/meson-vcs-tag.sh                             |   18 
>  util/help.c                                        |    2 
>  util/json.c                                        | 1542 --------------------
>  util/json.h                                        |   39 -
>  util/meson.build                                   |   16 
>  version.h.in                                       |    2 
>  134 files changed, 3561 insertions(+), 4658 deletions(-)
>  delete mode 100644 Documentation/cxl/Makefile.am
>  delete mode 100644 Documentation/cxl/lib/Makefile.am
>  create mode 100644 Documentation/cxl/lib/meson.build
>  create mode 100644 Documentation/cxl/meson.build
>  delete mode 100644 Documentation/daxctl/Makefile.am
>  create mode 100644 Documentation/daxctl/meson.build
>  delete mode 100644 Documentation/ndctl/Makefile.am
>  create mode 100644 Documentation/ndctl/meson.build
>  delete mode 100644 Makefile.am
>  delete mode 100644 Makefile.am.in
>  delete mode 100755 autogen.sh
>  create mode 100755 clean_config.sh
>  create mode 100644 config.h.meson
>  delete mode 100644 configure.ac
>  create mode 100644 contrib/meson.build
>  mode change 100755 => 100644 contrib/ndctl
>  delete mode 100644 cxl/Makefile.am
>  create mode 100644 cxl/filter.c
>  create mode 100644 cxl/filter.h
>  create mode 100644 cxl/json.c
>  create mode 100644 cxl/json.h
>  delete mode 100644 cxl/lib/Makefile.am
>  create mode 100644 cxl/lib/meson.build
>  create mode 100644 cxl/meson.build
>  delete mode 100644 daxctl/Makefile.am
>  create mode 100644 daxctl/filter.c
>  create mode 100644 daxctl/filter.h
>  create mode 100644 daxctl/json.c
>  create mode 100644 daxctl/json.h
>  delete mode 100644 daxctl/lib/Makefile.am
>  create mode 100644 daxctl/lib/meson.build
>  create mode 100644 daxctl/meson.build
>  create mode 100644 meson.build
>  create mode 100644 meson_options.txt
>  delete mode 100644 ndctl/Makefile.am
>  rename util/filter.c => ndctl/filter.c (88%)
>  rename util/filter.h => ndctl/filter.h (89%)
>  rename ndctl/{util/json-smart.c => json-smart.c} (99%)
>  create mode 100644 ndctl/json.c
>  create mode 100644 ndctl/json.h
>  rename ndctl/{util/keys.c => keys.c} (99%)
>  rename ndctl/{util/keys.h => keys.h} (100%)
>  delete mode 100644 ndctl/lib/Makefile.am
>  create mode 100644 ndctl/lib/meson.build
>  create mode 100644 ndctl/meson.build
>  create mode 100644 rhel/meson.build
>  create mode 100644 sles/meson.build
>  delete mode 100644 test/Makefile.am
>  delete mode 100755 test/blk-exhaust.sh
>  delete mode 100644 test/blk_namespaces.c
>  delete mode 100644 test/dpa-alloc.c
>  create mode 100644 test/meson.build
>  delete mode 100644 test/multi-pmem.c
>  delete mode 100644 test/parent-uuid.c
>  create mode 100755 tools/meson-vcs-tag.sh
>  create mode 100644 util/meson.build
>  create mode 100644 version.h.in
>
> base-commit: 25062cf34c70012f5d42ce1fef7e2dc129807c10

-- 
Cheers
~ Vaibhav

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [ndctl PATCH v3 00/16] ndctl: Meson support
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (16 preceding siblings ...)
  2022-01-12 13:54 ` [ndctl PATCH v3 00/16] ndctl: Meson support Vaibhav Jain
@ 2022-01-13  1:23 ` Alison Schofield
  2022-01-14 16:04 ` Verma, Vishal L
  18 siblings, 0 replies; 24+ messages in thread
From: Alison Schofield @ 2022-01-13  1:23 UTC (permalink / raw)
  To: Dan Williams; +Cc: vishal.l.verma, Vaibhav Jain, nvdimm, linux-cxl

Hi Dan - I'll offer a Tested-by since I used it for v2 of the CXL Partitions:
https://lore.kernel.org/nvdimm/cover.1641965853.git.alison.schofield@intel.com/

Very FAST!

Tested-by: Alison Schofield <alison.schofield@intel.com>


On Wed, Jan 05, 2022 at 01:31:39PM -0800, Dan Williams wrote:
> Changes since v2 [1]:
> 
> - Rebase on v72
>   - Add Meson support for the new config file directory definitions.
>   - Add Meson support for landing the daxctl udev rule
>     daxdev-reconfigure service in the right directories
> - Include the deprecation of BLK Aperture test infrastructure
> - Include a miscellaneous doc clarification for 'ndctl update-firmware'
> - Fix the tests support for moving the build directory out-of-line
> - Include a fix for the deprectation of the dax_pmem_compat module
>   pending in the libnvdimm-for-next tree.
> 
> [1]: https://lore.kernel.org/r/163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com
> 
> ---
> 
> As mentioned in patch 14 the motiviation for converting to Meson is
> primarily driven by speed (an order of magnitude in some scenarios), but
> Meson also includes better test and debug-build support. The build
> language is easier to read, write, and debug. Meson is all around better
> suited to the next phase of the ndctl project that will include all
> things "device memory" related (ndctl, daxctl, and cxl).
> 
> In order to simplify the conversion the old BLK-aperture test
> infrastructure is jettisoned and it will also be removed upstream. Some
> other refactorings and fixups are included as well to better organize
> the utilty infrastructure between truly common and sub-tool specific.
> 
> Vishal,
> 
> In preparation for ndctl-v73 please consider pulling in this series
> early mainly for my own sanity of not needing to forward port more
> updates to the autotools infrastructure.
> 
> ---
> 
> Dan Williams (16):
>       ndctl/docs: Clarify update-firwmware activation 'overflow' conditions
>       ndctl/test: Prepare for BLK-aperture support removal
>       ndctl/test: Move 'reset()' to function in 'common'
>       ndctl/test: Initialize the label area by default
>       ndctl/test: Skip BLK flags checks
>       ndctl/test: Move sector-mode to a different region
>       ndctl: Deprecate BLK aperture support
>       ndctl/test: Fix support for missing dax_pmem_compat module
>       util: Distribute 'filter' and 'json' helpers to per-tool objects
>       Documentation: Drop attrs.adoc include
>       build: Drop unnecessary $tool/config.h includes
>       test: Prepare out of line builds
>       ndctl: Drop executable bit for bash-completion script
>       build: Add meson build infrastructure
>       build: Add meson rpmbuild support
>       ndctl: Jettison autotools
> 
> 
>  .gitignore                                         |   64 -
>  Documentation/cxl/Makefile.am                      |   61 -
>  Documentation/cxl/lib/Makefile.am                  |   58 -
>  Documentation/cxl/lib/meson.build                  |   79 +
>  Documentation/cxl/meson.build                      |   84 +
>  Documentation/daxctl/Makefile.am                   |   75 -
>  Documentation/daxctl/daxctl-reconfigure-device.txt |    2 
>  Documentation/daxctl/meson.build                   |   94 +
>  Documentation/ndctl/Makefile.am                    |  106 -
>  Documentation/ndctl/intel-nvdimm-security.txt      |    2 
>  Documentation/ndctl/labels-description.txt         |    5 
>  Documentation/ndctl/meson.build                    |  124 ++
>  Documentation/ndctl/ndctl-create-namespace.txt     |   29 
>  Documentation/ndctl/ndctl-init-labels.txt          |    7 
>  Documentation/ndctl/ndctl-list.txt                 |    4 
>  Documentation/ndctl/ndctl-load-keys.txt            |    2 
>  Documentation/ndctl/ndctl-monitor.txt              |    2 
>  Documentation/ndctl/ndctl-sanitize-dimm.txt        |    2 
>  Documentation/ndctl/ndctl-setup-passphrase.txt     |    2 
>  Documentation/ndctl/ndctl-update-firmware.txt      |   64 +
>  Documentation/ndctl/ndctl-update-passphrase.txt    |    2 
>  Documentation/ndctl/region-description.txt         |   10 
>  Makefile.am                                        |  103 -
>  Makefile.am.in                                     |   49 -
>  README.md                                          |    1 
>  autogen.sh                                         |   28 
>  clean_config.sh                                    |    2 
>  config.h.meson                                     |  151 ++
>  configure.ac                                       |  270 ----
>  contrib/meson.build                                |   28 
>  contrib/ndctl                                      |    0 
>  contrib/nfit_test_depmod.conf                      |    1 
>  cxl/Makefile.am                                    |   22 
>  cxl/filter.c                                       |   25 
>  cxl/filter.h                                       |    7 
>  cxl/json.c                                         |  214 +++
>  cxl/json.h                                         |    8 
>  cxl/lib/Makefile.am                                |   32 
>  cxl/lib/meson.build                                |   35 
>  cxl/list.c                                         |    4 
>  cxl/memdev.c                                       |    3 
>  cxl/meson.build                                    |   25 
>  daxctl/Makefile.am                                 |   40 -
>  daxctl/device.c                                    |    5 
>  daxctl/filter.c                                    |   43 +
>  daxctl/filter.h                                    |   12 
>  daxctl/json.c                                      |  245 +++
>  daxctl/json.h                                      |   18 
>  daxctl/lib/Makefile.am                             |   42 -
>  daxctl/lib/meson.build                             |   44 +
>  daxctl/list.c                                      |    4 
>  daxctl/meson.build                                 |   35 
>  daxctl/migrate.c                                   |    1 
>  meson.build                                        |  286 ++++
>  meson_options.txt                                  |   25 
>  ndctl.spec.in                                      |   15 
>  ndctl/Makefile.am                                  |   84 -
>  ndctl/bat.c                                        |    5 
>  ndctl/bus.c                                        |    4 
>  ndctl/check.c                                      |    2 
>  ndctl/dimm.c                                       |    6 
>  ndctl/filter.c                                     |   60 -
>  ndctl/filter.h                                     |   12 
>  ndctl/inject-error.c                               |    6 
>  ndctl/inject-smart.c                               |    6 
>  ndctl/json-smart.c                                 |    5 
>  ndctl/json.c                                       | 1114 ++++++++++++++
>  ndctl/json.h                                       |   24 
>  ndctl/keys.c                                       |    6 
>  ndctl/keys.h                                       |    0 
>  ndctl/lib/Makefile.am                              |   58 -
>  ndctl/lib/libndctl.c                               |    2 
>  ndctl/lib/meson.build                              |   48 +
>  ndctl/lib/papr.c                                   |    4 
>  ndctl/lib/private.h                                |    4 
>  ndctl/list.c                                       |    5 
>  ndctl/load-keys.c                                  |    7 
>  ndctl/meson.build                                  |   82 +
>  ndctl/monitor.c                                    |    5 
>  ndctl/namespace.c                                  |    6 
>  ndctl/region.c                                     |    3 
>  ndctl/test.c                                       |   11 
>  rhel/meson.build                                   |   22 
>  rpmbuild.sh                                        |    5 
>  sles/meson.build                                   |   35 
>  test.h                                             |    3 
>  test/Makefile.am                                   |  192 --
>  test/ack-shutdown-count-set.c                      |    2 
>  test/blk-exhaust.sh                                |   32 
>  test/blk_namespaces.c                              |  357 -----
>  test/btt-check.sh                                  |    7 
>  test/btt-errors.sh                                 |   16 
>  test/btt-pad-compat.sh                             |    9 
>  test/clear.sh                                      |    4 
>  test/common                                        |   59 +
>  test/core.c                                        |   57 +
>  test/create.sh                                     |   17 
>  test/dax-pmd.c                                     |   11 
>  test/dax.sh                                        |    6 
>  test/daxctl-create.sh                              |    4 
>  test/daxdev-errors.c                               |    2 
>  test/daxdev-errors.sh                              |    8 
>  test/device-dax-fio.sh                             |    2 
>  test/device-dax.c                                  |    2 
>  test/dm.sh                                         |    4 
>  test/dpa-alloc.c                                   |  326 ----
>  test/dsm-fail.c                                    |    4 
>  test/firmware-update.sh                            |    8 
>  test/inject-error.sh                               |    7 
>  test/inject-smart.sh                               |    2 
>  test/label-compat.sh                               |    2 
>  test/libndctl.c                                    |  253 +--
>  test/list-smart-dimm.c                             |    6 
>  test/max_available_extent_ns.sh                    |    9 
>  test/meson.build                                   |  237 +++
>  test/mmap.sh                                       |    6 
>  test/monitor.sh                                    |   17 
>  test/multi-dax.sh                                  |    4 
>  test/multi-pmem.c                                  |  285 ----
>  test/parent-uuid.c                                 |  254 ---
>  test/pfn-meta-errors.sh                            |    4 
>  test/pmem-errors.sh                                |   12 
>  test/pmem_namespaces.c                             |    2 
>  test/rescan-partitions.sh                          |    7 
>  test/revoke-devmem.c                               |    2 
>  test/sector-mode.sh                                |   17 
>  test/sub-section.sh                                |    4 
>  test/track-uuid.sh                                 |    6 
>  tools/meson-vcs-tag.sh                             |   18 
>  util/help.c                                        |    2 
>  util/json.c                                        | 1542 --------------------
>  util/json.h                                        |   39 -
>  util/meson.build                                   |   16 
>  version.h.in                                       |    2 
>  134 files changed, 3561 insertions(+), 4658 deletions(-)
>  delete mode 100644 Documentation/cxl/Makefile.am
>  delete mode 100644 Documentation/cxl/lib/Makefile.am
>  create mode 100644 Documentation/cxl/lib/meson.build
>  create mode 100644 Documentation/cxl/meson.build
>  delete mode 100644 Documentation/daxctl/Makefile.am
>  create mode 100644 Documentation/daxctl/meson.build
>  delete mode 100644 Documentation/ndctl/Makefile.am
>  create mode 100644 Documentation/ndctl/meson.build
>  delete mode 100644 Makefile.am
>  delete mode 100644 Makefile.am.in
>  delete mode 100755 autogen.sh
>  create mode 100755 clean_config.sh
>  create mode 100644 config.h.meson
>  delete mode 100644 configure.ac
>  create mode 100644 contrib/meson.build
>  mode change 100755 => 100644 contrib/ndctl
>  delete mode 100644 cxl/Makefile.am
>  create mode 100644 cxl/filter.c
>  create mode 100644 cxl/filter.h
>  create mode 100644 cxl/json.c
>  create mode 100644 cxl/json.h
>  delete mode 100644 cxl/lib/Makefile.am
>  create mode 100644 cxl/lib/meson.build
>  create mode 100644 cxl/meson.build
>  delete mode 100644 daxctl/Makefile.am
>  create mode 100644 daxctl/filter.c
>  create mode 100644 daxctl/filter.h
>  create mode 100644 daxctl/json.c
>  create mode 100644 daxctl/json.h
>  delete mode 100644 daxctl/lib/Makefile.am
>  create mode 100644 daxctl/lib/meson.build
>  create mode 100644 daxctl/meson.build
>  create mode 100644 meson.build
>  create mode 100644 meson_options.txt
>  delete mode 100644 ndctl/Makefile.am
>  rename util/filter.c => ndctl/filter.c (88%)
>  rename util/filter.h => ndctl/filter.h (89%)
>  rename ndctl/{util/json-smart.c => json-smart.c} (99%)
>  create mode 100644 ndctl/json.c
>  create mode 100644 ndctl/json.h
>  rename ndctl/{util/keys.c => keys.c} (99%)
>  rename ndctl/{util/keys.h => keys.h} (100%)
>  delete mode 100644 ndctl/lib/Makefile.am
>  create mode 100644 ndctl/lib/meson.build
>  create mode 100644 ndctl/meson.build
>  create mode 100644 rhel/meson.build
>  create mode 100644 sles/meson.build
>  delete mode 100644 test/Makefile.am
>  delete mode 100755 test/blk-exhaust.sh
>  delete mode 100644 test/blk_namespaces.c
>  delete mode 100644 test/dpa-alloc.c
>  create mode 100644 test/meson.build
>  delete mode 100644 test/multi-pmem.c
>  delete mode 100644 test/parent-uuid.c
>  create mode 100755 tools/meson-vcs-tag.sh
>  create mode 100644 util/meson.build
>  create mode 100644 version.h.in
> 
> base-commit: 25062cf34c70012f5d42ce1fef7e2dc129807c10
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [ndctl PATCH v3 00/16] ndctl: Meson support
  2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
                   ` (17 preceding siblings ...)
  2022-01-13  1:23 ` Alison Schofield
@ 2022-01-14 16:04 ` Verma, Vishal L
  2022-01-14 16:55   ` Michal Suchánek
  2022-01-14 22:30   ` Jane Chu
  18 siblings, 2 replies; 24+ messages in thread
From: Verma, Vishal L @ 2022-01-14 16:04 UTC (permalink / raw)
  To: Williams, Dan J
  Cc: jmoyer, msuchanek, linux-cxl, nvdimm, breno.leitao, vaibhav, kilobyte

On Wed, 2022-01-05 at 13:31 -0800, Dan Williams wrote:
> Changes since v2 [1]:
> 
> - Rebase on v72
>   - Add Meson support for the new config file directory definitions.
>   - Add Meson support for landing the daxctl udev rule
>     daxdev-reconfigure service in the right directories
> - Include the deprecation of BLK Aperture test infrastructure
> - Include a miscellaneous doc clarification for 'ndctl update-firmware'
> - Fix the tests support for moving the build directory out-of-line
> - Include a fix for the deprectation of the dax_pmem_compat module
>   pending in the libnvdimm-for-next tree.
> 
> [1]: https://lore.kernel.org/r/163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com
> 
> ---
> 
> As mentioned in patch 14 the motiviation for converting to Meson is
> primarily driven by speed (an order of magnitude in some scenarios), but
> Meson also includes better test and debug-build support. The build
> language is easier to read, write, and debug. Meson is all around better
> suited to the next phase of the ndctl project that will include all
> things "device memory" related (ndctl, daxctl, and cxl).
> 
> In order to simplify the conversion the old BLK-aperture test
> infrastructure is jettisoned and it will also be removed upstream. Some
> other refactorings and fixups are included as well to better organize
> the utilty infrastructure between truly common and sub-tool specific.
> 
> Vishal,
> 
> In preparation for ndctl-v73 please consider pulling in this series
> early mainly for my own sanity of not needing to forward port more
> updates to the autotools infrastructure.
> 
Hi Dan,

These look great, thanks a lot for this work, it is an awesome workflow
improvement!  I've merged it into pending, and will also merge to
master shortly to encourage all new submissions to be based on this.

Also CC'ing a few distro maintainers - this will be a change to
packaging specs etc. that are maintained outside of the ndctl repo.
This change can be expected to land in the v73 release, which should be
in the next 2-4 weeks.

Thanks,
Vishal

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [ndctl PATCH v3 00/16] ndctl: Meson support
  2022-01-14 16:04 ` Verma, Vishal L
@ 2022-01-14 16:55   ` Michal Suchánek
  2022-01-14 22:30   ` Jane Chu
  1 sibling, 0 replies; 24+ messages in thread
From: Michal Suchánek @ 2022-01-14 16:55 UTC (permalink / raw)
  To: Verma, Vishal L
  Cc: Williams, Dan J, jmoyer, linux-cxl, nvdimm, breno.leitao,
	vaibhav, kilobyte

Hello,

On Fri, Jan 14, 2022 at 04:04:09PM +0000, Verma, Vishal L wrote:
> On Wed, 2022-01-05 at 13:31 -0800, Dan Williams wrote:
> > Changes since v2 [1]:
> > 
> > - Rebase on v72
> >   - Add Meson support for the new config file directory definitions.
> >   - Add Meson support for landing the daxctl udev rule
> >     daxdev-reconfigure service in the right directories
> > - Include the deprecation of BLK Aperture test infrastructure
> > - Include a miscellaneous doc clarification for 'ndctl update-firmware'
> > - Fix the tests support for moving the build directory out-of-line
> > - Include a fix for the deprectation of the dax_pmem_compat module
> >   pending in the libnvdimm-for-next tree.
> > 
> > [1]: https://lore.kernel.org/r/163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com

> Hi Dan,
> 
> These look great, thanks a lot for this work, it is an awesome workflow
> improvement!  I've merged it into pending, and will also merge to
> master shortly to encourage all new submissions to be based on this.
> 
> Also CC'ing a few distro maintainers - this will be a change to
> packaging specs etc. that are maintained outside of the ndctl repo.
> This change can be expected to land in the v73 release, which should be
> in the next 2-4 weeks.

Thanks for the heads-up.

The obvious downside is that with meson build system ndctl is no longer
buildable on older distributions. Then again the new featurees are not
needed there either with old kernels so I don't think this is really a
problem.

https://build.opensuse.org/package/show/home:michals/ndctl.git

Thanks

Michal

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [ndctl PATCH v3 00/16] ndctl: Meson support
  2022-01-14 16:04 ` Verma, Vishal L
  2022-01-14 16:55   ` Michal Suchánek
@ 2022-01-14 22:30   ` Jane Chu
  2022-01-14 22:47     ` Dan Williams
  1 sibling, 1 reply; 24+ messages in thread
From: Jane Chu @ 2022-01-14 22:30 UTC (permalink / raw)
  To: Verma, Vishal L, Williams, Dan J
  Cc: jmoyer, msuchanek, linux-cxl, nvdimm, breno.leitao, vaibhav, kilobyte

Hi,

Should the README.md file get updated accordingly?

thanks!
-jane

On 1/14/2022 8:04 AM, Verma, Vishal L wrote:
> On Wed, 2022-01-05 at 13:31 -0800, Dan Williams wrote:
>> Changes since v2 [1]:
>>
>> - Rebase on v72
>>    - Add Meson support for the new config file directory definitions.
>>    - Add Meson support for landing the daxctl udev rule
>>      daxdev-reconfigure service in the right directories
>> - Include the deprecation of BLK Aperture test infrastructure
>> - Include a miscellaneous doc clarification for 'ndctl update-firmware'
>> - Fix the tests support for moving the build directory out-of-line
>> - Include a fix for the deprectation of the dax_pmem_compat module
>>    pending in the libnvdimm-for-next tree.
>>
>> [1]: https://lore.kernel.org/r/163061537869.1943957.8491829881215255815.stgit@dwillia2-desk3.amr.corp.intel.com
>>
>> ---
>>
>> As mentioned in patch 14 the motiviation for converting to Meson is
>> primarily driven by speed (an order of magnitude in some scenarios), but
>> Meson also includes better test and debug-build support. The build
>> language is easier to read, write, and debug. Meson is all around better
>> suited to the next phase of the ndctl project that will include all
>> things "device memory" related (ndctl, daxctl, and cxl).
>>
>> In order to simplify the conversion the old BLK-aperture test
>> infrastructure is jettisoned and it will also be removed upstream. Some
>> other refactorings and fixups are included as well to better organize
>> the utilty infrastructure between truly common and sub-tool specific.
>>
>> Vishal,
>>
>> In preparation for ndctl-v73 please consider pulling in this series
>> early mainly for my own sanity of not needing to forward port more
>> updates to the autotools infrastructure.
>>
> Hi Dan,
> 
> These look great, thanks a lot for this work, it is an awesome workflow
> improvement!  I've merged it into pending, and will also merge to
> master shortly to encourage all new submissions to be based on this.
> 
> Also CC'ing a few distro maintainers - this will be a change to
> packaging specs etc. that are maintained outside of the ndctl repo.
> This change can be expected to land in the v73 release, which should be
> in the next 2-4 weeks.
> 
> Thanks,
> Vishal


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [ndctl PATCH v3 00/16] ndctl: Meson support
  2022-01-14 22:30   ` Jane Chu
@ 2022-01-14 22:47     ` Dan Williams
  2022-01-15  1:16       ` Verma, Vishal L
  0 siblings, 1 reply; 24+ messages in thread
From: Dan Williams @ 2022-01-14 22:47 UTC (permalink / raw)
  To: Jane Chu
  Cc: Verma, Vishal L, jmoyer, msuchanek, linux-cxl, nvdimm,
	breno.leitao, vaibhav, kilobyte

On Fri, Jan 14, 2022 at 2:31 PM Jane Chu <jane.chu@oracle.com> wrote:
>
> Hi,
>
> Should the README.md file get updated accordingly?

Indeed! Will fix.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [ndctl PATCH v3 00/16] ndctl: Meson support
  2022-01-14 22:47     ` Dan Williams
@ 2022-01-15  1:16       ` Verma, Vishal L
  0 siblings, 0 replies; 24+ messages in thread
From: Verma, Vishal L @ 2022-01-15  1:16 UTC (permalink / raw)
  To: Williams, Dan J, chu, jane
  Cc: kilobyte, jmoyer, linux-cxl, nvdimm, breno.leitao, msuchanek, vaibhav

On Fri, 2022-01-14 at 14:47 -0800, Dan Williams wrote:
> On Fri, Jan 14, 2022 at 2:31 PM Jane Chu <jane.chu@oracle.com> wrote:
> > 
> > Hi,
> > 
> > Should the README.md file get updated accordingly?
> 
> Indeed! Will fix.

Yep I have a patch for this actually in a local branch, I'll send it
out - was just waiting to see if any related fixes pop up.


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-01-15  1:16 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 21:31 [ndctl PATCH v3 00/16] ndctl: Meson support Dan Williams
2022-01-05 21:31 ` [ndctl PATCH v3 01/16] ndctl/docs: Clarify update-firwmware activation 'overflow' conditions Dan Williams
2022-01-05 21:31 ` [ndctl PATCH v3 02/16] ndctl/test: Prepare for BLK-aperture support removal Dan Williams
2022-01-05 21:31 ` [ndctl PATCH v3 03/16] ndctl/test: Move 'reset()' to function in 'common' Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 04/16] ndctl/test: Initialize the label area by default Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 05/16] ndctl/test: Skip BLK flags checks Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 06/16] ndctl/test: Move sector-mode to a different region Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 07/16] ndctl: Deprecate BLK aperture support Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 08/16] ndctl/test: Fix support for missing dax_pmem_compat module Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 09/16] util: Distribute 'filter' and 'json' helpers to per-tool objects Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 10/16] Documentation: Drop attrs.adoc include Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 11/16] build: Drop unnecessary $tool/config.h includes Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 12/16] test: Prepare out of line builds Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 13/16] ndctl: Drop executable bit for bash-completion script Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 14/16] build: Add meson build infrastructure Dan Williams
2022-01-05 21:32 ` [ndctl PATCH v3 15/16] build: Add meson rpmbuild support Dan Williams
2022-01-05 21:33 ` [ndctl PATCH v3 16/16] ndctl: Jettison autotools Dan Williams
2022-01-12 13:54 ` [ndctl PATCH v3 00/16] ndctl: Meson support Vaibhav Jain
2022-01-13  1:23 ` Alison Schofield
2022-01-14 16:04 ` Verma, Vishal L
2022-01-14 16:55   ` Michal Suchánek
2022-01-14 22:30   ` Jane Chu
2022-01-14 22:47     ` Dan Williams
2022-01-15  1:16       ` Verma, Vishal L

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.