[GIT PULL v2] libnvdimm, pmem: hook up memcpy_mcsafe
From: Williams, Dan J
Date: Wed Mar 30 2016 - 17:29:33 EST
Hi Linus, please pull from:
+AKA- git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-for-next
Now that mcsafe+AF8-memcpy() has landed, and the return value was been
clarified in commit cbf8b5a2b649 +ACI-x86/mm, x86/mce: Fix return
type/value for memcpy+AF8-mcsafe()+ACI-, let's hook up its primary usage in the
pmem driver.
The compilation problems from the initial posting have been fixed, this
has appeared in a -next release with no reported issues, and it picked
up an ack from Ingo. +AKA-There is no pressing need to merge this in 4.6-
rc2. +AKA-However, if we wait until 4.7 the new memcpy+AF8-mcsafe() capability
will ship without a user in 4.6-final.
---
The following changes since commit f55532a0c0b8bb6148f4e07853b876ef73bc69ca:
+AKA- Linux 4.6-rc1 (2016-03-26 16:03:24 -0700)
are available in the git repository at:
+AKA- git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-for-next
for you to fetch changes up to fc0c2028135c7f75fce36b90e44efb8003a9173b:
+AKA- x86, pmem: use memcpy+AF8-mcsafe() for memcpy+AF8-from+AF8-pmem() (2016-03-28 17:19:31 -0700)
----------------------------------------------------------------
Dan Williams (1):
+AKAAoACgAKAAoACg-x86, pmem: use memcpy+AF8-mcsafe() for memcpy+AF8-from+AF8-pmem()
commit fc0c2028135c7f75fce36b90e44efb8003a9173b
Author: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-
Date:+AKAAoACg-Tue Mar 8 10:30:19 2016 -0800
+AKAAoACgAKA-x86, pmem: use memcpy+AF8-mcsafe() for memcpy+AF8-from+AF8-pmem()
+AKAAoACgAKA-
+AKAAoACgAKA-Update the definition of memcpy+AF8-from+AF8-pmem() to return 0 or a negative
+AKAAoACgAKA-error code.+AKAAoA-Implement x86/arch+AF8-memcpy+AF8-from+AF8-pmem() with memcpy+AF8-mcsafe().
+AKAAoACgAKA-
+AKAAoACgAKA-Cc: Borislav Petkov +ADw-bp+AEA-alien8.de+AD4-
+AKAAoACgAKA-Cc: Tony Luck +ADw-tony.luck+AEA-intel.com+AD4-
+AKAAoACgAKA-Cc: Thomas Gleixner +ADw-tglx+AEA-linutronix.de+AD4-
+AKAAoACgAKA-Cc: Andy Lutomirski +ADw-luto+AEA-amacapital.net+AD4-
+AKAAoACgAKA-Cc: Peter Zijlstra +ADw-peterz+AEA-infradead.org+AD4-
+AKAAoACgAKA-Cc: Andrew Morton +ADw-akpm+AEA-linux-foundation.org+AD4-
+AKAAoACgAKA-Cc: Linus Torvalds +ADw-torvalds+AEA-linux-foundation.org+AD4-
+AKAAoACgAKA-Acked-by: Ingo Molnar +ADw-mingo+AEA-kernel.org+AD4-
+AKAAoACgAKA-Reviewed-by: Ross Zwisler +ADw-ross.zwisler+AEA-linux.intel.com+AD4-
+AKAAoACgAKA-Signed-off-by: Dan Williams +ADw-dan.j.williams+AEA-intel.com+AD4-
---
+AKA-arch/x86/include/asm/pmem.h +AHwAoACg-9 +-+-+-+-+-+-+-+-+-
+AKA-drivers/nvdimm/pmem.c+AKAAoACgAKAAoACgAKAAfACgAKA-4 +-+---
+AKA-include/linux/pmem.h+AKAAoACgAKAAoACgAKAAoAB8- 22 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------
+AKA-3 files changed, 27 insertions(+-), 8 deletions(-)
diff --git a/arch/x86/include/asm/pmem.h b/arch/x86/include/asm/pmem.h
index bf8b35d2035a..fbc5e92e1ecc 100644
--- a/arch/x86/include/asm/pmem.h
+-+-+- b/arch/x86/include/asm/pmem.h
+AEAAQA- -47,6 +-47,15 +AEAAQA- static inline void arch+AF8-memcpy+AF8-to+AF8-pmem(void +AF8AXw-pmem +ACo-dst, const void +ACo-src,
+AKA- BUG()+ADs-
+AKAAfQ-
+AKA-
+-static inline int arch+AF8-memcpy+AF8-from+AF8-pmem(void +ACo-dst, const void +AF8AXw-pmem +ACo-src,
+- size+AF8-t n)
+-+AHs-
+- if (static+AF8-cpu+AF8-has(X86+AF8-FEATURE+AF8-MCE+AF8-RECOVERY))
+- return memcpy+AF8-mcsafe(dst, (void +AF8AXw-force +ACo-) src, n)+ADs-
+- memcpy(dst, (void +AF8AXw-force +ACo-) src, n)+ADs-
+- return 0+ADs-
+-+AH0-
+-
+AKA-/+ACoAKg-
+AKA- +ACo- arch+AF8-wmb+AF8-pmem - synchronize writes to persistent memory
+AKA- +ACo-
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index ca5721c306bb..cc31c6f1f88e 100644
--- a/drivers/nvdimm/pmem.c
+-+-+- b/drivers/nvdimm/pmem.c
+AEAAQA- -99,7 +-99,7 +AEAAQA- static int pmem+AF8-do+AF8-bvec(struct pmem+AF8-device +ACo-pmem, struct page +ACo-page,
+AKA- if (unlikely(bad+AF8-pmem))
+AKA- rc +AD0- -EIO+ADs-
+AKA- else +AHs-
- memcpy+AF8-from+AF8-pmem(mem +- off, pmem+AF8-addr, len)+ADs-
+- rc +AD0- memcpy+AF8-from+AF8-pmem(mem +- off, pmem+AF8-addr, len)+ADs-
+AKA- flush+AF8-dcache+AF8-page(page)+ADs-
+AKA- +AH0-
+AKA- +AH0- else +AHs-
+AEAAQA- -295,7 +-295,7 +AEAAQA- static int pmem+AF8-rw+AF8-bytes(struct nd+AF8-namespace+AF8-common +ACo-ndns,
+AKA-
+AKA- if (unlikely(is+AF8-bad+AF8-pmem(+ACY-pmem-+AD4-bb, offset / 512, sz+AF8-align)))
+AKA- return -EIO+ADs-
- memcpy+AF8-from+AF8-pmem(buf, pmem-+AD4-virt+AF8-addr +- offset, size)+ADs-
+- return memcpy+AF8-from+AF8-pmem(buf, pmem-+AD4-virt+AF8-addr +- offset, size)+ADs-
+AKA- +AH0- else +AHs-
+AKA- memcpy+AF8-to+AF8-pmem(pmem-+AD4-virt+AF8-addr +- offset, buf, size)+ADs-
+AKA- wmb+AF8-pmem()+ADs-
diff --git a/include/linux/pmem.h b/include/linux/pmem.h
index 3ec5309e29f3..ac6d872ce067 100644
--- a/include/linux/pmem.h
+-+-+- b/include/linux/pmem.h
+AEAAQA- -42,6 +-42,13 +AEAAQA- static inline void arch+AF8-memcpy+AF8-to+AF8-pmem(void +AF8AXw-pmem +ACo-dst, const void +ACo-src,
+AKA- BUG()+ADs-
+AKAAfQ-
+AKA-
+-static inline int arch+AF8-memcpy+AF8-from+AF8-pmem(void +ACo-dst, const void +AF8AXw-pmem +ACo-src,
+- size+AF8-t n)
+-+AHs-
+- BUG()+ADs-
+- return -EFAULT+ADs-
+-+AH0-
+-
+AKA-static inline size+AF8-t arch+AF8-copy+AF8-from+AF8-iter+AF8-pmem(void +AF8AXw-pmem +ACo-addr, size+AF8-t bytes,
+AKA- struct iov+AF8-iter +ACo-i)
+AKAAew-
+AEAAQA- -66,14 +-73,17 +AEAAQA- static inline void arch+AF8-invalidate+AF8-pmem(void +AF8AXw-pmem +ACo-addr, size+AF8-t size)
+AKAAIw-endif
+AKA-
+AKA-/+ACo-
- +ACo- Architectures that define ARCH+AF8-HAS+AF8-PMEM+AF8-API must provide
- +ACo- implementations for arch+AF8-memcpy+AF8-to+AF8-pmem(), arch+AF8-wmb+AF8-pmem(),
- +ACo- arch+AF8-copy+AF8-from+AF8-iter+AF8-pmem(), arch+AF8-clear+AF8-pmem(), arch+AF8-wb+AF8-cache+AF8-pmem()
- +ACo- and arch+AF8-has+AF8-wmb+AF8-pmem().
+- +ACo- memcpy+AF8-from+AF8-pmem - read from persistent memory with error handling
+- +ACo- +AEA-dst: destination buffer
+- +ACo- +AEA-src: source buffer
+- +ACo- +AEA-size: transfer length
+- +ACo-
+- +ACo- Returns 0 on success negative error code on failure.
+AKA- +ACo-/
-static inline void memcpy+AF8-from+AF8-pmem(void +ACo-dst, void +AF8AXw-pmem const +ACo-src, size+AF8-t size)
+-static inline int memcpy+AF8-from+AF8-pmem(void +ACo-dst, void +AF8AXw-pmem const +ACo-src,
+- size+AF8-t size)
+AKAAew-
- memcpy(dst, (void +AF8AXw-force const +ACo-) src, size)+ADs-
+- return arch+AF8-memcpy+AF8-from+AF8-pmem(dst, src, size)+ADs-
+AKAAfQ-
+AKA-
+AKA-static inline bool arch+AF8-has+AF8-pmem+AF8-api(void)