Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] RAID6 Altivec fix

This patch fixes a signedness bug with RAID6 for Altivec, and makes the
Altivec code testable in userspace.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

H. Peter Anvin and committed by
Linus Torvalds
d7e70ba4 0d0fc3a2

+40 -10
+4
drivers/md/raid6.h
··· 69 69 #define __init 70 70 #define __exit 71 71 #define __attribute_const__ __attribute__((const)) 72 + #define noinline __attribute__((noinline)) 72 73 73 74 #define preempt_enable() 74 75 #define preempt_disable() 76 + #define cpu_has_feature(x) 1 77 + #define enable_kernel_altivec() 78 + #define disable_kernel_altivec() 75 79 76 80 #endif /* __KERNEL__ */ 77 81
+1
drivers/md/raid6algos.c
··· 19 19 #include "raid6.h" 20 20 #ifndef __KERNEL__ 21 21 #include <sys/mman.h> 22 + #include <stdio.h> 22 23 #endif 23 24 24 25 struct raid6_calls raid6_call;
+13 -5
drivers/md/raid6altivec.uc
··· 27 27 #ifdef CONFIG_ALTIVEC 28 28 29 29 #include <altivec.h> 30 - #include <asm/system.h> 31 - #include <asm/cputable.h> 30 + #ifdef __KERNEL__ 31 + # include <asm/system.h> 32 + # include <asm/cputable.h> 33 + #endif 32 34 33 35 /* 34 - * This is the C data type to use 36 + * This is the C data type to use. We use a vector of 37 + * signed char so vec_cmpgt() will generate the right 38 + * instruction. 35 39 */ 36 40 37 - typedef vector unsigned char unative_t; 41 + typedef vector signed char unative_t; 38 42 39 - #define NBYTES(x) ((vector unsigned char) {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}) 43 + #define NBYTES(x) ((vector signed char) {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}) 40 44 #define NSIZE sizeof(unative_t) 41 45 42 46 /* ··· 112 108 int raid6_have_altivec(void) 113 109 { 114 110 /* This assumes either all CPUs have Altivec or none does */ 111 + # ifdef __KERNEL__ 115 112 return cpu_has_feature(CPU_FTR_ALTIVEC); 113 + # else 114 + return 1; 115 + # endif 116 116 } 117 117 #endif 118 118
+22 -5
drivers/md/raid6test/Makefile
··· 8 8 CFLAGS = -I.. -g $(OPTFLAGS) 9 9 LD = ld 10 10 PERL = perl 11 + AR = ar 12 + RANLIB = ranlib 11 13 12 14 .c.o: 13 15 $(CC) $(CFLAGS) -c -o $@ $< ··· 20 18 %.uc: ../%.uc 21 19 cp -f $< $@ 22 20 23 - all: raid6.o raid6test 21 + all: raid6.a raid6test 24 22 25 - raid6.o: raid6int1.o raid6int2.o raid6int4.o raid6int8.o raid6int16.o \ 23 + raid6.a: raid6int1.o raid6int2.o raid6int4.o raid6int8.o raid6int16.o \ 26 24 raid6int32.o \ 27 25 raid6mmx.o raid6sse1.o raid6sse2.o \ 26 + raid6altivec1.o raid6altivec2.o raid6altivec4.o raid6altivec8.o \ 28 27 raid6recov.o raid6algos.o \ 29 28 raid6tables.o 30 - $(LD) -r -o $@ $^ 29 + rm -f $@ 30 + $(AR) cq $@ $^ 31 + $(RANLIB) $@ 31 32 32 - raid6test: raid6.o test.c 33 + raid6test: test.c raid6.a 33 34 $(CC) $(CFLAGS) -o raid6test $^ 35 + 36 + raid6altivec1.c: raid6altivec.uc ../unroll.pl 37 + $(PERL) ../unroll.pl 1 < raid6altivec.uc > $@ 38 + 39 + raid6altivec2.c: raid6altivec.uc ../unroll.pl 40 + $(PERL) ../unroll.pl 2 < raid6altivec.uc > $@ 41 + 42 + raid6altivec4.c: raid6altivec.uc ../unroll.pl 43 + $(PERL) ../unroll.pl 4 < raid6altivec.uc > $@ 44 + 45 + raid6altivec8.c: raid6altivec.uc ../unroll.pl 46 + $(PERL) ../unroll.pl 8 < raid6altivec.uc > $@ 34 47 35 48 raid6int1.c: raid6int.uc ../unroll.pl 36 49 $(PERL) ../unroll.pl 1 < raid6int.uc > $@ ··· 69 52 ./mktables > raid6tables.c 70 53 71 54 clean: 72 - rm -f *.o mktables mktables.c raid6int.uc raid6*.c raid6test 55 + rm -f *.o *.a mktables mktables.c raid6int.uc raid6*.c raid6test 73 56 74 57 spotless: clean 75 58 rm -f *~