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


Groups > linux.kernel > #1425443 > unrolled thread

[PATCH v1 0/4] PCI: pci_resource_to_user() cleanups

Started byBjorn Helgaas <bhelgaas@google.com>
First post2016-06-17 22:20 +0200
Last post2016-06-17 22:20 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v1 0/4] PCI: pci_resource_to_user() cleanups Bjorn Helgaas <bhelgaas@google.com> - 2016-06-17 22:20 +0200
    [PATCH v1 4/4] sparc/PCI: Implement pci_resource_to_user() with  pcibios_resource_to_bus() Bjorn Helgaas <bhelgaas@google.com> - 2016-06-17 22:20 +0200

#1425443 — [PATCH v1 0/4] PCI: pci_resource_to_user() cleanups

FromBjorn Helgaas <bhelgaas@google.com>
Date2016-06-17 22:20 +0200
Subject[PATCH v1 0/4] PCI: pci_resource_to_user() cleanups
Message-ID<rL8pc-2GK-7@gated-at.bofh.it>
The /sys/devices/pci.../.../resource and /proc/bus/pci/devices files
contain PCI BAR addresses.  On most architectures these addresses are
"resource" values, e.g., CPU physical memory addresses or Linux I/O port
numbers.  These may be offset from the raw PCI values if there are multiple
PCI host bridges.

On others (microblaze, mips, powerpc, sparc) they are raw PCI values as
they would appear on the PCI bus.  pci_resource_to_user() converts from the
struct resource to whatever the arch wants to expose.  It's a no-op on
most arches.

The PCI core provides a pcibios_resource_to_bus() function that converts
from struct resource values to raw PCI bus values.  These patches use that
when possible instead of the arch-specific hand-coded equivalent.

These shouldn't fix or break anything unless I've made a mistake.

---

Bjorn Helgaas (4):
      PCI: Unify pci_resource_to_user() declarations
      microblaze/PCI: Implement pci_resource_to_user() with pcibios_resource_to_bus()
      powerpc/pci: Implement pci_resource_to_user() with pcibios_resource_to_bus()
      sparc/PCI: Implement pci_resource_to_user() with pcibios_resource_to_bus()


 arch/microblaze/include/asm/pci.h |    3 ---
 arch/microblaze/pci/pci-common.c  |   42 ++++++++++++-------------------------
 arch/mips/include/asm/pci.h       |   10 ---------
 arch/mips/pci/pci.c               |   10 +++++++++
 arch/powerpc/include/asm/pci.h    |    3 ---
 arch/powerpc/kernel/pci-common.c  |   42 ++++++++++++-------------------------
 arch/sparc/include/asm/pci_64.h   |    3 ---
 arch/sparc/kernel/pci.c           |   20 ++++++++++--------
 include/linux/pci.h               |    6 ++++-
 9 files changed, 54 insertions(+), 85 deletions(-)

[toc] | [next] | [standalone]


#1425449 — [PATCH v1 4/4] sparc/PCI: Implement pci_resource_to_user() with pcibios_resource_to_bus()

FromBjorn Helgaas <bhelgaas@google.com>
Date2016-06-17 22:20 +0200
Subject[PATCH v1 4/4] sparc/PCI: Implement pci_resource_to_user() with pcibios_resource_to_bus()
Message-ID<rL8pc-2GK-29@gated-at.bofh.it>
In reply to#1425443
"User" addresses are shown in /sys/devices/pci.../.../resource and
/proc/bus/pci/devices and used as mmap offsets for /proc/bus/pci/BB/DD.F
files.  On sparc, these are PCI bus addresses, i.e., raw BAR values.

Previously pci_resource_to_user() computed the user address by
subtracting either pbm->io_space.start or pbm->mem_space.start from the
resource start.

We've already told the PCI core about those offsets here:

  pci_scan_one_pbm()
    pci_add_resource_offset(&resources, &pbm->io_space, pbm->io_space.start);
    pci_add_resource_offset(&resources, &pbm->mem_space, pbm->mem_space.start);
    pci_add_resource_offset(&resources, &pbm->mem64_space, pbm->mem_space.start);

so pcibios_resource_to_bus() knows how to do that translation.

No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
---
 arch/sparc/kernel/pci.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index c2b202d..9c1878f 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -986,16 +986,18 @@ void pci_resource_to_user(const struct pci_dev *pdev, int bar,
 			  const struct resource *rp, resource_size_t *start,
 			  resource_size_t *end)
 {
-	struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller;
-	unsigned long offset;
-
-	if (rp->flags & IORESOURCE_IO)
-		offset = pbm->io_space.start;
-	else
-		offset = pbm->mem_space.start;
+	struct pci_bus_region region;
 
-	*start = rp->start - offset;
-	*end = rp->end - offset;
+	/*
+	 * "User" addresses are shown in /sys/devices/pci.../.../resource
+	 * and /proc/bus/pci/devices and used as mmap offsets for
+	 * /proc/bus/pci/BB/DD.F files (see proc_bus_pci_mmap()).
+	 *
+	 * On sparc, these are PCI bus addresses, i.e., raw BAR values.
+	 */
+	pcibios_resource_to_bus(pdev->bus, &region, (struct resource *) rp);
+	*start = region.start;
+	*end = region.end;
 }
 
 void pcibios_set_master(struct pci_dev *dev)

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web