Skip to content

Commit

Permalink
RISC-V: Add PCIe I/O BAR memory mapping
Browse files Browse the repository at this point in the history
For legacy I/O BARs (non-MMIO BARs) to work correctly on RISC-V Linux,
we need to establish a reserved memory region for them, so that drivers
that wish to use the legacy I/O BARs can issue reads and writes against
a memory region that is mapped to the host PCIe controller's I/O BAR
mapping.

Signed-off-by: Yash Shah <[email protected]>
Signed-off-by: Paul Walmsley <[email protected]>
  • Loading branch information
yashshah7 authored and paul-walmsley-sifive committed Oct 28, 2019
1 parent f307307 commit 00a5bf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions arch/riscv/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <linux/types.h>
#include <asm/mmiowb.h>
#include <asm/pgtable.h>

extern void __iomem *ioremap(phys_addr_t offset, unsigned long size);

Expand Down Expand Up @@ -161,6 +162,12 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
#define writeq(v,c) ({ __io_bw(); writeq_cpu((v),(c)); __io_aw(); })
#endif

/*
* I/O port access constants.
*/
#define IO_SPACE_LIMIT (PCI_IO_SIZE - 1)
#define PCI_IOBASE ((void __iomem *)PCI_IO_START)

/*
* Emulation routines for the port-mapped IO space used by some PCI drivers.
* These are defined as being "fully synchronous", but also "not guaranteed to
Expand Down
7 changes: 6 additions & 1 deletion arch/riscv/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define _ASM_RISCV_PGTABLE_H

#include <linux/mmzone.h>
#include <linux/sizes.h>

#include <asm/pgtable-bits.h>

Expand Down Expand Up @@ -86,6 +87,7 @@ extern pgd_t swapper_pg_dir[];
#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
#define VMALLOC_END (PAGE_OFFSET - 1)
#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
#define PCI_IO_SIZE SZ_16M

/*
* Roughly size the vmemmap space to be large enough to fit enough
Expand All @@ -100,7 +102,10 @@ extern pgd_t swapper_pg_dir[];

#define vmemmap ((struct page *)VMEMMAP_START)

#define FIXADDR_TOP (VMEMMAP_START)
#define PCI_IO_END VMEMMAP_START
#define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE)
#define FIXADDR_TOP PCI_IO_START

#ifdef CONFIG_64BIT
#define FIXADDR_SIZE PMD_SIZE
#else
Expand Down

0 comments on commit 00a5bf3

Please sign in to comment.