| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: drm_cache.c,v 1.5 2015/03/06 12:06:35 riastradh Exp $ */ | | 1 | /* $NetBSD: drm_cache.c,v 1.6 2015/03/06 12:24:36 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: drm_cache.c,v 1.5 2015/03/06 12:06:35 riastradh Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_cache.c,v 1.6 2015/03/06 12:24:36 riastradh Exp $"); |
34 | | | 34 | |
35 | #include <sys/types.h> | | 35 | #include <sys/types.h> |
36 | #include <sys/xcall.h> | | 36 | #include <sys/xcall.h> |
37 | | | 37 | |
38 | #include <uvm/uvm_extern.h> | | 38 | #include <uvm/uvm_extern.h> |
39 | | | 39 | |
40 | #include <machine/cpufunc.h> | | 40 | #include <machine/cpufunc.h> |
41 | | | 41 | |
42 | #include <linux/mm_types.h> | | 42 | #include <linux/mm_types.h> |
43 | | | 43 | |
44 | #include <drm/drmP.h> | | 44 | #include <drm/drmP.h> |
45 | | | 45 | |
46 | static bool drm_md_clflush_finegrained_p(void); | | 46 | static bool drm_md_clflush_finegrained_p(void); |
| @@ -94,48 +94,42 @@ drm_clflush_virt_range(const void *vaddr | | | @@ -94,48 +94,42 @@ drm_clflush_virt_range(const void *vaddr |
94 | else | | 94 | else |
95 | drm_md_clflush_all(); | | 95 | drm_md_clflush_all(); |
96 | } | | 96 | } |
97 | | | 97 | |
98 | #if defined(__i386__) || defined(__x86_64__) | | 98 | #if defined(__i386__) || defined(__x86_64__) |
99 | | | 99 | |
100 | static bool | | 100 | static bool |
101 | drm_md_clflush_finegrained_p(void) | | 101 | drm_md_clflush_finegrained_p(void) |
102 | { | | 102 | { |
103 | return ISSET(cpu_info_primary.ci_feat_val[0], CPUID_CFLUSH); | | 103 | return ISSET(cpu_info_primary.ci_feat_val[0], CPUID_CFLUSH); |
104 | } | | 104 | } |
105 | | | 105 | |
106 | static void | | 106 | static void |
107 | drm_x86_clflush_cpu(void) | | | |
108 | { | | | |
109 | asm volatile ("wbinvd"); | | | |
110 | } | | | |
111 | | | | |
112 | static void | | | |
113 | drm_x86_clflush(const void *vaddr) | | 107 | drm_x86_clflush(const void *vaddr) |
114 | { | | 108 | { |
115 | asm volatile ("clflush %0" : : "m" (*(const char *)vaddr)); | | 109 | asm volatile ("clflush %0" : : "m" (*(const char *)vaddr)); |
116 | } | | 110 | } |
117 | | | 111 | |
118 | static size_t | | 112 | static size_t |
119 | drm_x86_clflush_size(void) | | 113 | drm_x86_clflush_size(void) |
120 | { | | 114 | { |
121 | KASSERT(drm_md_clflush_finegrained_p()); | | 115 | KASSERT(drm_md_clflush_finegrained_p()); |
122 | return cpu_info_primary.ci_cflush_lsize; | | 116 | return cpu_info_primary.ci_cflush_lsize; |
123 | } | | 117 | } |
124 | | | 118 | |
125 | static void | | 119 | static void |
126 | drm_x86_clflush_xc(void *arg0 __unused, void *arg1 __unused) | | 120 | drm_x86_clflush_xc(void *arg0 __unused, void *arg1 __unused) |
127 | { | | 121 | { |
128 | drm_x86_clflush_cpu(); | | 122 | wbinvd(); |
129 | } | | 123 | } |
130 | | | 124 | |
131 | static void | | 125 | static void |
132 | drm_md_clflush_all(void) | | 126 | drm_md_clflush_all(void) |
133 | { | | 127 | { |
134 | xc_wait(xc_broadcast(0, &drm_x86_clflush_xc, NULL, NULL)); | | 128 | xc_wait(xc_broadcast(0, &drm_x86_clflush_xc, NULL, NULL)); |
135 | } | | 129 | } |
136 | | | 130 | |
137 | static void | | 131 | static void |
138 | drm_md_clflush_page(struct page *page) | | 132 | drm_md_clflush_page(struct page *page) |
139 | { | | 133 | { |
140 | void *const vaddr = kmap_atomic(page); | | 134 | void *const vaddr = kmap_atomic(page); |
141 | | | 135 | |