]> Git Repo - linux.git/commitdiff
Merge tag 'libnvdimm-for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdim...
authorLinus Torvalds <[email protected]>
Sun, 18 Dec 2016 23:49:10 +0000 (15:49 -0800)
committerLinus Torvalds <[email protected]>
Sun, 18 Dec 2016 23:49:10 +0000 (15:49 -0800)
Pull libnvdimm updates from Dan Williams:
 "The libnvdimm pull request is relatively small this time around due to
  some development topics being deferred to 4.11.

  As for this pull request the bulk of it has been in -next for several
  releases leading to one late fix being added (commit 868f036fee4b
  ("libnvdimm: fix mishandled nvdimm_clear_poison() return value")). It
  has received a build success notification from the 0day-kbuild robot
  and passes the latest libnvdimm unit tests.

  Summary:

   - Dynamic label support: To date namespace label support has been
     limited to disambiguating cases where PMEM (direct load/store) and
     BLK (mmio aperture) accessed-capacity alias on the same DIMM. Since
     4.9 added support for multiple namespaces per PMEM-region there is
     value to support namespace labels even in the non-aliasing case.
     The presence of a valid namespace index block force-enables label
     support when the kernel would otherwise rely on region boundaries,
     and permits the region to be sub-divided.

   - Handle media errors in namespace metadata: Complement the error
     handling for media errors in namespace data areas with support for
     clearing errors on writes, and downgrading potential machine-check
     exceptions to simple i/o errors on read.

   - Device-DAX region attributes: Add 'align', 'id', and 'size' as
     attributes for device-dax regions. In particular this enables
     userspace tooling to generically size memory mapping and i/o
     operations. Prevent userspace from growing assumptions /
     dependencies about the parent device topology for a dax region. A
     libnvdimm namespace may not always be the parent device of a dax
     region.

   - Various cleanups and small fixes"

* tag 'libnvdimm-for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
  dax: add region 'id', 'size', and 'align' attributes
  libnvdimm: fix mishandled nvdimm_clear_poison() return value
  libnvdimm: replace mutex_is_locked() warnings with lockdep_assert_held
  libnvdimm, pfn: fix align attribute
  libnvdimm, e820: use module_platform_driver
  libnvdimm, namespace: use octal for permissions
  libnvdimm, namespace: avoid multiple sector calculations
  libnvdimm: remove else after return in nsio_rw_bytes()
  libnvdimm, namespace: fix the type of name variable
  libnvdimm: use consistent naming for request_mem_region()
  nvdimm: use the right length of "pmem"
  libnvdimm: check and clear poison before writing to pmem
  tools/testing/nvdimm: dynamic label support
  libnvdimm: allow a platform to force enable label support
  libnvdimm: use generic iostat interfaces

1  2 
drivers/dax/dax.c

diff --combined drivers/dax/dax.c
index 26ec39ddf21ffa4f58d09e62dda0fab90e46ae5f,9352cbc1f9537d1e7ecc2eeb5c2da2983159cf70..ed758b74ddf0b74fe3fdbc84f8dde771aead4aca
@@@ -75,6 -75,73 +75,73 @@@ struct dax_dev 
        struct resource res[0];
  };
  
+ static ssize_t id_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+ {
+       struct dax_region *dax_region;
+       ssize_t rc = -ENXIO;
+       device_lock(dev);
+       dax_region = dev_get_drvdata(dev);
+       if (dax_region)
+               rc = sprintf(buf, "%d\n", dax_region->id);
+       device_unlock(dev);
+       return rc;
+ }
+ static DEVICE_ATTR_RO(id);
+ static ssize_t region_size_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+ {
+       struct dax_region *dax_region;
+       ssize_t rc = -ENXIO;
+       device_lock(dev);
+       dax_region = dev_get_drvdata(dev);
+       if (dax_region)
+               rc = sprintf(buf, "%llu\n", (unsigned long long)
+                               resource_size(&dax_region->res));
+       device_unlock(dev);
+       return rc;
+ }
+ static struct device_attribute dev_attr_region_size = __ATTR(size, 0444,
+               region_size_show, NULL);
+ static ssize_t align_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+ {
+       struct dax_region *dax_region;
+       ssize_t rc = -ENXIO;
+       device_lock(dev);
+       dax_region = dev_get_drvdata(dev);
+       if (dax_region)
+               rc = sprintf(buf, "%u\n", dax_region->align);
+       device_unlock(dev);
+       return rc;
+ }
+ static DEVICE_ATTR_RO(align);
+ static struct attribute *dax_region_attributes[] = {
+       &dev_attr_region_size.attr,
+       &dev_attr_align.attr,
+       &dev_attr_id.attr,
+       NULL,
+ };
+ static const struct attribute_group dax_region_attribute_group = {
+       .name = "dax_region",
+       .attrs = dax_region_attributes,
+ };
+ static const struct attribute_group *dax_region_attribute_groups[] = {
+       &dax_region_attribute_group,
+       NULL,
+ };
  static struct inode *dax_alloc_inode(struct super_block *sb)
  {
        return kmem_cache_alloc(dax_cache, GFP_KERNEL);
@@@ -200,12 -267,31 +267,31 @@@ void dax_region_put(struct dax_region *
  }
  EXPORT_SYMBOL_GPL(dax_region_put);
  
+ static void dax_region_unregister(void *region)
+ {
+       struct dax_region *dax_region = region;
+       sysfs_remove_groups(&dax_region->dev->kobj,
+                       dax_region_attribute_groups);
+       dax_region_put(dax_region);
+ }
  struct dax_region *alloc_dax_region(struct device *parent, int region_id,
                struct resource *res, unsigned int align, void *addr,
                unsigned long pfn_flags)
  {
        struct dax_region *dax_region;
  
+       /*
+        * The DAX core assumes that it can store its private data in
+        * parent->driver_data. This WARN is a reminder / safeguard for
+        * developers of device-dax drivers.
+        */
+       if (dev_get_drvdata(parent)) {
+               dev_WARN(parent, "dax core failed to setup private data\n");
+               return NULL;
+       }
        if (!IS_ALIGNED(res->start, align)
                        || !IS_ALIGNED(resource_size(res), align))
                return NULL;
        if (!dax_region)
                return NULL;
  
+       dev_set_drvdata(parent, dax_region);
        memcpy(&dax_region->res, res, sizeof(*res));
        dax_region->pfn_flags = pfn_flags;
        kref_init(&dax_region->kref);
        dax_region->align = align;
        dax_region->dev = parent;
        dax_region->base = addr;
+       if (sysfs_create_groups(&parent->kobj, dax_region_attribute_groups)) {
+               kfree(dax_region);
+               return NULL;;
+       }
  
+       kref_get(&dax_region->kref);
+       if (devm_add_action_or_reset(parent, dax_region_unregister, dax_region))
+               return NULL;
        return dax_region;
  }
  EXPORT_SYMBOL_GPL(alloc_dax_region);
@@@ -328,6 -422,7 +422,6 @@@ static phys_addr_t pgoff_to_phys(struc
  static int __dax_dev_fault(struct dax_dev *dax_dev, struct vm_area_struct *vma,
                struct vm_fault *vmf)
  {
 -      unsigned long vaddr = (unsigned long) vmf->virtual_address;
        struct device *dev = &dax_dev->dev;
        struct dax_region *dax_region;
        int rc = VM_FAULT_SIGBUS;
  
        pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);
  
 -      rc = vm_insert_mixed(vma, vaddr, pfn);
 +      rc = vm_insert_mixed(vma, vmf->address, pfn);
  
        if (rc == -ENOMEM)
                return VM_FAULT_OOM;
This page took 0.064141 seconds and 4 git commands to generate.