libnvdimm: use consistent naming for request_mem_region()
authorDan Williams <dan.j.williams@intel.com>
Mon, 28 Nov 2016 19:15:18 +0000 (11:15 -0800)
committerDan Williams <dan.j.williams@intel.com>
Mon, 28 Nov 2016 19:15:18 +0000 (11:15 -0800)
Here is an example /proc/iomem listing for a system with 2 namespaces,
one in "sector" mode and one in "memory" mode:

  1fc000000-2fbffffff : Persistent Memory (legacy)
    1fc000000-2fbffffff : namespace1.0
  340000000-34fffffff : Persistent Memory
    340000000-34fffffff : btt0.1

Here is the corresponding ndctl listing:

  # ndctl list
  [
    {
      "dev":"namespace1.0",
      "mode":"memory",
      "size":4294967296,
      "blockdev":"pmem1"
    },
    {
      "dev":"namespace0.0",
      "mode":"sector",
      "size":267091968,
      "uuid":"f7594f86-badb-4592-875f-ded577da2eaf",
      "sector_size":4096,
      "blockdev":"pmem0s"
    }
  ]

Notice that the ndctl listing is purely in terms of namespace devices,
while the iomem listing leaks the internal "btt0.1" implementation
detail. Given that ndctl requires the namespace device name to change
the mode, for example:

  # ndctl create-namespace --reconfig=namespace0.0 --mode=raw --force

...use the namespace name in the iomem listing to keep the claiming
device name consistent across different mode settings.

Cc: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/dax/pmem.c
drivers/nvdimm/claim.c
drivers/nvdimm/pmem.c

index 9630d8837ba94ed3badc9a3755b53c08123b9a51..3ff84784249a1502f3cfa95353319b5e218057c8 100644 (file)
@@ -87,7 +87,8 @@ static int dax_pmem_probe(struct device *dev)
        pfn_sb = nd_pfn->pfn_sb;
 
        if (!devm_request_mem_region(dev, nsio->res.start,
-                               resource_size(&nsio->res), dev_name(dev))) {
+                               resource_size(&nsio->res),
+                               dev_name(&ndns->dev))) {
                dev_warn(dev, "could not reserve region %pR\n", &nsio->res);
                return -EBUSY;
        }
index 8d66fbb779ed66444abfd5831a2b4fb753c4f878..4638b9ea52290fb5f037943d91a28c4f84f3f6a3 100644 (file)
@@ -275,7 +275,7 @@ int devm_nsio_enable(struct device *dev, struct nd_namespace_io *nsio)
 
        nsio->size = resource_size(res);
        if (!devm_request_mem_region(dev, res->start, resource_size(res),
-                               dev_name(dev))) {
+                               dev_name(&ndns->dev))) {
                dev_warn(dev, "could not reserve region %pR\n", res);
                return -EBUSY;
        }
index 42b3a82170733971a3b1d000b8de4979f0ad311b..34f16a17c07bbfabbdc96a18462262faa3a52fb7 100644 (file)
@@ -266,7 +266,7 @@ static int pmem_attach_disk(struct device *dev,
                dev_warn(dev, "unable to guarantee persistence of writes\n");
 
        if (!devm_request_mem_region(dev, res->start, resource_size(res),
-                               dev_name(dev))) {
+                               dev_name(&ndns->dev))) {
                dev_warn(dev, "could not reserve region %pR\n", res);
                return -EBUSY;
        }