All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 11:17 ` Niklas Schnelle
  0 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

Hi,

This is version 3 of my attempt to get rid of a clang -Wnull-pointer-arithmetic
warning for the use of PCI_IOBASE in asm-generic/io.h. This was originally
found on s390 but should apply to all platforms leaving PCI_IOBASE undefined
while making use of the inb() and friends helpers from asm-generic/io.h.

This applies cleanly and was compile tested on top of v5.12-rc8 for the
previously broken ARC and nds32 architectures.

I did boot test this only on x86_64 and s390x the former implements inb()
itself while the latter would emit a WARN_ONCE() but no drivers using inb().

Thanks,
Niklas

Changes since v2:
- Improved comment for SPARC PCI_IOBASE definition as suggested by David Laight
- Added a patch for ARC which is missing the asm/bug.h include for WARN_ONCE()
  (kernel test robot)
- Added ifdefs to ioport_map() and __pci_ioport_map() since apparently at least
  test configs enable CONFIG_HAS_IOPORT_MAP even on architectures which leave
  PCI_IOBASE unset (kernel test robot for nds32 and ARC).

Changes since v1:
- Added patch to explicitly set PCI_IOBASE to 0 on sparc as suggested by Arnd
  Bergmann
- Instead of working around the warning with a uintptr_t PCI_IOBASE make inb()
  and friends explicitly WARN_ONCE() and return 0xff... (Arnd Bergmann)

Niklas Schnelle (3):
  sparc: explicitly set PCI_IOBASE to 0
  ARC: io.h: Include asm/bug.h
  asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on
    PCI_IOBASE

 arch/arc/include/asm/io.h   |  1 +
 arch/sparc/include/asm/io.h |  8 +++++
 include/asm-generic/io.h    | 64 ++++++++++++++++++++++++++++++++++---
 3 files changed, 69 insertions(+), 4 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v3 0/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 11:17 ` Niklas Schnelle
  0 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

Hi,

This is version 3 of my attempt to get rid of a clang -Wnull-pointer-arithmetic
warning for the use of PCI_IOBASE in asm-generic/io.h. This was originally
found on s390 but should apply to all platforms leaving PCI_IOBASE undefined
while making use of the inb() and friends helpers from asm-generic/io.h.

This applies cleanly and was compile tested on top of v5.12-rc8 for the
previously broken ARC and nds32 architectures.

I did boot test this only on x86_64 and s390x the former implements inb()
itself while the latter would emit a WARN_ONCE() but no drivers using inb().

Thanks,
Niklas

Changes since v2:
- Improved comment for SPARC PCI_IOBASE definition as suggested by David Laight
- Added a patch for ARC which is missing the asm/bug.h include for WARN_ONCE()
  (kernel test robot)
- Added ifdefs to ioport_map() and __pci_ioport_map() since apparently at least
  test configs enable CONFIG_HAS_IOPORT_MAP even on architectures which leave
  PCI_IOBASE unset (kernel test robot for nds32 and ARC).

Changes since v1:
- Added patch to explicitly set PCI_IOBASE to 0 on sparc as suggested by Arnd
  Bergmann
- Instead of working around the warning with a uintptr_t PCI_IOBASE make inb()
  and friends explicitly WARN_ONCE() and return 0xff... (Arnd Bergmann)

Niklas Schnelle (3):
  sparc: explicitly set PCI_IOBASE to 0
  ARC: io.h: Include asm/bug.h
  asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on
    PCI_IOBASE

 arch/arc/include/asm/io.h   |  1 +
 arch/sparc/include/asm/io.h |  8 +++++
 include/asm-generic/io.h    | 64 ++++++++++++++++++++++++++++++++++---
 3 files changed, 69 insertions(+), 4 deletions(-)

-- 
2.25.1


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v3 1/3] sparc: explicitly set PCI_IOBASE to 0
  2021-04-21 11:17 ` Niklas Schnelle
@ 2021-04-21 11:17   ` Niklas Schnelle
  -1 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

Instead of relying on the fallback in asm-generic/io.h which sets
PCI_IOBASE 0 if it is not defined set it explicitly.

Link: https://lore.kernel.org/lkml/CAK8P3a3PK9zyeP4ymELtc2ZYnymECoACiigw9Za+pvSJpCk5=g@mail.gmail.com/
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
v1 -> v2:
- Improved comment (David Laight)

 arch/sparc/include/asm/io.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/sparc/include/asm/io.h b/arch/sparc/include/asm/io.h
index 2eefa526b38f..c019e50702c1 100644
--- a/arch/sparc/include/asm/io.h
+++ b/arch/sparc/include/asm/io.h
@@ -1,6 +1,14 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef ___ASM_SPARC_IO_H
 #define ___ASM_SPARC_IO_H
+
+/*
+ * On LEON PCI addresses below 64k are converted to IO accesses.
+ * io_remap_xxx() returns a kernel virtual address in the PCI window so
+ * inb() doesn't need to add an offset.
+ */
+#define PCI_IOBASE ((void __iomem *)0)
+
 #if defined(__sparc__) && defined(__arch64__)
 #include <asm/io_64.h>
 #else
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 1/3] sparc: explicitly set PCI_IOBASE to 0
@ 2021-04-21 11:17   ` Niklas Schnelle
  0 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

Instead of relying on the fallback in asm-generic/io.h which sets
PCI_IOBASE 0 if it is not defined set it explicitly.

Link: https://lore.kernel.org/lkml/CAK8P3a3PK9zyeP4ymELtc2ZYnymECoACiigw9Za+pvSJpCk5=g@mail.gmail.com/
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
v1 -> v2:
- Improved comment (David Laight)

 arch/sparc/include/asm/io.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/sparc/include/asm/io.h b/arch/sparc/include/asm/io.h
index 2eefa526b38f..c019e50702c1 100644
--- a/arch/sparc/include/asm/io.h
+++ b/arch/sparc/include/asm/io.h
@@ -1,6 +1,14 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef ___ASM_SPARC_IO_H
 #define ___ASM_SPARC_IO_H
+
+/*
+ * On LEON PCI addresses below 64k are converted to IO accesses.
+ * io_remap_xxx() returns a kernel virtual address in the PCI window so
+ * inb() doesn't need to add an offset.
+ */
+#define PCI_IOBASE ((void __iomem *)0)
+
 #if defined(__sparc__) && defined(__arch64__)
 #include <asm/io_64.h>
 #else
-- 
2.25.1


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 2/3] ARC: io.h: Include asm/bug.h
  2021-04-21 11:17 ` Niklas Schnelle
@ 2021-04-21 11:17   ` Niklas Schnelle
  -1 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

From: Niklas Schnelle <niklas@komani.de>

In a future change asm-generic/io.h will make inb() and friends
WARN_ONCE() on systems without I/O port support. This requires
WARN_ONCE() from asm/bug.h to be included so include it in the
arch specific io.h as done by other architectures.

Signed-off-by: Niklas Schnelle <niklas@komani.de>
---
 arch/arc/include/asm/io.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h
index 8f777d6441a5..62ce2e486e29 100644
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <asm/byteorder.h>
+#include <asm/bug.h>
 #include <asm/page.h>
 #include <asm/unaligned.h>
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 2/3] ARC: io.h: Include asm/bug.h
@ 2021-04-21 11:17   ` Niklas Schnelle
  0 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

From: Niklas Schnelle <niklas@komani.de>

In a future change asm-generic/io.h will make inb() and friends
WARN_ONCE() on systems without I/O port support. This requires
WARN_ONCE() from asm/bug.h to be included so include it in the
arch specific io.h as done by other architectures.

Signed-off-by: Niklas Schnelle <niklas@komani.de>
---
 arch/arc/include/asm/io.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h
index 8f777d6441a5..62ce2e486e29 100644
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <asm/byteorder.h>
+#include <asm/bug.h>
 #include <asm/page.h>
 #include <asm/unaligned.h>
 
-- 
2.25.1


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
  2021-04-21 11:17 ` Niklas Schnelle
@ 2021-04-21 11:17   ` Niklas Schnelle
  -1 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

When PCI_IOBASE is not defined, it is set to 0 such that it is ignored
in calls to the readX/writeX primitives. This triggers clang's
-Wnull-pointer-arithmetic warning and will result in illegal accesses on
platforms that do not support I/O ports if drivers do still attempt to
access them.

Make things explicit and silence the warning by letting inb() and
friends fail with WARN_ONCE() and a 0xff... return in case PCI_IOBASE is
not defined.

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
v2 -> v3:
- Added ifdefs to ioport_map() and __pci_ioport_map() since apparently at least
  test configs enable CONFIG_HAS_IOPORT_MAP even on architectures which leave
  PCI_IOBASE unset (kernel test robot for nds32 and ARC).
v1 -> v2:
- Instead of working around the warning with a uintptr_t PCI_IOBASE make inb()
  and friends explicitly WARN_ONCE() and return 0xff... (Arnd)
 include/asm-generic/io.h | 64 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 60 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index c6af40ce03be..aabb0a8186ee 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -440,10 +440,6 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
 #endif
 #endif /* CONFIG_64BIT */
 
-#ifndef PCI_IOBASE
-#define PCI_IOBASE ((void __iomem *)0)
-#endif
-
 #ifndef IO_SPACE_LIMIT
 #define IO_SPACE_LIMIT 0xffff
 #endif
@@ -458,12 +454,17 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
 #define _inb _inb
 static inline u8 _inb(unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	u8 val;
 
 	__io_pbr();
 	val = __raw_readb(PCI_IOBASE + addr);
 	__io_par(val);
 	return val;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return ~0;
+#endif
 }
 #endif
 
@@ -471,12 +472,17 @@ static inline u8 _inb(unsigned long addr)
 #define _inw _inw
 static inline u16 _inw(unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	u16 val;
 
 	__io_pbr();
 	val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
 	__io_par(val);
 	return val;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return ~0;
+#endif
 }
 #endif
 
@@ -484,12 +490,17 @@ static inline u16 _inw(unsigned long addr)
 #define _inl _inl
 static inline u32 _inl(unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	u32 val;
 
 	__io_pbr();
 	val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
 	__io_par(val);
 	return val;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return ~0;
+#endif
 }
 #endif
 
@@ -497,9 +508,13 @@ static inline u32 _inl(unsigned long addr)
 #define _outb _outb
 static inline void _outb(u8 value, unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	__io_pbw();
 	__raw_writeb(value, PCI_IOBASE + addr);
 	__io_paw();
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -507,9 +522,13 @@ static inline void _outb(u8 value, unsigned long addr)
 #define _outw _outw
 static inline void _outw(u16 value, unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	__io_pbw();
 	__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
 	__io_paw();
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -517,9 +536,13 @@ static inline void _outw(u16 value, unsigned long addr)
 #define _outl _outl
 static inline void _outl(u32 value, unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	__io_pbw();
 	__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
 	__io_paw();
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -606,7 +629,11 @@ static inline void outl_p(u32 value, unsigned long addr)
 #define insb insb
 static inline void insb(unsigned long addr, void *buffer, unsigned int count)
 {
+#ifdef PCI_IOBASE
 	readsb(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -614,7 +641,11 @@ static inline void insb(unsigned long addr, void *buffer, unsigned int count)
 #define insw insw
 static inline void insw(unsigned long addr, void *buffer, unsigned int count)
 {
+#ifdef PCI_IOBASE
 	readsw(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -622,7 +653,11 @@ static inline void insw(unsigned long addr, void *buffer, unsigned int count)
 #define insl insl
 static inline void insl(unsigned long addr, void *buffer, unsigned int count)
 {
+#ifdef PCI_IOBASE
 	readsl(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -631,7 +666,11 @@ static inline void insl(unsigned long addr, void *buffer, unsigned int count)
 static inline void outsb(unsigned long addr, const void *buffer,
 			 unsigned int count)
 {
+#ifdef PCI_IOBASE
 	writesb(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -640,7 +679,11 @@ static inline void outsb(unsigned long addr, const void *buffer,
 static inline void outsw(unsigned long addr, const void *buffer,
 			 unsigned int count)
 {
+#ifdef PCI_IOBASE
 	writesw(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -649,7 +692,11 @@ static inline void outsw(unsigned long addr, const void *buffer,
 static inline void outsl(unsigned long addr, const void *buffer,
 			 unsigned int count)
 {
+#ifdef PCI_IOBASE
 	writesl(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -1001,18 +1048,27 @@ static inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size)
 #define ioport_map ioport_map
 static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
 {
+#ifdef PCI_IOBASE
 	port &= IO_SPACE_LIMIT;
 	return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return NULL;
+#endif
 }
 #define __pci_ioport_unmap __pci_ioport_unmap
 static inline void __pci_ioport_unmap(void __iomem *p)
 {
+#ifdef PCI_IOBASE
 	uintptr_t start = (uintptr_t) PCI_IOBASE;
 	uintptr_t addr = (uintptr_t) p;
 
 	if (addr >= start && addr < start + IO_SPACE_LIMIT)
 		return;
 	iounmap(p);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 11:17   ` Niklas Schnelle
  0 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:17 UTC (permalink / raw)
  To: Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

When PCI_IOBASE is not defined, it is set to 0 such that it is ignored
in calls to the readX/writeX primitives. This triggers clang's
-Wnull-pointer-arithmetic warning and will result in illegal accesses on
platforms that do not support I/O ports if drivers do still attempt to
access them.

Make things explicit and silence the warning by letting inb() and
friends fail with WARN_ONCE() and a 0xff... return in case PCI_IOBASE is
not defined.

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
v2 -> v3:
- Added ifdefs to ioport_map() and __pci_ioport_map() since apparently at least
  test configs enable CONFIG_HAS_IOPORT_MAP even on architectures which leave
  PCI_IOBASE unset (kernel test robot for nds32 and ARC).
v1 -> v2:
- Instead of working around the warning with a uintptr_t PCI_IOBASE make inb()
  and friends explicitly WARN_ONCE() and return 0xff... (Arnd)
 include/asm-generic/io.h | 64 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 60 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index c6af40ce03be..aabb0a8186ee 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -440,10 +440,6 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
 #endif
 #endif /* CONFIG_64BIT */
 
-#ifndef PCI_IOBASE
-#define PCI_IOBASE ((void __iomem *)0)
-#endif
-
 #ifndef IO_SPACE_LIMIT
 #define IO_SPACE_LIMIT 0xffff
 #endif
@@ -458,12 +454,17 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
 #define _inb _inb
 static inline u8 _inb(unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	u8 val;
 
 	__io_pbr();
 	val = __raw_readb(PCI_IOBASE + addr);
 	__io_par(val);
 	return val;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return ~0;
+#endif
 }
 #endif
 
@@ -471,12 +472,17 @@ static inline u8 _inb(unsigned long addr)
 #define _inw _inw
 static inline u16 _inw(unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	u16 val;
 
 	__io_pbr();
 	val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
 	__io_par(val);
 	return val;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return ~0;
+#endif
 }
 #endif
 
@@ -484,12 +490,17 @@ static inline u16 _inw(unsigned long addr)
 #define _inl _inl
 static inline u32 _inl(unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	u32 val;
 
 	__io_pbr();
 	val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
 	__io_par(val);
 	return val;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return ~0;
+#endif
 }
 #endif
 
@@ -497,9 +508,13 @@ static inline u32 _inl(unsigned long addr)
 #define _outb _outb
 static inline void _outb(u8 value, unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	__io_pbw();
 	__raw_writeb(value, PCI_IOBASE + addr);
 	__io_paw();
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -507,9 +522,13 @@ static inline void _outb(u8 value, unsigned long addr)
 #define _outw _outw
 static inline void _outw(u16 value, unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	__io_pbw();
 	__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
 	__io_paw();
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -517,9 +536,13 @@ static inline void _outw(u16 value, unsigned long addr)
 #define _outl _outl
 static inline void _outl(u32 value, unsigned long addr)
 {
+#ifdef PCI_IOBASE
 	__io_pbw();
 	__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
 	__io_paw();
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -606,7 +629,11 @@ static inline void outl_p(u32 value, unsigned long addr)
 #define insb insb
 static inline void insb(unsigned long addr, void *buffer, unsigned int count)
 {
+#ifdef PCI_IOBASE
 	readsb(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -614,7 +641,11 @@ static inline void insb(unsigned long addr, void *buffer, unsigned int count)
 #define insw insw
 static inline void insw(unsigned long addr, void *buffer, unsigned int count)
 {
+#ifdef PCI_IOBASE
 	readsw(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -622,7 +653,11 @@ static inline void insw(unsigned long addr, void *buffer, unsigned int count)
 #define insl insl
 static inline void insl(unsigned long addr, void *buffer, unsigned int count)
 {
+#ifdef PCI_IOBASE
 	readsl(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -631,7 +666,11 @@ static inline void insl(unsigned long addr, void *buffer, unsigned int count)
 static inline void outsb(unsigned long addr, const void *buffer,
 			 unsigned int count)
 {
+#ifdef PCI_IOBASE
 	writesb(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -640,7 +679,11 @@ static inline void outsb(unsigned long addr, const void *buffer,
 static inline void outsw(unsigned long addr, const void *buffer,
 			 unsigned int count)
 {
+#ifdef PCI_IOBASE
 	writesw(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -649,7 +692,11 @@ static inline void outsw(unsigned long addr, const void *buffer,
 static inline void outsl(unsigned long addr, const void *buffer,
 			 unsigned int count)
 {
+#ifdef PCI_IOBASE
 	writesl(PCI_IOBASE + addr, buffer, count);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
@@ -1001,18 +1048,27 @@ static inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size)
 #define ioport_map ioport_map
 static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
 {
+#ifdef PCI_IOBASE
 	port &= IO_SPACE_LIMIT;
 	return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+	return NULL;
+#endif
 }
 #define __pci_ioport_unmap __pci_ioport_unmap
 static inline void __pci_ioport_unmap(void __iomem *p)
 {
+#ifdef PCI_IOBASE
 	uintptr_t start = (uintptr_t) PCI_IOBASE;
 	uintptr_t addr = (uintptr_t) p;
 
 	if (addr >= start && addr < start + IO_SPACE_LIMIT)
 		return;
 	iounmap(p);
+#else
+	WARN_ONCE(1, "No I/O port support\n");
+#endif
 }
 #endif
 
-- 
2.25.1


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* RE: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
  2021-04-21 11:17   ` Niklas Schnelle
@ 2021-04-21 11:24     ` David Laight
  -1 siblings, 0 replies; 20+ messages in thread
From: David Laight @ 2021-04-21 11:24 UTC (permalink / raw)
  To: 'Niklas Schnelle', Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

From: Niklas Schnelle
> Sent: 21 April 2021 12:18
> 
> When PCI_IOBASE is not defined, it is set to 0 such that it is ignored
> in calls to the readX/writeX primitives. This triggers clang's
> -Wnull-pointer-arithmetic warning and will result in illegal accesses on
> platforms that do not support I/O ports if drivers do still attempt to
> access them.
> 
> Make things explicit and silence the warning by letting inb() and
> friends fail with WARN_ONCE() and a 0xff... return in case PCI_IOBASE is
> not defined.
...
> 
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index c6af40ce03be..aabb0a8186ee 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
...
> @@ -458,12 +454,17 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
>  #define _inb _inb
>  static inline u8 _inb(unsigned long addr)
>  {
> +#ifdef PCI_IOBASE
>  	u8 val;
> 
>  	__io_pbr();
>  	val = __raw_readb(PCI_IOBASE + addr);
>  	__io_par(val);
>  	return val;
> +#else
> +	WARN_ONCE(1, "No I/O port support\n");
> +	return ~0;
> +#endif
>  }
>  #endif

I suspect that this might be better not inlined
when PCI_IOBASE is undefined.

Otherwise you get quite a lot of bloat from all the
WARN_ONCE() calls.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* RE: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 11:24     ` David Laight
  0 siblings, 0 replies; 20+ messages in thread
From: David Laight @ 2021-04-21 11:24 UTC (permalink / raw)
  To: 'Niklas Schnelle', Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

From: Niklas Schnelle
> Sent: 21 April 2021 12:18
> 
> When PCI_IOBASE is not defined, it is set to 0 such that it is ignored
> in calls to the readX/writeX primitives. This triggers clang's
> -Wnull-pointer-arithmetic warning and will result in illegal accesses on
> platforms that do not support I/O ports if drivers do still attempt to
> access them.
> 
> Make things explicit and silence the warning by letting inb() and
> friends fail with WARN_ONCE() and a 0xff... return in case PCI_IOBASE is
> not defined.
...
> 
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index c6af40ce03be..aabb0a8186ee 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
...
> @@ -458,12 +454,17 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
>  #define _inb _inb
>  static inline u8 _inb(unsigned long addr)
>  {
> +#ifdef PCI_IOBASE
>  	u8 val;
> 
>  	__io_pbr();
>  	val = __raw_readb(PCI_IOBASE + addr);
>  	__io_par(val);
>  	return val;
> +#else
> +	WARN_ONCE(1, "No I/O port support\n");
> +	return ~0;
> +#endif
>  }
>  #endif

I suspect that this might be better not inlined
when PCI_IOBASE is undefined.

Otherwise you get quite a lot of bloat from all the
WARN_ONCE() calls.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
  2021-04-21 11:24     ` David Laight
@ 2021-04-21 11:50       ` Niklas Schnelle
  -1 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:50 UTC (permalink / raw)
  To: David Laight, Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

On Wed, 2021-04-21 at 11:24 +0000, David Laight wrote:
> From: Niklas Schnelle
> > Sent: 21 April 2021 12:18
> > 
> > When PCI_IOBASE is not defined, it is set to 0 such that it is ignored
> > in calls to the readX/writeX primitives. This triggers clang's
> > -Wnull-pointer-arithmetic warning and will result in illegal accesses on
> > platforms that do not support I/O ports if drivers do still attempt to
> > access them.
> > 
> > Make things explicit and silence the warning by letting inb() and
> > friends fail with WARN_ONCE() and a 0xff... return in case PCI_IOBASE is
> > not defined.
> ...
> > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> > index c6af40ce03be..aabb0a8186ee 100644
> > --- a/include/asm-generic/io.h
> > +++ b/include/asm-generic/io.h
> ...
> > @@ -458,12 +454,17 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
> >  #define _inb _inb
> >  static inline u8 _inb(unsigned long addr)
> >  {
> > +#ifdef PCI_IOBASE
> >  	u8 val;
> > 
> >  	__io_pbr();
> >  	val = __raw_readb(PCI_IOBASE + addr);
> >  	__io_par(val);
> >  	return val;
> > +#else
> > +	WARN_ONCE(1, "No I/O port support\n");
> > +	return ~0;
> > +#endif
> >  }
> >  #endif
> 
> I suspect that this might be better not inlined
> when PCI_IOBASE is undefined.
> 
> Otherwise you get quite a lot of bloat from all the
> WARN_ONCE() calls.
> 
> 	David

Hmm, I was wondering if we should rather have a large ifdef block of
all these functions stubbed to WARN_ONCE rather than in each function.
As I understand it this would be necessary if we want the inline gone.
They would still be static though so we still get a copy per
compilation unit that uses it or am I misunderstanding?

> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 11:50       ` Niklas Schnelle
  0 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 11:50 UTC (permalink / raw)
  To: David Laight, Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	linux-arch, linux-kernel, linux-s390, linux-snps-arc, sparclinux

On Wed, 2021-04-21 at 11:24 +0000, David Laight wrote:
> From: Niklas Schnelle
> > Sent: 21 April 2021 12:18
> > 
> > When PCI_IOBASE is not defined, it is set to 0 such that it is ignored
> > in calls to the readX/writeX primitives. This triggers clang's
> > -Wnull-pointer-arithmetic warning and will result in illegal accesses on
> > platforms that do not support I/O ports if drivers do still attempt to
> > access them.
> > 
> > Make things explicit and silence the warning by letting inb() and
> > friends fail with WARN_ONCE() and a 0xff... return in case PCI_IOBASE is
> > not defined.
> ...
> > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> > index c6af40ce03be..aabb0a8186ee 100644
> > --- a/include/asm-generic/io.h
> > +++ b/include/asm-generic/io.h
> ...
> > @@ -458,12 +454,17 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
> >  #define _inb _inb
> >  static inline u8 _inb(unsigned long addr)
> >  {
> > +#ifdef PCI_IOBASE
> >  	u8 val;
> > 
> >  	__io_pbr();
> >  	val = __raw_readb(PCI_IOBASE + addr);
> >  	__io_par(val);
> >  	return val;
> > +#else
> > +	WARN_ONCE(1, "No I/O port support\n");
> > +	return ~0;
> > +#endif
> >  }
> >  #endif
> 
> I suspect that this might be better not inlined
> when PCI_IOBASE is undefined.
> 
> Otherwise you get quite a lot of bloat from all the
> WARN_ONCE() calls.
> 
> 	David

Hmm, I was wondering if we should rather have a large ifdef block of
all these functions stubbed to WARN_ONCE rather than in each function.
As I understand it this would be necessary if we want the inline gone.
They would still be static though so we still get a copy per
compilation unit that uses it or am I misunderstanding?

> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
> 


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
  2021-04-21 11:50       ` Niklas Schnelle
@ 2021-04-21 11:57         ` Arnd Bergmann
  -1 siblings, 0 replies; 20+ messages in thread
From: Arnd Bergmann @ 2021-04-21 11:57 UTC (permalink / raw)
  To: Niklas Schnelle
  Cc: David Laight, Vineet Gupta, David S. Miller, Nathan Chancellor,
	Nick Desaulniers, clang-built-linux, linux-arch, linux-kernel,
	linux-s390, linux-snps-arc, sparclinux

On Wed, Apr 21, 2021 at 1:50 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
> On Wed, 2021-04-21 at 11:24 +0000, David Laight wrote:
> >
> > I suspect that this might be better not inlined
> > when PCI_IOBASE is undefined.
> >
> > Otherwise you get quite a lot of bloat from all the
> > WARN_ONCE() calls.
>
> Hmm, I was wondering if we should rather have a large ifdef block of
> all these functions stubbed to WARN_ONCE rather than in each function.
> As I understand it this would be necessary if we want the inline gone.
> They would still be static though so we still get a copy per
> compilation unit that uses it or am I misunderstanding?

I wouldn't worry too much about the size of known broken drivers during
compile testing. Also, since the functions are marked 'inline' and not
'__always_inline', the compiler is free to decide not to inline them if
the contents are excessively big, and since the strings are all identical,
they should be constant-folded.

If you want to make this a little smaller, using pr_warn_once()
would be a little smaller, but also give less information.

      Arnd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 11:57         ` Arnd Bergmann
  0 siblings, 0 replies; 20+ messages in thread
From: Arnd Bergmann @ 2021-04-21 11:57 UTC (permalink / raw)
  To: Niklas Schnelle
  Cc: David Laight, Vineet Gupta, David S. Miller, Nathan Chancellor,
	Nick Desaulniers, clang-built-linux, linux-arch, linux-kernel,
	linux-s390, linux-snps-arc, sparclinux

On Wed, Apr 21, 2021 at 1:50 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
> On Wed, 2021-04-21 at 11:24 +0000, David Laight wrote:
> >
> > I suspect that this might be better not inlined
> > when PCI_IOBASE is undefined.
> >
> > Otherwise you get quite a lot of bloat from all the
> > WARN_ONCE() calls.
>
> Hmm, I was wondering if we should rather have a large ifdef block of
> all these functions stubbed to WARN_ONCE rather than in each function.
> As I understand it this would be necessary if we want the inline gone.
> They would still be static though so we still get a copy per
> compilation unit that uses it or am I misunderstanding?

I wouldn't worry too much about the size of known broken drivers during
compile testing. Also, since the functions are marked 'inline' and not
'__always_inline', the compiler is free to decide not to inline them if
the contents are excessively big, and since the strings are all identical,
they should be constant-folded.

If you want to make this a little smaller, using pr_warn_once()
would be a little smaller, but also give less information.

      Arnd

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
  2021-04-21 11:17   ` Niklas Schnelle
@ 2021-04-21 15:19     ` kernel test robot
  -1 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-04-21 15:19 UTC (permalink / raw)
  To: Niklas Schnelle, Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: kbuild-all, netdev, Nathan Chancellor, Nick Desaulniers,
	clang-built-linux, linux-arch, linux-kernel, linux-s390

[-- Attachment #1: Type: text/plain, Size: 23965 bytes --]

Hi Niklas,

I love your patch! Yet something to improve:

[auto build test ERROR on soc/for-next]
[also build test ERROR on asm-generic/master v5.12-rc8 next-20210421]
[cannot apply to arc/for-next sparc-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: riscv-nommu_k210_defconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/05bc9b9b640336015712d139ebc42830d12a82da
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
        git checkout 05bc9b9b640336015712d139ebc42830d12a82da
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/main.c:17:
   include/asm-generic/io.h: In function 'inb_p':
>> arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   arch/riscv/include/asm/io.h:55:65: note: each undeclared identifier is reported only once for each function it appears in
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/riscv/include/uapi/asm/byteorder.h:10,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/riscv/include/asm/bitops.h:202,
                    from include/linux/bitops.h:32,
                    from include/linux/kernel.h:11,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from init/main.c:17:
   include/asm-generic/io.h: In function 'inw_p':
   arch/riscv/include/asm/io.h:56:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:36:51: note: in definition of macro '__le16_to_cpu'
      36 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:56:47: note: in expansion of macro 'readw_cpu'
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:587:9: note: in expansion of macro 'inw'
     587 |  return inw(addr);
         |         ^~~
   include/asm-generic/io.h: In function 'inl_p':
   arch/riscv/include/asm/io.h:57:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
      34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:57:47: note: in expansion of macro 'readl_cpu'
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:595:9: note: in expansion of macro 'inl'
     595 |  return inl(addr);
         |         ^~~
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/main.c:17:
   include/asm-generic/io.h: In function 'outb_p':
   arch/riscv/include/asm/io.h:59:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      59 | #define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:91:52: note: in definition of macro 'writeb_cpu'
      91 | #define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
         |                                                    ^
   include/asm-generic/io.h:603:2: note: in expansion of macro 'outb'
     603 |  outb(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outw_p':
   arch/riscv/include/asm/io.h:60:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      60 | #define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:92:76: note: in definition of macro 'writew_cpu'
      92 | #define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:611:2: note: in expansion of macro 'outw'
     611 |  outw(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outl_p':
   arch/riscv/include/asm/io.h:61:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      61 | #define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
      93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:619:2: note: in expansion of macro 'outl'
     619 |  outl(value, addr);
         |  ^~~~
   init/main.c: At top level:
   init/main.c:764:20: warning: no previous prototype for 'arch_post_acpi_subsys_init' [-Wmissing-prototypes]
     764 | void __init __weak arch_post_acpi_subsys_init(void) { }
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   init/main.c:776:20: warning: no previous prototype for 'mem_encrypt_init' [-Wmissing-prototypes]
     776 | void __init __weak mem_encrypt_init(void) { }
         |                    ^~~~~~~~~~~~~~~~
   init/main.c:778:20: warning: no previous prototype for 'poking_init' [-Wmissing-prototypes]
     778 | void __init __weak poking_init(void) { }
         |                    ^~~~~~~~~~~
--
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/do_mounts.c:2:
   include/asm-generic/io.h: In function 'inb_p':
>> arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   arch/riscv/include/asm/io.h:55:65: note: each undeclared identifier is reported only once for each function it appears in
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/riscv/include/uapi/asm/byteorder.h:10,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/riscv/include/asm/bitops.h:202,
                    from include/linux/bitops.h:32,
                    from include/linux/kernel.h:11,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from init/do_mounts.c:2:
   include/asm-generic/io.h: In function 'inw_p':
   arch/riscv/include/asm/io.h:56:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:36:51: note: in definition of macro '__le16_to_cpu'
      36 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:56:47: note: in expansion of macro 'readw_cpu'
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:587:9: note: in expansion of macro 'inw'
     587 |  return inw(addr);
         |         ^~~
   include/asm-generic/io.h: In function 'inl_p':
   arch/riscv/include/asm/io.h:57:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
      34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:57:47: note: in expansion of macro 'readl_cpu'
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:595:9: note: in expansion of macro 'inl'
     595 |  return inl(addr);
         |         ^~~
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/do_mounts.c:2:
   include/asm-generic/io.h: In function 'outb_p':
   arch/riscv/include/asm/io.h:59:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      59 | #define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:91:52: note: in definition of macro 'writeb_cpu'
      91 | #define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
         |                                                    ^
   include/asm-generic/io.h:603:2: note: in expansion of macro 'outb'
     603 |  outb(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outw_p':
   arch/riscv/include/asm/io.h:60:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      60 | #define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:92:76: note: in definition of macro 'writew_cpu'
      92 | #define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:611:2: note: in expansion of macro 'outw'
     611 |  outw(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outl_p':
   arch/riscv/include/asm/io.h:61:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      61 | #define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
      93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:619:2: note: in expansion of macro 'outl'
     619 |  outl(value, addr);
         |  ^~~~
--
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/rhashtable-types.h:15,
                    from include/linux/ipc.h:7,
                    from include/uapi/linux/sem.h:5,
                    from include/linux/sem.h:5,
                    from include/linux/sched.h:15,
                    from include/linux/uaccess.h:8,
                    from arch/riscv/kernel/signal.c:10:
   include/asm-generic/io.h: In function 'inb_p':
>> arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   arch/riscv/include/asm/io.h:55:65: note: each undeclared identifier is reported only once for each function it appears in
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/riscv/include/uapi/asm/byteorder.h:10,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/riscv/include/asm/bitops.h:202,
                    from include/linux/bitops.h:32,
                    from include/linux/kernel.h:11,
                    from include/asm-generic/bug.h:20,
                    from arch/riscv/include/asm/bug.h:83,
                    from include/linux/bug.h:5,
                    from include/linux/signal.h:5,
                    from arch/riscv/kernel/signal.c:9:
   include/asm-generic/io.h: In function 'inw_p':
   arch/riscv/include/asm/io.h:56:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:36:51: note: in definition of macro '__le16_to_cpu'
      36 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:56:47: note: in expansion of macro 'readw_cpu'
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:587:9: note: in expansion of macro 'inw'
     587 |  return inw(addr);
         |         ^~~
   include/asm-generic/io.h: In function 'inl_p':
   arch/riscv/include/asm/io.h:57:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
      34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:57:47: note: in expansion of macro 'readl_cpu'
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:595:9: note: in expansion of macro 'inl'
     595 |  return inl(addr);
         |         ^~~
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/rhashtable-types.h:15,
                    from include/linux/ipc.h:7,
                    from include/uapi/linux/sem.h:5,
                    from include/linux/sem.h:5,
                    from include/linux/sched.h:15,
                    from include/linux/uaccess.h:8,
                    from arch/riscv/kernel/signal.c:10:
   include/asm-generic/io.h: In function 'outb_p':
   arch/riscv/include/asm/io.h:59:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      59 | #define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:91:52: note: in definition of macro 'writeb_cpu'
      91 | #define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
         |                                                    ^
   include/asm-generic/io.h:603:2: note: in expansion of macro 'outb'
     603 |  outb(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outw_p':
   arch/riscv/include/asm/io.h:60:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      60 | #define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:92:76: note: in definition of macro 'writew_cpu'
      92 | #define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:611:2: note: in expansion of macro 'outw'
     611 |  outw(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outl_p':
   arch/riscv/include/asm/io.h:61:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      61 | #define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
      93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:619:2: note: in expansion of macro 'outl'
     619 |  outl(value, addr);
         |  ^~~~
   arch/riscv/kernel/signal.c: At top level:
..


vim +/PCI_IOBASE +55 arch/riscv/include/asm/io.h

fab957c11efe2f Palmer Dabbelt 2017-07-10  54  
ce246c444a08e0 Will Deacon    2019-02-22 @55  #define inb(c)		({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
ce246c444a08e0 Will Deacon    2019-02-22  56  #define inw(c)		({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
ce246c444a08e0 Will Deacon    2019-02-22  57  #define inl(c)		({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
fab957c11efe2f Palmer Dabbelt 2017-07-10  58  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 8401 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 15:19     ` kernel test robot
  0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-04-21 15:19 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 24340 bytes --]

Hi Niklas,

I love your patch! Yet something to improve:

[auto build test ERROR on soc/for-next]
[also build test ERROR on asm-generic/master v5.12-rc8 next-20210421]
[cannot apply to arc/for-next sparc-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: riscv-nommu_k210_defconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/05bc9b9b640336015712d139ebc42830d12a82da
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
        git checkout 05bc9b9b640336015712d139ebc42830d12a82da
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/main.c:17:
   include/asm-generic/io.h: In function 'inb_p':
>> arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   arch/riscv/include/asm/io.h:55:65: note: each undeclared identifier is reported only once for each function it appears in
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/riscv/include/uapi/asm/byteorder.h:10,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/riscv/include/asm/bitops.h:202,
                    from include/linux/bitops.h:32,
                    from include/linux/kernel.h:11,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from init/main.c:17:
   include/asm-generic/io.h: In function 'inw_p':
   arch/riscv/include/asm/io.h:56:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:36:51: note: in definition of macro '__le16_to_cpu'
      36 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:56:47: note: in expansion of macro 'readw_cpu'
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:587:9: note: in expansion of macro 'inw'
     587 |  return inw(addr);
         |         ^~~
   include/asm-generic/io.h: In function 'inl_p':
   arch/riscv/include/asm/io.h:57:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
      34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:57:47: note: in expansion of macro 'readl_cpu'
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:595:9: note: in expansion of macro 'inl'
     595 |  return inl(addr);
         |         ^~~
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/main.c:17:
   include/asm-generic/io.h: In function 'outb_p':
   arch/riscv/include/asm/io.h:59:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      59 | #define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:91:52: note: in definition of macro 'writeb_cpu'
      91 | #define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
         |                                                    ^
   include/asm-generic/io.h:603:2: note: in expansion of macro 'outb'
     603 |  outb(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outw_p':
   arch/riscv/include/asm/io.h:60:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      60 | #define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:92:76: note: in definition of macro 'writew_cpu'
      92 | #define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:611:2: note: in expansion of macro 'outw'
     611 |  outw(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outl_p':
   arch/riscv/include/asm/io.h:61:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      61 | #define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
      93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:619:2: note: in expansion of macro 'outl'
     619 |  outl(value, addr);
         |  ^~~~
   init/main.c: At top level:
   init/main.c:764:20: warning: no previous prototype for 'arch_post_acpi_subsys_init' [-Wmissing-prototypes]
     764 | void __init __weak arch_post_acpi_subsys_init(void) { }
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   init/main.c:776:20: warning: no previous prototype for 'mem_encrypt_init' [-Wmissing-prototypes]
     776 | void __init __weak mem_encrypt_init(void) { }
         |                    ^~~~~~~~~~~~~~~~
   init/main.c:778:20: warning: no previous prototype for 'poking_init' [-Wmissing-prototypes]
     778 | void __init __weak poking_init(void) { }
         |                    ^~~~~~~~~~~
--
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/do_mounts.c:2:
   include/asm-generic/io.h: In function 'inb_p':
>> arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   arch/riscv/include/asm/io.h:55:65: note: each undeclared identifier is reported only once for each function it appears in
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/riscv/include/uapi/asm/byteorder.h:10,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/riscv/include/asm/bitops.h:202,
                    from include/linux/bitops.h:32,
                    from include/linux/kernel.h:11,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from init/do_mounts.c:2:
   include/asm-generic/io.h: In function 'inw_p':
   arch/riscv/include/asm/io.h:56:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:36:51: note: in definition of macro '__le16_to_cpu'
      36 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:56:47: note: in expansion of macro 'readw_cpu'
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:587:9: note: in expansion of macro 'inw'
     587 |  return inw(addr);
         |         ^~~
   include/asm-generic/io.h: In function 'inl_p':
   arch/riscv/include/asm/io.h:57:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
      34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:57:47: note: in expansion of macro 'readl_cpu'
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:595:9: note: in expansion of macro 'inl'
     595 |  return inl(addr);
         |         ^~~
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from init/do_mounts.c:2:
   include/asm-generic/io.h: In function 'outb_p':
   arch/riscv/include/asm/io.h:59:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      59 | #define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:91:52: note: in definition of macro 'writeb_cpu'
      91 | #define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
         |                                                    ^
   include/asm-generic/io.h:603:2: note: in expansion of macro 'outb'
     603 |  outb(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outw_p':
   arch/riscv/include/asm/io.h:60:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      60 | #define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:92:76: note: in definition of macro 'writew_cpu'
      92 | #define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:611:2: note: in expansion of macro 'outw'
     611 |  outw(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outl_p':
   arch/riscv/include/asm/io.h:61:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      61 | #define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
      93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:619:2: note: in expansion of macro 'outl'
     619 |  outl(value, addr);
         |  ^~~~
--
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/rhashtable-types.h:15,
                    from include/linux/ipc.h:7,
                    from include/uapi/linux/sem.h:5,
                    from include/linux/sem.h:5,
                    from include/linux/sched.h:15,
                    from include/linux/uaccess.h:8,
                    from arch/riscv/kernel/signal.c:10:
   include/asm-generic/io.h: In function 'inb_p':
>> arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   arch/riscv/include/asm/io.h:55:65: note: each undeclared identifier is reported only once for each function it appears in
      55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:87:48: note: in definition of macro 'readb_cpu'
      87 | #define readb_cpu(c)  ({ u8  __r = __raw_readb(c); __r; })
         |                                                ^
   include/asm-generic/io.h:579:9: note: in expansion of macro 'inb'
     579 |  return inb(addr);
         |         ^~~
   In file included from include/linux/byteorder/little_endian.h:5,
                    from arch/riscv/include/uapi/asm/byteorder.h:10,
                    from include/asm-generic/bitops/le.h:6,
                    from arch/riscv/include/asm/bitops.h:202,
                    from include/linux/bitops.h:32,
                    from include/linux/kernel.h:11,
                    from include/asm-generic/bug.h:20,
                    from arch/riscv/include/asm/bug.h:83,
                    from include/linux/bug.h:5,
                    from include/linux/signal.h:5,
                    from arch/riscv/kernel/signal.c:9:
   include/asm-generic/io.h: In function 'inw_p':
   arch/riscv/include/asm/io.h:56:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:36:51: note: in definition of macro '__le16_to_cpu'
      36 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:56:47: note: in expansion of macro 'readw_cpu'
      56 | #define inw(c)  ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:587:9: note: in expansion of macro 'inw'
     587 |  return inw(addr);
         |         ^~~
   include/asm-generic/io.h: In function 'inl_p':
   arch/riscv/include/asm/io.h:57:65: error: 'PCI_IOBASE' undeclared (first use in this function)
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                                                 ^~~~~~~~~~
   include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro '__le32_to_cpu'
      34 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   arch/riscv/include/asm/io.h:57:47: note: in expansion of macro 'readl_cpu'
      57 | #define inl(c)  ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
         |                                               ^~~~~~~~~
   include/asm-generic/io.h:595:9: note: in expansion of macro 'inl'
     595 |  return inl(addr);
         |         ^~~
   In file included from arch/riscv/include/asm/clint.h:10,
                    from arch/riscv/include/asm/timex.h:15,
                    from include/linux/timex.h:65,
                    from include/linux/time32.h:13,
                    from include/linux/time.h:60,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/rhashtable-types.h:15,
                    from include/linux/ipc.h:7,
                    from include/uapi/linux/sem.h:5,
                    from include/linux/sem.h:5,
                    from include/linux/sched.h:15,
                    from include/linux/uaccess.h:8,
                    from arch/riscv/kernel/signal.c:10:
   include/asm-generic/io.h: In function 'outb_p':
   arch/riscv/include/asm/io.h:59:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      59 | #define outb(v,c) ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:91:52: note: in definition of macro 'writeb_cpu'
      91 | #define writeb_cpu(v, c) ((void)__raw_writeb((v), (c)))
         |                                                    ^
   include/asm-generic/io.h:603:2: note: in expansion of macro 'outb'
     603 |  outb(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outw_p':
   arch/riscv/include/asm/io.h:60:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      60 | #define outw(v,c) ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:92:76: note: in definition of macro 'writew_cpu'
      92 | #define writew_cpu(v, c) ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:611:2: note: in expansion of macro 'outw'
     611 |  outw(value, addr);
         |  ^~~~
   include/asm-generic/io.h: In function 'outl_p':
   arch/riscv/include/asm/io.h:61:57: error: 'PCI_IOBASE' undeclared (first use in this function)
      61 | #define outl(v,c) ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
         |                                                         ^~~~~~~~~~
   arch/riscv/include/asm/mmio.h:93:76: note: in definition of macro 'writel_cpu'
      93 | #define writel_cpu(v, c) ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
         |                                                                            ^
   include/asm-generic/io.h:619:2: note: in expansion of macro 'outl'
     619 |  outl(value, addr);
         |  ^~~~
   arch/riscv/kernel/signal.c: At top level:
..


vim +/PCI_IOBASE +55 arch/riscv/include/asm/io.h

fab957c11efe2f Palmer Dabbelt 2017-07-10  54  
ce246c444a08e0 Will Deacon    2019-02-22 @55  #define inb(c)		({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
ce246c444a08e0 Will Deacon    2019-02-22  56  #define inw(c)		({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
ce246c444a08e0 Will Deacon    2019-02-22  57  #define inl(c)		({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
fab957c11efe2f Palmer Dabbelt 2017-07-10  58  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 8401 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
  2021-04-21 15:19     ` kernel test robot
@ 2021-04-21 15:38       ` Niklas Schnelle
  -1 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 15:38 UTC (permalink / raw)
  To: kernel test robot, Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: kbuild-all, netdev, Nathan Chancellor, Nick Desaulniers,
	clang-built-linux, linux-arch, linux-kernel, linux-s390

On Wed, 2021-04-21 at 23:19 +0800, kernel test robot wrote:
> Hi Niklas,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on soc/for-next]
> [also build test ERROR on asm-generic/master v5.12-rc8 next-20210421]
> [cannot apply to arc/for-next sparc-next/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:    https://github.com/0day-ci/linux/commits/Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
> config: riscv-nommu_k210_defconfig (attached as .config)
> compiler: riscv64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/0day-ci/linux/commit/05bc9b9b640336015712d139ebc42830d12a82da
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
>         git checkout 05bc9b9b640336015712d139ebc42830d12a82da
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=riscv 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from arch/riscv/include/asm/clint.h:10,
>                     from arch/riscv/include/asm/timex.h:15,
>                     from include/linux/timex.h:65,
>                     from include/linux/time32.h:13,
>                     from include/linux/time.h:60,
>                     from include/linux/stat.h:19,
>                     from include/linux/module.h:13,
>                     from init/main.c:17:
>    include/asm-generic/io.h: In function 'inb_p':
> > > arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
>       55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })

Interesting, it looks to me like RISC-V sets PCI_IOBASE to 
((void __iomem *)PCI_IO_START) if running with an MMU but leaves it
undefined without an MMU. It does then use its own (broken?) inb/w/l()
macros with PCI_IOBASE 0 from asm-generic/io.h. What a mess ;-(


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 15:38       ` Niklas Schnelle
  0 siblings, 0 replies; 20+ messages in thread
From: Niklas Schnelle @ 2021-04-21 15:38 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2700 bytes --]

On Wed, 2021-04-21 at 23:19 +0800, kernel test robot wrote:
> Hi Niklas,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on soc/for-next]
> [also build test ERROR on asm-generic/master v5.12-rc8 next-20210421]
> [cannot apply to arc/for-next sparc-next/master]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:    https://github.com/0day-ci/linux/commits/Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
> config: riscv-nommu_k210_defconfig (attached as .config)
> compiler: riscv64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/0day-ci/linux/commit/05bc9b9b640336015712d139ebc42830d12a82da
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
>         git checkout 05bc9b9b640336015712d139ebc42830d12a82da
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=riscv 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from arch/riscv/include/asm/clint.h:10,
>                     from arch/riscv/include/asm/timex.h:15,
>                     from include/linux/timex.h:65,
>                     from include/linux/time32.h:13,
>                     from include/linux/time.h:60,
>                     from include/linux/stat.h:19,
>                     from include/linux/module.h:13,
>                     from init/main.c:17:
>    include/asm-generic/io.h: In function 'inb_p':
> > > arch/riscv/include/asm/io.h:55:65: error: 'PCI_IOBASE' undeclared (first use in this function)
>       55 | #define inb(c)  ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })

Interesting, it looks to me like RISC-V sets PCI_IOBASE to 
((void __iomem *)PCI_IO_START) if running with an MMU but leaves it
undefined without an MMU. It does then use its own (broken?) inb/w/l()
macros with PCI_IOBASE 0 from asm-generic/io.h. What a mess ;-(

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
  2021-04-21 11:17   ` Niklas Schnelle
@ 2021-04-21 16:59     ` kernel test robot
  -1 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-04-21 16:59 UTC (permalink / raw)
  To: Niklas Schnelle, Arnd Bergmann, Vineet Gupta, David S. Miller
  Cc: kbuild-all, netdev, Nathan Chancellor, Nick Desaulniers,
	clang-built-linux, linux-arch, linux-kernel, linux-s390

[-- Attachment #1: Type: text/plain, Size: 2761 bytes --]

Hi Niklas,

I love your patch! Yet something to improve:

[auto build test ERROR on soc/for-next]
[also build test ERROR on asm-generic/master v5.12-rc8 next-20210421]
[cannot apply to arc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: h8300-randconfig-r025-20210421 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/05bc9b9b640336015712d139ebc42830d12a82da
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
        git checkout 05bc9b9b640336015712d139ebc42830d12a82da
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=h8300 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/h8300/include/asm/io.h:63,
                    from drivers/input/gameport/lightning.c:13:
   include/asm-generic/io.h: In function '_inb':
>> include/asm-generic/io.h:465:2: error: implicit declaration of function 'WARN_ONCE' [-Werror=implicit-function-declaration]
     465 |  WARN_ONCE(1, "No I/O port support\n");
         |  ^~~~~~~~~
   cc1: some warnings being treated as errors


vim +/WARN_ONCE +465 include/asm-generic/io.h

   446	
   447	/*
   448	 * {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
   449	 * implemented on hardware that needs an additional delay for I/O accesses to
   450	 * take effect.
   451	 */
   452	
   453	#if !defined(inb) && !defined(_inb)
   454	#define _inb _inb
   455	static inline u8 _inb(unsigned long addr)
   456	{
   457	#ifdef PCI_IOBASE
   458		u8 val;
   459	
   460		__io_pbr();
   461		val = __raw_readb(PCI_IOBASE + addr);
   462		__io_par(val);
   463		return val;
   464	#else
 > 465		WARN_ONCE(1, "No I/O port support\n");
   466		return ~0;
   467	#endif
   468	}
   469	#endif
   470	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28679 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE
@ 2021-04-21 16:59     ` kernel test robot
  0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-04-21 16:59 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2833 bytes --]

Hi Niklas,

I love your patch! Yet something to improve:

[auto build test ERROR on soc/for-next]
[also build test ERROR on asm-generic/master v5.12-rc8 next-20210421]
[cannot apply to arc/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: h8300-randconfig-r025-20210421 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/05bc9b9b640336015712d139ebc42830d12a82da
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Niklas-Schnelle/asm-generic-io-h-Silence-Wnull-pointer-arithmetic-warning-on-PCI_IOBASE/20210421-192025
        git checkout 05bc9b9b640336015712d139ebc42830d12a82da
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=h8300 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/h8300/include/asm/io.h:63,
                    from drivers/input/gameport/lightning.c:13:
   include/asm-generic/io.h: In function '_inb':
>> include/asm-generic/io.h:465:2: error: implicit declaration of function 'WARN_ONCE' [-Werror=implicit-function-declaration]
     465 |  WARN_ONCE(1, "No I/O port support\n");
         |  ^~~~~~~~~
   cc1: some warnings being treated as errors


vim +/WARN_ONCE +465 include/asm-generic/io.h

   446	
   447	/*
   448	 * {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
   449	 * implemented on hardware that needs an additional delay for I/O accesses to
   450	 * take effect.
   451	 */
   452	
   453	#if !defined(inb) && !defined(_inb)
   454	#define _inb _inb
   455	static inline u8 _inb(unsigned long addr)
   456	{
   457	#ifdef PCI_IOBASE
   458		u8 val;
   459	
   460		__io_pbr();
   461		val = __raw_readb(PCI_IOBASE + addr);
   462		__io_par(val);
   463		return val;
   464	#else
 > 465		WARN_ONCE(1, "No I/O port support\n");
   466		return ~0;
   467	#endif
   468	}
   469	#endif
   470	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28679 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-04-21 17:00 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 11:17 [PATCH v3 0/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE Niklas Schnelle
2021-04-21 11:17 ` Niklas Schnelle
2021-04-21 11:17 ` [PATCH v3 1/3] sparc: explicitly set PCI_IOBASE to 0 Niklas Schnelle
2021-04-21 11:17   ` Niklas Schnelle
2021-04-21 11:17 ` [PATCH v3 2/3] ARC: io.h: Include asm/bug.h Niklas Schnelle
2021-04-21 11:17   ` Niklas Schnelle
2021-04-21 11:17 ` [PATCH v3 3/3] asm-generic/io.h: Silence -Wnull-pointer-arithmetic warning on PCI_IOBASE Niklas Schnelle
2021-04-21 11:17   ` Niklas Schnelle
2021-04-21 11:24   ` David Laight
2021-04-21 11:24     ` David Laight
2021-04-21 11:50     ` Niklas Schnelle
2021-04-21 11:50       ` Niklas Schnelle
2021-04-21 11:57       ` Arnd Bergmann
2021-04-21 11:57         ` Arnd Bergmann
2021-04-21 15:19   ` kernel test robot
2021-04-21 15:19     ` kernel test robot
2021-04-21 15:38     ` Niklas Schnelle
2021-04-21 15:38       ` Niklas Schnelle
2021-04-21 16:59   ` kernel test robot
2021-04-21 16:59     ` kernel test robot

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.