diff options
author | H. Peter Anvin <hpa@anvin.org> | 2007-02-28 23:11:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-03-01 17:53:36 -0500 |
commit | a723406c4aeedb9dc5d54fb81130d13c757f41bc (patch) | |
tree | 113050f138360aceb70d5a5168ef8990acd03856 /drivers/md/raid6sse2.c | |
parent | 64a742bc61f9115b0bb270fa081e5b5b9c35dcd0 (diff) |
[PATCH] md: RAID6: clean up CPUID and FPU enter/exit code
- Use kernel_fpu_begin() and kernel_fpu_end()
- Use boot_cpu_has() for feature testing even in userspace
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/raid6sse2.c')
-rw-r--r-- | drivers/md/raid6sse2.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/md/raid6sse2.c b/drivers/md/raid6sse2.c index b3aa7fe0877e..0f019762a7c3 100644 --- a/drivers/md/raid6sse2.c +++ b/drivers/md/raid6sse2.c | |||
@@ -30,17 +30,11 @@ static const struct raid6_sse_constants { | |||
30 | 30 | ||
31 | static int raid6_have_sse2(void) | 31 | static int raid6_have_sse2(void) |
32 | { | 32 | { |
33 | #ifdef __KERNEL__ | ||
34 | /* Not really boot_cpu but "all_cpus" */ | 33 | /* Not really boot_cpu but "all_cpus" */ |
35 | return boot_cpu_has(X86_FEATURE_MMX) && | 34 | return boot_cpu_has(X86_FEATURE_MMX) && |
36 | boot_cpu_has(X86_FEATURE_FXSR) && | 35 | boot_cpu_has(X86_FEATURE_FXSR) && |
37 | boot_cpu_has(X86_FEATURE_XMM) && | 36 | boot_cpu_has(X86_FEATURE_XMM) && |
38 | boot_cpu_has(X86_FEATURE_XMM2); | 37 | boot_cpu_has(X86_FEATURE_XMM2); |
39 | #else | ||
40 | /* User space test code */ | ||
41 | u32 features = cpuid_features(); | ||
42 | return ( (features & (15<<23)) == (15<<23) ); | ||
43 | #endif | ||
44 | } | 38 | } |
45 | 39 | ||
46 | /* | 40 | /* |
@@ -51,13 +45,12 @@ static void raid6_sse21_gen_syndrome(int disks, size_t bytes, void **ptrs) | |||
51 | u8 **dptr = (u8 **)ptrs; | 45 | u8 **dptr = (u8 **)ptrs; |
52 | u8 *p, *q; | 46 | u8 *p, *q; |
53 | int d, z, z0; | 47 | int d, z, z0; |
54 | raid6_sse_save_t sa; | ||
55 | 48 | ||
56 | z0 = disks - 3; /* Highest data disk */ | 49 | z0 = disks - 3; /* Highest data disk */ |
57 | p = dptr[z0+1]; /* XOR parity */ | 50 | p = dptr[z0+1]; /* XOR parity */ |
58 | q = dptr[z0+2]; /* RS syndrome */ | 51 | q = dptr[z0+2]; /* RS syndrome */ |
59 | 52 | ||
60 | raid6_before_sse2(&sa); | 53 | kernel_fpu_begin(); |
61 | 54 | ||
62 | asm volatile("movdqa %0,%%xmm0" : : "m" (raid6_sse_constants.x1d[0])); | 55 | asm volatile("movdqa %0,%%xmm0" : : "m" (raid6_sse_constants.x1d[0])); |
63 | asm volatile("pxor %xmm5,%xmm5"); /* Zero temp */ | 56 | asm volatile("pxor %xmm5,%xmm5"); /* Zero temp */ |
@@ -93,8 +86,8 @@ static void raid6_sse21_gen_syndrome(int disks, size_t bytes, void **ptrs) | |||
93 | asm volatile("pxor %xmm4,%xmm4"); | 86 | asm volatile("pxor %xmm4,%xmm4"); |
94 | } | 87 | } |
95 | 88 | ||
96 | raid6_after_sse2(&sa); | ||
97 | asm volatile("sfence" : : : "memory"); | 89 | asm volatile("sfence" : : : "memory"); |
90 | kernel_fpu_end(); | ||
98 | } | 91 | } |
99 | 92 | ||
100 | const struct raid6_calls raid6_sse2x1 = { | 93 | const struct raid6_calls raid6_sse2x1 = { |
@@ -112,13 +105,12 @@ static void raid6_sse22_gen_syndrome(int disks, size_t bytes, void **ptrs) | |||
112 | u8 **dptr = (u8 **)ptrs; | 105 | u8 **dptr = (u8 **)ptrs; |
113 | u8 *p, *q; | 106 | u8 *p, *q; |
114 | int d, z, z0; | 107 | int d, z, z0; |
115 | raid6_sse_save_t sa; | ||
116 | 108 | ||
117 | z0 = disks - 3; /* Highest data disk */ | 109 | z0 = disks - 3; /* Highest data disk */ |
118 | p = dptr[z0+1]; /* XOR parity */ | 110 | p = dptr[z0+1]; /* XOR parity */ |
119 | q = dptr[z0+2]; /* RS syndrome */ | 111 | q = dptr[z0+2]; /* RS syndrome */ |
120 | 112 | ||
121 | raid6_before_sse2(&sa); | 113 | kernel_fpu_begin(); |
122 | 114 | ||
123 | asm volatile("movdqa %0,%%xmm0" : : "m" (raid6_sse_constants.x1d[0])); | 115 | asm volatile("movdqa %0,%%xmm0" : : "m" (raid6_sse_constants.x1d[0])); |
124 | asm volatile("pxor %xmm5,%xmm5"); /* Zero temp */ | 116 | asm volatile("pxor %xmm5,%xmm5"); /* Zero temp */ |
@@ -156,8 +148,8 @@ static void raid6_sse22_gen_syndrome(int disks, size_t bytes, void **ptrs) | |||
156 | asm volatile("movntdq %%xmm6,%0" : "=m" (q[d+16])); | 148 | asm volatile("movntdq %%xmm6,%0" : "=m" (q[d+16])); |
157 | } | 149 | } |
158 | 150 | ||
159 | raid6_after_sse2(&sa); | ||
160 | asm volatile("sfence" : : : "memory"); | 151 | asm volatile("sfence" : : : "memory"); |
152 | kernel_fpu_end(); | ||
161 | } | 153 | } |
162 | 154 | ||
163 | const struct raid6_calls raid6_sse2x2 = { | 155 | const struct raid6_calls raid6_sse2x2 = { |
@@ -179,13 +171,12 @@ static void raid6_sse24_gen_syndrome(int disks, size_t bytes, void **ptrs) | |||
179 | u8 **dptr = (u8 **)ptrs; | 171 | u8 **dptr = (u8 **)ptrs; |
180 | u8 *p, *q; | 172 | u8 *p, *q; |
181 | int d, z, z0; | 173 | int d, z, z0; |
182 | raid6_sse16_save_t sa; | ||
183 | 174 | ||
184 | z0 = disks - 3; /* Highest data disk */ | 175 | z0 = disks - 3; /* Highest data disk */ |
185 | p = dptr[z0+1]; /* XOR parity */ | 176 | p = dptr[z0+1]; /* XOR parity */ |
186 | q = dptr[z0+2]; /* RS syndrome */ | 177 | q = dptr[z0+2]; /* RS syndrome */ |
187 | 178 | ||
188 | raid6_before_sse16(&sa); | 179 | kernel_fpu_begin(); |
189 | 180 | ||
190 | asm volatile("movdqa %0,%%xmm0" :: "m" (raid6_sse_constants.x1d[0])); | 181 | asm volatile("movdqa %0,%%xmm0" :: "m" (raid6_sse_constants.x1d[0])); |
191 | asm volatile("pxor %xmm2,%xmm2"); /* P[0] */ | 182 | asm volatile("pxor %xmm2,%xmm2"); /* P[0] */ |
@@ -256,8 +247,9 @@ static void raid6_sse24_gen_syndrome(int disks, size_t bytes, void **ptrs) | |||
256 | asm volatile("movntdq %%xmm14,%0" : "=m" (q[d+48])); | 247 | asm volatile("movntdq %%xmm14,%0" : "=m" (q[d+48])); |
257 | asm volatile("pxor %xmm14,%xmm14"); | 248 | asm volatile("pxor %xmm14,%xmm14"); |
258 | } | 249 | } |
250 | |||
259 | asm volatile("sfence" : : : "memory"); | 251 | asm volatile("sfence" : : : "memory"); |
260 | raid6_after_sse16(&sa); | 252 | kernel_fpu_end(); |
261 | } | 253 | } |
262 | 254 | ||
263 | const struct raid6_calls raid6_sse2x4 = { | 255 | const struct raid6_calls raid6_sse2x4 = { |