Skip to content

Commit 00a5bf3

Browse files
yashshah7paul-walmsley-sifive
authored andcommitted
RISC-V: Add PCIe I/O BAR memory mapping
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]>
1 parent f307307 commit 00a5bf3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

arch/riscv/include/asm/io.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <linux/types.h>
1515
#include <asm/mmiowb.h>
16+
#include <asm/pgtable.h>
1617

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

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

165+
/*
166+
* I/O port access constants.
167+
*/
168+
#define IO_SPACE_LIMIT (PCI_IO_SIZE - 1)
169+
#define PCI_IOBASE ((void __iomem *)PCI_IO_START)
170+
164171
/*
165172
* Emulation routines for the port-mapped IO space used by some PCI drivers.
166173
* These are defined as being "fully synchronous", but also "not guaranteed to

arch/riscv/include/asm/pgtable.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define _ASM_RISCV_PGTABLE_H
88

99
#include <linux/mmzone.h>
10+
#include <linux/sizes.h>
1011

1112
#include <asm/pgtable-bits.h>
1213

@@ -86,6 +87,7 @@ extern pgd_t swapper_pg_dir[];
8687
#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
8788
#define VMALLOC_END (PAGE_OFFSET - 1)
8889
#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
90+
#define PCI_IO_SIZE SZ_16M
8991

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

101103
#define vmemmap ((struct page *)VMEMMAP_START)
102104

103-
#define FIXADDR_TOP (VMEMMAP_START)
105+
#define PCI_IO_END VMEMMAP_START
106+
#define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE)
107+
#define FIXADDR_TOP PCI_IO_START
108+
104109
#ifdef CONFIG_64BIT
105110
#define FIXADDR_SIZE PMD_SIZE
106111
#else

0 commit comments

Comments
 (0)