Merge tag 'libnvdimm-for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 29 Jul 2016 00:22:07 +0000 (17:22 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 29 Jul 2016 00:38:16 +0000 (17:38 -0700)
Pull libnvdimm updates from Dan Williams:

 - Replace pcommit with ADR / directed-flushing.

   The pcommit instruction, which has not shipped on any product, is
   deprecated.  Instead, the requirement is that platforms implement
   either ADR, or provide one or more flush addresses per nvdimm.

   ADR (Asynchronous DRAM Refresh) flushes data in posted write buffers
   to the memory controller on a power-fail event.

   Flush addresses are defined in ACPI 6.x as an NVDIMM Firmware
   Interface Table (NFIT) sub-structure: "Flush Hint Address Structure".
   A flush hint is an mmio address that when written and fenced assures
   that all previous posted writes targeting a given dimm have been
   flushed to media.

 - On-demand ARS (address range scrub).

   Linux uses the results of the ACPI ARS commands to track bad blocks
   in pmem devices.  When latent errors are detected we re-scrub the
   media to refresh the bad block list, userspace can also request a
   re-scrub at any time.

 - Support for the Microsoft DSM (device specific method) command
   format.

 - Support for EDK2/OVMF virtual disk device memory ranges.

 - Various fixes and cleanups across the subsystem.

* tag 'libnvdimm-for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: (41 commits)
  libnvdimm-btt: Delete an unnecessary check before the function call "__nd_device_register"
  nfit: do an ARS scrub on hitting a latent media error
  nfit: move to nfit/ sub-directory
  nfit, libnvdimm: allow an ARS scrub to be triggered on demand
  libnvdimm: register nvdimm_bus devices with an nd_bus driver
  pmem: clarify a debug print in pmem_clear_poison
  x86/insn: remove pcommit
  Revert "KVM: x86: add pcommit support"
  nfit, tools/testing/nvdimm/: unify shutdown paths
  libnvdimm: move ->module to struct nvdimm_bus_descriptor
  nfit: cleanup acpi_nfit_init calling convention
  nfit: fix _FIT evaluation memory leak + use after free
  tools/testing/nvdimm: add manufacturing_{date|location} dimm properties
  tools/testing/nvdimm: add virtual ramdisk range
  acpi, nfit: treat virtual ramdisk SPA as pmem region
  pmem: kill __pmem address space
  pmem: kill wmb_pmem()
  libnvdimm, pmem: use nvdimm_flush() for namespace I/O writes
  fs/dax: remove wmb_pmem()
  libnvdimm, pmem: flush posted-write queues on shutdown
  ...

26 files changed:
1  2 
Documentation/filesystems/Locking
arch/powerpc/sysdev/axonram.c
arch/x86/include/asm/cpufeatures.h
arch/x86/kvm/vmx.c
arch/x86/lib/x86-opcode-map.txt
drivers/acpi/Kconfig
drivers/acpi/Makefile
drivers/block/brd.c
drivers/md/dm-linear.c
drivers/md/dm-snap.c
drivers/md/dm-stripe.c
drivers/md/dm-target.c
drivers/md/dm.c
drivers/nvdimm/blk.c
drivers/nvdimm/bus.c
drivers/nvdimm/pmem.c
drivers/s390/block/dcssblk.c
fs/dax.c
include/linux/blkdev.h
include/linux/compiler.h
include/linux/device-mapper.h
kernel/memremap.c
tools/perf/arch/x86/tests/insn-x86-dat-32.c
tools/perf/arch/x86/tests/insn-x86-dat-64.c
tools/perf/arch/x86/tests/insn-x86-dat-src.c
tools/perf/util/intel-pt-decoder/x86-opcode-map.txt

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -454,35 -447,9 +454,10 @@@ config ACPI_REDUCED_HARDWARE_ONL
  
          If you are unsure what to do, do not enable this option.
  
- config ACPI_NFIT
-       tristate "ACPI NVDIMM Firmware Interface Table (NFIT)"
-       depends on PHYS_ADDR_T_64BIT
-       depends on BLK_DEV
-       depends on ARCH_HAS_MMIO_FLUSH
-       select LIBNVDIMM
-       help
-         Infrastructure to probe ACPI 6 compliant platforms for
-         NVDIMMs (NFIT) and register a libnvdimm device tree.  In
-         addition to storage devices this also enables libnvdimm to pass
-         ACPI._DSM messages for platform/dimm configuration.
-         To compile this driver as a module, choose M here:
-         the module will be called nfit.
- config ACPI_NFIT_DEBUG
-       bool "NFIT DSM debug"
-       depends on ACPI_NFIT
-       depends on DYNAMIC_DEBUG
-       default n
-       help
-         Enabling this option causes the nfit driver to dump the
-         input and output buffers of _DSM operations on the ACPI0012
-         device and its children.  This can be very verbose, so leave
-         it disabled unless you are debugging a hardware / firmware
-         issue.
+ source "drivers/acpi/nfit/Kconfig"
  
  source "drivers/acpi/apei/Kconfig"
 +source "drivers/acpi/dptf/Kconfig"
  
  config ACPI_EXTLOG
        tristate "Extended Error Log support"
Simple merge
Simple merge
@@@ -141,27 -141,9 +141,27 @@@ static int linear_iterate_devices(struc
        return fn(ti, lc->dev, lc->start, ti->len, data);
  }
  
-                                void __pmem **kaddr, pfn_t *pfn, long size)
 +static long linear_direct_access(struct dm_target *ti, sector_t sector,
++                               void **kaddr, pfn_t *pfn, long size)
 +{
 +      struct linear_c *lc = ti->private;
 +      struct block_device *bdev = lc->dev->bdev;
 +      struct blk_dax_ctl dax = {
 +              .sector = linear_map_sector(ti, sector),
 +              .size = size,
 +      };
 +      long ret;
 +
 +      ret = bdev_direct_access(bdev, &dax);
 +      *kaddr = dax.addr;
 +      *pfn = dax.pfn;
 +
 +      return ret;
 +}
 +
  static struct target_type linear_target = {
        .name   = "linear",
 -      .version = {1, 2, 1},
 +      .version = {1, 3, 0},
        .module = THIS_MODULE,
        .ctr    = linear_ctr,
        .dtr    = linear_dtr,
@@@ -2302,13 -2301,6 +2302,13 @@@ static int origin_map(struct dm_target 
        return do_origin(o->dev, bio);
  }
  
-               void __pmem **kaddr, pfn_t *pfn, long size)
 +static long origin_direct_access(struct dm_target *ti, sector_t sector,
++              void **kaddr, pfn_t *pfn, long size)
 +{
 +      DMWARN("device does not support dax.");
 +      return -EIO;
 +}
 +
  /*
   * Set the target "max_io_len" field to the minimum of all the snapshots'
   * chunk sizes.
@@@ -308,29 -308,6 +308,29 @@@ static int stripe_map(struct dm_target 
        return DM_MAPIO_REMAPPED;
  }
  
-                                void __pmem **kaddr, pfn_t *pfn, long size)
 +static long stripe_direct_access(struct dm_target *ti, sector_t sector,
++                               void **kaddr, pfn_t *pfn, long size)
 +{
 +      struct stripe_c *sc = ti->private;
 +      uint32_t stripe;
 +      struct block_device *bdev;
 +      struct blk_dax_ctl dax = {
 +              .size = size,
 +      };
 +      long ret;
 +
 +      stripe_map_sector(sc, sector, &stripe, &dax.sector);
 +
 +      dax.sector += sc->stripe[stripe].physical_start;
 +      bdev = sc->stripe[stripe].dev->bdev;
 +
 +      ret = bdev_direct_access(bdev, &dax);
 +      *kaddr = dax.addr;
 +      *pfn = dax.pfn;
 +
 +      return ret;
 +}
 +
  /*
   * Stripe status:
   *
@@@ -148,15 -148,9 +148,15 @@@ static void io_err_release_clone_rq(str
  {
  }
  
-                                void __pmem **kaddr, pfn_t *pfn, long size)
 +static long io_err_direct_access(struct dm_target *ti, sector_t sector,
++                               void **kaddr, pfn_t *pfn, long size)
 +{
 +      return -EIO;
 +}
 +
  static struct target_type error_target = {
        .name = "error",
 -      .version = {1, 4, 0},
 +      .version = {1, 5, 0},
        .features = DM_TARGET_WILDCARD,
        .ctr  = io_err_ctr,
        .dtr  = io_err_dtr,
diff --cc drivers/md/dm.c
@@@ -905,42 -1473,15 +905,42 @@@ int dm_set_target_max_io_len(struct dm_
  }
  EXPORT_SYMBOL_GPL(dm_set_target_max_io_len);
  
 -/*
 - * A target may call dm_accept_partial_bio only from the map routine.  It is
 - * allowed for all bio types except REQ_FLUSH.
 - *
 - * dm_accept_partial_bio informs the dm that the target only wants to process
 - * additional n_sectors sectors of the bio and the rest of the data should be
 - * sent in a next bio.
 - *
 - * A diagram that explains the arithmetics:
 +static long dm_blk_direct_access(struct block_device *bdev, sector_t sector,
-                                void __pmem **kaddr, pfn_t *pfn, long size)
++                               void **kaddr, pfn_t *pfn, long size)
 +{
 +      struct mapped_device *md = bdev->bd_disk->private_data;
 +      struct dm_table *map;
 +      struct dm_target *ti;
 +      int srcu_idx;
 +      long len, ret = -EIO;
 +
 +      map = dm_get_live_table(md, &srcu_idx);
 +      if (!map)
 +              goto out;
 +
 +      ti = dm_table_find_target(map, sector);
 +      if (!dm_target_is_valid(ti))
 +              goto out;
 +
 +      len = max_io_len(sector, ti) << SECTOR_SHIFT;
 +      size = min(len, size);
 +
 +      if (ti->type->direct_access)
 +              ret = ti->type->direct_access(ti, sector, kaddr, pfn, size);
 +out:
 +      dm_put_live_table(md, srcu_idx);
 +      return min(ret, size);
 +}
 +
 +/*
 + * A target may call dm_accept_partial_bio only from the map routine.  It is
 + * allowed for all bio types except REQ_PREFLUSH.
 + *
 + * dm_accept_partial_bio informs the dm that the target only wants to process
 + * additional n_sectors sectors of the bio and the rest of the data should be
 + * sent in a next bio.
 + *
 + * A diagram that explains the arithmetics:
   * +--------------------+---------------+-------+
   * |         1          |       2       |   3   |
   * +--------------------+---------------+-------+
@@@ -282,19 -280,19 +280,18 @@@ static int nsblk_attach_disk(struct nd_
        disk = alloc_disk(0);
        if (!disk)
                return -ENOMEM;
-       if (devm_add_action(dev, nd_blk_release_disk, disk)) {
-               put_disk(disk);
-               return -ENOMEM;
-       }
  
 -      disk->driverfs_dev      = dev;
        disk->first_minor       = 0;
        disk->fops              = &nd_blk_fops;
        disk->queue             = q;
        disk->flags             = GENHD_FL_EXT_DEVT;
        nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name);
        set_capacity(disk, 0);
 -      add_disk(disk);
 +      device_add_disk(dev, disk);
  
+       if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk))
+               return -ENOMEM;
        if (nsblk_meta_size(nsblk)) {
                int rc = nd_integrity_init(disk, nsblk_meta_size(nsblk));
  
Simple merge
@@@ -302,9 -307,13 +307,13 @@@ static int pmem_attach_disk(struct devi
                        / 512);
        if (devm_init_badblocks(dev, &pmem->bb))
                return -ENOMEM;
-       nvdimm_badblocks_populate(to_nd_region(dev->parent), &pmem->bb, res);
+       nvdimm_badblocks_populate(nd_region, &pmem->bb, res);
        disk->bb = &pmem->bb;
 -      add_disk(disk);
 +      device_add_disk(dev, disk);
+       if (devm_add_action_or_reset(dev, pmem_release_disk, disk))
+               return -ENOMEM;
        revalidate_disk(disk);
  
        return 0;
Simple merge
diff --cc fs/dax.c
Simple merge
Simple merge
Simple merge
@@@ -125,14 -116,6 +125,14 @@@ typedef void (*dm_io_hints_fn) (struct 
   */
  typedef int (*dm_busy_fn) (struct dm_target *ti);
  
-                                    void __pmem **kaddr, pfn_t *pfn, long size);
 +/*
 + * Returns:
 + *  < 0 : error
 + * >= 0 : the number of bytes accessible at the address
 + */
 +typedef long (*dm_direct_access_fn) (struct dm_target *ti, sector_t sector,
++                                   void **kaddr, pfn_t *pfn, long size);
 +
  void dm_error(const char *message);
  
  struct dm_dev {
Simple merge