~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/pmem.h

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 __PMEM_H__
 14 #define __PMEM_H__
 15 
 16 #include <linux/io.h>
 17 #include <linux/uio.h>
 18 
 19 #ifdef CONFIG_ARCH_HAS_PMEM_API
 20 #define ARCH_MEMREMAP_PMEM MEMREMAP_WB
 21 #include <asm/pmem.h>
 22 #else
 23 #define ARCH_MEMREMAP_PMEM MEMREMAP_WT
 24 /*
 25  * These are simply here to enable compilation, all call sites gate
 26  * calling these symbols with arch_has_pmem_api() and redirect to the
 27  * implementation in asm/pmem.h.
 28  */
 29 static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n)
 30 {
 31         BUG();
 32 }
 33 
 34 static inline size_t arch_copy_from_iter_pmem(void *addr, size_t bytes,
 35                 struct iov_iter *i)
 36 {
 37         BUG();
 38         return 0;
 39 }
 40 
 41 static inline void arch_clear_pmem(void *addr, size_t size)
 42 {
 43         BUG();
 44 }
 45 
 46 static inline void arch_wb_cache_pmem(void *addr, size_t size)
 47 {
 48         BUG();
 49 }
 50 
 51 static inline void arch_invalidate_pmem(void *addr, size_t size)
 52 {
 53         BUG();
 54 }
 55 #endif
 56 
 57 static inline bool arch_has_pmem_api(void)
 58 {
 59         return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
 60 }
 61 
 62 /**
 63  * memcpy_to_pmem - copy data to persistent memory
 64  * @dst: destination buffer for the copy
 65  * @src: source buffer for the copy
 66  * @n: length of the copy in bytes
 67  *
 68  * Perform a memory copy that results in the destination of the copy
 69  * being effectively evicted from, or never written to, the processor
 70  * cache hierarchy after the copy completes.  After memcpy_to_pmem()
 71  * data may still reside in cpu or platform buffers, so this operation
 72  * must be followed by a blkdev_issue_flush() on the pmem block device.
 73  */
 74 static inline void memcpy_to_pmem(void *dst, const void *src, size_t n)
 75 {
 76         if (arch_has_pmem_api())
 77                 arch_memcpy_to_pmem(dst, src, n);
 78         else
 79                 memcpy(dst, src, n);
 80 }
 81 
 82 /**
 83  * copy_from_iter_pmem - copy data from an iterator to PMEM
 84  * @addr:       PMEM destination address
 85  * @bytes:      number of bytes to copy
 86  * @i:          iterator with source data
 87  *
 88  * Copy data from the iterator 'i' to the PMEM buffer starting at 'addr'.
 89  * See blkdev_issue_flush() note for memcpy_to_pmem().
 90  */
 91 static inline size_t copy_from_iter_pmem(void *addr, size_t bytes,
 92                 struct iov_iter *i)
 93 {
 94         if (arch_has_pmem_api())
 95                 return arch_copy_from_iter_pmem(addr, bytes, i);
 96         return copy_from_iter_nocache(addr, bytes, i);
 97 }
 98 
 99 /**
100  * clear_pmem - zero a PMEM memory range
101  * @addr:       virtual start address
102  * @size:       number of bytes to zero
103  *
104  * Write zeros into the memory range starting at 'addr' for 'size' bytes.
105  * See blkdev_issue_flush() note for memcpy_to_pmem().
106  */
107 static inline void clear_pmem(void *addr, size_t size)
108 {
109         if (arch_has_pmem_api())
110                 arch_clear_pmem(addr, size);
111         else
112                 memset(addr, 0, size);
113 }
114 
115 /**
116  * invalidate_pmem - flush a pmem range from the cache hierarchy
117  * @addr:       virtual start address
118  * @size:       bytes to invalidate (internally aligned to cache line size)
119  *
120  * For platforms that support clearing poison this flushes any poisoned
121  * ranges out of the cache
122  */
123 static inline void invalidate_pmem(void *addr, size_t size)
124 {
125         if (arch_has_pmem_api())
126                 arch_invalidate_pmem(addr, size);
127 }
128 
129 /**
130  * wb_cache_pmem - write back processor cache for PMEM memory range
131  * @addr:       virtual start address
132  * @size:       number of bytes to write back
133  *
134  * Write back the processor cache range starting at 'addr' for 'size' bytes.
135  * See blkdev_issue_flush() note for memcpy_to_pmem().
136  */
137 static inline void wb_cache_pmem(void *addr, size_t size)
138 {
139         if (arch_has_pmem_api())
140                 arch_wb_cache_pmem(addr, size);
141 }
142 #endif /* __PMEM_H__ */
143 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp