Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1398779 > unrolled thread
| Started by | zengzhaoxiu@163.com |
|---|---|
| First post | 2016-05-11 10:30 +0200 |
| Last post | 2016-05-11 11:30 +0200 |
| Articles | 20 on this page of 47 — 11 participants |
Back to article view | Back to linux.kernel
[patch V4 00/31] bitops: add parity functions zengzhaoxiu@163.com - 2016-05-11 10:30 +0200
[patch V4 01/31] bitops: add parity functions zengzhaoxiu@163.com - 2016-05-11 11:10 +0200
Re: [patch V4 01/31] bitops: add parity functions Martin Kepplinger <martink@posteo.de> - 2016-05-11 16:40 +0200
[patch V4 02/31] bitops: Include generic parity.h in some architectures' bitops.h zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
Re: [patch V4 02/31] bitops: Include generic parity.h in some architectures' bitops.h Jesper Nilsson <jesper.nilsson@axis.com> - 2016-05-11 12:10 +0200
Re: [patch V4 02/31] bitops: Include generic parity.h in some architectures' bitops.h Catalin Marinas <catalin.marinas@arm.com> - 2016-05-11 12:50 +0200
Re: [patch V4 02/31] bitops: Include generic parity.h in some architectures' bitops.h Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-05-11 16:00 +0200
Re: [patch V4 02/31] bitops: Include generic parity.h in some architectures' bitops.h Mark Salter <msalter@redhat.com> - 2016-05-11 17:30 +0200
[patch V4 09/31] bitops: Add x86-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
Re: [patch V4 09/31] bitops: Add x86-specific parity functions Peter Zijlstra <peterz@infradead.org> - 2016-05-11 11:40 +0200
Re: [patch V4 09/31] bitops: Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-05-11 12:00 +0200
Re: [patch V4 09/31] bitops: Add x86-specific parity functions Zhaoxiu Zeng <zengzhaoxiu@163.com> - 2016-05-16 18:00 +0200
Re: [patch V4 09/31] bitops: Add x86-specific parity functions Peter Zijlstra <peterz@infradead.org> - 2016-05-16 19:10 +0200
Re: [patch V4 09/31] bitops: Add x86-specific parity functions "H. Peter Anvin" <hpa@zytor.com> - 2016-05-16 21:30 +0200
Re: [patch V4 09/31] bitops: Add x86-specific parity functions Peter Zijlstra <peterz@infradead.org> - 2016-05-17 13:30 +0200
Re: [patch V4 09/31] bitops: Add x86-specific parity functions "H. Peter Anvin" <hpa@zytor.com> - 2016-05-16 21:30 +0200
[patch V4 06/31] bitops: Tile and MIPS (if has usable __builtin_popcount) use popcount parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 12/31] lib: bch: use parity32 zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 03/31] bitops: Add alpha-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 05/31] bitops: Add ia-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 11/31] mips: use parity functions in cerr-sb1.c zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 08/31] bitops: Add sparc-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
Re: [patch V4 08/31] bitops: Add sparc-specific parity functions David Miller <davem@davemloft.net> - 2016-05-12 02:00 +0200
[patch V4 10/31] sunrpc: use parity8 zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 07/31] bitops: Add powerpc-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 04/31] bitops: Add blackfin-specific parity functions zengzhaoxiu@163.com - 2016-05-11 11:20 +0200
[patch V4 28/31] input: use parity8 in elantech zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 19/31] mtd: use parity16 in ssfdc zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 23/31] ethernet: use parity8 in sun/niu.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
Re: [patch V4 23/31] ethernet: use parity8 in sun/niu.c David Miller <davem@davemloft.net> - 2016-05-12 02:10 +0200
[patch V4 20/31] mtd: use parity functions in inftlcore zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 14/31] media: use parity functions in saa7115 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 31/31] edac: use parity8 in amd64_edac.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 29/31] ethernet: use parity8 in broadcom/tg3.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
Re: [patch V4 29/31] ethernet: use parity8 in broadcom/tg3.c David Miller <davem@davemloft.net> - 2016-05-12 02:00 +0200
[patch V4 18/31] scsi: use parity32 in isci's phy zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 21/31] crypto: use parity functions in qat_hal zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 15/31] input: use parity32 in grip_mp zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 30/31] crypto: use parity_long is sahara.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 22/31] mtd: use parity16 in sm_ftl zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 25/31] input: use parity8 in sa1111ps2 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 16/31] input: use parity64 in sidewinder zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 27/31] serial: use parity32 in max3100 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 24/31] input: use parity8 in pcips2 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 26/31] iio: use parity32 in adxrs450 zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 17/31] input: use parity16 in ams_delta_serio zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
[patch V4 13/31] media: use parity8 in vivid-vbi-gen.c zengzhaoxiu@163.com - 2016-05-11 11:30 +0200
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:20 +0200 |
| Subject | [patch V4 11/31] mips: use parity functions in cerr-sb1.c |
| Message-ID | <rxytc-5fG-19@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
arch/mips/mm/cerr-sb1.c | 67 +++++++++++++------------------------------------
1 file changed, 17 insertions(+), 50 deletions(-)
diff --git a/arch/mips/mm/cerr-sb1.c b/arch/mips/mm/cerr-sb1.c
index ee5c1ff..2e7d660 100644
--- a/arch/mips/mm/cerr-sb1.c
+++ b/arch/mips/mm/cerr-sb1.c
@@ -264,27 +264,6 @@ asmlinkage void sb1_cache_error(void)
#endif
}
-
-/* Parity lookup table. */
-static const uint8_t parity[256] = {
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
- 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0
-};
-
/* Masks to select bits for Hamming parity, mask_72_64[i] for bit[i] */
static const uint64_t mask_72_64[8] = {
0x0738C808099264FFULL,
@@ -298,34 +277,28 @@ static const uint64_t mask_72_64[8] = {
};
/* Calculate the parity on a range of bits */
-static char range_parity(uint64_t dword, int max, int min)
+static inline char range_parity(uint64_t dword, int max, int min)
{
- char parity = 0;
- int i;
- dword >>= min;
- for (i=max-min; i>=0; i--) {
- if (dword & 0x1)
- parity = !parity;
- dword >>= 1;
+ int n = max - min + 1;
+ if (__builtin_constant_p(n)) {
+ if (n <= 8)
+ return parity8((unsigned int)(dword >> min) & ((1U << n) - 1));
+ if (n <= 16)
+ return parity16((unsigned int)(dword >> min) & ((1U << n) - 1));
+ if (n <= 32)
+ return parity32((unsigned int)(dword >> min) & ((1U << n) - 1));
}
- return parity;
+ return parity64((dword >> min) & ((1ULL << n) - 1));
}
/* Calculate the 4-bit even byte-parity for an instruction */
-static unsigned char inst_parity(uint32_t word)
+static inline unsigned char inst_parity(uint32_t word)
{
- int i, j;
- char parity = 0;
- for (j=0; j<4; j++) {
- char byte_parity = 0;
- for (i=0; i<8; i++) {
- if (word & 0x80000000)
- byte_parity = !byte_parity;
- word <<= 1;
- }
- parity <<= 1;
- parity |= byte_parity;
- }
+ char parity;
+ parity = parity8(word >> 24) << 3;
+ parity |= parity8(word >> 16) << 2;
+ parity |= parity8(word >> 8) << 1;
+ parity |= parity8(word);
return parity;
}
@@ -436,7 +409,6 @@ static uint32_t extract_ic(unsigned short addr, int data)
static uint8_t dc_ecc(uint64_t dword)
{
uint64_t t;
- uint32_t w;
uint8_t p;
int i;
@@ -445,12 +417,7 @@ static uint8_t dc_ecc(uint64_t dword)
{
p <<= 1;
t = dword & mask_72_64[i];
- w = (uint32_t)(t >> 32);
- p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF]
- ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]);
- w = (uint32_t)(t & 0xFFFFFFFF);
- p ^= (parity[w>>24] ^ parity[(w>>16) & 0xFF]
- ^ parity[(w>>8) & 0xFF] ^ parity[w & 0xFF]);
+ p |= parity64(t);
}
return p;
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:20 +0200 |
| Subject | [patch V4 08/31] bitops: Add sparc-specific parity functions |
| Message-ID | <rxytc-5fG-27@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Use runtime patching for sparc64, lifted from hweight
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
arch/sparc/include/asm/bitops_32.h | 1 +
arch/sparc/include/asm/bitops_64.h | 18 ++++++
arch/sparc/kernel/sparc_ksyms_64.c | 6 ++
arch/sparc/lib/Makefile | 2 +-
arch/sparc/lib/parity.S | 129 +++++++++++++++++++++++++++++++++++++
5 files changed, 155 insertions(+), 1 deletion(-)
create mode 100644 arch/sparc/lib/parity.S
diff --git a/arch/sparc/include/asm/bitops_32.h b/arch/sparc/include/asm/bitops_32.h
index 600ed1d..8c41896 100644
--- a/arch/sparc/include/asm/bitops_32.h
+++ b/arch/sparc/include/asm/bitops_32.h
@@ -98,6 +98,7 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/hweight.h>
+#include <asm-generic/bitops/parity.h>
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/le.h>
diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h
index 2d52240..999d504 100644
--- a/arch/sparc/include/asm/bitops_64.h
+++ b/arch/sparc/include/asm/bitops_64.h
@@ -47,6 +47,24 @@ unsigned int __arch_hweight16(unsigned int w);
unsigned int __arch_hweight8(unsigned int w);
#include <asm-generic/bitops/const_hweight.h>
+
+/*
+ * parityN: returns the parity of a N-bit word,
+ * i.e. the number of 1-bits in w modulo 2.
+ */
+
+static inline unsigned int __arch_parity4(unsigned int w)
+{
+ w &= 0xf;
+ return ((PARITY_MAGIC) >> w) & 1;
+}
+unsigned int __arch_parity8(unsigned int w);
+unsigned int __arch_parity16(unsigned int w);
+unsigned int __arch_parity32(unsigned int w);
+unsigned int __arch_parity64(__u64 w);
+
+#include <asm-generic/bitops/const_parity.h>
+
#include <asm-generic/bitops/lock.h>
#endif /* __KERNEL__ */
diff --git a/arch/sparc/kernel/sparc_ksyms_64.c b/arch/sparc/kernel/sparc_ksyms_64.c
index 9e034f2..7ee0818 100644
--- a/arch/sparc/kernel/sparc_ksyms_64.c
+++ b/arch/sparc/kernel/sparc_ksyms_64.c
@@ -45,6 +45,12 @@ EXPORT_SYMBOL(__arch_hweight16);
EXPORT_SYMBOL(__arch_hweight32);
EXPORT_SYMBOL(__arch_hweight64);
+/* from parity.S */
+EXPORT_SYMBOL(__arch_parity8);
+EXPORT_SYMBOL(__arch_parity16);
+EXPORT_SYMBOL(__arch_parity32);
+EXPORT_SYMBOL(__arch_parity64);
+
/* from ffs_ffz.S */
EXPORT_SYMBOL(ffs);
EXPORT_SYMBOL(__ffs);
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index 3269b02..2dbbcb1 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -39,7 +39,7 @@ lib-$(CONFIG_SPARC64) += GENmemcpy.o GENcopy_from_user.o GENcopy_to_user.o
lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o
lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o
-lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
+lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o parity.o
obj-$(CONFIG_SPARC64) += iomap.o
obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o
diff --git a/arch/sparc/lib/parity.S b/arch/sparc/lib/parity.S
new file mode 100644
index 0000000..ddfba96
--- /dev/null
+++ b/arch/sparc/lib/parity.S
@@ -0,0 +1,129 @@
+/*
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <linux/linkage.h>
+
+/*
+ * This file contains the generic code to calculate the parity
+ * of N-bits number, and the popc-patches.
+ */
+
+ .text
+ .align 32
+
+#define PARITY_MAGIC 0x6996
+
+/*
+ * unsigned int __arch_parity8(unsigned int w)
+ */
+ENTRY(__arch_parity8)
+ srl %o0, 4, %g1
+ xor %o0, %g1, %o0
+ and %o0, 0xf, %o0
+ sethi %hi(PARITY_MAGIC), %g1
+ or %g1, %lo(PARITY_MAGIC), %g1
+ srl %g1, %o0, %o0
+ retl
+ and %o0, 1, %o0
+ENDPROC(__arch_parity8)
+ .section .popc_6insn_patch, "ax"
+ .word __arch_parity8
+ sllx %o0, 64-8, %g1
+ popc %g1, %o0
+ retl
+ and %o0, 1, %o0
+ nop
+ nop
+ .previous
+
+/*
+ * unsigned int __arch_parity16(unsigned int w)
+ */
+ENTRY(__arch_parity16)
+ srl %o0, 8, %g1
+ xor %o0, %g1, %o0
+ srl %o0, 4, %g1
+ xor %o0, %g1, %o0
+ and %o0, 0xf, %o0
+ sethi %hi(PARITY_MAGIC), %g1
+ or %g1, %lo(PARITY_MAGIC), %g1
+ srl %g1, %o0, %o0
+ retl
+ and %o0, 1, %o0
+ENDPROC(__arch_parity16)
+ .section .popc_6insn_patch, "ax"
+ .word __arch_parity16
+ sllx %o0, 64-16, %g1
+ popc %g1, %o0
+ retl
+ and %o0, 1, %o0
+ nop
+ nop
+ .previous
+
+/*
+ * unsigned int __arch_parity32(unsigned int w)
+ */
+ENTRY(__arch_parity32)
+ srl %o0, 16, %g1
+ xor %o0, %g1, %o0
+ srl %o0, 8, %g1
+ xor %o0, %g1, %o0
+ srl %o0, 4, %g1
+ xor %o0, %g1, %o0
+ and %o0, 0xf, %o0
+ sethi %hi(PARITY_MAGIC), %g1
+ or %g1, %lo(PARITY_MAGIC), %g1
+ srl %g1, %o0, %o0
+ retl
+ and %o0, 1, %o0
+ENDPROC(__arch_parity32)
+ .section .popc_6insn_patch, "ax"
+ .word __arch_parity32
+ sllx %o0, 64-32, %g1
+ popc %g1, %o0
+ retl
+ and %o0, 1, %o0
+ nop
+ nop
+ .previous
+
+/*
+ * unsigned int __arch_parity64(__u64 w)
+ */
+ENTRY(__arch_parity64)
+ srlx %o0, 32, %g1
+ xor %o0, %g1, %o0
+ srl %o0, 16, %g1
+ xor %o0, %g1, %o0
+ srl %o0, 8, %g1
+ xor %o0, %g1, %o0
+ srl %o0, 4, %g1
+ xor %o0, %g1, %o0
+ and %o0, 0xf, %o0
+ sethi %hi(PARITY_MAGIC), %g1
+ or %g1, %lo(PARITY_MAGIC), %g1
+ srl %g1, %o0, %o0
+ retl
+ and %o0, 1, %o0
+ENDPROC(__arch_parity64)
+ .section .popc_3insn_patch, "ax"
+ .word __arch_parity64
+ popc %o0, %o0
+ retl
+ and %o0, 1, %o0
+ .previous
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-05-12 02:00 +0200 |
| Subject | Re: [patch V4 08/31] bitops: Add sparc-specific parity functions |
| Message-ID | <rxMcO-1Os-5@gated-at.bofh.it> |
| In reply to | #1398822 |
From: zengzhaoxiu@163.com Date: Wed, 11 May 2016 17:13:18 +0800 > From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> > > Use runtime patching for sparc64, lifted from hweight > > Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> Acked-by: David S. Miller <davem@davemloft.net>
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:20 +0200 |
| Subject | [patch V4 10/31] sunrpc: use parity8 |
| Message-ID | <rxytd-5fG-37@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
net/sunrpc/auth_gss/gss_krb5_keys.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/net/sunrpc/auth_gss/gss_krb5_keys.c b/net/sunrpc/auth_gss/gss_krb5_keys.c
index 8701331..c41b389 100644
--- a/net/sunrpc/auth_gss/gss_krb5_keys.c
+++ b/net/sunrpc/auth_gss/gss_krb5_keys.c
@@ -243,16 +243,12 @@ err_return:
return ret;
}
-#define smask(step) ((1<<step)-1)
-#define pstep(x, step) (((x)&smask(step))^(((x)>>step)&smask(step)))
-#define parity_char(x) pstep(pstep(pstep((x), 4), 2), 1)
-
static void mit_des_fixup_key_parity(u8 key[8])
{
int i;
for (i = 0; i < 8; i++) {
key[i] &= 0xfe;
- key[i] |= 1^parity_char(key[i]);
+ key[i] |= !parity8(key[i]);
}
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:20 +0200 |
| Subject | [patch V4 07/31] bitops: Add powerpc-specific parity functions |
| Message-ID | <rxytd-5fG-49@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Use runtime patching for ppc64, lifted from hweight_64
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
arch/powerpc/include/asm/bitops.h | 11 +++
arch/powerpc/lib/Makefile | 2 +-
arch/powerpc/lib/parity_64.S | 143 ++++++++++++++++++++++++++++++++++++++
arch/powerpc/lib/ppc_ksyms.c | 5 ++
4 files changed, 160 insertions(+), 1 deletion(-)
create mode 100644 arch/powerpc/lib/parity_64.S
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 59abc62..cd34030 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -269,8 +269,19 @@ unsigned int __arch_hweight16(unsigned int w);
unsigned int __arch_hweight32(unsigned int w);
unsigned long __arch_hweight64(__u64 w);
#include <asm-generic/bitops/const_hweight.h>
+static inline unsigned int __arch_parity4(unsigned int w)
+{
+ w &= 0xf;
+ return ((PARITY_MAGIC) >> w) & 1;
+}
+unsigned int __arch_parity8(unsigned int w);
+unsigned int __arch_parity16(unsigned int w);
+unsigned int __arch_parity32(unsigned int w);
+unsigned int __arch_parity64(__u64 w);
+#include <asm-generic/bitops/const_parity.h>
#else
#include <asm-generic/bitops/hweight.h>
+#include <asm-generic/bitops/parity.h>
#endif
#include <asm-generic/bitops/find.h>
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index ba21be1..cae2e7f 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -16,7 +16,7 @@ obj-$(CONFIG_PPC32) += div64.o copy_32.o
obj64-y += copypage_64.o copyuser_64.o usercopy_64.o mem_64.o hweight_64.o \
copyuser_power7.o string_64.o copypage_power7.o memcpy_power7.o \
- memcpy_64.o memcmp_64.o
+ memcpy_64.o memcmp_64.o parity_64.o
obj64-$(CONFIG_SMP) += locks.o
obj64-$(CONFIG_ALTIVEC) += vmx-helper.o
diff --git a/arch/powerpc/lib/parity_64.S b/arch/powerpc/lib/parity_64.S
new file mode 100644
index 0000000..3586a39
--- /dev/null
+++ b/arch/powerpc/lib/parity_64.S
@@ -0,0 +1,143 @@
+/*
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <asm/processor.h>
+#include <asm/ppc_asm.h>
+
+/*
+ * This file contains the generic code to calculate the parity
+ * of N-bits number, and the POPCNT feature sections.
+ *
+ * Note: This code relies on -mminimal-toc
+ */
+
+#define PARITY_MAGIC 0x6996
+
+/*
+ * unsigned int __arch_parity8(unsigned int w)
+ */
+_GLOBAL(__arch_parity8)
+BEGIN_FTR_SECTION
+ srdi r4,r3,4
+ xor r3,r3,r4
+ clrldi r3,r3,64-4
+ li r4,PARITY_MAGIC
+ srd r3,r4,r3
+ clrldi r3,r3,64-1
+ blr
+FTR_SECTION_ELSE
+ PPC_POPCNTB(R3,R3)
+ clrldi r3,r3,64-1
+ blr
+ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
+
+/*
+ * unsigned int __arch_parity16(unsigned int w)
+ */
+_GLOBAL(__arch_parity16)
+BEGIN_FTR_SECTION
+ srdi r4,r3,8
+ xor r3,r3,r4
+ srdi r4,r3,4
+ xor r3,r3,r4
+ clrldi r3,r3,64-4
+ li r4,PARITY_MAGIC
+ srd r3,r4,r3
+ clrldi r3,r3,64-1
+ blr
+FTR_SECTION_ELSE
+ BEGIN_FTR_SECTION_NESTED(50)
+ PPC_POPCNTB(R3,R3)
+ srdi r4,r3,8
+ add r3,r4,r3
+ clrldi r3,r3,64-1
+ blr
+ FTR_SECTION_ELSE_NESTED(50)
+ clrlwi r3,r3,16
+ PPC_POPCNTW(R3,R3)
+ clrldi r3,r3,64-1
+ blr
+ ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 50)
+ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
+
+/*
+ * unsigned int __arch_parity32(unsigned int w)
+ */
+_GLOBAL(__arch_parity32)
+BEGIN_FTR_SECTION
+ srdi r4,r3,16
+ xor r3,r3,r4
+ srdi r4,r3,8
+ xor r3,r3,r4
+ srdi r4,r3,4
+ xor r3,r3,r4
+ clrldi r3,r3,64-4
+ li r4,PARITY_MAGIC
+ srd r3,r4,r3
+ clrldi r3,r3,64-1
+ blr
+FTR_SECTION_ELSE
+ BEGIN_FTR_SECTION_NESTED(51)
+ PPC_POPCNTB(R3,R3)
+ srdi r4,r3,16
+ add r3,r4,r3
+ srdi r4,r3,8
+ add r3,r4,r3
+ clrldi r3,r3,64-1
+ blr
+ FTR_SECTION_ELSE_NESTED(51)
+ PPC_POPCNTW(R3,R3)
+ clrldi r3,r3,64-1
+ blr
+ ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 51)
+ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
+
+/*
+ * unsigned int __arch_parity64(__u64 w)
+ */
+_GLOBAL(__arch_parity64)
+BEGIN_FTR_SECTION
+ srdi r4,r3,32
+ xor r3,r3,r4
+ srdi r4,r3,16
+ xor r3,r3,r4
+ srdi r4,r3,8
+ xor r3,r3,r4
+ srdi r4,r3,4
+ xor r3,r3,r4
+ clrldi r3,r3,64-4
+ li r4,PARITY_MAGIC
+ srd r3,r4,r3
+ clrldi r3,r3,64-1
+ blr
+FTR_SECTION_ELSE
+ BEGIN_FTR_SECTION_NESTED(52)
+ PPC_POPCNTB(R3,R3)
+ srdi r4,r3,32
+ add r3,r4,r3
+ srdi r4,r3,16
+ add r3,r4,r3
+ srdi r4,r3,8
+ add r3,r4,r3
+ clrldi r3,r3,64-1
+ blr
+ FTR_SECTION_ELSE_NESTED(52)
+ PPC_POPCNTD(R3,R3)
+ clrldi r3,r3,64-1
+ blr
+ ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_POPCNTD, 52)
+ALT_FTR_SECTION_END_IFCLR(CPU_FTR_POPCNTB)
diff --git a/arch/powerpc/lib/ppc_ksyms.c b/arch/powerpc/lib/ppc_ksyms.c
index c422812..1ccfc29 100644
--- a/arch/powerpc/lib/ppc_ksyms.c
+++ b/arch/powerpc/lib/ppc_ksyms.c
@@ -30,4 +30,9 @@ EXPORT_SYMBOL(__arch_hweight8);
EXPORT_SYMBOL(__arch_hweight16);
EXPORT_SYMBOL(__arch_hweight32);
EXPORT_SYMBOL(__arch_hweight64);
+
+EXPORT_SYMBOL(__arch_parity8);
+EXPORT_SYMBOL(__arch_parity16);
+EXPORT_SYMBOL(__arch_parity32);
+EXPORT_SYMBOL(__arch_parity64);
#endif
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:20 +0200 |
| Subject | [patch V4 04/31] bitops: Add blackfin-specific parity functions |
| Message-ID | <rxytd-5fG-47@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
arch/blackfin/include/asm/bitops.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h
index b298b65..6609b7e 100644
--- a/arch/blackfin/include/asm/bitops.h
+++ b/arch/blackfin/include/asm/bitops.h
@@ -23,6 +23,7 @@
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/ffs.h>
#include <asm-generic/bitops/const_hweight.h>
+#include <asm-generic/bitops/const_parity.h>
#include <asm-generic/bitops/lock.h>
#include <asm-generic/bitops/ext2-atomic.h>
@@ -137,4 +138,34 @@ static inline unsigned int __arch_hweight8(unsigned int w)
return __arch_hweight32(w & 0xff);
}
+/*
+ * parityN: returns the parity of a N-bit word,
+ * i.e. the number of 1-bits in w modulo 2.
+ */
+
+static inline unsigned int __arch_parity32(unsigned int w)
+{
+ return __arch_hweight32(w) & 1;
+}
+
+static inline unsigned int __arch_parity64(__u64 w)
+{
+ return __arch_parity32((unsigned int)(w >> 32) ^ (unsigned int)w);
+}
+
+static inline unsigned int __arch_parity16(unsigned int w)
+{
+ return __arch_parity32(w & 0xffff);
+}
+
+static inline unsigned int __arch_parity8(unsigned int w)
+{
+ return __arch_parity32(w & 0xff);
+}
+
+static inline unsigned int __arch_parity4(unsigned int w)
+{
+ return __arch_parity32(w & 0xf);
+}
+
#endif /* _BLACKFIN_BITOPS_H */
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 28/31] input: use parity8 in elantech |
| Message-ID | <rxyCR-5ns-1@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Remove the parity lookup table, use parity8 instead.
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/mouse/elantech.c | 10 +++-------
drivers/input/mouse/elantech.h | 1 -
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 78f93cf..bbb4aa6 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -693,9 +693,9 @@ static int elantech_packet_check_v1(struct psmouse *psmouse)
p3 = (packet[0] & 0x04) >> 2;
- return etd->parity[packet[1]] == p1 &&
- etd->parity[packet[2]] == p2 &&
- etd->parity[packet[3]] == p3;
+ return parity8(packet[1]) != p1 &&
+ parity8(packet[2]) != p2 &&
+ parity8(packet[3]) != p3;
}
static int elantech_debounce_check_v2(struct psmouse *psmouse)
@@ -1635,10 +1635,6 @@ int elantech_init(struct psmouse *psmouse)
psmouse_reset(psmouse);
- etd->parity[0] = 1;
- for (i = 1; i < 256; i++)
- etd->parity[i] = etd->parity[i & (i - 1)] ^ 1;
-
/*
* Do the version query again so we can store the result
*/
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index e1cbf40..542c5d9 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -141,7 +141,6 @@ struct elantech_data {
unsigned int y_max;
unsigned int width;
struct finger_pos mt[ETP_MAX_FINGERS];
- unsigned char parity[256];
int (*send_cmd)(struct psmouse *psmouse, unsigned char c, unsigned char *param);
void (*original_set_rate)(struct psmouse *psmouse, unsigned int rate);
};
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 19/31] mtd: use parity16 in ssfdc |
| Message-ID | <rxyCR-5ns-3@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Use parity16 to do the odd parity checking, and rearrange the code.
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
drivers/mtd/ssfdc.c | 31 ++++++++-----------------------
1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
index daf82ba..1d55f15 100644
--- a/drivers/mtd/ssfdc.c
+++ b/drivers/mtd/ssfdc.c
@@ -182,24 +182,10 @@ static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf)
return 0;
}
-/* Parity calculator on a word of n bit size */
-static int get_parity(int number, int size)
-{
- int k;
- int parity;
-
- parity = 1;
- for (k = 0; k < size; k++) {
- parity += (number >> k);
- parity &= 1;
- }
- return parity;
-}
-
/* Read and validate the logical block address field stored in the OOB */
static int get_logical_address(uint8_t *oob_buf)
{
- int block_address, parity;
+ int block_address;
int offset[2] = {6, 11}; /* offset of the 2 address fields within OOB */
int j;
int ok = 0;
@@ -215,18 +201,17 @@ static int get_logical_address(uint8_t *oob_buf)
/* Check for the signature bits in the address field (MSBits) */
if ((block_address & ~0x7FF) == 0x1000) {
- parity = block_address & 0x01;
block_address &= 0x7FF;
- block_address >>= 1;
- if (get_parity(block_address, 10) != parity) {
- pr_debug("SSFDC_RO: logical address field%d"
- "parity error(0x%04X)\n", j+1,
- block_address);
- } else {
- ok = 1;
+ ok = parity16(block_address);
+ if (ok) {
+ block_address >>= 1;
break;
}
+
+ pr_debug("SSFDC_RO: logical address field%d"
+ "parity error(0x%04X)\n", j+1,
+ block_address);
}
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 23/31] ethernet: use parity8 in sun/niu.c |
| Message-ID | <rxyCS-5ns-11@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
---
drivers/net/ethernet/sun/niu.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 9cc4564..8c344ef 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -2742,18 +2742,12 @@ static int niu_set_alt_mac_rdc_table(struct niu *np, int idx,
static u64 vlan_entry_set_parity(u64 reg_val)
{
- u64 port01_mask;
- u64 port23_mask;
-
- port01_mask = 0x00ff;
- port23_mask = 0xff00;
-
- if (hweight64(reg_val & port01_mask) & 1)
+ if (parity8(reg_val))
reg_val |= ENET_VLAN_TBL_PARITY0;
else
reg_val &= ~ENET_VLAN_TBL_PARITY0;
- if (hweight64(reg_val & port23_mask) & 1)
+ if (parity8((unsigned int)reg_val >> 8))
reg_val |= ENET_VLAN_TBL_PARITY1;
else
reg_val &= ~ENET_VLAN_TBL_PARITY1;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-05-12 02:10 +0200 |
| Subject | Re: [patch V4 23/31] ethernet: use parity8 in sun/niu.c |
| Message-ID | <rxMmu-2gq-3@gated-at.bofh.it> |
| In reply to | #1398833 |
From: zengzhaoxiu@163.com Date: Wed, 11 May 2016 17:22:17 +0800 > From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> > > Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> > Acked-by: Michal Nazarewicz <mina86@mina86.com> Acked-by: David S. Miller <davem@davemloft.net>
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 20/31] mtd: use parity functions in inftlcore |
| Message-ID | <rxyCS-5ns-13@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
drivers/mtd/inftlcore.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index b66b541..8c9457b 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -457,15 +457,6 @@ static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock)
return INFTL_foldchain(inftl, LongestChain, pendingblock);
}
-static int nrbits(unsigned int val, int bitcount)
-{
- int i, total = 0;
-
- for (i = 0; (i < bitcount); i++)
- total += (((0x1 << i) & val) ? 1 : 0);
- return total;
-}
-
/*
* INFTL_findwriteunit: Return the unit number into which we can write
* for this block. Make it available if it isn't already.
@@ -593,10 +584,10 @@ hitused:
if (prev_block < inftl->nb_blocks)
prev_block -= inftl->firstEUN;
- parity = (nrbits(thisVUC, 16) & 0x1) ? 0x1 : 0;
- parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0;
- parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0;
- parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0;
+ parity = parity16(thisVUC);
+ parity |= parity16(prev_block) << 1;
+ parity |= parity8(anac) << 2;
+ parity |= parity8(nacs) << 3;
oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC);
oob.u.a.prevUnitNo = cpu_to_le16(prev_block);
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 14/31] media: use parity functions in saa7115 |
| Message-ID | <rxyCS-5ns-15@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
drivers/media/i2c/saa7115.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index d2a1ce2..4c22df8 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -672,15 +672,6 @@ static const unsigned char saa7115_init_misc[] = {
0x00, 0x00
};
-static int saa711x_odd_parity(u8 c)
-{
- c ^= (c >> 4);
- c ^= (c >> 2);
- c ^= (c >> 1);
-
- return c & 1;
-}
-
static int saa711x_decode_vps(u8 *dst, u8 *p)
{
static const u8 biphase_tbl[] = {
@@ -733,7 +724,6 @@ static int saa711x_decode_wss(u8 *p)
static const int wss_bits[8] = {
0, 0, 0, 1, 0, 1, 1, 1
};
- unsigned char parity;
int wss = 0;
int i;
@@ -745,11 +735,8 @@ static int saa711x_decode_wss(u8 *p)
return -1;
wss |= b2 << i;
}
- parity = wss & 15;
- parity ^= parity >> 2;
- parity ^= parity >> 1;
- if (!(parity & 1))
+ if (!parity4(wss))
return -1;
return wss;
@@ -1235,7 +1222,7 @@ static int saa711x_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vb
vbi->type = V4L2_SLICED_TELETEXT_B;
break;
case 4:
- if (!saa711x_odd_parity(p[0]) || !saa711x_odd_parity(p[1]))
+ if (!parity8(p[0]) || !parity8(p[1]))
return 0;
vbi->type = V4L2_SLICED_CAPTION_525;
break;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 31/31] edac: use parity8 in amd64_edac.c |
| Message-ID | <rxyCS-5ns-17@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
drivers/edac/amd64_edac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index d87a475..8727ae5 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1430,7 +1430,7 @@ static u8 f1x_determine_channel(struct amd64_pvt *pvt, u64 sys_addr,
if (intlv_addr & 0x2) {
u8 shift = intlv_addr & 0x1 ? 9 : 6;
- u32 temp = hweight_long((u32) ((sys_addr >> 16) & 0x1F)) % 2;
+ u8 temp = parity8((sys_addr >> 16) & 0x1F);
return ((sys_addr >> shift) & 1) ^ temp;
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 29/31] ethernet: use parity8 in broadcom/tg3.c |
| Message-ID | <rxyCT-5ns-19@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Acked-by: Siva Reddy Kallam <siva.kallam@broadcom.com>
---
drivers/net/ethernet/broadcom/tg3.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 3010080..802a429 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -12939,11 +12939,7 @@ static int tg3_test_nvram(struct tg3 *tp)
err = -EIO;
for (i = 0; i < NVRAM_SELFBOOT_DATA_SIZE; i++) {
- u8 hw8 = hweight8(data[i]);
-
- if ((hw8 & 0x1) && parity[i])
- goto out;
- else if (!(hw8 & 0x1) && !parity[i])
+ if (parity8(data[i]) == !!parity[i])
goto out;
}
err = 0;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-05-12 02:00 +0200 |
| Subject | Re: [patch V4 29/31] ethernet: use parity8 in broadcom/tg3.c |
| Message-ID | <rxMcO-1Os-11@gated-at.bofh.it> |
| In reply to | #1398839 |
From: zengzhaoxiu@163.com Date: Wed, 11 May 2016 17:24:33 +0800 > From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> > > Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> > Acked-by: Siva Reddy Kallam <siva.kallam@broadcom.com> Acked-by: David S. Miller <davem@davemloft.net>
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 18/31] scsi: use parity32 in isci's phy |
| Message-ID | <rxyCT-5ns-21@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
drivers/scsi/isci/phy.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index cb87b2e..a06aff6 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -122,8 +122,6 @@ sci_phy_link_layer_initialization(struct isci_phy *iphy,
int phy_idx = iphy->phy_index;
struct sci_phy_cap phy_cap;
u32 phy_configuration;
- u32 parity_check = 0;
- u32 parity_count = 0;
u32 llctl, link_rate;
u32 clksm_value = 0;
u32 sp_timeouts = 0;
@@ -225,18 +223,7 @@ sci_phy_link_layer_initialization(struct isci_phy *iphy,
/* The SAS specification indicates that the phy_capabilities that
* are transmitted shall have an even parity. Calculate the parity.
*/
- parity_check = phy_cap.all;
- while (parity_check != 0) {
- if (parity_check & 0x1)
- parity_count++;
- parity_check >>= 1;
- }
-
- /* If parity indicates there are an odd number of bits set, then
- * set the parity bit to 1 in the phy capabilities.
- */
- if ((parity_count % 2) != 0)
- phy_cap.parity = 1;
+ phy_cap.parity = parity32(phy_cap.all);
writel(phy_cap.all, &llr->phy_capabilities);
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 21/31] crypto: use parity functions in qat_hal |
| Message-ID | <rxyCU-5ns-35@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
---
drivers/crypto/qat/qat_common/qat_hal.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
index 1e480f1..318558f 100644
--- a/drivers/crypto/qat/qat_common/qat_hal.c
+++ b/drivers/crypto/qat/qat_common/qat_hal.c
@@ -546,17 +546,6 @@ static void qat_hal_disable_ctx(struct icp_qat_fw_loader_handle *handle,
qat_hal_wr_ae_csr(handle, ae, CTX_ENABLES, ctx);
}
-static uint64_t qat_hal_parity_64bit(uint64_t word)
-{
- word ^= word >> 1;
- word ^= word >> 2;
- word ^= word >> 4;
- word ^= word >> 8;
- word ^= word >> 16;
- word ^= word >> 32;
- return word & 1;
-}
-
static uint64_t qat_hal_set_uword_ecc(uint64_t uword)
{
uint64_t bit0_mask = 0xff800007fffULL, bit1_mask = 0x1f801ff801fULL,
@@ -566,13 +555,13 @@ static uint64_t qat_hal_set_uword_ecc(uint64_t uword)
/* clear the ecc bits */
uword &= ~(0x7fULL << 0x2C);
- uword |= qat_hal_parity_64bit(bit0_mask & uword) << 0x2C;
- uword |= qat_hal_parity_64bit(bit1_mask & uword) << 0x2D;
- uword |= qat_hal_parity_64bit(bit2_mask & uword) << 0x2E;
- uword |= qat_hal_parity_64bit(bit3_mask & uword) << 0x2F;
- uword |= qat_hal_parity_64bit(bit4_mask & uword) << 0x30;
- uword |= qat_hal_parity_64bit(bit5_mask & uword) << 0x31;
- uword |= qat_hal_parity_64bit(bit6_mask & uword) << 0x32;
+ uword |= (uint64_t)parity64(bit0_mask & uword) << 0x2C;
+ uword |= (uint64_t)parity64(bit1_mask & uword) << 0x2D;
+ uword |= (uint64_t)parity64(bit2_mask & uword) << 0x2E;
+ uword |= (uint64_t)parity64(bit3_mask & uword) << 0x2F;
+ uword |= (uint64_t)parity64(bit4_mask & uword) << 0x30;
+ uword |= (uint64_t)parity64(bit5_mask & uword) << 0x31;
+ uword |= (uint64_t)parity64(bit6_mask & uword) << 0x32;
return uword;
}
@@ -853,15 +842,14 @@ void qat_hal_wr_umem(struct icp_qat_fw_loader_handle *handle,
uaddr |= UA_ECS;
qat_hal_wr_ae_csr(handle, ae, USTORE_ADDRESS, uaddr);
for (i = 0; i < words_num; i++) {
- unsigned int uwrd_lo, uwrd_hi, tmp;
+ unsigned int uwrd_lo, uwrd_hi;
uwrd_lo = ((data[i] & 0xfff0000) << 4) | (0x3 << 18) |
((data[i] & 0xff00) << 2) |
(0x3 << 8) | (data[i] & 0xff);
uwrd_hi = (0xf << 4) | ((data[i] & 0xf0000000) >> 28);
- uwrd_hi |= (hweight32(data[i] & 0xffff) & 0x1) << 8;
- tmp = ((data[i] >> 0x10) & 0xffff);
- uwrd_hi |= (hweight32(tmp) & 0x1) << 9;
+ uwrd_hi |= parity16(data[i]) << 8;
+ uwrd_hi |= parity16(data[i] >> 16) << 9;
qat_hal_wr_ae_csr(handle, ae, USTORE_DATA_LOWER, uwrd_lo);
qat_hal_wr_ae_csr(handle, ae, USTORE_DATA_UPPER, uwrd_hi);
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 15/31] input: use parity32 in grip_mp |
| Message-ID | <rxyCT-5ns-29@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/joystick/grip_mp.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index 573191d..3e29eb1 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -112,20 +112,6 @@ static const int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5
static int register_slot(int i, struct grip_mp *grip);
/*
- * Returns whether an odd or even number of bits are on in pkt.
- */
-
-static int bit_parity(u32 pkt)
-{
- int x = pkt ^ (pkt >> 16);
- x ^= x >> 8;
- x ^= x >> 4;
- x ^= x >> 2;
- x ^= x >> 1;
- return x & 1;
-}
-
-/*
* Poll gameport; return true if all bits set in 'onbits' are on and
* all bits set in 'offbits' are off.
*/
@@ -235,7 +221,7 @@ static int mp_io(struct gameport* gameport, int sendflags, int sendcode, u32 *pa
pkt = (pkt >> 2) | 0xf0000000;
}
- if (bit_parity(pkt) == 1)
+ if (parity32(pkt))
return IO_RESET;
/* Acknowledge packet receipt */
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 30/31] crypto: use parity_long is sahara.c |
| Message-ID | <rxyCU-5ns-39@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> --- drivers/crypto/sahara.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index c3f3d89..5c44a15 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -783,7 +783,7 @@ static u32 sahara_sha_init_hdr(struct sahara_dev *dev, if (rctx->last) hdr |= SAHARA_HDR_MDHA_PDATA; - if (hweight_long(hdr) % 2 == 0) + if (!parity_long(hdr)) hdr |= SAHARA_HDR_PARITY_BIT; return hdr; -- 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | zengzhaoxiu@163.com |
|---|---|
| Date | 2016-05-11 11:30 +0200 |
| Subject | [patch V4 22/31] mtd: use parity16 in sm_ftl |
| Message-ID | <rxyCT-5ns-31@gated-at.bofh.it> |
| In reply to | #1398779 |
From: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> --- drivers/mtd/sm_ftl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c index b096f8b..345ff1a 100644 --- a/drivers/mtd/sm_ftl.c +++ b/drivers/mtd/sm_ftl.c @@ -136,7 +136,7 @@ static int sm_get_lba(uint8_t *lba) return -2; /* check parity - endianness doesn't matter */ - if (hweight16(*(uint16_t *)lba) & 1) + if (parity16(*(uint16_t *)lba)) return -2; return (lba[1] >> 1) | ((lba[0] & 0x07) << 7); @@ -183,8 +183,7 @@ static void sm_write_lba(struct sm_oob *oob, uint16_t lba) tmp[0] = 0x10 | ((lba >> 7) & 0x07); tmp[1] = (lba << 1) & 0xFF; - if (hweight16(*(uint16_t *)tmp) & 0x01) - tmp[1] |= 1; + tmp[1] |= parity16(*(uint16_t *)tmp); oob->lba_copy1[0] = oob->lba_copy2[0] = tmp[0]; oob->lba_copy1[1] = oob->lba_copy2[1] = tmp[1]; -- 2.7.4
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | linux.kernel
csiph-web