From: David Woodhouse <dwmw2@infradead.org> To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com> Subject: [PATCH 1/3] arm64: enable pci resource mapping using sysfs Date: Wed, 15 Mar 2017 17:17:46 +0000 [thread overview] Message-ID: <1489598266.86622.12.camel@infradead.org> (raw) [-- Attachment #1.1: Type: text/plain, Size: 1930 bytes --] From: Brijesh Singh <brijess@amazon.com> To support pci resource mapping from userspace, pci_mmap_page_range implementation must be done for that platform. This support was broken for arm64. This patch copies existing implementation from arm to enable sysfs mmap. [dwmw2: Add WC support] Reviewed-by: Erik Quanstrom <quanstro@amazon.com> Reviewed-by: Anthony Liguori <aliguori@amazon.com> Signed-off-by: Brijesh Singh <brijess@amazon.com> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> --- arch/arm64/include/asm/pci.h | 4 ++++ arch/arm64/kernel/pci.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h index b9a7ba9..f73734f 100644 --- a/arch/arm64/include/asm/pci.h +++ b/arch/arm64/include/asm/pci.h @@ -37,5 +37,9 @@ static inline int pci_proc_domain(struct pci_bus *bus) } #endif /* CONFIG_PCI */ +#define HAVE_PCI_MMAP +extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, + enum pci_mmap_state mmap_state, int write_combine); + #endif /* __KERNEL__ */ #endif /* __ASM_PCI_H */ diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 4f0e3eb..a9b6542 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -228,3 +228,22 @@ void pcibios_remove_bus(struct pci_bus *bus) } #endif + +int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, + enum pci_mmap_state mmap_state, int write_combine) +{ + if (mmap_state == pci_mmap_io) + return -EINVAL; + + if (write_combine) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + else + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) + return -EAGAIN; + + return 0; +} -- dwmw2 [-- Attachment #1.2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 4938 bytes --] [-- Attachment #2: Type: text/plain, Size: 176 bytes --] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: David Woodhouse <dwmw2@infradead.org> To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com> Subject: [PATCH 1/3] arm64: enable pci resource mapping using sysfs Date: Wed, 15 Mar 2017 17:17:46 +0000 [thread overview] Message-ID: <1489598266.86622.12.camel@infradead.org> (raw) Message-ID: <20170315171746.lqa4L-Q1Nkwu_Q3EoEnFW7s-j-2wx8yf0ENjhCx4XYw@z> (raw) [-- Attachment #1: Type: text/plain, Size: 1930 bytes --] From: Brijesh Singh <brijess@amazon.com> To support pci resource mapping from userspace, pci_mmap_page_range implementation must be done for that platform. This support was broken for arm64. This patch copies existing implementation from arm to enable sysfs mmap. [dwmw2: Add WC support] Reviewed-by: Erik Quanstrom <quanstro@amazon.com> Reviewed-by: Anthony Liguori <aliguori@amazon.com> Signed-off-by: Brijesh Singh <brijess@amazon.com> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> --- arch/arm64/include/asm/pci.h | 4 ++++ arch/arm64/kernel/pci.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h index b9a7ba9..f73734f 100644 --- a/arch/arm64/include/asm/pci.h +++ b/arch/arm64/include/asm/pci.h @@ -37,5 +37,9 @@ static inline int pci_proc_domain(struct pci_bus *bus) } #endif /* CONFIG_PCI */ +#define HAVE_PCI_MMAP +extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, + enum pci_mmap_state mmap_state, int write_combine); + #endif /* __KERNEL__ */ #endif /* __ASM_PCI_H */ diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 4f0e3eb..a9b6542 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -228,3 +228,22 @@ void pcibios_remove_bus(struct pci_bus *bus) } #endif + +int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, + enum pci_mmap_state mmap_state, int write_combine) +{ + if (mmap_state == pci_mmap_io) + return -EINVAL; + + if (write_combine) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + else + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) + return -EAGAIN; + + return 0; +} -- dwmw2 [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 4938 bytes --]
next reply other threads:[~2017-03-15 17:17 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-03-15 17:17 David Woodhouse [this message] 2017-03-15 17:17 ` [PATCH 1/3] arm64: enable pci resource mapping using sysfs David Woodhouse 2017-03-15 17:54 ` Mark Rutland 2017-03-15 17:54 ` Mark Rutland 2017-03-15 19:18 ` David Woodhouse 2017-03-20 10:24 ` Will Deacon 2017-03-20 10:24 ` Will Deacon 2017-03-20 10:28 ` David Woodhouse 2017-03-20 10:28 ` David Woodhouse
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=1489598266.86622.12.camel@infradead.org \ --to=dwmw2@infradead.org \ --cc=catalin.marinas@arm.com \ --cc=linux-arch@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=will.deacon@arm.com \ /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: linkBe 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).