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
From: Niklas Schnelle <[email protected]>
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 <[email protected]>
---
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
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 <[email protected]>
---
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