* [PATCH 01/23] scripts: import Linux Kconfig.include
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 02/23] sandbox: define CONFIG_64BIT as appropriate Ahmad Fatoum
` (21 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
With this include, we can have goodies like $(cc-option ...) and
$(success ...) inside our Kconfig files.
gcc-version also now becomes available. While unused for now, it can
allow us to selectively turn on warnings on new GCC versions, which
were previously disabled because of their too high false positive rate.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
scripts/Kconfig.include | 53 +++++++++++++++++++++++++++++++++++++++++
scripts/gcc-version.sh | 20 ++++++++++++++++
2 files changed, 73 insertions(+)
create mode 100644 scripts/Kconfig.include
create mode 100755 scripts/gcc-version.sh
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
new file mode 100644
index 000000000000..496d11c92c97
--- /dev/null
+++ b/scripts/Kconfig.include
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Kconfig helper macros
+
+# Convenient variables
+comma := ,
+quote := "
+squote := '
+empty :=
+space := $(empty) $(empty)
+dollar := $
+right_paren := )
+left_paren := (
+
+# $(if-success,<command>,<then>,<else>)
+# Return <then> if <command> exits with 0, <else> otherwise.
+if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
+
+# $(success,<command>)
+# Return y if <command> exits with 0, n otherwise
+success = $(if-success,$(1),y,n)
+
+# $(failure,<command>)
+# Return n if <command> exits with 0, y otherwise
+failure = $(if-success,$(1),n,y)
+
+# $(cc-option,<flag>)
+# Return y if the compiler supports <flag>, n otherwise
+cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
+
+# $(ld-option,<flag>)
+# Return y if the linker supports <flag>, n otherwise
+ld-option = $(success,$(LD) -v $(1))
+
+# $(as-instr,<instr>)
+# Return y if the assembler supports <instr>, n otherwise
+as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -)
+
+# check if $(CC) and $(LD) exist
+$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
+$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
+
+# Fail if the linker is gold as it's not capable of linking the kernel proper
+$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
+
+# gcc version including patch level
+gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
+
+# machine bit flags
+# $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
+# $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
+cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1))
+m32-flag := $(cc-option-bit,-m32)
+m64-flag := $(cc-option-bit,-m64)
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
new file mode 100755
index 000000000000..ae353432539b
--- /dev/null
+++ b/scripts/gcc-version.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# gcc-version gcc-command
+#
+# Print the gcc version of `gcc-command' in a 5 or 6-digit form
+# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc.
+
+compiler="$*"
+
+if [ ${#compiler} -eq 0 ]; then
+ echo "Error: No compiler specified." >&2
+ printf "Usage:\n\t$0 <gcc-command>\n" >&2
+ exit 1
+fi
+
+MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
+MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
+PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
+printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 02/23] sandbox: define CONFIG_64BIT as appropriate
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 01/23] scripts: import Linux Kconfig.include Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 10:00 ` Roland Hieber
2020-05-11 7:21 ` [PATCH 03/23] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol Ahmad Fatoum
` (20 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum, Ahmad Fatoum
From: Ahmad Fatoum <ahmad@a3f.at>
All 64-bit architectures are supposed to define CONFIG_64BIT to support
the relevant 64-bit MMIO accessors. The sandbox architecture is a bit
of a special case, because barebox uses the toolchain default and
doesn't force a bitness. Add 64BIT as promptless symbol, which reflects
the pointer size of the target platform.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/Kconfig | 9 +++++++++
scripts/gcc-64bitptr.sh | 9 +++++++++
2 files changed, 18 insertions(+)
create mode 100755 scripts/gcc-64bitptr.sh
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 6ec71a99e53f..46cfe8b4b1c8 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -1,3 +1,5 @@
+source "scripts/Kconfig.include"
+
config SANDBOX
bool
select OFTREE
@@ -20,3 +22,10 @@ config SANDBOX_UNWIND
default y
select ARCH_HAS_STACK_DUMP
depends on UBSAN || KASAN
+
+config CC_IS_64BIT
+ def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
+
+config 64BIT
+ bool
+ default CC_IS_64BIT
diff --git a/scripts/gcc-64bitptr.sh b/scripts/gcc-64bitptr.sh
new file mode 100755
index 000000000000..7fb05703b813
--- /dev/null
+++ b/scripts/gcc-64bitptr.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+
+cat << "END" | $@ -x c - -c -o /dev/null
+int main(void)
+{
+ return sizeof(struct { int:-!(sizeof(void *) == 8); });
+}
+END
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 02/23] sandbox: define CONFIG_64BIT as appropriate
2020-05-11 7:21 ` [PATCH 02/23] sandbox: define CONFIG_64BIT as appropriate Ahmad Fatoum
@ 2020-05-11 10:00 ` Roland Hieber
2020-05-12 7:14 ` Ahmad Fatoum
0 siblings, 1 reply; 30+ messages in thread
From: Roland Hieber @ 2020-05-11 10:00 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Ahmad Fatoum
On Mon, May 11, 2020 at 09:21:19AM +0200, Ahmad Fatoum wrote:
> From: Ahmad Fatoum <ahmad@a3f.at>
>
> All 64-bit architectures are supposed to define CONFIG_64BIT to support
> the relevant 64-bit MMIO accessors. The sandbox architecture is a bit
> of a special case, because barebox uses the toolchain default and
> doesn't force a bitness. Add 64BIT as promptless symbol, which reflects
> the pointer size of the target platform.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Nitpick: S-o-b address is different from the author address.
Same on the next patch.
- Roland
> ---
> arch/sandbox/Kconfig | 9 +++++++++
> scripts/gcc-64bitptr.sh | 9 +++++++++
> 2 files changed, 18 insertions(+)
> create mode 100755 scripts/gcc-64bitptr.sh
>
> diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
> index 6ec71a99e53f..46cfe8b4b1c8 100644
> --- a/arch/sandbox/Kconfig
> +++ b/arch/sandbox/Kconfig
> @@ -1,3 +1,5 @@
> +source "scripts/Kconfig.include"
> +
> config SANDBOX
> bool
> select OFTREE
> @@ -20,3 +22,10 @@ config SANDBOX_UNWIND
> default y
> select ARCH_HAS_STACK_DUMP
> depends on UBSAN || KASAN
> +
> +config CC_IS_64BIT
> + def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
> +
> +config 64BIT
> + bool
> + default CC_IS_64BIT
> diff --git a/scripts/gcc-64bitptr.sh b/scripts/gcc-64bitptr.sh
> new file mode 100755
> index 000000000000..7fb05703b813
> --- /dev/null
> +++ b/scripts/gcc-64bitptr.sh
> @@ -0,0 +1,9 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +cat << "END" | $@ -x c - -c -o /dev/null
> +int main(void)
> +{
> + return sizeof(struct { int:-!(sizeof(void *) == 8); });
> +}
> +END
> --
> 2.26.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Roland Hieber, Pengutronix e.K. | r.hieber@pengutronix.de |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 02/23] sandbox: define CONFIG_64BIT as appropriate
2020-05-11 10:00 ` Roland Hieber
@ 2020-05-12 7:14 ` Ahmad Fatoum
0 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-12 7:14 UTC (permalink / raw)
To: Roland Hieber; +Cc: barebox, Ahmad Fatoum
Hi,
On 5/11/20 12:00 PM, Roland Hieber wrote:
> On Mon, May 11, 2020 at 09:21:19AM +0200, Ahmad Fatoum wrote:
>> From: Ahmad Fatoum <ahmad@a3f.at>
>>
>> All 64-bit architectures are supposed to define CONFIG_64BIT to support
>> the relevant 64-bit MMIO accessors. The sandbox architecture is a bit
>> of a special case, because barebox uses the toolchain default and
>> doesn't force a bitness. Add 64BIT as promptless symbol, which reflects
>> the pointer size of the target platform.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>
> Nitpick: S-o-b address is different from the author address.
> Same on the next patch.
Ah, missed those. I can fix this in v2.
Thanks
Ahmad
>
> - Roland
>
>> ---
>> arch/sandbox/Kconfig | 9 +++++++++
>> scripts/gcc-64bitptr.sh | 9 +++++++++
>> 2 files changed, 18 insertions(+)
>> create mode 100755 scripts/gcc-64bitptr.sh
>>
>> diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
>> index 6ec71a99e53f..46cfe8b4b1c8 100644
>> --- a/arch/sandbox/Kconfig
>> +++ b/arch/sandbox/Kconfig
>> @@ -1,3 +1,5 @@
>> +source "scripts/Kconfig.include"
>> +
>> config SANDBOX
>> bool
>> select OFTREE
>> @@ -20,3 +22,10 @@ config SANDBOX_UNWIND
>> default y
>> select ARCH_HAS_STACK_DUMP
>> depends on UBSAN || KASAN
>> +
>> +config CC_IS_64BIT
>> + def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
>> +
>> +config 64BIT
>> + bool
>> + default CC_IS_64BIT
>> diff --git a/scripts/gcc-64bitptr.sh b/scripts/gcc-64bitptr.sh
>> new file mode 100755
>> index 000000000000..7fb05703b813
>> --- /dev/null
>> +++ b/scripts/gcc-64bitptr.sh
>> @@ -0,0 +1,9 @@
>> +#!/bin/sh
>> +# SPDX-License-Identifier: GPL-2.0-only
>> +
>> +cat << "END" | $@ -x c - -c -o /dev/null
>> +int main(void)
>> +{
>> + return sizeof(struct { int:-!(sizeof(void *) == 8); });
>> +}
>> +END
>> --
>> 2.26.2
>>
>>
>> _______________________________________________
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
>>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 03/23] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 01/23] scripts: import Linux Kconfig.include Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 02/23] sandbox: define CONFIG_64BIT as appropriate Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 04/23] include: io.h: provide (in|out)_(le|be)(16|32) helpers for all archs Ahmad Fatoum
` (19 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum, Ahmad Fatoum
From: Ahmad Fatoum <ahmad@a3f.at>
Now that we have an accurate CONFIG_64BIT describing sandbox bitness,
we don't need to assume everything except __x86_64__ as 32-bit.
This assumes that sizeof(long) == sizeof(void *), which is assumed
anyway throughout the code base.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/include/asm/bitsperlong.h | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/arch/sandbox/include/asm/bitsperlong.h b/arch/sandbox/include/asm/bitsperlong.h
index 00c1fc2625b2..6dc0bb0c13b2 100644
--- a/arch/sandbox/include/asm/bitsperlong.h
+++ b/arch/sandbox/include/asm/bitsperlong.h
@@ -1,10 +1 @@
-#ifndef __ASM_BITSPERLONG_H
-#define __ASM_BITSPERLONG_H
-
-#ifdef __x86_64__
-#define BITS_PER_LONG 64
-#else
-#define BITS_PER_LONG 32
-#endif
-
-#endif /* __ASM_BITSPERLONG_H */
+#include <asm-generic/bitsperlong.h>
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 04/23] include: io.h: provide (in|out)_(le|be)(16|32) helpers for all archs
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (2 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 03/23] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-12 7:11 ` Sascha Hauer
2020-05-11 7:21 ` [PATCH 05/23] ARM: asm/io.h: fall back to asm-generic out_be32 and friends Ahmad Fatoum
` (18 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
These U-Boot style bitwise operations macros will be needed for
COMPILE_TEST-compiled drivers on platforms except for ARM. Add fallback
definitions there, based on the ARM ones.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/asm-generic/io.h | 138 +++++++++++++++++++++++++++++++++++++++
1 file changed, 138 insertions(+)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 76e6d0dc1112..84bf0064d8b8 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -424,4 +424,142 @@ static inline void iowrite64be(u64 value, volatile void __iomem *addr)
#define IOMEM(addr) ((void __force __iomem *)(addr))
#endif
+/*
+ * Clear and set bits in one shot. These macros can be used to clear and
+ * set multiple bits in a register using a single call. These macros can
+ * also be used to set a multiple-bit bit pattern using a mask, by
+ * specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#ifndef out_arch
+#define out_arch(type,endian,a,v) __raw_write##type(cpu_to_##endian(v),a)
+#endif
+
+#ifndef in_arch
+#define in_arch(type,endian,a) endian##_to_cpu(__raw_read##type(a))
+#endif
+
+#ifndef out_le64
+#define out_le64(a,v) out_arch(q,le64,a,v)
+#endif
+
+#ifndef out_le32
+#define out_le32(a,v) out_arch(l,le32,a,v)
+#endif
+
+#ifndef out_le16
+#define out_le16(a,v) out_arch(w,le16,a,v)
+#endif
+
+#ifndef in_le64
+#define in_le64(a) in_arch(q,le64,a)
+#endif
+
+#ifndef in_le32
+#define in_le32(a) in_arch(l,le32,a)
+#endif
+
+#ifndef in_le16
+#define in_le16(a) in_arch(w,le16,a)
+#endif
+
+#ifndef out_be32
+#define out_be32(a,v) out_arch(l,be32,a,v)
+#endif
+
+#ifndef out_be16
+#define out_be16(a,v) out_arch(w,be16,a,v)
+#endif
+
+#ifndef in_be32
+#define in_be32(a) in_arch(l,be32,a)
+#endif
+
+#ifndef in_be16
+#define in_be16(a) in_arch(w,be16,a)
+#endif
+
+#ifndef out_8
+#define out_8(a,v) __raw_writeb(v,a)
+#endif
+
+#ifndef in_8
+#define in_8(a) __raw_readb(a)
+#endif
+
+
+#ifndef clrbits
+#define clrbits(type, addr, clear) \
+ out_##type((addr), in_##type(addr) & ~(clear))
+#endif
+
+#ifndef setbits
+#define setbits(type, addr, set) \
+ out_##type((addr), in_##type(addr) | (set))
+#endif
+
+#define clrsetbits(type, addr, clear, set) \
+ out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
+
+#ifndef clrbits_be32
+#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
+#endif
+
+#ifndef setbits_be32
+#define setbits_be32(addr, set) setbits(be32, addr, set)
+#endif
+
+#ifndef clrsetbits_be32
+#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
+#endif
+
+#ifndef clrbits_le32
+#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
+#endif
+
+#ifndef setbits_le32
+#define setbits_le32(addr, set) setbits(le32, addr, set)
+#endif
+
+#ifndef clrsetbits_le32
+#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
+#endif
+
+#ifndef clrbits_be16
+#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
+#endif
+
+#ifndef setbits_be16
+#define setbits_be16(addr, set) setbits(be16, addr, set)
+#endif
+
+#ifndef clrsetbits_be16
+#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
+#endif
+
+#ifndef clrbits_le16
+#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
+#endif
+
+#ifndef setbits_le16
+#define setbits_le16(addr, set) setbits(le16, addr, set)
+#endif
+
+#ifndef clrsetbits_le16
+#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
+#endif
+
+#ifndef clrbits_8
+#define clrbits_8(addr, clear) clrbits(8, addr, clear)
+#endif
+
+#ifndef setbits_8
+#define setbits_8(addr, set) setbits(8, addr, set)
+#endif
+
+#ifndef clrsetbits_8
+#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+#endif
+
#endif /* __ASM_GENERIC_IO_H */
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 04/23] include: io.h: provide (in|out)_(le|be)(16|32) helpers for all archs
2020-05-11 7:21 ` [PATCH 04/23] include: io.h: provide (in|out)_(le|be)(16|32) helpers for all archs Ahmad Fatoum
@ 2020-05-12 7:11 ` Sascha Hauer
2020-05-12 7:13 ` Ahmad Fatoum
0 siblings, 1 reply; 30+ messages in thread
From: Sascha Hauer @ 2020-05-12 7:11 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Mon, May 11, 2020 at 09:21:21AM +0200, Ahmad Fatoum wrote:
> These U-Boot style bitwise operations macros will be needed for
> COMPILE_TEST-compiled drivers on platforms except for ARM. Add fallback
> definitions there, based on the ARM ones.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> include/asm-generic/io.h | 138 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 138 insertions(+)
>
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index 76e6d0dc1112..84bf0064d8b8 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -424,4 +424,142 @@ static inline void iowrite64be(u64 value, volatile void __iomem *addr)
> #define IOMEM(addr) ((void __force __iomem *)(addr))
> #endif
>
> +/*
> + * Clear and set bits in one shot. These macros can be used to clear and
> + * set multiple bits in a register using a single call. These macros can
> + * also be used to set a multiple-bit bit pattern using a mask, by
> + * specifying the mask in the 'clear' parameter and the new bit pattern
> + * in the 'set' parameter.
> + */
> +
> +#ifndef out_arch
> +#define out_arch(type,endian,a,v) __raw_write##type(cpu_to_##endian(v),a)
> +#endif
Better add these to a separate file in case we want to sync io.h with
Linux?
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 04/23] include: io.h: provide (in|out)_(le|be)(16|32) helpers for all archs
2020-05-12 7:11 ` Sascha Hauer
@ 2020-05-12 7:13 ` Ahmad Fatoum
0 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-12 7:13 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 5/12/20 9:11 AM, Sascha Hauer wrote:
> On Mon, May 11, 2020 at 09:21:21AM +0200, Ahmad Fatoum wrote:
>> These U-Boot style bitwise operations macros will be needed for
>> COMPILE_TEST-compiled drivers on platforms except for ARM. Add fallback
>> definitions there, based on the ARM ones.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>> include/asm-generic/io.h | 138 +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 138 insertions(+)
>>
>> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
>> index 76e6d0dc1112..84bf0064d8b8 100644
>> --- a/include/asm-generic/io.h
>> +++ b/include/asm-generic/io.h
>> @@ -424,4 +424,142 @@ static inline void iowrite64be(u64 value, volatile void __iomem *addr)
>> #define IOMEM(addr) ((void __force __iomem *)(addr))
>> #endif
>>
>> +/*
>> + * Clear and set bits in one shot. These macros can be used to clear and
>> + * set multiple bits in a register using a single call. These macros can
>> + * also be used to set a multiple-bit bit pattern using a mask, by
>> + * specifying the mask in the 'clear' parameter and the new bit pattern
>> + * in the 'set' parameter.
>> + */
>> +
>> +#ifndef out_arch
>> +#define out_arch(type,endian,a,v) __raw_write##type(cpu_to_##endian(v),a)
>> +#endif
>
> Better add these to a separate file in case we want to sync io.h with
> Linux?
Give me a ping when you finished looking through the series and I'll send a v2.
Cheers
>
> Sascha
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 05/23] ARM: asm/io.h: fall back to asm-generic out_be32 and friends
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (3 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 04/23] include: io.h: provide (in|out)_(le|be)(16|32) helpers for all archs Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 06/23] clocksource: arm_global_timer.c: remove unused asm/ header Ahmad Fatoum
` (17 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
With the generic implementations in place in asm-generic/io.h, we can
drop the now-duplicate ARM definitions.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/include/asm/io.h | 57 ---------------------------------------
1 file changed, 57 deletions(-)
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 56db5463410e..2d28f018524a 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -12,63 +12,6 @@ extern void memcpy_fromio(void *, const volatile void __iomem *, size_t);
extern void memcpy_toio(volatile void __iomem *, const void *, size_t);
extern void memset_io(volatile void __iomem *, int, size_t);
-/*
- * Clear and set bits in one shot. These macros can be used to clear and
- * set multiple bits in a register using a single call. These macros can
- * also be used to set a multiple-bit bit pattern using a mask, by
- * specifying the mask in the 'clear' parameter and the new bit pattern
- * in the 'set' parameter.
- */
-
-#define out_arch(type,endian,a,v) __raw_write##type(cpu_to_##endian(v),a)
-#define in_arch(type,endian,a) endian##_to_cpu(__raw_read##type(a))
-
-#define out_le64(a,v) out_arch(q,le64,a,v)
-#define out_le32(a,v) out_arch(l,le32,a,v)
-#define out_le16(a,v) out_arch(w,le16,a,v)
-
-#define in_le64(a) in_arch(q,le64,a)
-#define in_le32(a) in_arch(l,le32,a)
-#define in_le16(a) in_arch(w,le16,a)
-
-#define out_be32(a,v) out_arch(l,be32,a,v)
-#define out_be16(a,v) out_arch(w,be16,a,v)
-
-#define in_be32(a) in_arch(l,be32,a)
-#define in_be16(a) in_arch(w,be16,a)
-
-#define out_8(a,v) __raw_writeb(v,a)
-#define in_8(a) __raw_readb(a)
-
-#define clrbits(type, addr, clear) \
- out_##type((addr), in_##type(addr) & ~(clear))
-
-#define setbits(type, addr, set) \
- out_##type((addr), in_##type(addr) | (set))
-
-#define clrsetbits(type, addr, clear, set) \
- out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
-
-#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
-#define setbits_be32(addr, set) setbits(be32, addr, set)
-#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
-
-#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
-#define setbits_le32(addr, set) setbits(le32, addr, set)
-#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
-
-#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
-#define setbits_be16(addr, set) setbits(be16, addr, set)
-#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
-
-#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
-#define setbits_le16(addr, set) setbits(le16, addr, set)
-#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
-
-#define clrbits_8(addr, clear) clrbits(8, addr, clear)
-#define setbits_8(addr, set) setbits(8, addr, set)
-#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
-
static inline void *phys_to_virt(unsigned long phys)
{
return (void *)phys;
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 06/23] clocksource: arm_global_timer.c: remove unused asm/ header
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (4 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 05/23] ARM: asm/io.h: fall back to asm-generic out_be32 and friends Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 07/23] mtd: nand: orion: depend on ARM Ahmad Fatoum
` (16 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We don't use the header and dropping it allows us to compile-test the
driver under non-ARM architectures. Do so.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/clocksource/arm_global_timer.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c
index 44e3a3c762fb..78cd72d3eb45 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -20,7 +20,6 @@
#include <clock.h>
#include <linux/clk.h>
#include <io.h>
-#include <asm/system.h>
#define GT_COUNTER0 0x00
#define GT_COUNTER1 0x04
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 07/23] mtd: nand: orion: depend on ARM
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (5 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 06/23] clocksource: arm_global_timer.c: remove unused asm/ header Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 08/23] ddr: fsl: " Ahmad Fatoum
` (15 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We have inline assembly in the driver, so we can't compile-test it
unmodified on non-ARM. Indicate so in the Kconfig.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mtd/nand/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index fff9903d1d35..b81e72d6b773 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -98,7 +98,7 @@ config MTD_NAND_OMAP_ELM
config NAND_ORION
bool
prompt "Marvell Orion NAND driver"
- depends on ARCH_KIRKWOOD || COMPILE_TEST
+ depends on ARM && (ARCH_KIRKWOOD || COMPILE_TEST)
help
Support for the Orion NAND controller, present in Kirkwood SoCs.
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 08/23] ddr: fsl: depend on ARM
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (6 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 07/23] mtd: nand: orion: depend on ARM Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 09/23] net: fec_imx: depend on HAS_DMA Ahmad Fatoum
` (14 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We have inline assembly in the driver, so we can't compile-test it
unmodified on non-ARM. Indicate so in the Kconfig.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/ddr/fsl/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/ddr/fsl/Kconfig b/drivers/ddr/fsl/Kconfig
index 09920bb8632e..b12bf8f7776f 100644
--- a/drivers/ddr/fsl/Kconfig
+++ b/drivers/ddr/fsl/Kconfig
@@ -1,5 +1,6 @@
config DDR_FSL
bool "Freescale DDR support" if COMPILE_TEST
+ depends on ARM
if DDR_FSL
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 09/23] net: fec_imx: depend on HAS_DMA
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (7 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 08/23] ddr: fsl: " Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 10/23] net: macb: " Ahmad Fatoum
` (13 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The driver makes use of dma_alloc_coherent and brethren. Depend on
HAS_DMA to be sure, we don't run into link errors when compile-testing.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/net/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9bb498527557..ee8a716d9a3d 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -155,6 +155,7 @@ config DRIVER_NET_ETHOC
config DRIVER_NET_FEC_IMX
bool "i.MX FEC Ethernet driver"
depends on ARCH_HAS_FEC_IMX || COMPILE_TEST
+ depends on HAS_DMA
select PHYLIB
config DRIVER_NET_FSL_FMAN
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 10/23] net: macb: depend on HAS_DMA
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (8 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 09/23] net: fec_imx: depend on HAS_DMA Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 11/23] sandbox: implement stub physical virtual translation Ahmad Fatoum
` (12 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The driver makes use of dma_alloc_coherent and brethren. Depend on
HAS_DMA to be sure, we don't run into link errors when compile-testing.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/net/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ee8a716d9a3d..76509a52a1c7 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -181,6 +181,7 @@ config DRIVER_NET_KS8851_MLL
config DRIVER_NET_MACB
bool "macb Ethernet driver"
depends on HAS_MACB || COMPILE_TEST
+ depends on HAS_DMA
select PHYLIB
config DRIVER_NET_MICREL
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 11/23] sandbox: implement stub physical virtual translation
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (9 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 10/23] net: macb: " Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 12/23] sandbox: asm: implement stub DMA functions Ahmad Fatoum
` (11 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
For compile-testing drivers that use DMA operations under sandbox,
we want stub implementations of these. Provide them.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/include/asm/io.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index cb891df5c8c8..9fa8414e1cf6 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -5,4 +5,14 @@
#include <asm-generic/io.h>
+static inline void *phys_to_virt(unsigned long phys)
+{
+ return (void *)phys;
+}
+
+static inline unsigned long virt_to_phys(volatile void *mem)
+{
+ return (unsigned long)mem;
+}
+
#endif /* __ASM_SANDBOX_IO_H */
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 12/23] sandbox: asm: implement stub DMA functions
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (10 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 11/23] sandbox: implement stub physical virtual translation Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 13/23] sandbox: select HAS_DMA Ahmad Fatoum
` (10 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
For compile-testing drivers that use DMA operations under sandbox,
we want stub implementations of these. Provide them.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/include/asm/dma.h | 53 +++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index 459536779e0a..5e72d8e7df2d 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -8,6 +8,57 @@
#ifndef __ASM_DMA_H
#define __ASM_DMA_H
-/* empty*/
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <driver.h>
+
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+ return xmemalign(64, ALIGN(size, 64));
+}
+
+static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
+{
+ void *ret = xmemalign(4096, size);
+ if (dma_handle)
+ *dma_handle = (dma_addr_t)ret;
+
+ memset(ret, 0, size);
+
+ return ret;
+}
+
+static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+ return dma_alloc_coherent(size, dma_handle);
+}
+
+static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
+ size_t size)
+{
+ free(mem);
+}
+
+static inline dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+ enum dma_data_direction dir)
+{
+ return (dma_addr_t)ptr;
+}
+
+static inline void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+ enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+}
#endif /* __ASM_DMA_H */
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 13/23] sandbox: select HAS_DMA
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (11 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 12/23] sandbox: asm: implement stub DMA functions Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 14/23] ARM: atomic.h: move generic implementation to asm-generic Ahmad Fatoum
` (9 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
With the DMA stubs in place, we can indicate HAS_DMA in good conscience.
Do so.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 46cfe8b4b1c8..e116fe2deb0b 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -6,6 +6,7 @@ config SANDBOX
select GPIOLIB
select ARCH_HAS_UBSAN_SANITIZE_ALL
select HAVE_ARCH_KASAN
+ select HAS_DMA
default y
config ARCH_TEXT_BASE
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 14/23] ARM: atomic.h: move generic implementation to asm-generic
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (12 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 13/23] sandbox: select HAS_DMA Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 15/23] sandbox: asm: implement <asm/atomic.h> Ahmad Fatoum
` (8 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
For easier code-sharing, the UBIFS code still uses the Linux atomic
accessors. Make porting it to sandbox easier, by providing these
functions for all platforms.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/include/asm/atomic.h | 108 +---------------------------------
include/asm-generic/atomic.h | 99 +++++++++++++++++++++++++++++++
2 files changed, 102 insertions(+), 105 deletions(-)
create mode 100644 include/asm-generic/atomic.h
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 9b79506b594b..6abe62a278e9 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -1,111 +1,9 @@
-/*
- * linux/include/asm-arm/atomic.h
- *
- * Copyright (c) 1996 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Changelog:
- * 27-06-1996 RMK Created
- * 13-04-1997 RMK Made functions atomic!
- * 07-12-1997 RMK Upgraded for v2.1.
- * 26-08-1998 PJB Added #ifdef __KERNEL__
- */
+// SPDX-License-Identifier: GPL2.0
+
#ifndef __ASM_ARM_ATOMIC_H
#define __ASM_ARM_ATOMIC_H
-#ifdef CONFIG_SMP
-#error SMP not supported
-#endif
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#ifdef __KERNEL__
#include <asm/proc-armv/system.h>
+#include <asm-generic/atomic.h>
-#define atomic_read(v) ((v)->counter)
-#define atomic_set(v,i) (((v)->counter) = (i))
-
-static inline void atomic_add(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_sub(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_inc(volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += 1;
- local_irq_restore(flags);
-}
-
-static inline void atomic_dec(volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= 1;
- local_irq_restore(flags);
-}
-
-static inline int atomic_dec_and_test(volatile atomic_t *v)
-{
- unsigned long flags = 0;
- int val;
-
- local_irq_save(flags);
- val = v->counter;
- v->counter = val -= 1;
- local_irq_restore(flags);
-
- return val == 0;
-}
-
-static inline int atomic_add_negative(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
- int val;
-
- local_irq_save(flags);
- val = v->counter;
- v->counter = val += i;
- local_irq_restore(flags);
-
- return val < 0;
-}
-
-static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- *addr &= ~mask;
- local_irq_restore(flags);
-}
-
-/* Atomic operations are already serializing on ARM */
-#define smp_mb__before_atomic_dec() barrier()
-#define smp_mb__after_atomic_dec() barrier()
-#define smp_mb__before_atomic_inc() barrier()
-#define smp_mb__after_atomic_inc() barrier()
-
-#endif
#endif
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
new file mode 100644
index 000000000000..6357b66a5304
--- /dev/null
+++ b/include/asm-generic/atomic.h
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * based on linux/include/asm-arm/atomic.h
+ *
+ * Copyright (c) 1996 Russell King.
+ */
+
+#ifndef __ASM_GENERIC_ATOMIC_H
+#define __ASM_GENERIC_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i) { (i) }
+
+#define atomic_read(v) ((v)->counter)
+#define atomic_set(v,i) (((v)->counter) = (i))
+
+static inline void atomic_add(int i, volatile atomic_t *v)
+{
+ unsigned long flags = 0;
+
+ local_irq_save(flags);
+ v->counter += i;
+ local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v)
+{
+ unsigned long flags = 0;
+
+ local_irq_save(flags);
+ v->counter -= i;
+ local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v)
+{
+ unsigned long flags = 0;
+
+ local_irq_save(flags);
+ v->counter += 1;
+ local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v)
+{
+ unsigned long flags = 0;
+
+ local_irq_save(flags);
+ v->counter -= 1;
+ local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v)
+{
+ unsigned long flags = 0;
+ int val;
+
+ local_irq_save(flags);
+ val = v->counter;
+ v->counter = val -= 1;
+ local_irq_restore(flags);
+
+ return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v)
+{
+ unsigned long flags = 0;
+ int val;
+
+ local_irq_save(flags);
+ val = v->counter;
+ v->counter = val += i;
+ local_irq_restore(flags);
+
+ return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+ unsigned long flags = 0;
+
+ local_irq_save(flags);
+ *addr &= ~mask;
+ local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec() barrier()
+#define smp_mb__after_atomic_dec() barrier()
+#define smp_mb__before_atomic_inc() barrier()
+#define smp_mb__after_atomic_inc() barrier()
+
+#endif
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 15/23] sandbox: asm: implement <asm/atomic.h>
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (13 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 14/23] ARM: atomic.h: move generic implementation to asm-generic Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-12 7:26 ` Sascha Hauer
2020-05-11 7:21 ` [PATCH 16/23] sandbox: support forcing 32-bit x86 Ahmad Fatoum
` (7 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
For easier code-sharing, the UBIFS code still uses the Kernel's
atomic accessors. Provide a sandbox <asm/atomic.h> header, so we
can compile-test UBI under sandbox.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/include/asm/atomic.h | 11 +++++++++++
arch/sandbox/include/asm/system.h | 14 ++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 arch/sandbox/include/asm/atomic.h
create mode 100644 arch/sandbox/include/asm/system.h
diff --git a/arch/sandbox/include/asm/atomic.h b/arch/sandbox/include/asm/atomic.h
new file mode 100644
index 000000000000..ef1043493b8f
--- /dev/null
+++ b/arch/sandbox/include/asm/atomic.h
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2020 Ahmad Fatoum
+ */
+#ifndef __ASM_SANDBOX_ATOMIC_H
+#define __ASM_SANDBOX_ATOMIC_H
+
+#include <asm/system.h>
+#include <asm-generic/atomic.h>
+
+#endif
diff --git a/arch/sandbox/include/asm/system.h b/arch/sandbox/include/asm/system.h
new file mode 100644
index 000000000000..a9b99b07b9a6
--- /dev/null
+++ b/arch/sandbox/include/asm/system.h
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2020 Ahmad Fatoum
+ */
+#ifndef __ASM_SANDBOX_SYSTEM_H
+#define __ASM_SANDBOX_SYSTEM_H
+
+#define local_irq_enable() do { } while (0)
+#define local_irq_disable() do { } while (0)
+#define local_save_flags(x) do { (void)x; } while (0)
+#define local_irq_save(x) do { (void)x; } while (0)
+#define local_irq_restore(x) do { (void)x; } while (0)
+
+#endif
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 15/23] sandbox: asm: implement <asm/atomic.h>
2020-05-11 7:21 ` [PATCH 15/23] sandbox: asm: implement <asm/atomic.h> Ahmad Fatoum
@ 2020-05-12 7:26 ` Sascha Hauer
0 siblings, 0 replies; 30+ messages in thread
From: Sascha Hauer @ 2020-05-12 7:26 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Mon, May 11, 2020 at 09:21:32AM +0200, Ahmad Fatoum wrote:
> For easier code-sharing, the UBIFS code still uses the Kernel's
> atomic accessors. Provide a sandbox <asm/atomic.h> header, so we
> can compile-test UBI under sandbox.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> arch/sandbox/include/asm/atomic.h | 11 +++++++++++
> arch/sandbox/include/asm/system.h | 14 ++++++++++++++
> 2 files changed, 25 insertions(+)
> create mode 100644 arch/sandbox/include/asm/atomic.h
> create mode 100644 arch/sandbox/include/asm/system.h
>
> diff --git a/arch/sandbox/include/asm/atomic.h b/arch/sandbox/include/asm/atomic.h
> new file mode 100644
> index 000000000000..ef1043493b8f
> --- /dev/null
> +++ b/arch/sandbox/include/asm/atomic.h
> @@ -0,0 +1,11 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2020 Ahmad Fatoum
> + */
> +#ifndef __ASM_SANDBOX_ATOMIC_H
> +#define __ASM_SANDBOX_ATOMIC_H
> +
> +#include <asm/system.h>
> +#include <asm-generic/atomic.h>
> +
> +#endif
> diff --git a/arch/sandbox/include/asm/system.h b/arch/sandbox/include/asm/system.h
> new file mode 100644
> index 000000000000..a9b99b07b9a6
> --- /dev/null
> +++ b/arch/sandbox/include/asm/system.h
> @@ -0,0 +1,14 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2020 Ahmad Fatoum
> + */
> +#ifndef __ASM_SANDBOX_SYSTEM_H
> +#define __ASM_SANDBOX_SYSTEM_H
> +
> +#define local_irq_enable() do { } while (0)
> +#define local_irq_disable() do { } while (0)
> +#define local_save_flags(x) do { (void)x; } while (0)
> +#define local_irq_save(x) do { (void)x; } while (0)
> +#define local_irq_restore(x) do { (void)x; } while (0)
Now we have generic atomic_* functions, but they are only usable on
architectures providing local_irq_* functions, which on barebox are by
definition empty. Why not simply drop the local_irq_* functions
entirely?
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 16/23] sandbox: support forcing 32-bit x86
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (14 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 15/23] sandbox: asm: implement <asm/atomic.h> Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 17/23] usb: xhci-hcd: remove unused #include <asm/cache.h> Ahmad Fatoum
` (6 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
If gcc supports multiple architectures, barebox uses only the default
when compiling for ARCH=sandbox, this is e.g. the case with compilers
that generate borth 32- and 64-bit x86 exectuables.
There can be good reasons to force 32-bit though, e.g. to reduce memory
consumption while fuzzing or to temporarily avoid 32-to-64-bit warnings,
while running the static analyzer. Add an option for this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/Kconfig | 7 +++++++
arch/sandbox/Makefile | 12 +++++++++++-
arch/sandbox/os/Makefile | 2 +-
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index e116fe2deb0b..3f10709021a7 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -27,6 +27,13 @@ config SANDBOX_UNWIND
config CC_IS_64BIT
def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
+config CC_HAS_LINUX_I386_SUPPORT
+ def_bool $(cc-option,-m32) && $(ld-option,-m elf_i386)
+
config 64BIT
bool
+ default n if SANDBOX_LINUX_I386
default CC_IS_64BIT
+
+config SANDBOX_LINUX_I386
+ bool "32-bit x86 barebox" if CC_HAS_LINUX_I386_SUPPORT
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index c205f47ff491..34162948185a 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -56,11 +56,21 @@ ifeq ($(CONFIG_UBSAN),y)
SANITIZER_LIBS += -fsanitize=undefined
endif
-cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(BAREBOX_LDS) \
+ifeq ($(CONFIG_SANDBOX_LINUX_I386),y)
+KBUILD_CFLAGS += -m32
+KBUILD_LDFLAGS += -m elf_i386
+KBUILD_AFLAGS += -m32
+BAREBOX_LDFLAGS += -m32
+endif
+
+BAREBOX_LDFLAGS += \
+ -Wl,-T,$(BAREBOX_LDS) \
-Wl,--start-group $(BAREBOX_OBJS) -Wl,--end-group \
-lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) \
$(SANITIZER_LIBS)
+cmd_barebox__ = $(CC) -o $@ $(BAREBOX_LDFLAGS)
+
common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/
common-$(CONFIG_OFTREE) += arch/sandbox/dts/
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index 40306b5ffed8..8c294dae1bd8 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -10,7 +10,7 @@ endif
KBUILD_CPPFLAGS += -DCONFIG_MALLOC_SIZE=$(CONFIG_MALLOC_SIZE)
-KBUILD_CFLAGS := -Wall
+KBUILD_CFLAGS += -Wall
NOSTDINC_FLAGS :=
obj-y = common.o tap.o
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 17/23] usb: xhci-hcd: remove unused #include <asm/cache.h>
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (15 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 16/23] sandbox: support forcing 32-bit x86 Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 18/23] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper Ahmad Fatoum
` (5 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We don't use anything defined within, so drop it.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/usb/host/xhci.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 886cbef14c3a..1a3f7e7642bc 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -17,7 +17,6 @@
#define HOST_XHCI_H_
#include <asm/types.h>
-#include <asm/cache.h>
#include <io.h>
#include <linux/list.h>
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 18/23] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (16 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 17/23] usb: xhci-hcd: remove unused #include <asm/cache.h> Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 19/23] include: bitops: fix dead increment in fls() and ffs() Ahmad Fatoum
` (4 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Commit 3c5317e9046 ("usb: xhci-hcd: Make use of lo_hi_readq/writeq()")
had made use of lo_hi_readq/writeq() to implement xhci_read/write_64(),
like Linux does, but this was removed in commit fddd1c7c51a8
("usb: host: remove xhci driver"). Reinstate it to make code clearer.
No functional change.
[Note: Linux doesn't use any readq/writeq, but does two 32-bit access
always, even on 64-bit systems]
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/usb/host/xhci.h | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 1a3f7e7642bc..9ffbb103d562 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -18,6 +18,7 @@
#include <asm/types.h>
#include <io.h>
+#include <io-64-nonatomic-lo-hi.h>
#include <linux/list.h>
#define MAX_EP_CTX_NUM 31
@@ -1112,10 +1113,7 @@ static inline u64 xhci_readq(__le64 volatile *regs)
#if BITS_PER_LONG == 64
return readq(regs);
#else
- __u32 *ptr = (__u32 *)regs;
- u64 val_lo = readl(ptr);
- u64 val_hi = readl(ptr + 1);
- return val_lo + (val_hi << 32);
+ return lo_hi_readq(regs);
#endif
}
@@ -1124,12 +1122,7 @@ static inline void xhci_writeq(__le64 volatile *regs, const u64 val)
#if BITS_PER_LONG == 64
writeq(val, regs);
#else
- __u32 *ptr = (__u32 *)regs;
- u32 val_lo = lower_32_bits(val);
- /* FIXME */
- u32 val_hi = upper_32_bits(val);
- writel(val_lo, ptr);
- writel(val_hi, ptr + 1);
+ lo_hi_writeq(val, regs);
#endif
}
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 19/23] include: bitops: fix dead increment in fls() and ffs()
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (17 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 18/23] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-12 7:31 ` Sascha Hauer
2020-05-11 7:21 ` [PATCH 20/23] commands: tftp: drop unused variable Ahmad Fatoum
` (3 subsequent siblings)
22 siblings, 1 reply; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Static analyzers trip over this and a comment is as descriptive,
thus replace the dead code.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/asm-generic/bitops/ffs.h | 2 +-
include/asm-generic/bitops/fls.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/bitops/ffs.h b/include/asm-generic/bitops/ffs.h
index fbbb43af7dc0..afc2d7b2d19f 100644
--- a/include/asm-generic/bitops/ffs.h
+++ b/include/asm-generic/bitops/ffs.h
@@ -32,7 +32,7 @@ static inline int ffs(int x)
r += 2;
}
if (!(x & 1)) {
- x >>= 1;
+ /* x >>= 1; */
r += 1;
}
return r;
diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
index 850859bc5069..9d5d26a3bbdf 100644
--- a/include/asm-generic/bitops/fls.h
+++ b/include/asm-generic/bitops/fls.h
@@ -32,7 +32,7 @@ static inline int fls(int x)
r -= 2;
}
if (!(x & 0x80000000u)) {
- x <<= 1;
+ /* x <<= 1; */
r -= 1;
}
return r;
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 19/23] include: bitops: fix dead increment in fls() and ffs()
2020-05-11 7:21 ` [PATCH 19/23] include: bitops: fix dead increment in fls() and ffs() Ahmad Fatoum
@ 2020-05-12 7:31 ` Sascha Hauer
0 siblings, 0 replies; 30+ messages in thread
From: Sascha Hauer @ 2020-05-12 7:31 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Mon, May 11, 2020 at 09:21:36AM +0200, Ahmad Fatoum wrote:
> Static analyzers trip over this and a comment is as descriptive,
> thus replace the dead code.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> include/asm-generic/bitops/ffs.h | 2 +-
> include/asm-generic/bitops/fls.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/bitops/ffs.h b/include/asm-generic/bitops/ffs.h
> index fbbb43af7dc0..afc2d7b2d19f 100644
> --- a/include/asm-generic/bitops/ffs.h
> +++ b/include/asm-generic/bitops/ffs.h
> @@ -32,7 +32,7 @@ static inline int ffs(int x)
> r += 2;
> }
> if (!(x & 1)) {
> - x >>= 1;
> + /* x >>= 1; */
I would rather just drop the dead code.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 20/23] commands: tftp: drop unused variable
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (18 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 19/23] include: bitops: fix dead increment in fls() and ffs() Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 21/23] commands: test: drop dead assignment Ahmad Fatoum
` (2 subsequent siblings)
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The flags variables is not used. Drop it.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
commands/tftp.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/commands/tftp.c b/commands/tftp.c
index 1569819844bf..48ff00c6217c 100644
--- a/commands/tftp.c
+++ b/commands/tftp.c
@@ -20,7 +20,6 @@ static int do_tftpb(int argc, char *argv[])
{
char *source, *dest, *freep;
int opt;
- unsigned long flags;
int tftp_push = 0;
int ret;
IPaddr_t ip;
@@ -46,13 +45,10 @@ static int do_tftpb(int argc, char *argv[])
else
dest = argv[optind];
- if (tftp_push) {
+ if (tftp_push)
dest = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, dest);
- flags = O_RDONLY;
- } else {
+ else
source = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, source);
- flags = O_WRONLY | O_CREAT;
- }
if (!freep)
return -ENOMEM;
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 21/23] commands: test: drop dead assignment
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (19 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 20/23] commands: tftp: drop unused variable Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 22/23] sandbox: os: add_image: fix memory leak Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 23/23] mtd: nand: base: fix use of uninitialized struct member Ahmad Fatoum
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
last_expr is set to a different value few lines later. Drop the dead
assignment.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
commands/test.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/commands/test.c b/commands/test.c
index 505b7c56b1a4..c845cec01789 100644
--- a/commands/test.c
+++ b/commands/test.c
@@ -86,7 +86,6 @@ static int do_test(int argc, char *argv[])
if (argc < 2)
return 1;
- last_expr = 0;
left = argc - 1;
ap = argv + 1;
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 22/23] sandbox: os: add_image: fix memory leak
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (20 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 21/23] commands: test: drop dead assignment Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
2020-05-11 7:21 ` [PATCH 23/23] mtd: nand: base: fix use of uninitialized struct member Ahmad Fatoum
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
devname is strdup'd few lines later, so remove the earlier strdup.
The pointer isn't stored anywhere persistent in between.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/os/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index e67ea14138c0..382a92304020 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -236,7 +236,7 @@ static int add_image(char *str, char *devname_template, int *devname_number)
filename = devname;
snprintf(tmp, sizeof(tmp),
devname_template, (*devname_number)++);
- devname = strdup(tmp);
+ devname = tmp;
}
printf("add %s backed by file %s%s\n", devname,
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 23/23] mtd: nand: base: fix use of uninitialized struct member
2020-05-11 7:21 [PATCH 00/23] sandbox: support COMPILE_TESTing drivers Ahmad Fatoum
` (21 preceding siblings ...)
2020-05-11 7:21 ` [PATCH 22/23] sandbox: os: add_image: fix memory leak Ahmad Fatoum
@ 2020-05-11 7:21 ` Ahmad Fatoum
22 siblings, 0 replies; 30+ messages in thread
From: Ahmad Fatoum @ 2020-05-11 7:21 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
ooblen is read in nand_do_read_ops, despite never having been assigned a
value. Because ooblen is used to indicate how many bytes of oobbuf are
usable and oobbuf is NULL, use 0 as initial value.
Found on ARCH=sandbox using clang-analyzer.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mtd/nand/nand_base.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 00f0f7588434..3f4c787f49da 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1688,6 +1688,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
nand_get_device(mtd, FL_READING);
ops.len = len;
ops.datbuf = buf;
+ ops.ooblen = 0;
ops.oobbuf = NULL;
ops.mode = MTD_OPS_PLACE_OOB;
ret = nand_do_read_ops(mtd, from, &ops);
--
2.26.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 30+ messages in thread