Commit c5bce408 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'libnvdimm-for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm

Pull nvdimm mcsafe_memcpy use from Dan Williams:
 "Now that mcsafe_memcpy() has landed, and the return value was been
  clarified in commit cbf8b5a2 ("x86/mm, x86/mce: Fix return
  type/value for memcpy_mcsafe()"), 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.  There is no pressing need to merge this
  in 4.6- rc2.  However, if we wait until 4.7 the new memcpy_mcsafe()
  capability will ship without a user in 4.6-final"

* 'libnvdimm-for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
  x86, pmem: use memcpy_mcsafe() for memcpy_from_pmem()
parents 1e6d88cc fc0c2028
...@@ -47,6 +47,15 @@ static inline void arch_memcpy_to_pmem(void __pmem *dst, const void *src, ...@@ -47,6 +47,15 @@ static inline void arch_memcpy_to_pmem(void __pmem *dst, const void *src,
BUG(); BUG();
} }
static inline int arch_memcpy_from_pmem(void *dst, const void __pmem *src,
size_t n)
{
if (static_cpu_has(X86_FEATURE_MCE_RECOVERY))
return memcpy_mcsafe(dst, (void __force *) src, n);
memcpy(dst, (void __force *) src, n);
return 0;
}
/** /**
* arch_wmb_pmem - synchronize writes to persistent memory * arch_wmb_pmem - synchronize writes to persistent memory
* *
......
...@@ -99,7 +99,7 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page, ...@@ -99,7 +99,7 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
if (unlikely(bad_pmem)) if (unlikely(bad_pmem))
rc = -EIO; rc = -EIO;
else { else {
memcpy_from_pmem(mem + off, pmem_addr, len); rc = memcpy_from_pmem(mem + off, pmem_addr, len);
flush_dcache_page(page); flush_dcache_page(page);
} }
} else { } else {
...@@ -295,7 +295,7 @@ static int pmem_rw_bytes(struct nd_namespace_common *ndns, ...@@ -295,7 +295,7 @@ static int pmem_rw_bytes(struct nd_namespace_common *ndns,
if (unlikely(is_bad_pmem(&pmem->bb, offset / 512, sz_align))) if (unlikely(is_bad_pmem(&pmem->bb, offset / 512, sz_align)))
return -EIO; return -EIO;
memcpy_from_pmem(buf, pmem->virt_addr + offset, size); return memcpy_from_pmem(buf, pmem->virt_addr + offset, size);
} else { } else {
memcpy_to_pmem(pmem->virt_addr + offset, buf, size); memcpy_to_pmem(pmem->virt_addr + offset, buf, size);
wmb_pmem(); wmb_pmem();
......
...@@ -42,6 +42,13 @@ static inline void arch_memcpy_to_pmem(void __pmem *dst, const void *src, ...@@ -42,6 +42,13 @@ static inline void arch_memcpy_to_pmem(void __pmem *dst, const void *src,
BUG(); BUG();
} }
static inline int arch_memcpy_from_pmem(void *dst, const void __pmem *src,
size_t n)
{
BUG();
return -EFAULT;
}
static inline size_t arch_copy_from_iter_pmem(void __pmem *addr, size_t bytes, static inline size_t arch_copy_from_iter_pmem(void __pmem *addr, size_t bytes,
struct iov_iter *i) struct iov_iter *i)
{ {
...@@ -66,14 +73,17 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size) ...@@ -66,14 +73,17 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size)
#endif #endif
/* /*
* Architectures that define ARCH_HAS_PMEM_API must provide * memcpy_from_pmem - read from persistent memory with error handling
* implementations for arch_memcpy_to_pmem(), arch_wmb_pmem(), * @dst: destination buffer
* arch_copy_from_iter_pmem(), arch_clear_pmem(), arch_wb_cache_pmem() * @src: source buffer
* and arch_has_wmb_pmem(). * @size: transfer length
*
* Returns 0 on success negative error code on failure.
*/ */
static inline void memcpy_from_pmem(void *dst, void __pmem const *src, size_t size) static inline int memcpy_from_pmem(void *dst, void __pmem const *src,
size_t size)
{ {
memcpy(dst, (void __force const *) src, size); return arch_memcpy_from_pmem(dst, src, size);
} }
static inline bool arch_has_pmem_api(void) static inline bool arch_has_pmem_api(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment