x86, libnvdimm, pmem: move arch_invalidate_pmem() to libnvdimm
[platform/kernel/linux-rpi.git] / arch / x86 / include / asm / pmem.h
1 /*
2  * Copyright(c) 2015 Intel Corporation. All rights reserved.
3  *
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.
7  *
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.
12  */
13 #ifndef __ASM_X86_PMEM_H__
14 #define __ASM_X86_PMEM_H__
15
16 #include <linux/uaccess.h>
17 #include <asm/cacheflush.h>
18 #include <asm/cpufeature.h>
19 #include <asm/special_insns.h>
20
21 #ifdef CONFIG_ARCH_HAS_PMEM_API
22 /**
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
27  *
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.
30  */
31 static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n)
32 {
33         int rem;
34
35         /*
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.
40          */
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))
44                 BUG();
45 }
46 #endif /* CONFIG_ARCH_HAS_PMEM_API */
47 #endif /* __ASM_X86_PMEM_H__ */