Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address to resource

From: Bjorn Helgaas
Date: Fri May 06 2016 - 14:26:10 EST


On Thu, May 05, 2016 at 08:53:14AM -0700, Yinghai Lu wrote:
> On Wed, May 4, 2016 at 5:25 PM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
> > On Wed, May 4, 2016 at 11:46 AM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
> >> On Wed, May 4, 2016 at 8:17 AM, Bjorn Helgaas <helgaas@xxxxxxxxxx> wrote:
> >>> My goal is to make pci_mmap_resource() and proc_bus_pci_mmap() look
> >>> very similar, e.g.,
> >>>
> >>> /* locate resource */
> >>> pci_user_to_resource() # only in proc_bus_pci_mmap()
> >>> if (!pci_mmap_fits()) {
> >>> WARN(...);
> >>> return -EINVAL;
> >>> }
> >>> pci_mmap_page_range();
> >
>
> v3, that have more change to pass *res to make powerpc prot setting simple.

This looks corrupted. On v4.6-rc2:

$ stg import -M m/yh3
Checking for changes in the working directory ... done
Importing patch "re-patch-v11-04-60-sparc-pci" ... fatal: corrupt patch at line 266
stg import: Diff does not apply cleanly

> ...
> Subject: [RFC PATCH v3 2/2] PCI: Let pci_mmap_page_range() take resource addr
>
> In 8c05cd08a7 ("PCI: fix offset check for sysfs mmapped files"), try
> to check exposed value with resource start/end in proc mmap path.
> | start = vma->vm_pgoff;
> | size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1;
> | pci_start = (mmap_api == PCI_MMAP_PROCFS) ?
> | pci_resource_start(pdev, resno) >> PAGE_SHIFT : 0;
> | if (start >= pci_start && start < pci_start + size &&
> | start + nr <= pci_start + size)
>
> That would break sparc that exposed value is still BAR value.
>
> In the patch:
> 1. in proc path: proc_bus_pci_mmap, try convert back to resource
> before calling pci_mmap_page_range
> 2. in sysfs path: pci_mmap_resource will just offset with resource start.
> 3. all pci_mmap_page_range will all have vma->vm_pgoff with in resource
> range instead of BAR value.
> 4. remove __pci_mmap_make_offset, as the checking is done
> in pci_mmap_fits().

This looks like it could possibly be split into several patches. I
think it's too big to apply as-is.

I'm not sure what bug this is fixing or what improvement it's making.