2 * Copyright(c) 2015 Intel Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 #ifndef __ASM_X86_PMEM_H__
14 #define __ASM_X86_PMEM_H__
16 #include <linux/uaccess.h>
17 #include <asm/cacheflush.h>
18 #include <asm/cpufeature.h>
19 #include <asm/special_insns.h>
21 #ifdef CONFIG_ARCH_HAS_PMEM_API
23 * arch_memcpy_to_pmem - copy data to persistent memory
24 * @dst: destination buffer for the copy
25 * @src: source buffer for the copy
26 * @n: length of the copy in bytes
28 * Copy data to persistent memory media via non-temporal stores so that
29 * a subsequent pmem driver flush operation will drain posted write queues.
31 static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n)
36 * We are copying between two kernel buffers, if
37 * __copy_from_user_inatomic_nocache() returns an error (page
38 * fault) we would have already reported a general protection fault
39 * before the WARN+BUG.
41 rem = __copy_from_user_inatomic_nocache(dst, (void __user *) src, n);
42 if (WARN(rem, "%s: fault copying %p <- %p unwritten: %d\n",
43 __func__, dst, src, rem))
46 #endif /* CONFIG_ARCH_HAS_PMEM_API */
47 #endif /* __ASM_X86_PMEM_H__ */