diff options
author | Dan Williams <dan.j.williams@intel.com> | 2017-01-13 17:14:23 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2017-04-25 16:20:46 -0400 |
commit | 6abccd1bfee49e491095772fd5aa9e96d915ae52 (patch) | |
tree | 594b473022733c4220e52a0f82ddea1c6a7e248f | |
parent | d4b29fd78ea6fc2be219be3af1a992149b4ff0f6 (diff) |
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: Tony Luck <tony.luck@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | arch/x86/include/asm/pmem.h | 5 | ||||
-rw-r--r-- | arch/x86/include/asm/string_64.h | 1 | ||||
-rw-r--r-- | drivers/acpi/nfit/core.c | 3 | ||||
-rw-r--r-- | drivers/nvdimm/claim.c | 2 | ||||
-rw-r--r-- | drivers/nvdimm/pmem.c | 2 | ||||
-rw-r--r-- | include/linux/pmem.h | 23 | ||||
-rw-r--r-- | include/linux/string.h | 8 |
7 files changed, 12 insertions, 32 deletions
diff --git a/arch/x86/include/asm/pmem.h b/arch/x86/include/asm/pmem.h index 529bb4a6487a..d5a22bac9988 100644 --- a/arch/x86/include/asm/pmem.h +++ b/arch/x86/include/asm/pmem.h | |||
@@ -44,11 +44,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n) | |||
44 | BUG(); | 44 | BUG(); |
45 | } | 45 | } |
46 | 46 | ||
47 | static inline int arch_memcpy_from_pmem(void *dst, const void *src, size_t n) | ||
48 | { | ||
49 | return memcpy_mcsafe(dst, src, n); | ||
50 | } | ||
51 | |||
52 | /** | 47 | /** |
53 | * arch_wb_cache_pmem - write back a cache range with CLWB | 48 | * arch_wb_cache_pmem - write back a cache range with CLWB |
54 | * @vaddr: virtual start address | 49 | * @vaddr: virtual start address |
diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h index a164862d77e3..733bae07fb29 100644 --- a/arch/x86/include/asm/string_64.h +++ b/arch/x86/include/asm/string_64.h | |||
@@ -79,6 +79,7 @@ int strcmp(const char *cs, const char *ct); | |||
79 | #define memset(s, c, n) __memset(s, c, n) | 79 | #define memset(s, c, n) __memset(s, c, n) |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | #define __HAVE_ARCH_MEMCPY_MCSAFE 1 | ||
82 | __must_check int memcpy_mcsafe_unrolled(void *dst, const void *src, size_t cnt); | 83 | __must_check int memcpy_mcsafe_unrolled(void *dst, const void *src, size_t cnt); |
83 | DECLARE_STATIC_KEY_FALSE(mcsafe_key); | 84 | DECLARE_STATIC_KEY_FALSE(mcsafe_key); |
84 | 85 | ||
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index c8ea9d698cd0..d0c07b2344e4 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
@@ -1783,8 +1783,7 @@ static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk, | |||
1783 | mmio_flush_range((void __force *) | 1783 | mmio_flush_range((void __force *) |
1784 | mmio->addr.aperture + offset, c); | 1784 | mmio->addr.aperture + offset, c); |
1785 | 1785 | ||
1786 | memcpy_from_pmem(iobuf + copied, | 1786 | memcpy(iobuf + copied, mmio->addr.aperture + offset, c); |
1787 | mmio->addr.aperture + offset, c); | ||
1788 | } | 1787 | } |
1789 | 1788 | ||
1790 | copied += c; | 1789 | copied += c; |
diff --git a/drivers/nvdimm/claim.c b/drivers/nvdimm/claim.c index ca6d572c48fc..3a35e8028b9c 100644 --- a/drivers/nvdimm/claim.c +++ b/drivers/nvdimm/claim.c | |||
@@ -239,7 +239,7 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns, | |||
239 | if (rw == READ) { | 239 | if (rw == READ) { |
240 | if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) | 240 | if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) |
241 | return -EIO; | 241 | return -EIO; |
242 | return memcpy_from_pmem(buf, nsio->addr + offset, size); | 242 | return memcpy_mcsafe(buf, nsio->addr + offset, size); |
243 | } | 243 | } |
244 | 244 | ||
245 | if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) { | 245 | if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) { |
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 85b85633d674..3b3dab73d741 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c | |||
@@ -89,7 +89,7 @@ static int read_pmem(struct page *page, unsigned int off, | |||
89 | int rc; | 89 | int rc; |
90 | void *mem = kmap_atomic(page); | 90 | void *mem = kmap_atomic(page); |
91 | 91 | ||
92 | rc = memcpy_from_pmem(mem + off, pmem_addr, len); | 92 | rc = memcpy_mcsafe(mem + off, pmem_addr, len); |
93 | kunmap_atomic(mem); | 93 | kunmap_atomic(mem); |
94 | if (rc) | 94 | if (rc) |
95 | return -EIO; | 95 | return -EIO; |
diff --git a/include/linux/pmem.h b/include/linux/pmem.h index e856c2cb0fe8..71ecf3d46aac 100644 --- a/include/linux/pmem.h +++ b/include/linux/pmem.h | |||
@@ -31,12 +31,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n) | |||
31 | BUG(); | 31 | BUG(); |
32 | } | 32 | } |
33 | 33 | ||
34 | static inline int arch_memcpy_from_pmem(void *dst, const void *src, size_t n) | ||
35 | { | ||
36 | BUG(); | ||
37 | return -EFAULT; | ||
38 | } | ||
39 | |||
40 | static inline size_t arch_copy_from_iter_pmem(void *addr, size_t bytes, | 34 | static inline size_t arch_copy_from_iter_pmem(void *addr, size_t bytes, |
41 | struct iov_iter *i) | 35 | struct iov_iter *i) |
42 | { | 36 | { |
@@ -65,23 +59,6 @@ static inline bool arch_has_pmem_api(void) | |||
65 | return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API); | 59 | return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API); |
66 | } | 60 | } |
67 | 61 | ||
68 | /* | ||
69 | * memcpy_from_pmem - read from persistent memory with error handling | ||
70 | * @dst: destination buffer | ||
71 | * @src: source buffer | ||
72 | * @size: transfer length | ||
73 | * | ||
74 | * Returns 0 on success negative error code on failure. | ||
75 | */ | ||
76 | static inline int memcpy_from_pmem(void *dst, void const *src, size_t size) | ||
77 | { | ||
78 | if (arch_has_pmem_api()) | ||
79 | return arch_memcpy_from_pmem(dst, src, size); | ||
80 | else | ||
81 | memcpy(dst, src, size); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | /** | 62 | /** |
86 | * memcpy_to_pmem - copy data to persistent memory | 63 | * memcpy_to_pmem - copy data to persistent memory |
87 | * @dst: destination buffer for the copy | 64 | * @dst: destination buffer for the copy |
diff --git a/include/linux/string.h b/include/linux/string.h index 26b6f6a66f83..9d6f189157e2 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
@@ -114,6 +114,14 @@ extern int memcmp(const void *,const void *,__kernel_size_t); | |||
114 | #ifndef __HAVE_ARCH_MEMCHR | 114 | #ifndef __HAVE_ARCH_MEMCHR |
115 | extern void * memchr(const void *,int,__kernel_size_t); | 115 | extern void * memchr(const void *,int,__kernel_size_t); |
116 | #endif | 116 | #endif |
117 | #ifndef __HAVE_ARCH_MEMCPY_MCSAFE | ||
118 | static inline __must_check int memcpy_mcsafe(void *dst, const void *src, | ||
119 | size_t cnt) | ||
120 | { | ||
121 | memcpy(dst, src, cnt); | ||
122 | return 0; | ||
123 | } | ||
124 | #endif | ||
117 | void *memchr_inv(const void *s, int c, size_t n); | 125 | void *memchr_inv(const void *s, int c, size_t n); |
118 | char *strreplace(char *s, char old, char new); | 126 | char *strreplace(char *s, char old, char new); |
119 | 127 | ||