]> git.baikalelectronics.ru Git - kernel.git/commit
Revert "powerpc/64: Fix checksum folding in csum_add()"
authorChristophe Leroy <christophe.leroy@c-s.fr>
Tue, 10 Apr 2018 06:34:37 +0000 (08:34 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 17 May 2018 14:09:04 +0000 (00:09 +1000)
commit6974e6a5b25be9d52801fe62e44925b22dec543a
tree13844598b358ba9984b251ae2e26fcd952138c2b
parent11fe9df5c87232447276e1b08e900400b9f57332
Revert "powerpc/64: Fix checksum folding in csum_add()"

This reverts commit e6e94f507638a0853ecdf01245c7c2db9934731b.

That commit was pointless, because csum_add() sums two 32 bits
values, so the sum is 0x1fffffffe at the maximum.
And then when adding upper part (1) and lower part (0xfffffffe),
the result is 0xffffffff which doesn't carry.
Any lower value will not carry either.

And behind the fact that this commit is useless, it also kills the
whole purpose of having an arch specific inline csum_add()
because the resulting code gets even worse than what is obtained
with the generic implementation of csum_add()

0000000000000240 <.csum_add>:
 240: 38 00 ff ff  li      r0,-1
 244: 7c 84 1a 14  add     r4,r4,r3
 248: 78 00 00 20  clrldi  r0,r0,32
 24c: 78 89 00 22  rldicl  r9,r4,32,32
 250: 7c 80 00 38  and     r0,r4,r0
 254: 7c 09 02 14  add     r0,r9,r0
 258: 78 09 00 22  rldicl  r9,r0,32,32
 25c: 7c 00 4a 14  add     r0,r0,r9
 260: 78 03 00 20  clrldi  r3,r0,32
 264: 4e 80 00 20  blr

In comparison, the generic implementation of csum_add() gives:

0000000000000290 <.csum_add>:
 290: 7c 63 22 14  add     r3,r3,r4
 294: 7f 83 20 40  cmplw   cr7,r3,r4
 298: 7c 10 10 26  mfocrf  r0,1
 29c: 54 00 ef fe  rlwinm  r0,r0,29,31,31
 2a0: 7c 60 1a 14  add     r3,r0,r3
 2a4: 78 63 00 20  clrldi  r3,r3,32
 2a8: 4e 80 00 20  blr

And the reverted implementation for PPC64 gives:

0000000000000240 <.csum_add>:
 240: 7c 84 1a 14  add     r4,r4,r3
 244: 78 80 00 22  rldicl  r0,r4,32,32
 248: 7c 80 22 14  add     r4,r0,r4
 24c: 78 83 00 20  clrldi  r3,r4,32
 250: 4e 80 00 20  blr

Fixes: e6e94f507638a ("powerpc/64: Fix checksum folding in csum_add()")
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Acked-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/checksum.h