[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210510085339.1857696-3-schnelle@linux.ibm.com>
Date: Mon, 10 May 2021 10:53:38 +0200
From: Niklas Schnelle <schnelle@...ux.ibm.com>
To: Arnd Bergmann <arnd@...db.de>, Vineet Gupta <vgupta@...opsys.com>,
"David S. Miller" <davem@...emloft.net>
Cc: Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
clang-built-linux@...glegroups.com, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org,
linux-snps-arc@...ts.infradead.org, sparclinux@...r.kernel.org
Subject: [PATCH v5 2/3] risc-v: Use generic io.h helpers for nommu
From: Niklas Schnelle <niklas@...ani.de>
Without MMU support PCI_IOBASE is left undefined because PCI_IO_END is
VMEMMAP_START. Nevertheless the in*()/out*() helper macros are left
defined with uses of PCI_IOBASE.
At the moment this only compiles because asm-generic/io.h defines
PCI_IOBASE as 0 if it is undefined and so at macro expansion PCI_IOBASE
is defined. This leads to compilation errors when asm-generic/io.h is
changed to leave PCI_IOBASE undefined. More importantly it is currently
broken at runtime, as accessing a fixed I/O port number of an ISA device
on NOMMU RISC-V would turn into a NULL pointer dereference.
Instead only define the in*()/out*() helper macros with MMU support and
fall back to the asm-generic/io.h helper stubs otherwise.
Signed-off-by: Niklas Schnelle <niklas@...ani.de>
---
arch/riscv/include/asm/io.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h
index c025a746a148..31a8b98c0f13 100644
--- a/arch/riscv/include/asm/io.h
+++ b/arch/riscv/include/asm/io.h
@@ -23,12 +23,12 @@
#include <asm/mmio.h>
/*
- * I/O port access constants.
+ * I/O port access constants. Without MMU support leave PCI_IOBASE undefined
+ * and fall back to generic stubs for I/O access routines.
*/
#ifdef CONFIG_MMU
#define IO_SPACE_LIMIT (PCI_IO_SIZE - 1)
#define PCI_IOBASE ((void __iomem *)PCI_IO_START)
-#endif /* CONFIG_MMU */
/*
* Emulation routines for the port-mapped IO space used by some PCI drivers.
@@ -145,6 +145,7 @@ __io_writes_outs(writes, u64, q, __io_bw(), __io_aw())
__io_writes_outs(outs, u64, q, __io_pbr(), __io_paw())
#define outsq(addr, buffer, count) __outsq((void __iomem *)addr, buffer, count)
#endif
+#endif /* CONFIG_MMU */
#include <asm-generic/io.h>
--
2.25.1
Powered by blists - more mailing lists