libnvdimm/region: Introduce NDD_LABELING
authorDan Williams <dan.j.williams@intel.com>
Thu, 30 Jan 2020 20:06:18 +0000 (12:06 -0800)
committerDan Williams <dan.j.williams@intel.com>
Tue, 17 Mar 2020 19:23:21 +0000 (12:23 -0700)
The NDD_ALIASING flag is used to indicate where pmem capacity might
alias with blk capacity and require labeling. It is also used to
indicate whether the DIMM supports labeling. Separate this latter
capability into its own flag so that the NDD_ALIASING flag is scoped to
true aliased configurations.

To my knowledge aliased configurations only exist in the ACPI spec,
there are no known platforms that ship this support in production.

This clarity allows namespace-capacity alignment constraints around
interleave-ways to be relaxed.

Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Link: https://lore.kernel.org/r/158041477856.3889308.4212605617834097674.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
arch/powerpc/platforms/pseries/papr_scm.c
drivers/acpi/nfit/core.c
drivers/nvdimm/dimm.c
drivers/nvdimm/dimm_devs.c
drivers/nvdimm/namespace_devs.c
drivers/nvdimm/nd.h
drivers/nvdimm/region_devs.c
include/linux/libnvdimm.h

index 0b4467e378e5d33ee7a15316f982fc09d4cfb3b3..589858cb32037bdb430cc93a4c54e1a090fdf729 100644 (file)
@@ -328,7 +328,7 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
        }
 
        dimm_flags = 0;
-       set_bit(NDD_ALIASING, &dimm_flags);
+       set_bit(NDD_LABELING, &dimm_flags);
 
        p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags,
                                  PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
index a3320f93616dec56cb7c6015962525454d4b8a9c..71d7f2aa1b12de5ab7ae158587e66cc83bc074d7 100644 (file)
@@ -2026,8 +2026,10 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
                        continue;
                }
 
-               if (nfit_mem->bdw && nfit_mem->memdev_pmem)
+               if (nfit_mem->bdw && nfit_mem->memdev_pmem) {
                        set_bit(NDD_ALIASING, &flags);
+                       set_bit(NDD_LABELING, &flags);
+               }
 
                /* collate flags across all memdevs for this dimm */
                list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
index 64776ed15bb3be70f15063bf5b52f68f9e2b74a8..7d4ddc4d932277f6880833750853c78b72ebe095 100644 (file)
@@ -99,7 +99,7 @@ static int nvdimm_probe(struct device *dev)
        if (ndd->ns_current >= 0) {
                rc = nd_label_reserve_dpa(ndd);
                if (rc == 0)
-                       nvdimm_set_aliasing(dev);
+                       nvdimm_set_labeling(dev);
        }
        nvdimm_bus_unlock(dev);
 
index 94ea6dba6b4ff8361ab3baeb74facac65fc9a797..39a61a514746018c8ecd25145d2ed0de80dce71a 100644 (file)
@@ -32,7 +32,7 @@ int nvdimm_check_config_data(struct device *dev)
 
        if (!nvdimm->cmd_mask ||
            !test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask)) {
-               if (test_bit(NDD_ALIASING, &nvdimm->flags))
+               if (test_bit(NDD_LABELING, &nvdimm->flags))
                        return -ENXIO;
                else
                        return -ENOTTY;
@@ -173,11 +173,11 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
        return rc;
 }
 
-void nvdimm_set_aliasing(struct device *dev)
+void nvdimm_set_labeling(struct device *dev)
 {
        struct nvdimm *nvdimm = to_nvdimm(dev);
 
-       set_bit(NDD_ALIASING, &nvdimm->flags);
+       set_bit(NDD_LABELING, &nvdimm->flags);
 }
 
 void nvdimm_set_locked(struct device *dev)
@@ -312,8 +312,9 @@ static ssize_t flags_show(struct device *dev,
 {
        struct nvdimm *nvdimm = to_nvdimm(dev);
 
-       return sprintf(buf, "%s%s\n",
+       return sprintf(buf, "%s%s%s\n",
                        test_bit(NDD_ALIASING, &nvdimm->flags) ? "alias " : "",
+                       test_bit(NDD_LABELING, &nvdimm->flags) ? "label " : "",
                        test_bit(NDD_LOCKED, &nvdimm->flags) ? "lock " : "");
 }
 static DEVICE_ATTR_RO(flags);
index 77e211c7d94d3d086f30131334f38d9890f410a6..01f6c22f0d1a9c28d2acfdcebb9aec0a4dbdf895 100644 (file)
@@ -2538,7 +2538,7 @@ static int init_active_labels(struct nd_region *nd_region)
                if (!ndd) {
                        if (test_bit(NDD_LOCKED, &nvdimm->flags))
                                /* fail, label data may be unreadable */;
-                       else if (test_bit(NDD_ALIASING, &nvdimm->flags))
+                       else if (test_bit(NDD_LABELING, &nvdimm->flags))
                                /* fail, labels needed to disambiguate dpa */;
                        else
                                return 0;
index c9f6a5b5253aaf3e15109b8d000979c7ee74f1ee..ca39abe29c7cb0fbd59b1a53728834cb4e8e8314 100644 (file)
@@ -252,7 +252,7 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
                void *buf, size_t len);
 long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
                unsigned int len);
-void nvdimm_set_aliasing(struct device *dev);
+void nvdimm_set_labeling(struct device *dev);
 void nvdimm_set_locked(struct device *dev);
 void nvdimm_clear_locked(struct device *dev);
 int nvdimm_security_setup_events(struct device *dev);
index a19e535830d9f611b2b2ce05d8e907edea122a2d..a5fc6e4c56ff3ec91685858fe269ce6b86abbff4 100644 (file)
@@ -195,16 +195,16 @@ EXPORT_SYMBOL_GPL(nd_blk_region_set_provider_data);
 int nd_region_to_nstype(struct nd_region *nd_region)
 {
        if (is_memory(&nd_region->dev)) {
-               u16 i, alias;
+               u16 i, label;
 
-               for (i = 0, alias = 0; i < nd_region->ndr_mappings; i++) {
+               for (i = 0, label = 0; i < nd_region->ndr_mappings; i++) {
                        struct nd_mapping *nd_mapping = &nd_region->mapping[i];
                        struct nvdimm *nvdimm = nd_mapping->nvdimm;
 
-                       if (test_bit(NDD_ALIASING, &nvdimm->flags))
-                               alias++;
+                       if (test_bit(NDD_LABELING, &nvdimm->flags))
+                               label++;
                }
-               if (alias)
+               if (label)
                        return ND_DEVICE_NAMESPACE_PMEM;
                else
                        return ND_DEVICE_NAMESPACE_IO;
index 9df091bd30ba62c488c561a7ba996eeaf9ee647d..18da4059be09ab7fa576322c43089191495a25ea 100644 (file)
@@ -37,6 +37,8 @@ enum {
        NDD_WORK_PENDING = 4,
        /* ignore / filter NSLABEL_FLAG_LOCAL for this DIMM, i.e. no aliasing */
        NDD_NOBLK = 5,
+       /* dimm supports namespace labels */
+       NDD_LABELING = 6,
 
        /* need to set a limit somewhere, but yes, this is likely overkill */
        ND_IOCTL_MAX_BUFLEN = SZ_4M,