direct-io.hg

view linux-2.6-xen-sparse/include/linux/highmem.h @ 11509:2e6c10dc7c0b

[POWERPC][XEN] make sure put_domain() is called in case of allocate_rma() failuer

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Tue Sep 12 10:53:46 2006 -0400 (2006-09-12)
parents 4b06313b9790
children 4fad820a2233
line source
1 #ifndef _LINUX_HIGHMEM_H
2 #define _LINUX_HIGHMEM_H
4 #include <linux/config.h>
5 #include <linux/fs.h>
6 #include <linux/mm.h>
8 #include <asm/cacheflush.h>
10 #ifdef CONFIG_HIGHMEM
12 #include <asm/highmem.h>
14 /* declarations for linux/mm/highmem.c */
15 unsigned int nr_free_highpages(void);
16 #ifdef CONFIG_XEN
17 void kmap_flush_unused(void);
18 #endif
20 #else /* CONFIG_HIGHMEM */
22 static inline unsigned int nr_free_highpages(void) { return 0; }
23 #ifdef CONFIG_XEN
24 static inline void kmap_flush_unused(void) { }
25 #endif
27 static inline void *kmap(struct page *page)
28 {
29 might_sleep();
30 return page_address(page);
31 }
33 #define kunmap(page) do { (void) (page); } while (0)
35 #define kmap_atomic(page, idx) page_address(page)
36 #define kunmap_atomic(addr, idx) do { } while (0)
37 #define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn))
38 #define kmap_atomic_to_page(ptr) virt_to_page(ptr)
40 #endif /* CONFIG_HIGHMEM */
42 /* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
43 static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
44 {
45 void *addr = kmap_atomic(page, KM_USER0);
46 clear_user_page(addr, vaddr, page);
47 kunmap_atomic(addr, KM_USER0);
48 /* Make sure this page is cleared on other CPU's too before using it */
49 smp_wmb();
50 }
52 #ifndef __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
53 static inline struct page *
54 alloc_zeroed_user_highpage(struct vm_area_struct *vma, unsigned long vaddr)
55 {
56 struct page *page = alloc_page_vma(GFP_HIGHUSER, vma, vaddr);
58 if (page)
59 clear_user_highpage(page, vaddr);
61 return page;
62 }
63 #endif
65 static inline void clear_highpage(struct page *page)
66 {
67 void *kaddr = kmap_atomic(page, KM_USER0);
68 clear_page(kaddr);
69 kunmap_atomic(kaddr, KM_USER0);
70 }
72 /*
73 * Same but also flushes aliased cache contents to RAM.
74 */
75 static inline void memclear_highpage_flush(struct page *page, unsigned int offset, unsigned int size)
76 {
77 void *kaddr;
79 BUG_ON(offset + size > PAGE_SIZE);
81 kaddr = kmap_atomic(page, KM_USER0);
82 memset((char *)kaddr + offset, 0, size);
83 flush_dcache_page(page);
84 kunmap_atomic(kaddr, KM_USER0);
85 }
87 static inline void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr)
88 {
89 char *vfrom, *vto;
91 vfrom = kmap_atomic(from, KM_USER0);
92 vto = kmap_atomic(to, KM_USER1);
93 copy_user_page(vto, vfrom, vaddr, to);
94 kunmap_atomic(vfrom, KM_USER0);
95 kunmap_atomic(vto, KM_USER1);
96 /* Make sure this page is cleared on other CPU's too before using it */
97 smp_wmb();
98 }
100 static inline void copy_highpage(struct page *to, struct page *from)
101 {
102 char *vfrom, *vto;
104 vfrom = kmap_atomic(from, KM_USER0);
105 vto = kmap_atomic(to, KM_USER1);
106 copy_page(vto, vfrom);
107 kunmap_atomic(vfrom, KM_USER0);
108 kunmap_atomic(vto, KM_USER1);
109 }
111 #endif /* _LINUX_HIGHMEM_H */