Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package ndctl for openSUSE:Factory checked 
in at 2022-03-13 20:24:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ndctl (Old)
 and      /work/SRC/openSUSE:Factory/.ndctl.new.25692 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ndctl"

Sun Mar 13 20:24:58 2022 rev:38 rq:960797 version:71.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/ndctl/ndctl.changes      2021-10-16 
22:47:16.788673696 +0200
+++ /work/SRC/openSUSE:Factory/.ndctl.new.25692/ndctl.changes   2022-03-13 
20:25:04.339648653 +0100
@@ -1,0 +2,33 @@
+Mon Mar  7 20:54:26 UTC 2022 - Michal Suchanek <msucha...@suse.com>
+
+- Add support for reporting dirty shutdown count (jsc#SLE-18196).
+   + 0016-libndctl-papr-Add-support-for-reporting-shutdown-cou.patch
+   + 0009-libndctl-papr-Fix-probe-for-papr-scm-compatible-nvdi.patch
+   + 0003-libndctl-Unify-adding-dimms-for-papr-and-nfit-famili.patch
+- Merge fixes that went into v72 and v73
+   - Documentation updates
+      + 0015-ndctl-docs-Clarify-update-firwmware-activation-overf.patch
+      + 0014-Documentation-ndctl-fix-self-reference-of-ndctl-disa.patch
+      + 0013-daxctl-Add-Soft-Reservation-theory-of-operation.patch
+      + 0008-ndctl-Update-nvdimm-mailing-list-address.patch
+   - Label index block calculation fix
+      + 0012-ndctl-dimm-Fix-label-index-block-calculations.patch
+      + 0002-Expose-ndctl_bus_nfit_translate_spa-as-a-public-func.patch
+   - Scrub fix
+      + 0011-ndctl-scrub-Reread-scrub-engine-status-at-start.patch
+      + 0010-ndctl-scrub-Stop-translating-return-values.patch
+   - Add memblock count to JSON
+      + 0007-daxctl-emit-counts-of-total-and-online-memblocks.patch
+   - DAX disable fix
+      + 0006-libndctl-check-for-active-system-ram-before-disablin.patch
+      + 0005-libdaxctl-add-an-API-to-check-if-a-device-is-active.patch
+      + 0001-ndctl-namespace-Fix-disable-namespace-accounting-rel.patch
+   - DAX reconfigure fix
+      + 0004-daxctl-fail-reconfigure-device-based-on-kernel-onlin.patch
+
+-------------------------------------------------------------------
+Fri Mar  4 13:08:55 UTC 2022 - Martin Wilck <mwi...@suse.com>
+
+- Install modprobe.conf file to %_modprobedir (bsc#1196275, jsc#SLE-20639) 
+
+-------------------------------------------------------------------

New:
----
  0001-ndctl-namespace-Fix-disable-namespace-accounting-rel.patch
  0002-Expose-ndctl_bus_nfit_translate_spa-as-a-public-func.patch
  0003-libndctl-Unify-adding-dimms-for-papr-and-nfit-famili.patch
  0004-daxctl-fail-reconfigure-device-based-on-kernel-onlin.patch
  0005-libdaxctl-add-an-API-to-check-if-a-device-is-active.patch
  0006-libndctl-check-for-active-system-ram-before-disablin.patch
  0007-daxctl-emit-counts-of-total-and-online-memblocks.patch
  0008-ndctl-Update-nvdimm-mailing-list-address.patch
  0009-libndctl-papr-Fix-probe-for-papr-scm-compatible-nvdi.patch
  0010-ndctl-scrub-Stop-translating-return-values.patch
  0011-ndctl-scrub-Reread-scrub-engine-status-at-start.patch
  0012-ndctl-dimm-Fix-label-index-block-calculations.patch
  0013-daxctl-Add-Soft-Reservation-theory-of-operation.patch
  0014-Documentation-ndctl-fix-self-reference-of-ndctl-disa.patch
  0015-ndctl-docs-Clarify-update-firwmware-activation-overf.patch
  0016-libndctl-papr-Add-support-for-reporting-shutdown-cou.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ndctl.spec ++++++
--- /var/tmp/diff_new_pack.h2dhsR/_old  2022-03-13 20:25:04.899649313 +0100
+++ /var/tmp/diff_new_pack.h2dhsR/_new  2022-03-13 20:25:04.907649321 +0100
@@ -16,6 +16,11 @@
 # Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
+%if 0%{?suse_version} < 1550 && 0%{?sle_version} <= 150300
+# systemd-rpm-macros is wrong in 15.3 and below
+%define _modprobedir /lib/modprobe.d
+%endif
+%global modprobe_d_files nvdimm-security.conf
 
 %define lname libndctl6
 %define dname libndctl-devel
@@ -30,6 +35,22 @@
 Patch9:         %{name}-namespace-skip-zero-namespaces-when-processing.patch
 Patch13:        %{name}-namespace-Suppress-ENXIO-when-processing-all-n.patch
 Patch14:       harden_ndctl-monitor.service.patch
+Patch15:        0001-ndctl-namespace-Fix-disable-namespace-accounting-rel.patch
+Patch16:        0002-Expose-ndctl_bus_nfit_translate_spa-as-a-public-func.patch
+Patch17:        0003-libndctl-Unify-adding-dimms-for-papr-and-nfit-famili.patch
+Patch18:        0004-daxctl-fail-reconfigure-device-based-on-kernel-onlin.patch
+Patch19:        0005-libdaxctl-add-an-API-to-check-if-a-device-is-active.patch
+Patch20:        0006-libndctl-check-for-active-system-ram-before-disablin.patch
+Patch21:        0007-daxctl-emit-counts-of-total-and-online-memblocks.patch
+Patch22:        0008-ndctl-Update-nvdimm-mailing-list-address.patch
+Patch23:        0009-libndctl-papr-Fix-probe-for-papr-scm-compatible-nvdi.patch
+Patch24:        0010-ndctl-scrub-Stop-translating-return-values.patch
+Patch25:        0011-ndctl-scrub-Reread-scrub-engine-status-at-start.patch
+Patch26:        0012-ndctl-dimm-Fix-label-index-block-calculations.patch
+Patch27:        0013-daxctl-Add-Soft-Reservation-theory-of-operation.patch
+Patch28:        0014-Documentation-ndctl-fix-self-reference-of-ndctl-disa.patch
+Patch29:        0015-ndctl-docs-Clarify-update-firwmware-activation-overf.patch
+Patch30:        0016-libndctl-papr-Add-support-for-reporting-shutdown-cou.patch
 BuildRequires:  autoconf
 BuildRequires:  automake
 BuildRequires:  keyutils-devel
@@ -107,15 +128,21 @@
 %if 0%{?suse_version} > 1500
 export CFLAGS="%optflags -fcommon"
 %endif
-%make_install
+%make_install modprobedir=%{_modprobedir}
 find %{buildroot} -type f -name "*.la" -delete -print
 mkdir -p %{buildroot}%{_sbindir}
 ln -sf service %{buildroot}%{_sbindir}/rcndctl-monitor
 
 %post -n %{lname} -p /sbin/ldconfig
 %postun -n %{lname} -p /sbin/ldconfig
+
 %pre
 %service_add_pre ndctl-monitor.service
+# Avoid restoring outdated stuff in posttrans
+for _f in %{?modprobe_d_files}; do
+    [ ! -f "/etc/modprobe.d/${_f}.rpmsave" ] || \
+        mv -f "/etc/modprobe.d/${_f}.rpmsave" 
"/etc/modprobe.d/${_f}.rpmsave.old" || :
+done
 
 %post
 %service_add_post ndctl-monitor.service
@@ -126,6 +153,13 @@
 %postun
 %service_del_postun ndctl-monitor.service
 
+%posttrans
+# Migration of modprobe.conf files to _modprobedir
+for _f in %{?modprobe_d_files}; do
+    [ ! -f "/etc/modprobe.d/${_f}.rpmsave" ] || \
+        mv -fv "/etc/modprobe.d/${_f}.rpmsave" "/etc/modprobe.d/${_f}" || :
+done
+
 %files
 %license COPYING LICENSES/*/*
 %doc README.md CONTRIBUTING.md
@@ -137,8 +171,8 @@
 %dir %{_sysconfdir}/ndctl/keys
 %{_sysconfdir}/ndctl/keys/keys.readme
 %config %{_sysconfdir}/ndctl/monitor.conf
-%dir %{_sysconfdir}/modprobe.d
-%config %{_sysconfdir}/modprobe.d/nvdimm-security.conf
+%dir %{_modprobedir}
+%{_modprobedir}/nvdimm-security.conf
 %{_unitdir}/ndctl-monitor.service
 %dir %{_datadir}/bash-completion/
 %dir %{_datadir}/bash-completion/completions/

++++++ 0001-ndctl-namespace-Fix-disable-namespace-accounting-rel.patch ++++++
>From fe626a8a8a1b1bc94ea95c693ec672109909e3dc Mon Sep 17 00:00:00 2001
From: Redhairer Li <redhairer...@intel.com>
Date: Thu, 28 Jan 2021 22:03:39 +0800
Subject: [PATCH] ndctl/namespace: Fix disable-namespace accounting relative to
 seed devices

Upstream: v72
Git-commit: fe626a8a8a1b1bc94ea95c693ec672109909e3dc

Seed namespaces are included in "ndctl disable-namespace all". However
since the user never "creates" them it is surprising to see
"disable-namespace" report 1 more namespace relative to the number that
have been created. Catch attempts to disable a zero-sized namespace:

Before:
{
  "dev":"namespace1.0",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1"
}
{
  "dev":"namespace1.1",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.1"
}
{
  "dev":"namespace1.2",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.2"
}
disabled 4 namespaces

After:
{
  "dev":"namespace1.0",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1"
}
{
  "dev":"namespace1.3",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.3"
}
{
  "dev":"namespace1.1",
  "size":"492.00 MiB (515.90 MB)",
  "blockdev":"pmem1.1"
}
disabled 3 namespaces

Signed-off-by: Redhairer Li <redhairer...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
Link: 
https://lore.kernel.org/linux-nvdimm/20210128140339.3080-1-redhairer...@intel.com/
---
 ndctl/lib/libndctl.c | 10 ++++++++--
 ndctl/namespace.c    |  8 ++++----
 ndctl/region.c       |  2 +-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 36fb6fe..2f6d806 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -4602,6 +4602,7 @@ NDCTL_EXPORT int ndctl_namespace_disable_safe(struct 
ndctl_namespace *ndns)
        const char *bdev = NULL;
        char path[50];
        int fd;
+       unsigned long long size = ndctl_namespace_get_size(ndns);
 
        if (pfn && ndctl_pfn_is_enabled(pfn))
                bdev = ndctl_pfn_get_block_device(pfn);
@@ -4631,8 +4632,13 @@ NDCTL_EXPORT int ndctl_namespace_disable_safe(struct 
ndctl_namespace *ndns)
                                        devname, bdev, strerror(errno));
                        return -errno;
                }
-       } else
-               ndctl_namespace_disable_invalidate(ndns);
+       } else {
+               if (size == 0)
+                       /* No disable necessary due to no capacity allocated */
+                       return 1;
+               else
+                       ndctl_namespace_disable_invalidate(ndns);
+       }
 
        return 0;
 }
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 0c8df9f..1feb74d 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -1125,7 +1125,7 @@ static int namespace_prep_reconfig(struct ndctl_region 
*region,
        }
 
        rc = ndctl_namespace_disable_safe(ndns);
-       if (rc)
+       if (rc < 0)
                return rc;
 
        ndctl_namespace_set_enforce_mode(ndns, NDCTL_NS_MODE_RAW);
@@ -1431,7 +1431,7 @@ static int dax_clear_badblocks(struct ndctl_dax *dax)
                return -ENXIO;
 
        rc = ndctl_namespace_disable_safe(ndns);
-       if (rc) {
+       if (rc < 0) {
                error("%s: unable to disable namespace: %s\n", devname,
                        strerror(-rc));
                return rc;
@@ -1455,7 +1455,7 @@ static int pfn_clear_badblocks(struct ndctl_pfn *pfn)
                return -ENXIO;
 
        rc = ndctl_namespace_disable_safe(ndns);
-       if (rc) {
+       if (rc < 0) {
                error("%s: unable to disable namespace: %s\n", devname,
                        strerror(-rc));
                return rc;
@@ -1478,7 +1478,7 @@ static int raw_clear_badblocks(struct ndctl_namespace 
*ndns)
                return -ENXIO;
 
        rc = ndctl_namespace_disable_safe(ndns);
-       if (rc) {
+       if (rc < 0) {
                error("%s: unable to disable namespace: %s\n", devname,
                        strerror(-rc));
                return rc;
diff --git a/ndctl/region.c b/ndctl/region.c
index 3edb9b3..4552c4a 100644
--- a/ndctl/region.c
+++ b/ndctl/region.c
@@ -70,7 +70,7 @@ static int region_action(struct ndctl_region *region, enum 
device_action mode)
        case ACTION_DISABLE:
                ndctl_namespace_foreach(region, ndns) {
                        rc = ndctl_namespace_disable_safe(ndns);
-                       if (rc)
+                       if (rc < 0)
                                return rc;
                }
                rc = ndctl_region_disable_invalidate(region);
-- 
2.35.1


++++++ 0002-Expose-ndctl_bus_nfit_translate_spa-as-a-public-func.patch ++++++
>From c81fa15bafb1295aaa7d7f09500c3fbdd68b0011 Mon Sep 17 00:00:00 2001
From: "Tsaur, Erwin" <erwin.ts...@intel.com>
Date: Thu, 4 Mar 2021 17:18:04 -0800
Subject: [PATCH] Expose ndctl_bus_nfit_translate_spa as a public function.

Upstream: v72
Git-commit: c81fa15bafb1295aaa7d7f09500c3fbdd68b0011

The motivation is to allow access to ACPI defined NVDIMM Root Device
_DSM Function Index 5(Translate SPA).  The rest of the _DSM functions,
which are mostly ARS related, are already public.

Basically move ndctl_bus_nfit_translate_spa declaration from private.h
to libndctl.h.

Reviewed-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: "Tsaur, Erwin" <erwin.ts...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
Link: https://lore.kernel.org/r/20210305011804.3573-1-erwin.ts...@intel.com
---
 ndctl/lib/libndctl.sym | 4 ++++
 ndctl/lib/nfit.c       | 2 +-
 ndctl/lib/private.h    | 2 --
 ndctl/libndctl.h       | 2 ++
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index 0a82616..58afb74 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -451,3 +451,7 @@ LIBNDCTL_25 {
        ndctl_bus_clear_fw_activate_nosuspend;
        ndctl_bus_activate_firmware;
 } LIBNDCTL_24;
+
+LIBNDCTL_26 {
+       ndctl_bus_nfit_translate_spa;
+} LIBNDCTL_25;
diff --git a/ndctl/lib/nfit.c b/ndctl/lib/nfit.c
index 6f68fcf..d85682f 100644
--- a/ndctl/lib/nfit.c
+++ b/ndctl/lib/nfit.c
@@ -114,7 +114,7 @@ static int is_valid_spa(struct ndctl_bus *bus, unsigned 
long long spa)
  *
  * If success, returns zero, store dimm's @handle, and @dpa.
  */
-int ndctl_bus_nfit_translate_spa(struct ndctl_bus *bus,
+NDCTL_EXPORT int ndctl_bus_nfit_translate_spa(struct ndctl_bus *bus,
        unsigned long long address, unsigned int *handle, unsigned long long 
*dpa)
 {
 
diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h
index ede1300..8f4510e 100644
--- a/ndctl/lib/private.h
+++ b/ndctl/lib/private.h
@@ -370,8 +370,6 @@ static inline int check_kmod(struct kmod_ctx *kmod_ctx)
        return kmod_ctx ? 0 : -ENXIO;
 }
 
-int ndctl_bus_nfit_translate_spa(struct ndctl_bus *bus, unsigned long long 
addr,
-               unsigned int *handle, unsigned long long *dpa);
 struct ndctl_cmd *ndctl_bus_cmd_new_err_inj(struct ndctl_bus *bus);
 struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_clr(struct ndctl_bus *bus);
 struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_stat(struct ndctl_bus *bus,
diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
index 60e1288..87d07b7 100644
--- a/ndctl/libndctl.h
+++ b/ndctl/libndctl.h
@@ -152,6 +152,8 @@ int ndctl_bus_clear_fw_activate_noidle(struct ndctl_bus 
*bus);
 int ndctl_bus_set_fw_activate_nosuspend(struct ndctl_bus *bus);
 int ndctl_bus_clear_fw_activate_nosuspend(struct ndctl_bus *bus);
 int ndctl_bus_activate_firmware(struct ndctl_bus *bus, enum ndctl_fwa_method 
method);
+int ndctl_bus_nfit_translate_spa(struct ndctl_bus *bus, unsigned long long 
addr,
+               unsigned int *handle, unsigned long long *dpa);
 
 struct ndctl_dimm;
 struct ndctl_dimm *ndctl_dimm_get_first(struct ndctl_bus *bus);
-- 
2.35.1


++++++ 0003-libndctl-Unify-adding-dimms-for-papr-and-nfit-famili.patch ++++++
>From daef3a386a9c45105a2c045ddee46600e265939f Mon Sep 17 00:00:00 2001
From: Santosh Sivaraj <sant...@fossix.org>
Date: Thu, 13 May 2021 11:42:15 +0530
Subject: [PATCH] libndctl: Unify adding dimms for papr and nfit families

Upstream: v72
Git-commit: daef3a386a9c45105a2c045ddee46600e265939f

In preparation for enabling tests on non-nfit devices, unify both, already very
similar, functions into one. This will help in adding all attributes needed for
the unit tests. Since the function doesn't fail if some of the dimm attributes
are missing, this will work fine on PAPR platforms though only part of the DIMM
attributes are provided (This doesn't mean that all of the DIMM attributes can
be missing).

Link: https://lore.kernel.org/r/20210513061218.760322-1-sant...@fossix.org
Signed-off-by: Santosh Sivaraj <sant...@fossix.org>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 ndctl/lib/libndctl.c | 103 ++++++++++++++++---------------------------
 1 file changed, 38 insertions(+), 65 deletions(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 2f6d806..e45353f 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1646,41 +1646,9 @@ static int ndctl_bind(struct ndctl_ctx *ctx, struct 
kmod_module *module,
 static int ndctl_unbind(struct ndctl_ctx *ctx, const char *devpath);
 static struct kmod_module *to_module(struct ndctl_ctx *ctx, const char *alias);
 
-static int add_papr_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
-{
-       int rc = -ENODEV;
-       char buf[SYSFS_ATTR_SIZE];
-       struct ndctl_ctx *ctx = dimm->bus->ctx;
-       char *path = calloc(1, strlen(dimm_base) + 100);
-       const char * const devname = ndctl_dimm_get_devname(dimm);
-
-       dbg(ctx, "%s: Probing of_pmem dimm at %s\n", devname, dimm_base);
-
-       if (!path)
-               return -ENOMEM;
-
-       /* construct path to the papr compatible dimm flags file */
-       sprintf(path, "%s/papr/flags", dimm_base);
-
-       if (ndctl_bus_is_papr_scm(dimm->bus) &&
-           sysfs_read_attr(ctx, path, buf) == 0) {
-
-               dbg(ctx, "%s: Adding papr-scm dimm flags:\"%s\"\n", devname, 
buf);
-               dimm->cmd_family = NVDIMM_FAMILY_PAPR;
-
-               /* Parse dimm flags */
-               parse_papr_flags(dimm, buf);
-
-               /* Allocate monitor mode fd */
-               dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
-               rc = 0;
-       }
-
-       free(path);
-       return rc;
-}
-
-static int add_nfit_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
+static int populate_dimm_attributes(struct ndctl_dimm *dimm,
+                                   const char *dimm_base,
+                                   const char *bus_prefix)
 {
        int i, rc = -1;
        char buf[SYSFS_ATTR_SIZE];
@@ -1694,7 +1662,7 @@ static int add_nfit_dimm(struct ndctl_dimm *dimm, const 
char *dimm_base)
         * 'unique_id' may not be available on older kernels, so don't
         * fail if the read fails.
         */
-       sprintf(path, "%s/nfit/id", dimm_base);
+       sprintf(path, "%s/%s/id", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0) {
                unsigned int b[9];
 
@@ -1709,68 +1677,74 @@ static int add_nfit_dimm(struct ndctl_dimm *dimm, const 
char *dimm_base)
                }
        }
 
-       sprintf(path, "%s/nfit/handle", dimm_base);
+       sprintf(path, "%s/%s/handle", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) < 0)
                goto err_read;
        dimm->handle = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/phys_id", dimm_base);
+       sprintf(path, "%s/%s/phys_id", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) < 0)
                goto err_read;
        dimm->phys_id = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/serial", dimm_base);
+       sprintf(path, "%s/%s/serial", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->serial = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/vendor", dimm_base);
+       sprintf(path, "%s/%s/vendor", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->vendor_id = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/device", dimm_base);
+       sprintf(path, "%s/%s/device", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->device_id = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/rev_id", dimm_base);
+       sprintf(path, "%s/%s/rev_id", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->revision_id = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/dirty_shutdown", dimm_base);
+       sprintf(path, "%s/%s/dirty_shutdown", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->dirty_shutdown = strtoll(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/subsystem_vendor", dimm_base);
+       sprintf(path, "%s/%s/subsystem_vendor", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->subsystem_vendor_id = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/subsystem_device", dimm_base);
+       sprintf(path, "%s/%s/subsystem_device", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->subsystem_device_id = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/subsystem_rev_id", dimm_base);
+       sprintf(path, "%s/%s/subsystem_rev_id", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->subsystem_revision_id = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/family", dimm_base);
+       sprintf(path, "%s/%s/family", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->cmd_family = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/dsm_mask", dimm_base);
+       sprintf(path, "%s/%s/dsm_mask", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->nfit_dsm_mask = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/format", dimm_base);
+       sprintf(path, "%s/%s/format", dimm_base, bus_prefix);
        if (sysfs_read_attr(ctx, path, buf) == 0)
                dimm->format[0] = strtoul(buf, NULL, 0);
        for (i = 1; i < dimm->formats; i++) {
-               sprintf(path, "%s/nfit/format%d", dimm_base, i);
+               sprintf(path, "%s/%s/format%d", dimm_base, bus_prefix, i);
                if (sysfs_read_attr(ctx, path, buf) == 0)
                        dimm->format[i] = strtoul(buf, NULL, 0);
        }
 
-       sprintf(path, "%s/nfit/flags", dimm_base);
-       if (sysfs_read_attr(ctx, path, buf) == 0)
-               parse_nfit_mem_flags(dimm, buf);
+       sprintf(path, "%s/%s/flags", dimm_base, bus_prefix);
+       if (sysfs_read_attr(ctx, path, buf) == 0) {
+               if (ndctl_bus_has_nfit(dimm->bus))
+                       parse_nfit_mem_flags(dimm, buf);
+               else if (ndctl_bus_is_papr_scm(dimm->bus)) {
+                       dimm->cmd_family = NVDIMM_FAMILY_PAPR;
+                       parse_papr_flags(dimm, buf);
+               }
+       }
 
        dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
        rc = 0;
@@ -1792,7 +1766,8 @@ static void *add_dimm(void *parent, int id, const char 
*dimm_base)
        if (!path)
                return NULL;
 
-       sprintf(path, "%s/nfit/formats", dimm_base);
+       sprintf(path, "%s/%s/formats", dimm_base,
+               ndctl_bus_has_nfit(bus) ? "nfit" : "papr");
        if (sysfs_read_attr(ctx, path, buf) < 0)
                formats = 1;
        else
@@ -1866,13 +1841,12 @@ static void *add_dimm(void *parent, int id, const char 
*dimm_base)
        else
                dimm->fwa_result = fwa_result_to_result(buf);
 
+       dimm->formats = formats;
        /* Check if the given dimm supports nfit */
        if (ndctl_bus_has_nfit(bus)) {
-               dimm->formats = formats;
-               rc = add_nfit_dimm(dimm, dimm_base);
-       } else if (ndctl_bus_has_of_node(bus)) {
-               rc = add_papr_dimm(dimm, dimm_base);
-       }
+               rc = populate_dimm_attributes(dimm, dimm_base, "nfit");
+       } else if (ndctl_bus_has_of_node(bus))
+               rc = populate_dimm_attributes(dimm, dimm_base, "papr");
 
        if (rc == -ENODEV) {
                /* Unprobed dimm with no family */
@@ -2531,13 +2505,12 @@ static void *add_region(void *parent, int id, const 
char *region_base)
                goto err_read;
        region->num_mappings = strtoul(buf, NULL, 0);
 
-       sprintf(path, "%s/nfit/range_index", region_base);
-       if (ndctl_bus_has_nfit(bus)) {
-               if (sysfs_read_attr(ctx, path, buf) < 0)
-                       goto err_read;
-               region->range_index = strtoul(buf, NULL, 0);
-       } else
+       sprintf(path, "%s/%s/range_index", region_base,
+               ndctl_bus_has_nfit(bus) ? "nfit": "papr");
+       if (sysfs_read_attr(ctx, path, buf) < 0)
                region->range_index = -1;
+       else
+               region->range_index = strtoul(buf, NULL, 0);
 
        sprintf(path, "%s/read_only", region_base);
        if (sysfs_read_attr(ctx, path, buf) < 0)
-- 
2.35.1


++++++ 0004-daxctl-fail-reconfigure-device-based-on-kernel-onlin.patch ++++++
>From 99415dfc7c5167c49a5732f577836f68872645b2 Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.ve...@intel.com>
Date: Wed, 24 Mar 2021 12:09:29 -0700
Subject: [PATCH] daxctl: fail reconfigure-device based on kernel onlining
 policy

Upstream: v72
Git-commit: 99415dfc7c5167c49a5732f577836f68872645b2

If the kernel has a policy set to auto-online any new memory blocks, we
know that an attempt to reconfigure a device either in ZONE_MOVABLE, or
with the --no-online is going to fail. While we detect this race after
the fact, and print a warning, that is often insufficient as the user
may be forced to reboot to get out of the situation, resulting in an
unpleasant experience.

Detect whether the kernel policy is set to auto-online. If so, fail
device reconfigure operations that we know can't be satisfied. Allow
for overriding this safety check via the -f (--force) option. Update the
man page to talk about this, and the unit test to test for an expected
failure by enabling auto-onlining.

Cc: Dave Hansen <dave.han...@intel.com>
Reported-by: Chunye Xu <chunye...@intel.com>
Reported-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 .../daxctl/daxctl-reconfigure-device.txt      | 12 ++++++-
 daxctl/device.c                               | 10 ++++++
 daxctl/lib/libdaxctl-private.h                |  1 +
 daxctl/lib/libdaxctl.c                        | 21 +++++++++++
 daxctl/lib/libdaxctl.sym                      |  5 +++
 daxctl/libdaxctl.h                            |  1 +
 test/daxctl-devices.sh                        | 36 +++++++++++++++++++
 7 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/Documentation/daxctl/daxctl-reconfigure-device.txt 
b/Documentation/daxctl/daxctl-reconfigure-device.txt
index ad33eda..f112b3c 100644
--- a/Documentation/daxctl/daxctl-reconfigure-device.txt
+++ b/Documentation/daxctl/daxctl-reconfigure-device.txt
@@ -119,6 +119,10 @@ recommended to use the --no-online option described below. 
This will abridge
 the device reconfiguration operation to just hotplugging the memory, and
 refrain from then onlining it.
 
+In case daxctl detects that there is a kernel policy to auto-online blocks
+(via /sys/devices/system/memory/auto_online_blocks), then reconfiguring to
+system-ram will result in a failure. This can be overridden with '--force'.
+
 OPTIONS
 -------
 include::region-option.txt[]
@@ -162,12 +166,18 @@ include::movable-options.txt[]
 
 -f::
 --force::
-       When converting from "system-ram" mode to "devdax", it is expected
+       - When converting from "system-ram" mode to "devdax", it is expected
        that all the memory sections are first made offline. By default,
        daxctl won't touch online memory. However with this option, attempt
        to offline the memory on the NUMA node associated with the dax device
        before converting it back to "devdax" mode.
 
+       - Additionally, if a kernel policy to auto-online blocks is detected,
+       reconfiguration to system-ram fails. With this option, the failure can
+       be overridden to allow reconfiguration regardless of kernel policy.
+       Doing this may result in a successful reconfiguration, but it may
+       not be possible to subsequently offline the memory without a reboot.
+
 
 include::human-option.txt[]
 
diff --git a/daxctl/device.c b/daxctl/device.c
index 0721a57..a427b7d 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -541,8 +541,18 @@ static int disable_devdax_device(struct daxctl_dev *dev)
 
 static int reconfig_mode_system_ram(struct daxctl_dev *dev)
 {
+       const char *devname = daxctl_dev_get_devname(dev);
        int rc, skip_enable = 0;
 
+       if (param.no_online || !param.no_movable) {
+               if (!param.force && daxctl_dev_will_auto_online_memory(dev)) {
+                       fprintf(stderr,
+                               "%s: error: kernel policy will auto-online 
memory, aborting\n",
+                               devname);
+                       return -EBUSY;
+               }
+       }
+
        if (daxctl_dev_is_enabled(dev)) {
                rc = disable_devdax_device(dev);
                if (rc < 0)
diff --git a/daxctl/lib/libdaxctl-private.h b/daxctl/lib/libdaxctl-private.h
index af257fd..ae45311 100644
--- a/daxctl/lib/libdaxctl-private.h
+++ b/daxctl/lib/libdaxctl-private.h
@@ -111,6 +111,7 @@ struct daxctl_memory {
        char *node_path;
        unsigned long block_size;
        enum memory_zones zone;
+       bool auto_online;
 };
 
 
diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 479e8f6..879f7e6 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -1644,3 +1644,24 @@ DAXCTL_EXPORT int daxctl_memory_is_movable(struct 
daxctl_memory *mem)
                return rc;
        return (mem->zone == MEM_ZONE_MOVABLE) ? 1 : 0;
 }
+
+DAXCTL_EXPORT int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev)
+{
+       const char *auto_path = "/sys/devices/system/memory/auto_online_blocks";
+       const char *devname = daxctl_dev_get_devname(dev);
+       struct daxctl_ctx *ctx = daxctl_dev_get_ctx(dev);
+       char buf[SYSFS_ATTR_SIZE];
+
+       /*
+        * If we can't read the policy for some reason, don't fail yet. Assume
+        * the auto-onlining policy is absent, and carry on. If onlining blocks
+        * does result in the memory being in an inconsistent state, we have a
+        * check and warning for it after the fact
+        */
+       if (sysfs_read_attr(ctx, auto_path, buf) != 0)
+               err(ctx, "%s: Unable to determine auto-online policy: %s\n",
+                               devname, strerror(errno));
+
+       /* match both "online" and "online_movable" */
+       return !strncmp(buf, "online", 6);
+}
diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym
index a4e1684..892e393 100644
--- a/daxctl/lib/libdaxctl.sym
+++ b/daxctl/lib/libdaxctl.sym
@@ -91,3 +91,8 @@ global:
        daxctl_mapping_get_size;
        daxctl_dev_set_mapping;
 } LIBDAXCTL_7;
+
+LIBDAXCTL_9 {
+global:
+       daxctl_dev_will_auto_online_memory;
+} LIBDAXCTL_8;
diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h
index e82b274..30ab51a 100644
--- a/daxctl/libdaxctl.h
+++ b/daxctl/libdaxctl.h
@@ -71,6 +71,7 @@ int daxctl_dev_disable(struct daxctl_dev *dev);
 int daxctl_dev_enable_devdax(struct daxctl_dev *dev);
 int daxctl_dev_enable_ram(struct daxctl_dev *dev);
 int daxctl_dev_get_target_node(struct daxctl_dev *dev);
+int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev);
 
 struct daxctl_memory;
 struct daxctl_memory *daxctl_dev_get_memory(struct daxctl_dev *dev);
diff --git a/test/daxctl-devices.sh b/test/daxctl-devices.sh
index 496e4f2..eed5906 100755
--- a/test/daxctl-devices.sh
+++ b/test/daxctl-devices.sh
@@ -64,6 +64,26 @@ daxctl_get_mode()
        "$DAXCTL" list -d "$1" | jq -er '.[].mode'
 }
 
+set_online_policy()
+{
+       echo "online" > /sys/devices/system/memory/auto_online_blocks
+}
+
+unset_online_policy()
+{
+       echo "offline" > /sys/devices/system/memory/auto_online_blocks
+}
+
+save_online_policy()
+{
+       saved_policy="$(cat /sys/devices/system/memory/auto_online_blocks)"
+}
+
+restore_online_policy()
+{
+       echo "$saved_policy" > /sys/devices/system/memory/auto_online_blocks
+}
+
 daxctl_test()
 {
        local daxdev
@@ -71,6 +91,9 @@ daxctl_test()
        daxdev=$(daxctl_get_dev "$testdev")
        test -n "$daxdev"
 
+       # these tests need to run with kernel onlining policy turned off
+       save_online_policy
+       unset_online_policy
        "$DAXCTL" reconfigure-device -N -m system-ram "$daxdev"
        [[ $(daxctl_get_mode "$daxdev") == "system-ram" ]]
        "$DAXCTL" online-memory "$daxdev"
@@ -81,6 +104,19 @@ daxctl_test()
        [[ $(daxctl_get_mode "$daxdev") == "system-ram" ]]
        "$DAXCTL" reconfigure-device -f -m devdax "$daxdev"
        [[ $(daxctl_get_mode "$daxdev") == "devdax" ]]
+
+       # this tests for reconfiguration failure if an online-policy is set
+       set_online_policy
+       : "This command is expected to fail:"
+       if ! "$DAXCTL" reconfigure-device -N -m system-ram "$daxdev"; then
+               echo "reconfigure failed as expected"
+       else
+               echo "reconfigure succeded, expected failure"
+               restore_online_policy
+               return 1
+       fi
+
+       restore_online_policy
 }
 
 find_testdev
-- 
2.35.1


++++++ 0005-libdaxctl-add-an-API-to-check-if-a-device-is-active.patch ++++++
>From e563e6a7c55e65c554e07db6215f8bcb2d411d3b Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.ve...@intel.com>
Date: Tue, 30 Mar 2021 20:50:37 -0600
Subject: [PATCH] libdaxctl: add an API to check if a device is active

Upstream: v72
Git-commit: e563e6a7c55e65c554e07db6215f8bcb2d411d3b

Add an API to check whether a daxctl device is active in system-ram
mode. This would be used from libndctl during
ndctl_namespace_disable_safe(), so that we don't disable/destroy an
underlying namespace while the memory is active and online.

Reported-by: Chunye Xu <chunye...@intel.com>
Cc: Dan Williams <dan.j.willi...@intel.com>
Cc: Dave Hansen <dave.han...@linux.intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 daxctl/lib/libdaxctl.c   | 10 ++++++++++
 daxctl/lib/libdaxctl.sym |  1 +
 daxctl/libdaxctl.h       |  1 +
 3 files changed, 12 insertions(+)

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index 879f7e6..860bd9c 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -1665,3 +1665,13 @@ DAXCTL_EXPORT int 
daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev)
        /* match both "online" and "online_movable" */
        return !strncmp(buf, "online", 6);
 }
+
+DAXCTL_EXPORT int daxctl_dev_has_online_memory(struct daxctl_dev *dev)
+{
+       struct daxctl_memory *mem = daxctl_dev_get_memory(dev);
+
+       if (mem)
+               return daxctl_memory_is_online(mem);
+       else
+               return 0;
+}
diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym
index 892e393..a13e93d 100644
--- a/daxctl/lib/libdaxctl.sym
+++ b/daxctl/lib/libdaxctl.sym
@@ -95,4 +95,5 @@ global:
 LIBDAXCTL_9 {
 global:
        daxctl_dev_will_auto_online_memory;
+       daxctl_dev_has_online_memory;
 } LIBDAXCTL_8;
diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h
index 30ab51a..683ae9c 100644
--- a/daxctl/libdaxctl.h
+++ b/daxctl/libdaxctl.h
@@ -72,6 +72,7 @@ int daxctl_dev_enable_devdax(struct daxctl_dev *dev);
 int daxctl_dev_enable_ram(struct daxctl_dev *dev);
 int daxctl_dev_get_target_node(struct daxctl_dev *dev);
 int daxctl_dev_will_auto_online_memory(struct daxctl_dev *dev);
+int daxctl_dev_has_online_memory(struct daxctl_dev *dev);
 
 struct daxctl_memory;
 struct daxctl_memory *daxctl_dev_get_memory(struct daxctl_dev *dev);
-- 
2.35.1


++++++ 0006-libndctl-check-for-active-system-ram-before-disablin.patch ++++++
>From 573f0d46cff15fff2804b3fb444d1e34f482e788 Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.ve...@intel.com>
Date: Tue, 30 Mar 2021 20:54:55 -0600
Subject: [PATCH] libndctl: check for active system-ram before disabling daxctl
 devices

Upstream: v72
Git-commit: 573f0d46cff15fff2804b3fb444d1e34f482e788

Teach ndctl_namespace_disable_safe() to look at the state of a
daxctl_dev with respect to whether it is active in 'system-ram' mode
before disabling it. This is similar to checking whether a filesystem is
actively mounted on a namespace before disabling it.

Without this, libndctl would happily disable a devdax namespace while the
device was active in system-ram mode. If the namespace was subsequently
also destroyed, this would leave the memory without any sort of a
'handle' to perform any subsequent operation on it, and the system would
have to be rebooted to get out of this situation.

Reported-by: Chunye Xu <chunye...@intel.com>
Cc: Dan Williams <dan.j.willi...@intel.com>
Cc: Dave Hansen <dave.han...@linux.intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 ndctl/lib/libndctl.c   | 25 ++++++++++++++++++++++++-
 test/daxctl-devices.sh | 16 ++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 2f6d806..2eda56c 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -4593,21 +4593,40 @@ NDCTL_EXPORT int 
ndctl_namespace_disable_invalidate(struct ndctl_namespace *ndns
        return ndctl_namespace_disable(ndns);
 }
 
+static int ndctl_dax_has_active_memory(struct ndctl_dax *dax)
+{
+       struct daxctl_region *dax_region;
+       struct daxctl_dev *dax_dev;
+
+       dax_region = ndctl_dax_get_daxctl_region(dax);
+       if (!dax_region)
+               return 0;
+
+       daxctl_dev_foreach(dax_region, dax_dev)
+               if (daxctl_dev_has_online_memory(dax_dev))
+                       return 1;
+
+       return 0;
+}
+
 NDCTL_EXPORT int ndctl_namespace_disable_safe(struct ndctl_namespace *ndns)
 {
        const char *devname = ndctl_namespace_get_devname(ndns);
        struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
        struct ndctl_pfn *pfn = ndctl_namespace_get_pfn(ndns);
        struct ndctl_btt *btt = ndctl_namespace_get_btt(ndns);
+       struct ndctl_dax *dax = ndctl_namespace_get_dax(ndns);
        const char *bdev = NULL;
+       int fd, active = 0;
        char path[50];
-       int fd;
        unsigned long long size = ndctl_namespace_get_size(ndns);
 
        if (pfn && ndctl_pfn_is_enabled(pfn))
                bdev = ndctl_pfn_get_block_device(pfn);
        else if (btt && ndctl_btt_is_enabled(btt))
                bdev = ndctl_btt_get_block_device(btt);
+       else if (dax && ndctl_dax_is_enabled(dax))
+               active = ndctl_dax_has_active_memory(dax);
        else if (ndctl_namespace_is_enabled(ndns))
                bdev = ndctl_namespace_get_block_device(ndns);
 
@@ -4632,6 +4651,10 @@ NDCTL_EXPORT int ndctl_namespace_disable_safe(struct 
ndctl_namespace *ndns)
                                        devname, bdev, strerror(errno));
                        return -errno;
                }
+       } else if (active) {
+               dbg(ctx, "%s: active as system-ram, refusing to disable\n",
+                               devname);
+               return -EBUSY;
        } else {
                if (size == 0)
                        /* No disable necessary due to no capacity allocated */
diff --git a/test/daxctl-devices.sh b/test/daxctl-devices.sh
index eed5906..56c9691 100755
--- a/test/daxctl-devices.sh
+++ b/test/daxctl-devices.sh
@@ -105,6 +105,22 @@ daxctl_test()
        "$DAXCTL" reconfigure-device -f -m devdax "$daxdev"
        [[ $(daxctl_get_mode "$daxdev") == "devdax" ]]
 
+       # fail 'ndctl-disable-namespace' while the devdax namespace is active
+       # as system-ram. If this test fails, a reboot will be required to
+       # recover from the resulting state.
+       test -n "$testdev"
+       "$DAXCTL" reconfigure-device -m system-ram "$daxdev"
+       [[ $(daxctl_get_mode "$daxdev") == "system-ram" ]]
+       if ! "$NDCTL" disable-namespace "$testdev"; then
+               echo "disable-namespace failed as expected"
+       else
+               echo "disable-namespace succeded, expected failure"
+               echo "reboot required to recover from this state"
+               return 1
+       fi
+       "$DAXCTL" reconfigure-device -f -m devdax "$daxdev"
+       [[ $(daxctl_get_mode "$daxdev") == "devdax" ]]
+
        # this tests for reconfiguration failure if an online-policy is set
        set_online_policy
        : "This command is expected to fail:"
-- 
2.35.1


++++++ 0007-daxctl-emit-counts-of-total-and-online-memblocks.patch ++++++
>From e81f890c7ae1c940c7f52b8984e8728706489728 Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.ve...@intel.com>
Date: Wed, 31 Mar 2021 13:51:35 -0600
Subject: [PATCH] daxctl: emit counts of total and online memblocks

Upstream: v72
Git-commit: e81f890c7ae1c940c7f52b8984e8728706489728

Fir daxctl device listings, if in 'system-ram' mode, it is useful to
know whether the memory associated with the device is online or not.
Since the memory is comprised of a number of 'memblocks', and it is
possible (albeit rare) to have a subset of them online, and the rest
offline, we can't just use a boolean online-or-offline flag for the
state.

Add a couple of counts, one for the total number of memblocks associated
with the device, and another for the ones that are online.

Link: https://github.com/pmem/ndctl/issues/139
Cc: Dan Williams <dan.j.willi...@intel.com>
Cc: Dave Hansen <dave.han...@linux.intel.com>
Reported-by: Steve Scargall <steve.scarg...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 util/json.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/util/json.c b/util/json.c
index ca0167b..a8d2412 100644
--- a/util/json.c
+++ b/util/json.c
@@ -482,6 +482,17 @@ struct json_object *util_daxctl_dev_to_json(struct 
daxctl_dev *dev,
                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);
-- 
2.35.1


++++++ 0008-ndctl-Update-nvdimm-mailing-list-address.patch ++++++
>From 063af7c447d257397a925df81897da2c71e31653 Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.ve...@intel.com>
Date: Tue, 18 May 2021 16:25:27 -0600
Subject: [PATCH] ndctl: Update nvdimm mailing list address

Upstream: v72
Git-commit: 063af7c447d257397a925df81897da2c71e31653

The 'nvdimm' mailing list has moved from lists.01.org to
lists.linux.dev. Update CONTRIBUTING.md and configure.ac to reflect
this.

Link: https://lore.kernel.org/r/20210518222527.550730-1-vishal.l.ve...@intel.com
Cc: Dan Williams <dan.j.willi...@intel.com>
Reviewed-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 CONTRIBUTING.md | 7 ++++---
 configure.ac    | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4c29d31..4f4865d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -6,13 +6,14 @@ The following is a set of guidelines that we adhere to, and 
request that
 contributors follow.
 
 1. The libnvdimm (kernel subsystem) and ndctl developers primarily use
-   the 
[linux-nvdimm](https://lists.01.org/postorius/lists/linux-nvdimm.lists.01.org/)
+   the [nvdimm](https://subspace.kernel.org/lists.linux.dev.html)
    mailing list for everything. It is recommended to send patches to
-   **```linux-nvd...@lists.01.org```**
+   **```nvd...@lists.linux.dev```**
+   An archive is available on [lore](https://lore.kernel.org/nvdimm/)
 
 1. Github [issues](https://github.com/pmem/ndctl/issues) are an acceptable
    way to report a problem, but if you just have a question,
-   [email](mailto:linux-nvd...@lists.01.org) the above list.
+   [email](mailto:nvd...@lists.linux.dev) the above list.
 
 1. We follow the Linux Kernel [Coding Style Guide][cs] as applicable.
 
diff --git a/configure.ac b/configure.ac
index 5ec8d2f..dc39dbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ(2.60)
 m4_include([version.m4])
 AC_INIT([ndctl],
         GIT_VERSION,
-        [linux-nvd...@lists.01.org],
+        [nvd...@lists.linux.dev],
         [ndctl],
         [https://github.com/pmem/ndctl])
 AC_CONFIG_SRCDIR([ndctl/lib/libndctl.c])
-- 
2.35.1


++++++ 0009-libndctl-papr-Fix-probe-for-papr-scm-compatible-nvdi.patch ++++++
>From e086106b4d81a2079141c848db7695451c04e877 Mon Sep 17 00:00:00 2001
From: Vaibhav Jain <vaib...@linux.ibm.com>
Date: Mon, 17 May 2021 21:18:24 +0530
Subject: [PATCH] libndctl/papr: Fix probe for papr-scm compatible nvdimms

Upstream: v72
Git-commit: e086106b4d81a2079141c848db7695451c04e877

With recent changes introduced for unification of PAPR and NFIT
families the probe for papr-scm nvdimms is broken since they don't
expose 'handle' or 'phys_id' sysfs attributes. These attributes are
only exposed by NFIT and 'nvdimm_test' nvdimms. Since 'unable to read'
these sysfs attributes is a non-recoverable error hence this prevents
probing of 'PAPR-SCM' nvdimms and ndctl reports following error:

$ sudo NDCTL_LOG=debug ndctl list -DH
libndctl: ndctl_new: ctx 0x10015342c70 created
libndctl: add_dimm: nmem1: probe failed: Operation not permitted
libndctl: __sysfs_device_parse: nmem1: add_dev() failed
libndctl: add_dimm: nmem0: probe failed: Operation not permitted
libndctl: __sysfs_device_parse: nmem0: add_dev() failed

Fixing this bug is complicated by the fact these attributes are needed
for by the 'nvdimm_test' nvdimms which also uses the
NVDIMM_FAMILY_PAPR. Adding a two way comparison for these two
attributes in populate_dimm_attributes() to distinguish between
'nvdimm_test' and papr-scm nvdimms will be clunky and make future
updates to populate_dimm_attributes() error prone.

So, this patch proposes to fix the issue by re-introducing
add_papr_dimm() to probe both papr-scm and 'nvdimm_test' nvdimms. The
'compatible' sysfs attribute associated with the PAPR device is used
to distinguish between the two nvdimm types and in case an
'nvdimm_test' device is detected then forward its probe to
populate_dimm_attributes().

families")

Link: https://lore.kernel.org/r/20210517154824.142237-1-vaib...@linux.ibm.com
Fixes: daef3a386a9c("libndctl: Unify adding dimms for papr and nfit
Signed-off-by: Vaibhav Jain <vaib...@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 ndctl/lib/libndctl.c | 57 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 3a496ed..aa36a3c 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1754,6 +1754,58 @@ static int populate_dimm_attributes(struct ndctl_dimm 
*dimm,
        return rc;
 }
 
+static int add_papr_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
+{
+       int rc = -ENODEV;
+       char buf[SYSFS_ATTR_SIZE];
+       struct ndctl_ctx *ctx = dimm->bus->ctx;
+       char *path = calloc(1, strlen(dimm_base) + 100);
+       const char * const devname = ndctl_dimm_get_devname(dimm);
+
+       dbg(ctx, "%s: Probing of_pmem dimm at %s\n", devname, dimm_base);
+
+       if (!path)
+               return -ENOMEM;
+
+       /* Check the compatibility of the probed nvdimm */
+       sprintf(path, "%s/../of_node/compatible", dimm_base);
+       if (sysfs_read_attr(ctx, path, buf) < 0) {
+               dbg(ctx, "%s: Unable to read compatible field\n", devname);
+               rc =  -ENODEV;
+               goto out;
+       }
+
+       dbg(ctx, "%s:Compatible of_pmem = '%s'\n", devname, buf);
+
+       /* Probe for papr-scm memory */
+       if (strcmp(buf, "ibm,pmemory") == 0) {
+               /* Read the dimm flags file */
+               sprintf(path, "%s/papr/flags", dimm_base);
+               if (sysfs_read_attr(ctx, path, buf) < 0) {
+                       rc = -errno;
+                       err(ctx, "%s: Unable to read dimm-flags\n", devname);
+                       goto out;
+               }
+
+               dbg(ctx, "%s: Adding papr-scm dimm flags:\"%s\"\n", devname, 
buf);
+               dimm->cmd_family = NVDIMM_FAMILY_PAPR;
+
+               /* Parse dimm flags */
+               parse_papr_flags(dimm, buf);
+
+               /* Allocate monitor mode fd */
+               dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
+               rc = 0;
+
+       } else if (strcmp(buf, "nvdimm_test") == 0) {
+               /* probe via common populate_dimm_attributes() */
+               rc = populate_dimm_attributes(dimm, dimm_base, "papr");
+       }
+out:
+       free(path);
+       return rc;
+}
+
 static void *add_dimm(void *parent, int id, const char *dimm_base)
 {
        int formats, i, rc = -ENODEV;
@@ -1845,8 +1897,9 @@ static void *add_dimm(void *parent, int id, const char 
*dimm_base)
        /* Check if the given dimm supports nfit */
        if (ndctl_bus_has_nfit(bus)) {
                rc = populate_dimm_attributes(dimm, dimm_base, "nfit");
-       } else if (ndctl_bus_has_of_node(bus))
-               rc = populate_dimm_attributes(dimm, dimm_base, "papr");
+       } else if (ndctl_bus_has_of_node(bus)) {
+               rc = add_papr_dimm(dimm, dimm_base);
+       }
 
        if (rc == -ENODEV) {
                /* Unprobed dimm with no family */
-- 
2.35.1


++++++ 0010-ndctl-scrub-Stop-translating-return-values.patch ++++++
>From c52109355b715bbe21e284090435bee7563863cc Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.willi...@intel.com>
Date: Wed, 26 May 2021 16:33:04 -0700
Subject: [PATCH] ndctl/scrub: Stop translating return values

Upstream: v72
Git-commit: c52109355b715bbe21e284090435bee7563863cc

In preparation for triggering a poll loop within ndctl_bus_start_scrub(),
stop translating return values into -EOPNOTSUPP.

Link: 
https://lore.kernel.org/r/162207198482.3715490.5994844104395495686.st...@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 ndctl/lib/libndctl.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index aa36a3c..e5641fe 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1354,14 +1354,8 @@ static int __ndctl_bus_get_scrub_state(struct ndctl_bus 
*bus,
 NDCTL_EXPORT int ndctl_bus_start_scrub(struct ndctl_bus *bus)
 {
        struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus);
-       int rc;
 
-       rc = sysfs_write_attr(ctx, bus->scrub_path, "1\n");
-       if (rc == -EBUSY)
-               return rc;
-       else if (rc < 0)
-               return -EOPNOTSUPP;
-       return 0;
+       return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
 }
 
 NDCTL_EXPORT int ndctl_bus_get_scrub_state(struct ndctl_bus *bus)
-- 
2.35.1


++++++ 0011-ndctl-scrub-Reread-scrub-engine-status-at-start.patch ++++++
>From 4e646fa490ba4b782afa188dd8818b94c419924e Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.willi...@intel.com>
Date: Wed, 26 May 2021 16:33:10 -0700
Subject: [PATCH] ndctl/scrub: Reread scrub-engine status at start

Upstream: v72
Git-commit: 4e646fa490ba4b782afa188dd8818b94c419924e

Given that the kernel has exponential backoff to cover the lack of
interrupts for scrub completion status there is a reasonable likelihood
that 'ndctl start-scrub' is issued while the hardware/platform scrub-state
is idle, but the kernel engine poll timer has not fired.

Trigger at least one poll cycle for the kernel to re-read the scrub-state
before reporting that ARS is busy.

Link: 
https://lore.kernel.org/r/162207199057.3715490.2469820075085914776.st...@dwillia2-desk3.amr.corp.intel.com
Reported-by: Krzysztof Rusocki <krzysztof.ruso...@intel.com>
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 ndctl/lib/libndctl.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index e5641fe..536e142 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1354,8 +1354,18 @@ static int __ndctl_bus_get_scrub_state(struct ndctl_bus 
*bus,
 NDCTL_EXPORT int ndctl_bus_start_scrub(struct ndctl_bus *bus)
 {
        struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus);
+       int rc;
+
+       rc = sysfs_write_attr(ctx, bus->scrub_path, "1\n");
 
-       return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
+       /*
+        * Try at least 1 poll cycle before reporting busy in case this
+        * request hits the kernel's exponential backoff while the
+        * hardware/platform scrub state is idle.
+        */
+       if (rc == -EBUSY && ndctl_bus_poll_scrub_completion(bus, 1, 1) == 0)
+               return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
+       return rc;
 }
 
 NDCTL_EXPORT int ndctl_bus_get_scrub_state(struct ndctl_bus *bus)
-- 
2.35.1


++++++ 0012-ndctl-dimm-Fix-label-index-block-calculations.patch ++++++
>From 7e98977c10ad5f4baf5e3bc4d5b4b2fd733a8b7e Mon Sep 17 00:00:00 2001
From: Jingqi Liu <jingqi....@intel.com>
Date: Thu, 8 Jul 2021 16:14:46 +0800
Subject: [PATCH] ndctl/dimm: Fix label index block calculations

Upstream: v72
Git-commit: 7e98977c10ad5f4baf5e3bc4d5b4b2fd733a8b7e

The following bug is caused by setting the size of Label Index Block
to a fixed 256 bytes.

Use the following Qemu command to start a Guest with 2MB label-size:
        -object 
memory-backend-file,id=mem1,share=on,mem-path=/dev/dax1.1,size=14G,align=2M
        -device nvdimm,memdev=mem1,id=nv1,label-size=2M

There is a namespace in the Guest as follows:
        $ ndctl list
        [
          {
            "dev":"namespace0.0",
            "mode":"devdax",
            "map":"dev",
            "size":14780727296,
            "uuid":"58ad5282-5a16-404f-b8ee-e28b4c784eb8",
            "chardev":"dax0.0",
            "align":2097152,
            "name":"namespace0.0"
          }
        ]

Fail to read labels. The result is as follows:
        $ ndctl read-labels -u nmem0
        [
        ]
        read 0 nmem

If using the following Qemu command to start the Guest with 128K
label-size, this label can be read correctly.
        -object 
memory-backend-file,id=mem1,share=on,mem-path=/dev/dax1.1,size=14G,align=2M
        -device nvdimm,memdev=mem1,id=nv1,label-size=128K

The size of a Label Index Block depends on how many label slots fit into
the label storage area. The minimum size of an index block is 256 bytes
and the size must be a multiple of 256 bytes. For a storage area of 128KB,
the corresponding Label Index Block size is 256 bytes. But if the label
storage area is not 128KB, the Label Index Block size should not be 256 bytes.

Namespace Label Index Block appears twice at the top of the label storage area.
Following the two index blocks, an array for storing labels takes up the
remainder of the label storage area.

For obtaining the size of Namespace Index Block, we also cannot rely on
the field of 'mysize' in this index block since it might be corrupted.
Similar to the linux kernel, we use sizeof_namespace_index() to get the size
of Namespace Index Block. Then we can also correctly calculate the starting
offset of the following namespace labels.

Link: https://lore.kernel.org/r/20210708081446.14323-1-jingqi....@intel.com
Suggested-by: Dan Williams <dan.j.willi...@intel.com>
Reviewed-by: Dan Williams <dan.j.willi...@intel.com>
Reviewed-by: Vishal Verma <vishal.l.ve...@intel.com>
Signed-off-by: Jingqi Liu <jingqi....@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 ndctl/dimm.c           | 19 +++++++++++++++----
 ndctl/lib/dimm.c       |  5 +++++
 ndctl/lib/libndctl.sym |  1 +
 ndctl/libndctl.h       |  1 +
 4 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index 09ce49e..1d2d9a2 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -94,13 +94,18 @@ static struct json_object *dump_label_json(struct 
ndctl_dimm *dimm,
        struct json_object *jarray = json_object_new_array();
        struct json_object *jlabel = NULL;
        struct namespace_label nslabel;
+       unsigned int nsindex_size;
        unsigned int slot = -1;
        ssize_t offset;
 
        if (!jarray)
                return NULL;
 
-       for (offset = NSINDEX_ALIGN * 2; offset < size;
+       nsindex_size = ndctl_dimm_sizeof_namespace_index(dimm);
+       if (nsindex_size == 0)
+               return NULL;
+
+       for (offset = nsindex_size * 2; offset < size;
                        offset += ndctl_dimm_sizeof_namespace_label(dimm)) {
                ssize_t len = min_t(ssize_t,
                                ndctl_dimm_sizeof_namespace_label(dimm),
@@ -204,17 +209,23 @@ static struct json_object *dump_label_json(struct 
ndctl_dimm *dimm,
        return jarray;
 }
 
-static struct json_object *dump_index_json(struct ndctl_cmd *cmd_read, ssize_t 
size)
+static struct json_object *dump_index_json(struct ndctl_dimm *dimm,
+               struct ndctl_cmd *cmd_read, ssize_t size)
 {
        struct json_object *jarray = json_object_new_array();
        struct json_object *jindex = NULL;
        struct namespace_index nsindex;
+       unsigned int nsindex_size;
        ssize_t offset;
 
        if (!jarray)
                return NULL;
 
-       for (offset = 0; offset < NSINDEX_ALIGN * 2; offset += NSINDEX_ALIGN) {
+       nsindex_size = ndctl_dimm_sizeof_namespace_index(dimm);
+       if (nsindex_size == 0)
+               return NULL;
+
+       for (offset = 0; offset < nsindex_size * 2; offset += nsindex_size) {
                ssize_t len = min_t(ssize_t, sizeof(nsindex), size - offset);
                struct json_object *jobj;
 
@@ -288,7 +299,7 @@ static struct json_object *dump_json(struct ndctl_dimm 
*dimm,
                goto err;
        json_object_object_add(jdimm, "dev", jobj);
 
-       jindex = dump_index_json(cmd_read, size);
+       jindex = dump_index_json(dimm, cmd_read, size);
        if (!jindex)
                goto err;
        json_object_object_add(jdimm, "index", jindex);
diff --git a/ndctl/lib/dimm.c b/ndctl/lib/dimm.c
index c045cbe..9e36e28 100644
--- a/ndctl/lib/dimm.c
+++ b/ndctl/lib/dimm.c
@@ -256,6 +256,11 @@ static int __label_validate(struct nvdimm_data *ndd)
        return -EINVAL;
 }
 
+NDCTL_EXPORT unsigned int ndctl_dimm_sizeof_namespace_index(struct ndctl_dimm 
*dimm)
+{
+       return sizeof_namespace_index(&dimm->ndd);
+}
+
 /*
  * If the dimm labels have not been previously validated this routine
  * will make up a default size. Otherwise, it will pick the size based
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index 58afb74..5ee73b7 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -454,4 +454,5 @@ LIBNDCTL_25 {
 
 LIBNDCTL_26 {
        ndctl_bus_nfit_translate_spa;
+       ndctl_dimm_sizeof_namespace_index;
 } LIBNDCTL_25;
diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
index 87d07b7..df109bb 100644
--- a/ndctl/libndctl.h
+++ b/ndctl/libndctl.h
@@ -337,6 +337,7 @@ int ndctl_dimm_init_labels(struct ndctl_dimm *dimm,
                enum ndctl_namespace_version v);
 unsigned long ndctl_dimm_get_available_labels(struct ndctl_dimm *dimm);
 unsigned int ndctl_dimm_sizeof_namespace_label(struct ndctl_dimm *dimm);
+unsigned int ndctl_dimm_sizeof_namespace_index(struct ndctl_dimm *dimm);
 unsigned int ndctl_cmd_cfg_size_get_size(struct ndctl_cmd *cfg_size);
 ssize_t ndctl_cmd_cfg_read_get_data(struct ndctl_cmd *cfg_read, void *buf,
                unsigned int len, unsigned int offset);
-- 
2.35.1


++++++ 0013-daxctl-Add-Soft-Reservation-theory-of-operation.patch ++++++
>From 8f4e42c0c526e85b045fd0329df7cb904f511c98 Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.willi...@intel.com>
Date: Thu, 7 Oct 2021 14:59:53 -0700
Subject: [PATCH] daxctl: Add "Soft Reservation" theory of operation

Upstream: v72
Git-commit: 8f4e42c0c526e85b045fd0329df7cb904f511c98

As systems are starting to ship memory with the EFI "Special Purpose"
attribute that Linux optionally turns into "Soft Reserved" ranges one of
the immediate first questions is "where is my special memory, and how do
access it". Add some documentation to explain the default behaviour of
"Soft Reserved".

Link: 
https://lore.kernel.org/r/163364399303.201290.6835215953983673447.st...@dwillia2-desk3.amr.corp.intel.com
Reported-by: John Groves <j...@jagalactic.com>
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 .../daxctl/daxctl-reconfigure-device.txt      | 127 ++++++++++++------
 1 file changed, 88 insertions(+), 39 deletions(-)

diff --git a/Documentation/daxctl/daxctl-reconfigure-device.txt 
b/Documentation/daxctl/daxctl-reconfigure-device.txt
index f112b3c..132684c 100644
--- a/Documentation/daxctl/daxctl-reconfigure-device.txt
+++ b/Documentation/daxctl/daxctl-reconfigure-device.txt
@@ -12,6 +12,94 @@ SYNOPSIS
 [verse]
 'daxctl reconfigure-device' <dax0.0> [<dax1.0>...<daxY.Z>] [<options>]
 
+DESCRIPTION
+-----------
+
+Reconfigure the operational mode of a dax device. This can be used to convert
+a regular 'devdax' mode device to the 'system-ram' mode which arranges for the
+dax range to be hot-plugged into the system as regular memory.
+
+NOTE: This is a destructive operation. Any data on the dax device *will* be
+lost.
+
+NOTE: Device reconfiguration depends on the dax-bus device model. See
+linkdaxctl:daxctl-migrate-device-model[1] for more information. If dax-class is
+in use (via the dax_pmem_compat driver), the reconfiguration will fail with an
+error such as the following:
+----
+# daxctl reconfigure-device --mode=system-ram --region=0 all
+libdaxctl: daxctl_dev_disable: dax3.0: error: device model is dax-class
+dax3.0: disable failed: Operation not supported
+error reconfiguring devices: Operation not supported
+reconfigured 0 devices
+----
+
+'daxctl-reconfigure-device' nominally expects that it will online new memory
+blocks as 'movable', so that kernel data doesn't make it into this memory.
+However, there are other potential agents that may be configured to
+automatically online new hot-plugged memory as it appears. Most notably,
+these are the '/sys/devices/system/memory/auto_online_blocks' configuration,
+or system udev rules. If such an agent races to online memory sections, daxctl
+checks if the blocks were onlined as 'movable' memory. If this was not the
+case, and the memory blocks are found to be in a different zone, then a
+warning is displayed. If it is desired that a different agent control the
+onlining of memory blocks, and the associated memory zone, then it is
+recommended to use the --no-online option described below. This will abridge
+the device reconfiguration operation to just hotplugging the memory, and
+refrain from then onlining it.
+
+In case daxctl detects that there is a kernel policy to auto-online blocks
+(via /sys/devices/system/memory/auto_online_blocks), then reconfiguring to
+system-ram will result in a failure. This can be overridden with '--force'.
+
+
+THEORY OF OPERATION
+-------------------
+The kernel device-dax subsystem surfaces character devices
+that provide DAX-access (direct mappings sans page-cache buffering) to a
+given memory region. The devices are named /dev/daxX.Y where X is a
+region-id and Y is an instance-id within that region. There are 2
+mechanisms that trigger device-dax instances to appear:
+
+1. Persistent Memory (PMEM) namespace configured in "devdax" mode. See
+"ndctl create-namspace --help" and
+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/dax/Kconfig[CONFIG_DEV_DAX_PMEM].
+In this case the device-dax instance is statically sized to its host
+memory region which is bounded to the physical address range of the host
+namespace.
+
+2. Soft Reserved memory enumerated by platform firmware. On EFI systems
+this is communicated via the so called EFI_MEMORY_SP "Special Purpose"
+attribute. See
+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/dax/Kconfig[CONFIG_DEV_DAX_HMEM].
+In this case the device-dax instance(s) associated with the given memory
+region can be resized and divided into multiple devices.
+
+In the Soft Reservation case the expectation for EFI + ACPI based
+platforms is that in addition to the EFI_MEMORY_SP attribute the
+firmware also creates distinct ACPI proximity domains for any address
+range that has different performance characteristics than default
+"System RAM". So, the SRAT will define the proximity domain, the SLIT
+communicates relative distance to other proximity domains, and the HMAT
+is populated with nominal read/write latency and read/write bandwidth
+data. That HMAT data is emitted to the kernel log on bootup, and also
+exported to sysfs. See
+https://www.kernel.org/doc/html/latest/admin-guide/mm/numaperf.html[NUMAPERF],
+for the runtime representation of CPU to Memory node performance
+details.
+
+Outside of the NUMA performance details linked above the other method to
+detect the presence of "Soft Reserved" memory is to dump /proc/iomem and
+look for "Soft Reserved" ranges. If the kernel was not built with
+CONFIG_EFI_SOFTRESERVE, predates the introduction of
+CONFIG_EFI_SOFTRESERVE (v5.5), or was booted with the efi=nosoftreserve
+command line then device-dax will not attach and the expectation is that
+the memory shows up as a memory-only NUMA node. Otherwise the memory
+shows up as a device-dax instance and DAXCTL(1) can be used to
+optionally partition it and assign the memory back to the kernel as
+"System RAM", or the device can be mapped directly as the back end of a
+userspace memory allocator like https://pmem.io/vmem/libvmem/[LIBVMEM].
+
 EXAMPLES
 --------
 
@@ -83,45 +171,6 @@ reconfigured 1 device
 reconfigured 1 device
 ----
 
-DESCRIPTION
------------
-
-Reconfigure the operational mode of a dax device. This can be used to convert
-a regular 'devdax' mode device to the 'system-ram' mode which arranges for the
-dax range to be hot-plugged into the system as regular memory.
-
-NOTE: This is a destructive operation. Any data on the dax device *will* be
-lost.
-
-NOTE: Device reconfiguration depends on the dax-bus device model. See
-linkdaxctl:daxctl-migrate-device-model[1] for more information. If dax-class is
-in use (via the dax_pmem_compat driver), the reconfiguration will fail with an
-error such as the following:
-----
-# daxctl reconfigure-device --mode=system-ram --region=0 all
-libdaxctl: daxctl_dev_disable: dax3.0: error: device model is dax-class
-dax3.0: disable failed: Operation not supported
-error reconfiguring devices: Operation not supported
-reconfigured 0 devices
-----
-
-'daxctl-reconfigure-device' nominally expects that it will online new memory
-blocks as 'movable', so that kernel data doesn't make it into this memory.
-However, there are other potential agents that may be configured to
-automatically online new hot-plugged memory as it appears. Most notably,
-these are the '/sys/devices/system/memory/auto_online_blocks' configuration,
-or system udev rules. If such an agent races to online memory sections, daxctl
-checks if the blocks were onlined as 'movable' memory. If this was not the
-case, and the memory blocks are found to be in a different zone, then a
-warning is displayed. If it is desired that a different agent control the
-onlining of memory blocks, and the associated memory zone, then it is
-recommended to use the --no-online option described below. This will abridge
-the device reconfiguration operation to just hotplugging the memory, and
-refrain from then onlining it.
-
-In case daxctl detects that there is a kernel policy to auto-online blocks
-(via /sys/devices/system/memory/auto_online_blocks), then reconfiguring to
-system-ram will result in a failure. This can be overridden with '--force'.
 
 OPTIONS
 -------
-- 
2.35.1


++++++ 0014-Documentation-ndctl-fix-self-reference-of-ndctl-disa.patch ++++++
>From 3f2a2973b23fa86c810aab49eeb8ff5f97a02720 Mon Sep 17 00:00:00 2001
From: Yasunori Goto <y-g...@fujitsu.com>
Date: Wed, 3 Feb 2021 19:17:07 +0900
Subject: [PATCH] Documentation/ndctl: fix self-reference of ndctl
 disable-namespace

Upstream: v73
Git-commit: 3f2a2973b23fa86c810aab49eeb8ff5f97a02720

The man manual of ndctl disable-namespace link to itself at See
Also section. It should be enable-namespace instead of it.

Signed-off-by: Yasunori Goto <y-g...@fujitsu.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
Link: https://github.com/pmem/ndctl/pull/160
---
 Documentation/ndctl/ndctl-disable-namespace.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/ndctl/ndctl-disable-namespace.txt 
b/Documentation/ndctl/ndctl-disable-namespace.txt
index 5d3a8be..187348f 100644
--- a/Documentation/ndctl/ndctl-disable-namespace.txt
+++ b/Documentation/ndctl/ndctl-disable-namespace.txt
@@ -22,4 +22,4 @@ include::../copyright.txt[]
 
 SEE ALSO
 --------
-linkndctl:ndctl-disable-namespace[1]
+linkndctl:ndctl-enable-namespace[1]
-- 
2.35.1


++++++ 0015-ndctl-docs-Clarify-update-firwmware-activation-overf.patch ++++++
>From 475cb041a97d3c7140efd1b0cda820fb22b69d11 Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.willi...@intel.com>
Date: Wed, 5 Jan 2022 13:31:44 -0800
Subject: [PATCH] ndctl/docs: Clarify update-firwmware activation 'overflow'
 conditions

Upstream: v73
Git-commit: 475cb041a97d3c7140efd1b0cda820fb22b69d11

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.

Link: 
https://lore.kernel.org/r/164141830490.3990253.6263569501446070716.st...@dwillia2-desk3.amr.corp.intel.com
Tested-by: Alison Schofield <alison.schofi...@intel.com>
Tested-by: Vaibhav Jain <vaib...@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@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 1080d62..6166457 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::
-- 
2.35.1


++++++ 0016-libndctl-papr-Add-support-for-reporting-shutdown-cou.patch ++++++
>From aa990008f48f21121474a411d829f24e832c89a2 Mon Sep 17 00:00:00 2001
From: Vaibhav Jain <vaib...@linux.ibm.com>
Date: Tue, 25 Jan 2022 00:26:05 +0530
Subject: [PATCH] libndctl/papr: Add support for reporting shutdown-count

Upstream: v73
Git-commit: aa990008f48f21121474a411d829f24e832c89a2

Add support for reporting dirty-shutdown-count (DSC) for PAPR based
NVDIMMs. The sysfs attribute exposing this value is located at
nmemX/papr/dirty_shutdown.

This counter is also returned in payload for PAPR_PDSM_HEALTH as newly
introduced member 'dimm_dsc' in 'struct nd_papr_pdsm_health'. Presence
of 'DSC' is indicated by the PDSM_DIMM_DSC_VALID extension flag.

The patch implements 'ndctl_dimm_ops.smart_get_shutdown_count'
callback in implemented as papr_smart_get_shutdown_count().

Kernel side changes to support reporting DSC have been merged to linux kernel
via patch proposed at [1]. With updated kernel 'ndctl list -DH' reports
following output on PPC64:

$ sudo ndctl list -DH
[
  {
    "dev":"nmem0",
    "health":{
      "health_state":"ok",
      "life_used_percentage":50,
      "shutdown_state":"clean",
      "shutdown_count":10
    }
  }
]

[1] 
http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210624080621.252038-1-vaib...@linux.ibm.com

Link: https://lore.kernel.org/r/20220124185605.1465681-1-vaib...@linux.ibm.com
Signed-off-by: Vaibhav Jain <vaib...@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
---
 ndctl/lib/libndctl.c  |  6 +++++-
 ndctl/lib/papr.c      | 23 +++++++++++++++++++++++
 ndctl/lib/papr_pdsm.h |  6 ++++++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 47a234c..5979a92 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1819,8 +1819,12 @@ static int add_papr_dimm(struct ndctl_dimm *dimm, const 
char *dimm_base)
 
                /* Allocate monitor mode fd */
                dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
-               rc = 0;
+               /* Get the dirty shutdown counter value */
+               sprintf(path, "%s/papr/dirty_shutdown", dimm_base);
+               if (sysfs_read_attr(ctx, path, buf) == 0)
+                       dimm->dirty_shutdown = strtoll(buf, NULL, 0);
 
+               rc = 0;
        } else if (strcmp(buf, "nvdimm_test") == 0) {
                /* probe via common populate_dimm_attributes() */
                rc = populate_dimm_attributes(dimm, dimm_base, "papr");
diff --git a/ndctl/lib/papr.c b/ndctl/lib/papr.c
index 43b8412..46cf9c1 100644
--- a/ndctl/lib/papr.c
+++ b/ndctl/lib/papr.c
@@ -165,6 +165,9 @@ static unsigned int papr_smart_get_flags(struct ndctl_cmd 
*cmd)
                if (health.extension_flags & PDSM_DIMM_HEALTH_RUN_GAUGE_VALID)
                        flags |= ND_SMART_USED_VALID;
 
+               if (health.extension_flags &  PDSM_DIMM_DSC_VALID)
+                       flags |= ND_SMART_SHUTDOWN_COUNT_VALID;
+
                return flags;
        }
 
@@ -236,6 +239,25 @@ static unsigned int papr_smart_get_life_used(struct 
ndctl_cmd *cmd)
                (100 - health.dimm_fuel_gauge) : 0;
 }
 
+static unsigned int papr_smart_get_shutdown_count(struct ndctl_cmd *cmd)
+{
+
+       struct nd_papr_pdsm_health health;
+
+       /* Ignore in case of error or invalid pdsm */
+       if (!cmd_is_valid(cmd) ||
+           to_pdsm(cmd)->cmd_status != 0 ||
+           to_pdsm_cmd(cmd) != PAPR_PDSM_HEALTH)
+               return 0;
+
+       /* get the payload from command */
+       health = to_payload(cmd)->health;
+
+       return (health.extension_flags & PDSM_DIMM_DSC_VALID) ?
+               (health.dimm_dsc) : 0;
+
+}
+
 struct ndctl_dimm_ops * const papr_dimm_ops = &(struct ndctl_dimm_ops) {
        .cmd_is_supported = papr_cmd_is_supported,
        .smart_get_flags = papr_smart_get_flags,
@@ -245,4 +267,5 @@ struct ndctl_dimm_ops * const papr_dimm_ops = &(struct 
ndctl_dimm_ops) {
        .smart_get_health = papr_smart_get_health,
        .smart_get_shutdown_state = papr_smart_get_shutdown_state,
        .smart_get_life_used = papr_smart_get_life_used,
+       .smart_get_shutdown_count = papr_smart_get_shutdown_count,
 };
diff --git a/ndctl/lib/papr_pdsm.h b/ndctl/lib/papr_pdsm.h
index 1bac8a7..f45b1e4 100644
--- a/ndctl/lib/papr_pdsm.h
+++ b/ndctl/lib/papr_pdsm.h
@@ -75,6 +75,9 @@
 /* Indicate that the 'dimm_fuel_gauge' field is valid */
 #define PDSM_DIMM_HEALTH_RUN_GAUGE_VALID 1
 
+/* Indicate that the 'dimm_dsc' field is valid */
+#define PDSM_DIMM_DSC_VALID 2
+
 /*
  * Struct exchanged between kernel & ndctl in for PAPR_PDSM_HEALTH
  * Various flags indicate the health status of the dimm.
@@ -103,6 +106,9 @@ struct nd_papr_pdsm_health {
 
                        /* Extension flag PDSM_DIMM_HEALTH_RUN_GAUGE_VALID */
                        __u16 dimm_fuel_gauge;
+
+                       /* Extension flag PDSM_DIMM_DSC_VALID */
+                       __u64 dimm_dsc;
                };
                __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
        };
-- 
2.35.1


++++++ ndctl-namespace-Suppress-ENXIO-when-processing-all-n.patch ++++++
--- /var/tmp/diff_new_pack.h2dhsR/_old  2022-03-13 20:25:05.119649571 +0100
+++ /var/tmp/diff_new_pack.h2dhsR/_new  2022-03-13 20:25:05.123649576 +0100
@@ -1,10 +1,11 @@
-From 6a678667c6279369dda999da8535e327df036705 Mon Sep 17 00:00:00 2001
+From 07011a334fd1e4b641cdbfaf5de7500f7bdc941d Mon Sep 17 00:00:00 2001
 From: Michal Suchanek <msucha...@suse.de>
-Date: Thu, 23 Jul 2020 19:16:59 +0200
+Date: Wed, 6 Jan 2021 14:17:41 +0100
 Subject: [PATCH] ndctl/namespace: Suppress -ENXIO when processing all
  namespaces.
 
-Upstream: submitted https://patchwork.kernel.org/patch/11681431/
+Upstream: v72
+Git-commit: 07011a334fd1e4b641cdbfaf5de7500f7bdc941d
 
 When processing all namespaces and no namespaces exist user gets the
 default -ENXIO. Set default rc to 0 when processing all namespaces.
@@ -56,19 +57,20 @@
 Note: this does change the return value from -ENXIO to 0 in the cases
 when no namespaces exist and processing all namespaces was requested.
 
-Signed-off-by: Michal Suchanek <msucha...@suse.de>
+Link: https://patchwork.kernel.org/patch/11681431/
+Link: 
https://lore.kernel.org/r/32c8cd8d2716f5e52aebea4e4d303eeb4e0550f9.1609938610.git.msucha...@suse.de
 Reviewed-by: Santosh S <sant...@fossix.org>
----
-v2: fix the error code references in the commit message
+Signed-off-by: Michal Suchanek <msucha...@suse.de>
+Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
 ---
  ndctl/namespace.c | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/ndctl/namespace.c b/ndctl/namespace.c
-index 3fabe4799d75..835f4076008a 100644
+index 5e65ed5..cd822b3 100644
 --- a/ndctl/namespace.c
 +++ b/ndctl/namespace.c
-@@ -2112,6 +2112,9 @@ static int do_xaction_namespace(const char *namespace,
+@@ -2151,6 +2151,9 @@ static int do_xaction_namespace(const char *namespace,
        if (!namespace && action != ACTION_CREATE)
                return rc;
  
@@ -79,6 +81,6 @@
                ndctl_set_log_priority(ctx, LOG_DEBUG);
  
 -- 
-2.28.0
+2.35.1
 
 

++++++ ndctl-namespace-skip-zero-namespaces-when-processing.patch ++++++
--- /var/tmp/diff_new_pack.h2dhsR/_old  2022-03-13 20:25:05.139649595 +0100
+++ /var/tmp/diff_new_pack.h2dhsR/_new  2022-03-13 20:25:05.143649600 +0100
@@ -1,33 +1,39 @@
-From ff4e8668a5edd2eaa38f08deb9b357778019e2ea Mon Sep 17 00:00:00 2001
+From 9bd2994f91bb77604521cbe09a76a51d092c2cfd Mon Sep 17 00:00:00 2001
 From: Michal Suchanek <msucha...@suse.de>
-Date: Fri, 3 Apr 2020 19:38:33 +0200
-Subject: [PATCH] ndctl/namespace: skip zero namespaces when processing all
+Date: Wed, 6 Jan 2021 14:17:40 +0100
+Subject: [PATCH] ndctl/namespace: Skip seed namespaces when processing all
  namespaces.
 
-Upstream: submitted https://patchwork.kernel.org/patch/11681433/
+Upstream: v72
+Git-commit: 9bd2994f91bb77604521cbe09a76a51d092c2cfd
 
-The kernel always creates zero length namespace with uuid 0 in each
-region.
+The seed namespaces are exposed by the kernel but most operations are
+not valid on seed namespaces.
 
 When processing all namespaces the user gets confusing errors from ndctl
-trying to process this namespace. Skip it.
+trying to process seed namespaces. The kernel does not provide any way
+to tell that a namspace is seed namespace but skipping namespaces with
+zero size and UUID is a good heuristic.
 
 The user can still specify the namespace by name directly in case
 processing it is desirable.
 
+Link: https://patchwork.kernel.org/patch/11473645/
+Link: 
https://lore.kernel.org/r/e55ae2c17b8b9c3288491efe6214338118e8c5ae.1609938610.git.msucha...@suse.de
 Fixes: #41
-Reviewed-by: Santosh S <sant...@fossix.org>
 Tested-by: Harish Sriram <har...@linux.ibm.com>
+Reviewed-by: Santosh S <sant...@fossix.org>
 Signed-off-by: Michal Suchanek <msucha...@suse.de>
+Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
 ---
  ndctl/namespace.c | 16 +++++++++++++---
  1 file changed, 13 insertions(+), 3 deletions(-)
 
 diff --git a/ndctl/namespace.c b/ndctl/namespace.c
-index e734248c9752..3fabe4799d75 100644
+index 1e8a2cd..5e65ed5 100644
 --- a/ndctl/namespace.c
 +++ b/ndctl/namespace.c
-@@ -2171,9 +2171,19 @@ static int do_xaction_namespace(const char *namespace,
+@@ -2210,9 +2210,19 @@ static int do_xaction_namespace(const char *namespace,
                        ndctl_namespace_foreach_safe(region, ndns, _n) {
                                ndns_name = ndctl_namespace_get_devname(ndns);
  
@@ -51,6 +57,6 @@
                                case ACTION_DISABLE:
                                        rc = ndctl_namespace_disable_safe(ndns);
 -- 
-2.28.0
+2.35.1
 
 

Reply via email to