From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM64/PCI: Allow userspace to mmap PCI resources
Date: Wed, 3 May 2017 16:58:58 +0100 [thread overview]
Message-ID: <20170503155858.GA11986@red-moon> (raw)
In-Reply-To: <1493826538-23785-1-git-send-email-Bharat.Bhushan@nxp.com>
On Wed, May 03, 2017 at 09:18:58PM +0530, Bharat Bhushan wrote:
> This patch allows user-space to mmap PCI resources. This
> patch is inline to arm32 bit implementation.
>
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
> ---
> arch/arm64/include/asm/pci.h | 4 ++++
> arch/arm64/kernel/pci.c | 19 +++++++++++++++++++
> 2 files changed, 23 insertions(+)
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/arm64/include/asm/pci.h?id=f719582435afe9c7985206e42d804ea6aa315d33
>
> diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
> index b9a7ba9..8a18915 100644
> --- a/arch/arm64/include/asm/pci.h
> +++ b/arch/arm64/include/asm/pci.h
> @@ -31,6 +31,10 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
> return -ENODEV;
> }
>
> +#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);
> static inline int pci_proc_domain(struct pci_bus *bus)
> {
> return 1;
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index ce20f4c..2e45a83 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -97,6 +97,25 @@ int pcibios_check_service_irqs(struct pci_dev *dev, int *irqs, int mask)
> return count;
> }
>
> +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;
> +
> + /*
> + * Mark this as IO
> + */
> + 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;
> +}
> +
> /*
> * raw_pci_read/write - Platform-specific PCI config space access.
> */
> --
> 1.9.3
>
next prev parent reply other threads:[~2017-05-03 15:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 15:48 [PATCH] ARM64/PCI: Allow userspace to mmap PCI resources Bharat Bhushan
2017-05-03 15:58 ` Lorenzo Pieralisi [this message]
2017-05-03 16:00 ` Bharat Bhushan
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=20170503155858.GA11986@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=linux-arm-kernel@lists.infradead.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