* [U-Boot] [PATCH] arm/arm64: bitops: fix find_next_zero_bit to be compat with arm64
@ 2018-06-28 19:25 Grygorii Strashko
2018-07-20 12:36 ` [U-Boot] " Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Grygorii Strashko @ 2018-06-28 19:25 UTC (permalink / raw)
To: u-boot
Current implementation of find_next_zero_bit() is incompatible with arm64.
Hence fix it by using BITS_PER_LONG define instead of constants and
use generic ffz() implementation.
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
arch/arm/include/asm/bitops.h | 41 +++++++++++++----------------------------
1 file changed, 13 insertions(+), 28 deletions(-)
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index 2750d9b..b02c454 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -15,6 +15,8 @@
#ifndef __ASM_ARM_BITOPS_H
#define __ASM_ARM_BITOPS_H
+#include <asm-generic/bitops/__ffs.h>
+
#ifdef __KERNEL__
#include <asm/proc-armv/system.h>
@@ -108,50 +110,34 @@ static inline int __ilog2(unsigned int x)
return generic_fls(x) - 1;
}
-/*
- * ffz = Find First Zero in word. Undefined if no zero exists,
- * so code should check against ~0UL first..
- */
-static inline unsigned long ffz(unsigned long word)
-{
- int k;
-
- word = ~word;
- k = 31;
- if (word & 0x0000ffff) { k -= 16; word <<= 16; }
- if (word & 0x00ff0000) { k -= 8; word <<= 8; }
- if (word & 0x0f000000) { k -= 4; word <<= 4; }
- if (word & 0x30000000) { k -= 2; word <<= 2; }
- if (word & 0x40000000) { k -= 1; }
- return k;
-}
+#define ffz(x) __ffs(~(x))
static inline int find_next_zero_bit(void *addr, int size, int offset)
{
- unsigned long *p = ((unsigned long *)addr) + (offset >> 5);
- unsigned long result = offset & ~31UL;
+ unsigned long *p = ((unsigned long *)addr) + (offset / BITS_PER_LONG);
+ unsigned long result = offset & ~(BITS_PER_LONG - 1);
unsigned long tmp;
if (offset >= size)
return size;
size -= result;
- offset &= 31UL;
+ offset &= (BITS_PER_LONG - 1);
if (offset) {
tmp = *(p++);
- tmp |= ~0UL >> (32-offset);
- if (size < 32)
+ tmp |= ~0UL >> (BITS_PER_LONG - offset);
+ if (size < BITS_PER_LONG)
goto found_first;
if (~tmp)
goto found_middle;
- size -= 32;
- result += 32;
+ size -= BITS_PER_LONG;
+ result += BITS_PER_LONG;
}
- while (size & ~31UL) {
+ while (size & ~(BITS_PER_LONG - 1)) {
tmp = *(p++);
if (~tmp)
goto found_middle;
- result += 32;
- size -= 32;
+ result += BITS_PER_LONG;
+ size -= BITS_PER_LONG;
}
if (!size)
return result;
@@ -191,7 +177,6 @@ found_middle:
#endif /* __KERNEL__ */
#include <asm-generic/bitops/__fls.h>
-#include <asm-generic/bitops/__ffs.h>
#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/fls64.h>
--
2.10.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] arm/arm64: bitops: fix find_next_zero_bit to be compat with arm64
2018-06-28 19:25 [U-Boot] [PATCH] arm/arm64: bitops: fix find_next_zero_bit to be compat with arm64 Grygorii Strashko
@ 2018-07-20 12:36 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2018-07-20 12:36 UTC (permalink / raw)
To: u-boot
On Thu, Jun 28, 2018 at 02:25:52PM -0500, Grygorii Strashko wrote:
> Current implementation of find_next_zero_bit() is incompatible with arm64.
> Hence fix it by using BITS_PER_LONG define instead of constants and
> use generic ffz() implementation.
>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180720/1fc2b5b3/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-20 12:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 19:25 [U-Boot] [PATCH] arm/arm64: bitops: fix find_next_zero_bit to be compat with arm64 Grygorii Strashko
2018-07-20 12:36 ` [U-Boot] " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.