Commit 6abccd1b authored by Dan Williams's avatar Dan Williams

x86, dax, pmem: remove indirection around memcpy_from_pmem()

memcpy_from_pmem() maps directly to memcpy_mcsafe(). The wrapper
serves no real benefit aside from affording a more generic function name
than the x86-specific 'mcsafe'. However this would not be the first time
that x86 terminology leaked into the global namespace. For lack of
better name, just use memcpy_mcsafe() directly.

This conversion also catches a place where we should have been using
plain memcpy, acpi_nfit_blk_single_io().

Cc: <x86@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Acked-by: default avatarTony Luck <tony.luck@intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent d4b29fd7
...@@ -44,11 +44,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n) ...@@ -44,11 +44,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n)
BUG(); BUG();
} }
static inline int arch_memcpy_from_pmem(void *dst, const void *src, size_t n)
{
return memcpy_mcsafe(dst, src, n);
}
/** /**
* arch_wb_cache_pmem - write back a cache range with CLWB * arch_wb_cache_pmem - write back a cache range with CLWB
* @vaddr: virtual start address * @vaddr: virtual start address
......
...@@ -79,6 +79,7 @@ int strcmp(const char *cs, const char *ct); ...@@ -79,6 +79,7 @@ int strcmp(const char *cs, const char *ct);
#define memset(s, c, n) __memset(s, c, n) #define memset(s, c, n) __memset(s, c, n)
#endif #endif
#define __HAVE_ARCH_MEMCPY_MCSAFE 1
__must_check int memcpy_mcsafe_unrolled(void *dst, const void *src, size_t cnt); __must_check int memcpy_mcsafe_unrolled(void *dst, const void *src, size_t cnt);
DECLARE_STATIC_KEY_FALSE(mcsafe_key); DECLARE_STATIC_KEY_FALSE(mcsafe_key);
......
...@@ -1783,8 +1783,7 @@ static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk, ...@@ -1783,8 +1783,7 @@ static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk,
mmio_flush_range((void __force *) mmio_flush_range((void __force *)
mmio->addr.aperture + offset, c); mmio->addr.aperture + offset, c);
memcpy_from_pmem(iobuf + copied, memcpy(iobuf + copied, mmio->addr.aperture + offset, c);
mmio->addr.aperture + offset, c);
} }
copied += c; copied += c;
......
...@@ -239,7 +239,7 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns, ...@@ -239,7 +239,7 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns,
if (rw == READ) { if (rw == READ) {
if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align)))
return -EIO; return -EIO;
return memcpy_from_pmem(buf, nsio->addr + offset, size); return memcpy_mcsafe(buf, nsio->addr + offset, size);
} }
if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) { if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) {
......
...@@ -89,7 +89,7 @@ static int read_pmem(struct page *page, unsigned int off, ...@@ -89,7 +89,7 @@ static int read_pmem(struct page *page, unsigned int off,
int rc; int rc;
void *mem = kmap_atomic(page); void *mem = kmap_atomic(page);
rc = memcpy_from_pmem(mem + off, pmem_addr, len); rc = memcpy_mcsafe(mem + off, pmem_addr, len);
kunmap_atomic(mem); kunmap_atomic(mem);
if (rc) if (rc)
return -EIO; return -EIO;
......
...@@ -31,12 +31,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n) ...@@ -31,12 +31,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n)
BUG(); BUG();
} }
static inline int arch_memcpy_from_pmem(void *dst, const void *src, size_t n)
{
BUG();
return -EFAULT;
}
static inline size_t arch_copy_from_iter_pmem(void *addr, size_t bytes, static inline size_t arch_copy_from_iter_pmem(void *addr, size_t bytes,
struct iov_iter *i) struct iov_iter *i)
{ {
...@@ -65,23 +59,6 @@ static inline bool arch_has_pmem_api(void) ...@@ -65,23 +59,6 @@ static inline bool arch_has_pmem_api(void)
return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API); return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
} }
/*
* memcpy_from_pmem - read from persistent memory with error handling
* @dst: destination buffer
* @src: source buffer
* @size: transfer length
*
* Returns 0 on success negative error code on failure.
*/
static inline int memcpy_from_pmem(void *dst, void const *src, size_t size)
{
if (arch_has_pmem_api())
return arch_memcpy_from_pmem(dst, src, size);
else
memcpy(dst, src, size);
return 0;
}
/** /**
* memcpy_to_pmem - copy data to persistent memory * memcpy_to_pmem - copy data to persistent memory
* @dst: destination buffer for the copy * @dst: destination buffer for the copy
......
...@@ -114,6 +114,14 @@ extern int memcmp(const void *,const void *,__kernel_size_t); ...@@ -114,6 +114,14 @@ extern int memcmp(const void *,const void *,__kernel_size_t);
#ifndef __HAVE_ARCH_MEMCHR #ifndef __HAVE_ARCH_MEMCHR
extern void * memchr(const void *,int,__kernel_size_t); extern void * memchr(const void *,int,__kernel_size_t);
#endif #endif
#ifndef __HAVE_ARCH_MEMCPY_MCSAFE
static inline __must_check int memcpy_mcsafe(void *dst, const void *src,
size_t cnt)
{
memcpy(dst, src, cnt);
return 0;
}
#endif
void *memchr_inv(const void *s, int c, size_t n); void *memchr_inv(const void *s, int c, size_t n);
char *strreplace(char *s, char old, char new); char *strreplace(char *s, char old, char new);
......
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