]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
libnvdimm: convert NDD_ flags to use bitops, introduce NDD_LOCKED
authorDan Williams <dan.j.williams@intel.com>
Thu, 4 May 2017 21:01:24 +0000 (14:01 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 4 May 2017 21:01:24 +0000 (14:01 -0700)
This is a preparation patch for handling locked nvdimm label regions, a
new concept as introduced by the latest DSM document on pmem.io [1]. A
future patch will leverage nvdimm_set_locked() at DIMM probe time to
flag regions that can not be enabled. There should be no functional
difference resulting from this change.

[1]: http://pmem.io/documents/NVDIMM_DSM_Interface_Example-V1.3.pdf

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/acpi/nfit/core.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 ced95a79c1a1e69376ca7fd859e3b05a1b9a49a6..a26c2297c1ed0d7287b97f605fd1af34a49621f8 100644 (file)
@@ -1512,7 +1512,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
                }
 
                if (nfit_mem->bdw && nfit_mem->memdev_pmem)
-                       flags |= NDD_ALIASING;
+                       set_bit(NDD_ALIASING, &flags);
 
                /* collate flags across all memdevs for this dimm */
                list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
@@ -1527,7 +1527,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
 
                mem_flags = __to_nfit_memdev(nfit_mem)->flags;
                if (mem_flags & ACPI_NFIT_MEM_NOT_ARMED)
-                       flags |= NDD_UNARMED;
+                       set_bit(NDD_UNARMED, &flags);
 
                rc = acpi_nfit_add_dimm(acpi_desc, nfit_mem, device_handle);
                if (rc)
index 8b721321be5b1cb291e780ae9a5ed7ea5ad67e09..7d1a3dbc7d5df49d8e88c1243169cbe9dad87c72 100644 (file)
@@ -34,7 +34,7 @@ int nvdimm_check_config_data(struct device *dev)
 
        if (!nvdimm->cmd_mask ||
            !test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask)) {
-               if (nvdimm->flags & NDD_ALIASING)
+               if (test_bit(NDD_ALIASING, &nvdimm->flags))
                        return -ENXIO;
                else
                        return -ENOTTY;
@@ -188,7 +188,14 @@ void nvdimm_set_aliasing(struct device *dev)
 {
        struct nvdimm *nvdimm = to_nvdimm(dev);
 
-       nvdimm->flags |= NDD_ALIASING;
+       set_bit(NDD_ALIASING, &nvdimm->flags);
+}
+
+void nvdimm_set_locked(struct device *dev)
+{
+       struct nvdimm *nvdimm = to_nvdimm(dev);
+
+       set_bit(NDD_LOCKED, &nvdimm->flags);
 }
 
 static void nvdimm_release(struct device *dev)
index 1b481a5fb9667da9731c4a536dd16ef73f5e1ead..2f2d8afc684a59c15421396c59f24db5d415232e 100644 (file)
@@ -2240,7 +2240,7 @@ static int init_active_labels(struct nd_region *nd_region)
                 * being activated if it aliases DPA.
                 */
                if (!ndd) {
-                       if ((nvdimm->flags & NDD_ALIASING) == 0)
+                       if (!test_bit(NDD_ALIASING, &nvdimm->flags))
                                return 0;
                        dev_dbg(&nd_region->dev, "%s: is disabled, failing probe\n",
                                        dev_name(&nd_mapping->nvdimm->dev));
index c3b33cf655fb9443858c372bf203ab49306f54c1..77d032192bf7d6c11e97b9afb345272b1f3f50ff 100644 (file)
@@ -240,6 +240,7 @@ int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
 long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
                unsigned int len);
 void nvdimm_set_aliasing(struct device *dev);
+void nvdimm_set_locked(struct device *dev);
 struct nd_btt *to_nd_btt(struct device *dev);
 
 struct nd_gen_sb {
index 07756b2e1cd5b9f7575b4ccefa6bf9b4de5ce34f..b550edf2571f448df70e973ba9d6265ab894299c 100644 (file)
@@ -222,7 +222,7 @@ int nd_region_to_nstype(struct nd_region *nd_region)
                        struct nd_mapping *nd_mapping = &nd_region->mapping[i];
                        struct nvdimm *nvdimm = nd_mapping->nvdimm;
 
-                       if (nvdimm->flags & NDD_ALIASING)
+                       if (test_bit(NDD_ALIASING, &nvdimm->flags))
                                alias++;
                }
                if (alias)
@@ -881,7 +881,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
                        return NULL;
                }
 
-               if (nvdimm->flags & NDD_UNARMED)
+               if (test_bit(NDD_UNARMED, &nvdimm->flags))
                        ro = 1;
        }
 
index f07b1b14159a095067175714e5c58a649e32508e..6c807017128d4645d423b6ded0737c452fa3a3e6 100644 (file)
 
 enum {
        /* when a dimm supports both PMEM and BLK access a label is required */
-       NDD_ALIASING = 1 << 0,
+       NDD_ALIASING = 0,
        /* unarmed memory devices may not persist writes */
-       NDD_UNARMED = 1 << 1,
+       NDD_UNARMED = 1,
+       /* locked memory devices should not be accessed */
+       NDD_LOCKED = 2,
 
        /* need to set a limit somewhere, but yes, this is likely overkill */
        ND_IOCTL_MAX_BUFLEN = SZ_4M,