On Wed, Jun 8, 2016 at 3:35 PM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote: > At the same time, can you kill __pci_mmap_set_pgprot() for powerpc. Can you please put your two patches and this attached one into to pci/next? Then I could send updated PCI: Let pci_mmap_page_range() take resource address. Thanks Yinghai
From: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> Subject: [PATCH] powerpc/PCI: Remove __pci_mmap_set_pgprot() PCI: Ignore write-combining when mapping I/O port space already handle the io port mmap path. For mmio mmap path, caller should state that correctly if write_combine is really needed. via proc path it should look like: mmap(fd, ...) # default is I/O, non-combining ioctl(fd, PCIIOC_WRITE_COMBINE, 1); # request write-combining ioctl(fd, PCIIOC_MMAP_IS_MEM); # request memory space mmap(fd, ...) sysfs path, it should use resource]?]_wc. Signed-off-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> --- arch/powerpc/kernel/pci-common.c | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) Index: linux-2.6/arch/powerpc/kernel/pci-common.c =================================================================== --- linux-2.6.orig/arch/powerpc/kernel/pci-common.c +++ linux-2.6/arch/powerpc/kernel/pci-common.c @@ -356,36 +356,6 @@ static struct resource *__pci_mmap_make_ } /* - * Set vm_page_prot of VMA, as appropriate for this architecture, for a pci - * device mapping. - */ -static pgprot_t __pci_mmap_set_pgprot(struct pci_dev *dev, struct resource *rp, - pgprot_t protection, - enum pci_mmap_state mmap_state, - int write_combine) -{ - - /* Write combine is always 0 on non-memory space mappings. On - * memory space, if the user didn't pass 1, we check for a - * "prefetchable" resource. This is a bit hackish, but we use - * this to workaround the inability of /sysfs to provide a write - * combine bit - */ - if (mmap_state != pci_mmap_mem) - write_combine = 0; - else if (write_combine == 0) { - if (rp->flags & IORESOURCE_PREFETCH) - write_combine = 1; - } - - /* XXX would be nice to have a way to ask for write-through */ - if (write_combine) - return pgprot_noncached_wc(protection); - else - return pgprot_noncached(protection); -} - -/* * This one is used by /dev/mem and fbdev who have no clue about the * PCI device, it tries to find the PCI device first and calls the * above routine @@ -458,9 +428,10 @@ int pci_mmap_page_range(struct pci_dev * return -EINVAL; vma->vm_pgoff = offset >> PAGE_SHIFT; - vma->vm_page_prot = __pci_mmap_set_pgprot(dev, rp, - vma->vm_page_prot, - mmap_state, write_combine); + if (write_combine) + vma->vm_page_prot = pgprot_noncached_wc(vma->vm_page_prot); + else + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); ret = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start, vma->vm_page_prot);
![]() |