diff options
author | David Woodhouse <dwmw@amazon.co.uk> | 2017-04-12 14:26:08 +0200 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2017-04-20 15:47:47 +0200 |
commit | 2bea36fd1af440e1853e431459a0bf929266cd52 (patch) | |
tree | 00c651b65d825c50f397cefb8aab7922b727d8f9 /drivers/pci/mmap.c | |
parent | x86/PCI: Use generic pci_mmap_resource_range() (diff) | |
download | linux-2bea36fd1af440e1853e431459a0bf929266cd52.tar.xz linux-2bea36fd1af440e1853e431459a0bf929266cd52.zip |
PCI: Add I/O BAR support to generic pci_mmap_resource_range()
This will need to call into an arch-provided pci_iobar_pfn() function.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/mmap.c')
-rw-r--r-- | drivers/pci/mmap.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/pci/mmap.c b/drivers/pci/mmap.c index b7aca9c89c31..9a5e5a9055eb 100644 --- a/drivers/pci/mmap.c +++ b/drivers/pci/mmap.c @@ -48,9 +48,7 @@ int pci_mmap_resource_range(struct pci_dev *pdev, int bar, enum pci_mmap_state mmap_state, int write_combine) { unsigned long size; - - if (mmap_state == pci_mmap_io) - return -EINVAL; + int ret; size = ((pci_resource_len(pdev, bar) - 1) >> PAGE_SHIFT) + 1; if (vma->vm_pgoff + vma_pages(vma) > size) @@ -61,7 +59,13 @@ int pci_mmap_resource_range(struct pci_dev *pdev, int bar, else vma->vm_page_prot = pgprot_device(vma->vm_page_prot); - vma->vm_pgoff += (pci_resource_start(pdev, bar) >> PAGE_SHIFT); + if (mmap_state == pci_mmap_io) { + ret = pci_iobar_pfn(pdev, bar, vma); + if (ret) + return ret; + } else + vma->vm_pgoff += (pci_resource_start(pdev, bar) >> PAGE_SHIFT); + vma->vm_ops = &pci_phys_vm_ops; return io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, |