From cc4589ebfae6f8dbb5cf880a0a67eedab3416492 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 11 Aug 2010 00:19:05 +0100 Subject: Rename raid6 files now they're in a 'raid6' directory. Linus asks 'why "raid6" twice?'. No reason. Signed-off-by: David Woodhouse --- lib/raid6/mmx.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 lib/raid6/mmx.c (limited to 'lib/raid6/mmx.c') diff --git a/lib/raid6/mmx.c b/lib/raid6/mmx.c new file mode 100644 index 000000000000..e7f6c13132bf --- /dev/null +++ b/lib/raid6/mmx.c @@ -0,0 +1,142 @@ +/* -*- linux-c -*- ------------------------------------------------------- * + * + * Copyright 2002 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * raid6mmx.c + * + * MMX implementation of RAID-6 syndrome functions + */ + +#if defined(__i386__) && !defined(__arch_um__) + +#include +#include "raid6x86.h" + +/* Shared with raid6sse1.c */ +const struct raid6_mmx_constants { + u64 x1d; +} raid6_mmx_constants = { + 0x1d1d1d1d1d1d1d1dULL, +}; + +static int raid6_have_mmx(void) +{ + /* Not really "boot_cpu" but "all_cpus" */ + return boot_cpu_has(X86_FEATURE_MMX); +} + +/* + * Plain MMX implementation + */ +static void raid6_mmx1_gen_syndrome(int disks, size_t bytes, void **ptrs) +{ + u8 **dptr = (u8 **)ptrs; + u8 *p, *q; + int d, z, z0; + + z0 = disks - 3; /* Highest data disk */ + p = dptr[z0+1]; /* XOR parity */ + q = dptr[z0+2]; /* RS syndrome */ + + kernel_fpu_begin(); + + asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d)); + asm volatile("pxor %mm5,%mm5"); /* Zero temp */ + + for ( d = 0 ; d < bytes ; d += 8 ) { + asm volatile("movq %0,%%mm2" : : "m" (dptr[z0][d])); /* P[0] */ + asm volatile("movq %mm2,%mm4"); /* Q[0] */ + for ( z = z0-1 ; z >= 0 ; z-- ) { + asm volatile("movq %0,%%mm6" : : "m" (dptr[z][d])); + asm volatile("pcmpgtb %mm4,%mm5"); + asm volatile("paddb %mm4,%mm4"); + asm volatile("pand %mm0,%mm5"); + asm volatile("pxor %mm5,%mm4"); + asm volatile("pxor %mm5,%mm5"); + asm volatile("pxor %mm6,%mm2"); + asm volatile("pxor %mm6,%mm4"); + } + asm volatile("movq %%mm2,%0" : "=m" (p[d])); + asm volatile("pxor %mm2,%mm2"); + asm volatile("movq %%mm4,%0" : "=m" (q[d])); + asm volatile("pxor %mm4,%mm4"); + } + + kernel_fpu_end(); +} + +const struct raid6_calls raid6_mmxx1 = { + raid6_mmx1_gen_syndrome, + raid6_have_mmx, + "mmxx1", + 0 +}; + +/* + * Unrolled-by-2 MMX implementation + */ +static void raid6_mmx2_gen_syndrome(int disks, size_t bytes, void **ptrs) +{ + u8 **dptr = (u8 **)ptrs; + u8 *p, *q; + int d, z, z0; + + z0 = disks - 3; /* Highest data disk */ + p = dptr[z0+1]; /* XOR parity */ + q = dptr[z0+2]; /* RS syndrome */ + + kernel_fpu_begin(); + + asm volatile("movq %0,%%mm0" : : "m" (raid6_mmx_constants.x1d)); + asm volatile("pxor %mm5,%mm5"); /* Zero temp */ + asm volatile("pxor %mm7,%mm7"); /* Zero temp */ + + for ( d = 0 ; d < bytes ; d += 16 ) { + asm volatile("movq %0,%%mm2" : : "m" (dptr[z0][d])); /* P[0] */ + asm volatile("movq %0,%%mm3" : : "m" (dptr[z0][d+8])); + asm volatile("movq %mm2,%mm4"); /* Q[0] */ + asm volatile("movq %mm3,%mm6"); /* Q[1] */ + for ( z = z0-1 ; z >= 0 ; z-- ) { + asm volatile("pcmpgtb %mm4,%mm5"); + asm volatile("pcmpgtb %mm6,%mm7"); + asm volatile("paddb %mm4,%mm4"); + asm volatile("paddb %mm6,%mm6"); + asm volatile("pand %mm0,%mm5"); + asm volatile("pand %mm0,%mm7"); + asm volatile("pxor %mm5,%mm4"); + asm volatile("pxor %mm7,%mm6"); + asm volatile("movq %0,%%mm5" : : "m" (dptr[z][d])); + asm volatile("movq %0,%%mm7" : : "m" (dptr[z][d+8])); + asm volatile("pxor %mm5,%mm2"); + asm volatile("pxor %mm7,%mm3"); + asm volatile("pxor %mm5,%mm4"); + asm volatile("pxor %mm7,%mm6"); + asm volatile("pxor %mm5,%mm5"); + asm volatile("pxor %mm7,%mm7"); + } + asm volatile("movq %%mm2,%0" : "=m" (p[d])); + asm volatile("movq %%mm3,%0" : "=m" (p[d+8])); + asm volatile("movq %%mm4,%0" : "=m" (q[d])); + asm volatile("movq %%mm6,%0" : "=m" (q[d+8])); + } + + kernel_fpu_end(); +} + +const struct raid6_calls raid6_mmxx2 = { + raid6_mmx2_gen_syndrome, + raid6_have_mmx, + "mmxx2", + 0 +}; + +#endif -- cgit v1.2.3 From a8e026c785b3fecef0ef5c00c15223542c4db8f5 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 12 Aug 2010 06:44:54 +1000 Subject: Further tidyup of raid6 naming in lib/raid6 Rename raid6/raid6x86.h to raid6/x86.h and modify some comments. Signed-off-by: NeilBrown --- lib/raid6/algos.c | 2 +- lib/raid6/mmx.c | 6 +++--- lib/raid6/raid6x86.h | 61 ---------------------------------------------------- lib/raid6/recov.c | 2 +- lib/raid6/sse1.c | 6 +++--- lib/raid6/sse2.c | 4 ++-- lib/raid6/x86.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 lib/raid6/raid6x86.h create mode 100644 lib/raid6/x86.h (limited to 'lib/raid6/mmx.c') diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index df7ff72777b8..b595f560bee7 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6algos.c + * raid6/algos.c * * Algorithm list and algorithm selection for RAID-6 */ diff --git a/lib/raid6/mmx.c b/lib/raid6/mmx.c index e7f6c13132bf..279347f23094 100644 --- a/lib/raid6/mmx.c +++ b/lib/raid6/mmx.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6mmx.c + * raid6/mmx.c * * MMX implementation of RAID-6 syndrome functions */ @@ -19,9 +19,9 @@ #if defined(__i386__) && !defined(__arch_um__) #include -#include "raid6x86.h" +#include "x86.h" -/* Shared with raid6sse1.c */ +/* Shared with raid6/sse1.c */ const struct raid6_mmx_constants { u64 x1d; } raid6_mmx_constants = { diff --git a/lib/raid6/raid6x86.h b/lib/raid6/raid6x86.h deleted file mode 100644 index 4c22c1568558..000000000000 --- a/lib/raid6/raid6x86.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ----------------------------------------------------------------------- * - * - * Copyright 2002-2004 H. Peter Anvin - All Rights Reserved - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, Inc., 53 Temple Place Ste 330, - * Boston MA 02111-1307, USA; either version 2 of the License, or - * (at your option) any later version; incorporated herein by reference. - * - * ----------------------------------------------------------------------- */ - -/* - * raid6x86.h - * - * Definitions common to x86 and x86-64 RAID-6 code only - */ - -#ifndef LINUX_RAID_RAID6X86_H -#define LINUX_RAID_RAID6X86_H - -#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) - -#ifdef __KERNEL__ /* Real code */ - -#include - -#else /* Dummy code for user space testing */ - -static inline void kernel_fpu_begin(void) -{ -} - -static inline void kernel_fpu_end(void) -{ -} - -#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */ -#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions - * (fast save and restore) */ -#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */ -#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */ -#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */ - -/* Should work well enough on modern CPUs for testing */ -static inline int boot_cpu_has(int flag) -{ - u32 eax = (flag >> 5) ? 0x80000001 : 1; - u32 edx; - - asm volatile("cpuid" - : "+a" (eax), "=d" (edx) - : : "ecx", "ebx"); - - return (edx >> (flag & 31)) & 1; -} - -#endif /* ndef __KERNEL__ */ - -#endif -#endif diff --git a/lib/raid6/recov.c b/lib/raid6/recov.c index 2609f00e0d61..8590d19cf522 100644 --- a/lib/raid6/recov.c +++ b/lib/raid6/recov.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6recov.c + * raid6/recov.c * * RAID-6 data recovery in dual failure mode. In single failure mode, * use the RAID-5 algorithm (or, in the case of Q failure, just reconstruct diff --git a/lib/raid6/sse1.c b/lib/raid6/sse1.c index b274dd5eab8f..10dd91948c07 100644 --- a/lib/raid6/sse1.c +++ b/lib/raid6/sse1.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6sse1.c + * raid6/sse1.c * * SSE-1/MMXEXT implementation of RAID-6 syndrome functions * @@ -24,9 +24,9 @@ #if defined(__i386__) && !defined(__arch_um__) #include -#include "raid6x86.h" +#include "x86.h" -/* Defined in raid6mmx.c */ +/* Defined in raid6/mmx.c */ extern const struct raid6_mmx_constants { u64 x1d; } raid6_mmx_constants; diff --git a/lib/raid6/sse2.c b/lib/raid6/sse2.c index 6ed6c6c0389f..bc2d57daa589 100644 --- a/lib/raid6/sse2.c +++ b/lib/raid6/sse2.c @@ -11,7 +11,7 @@ * ----------------------------------------------------------------------- */ /* - * raid6sse2.c + * raid6/sse2.c * * SSE-2 implementation of RAID-6 syndrome functions * @@ -20,7 +20,7 @@ #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) #include -#include "raid6x86.h" +#include "x86.h" static const struct raid6_sse_constants { u64 x1d[2]; diff --git a/lib/raid6/x86.h b/lib/raid6/x86.h new file mode 100644 index 000000000000..cb2a8c91c886 --- /dev/null +++ b/lib/raid6/x86.h @@ -0,0 +1,61 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2002-2004 H. Peter Anvin - All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, Inc., 53 Temple Place Ste 330, + * Boston MA 02111-1307, USA; either version 2 of the License, or + * (at your option) any later version; incorporated herein by reference. + * + * ----------------------------------------------------------------------- */ + +/* + * raid6/x86.h + * + * Definitions common to x86 and x86-64 RAID-6 code only + */ + +#ifndef LINUX_RAID_RAID6X86_H +#define LINUX_RAID_RAID6X86_H + +#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) + +#ifdef __KERNEL__ /* Real code */ + +#include + +#else /* Dummy code for user space testing */ + +static inline void kernel_fpu_begin(void) +{ +} + +static inline void kernel_fpu_end(void) +{ +} + +#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */ +#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions + * (fast save and restore) */ +#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */ +#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */ +#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */ + +/* Should work well enough on modern CPUs for testing */ +static inline int boot_cpu_has(int flag) +{ + u32 eax = (flag >> 5) ? 0x80000001 : 1; + u32 edx; + + asm volatile("cpuid" + : "+a" (eax), "=d" (edx) + : : "ecx", "ebx"); + + return (edx >> (flag & 31)) & 1; +} + +#endif /* ndef __KERNEL__ */ + +#endif +#endif -- cgit v1.2.3