aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/highmem.h
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/highmem.h
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/linux/highmem.h')
-rw-r--r--include/linux/highmem.h54
1 files changed, 25 insertions, 29 deletions
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index ef788b5b4a3..3a93f73a8ac 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -3,7 +3,6 @@
3 3
4#include <linux/fs.h> 4#include <linux/fs.h>
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/bug.h>
7#include <linux/mm.h> 6#include <linux/mm.h>
8#include <linux/uaccess.h> 7#include <linux/uaccess.h>
9#include <linux/hardirq.h> 8#include <linux/hardirq.h>
@@ -39,17 +38,10 @@ extern unsigned long totalhigh_pages;
39 38
40void kmap_flush_unused(void); 39void kmap_flush_unused(void);
41 40
42struct page *kmap_to_page(void *addr);
43
44#else /* CONFIG_HIGHMEM */ 41#else /* CONFIG_HIGHMEM */
45 42
46static inline unsigned int nr_free_highpages(void) { return 0; } 43static inline unsigned int nr_free_highpages(void) { return 0; }
47 44
48static inline struct page *kmap_to_page(void *addr)
49{
50 return virt_to_page(addr);
51}
52
53#define totalhigh_pages 0UL 45#define totalhigh_pages 0UL
54 46
55#ifndef ARCH_HAS_KMAP 47#ifndef ARCH_HAS_KMAP
@@ -63,12 +55,12 @@ static inline void kunmap(struct page *page)
63{ 55{
64} 56}
65 57
66static inline void *kmap_atomic(struct page *page) 58static inline void *__kmap_atomic(struct page *page)
67{ 59{
68 pagefault_disable(); 60 pagefault_disable();
69 return page_address(page); 61 return page_address(page);
70} 62}
71#define kmap_atomic_prot(page, prot) kmap_atomic(page) 63#define kmap_atomic_prot(page, prot) __kmap_atomic(page)
72 64
73static inline void __kunmap_atomic(void *addr) 65static inline void __kunmap_atomic(void *addr)
74{ 66{
@@ -117,23 +109,27 @@ static inline void kmap_atomic_idx_pop(void)
117#endif 109#endif
118 110
119/* 111/*
112 * Make both: kmap_atomic(page, idx) and kmap_atomic(page) work.
113 */
114#define kmap_atomic(page, args...) __kmap_atomic(page)
115
116/*
120 * Prevent people trying to call kunmap_atomic() as if it were kunmap() 117 * Prevent people trying to call kunmap_atomic() as if it were kunmap()
121 * kunmap_atomic() should get the return value of kmap_atomic, not the page. 118 * kunmap_atomic() should get the return value of kmap_atomic, not the page.
122 */ 119 */
123#define kunmap_atomic(addr) \ 120#define kunmap_atomic(addr, args...) \
124do { \ 121do { \
125 BUILD_BUG_ON(__same_type((addr), struct page *)); \ 122 BUILD_BUG_ON(__same_type((addr), struct page *)); \
126 __kunmap_atomic(addr); \ 123 __kunmap_atomic(addr); \
127} while (0) 124} while (0)
128 125
129
130/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */ 126/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
131#ifndef clear_user_highpage 127#ifndef clear_user_highpage
132static inline void clear_user_highpage(struct page *page, unsigned long vaddr) 128static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
133{ 129{
134 void *addr = kmap_atomic(page); 130 void *addr = kmap_atomic(page, KM_USER0);
135 clear_user_page(addr, vaddr, page); 131 clear_user_page(addr, vaddr, page);
136 kunmap_atomic(addr); 132 kunmap_atomic(addr, KM_USER0);
137} 133}
138#endif 134#endif
139 135
@@ -184,16 +180,16 @@ alloc_zeroed_user_highpage_movable(struct vm_area_struct *vma,
184 180
185static inline void clear_highpage(struct page *page) 181static inline void clear_highpage(struct page *page)
186{ 182{
187 void *kaddr = kmap_atomic(page); 183 void *kaddr = kmap_atomic(page, KM_USER0);
188 clear_page(kaddr); 184 clear_page(kaddr);
189 kunmap_atomic(kaddr); 185 kunmap_atomic(kaddr, KM_USER0);
190} 186}
191 187
192static inline void zero_user_segments(struct page *page, 188static inline void zero_user_segments(struct page *page,
193 unsigned start1, unsigned end1, 189 unsigned start1, unsigned end1,
194 unsigned start2, unsigned end2) 190 unsigned start2, unsigned end2)
195{ 191{
196 void *kaddr = kmap_atomic(page); 192 void *kaddr = kmap_atomic(page, KM_USER0);
197 193
198 BUG_ON(end1 > PAGE_SIZE || end2 > PAGE_SIZE); 194 BUG_ON(end1 > PAGE_SIZE || end2 > PAGE_SIZE);
199 195
@@ -203,7 +199,7 @@ static inline void zero_user_segments(struct page *page,
203 if (end2 > start2) 199 if (end2 > start2)
204 memset(kaddr + start2, 0, end2 - start2); 200 memset(kaddr + start2, 0, end2 - start2);
205 201
206 kunmap_atomic(kaddr); 202 kunmap_atomic(kaddr, KM_USER0);
207 flush_dcache_page(page); 203 flush_dcache_page(page);
208} 204}
209 205
@@ -232,11 +228,11 @@ static inline void copy_user_highpage(struct page *to, struct page *from,
232{ 228{
233 char *vfrom, *vto; 229 char *vfrom, *vto;
234 230
235 vfrom = kmap_atomic(from); 231 vfrom = kmap_atomic(from, KM_USER0);
236 vto = kmap_atomic(to); 232 vto = kmap_atomic(to, KM_USER1);
237 copy_user_page(vto, vfrom, vaddr, to); 233 copy_user_page(vto, vfrom, vaddr, to);
238 kunmap_atomic(vto); 234 kunmap_atomic(vto, KM_USER1);
239 kunmap_atomic(vfrom); 235 kunmap_atomic(vfrom, KM_USER0);
240} 236}
241 237
242#endif 238#endif
@@ -245,11 +241,11 @@ static inline void copy_highpage(struct page *to, struct page *from)
245{ 241{
246 char *vfrom, *vto; 242 char *vfrom, *vto;
247 243
248 vfrom = kmap_atomic(from); 244 vfrom = kmap_atomic(from, KM_USER0);
249 vto = kmap_atomic(to); 245 vto = kmap_atomic(to, KM_USER1);
250 copy_page(vto, vfrom); 246 copy_page(vto, vfrom);
251 kunmap_atomic(vto); 247 kunmap_atomic(vto, KM_USER1);
252 kunmap_atomic(vfrom); 248 kunmap_atomic(vfrom, KM_USER0);
253} 249}
254 250
255#endif /* _LINUX_HIGHMEM_H */ 251#endif /* _LINUX_HIGHMEM_H */