From: Yash Shah <yash.shah@sifive.com>
To: "Paul Walmsley ( Sifive)" <paul.walmsley@g.sifive.com>,
"Palmer Dabbelt ( Sifive)" <palmer@g.sifive.com>,
"linux-riscv@lists.infradead.org"
<linux-riscv@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "aou@eecs.berkeley.edu" <aou@eecs.berkeley.edu>,
"will@kernel.org" <will@kernel.org>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"allison@lohutok.net" <allison@lohutok.net>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"Anup.Patel@wdc.com" <Anup.Patel@wdc.com>,
"rppt@linux.ibm.com" <rppt@linux.ibm.com>,
Greentime Hu <greentime.hu@g.sifive.com>,
"alex@ghiti.fr" <alex@ghiti.fr>,
"logang@deltatee.com" <logang@deltatee.com>,
"sorear2@gmail.com" <sorear2@gmail.com>,
Sachin Ghadi <sachin.ghadi@sifive.com>,
Yash Shah <yash.shah@sifive.com>
Subject: [PATCH] RISC-V: Add PCIe I/O BAR memory mapping
Date: Thu, 24 Oct 2019 09:14:16 +0000 [thread overview]
Message-ID: <1571908438-4802-1-git-send-email-yash.shah@sifive.com> (raw)
For I/O 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 I/O BARs
can issue reads and writes against a memory region that is mapped to the
host PCIe controller's I/O BAR MMIO mapping.
Signed-off-by: Yash Shah <yash.shah@sifive.com>
---
arch/riscv/include/asm/io.h | 7 +++++++
arch/riscv/include/asm/pgtable.h | 7 ++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h
index fc1189a..3ba4d93 100644
--- a/arch/riscv/include/asm/io.h
+++ b/arch/riscv/include/asm/io.h
@@ -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);
@@ -162,6 +163,12 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
#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
* be fully ordered with respect to other memory and I/O operations". We're
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 7fc5e4a..d78cc74 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -7,6 +7,7 @@
#define _ASM_RISCV_PGTABLE_H
#include <linux/mmzone.h>
+#include <linux/sizes.h>
#include <asm/pgtable-bits.h>
@@ -88,6 +89,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
@@ -102,7 +104,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
--
2.7.4
next reply other threads:[~2019-10-24 9:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 9:14 Yash Shah [this message]
2019-10-24 16:24 ` [PATCH] RISC-V: Add PCIe I/O BAR memory mapping Logan Gunthorpe
2019-10-24 16:51 ` Paul Walmsley
2019-10-24 17:07 ` Logan Gunthorpe
2019-10-25 6:35 ` Yash Shah
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1571908438-4802-1-git-send-email-yash.shah@sifive.com \
--to=yash.shah@sifive.com \
--cc=Anup.Patel@wdc.com \
--cc=alex@ghiti.fr \
--cc=allison@lohutok.net \
--cc=aou@eecs.berkeley.edu \
--cc=catalin.marinas@arm.com \
--cc=greentime.hu@g.sifive.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=logang@deltatee.com \
--cc=palmer@g.sifive.com \
--cc=paul.walmsley@g.sifive.com \
--cc=rppt@linux.ibm.com \
--cc=sachin.ghadi@sifive.com \
--cc=sorear2@gmail.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).