2023-09-20 09:45:19

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 00/16] xtensa: fix W=1 build warnings

This series fixes all xtensa W=1 build warnings that I have seen
with the exception of some in arch/xtensa/boot/. [1]

These have been through defconfig, allnoconfig, tinyconfig, allyesconfig,
allmodconfig, and many randconfig builds.

[PATCH 01/16] xtensa: FSF: define XCHAL_HAVE_DIV32
[PATCH 02/16] xtensa: fault: include <asm/traps.h>
[PATCH 03/16] xtensa: irq: include <asm/traps.h>
[PATCH 04/16] xtensa: ptrace: add prototypes to <asm/ptrace.h>
[PATCH 05/16] xtensa: processor.h: add init_arch() prototype
[PATCH 06/16] xtensa: signal: include headers for function prototypes
[PATCH 07/16] xtensa: stacktrace: include <asm/ftrace.h> for prototype
[PATCH 08/16] xtensa: traps: add <linux/cpu.h> for function prototype
[PATCH 09/16] irqchip: irq-xtensa-mx: include header for missing prototype
[PATCH 10/16] xtensa: smp: add headers for missing function prototypes
[PATCH 11/16] xtensa: hw_breakpoing: include header for missing prototype
[PATCH 12/16] xtensa: tlb: include <asm/tlb.h> for missing prototype
[PATCH 13/16] xtensa: iss/network: make functions static
[PATCH 14/16] xtensa: boot: don't add include-dirs
[PATCH 15/16] xtensa: umulsidi3: fix conditional expression
[PATCH 16/16] xtensa: boot/lib: add missing prototypes for functions

1:
arch/xtensa/boot/boot-elf/bootstrap.S:68: Warning: value 0x1a0003000 truncated to 0xa0003000

arch/xtensa/boot/Makefile | 3 +--
arch/xtensa/boot/lib/zmem.c | 4 ++++
arch/xtensa/include/asm/hw_breakpoint.h | 1 +
arch/xtensa/include/asm/processor.h | 5 +++++
arch/xtensa/include/asm/ptrace.h | 3 +++
arch/xtensa/include/asm/smp.h | 1 +
arch/xtensa/include/asm/tlb.h | 2 ++
arch/xtensa/kernel/hw_breakpoint.c | 1 +
arch/xtensa/kernel/irq.c | 1 +
arch/xtensa/kernel/ptrace.c | 1 -
arch/xtensa/kernel/signal.c | 2 ++
arch/xtensa/kernel/smp.c | 1 +
arch/xtensa/kernel/stacktrace.c | 1 +
arch/xtensa/kernel/traps.c | 1 +
arch/xtensa/lib/umulsidi3.S | 4 +++-
arch/xtensa/mm/fault.c | 1 +
arch/xtensa/mm/tlb.c | 1 +
arch/xtensa/platforms/iss/network.c | 4 ++--
arch/xtensa/variants/fsf/include/variant/core.h | 1 +
drivers/irqchip/irq-xtensa-mx.c | 1 +
20 files changed, 33 insertions(+), 6 deletions(-)

Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Marc Zyngier <[email protected]>


2023-09-20 10:31:54

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 05/16] xtensa: processor.h: add init_arch() prototype

Add the prototype for init_arch() to asm/processor.h to prevent a
build warning:

arch/xtensa/kernel/setup.c:244:13: warning: no previous prototype for 'init_arch' [-Wmissing-prototypes]
244 | void __init init_arch(bp_tag_t *bp_start)

Signed-off-by: Randy Dunlap <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/include/asm/processor.h | 4 ++++
1 file changed, 4 insertions(+)

diff -- a/arch/xtensa/include/asm/processor.h b/arch/xtensa/include/asm/processor.h
--- a/arch/xtensa/include/asm/processor.h
+++ b/arch/xtensa/include/asm/processor.h
@@ -14,6 +14,8 @@

#include <linux/compiler.h>
#include <linux/stringify.h>
+
+#include <asm/bootparam.h>
#include <asm/ptrace.h>
#include <asm/types.h>
#include <asm/regs.h>
@@ -217,6 +219,8 @@ struct mm_struct;

extern unsigned long __get_wchan(struct task_struct *p);

+void init_arch(bp_tag_t *bp_start);
+
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
#define KSTK_ESP(tsk) (task_pt_regs(tsk)->areg[1])

2023-09-20 11:34:29

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 12/16] xtensa: tlb: include <asm/tlb.h> for missing prototype

Add the prototype for check_tlb_sanity() to <asm/tlb.h> and use that
header to prevent a build warning:

arch/xtensa/mm/tlb.c:273:6: warning: no previous prototype for 'check_tlb_sanity' [-Wmissing-prototypes]
273 | void check_tlb_sanity(void)

Signed-off-by: Randy Dunlap <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/include/asm/tlb.h | 2 ++
arch/xtensa/mm/tlb.c | 1 +
2 files changed, 3 insertions(+)

diff -- a/arch/xtensa/include/asm/tlb.h b/arch/xtensa/include/asm/tlb.h
--- a/arch/xtensa/include/asm/tlb.h
+++ b/arch/xtensa/include/asm/tlb.h
@@ -18,4 +18,6 @@

#define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte)

+void check_tlb_sanity(void);
+
#endif /* _XTENSA_TLB_H */
diff -- a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c
--- a/arch/xtensa/mm/tlb.c
+++ b/arch/xtensa/mm/tlb.c
@@ -17,6 +17,7 @@
#include <linux/mm.h>
#include <asm/processor.h>
#include <asm/mmu_context.h>
+#include <asm/tlb.h>
#include <asm/tlbflush.h>
#include <asm/cacheflush.h>

2023-09-20 12:07:03

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 03/16] xtensa: irq: include <asm/traps.h>

Use <asm/traps.h> to provide the function prototype for do_IRQ()
to prevent a build warning:

arch/xtensa/kernel/irq.c:34:17: warning: no previous prototype for 'do_IRQ' [-Wmissing-prototypes]
34 | asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs)

Signed-off-by: Randy Dunlap <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/kernel/irq.c | 1 +
1 file changed, 1 insertion(+)

diff -- a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c
--- a/arch/xtensa/kernel/irq.c
+++ b/arch/xtensa/kernel/irq.c
@@ -28,6 +28,7 @@
#include <asm/mxregs.h>
#include <linux/uaccess.h>
#include <asm/platform.h>
+#include <asm/traps.h>

DECLARE_PER_CPU(unsigned long, nmi_count);

2023-09-20 12:26:35

by Max Filippov

[permalink] [raw]
Subject: Re: [PATCH 00/16] xtensa: fix W=1 build warnings

Hi Randy,

On Tue, Sep 19, 2023 at 10:21 PM Randy Dunlap <[email protected]> wrote:
>
> This series fixes all xtensa W=1 build warnings that I have seen
> with the exception of some in arch/xtensa/boot/. [1]
>
> These have been through defconfig, allnoconfig, tinyconfig, allyesconfig,
> allmodconfig, and many randconfig builds.
>
> [PATCH 01/16] xtensa: FSF: define XCHAL_HAVE_DIV32
> [PATCH 02/16] xtensa: fault: include <asm/traps.h>
> [PATCH 03/16] xtensa: irq: include <asm/traps.h>
> [PATCH 04/16] xtensa: ptrace: add prototypes to <asm/ptrace.h>
> [PATCH 05/16] xtensa: processor.h: add init_arch() prototype
> [PATCH 06/16] xtensa: signal: include headers for function prototypes
> [PATCH 07/16] xtensa: stacktrace: include <asm/ftrace.h> for prototype
> [PATCH 08/16] xtensa: traps: add <linux/cpu.h> for function prototype
> [PATCH 09/16] irqchip: irq-xtensa-mx: include header for missing prototype
> [PATCH 10/16] xtensa: smp: add headers for missing function prototypes
> [PATCH 11/16] xtensa: hw_breakpoing: include header for missing prototype
> [PATCH 12/16] xtensa: tlb: include <asm/tlb.h> for missing prototype
> [PATCH 13/16] xtensa: iss/network: make functions static
> [PATCH 14/16] xtensa: boot: don't add include-dirs
> [PATCH 15/16] xtensa: umulsidi3: fix conditional expression
> [PATCH 16/16] xtensa: boot/lib: add missing prototypes for functions
>
> 1:
> arch/xtensa/boot/boot-elf/bootstrap.S:68: Warning: value 0x1a0003000 truncated to 0xa0003000
>
> arch/xtensa/boot/Makefile | 3 +--
> arch/xtensa/boot/lib/zmem.c | 4 ++++
> arch/xtensa/include/asm/hw_breakpoint.h | 1 +
> arch/xtensa/include/asm/processor.h | 5 +++++
> arch/xtensa/include/asm/ptrace.h | 3 +++
> arch/xtensa/include/asm/smp.h | 1 +
> arch/xtensa/include/asm/tlb.h | 2 ++
> arch/xtensa/kernel/hw_breakpoint.c | 1 +
> arch/xtensa/kernel/irq.c | 1 +
> arch/xtensa/kernel/ptrace.c | 1 -
> arch/xtensa/kernel/signal.c | 2 ++
> arch/xtensa/kernel/smp.c | 1 +
> arch/xtensa/kernel/stacktrace.c | 1 +
> arch/xtensa/kernel/traps.c | 1 +
> arch/xtensa/lib/umulsidi3.S | 4 +++-
> arch/xtensa/mm/fault.c | 1 +
> arch/xtensa/mm/tlb.c | 1 +
> arch/xtensa/platforms/iss/network.c | 4 ++--
> arch/xtensa/variants/fsf/include/variant/core.h | 1 +
> drivers/irqchip/irq-xtensa-mx.c | 1 +
> 20 files changed, 33 insertions(+), 6 deletions(-)
>
> Cc: Chris Zankel <[email protected]>
> Cc: Max Filippov <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Marc Zyngier <[email protected]>

Thank you for this nice cleanup. Applied the whole series (except
the first and the last patches, which I replaced with different fixes)
to my xtensa tree.

--
Thanks.
-- Max

2023-09-20 14:20:21

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 07/16] xtensa: stacktrace: include <asm/ftrace.h> for prototype

Use <asm/ftrace.h> to prevent a build warning:

arch/xtensa/kernel/stacktrace.c:263:15: warning: no previous prototype for 'return_address' [-Wmissing-prototypes]
263 | unsigned long return_address(unsigned level)

Signed-off-by: Randy Dunlap <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/kernel/stacktrace.c | 1 +
1 file changed, 1 insertion(+)

diff -- a/arch/xtensa/kernel/stacktrace.c b/arch/xtensa/kernel/stacktrace.c
--- a/arch/xtensa/kernel/stacktrace.c
+++ b/arch/xtensa/kernel/stacktrace.c
@@ -12,6 +12,7 @@
#include <linux/sched.h>
#include <linux/stacktrace.h>

+#include <asm/ftrace.h>
#include <asm/stacktrace.h>
#include <asm/traps.h>
#include <linux/uaccess.h>

2023-09-20 14:34:38

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 15/16] xtensa: umulsidi3: fix conditional expression

Even when a variant has one or more of these defines set to 1, the
multiplier code paths are not used. Change the expression so that the
correct code paths are used.

arch/xtensa/lib/umulsidi3.S:44:38: warning: "XCHAL_NO_MUL" is not defined, evaluates to 0 [-Wundef]
44 | #if defined(__XTENSA_CALL0_ABI__) && XCHAL_NO_MUL
arch/xtensa/lib/umulsidi3.S:145:38: warning: "XCHAL_NO_MUL" is not defined, evaluates to 0 [-Wundef]
145 | #if defined(__XTENSA_CALL0_ABI__) && XCHAL_NO_MUL
arch/xtensa/lib/umulsidi3.S:159:5: warning: "XCHAL_NO_MUL" is not defined, evaluates to 0 [-Wundef]
159 | #if XCHAL_NO_MUL

Fixes: 8939c58d68f9 ("xtensa: add __umulsidi3 helper")
Signed-off-by: Randy Dunlap <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/lib/umulsidi3.S | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff -- a/arch/xtensa/lib/umulsidi3.S b/arch/xtensa/lib/umulsidi3.S
--- a/arch/xtensa/lib/umulsidi3.S
+++ b/arch/xtensa/lib/umulsidi3.S
@@ -3,7 +3,9 @@
#include <asm/asmmacro.h>
#include <asm/core.h>

-#if !XCHAL_HAVE_MUL16 && !XCHAL_HAVE_MUL32 && !XCHAL_HAVE_MAC16
+#if XCHAL_HAVE_MUL16 || XCHAL_HAVE_MUL32 || XCHAL_HAVE_MAC16
+#define XCHAL_NO_MUL 0
+#else
#define XCHAL_NO_MUL 1
#endif

2023-09-20 15:02:10

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 08/16] xtensa: traps: add <linux/cpu.h> for function prototype

Use <linux/cpu.h> to provide the prototype for trap_init(), to prevent
a build warning:

arch/xtensa/kernel/traps.c:484:13: warning: no previous prototype for 'trap_init' [-Wmissing-prototypes]
484 | void __init trap_init(void)

Signed-off-by: Randy Dunlap <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/kernel/traps.c | 1 +
1 file changed, 1 insertion(+)

diff -- a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -23,6 +23,7 @@
* for more details.
*/

+#include <linux/cpu.h>
#include <linux/kernel.h>
#include <linux/sched/signal.h>
#include <linux/sched/debug.h>

2023-09-20 22:14:56

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH 01/16] xtensa: FSF: define XCHAL_HAVE_DIV32

When variant FSF is set, XCHAL_HAVE_DIV32 is not defined,
so add the define for FSF to prevent build warnings:

arch/xtensa/lib/divsi3.S:9:5: warning: "XCHAL_HAVE_DIV32" is not defined, evaluates to 0 [-Wundef]
9 | #if XCHAL_HAVE_DIV32
arch/xtensa/lib/modsi3.S:9:5: warning: "XCHAL_HAVE_DIV32" is not defined, evaluates to 0 [-Wundef]
9 | #if XCHAL_HAVE_DIV32

Fixes: 173d6681380a ("xtensa: remove extra header files")
Signed-off-by: Randy Dunlap <[email protected]>
Reported-by: kernel test robot <[email protected]>
Closes: lore.kernel.org/r/[email protected]
Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
---
arch/xtensa/variants/fsf/include/variant/core.h | 1 +
1 file changed, 1 insertion(+)

diff -- a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
--- a/arch/xtensa/variants/fsf/include/variant/core.h
+++ b/arch/xtensa/variants/fsf/include/variant/core.h
@@ -41,6 +41,7 @@
#define XCHAL_HAVE_MUL16 0 /* MUL16S/MUL16U instructions */
#define XCHAL_HAVE_MUL32 0 /* MULL instruction */
#define XCHAL_HAVE_MUL32_HIGH 0 /* MULUH/MULSH instructions */
+#define XCHAL_HAVE_DIV32 0 /* QUOS/QUOU/REMS/REMU instructions */
#define XCHAL_HAVE_L32R 1 /* L32R instruction */
#define XCHAL_HAVE_ABSOLUTE_LITERALS 1 /* non-PC-rel (extended) L32R */
#define XCHAL_HAVE_CONST16 0 /* CONST16 instruction */