Skip to content

Commit

Permalink
risc-v: Use generic io.h helpers for nommu
Browse files Browse the repository at this point in the history
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@komani.de>
  • Loading branch information
niklas88 authored and intel-lab-lkp committed May 10, 2021
1 parent 2a0df8f commit 606bc1a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/riscv/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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>

Expand Down

0 comments on commit 606bc1a

Please sign in to comment.