aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid6sse1.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@anvin.org>2007-02-28 23:11:25 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-03-01 17:53:36 -0500
commita723406c4aeedb9dc5d54fb81130d13c757f41bc (patch)
tree113050f138360aceb70d5a5168ef8990acd03856 /drivers/md/raid6sse1.c
parent64a742bc61f9115b0bb270fa081e5b5b9c35dcd0 (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/raid6sse1.c')
-rw-r--r--drivers/md/raid6sse1.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/md/raid6sse1.c b/drivers/md/raid6sse1.c
index f7e7859f71aa..f0a1ba8f40ba 100644
--- a/drivers/md/raid6sse1.c
+++ b/drivers/md/raid6sse1.c
@@ -33,16 +33,10 @@ extern const struct raid6_mmx_constants {
33 33
34static int raid6_have_sse1_or_mmxext(void) 34static int raid6_have_sse1_or_mmxext(void)
35{ 35{
36#ifdef __KERNEL__
37 /* Not really boot_cpu but "all_cpus" */ 36 /* Not really boot_cpu but "all_cpus" */
38 return boot_cpu_has(X86_FEATURE_MMX) && 37 return boot_cpu_has(X86_FEATURE_MMX) &&
39 (boot_cpu_has(X86_FEATURE_XMM) || 38 (boot_cpu_has(X86_FEATURE_XMM) ||
40 boot_cpu_has(X86_FEATURE_MMXEXT)); 39 boot_cpu_has(X86_FEATURE_MMXEXT));
41#else
42 /* User space test code - this incorrectly breaks on some Athlons */
43 u32 features = cpuid_features();
44 return ( (features & (5<<23)) == (5<<23) );
45#endif
46} 40}
47 41
48/* 42/*
@@ -53,14 +47,12 @@ static void raid6_sse11_gen_syndrome(int disks, size_t bytes, void **ptrs)
53 u8 **dptr = (u8 **)ptrs; 47 u8 **dptr = (u8 **)ptrs;
54 u8 *p, *q; 48 u8 *p, *q;
55 int d, z, z0; 49 int d, z, z0;
56 raid6_mmx_save_t sa;
57 50
58 z0 = disks - 3; /* Highest data disk */ 51 z0 = disks - 3; /* Highest data disk */
59 p = dptr[z0+1]; /* XOR parity */ 52 p = dptr[z0+1]; /* XOR parity */
60 q = dptr[z0+2]; /* RS syndrome */ 53 q = dptr[z0+2]; /* RS syndrome */
61 54
62 /* This is really MMX code, not SSE */ 55 kernel_fpu_begin();
63 raid6_before_mmx(&sa);
64 56
65 asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d)); 57 asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d));
66 asm volatile("pxor %mm5,%mm5"); /* Zero temp */ 58 asm volatile("pxor %mm5,%mm5"); /* Zero temp */
@@ -94,8 +86,8 @@ static void raid6_sse11_gen_syndrome(int disks, size_t bytes, void **ptrs)
94 asm volatile("movntq %%mm4,%0" : "=m" (q[d])); 86 asm volatile("movntq %%mm4,%0" : "=m" (q[d]));
95 } 87 }
96 88
97 raid6_after_mmx(&sa);
98 asm volatile("sfence" : : : "memory"); 89 asm volatile("sfence" : : : "memory");
90 kernel_fpu_end();
99} 91}
100 92
101const struct raid6_calls raid6_sse1x1 = { 93const struct raid6_calls raid6_sse1x1 = {
@@ -113,13 +105,12 @@ static void raid6_sse12_gen_syndrome(int disks, size_t bytes, void **ptrs)
113 u8 **dptr = (u8 **)ptrs; 105 u8 **dptr = (u8 **)ptrs;
114 u8 *p, *q; 106 u8 *p, *q;
115 int d, z, z0; 107 int d, z, z0;
116 raid6_mmx_save_t sa;
117 108
118 z0 = disks - 3; /* Highest data disk */ 109 z0 = disks - 3; /* Highest data disk */
119 p = dptr[z0+1]; /* XOR parity */ 110 p = dptr[z0+1]; /* XOR parity */
120 q = dptr[z0+2]; /* RS syndrome */ 111 q = dptr[z0+2]; /* RS syndrome */
121 112
122 raid6_before_mmx(&sa); 113 kernel_fpu_begin();
123 114
124 asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d)); 115 asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d));
125 asm volatile("pxor %mm5,%mm5"); /* Zero temp */ 116 asm volatile("pxor %mm5,%mm5"); /* Zero temp */
@@ -157,8 +148,8 @@ static void raid6_sse12_gen_syndrome(int disks, size_t bytes, void **ptrs)
157 asm volatile("movntq %%mm6,%0" : "=m" (q[d+8])); 148 asm volatile("movntq %%mm6,%0" : "=m" (q[d+8]));
158 } 149 }
159 150
160 raid6_after_mmx(&sa);
161 asm volatile("sfence" : :: "memory"); 151 asm volatile("sfence" : :: "memory");
152 kernel_fpu_end();
162} 153}
163 154
164const struct raid6_calls raid6_sse1x2 = { 155const struct raid6_calls raid6_sse1x2 = {