Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1393949

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

From Yinghai Lu <yinghai@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address to resource
Date 2016-05-04 07:10 +0200
Message-ID <ruXep-5ZP-1@gated-at.bofh.it> (permalink)
References (4 earlier) <rsUE4-41Z-21@gated-at.bofh.it> <rtaSu-1U4-21@gated-at.bofh.it> <ruRsm-dq-9@gated-at.bofh.it> <ruT17-1Cp-3@gated-at.bofh.it> <ruTNv-2ke-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, May 3, 2016 at 6:25 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Wed, May 04, 2016 at 10:37:40AM +1000, Benjamin Herrenschmidt wrote:
>>
>> The problem tends to be old Xserver expectations...
>>
>> That stuff has been a can of worms over the years and we did things in
>> the kernel to work around X limitations. I'm not that keen on touching
>> /proc at all in that regard. Leave it there do what it does today, it's
>> a user visible ABI, don't change it.
>
> I did not propose changing any user-visible ABI.  To recap what I did
> propose:

I want to avoid introduce one strange pci_user_to_resource.

>
>   - The sysfs path uses offsets between 0 and BAR size on all arches.
>     It uses pci_resource_to_user() today, but I think it should not.
>
>   - The procfs path uses offsets of resource values (CPU physical
>     addresses) on most architectures, but uses something else, e.g.,
>     BAR values, on others.  pci_resource_to_user() does this
>     translation.  The procfs path does not use pci_resource_to_user()
>     today, but I think it should.

current powerpc pci_resource_to_user is strange:
it will return resource start for io mem.
but will return BAR (?) start for io port.

sparc pci_resource_to_user does return BAR value for iomem.

>
>   - This implies that pci_mmap_page_range() should deal with resource
>     values (CPU physical addresses), and proc_bus_pci_mmap() should do
>     any necessary arch-specific translation from BAR values to
>     resource values.

so will need one different version pci_user_to_resource.
and can not use pcibios_bus_to_resource directly, and will be another mess.

Can you reconsider to keep the pci_mmap_page_range still use BAR value
and only touch pci_mmap_fits() ?

like i suggested before, and it does not conflict with the patchset.

Subject: [PATCH] PCI: Fix pci_mmap_fits() with proc interface

Passed value is user address, so need to compare it with
user addr that is converted from dev resource.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/pci-sysfs.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/pci/pci-sysfs.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-sysfs.c
+++ linux-2.6/drivers/pci/pci-sysfs.c
@@ -969,15 +969,19 @@ void pci_remove_legacy_files(struct pci_
 int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,
           enum pci_mmap_api mmap_api)
 {
-    unsigned long nr, start, size, pci_start;
+    unsigned long nr, start, size;
+    resource_size_t pci_start = 0, pci_end;

     if (pci_resource_len(pdev, resno) == 0)
         return 0;
     nr = vma_pages(vma);
     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 (mmap_api == PCI_MMAP_PROCFS) {
+        pci_resource_to_user(pdev, resno, &pdev->resource[resno],
+                     &pci_start, &pci_end);
+        pci_start >>= PAGE_SHIFT;
+    }
     if (start >= pci_start && start < pci_start + size &&
             start + nr <= pci_start + size)
         return 1;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Bjorn Helgaas <helgaas@kernel.org> - 2016-04-28 16:00 +0200
  Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-04-29 09:20 +0200
    Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-04 01:00 +0200
      Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2016-05-04 02:40 +0200
        Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Bjorn Helgaas <helgaas@kernel.org> - 2016-05-04 03:30 +0200
          Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-04 07:10 +0200
            Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-04 08:00 +0200
              Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Bjorn Helgaas <helgaas@kernel.org> - 2016-05-04 17:20 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-04 20:50 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-05 02:30 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-05 18:00 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2016-05-06 00:10 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-06 03:00 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-06 06:20 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Bjorn Helgaas <helgaas@kernel.org> - 2016-05-06 20:30 +0200
                Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus address  to resource Yinghai Lu <yinghai@kernel.org> - 2016-05-10 08:20 +0200
        Re: [PATCH v11 04/60] sparc/PCI: Use correct offset for bus  address to resource David Miller <davem@davemloft.net> - 2016-05-04 06:20 +0200

csiph-web