[GIT PULL] libnvdimm fixes for 4.8

From: Williams, Dan J
Date: Thu Sep 29 2016 - 17:15:38 EST


Hi Linus, please pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

...to receive the following:

- (4) fixes for +ACI-flush hint+ACI- support. Flush hints are addresses
advertised by the ACPI 6+- NFIT (NVDIMM Firmware Interface Table) that
when written and fenced guarantee that writes pending in platform write
buffers (outside the cpu) have been flushed to media. +AKA-They might also
be used by hypervisors as a trigger condition to flush guest-persistent
memory ranges to storage.

Fix a potential data corruption issue, a broken definition of the hint
array, a wrong allocation size for the unit test implementation of the
flush hint table, and missing NULL check in an error path. +AKA-The unit
test, while it did not prevent these bugs from being merged, at least
triggered occasional crashes in advance of production usages.

- Fix handling of ACPI DSM error status results. +AKA-The DSM mechanism
allows communication with platform and memory device firmware. +AKA-We
correctly parse known errors, but were silently ignoring others. +AKA-Fix
it to consistently fail any command with a non-zero status return that
we otherwise do not interpret / handle.

These changes have a build success notification from the 0day robot and
have appeared in a -next release over the past week.

The following changes since commit 3be7988674ab33565700a37b210f502563d932e6:

Linux 4.8-rc7 (2016-09-18 17:27:41 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes

for you to fetch changes up to 595c73071e6641e59b83911fbb4026e767471000:

libnvdimm, region: fix flush hint table thinko (2016-09-24 11:45:38 -0700)

----------------------------------------------------------------
Dan Williams (4):
tools/testing/nvdimm: fix allocation range for mock flush hint tables
libnvdimm: fix devm+AF8-nvdimm+AF8-memremap() error path
nfit: fail DSMs that return non-zero status by default
libnvdimm, region: fix flush hint table thinko

Oliver O'Halloran (1):
nvdimm: fix PHYS+AF8-PFN/PFN+AF8-PHYS mixup

drivers/acpi/nfit/core.c +AHw- 48 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+------------------
drivers/nvdimm/core.c +AHw- 8 +-+-+-+-+-+--
drivers/nvdimm/nd.h +AHw- 22 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+---
drivers/nvdimm/region+AF8-devs.c +AHw- 22 +-+-+-+-+-+-+-+-+-+---------
tools/testing/nvdimm/test/nfit.c +AHw- 3 +-+--
5 files changed, 70 insertions(+-), 33 deletions(-)


commit 480b6837aa579991c6acc113bccf838e6a90843c
Author: Oliver O'Halloran +ADw-oohall+AEA-gmail.com+AD4-
Date: Mon Sep 19 20:19:00 2016 +-1000

nvdimm: fix PHYS+AF8-PFN/PFN+AF8-PHYS mixup

nd+AF8-activate+AF8-region() iomaps any hint addresses required when activating
a region. To prevent duplicate mappings it checks the PFN of the hint to
be mapped against the PFNs of the already mapped hints. Unfortunately it
doesn't convert the PFN back into a physical address before passing it
to devm+AF8-nvdimm+AF8-ioremap(). Instead it applies PHYS+AF8-PFN a second time
which ends about as well as you would imagine.

Signed-off-by: Oliver O'Halloran +ADw-oohall+AEA-gmail.com+AD4-
Signed-off-by: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-

commit 9d15ce9caaf9ecbec74e3be156a4a57451ed16c2
Author: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-
Date: Mon Sep 19 13:49:48 2016 -0700

tools/testing/nvdimm: fix allocation range for mock flush hint tables

Commit 480b6837aa57 +ACI-nvdimm: fix PHYS+AF8-PFN/PFN+AF8-PHYS mixup+ACI- identified
that we were passing an invalid address to devm+AF8-nvdimm+AF8-ioremap(). With
that fixed it exposed a bug in the memory reservation size for flush
hint tables. Since we map a full page we need to mock a full page of
memory to back the flush hint table entries.

Cc: Oliver O'Halloran +ADw-oohall+AEA-gmail.com+AD4-
Signed-off-by: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-

commit ecfb6d8a041cc2ca80bc69ffc20c00067d190df5
Author: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-
Date: Wed Sep 21 09:22:33 2016 -0700

libnvdimm: fix devm+AF8-nvdimm+AF8-memremap() error path

The internal alloc+AF8-nvdimm+AF8-map() helper might fail, particularly if the
memory region is already busy. Report request+AF8-mem+AF8-region() failures and
check for the failure.

Reported-by: Ryan Chen +ADw-ryan.chan105+AEA-gmail.com+AD4-
Signed-off-by: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-

commit 11294d63ac915230a36b0603c62134ef7b173d0a
Author: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-
Date: Wed Sep 21 09:21:26 2016 -0700

nfit: fail DSMs that return non-zero status by default

For the DSMs where the kernel knows the format of the output buffer and
originates those DSMs from within the kernel, return -EIO for any
non-zero status. If the BIOS is indicating a status that we do not know
how to handle, fail the DSM.

Cc: +ADw-stable+AEA-vger.kernel.org+AD4-
Signed-off-by: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-

commit 595c73071e6641e59b83911fbb4026e767471000
Author: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-
Date: Fri Sep 23 17:53:52 2016 -0700

libnvdimm, region: fix flush hint table thinko

The definition of the flush hint table as:

void +AF8AXw-iomem +ACo-flush+AF8-wpq+AFs-0+AF0AWw-0+AF0AOw-

...passed the unit test, but is broken as flush+AF8-wpq+AFs-0+AF0AWw-1+AF0- and
flush+AF8-wpq+AFs-1+AF0AWw-0+AF0- refer to the same entry. Fix this to use a helper that
calculates a slot in the table based on the geometry of flush hints in
the region. This is important to get right since virtualization
solutions use this mechanism to trigger hypervisor flushes to platform
persistence.

Reported-by: Dave Jiang +ADw-dave.jiang+AEA-intel.com+AD4-
Tested-by: Dave Jiang +ADw-dave.jiang+AEA-intel.com+AD4-
Signed-off-by: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-