Rev 4539 | Rev 6084 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4539 | Rev 5271 | ||
---|---|---|---|
1 | /************************************************************************** |
1 | /************************************************************************** |
2 | * |
2 | * |
3 | * Copyright (c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA |
3 | * Copyright (c) 2006-2007 Tungsten Graphics, Inc., Cedar Park, TX., USA |
4 | * All Rights Reserved. |
4 | * All Rights Reserved. |
5 | * |
5 | * |
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
7 | * copy of this software and associated documentation files (the |
7 | * copy of this software and associated documentation files (the |
8 | * "Software"), to deal in the Software without restriction, including |
8 | * "Software"), to deal in the Software without restriction, including |
9 | * without limitation the rights to use, copy, modify, merge, publish, |
9 | * without limitation the rights to use, copy, modify, merge, publish, |
10 | * distribute, sub license, and/or sell copies of the Software, and to |
10 | * distribute, sub license, and/or sell copies of the Software, and to |
11 | * permit persons to whom the Software is furnished to do so, subject to |
11 | * permit persons to whom the Software is furnished to do so, subject to |
12 | * the following conditions: |
12 | * the following conditions: |
13 | * |
13 | * |
14 | * The above copyright notice and this permission notice (including the |
14 | * The above copyright notice and this permission notice (including the |
15 | * next paragraph) shall be included in all copies or substantial portions |
15 | * next paragraph) shall be included in all copies or substantial portions |
16 | * of the Software. |
16 | * of the Software. |
17 | * |
17 | * |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
25 | * |
25 | * |
26 | **************************************************************************/ |
26 | **************************************************************************/ |
27 | /* |
27 | /* |
28 | * Authors: Thomas Hellström |
28 | * Authors: Thomas Hellström |
29 | */ |
29 | */ |
30 | 30 | ||
31 | #include |
31 | #include |
32 | #include |
- | |
33 | #include |
32 | #include |
34 | 33 | ||
35 | extern int x86_clflush_size; |
34 | extern int x86_clflush_size; |
36 | - | ||
37 | static inline void clflush(volatile void *__p) |
- | |
38 | { |
- | |
39 | asm volatile("clflush %0" : "+m" (*(volatile char*)__p)); |
- | |
40 | } |
35 | |
41 | 36 | ||
42 | #if 0 |
37 | #if 0 |
43 | static void |
38 | static void |
44 | drm_clflush_page(struct page *page) |
39 | drm_clflush_page(struct page *page) |
45 | { |
40 | { |
46 | uint8_t *page_virtual; |
41 | uint8_t *page_virtual; |
47 | unsigned int i; |
42 | unsigned int i; |
48 | const int size = boot_cpu_data.x86_clflush_size; |
43 | const int size = boot_cpu_data.x86_clflush_size; |
49 | 44 | ||
50 | if (unlikely(page == NULL)) |
45 | if (unlikely(page == NULL)) |
51 | return; |
46 | return; |
52 | 47 | ||
53 | page_virtual = kmap_atomic(page); |
48 | page_virtual = kmap_atomic(page); |
54 | for (i = 0; i < PAGE_SIZE; i += size) |
49 | for (i = 0; i < PAGE_SIZE; i += size) |
55 | clflush(page_virtual + i); |
50 | clflush(page_virtual + i); |
56 | kunmap_atomic(page_virtual); |
51 | kunmap_atomic(page_virtual); |
57 | } |
52 | } |
58 | 53 | ||
59 | static void drm_cache_flush_clflush(struct page *pages[], |
54 | static void drm_cache_flush_clflush(struct page *pages[], |
60 | unsigned long num_pages) |
55 | unsigned long num_pages) |
61 | { |
56 | { |
62 | unsigned long i; |
57 | unsigned long i; |
63 | 58 | ||
64 | mb(); |
59 | mb(); |
65 | for (i = 0; i < num_pages; i++) |
60 | for (i = 0; i < num_pages; i++) |
66 | drm_clflush_page(*pages++); |
61 | drm_clflush_page(*pages++); |
67 | mb(); |
62 | mb(); |
68 | } |
63 | } |
69 | 64 | ||
70 | static void |
65 | static void |
71 | drm_clflush_ipi_handler(void *null) |
66 | drm_clflush_ipi_handler(void *null) |
72 | { |
67 | { |
73 | wbinvd(); |
68 | wbinvd(); |
74 | } |
69 | } |
75 | #endif |
70 | #endif |
76 | 71 | ||
77 | void |
72 | void |
78 | drm_clflush_pages(struct page *pages[], unsigned long num_pages) |
73 | drm_clflush_pages(struct page *pages[], unsigned long num_pages) |
79 | { |
74 | { |
80 | uint8_t *pva; |
75 | uint8_t *pva; |
81 | unsigned int i, j; |
76 | unsigned int i, j; |
82 | 77 | ||
83 | pva = AllocKernelSpace(4096); |
78 | pva = AllocKernelSpace(4096); |
84 | 79 | ||
85 | if(pva != NULL) |
80 | if(pva != NULL) |
86 | { |
81 | { |
87 | dma_addr_t *src, *dst; |
82 | dma_addr_t *src, *dst; |
88 | u32 count; |
83 | u32 count; |
89 | 84 | ||
90 | for (i = 0; i < num_pages; i++) |
85 | for (i = 0; i < num_pages; i++) |
91 | { |
86 | { |
92 | mb(); |
87 | mb(); |
93 | MapPage(pva, page_to_phys(pages[i]), 0x001); |
88 | MapPage(pva, page_to_phys(pages[i]), 0x001); |
94 | for (j = 0; j < PAGE_SIZE; j += x86_clflush_size) |
89 | for (j = 0; j < PAGE_SIZE; j += x86_clflush_size) |
95 | clflush(pva + j); |
90 | clflush(pva + j); |
96 | } |
91 | } |
97 | FreeKernelSpace(pva); |
92 | FreeKernelSpace(pva); |
98 | } |
93 | } |
99 | mb(); |
94 | mb(); |
100 | } |
95 | } |
101 | EXPORT_SYMBOL(drm_clflush_pages); |
96 | EXPORT_SYMBOL(drm_clflush_pages); |
102 | 97 | ||
103 | void |
98 | void |
104 | drm_clflush_sg(struct sg_table *st) |
99 | drm_clflush_sg(struct sg_table *st) |
105 | { |
100 | { |
106 | struct sg_page_iter sg_iter; |
101 | struct sg_page_iter sg_iter; |
107 | struct page *page; |
102 | struct page *page; |
108 | 103 | ||
109 | uint8_t *pva; |
104 | uint8_t *pva; |
110 | unsigned int i; |
105 | unsigned int i; |
111 | 106 | ||
112 | pva = AllocKernelSpace(4096); |
107 | pva = AllocKernelSpace(4096); |
113 | if( pva != NULL) |
108 | if( pva != NULL) |
114 | { |
109 | { |
115 | mb(); |
110 | mb(); |
116 | for_each_sg_page(st->sgl, &sg_iter, st->nents, 0) |
111 | for_each_sg_page(st->sgl, &sg_iter, st->nents, 0) |
117 | { |
112 | { |
118 | page = sg_page_iter_page(&sg_iter); |
113 | page = sg_page_iter_page(&sg_iter); |
119 | 114 | ||
120 | MapPage(pva,page_to_phys(page), 0x001); |
115 | MapPage(pva,page_to_phys(page), 0x001); |
121 | 116 | ||
122 | for (i = 0; i < PAGE_SIZE; i += x86_clflush_size) |
117 | for (i = 0; i < PAGE_SIZE; i += x86_clflush_size) |
123 | clflush(pva + i); |
118 | clflush(pva + i); |
124 | }; |
119 | }; |
125 | FreeKernelSpace(pva); |
120 | FreeKernelSpace(pva); |
126 | }; |
121 | }; |
127 | mb(); |
122 | mb(); |
128 | } |
123 | } |
129 | EXPORT_SYMBOL(drm_clflush_sg); |
124 | EXPORT_SYMBOL(drm_clflush_sg); |
130 | 125 | ||
131 | #if 0 |
126 | #if 0 |
132 | void |
127 | void |
133 | drm_clflush_virt_range(char *addr, unsigned long length) |
128 | drm_clflush_virt_range(char *addr, unsigned long length) |
134 | { |
129 | { |
135 | #if defined(CONFIG_X86) |
130 | #if defined(CONFIG_X86) |
136 | if (cpu_has_clflush) { |
131 | if (cpu_has_clflush) { |
137 | char *end = addr + length; |
132 | char *end = addr + length; |
138 | mb(); |
133 | mb(); |
139 | for (; addr < end; addr += boot_cpu_data.x86_clflush_size) |
134 | for (; addr < end; addr += boot_cpu_data.x86_clflush_size) |
140 | clflush(addr); |
135 | clflush(addr); |
141 | clflush(end - 1); |
136 | clflush(end - 1); |
142 | mb(); |
137 | mb(); |
143 | return; |
138 | return; |
144 | } |
139 | } |
145 | 140 | ||
146 | if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) |
141 | if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) |
147 | printk(KERN_ERR "Timed out waiting for cache flush.\n"); |
142 | printk(KERN_ERR "Timed out waiting for cache flush.\n"); |
148 | #else |
143 | #else |
149 | printk(KERN_ERR "Architecture has no drm_cache.c support\n"); |
144 | printk(KERN_ERR "Architecture has no drm_cache.c support\n"); |
150 | WARN_ON_ONCE(1); |
145 | WARN_ON_ONCE(1); |
151 | #endif |
146 | #endif |
152 | } |
147 | } |
153 | EXPORT_SYMBOL(drm_clflush_virt_range); |
148 | EXPORT_SYMBOL(drm_clflush_virt_range); |
154 | 149 | ||
155 | #endif>>>>>> |
150 | #endif>>>>>> |