1. 20 11月, 2015 1 次提交
  2. 07 11月, 2015 2 次提交
  3. 25 9月, 2015 1 次提交
  4. 16 9月, 2015 1 次提交
    • B
      PCI: Revert "PCI: Call pci_read_bridge_bases() from core instead of arch code" · 237865f1
      Bjorn Helgaas 提交于
      Revert dff22d20 ("PCI: Call pci_read_bridge_bases() from core instead
      of arch code").
      
      Reading PCI bridge windows is not arch-specific in itself, but there is PCI
      core code that doesn't work correctly if we read them too early.  For
      example, Hannes found this case on an ARM Freescale i.mx6 board:
      
        pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff]
        pci 0000:00:00.0: PCI bridge to [bus 01-ff]
        pci 0000:00:00.0: BAR 8: no space for [mem size 0x01000000] (mem window)
        pci 0000:01:00.0: BAR 2: failed to assign [mem size 0x00200000]
        pci 0000:01:00.0: BAR 1: failed to assign [mem size 0x00004000]
        pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x00000100]
      
      The 00:00.0 mem window needs to be at least 3MB: the 01:00.0 device needs
      0x204100 of space, and mem windows are megabyte-aligned.
      
      Bus sizing can increase a bridge window size, but never *decrease* it (see
      d65245c3 ("PCI: don't shrink bridge resources")).  Prior to
      dff22d20, ARM didn't read bridge windows at all, so the "original size"
      was zero, and we assigned a 3MB window.
      
      After dff22d20, we read the bridge windows before sizing the bus.  The
      firmware programmed a 16MB window (size 0x01000000) in 00:00.0, and since
      we never decrease the size, we kept 16MB even though we only needed 3MB.
      But 16MB doesn't fit in the host bridge aperture, so we failed to assign
      space for the window and the downstream devices.
      
      I think this is a defect in the PCI core: we shouldn't rely on the firmware
      to assign sensible windows.
      
      Ray reported a similar problem, also on ARM, with Broadcom iProc.
      
      Issues like this are too hard to fix right now, so revert dff22d20.
      Reported-by: NHannes <oe5hpm@gmail.com>
      Reported-by: NRay Jui <rjui@broadcom.com>
      Link: http://lkml.kernel.org/r/CAAa04yFQEUJm7Jj1qMT57-LG7ZGtnhNDBe=PpSRa70Mj+XhW-A@mail.gmail.com
      Link: http://lkml.kernel.org/r/55F75BB8.4070405@broadcom.comSigned-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      Acked-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      237865f1
  5. 26 8月, 2015 1 次提交
    • G
      PCI: Make pci_msi_setup_pci_dev() non-static for use by arch code · 22b6839b
      Guilherme G. Piccoli 提交于
      Commit 1851617c ("PCI/MSI: Disable MSI at enumeration even if kernel
      doesn't support MSI") changed the location of the code that initialises
      dev->msi_cap/msix_cap and then disables MSI/MSI-X interrupts at PCI
      probe time in devices that have this flag set. It moved the code from
      pci_msi_init_pci_dev() to a new function named pci_msi_setup_pci_dev(),
      called by pci_setup_device().
      
      The pseries PCI probing code does not call pci_setup_device(), so since
      the aforementioned commit the function pci_msi_setup_pci_dev() is not
      called and MSI/MSI-X interrupts are left enabled. Additionally because
      dev->msi_cap/msix_cap are not initialised no driver can ever enable
      MSI/MSI-X.
      
      To fix this, the pseries PCI probe should manually call
      pci_msi_setup_pci_dev(), so this patch makes it non-static.
      
      Fixes: 1851617c ("PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI")
      [mpe: Update change log to mention dev->msi_cap/msix_cap]
      Signed-off-by: NGuilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      22b6839b
  6. 24 8月, 2015 1 次提交
    • K
      PCI: Set MPS to match upstream bridge · 27d868b5
      Keith Busch 提交于
      Firmware typically configures the PCIe fabric with a consistent Max Payload
      Size setting based on the devices present at boot.  A hot-added device
      typically has the power-on default MPS setting (128 bytes), which may not
      match the fabric.
      
      The previous Linux default, in the absence of any "pci=pcie_bus_*" options,
      was PCIE_BUS_TUNE_OFF, in which we never touch MPS, even for hot-added
      devices.
      
      Add a new default setting, PCIE_BUS_DEFAULT, in which we make sure every
      device's MPS setting matches the upstream bridge.  This makes it more
      likely that a hot-added device will work in a system with optimized MPS
      configuration.
      
      Note that if we hot-add a device that only supports 128-byte MPS, it still
      likely won't work because we don't reconfigure the rest of the fabric.
      Booting with "pci=pcie_bus_peer2peer" is a workaround for this because it
      sets MPS to 128 for everything.
      
      [bhelgaas: changelog, new default, rework for pci_configure_device() path]
      Tested-by: NKeith Busch <keith.busch@intel.com>
      Tested-by: NJordan Hargrave <jharg93@gmail.com>
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      27d868b5
  7. 21 8月, 2015 2 次提交
  8. 20 8月, 2015 1 次提交
    • Y
      PCI: Tolerate hierarchies with no Root Port · b35b1df5
      Yijing Wang 提交于
      We should not assume any particular hardware topology.  Commit d0751b98
      ("PCI: Add dev->has_secondary_link to track downstream PCIe links") relied
      on the assumption that every PCIe hierarchy is rooted at a Root Port.  But
      we can't rely on any assumption about what hardware we will find; we just
      have to deal with the world as it is.
      
      On some platforms, PCIe devices (endpoints, switch upstream ports, etc.)
      appear directly on the root bus, and there is no Root Port in the PCI bus
      hierarchy.  For example, Meelis observed these top-level devices on a
      Sparc V245:
      
        0000:02:00.0 PCI bridge to [bus 03-0d]    Switch Upstream Port
        0001:02:00.0 PCI bridge to [bus 03]       PCIe to PCI/PCI-X Bridge
      
      These devices *look* like they have links going upstream, but there really
      are no upstream devices.
      
      In set_pcie_port_type(), we used the parent device to figure out which side
      of a switch port has a link, so if the parent device did not exist, we
      dereferenced a NULL parent pointer.
      
      Check whether the parent device exists before dereferencing it.
      
      Meelis observed this oops on Sparc V245 and T2000.  Ben Herrenschmidt says
      this is also possible on IBM PowerVM guests on PowerPC.
      
      [bhelgaas: changelog, comment]
      Link: http://lkml.kernel.org/r/alpine.LRH.2.20.1508122118210.18637@math.ut.eeReported-by: NMeelis Roos <mroos@linux.ee>
      Tested-by: NMeelis Roos <mroos@linux.ee>
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      b35b1df5
  9. 14 8月, 2015 1 次提交
    • B
      PCI: Allocate ATS struct during enumeration · edc90fee
      Bjorn Helgaas 提交于
      Previously, we allocated pci_ats structures when an IOMMU driver called
      pci_enable_ats().  An SR-IOV VF shares the STU setting with its PF, so when
      enabling ATS on the VF, we allocated a pci_ats struct for the PF if it
      didn't already have one.  We held the sriov->lock to serialize threads
      concurrently enabling ATS on several VFS so only one would allocate the PF
      pci_ats.
      
      Gregor reported a deadlock here:
      
        pci_enable_sriov
          sriov_enable
            virtfn_add
              mutex_lock(dev->sriov->lock)      # acquire sriov->lock
              pci_device_add
                device_add
                  BUS_NOTIFY_ADD_DEVICE notifier chain
                  iommu_bus_notifier
                    amd_iommu_add_device        # iommu_ops.add_device
                      init_iommu_group
                        iommu_group_get_for_dev
                          iommu_group_add_device
                            __iommu_attach_device
                              amd_iommu_attach_device  # iommu_ops.attach_device
                                attach_device
                                  pci_enable_ats
                                    mutex_lock(dev->sriov->lock) # deadlock
      
      There's no reason to delay allocating the pci_ats struct, and if we
      allocate it for each device at enumeration-time, there's no need for
      locking in pci_enable_ats().
      
      Allocate pci_ats struct during enumeration, when we initialize other
      capabilities.
      
      Note that this implementation requires ATS to be enabled on the PF first,
      before on any of the VFs because the PF controls the STU for all the VFs.
      
      Link: http://permalink.gmane.org/gmane.linux.kernel.iommu/9433Reported-by: NGregor Dick <gdick@solarflare.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NJoerg Roedel <jroedel@suse.de>
      edc90fee
  10. 11 8月, 2015 1 次提交
    • D
      cleanup IORESOURCE_CACHEABLE vs ioremap() · 92b19ff5
      Dan Williams 提交于
      Quoting Arnd:
          I was thinking the opposite approach and basically removing all uses
          of IORESOURCE_CACHEABLE from the kernel. There are only a handful of
          them.and we can probably replace them all with hardcoded
          ioremap_cached() calls in the cases they are actually useful.
      
      All existing usages of IORESOURCE_CACHEABLE call ioremap() instead of
      ioremap_nocache() if the resource is cacheable, however ioremap() is
      uncached by default. Clearly none of the existing usages care about the
      cacheability. Particularly devm_ioremap_resource() never worked as
      advertised since it always fell back to plain ioremap().
      
      Clean this up as the new direction we want is to convert
      ioremap_<type>() usages to memremap(..., flags).
      Suggested-by: NArnd Bergmann <arnd@arndb.de>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      92b19ff5
  11. 31 7月, 2015 1 次提交
  12. 30 7月, 2015 2 次提交
  13. 23 7月, 2015 1 次提交
    • L
      PCI: Call pci_read_bridge_bases() from core instead of arch code · dff22d20
      Lorenzo Pieralisi 提交于
      When we scan a PCI bus, we read PCI-PCI bridge window registers with
      pci_read_bridge_bases() so we can validate the resource hierarchy.  Most
      architectures call pci_read_bridge_bases() from pcibios_fixup_bus(), but
      PCI-PCI bridges are not arch-specific, so this doesn't need to be in
      arch-specific code.
      
      Call pci_read_bridge_bases() directly from the PCI core instead of from
      arch code.
      
      For alpha and mips, we now call pci_read_bridge_bases() always; previously
      we only called it if PCI_PROBE_ONLY was set.
      
      [bhelgaas: changelog]
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: Ralf Baechle <ralf@linux-mips.org>
      CC: James E.J. Bottomley <jejb@parisc-linux.org>
      CC: Michael Ellerman <mpe@ellerman.id.au>
      CC: Bjorn Helgaas <bhelgaas@google.com>
      CC: Richard Henderson <rth@twiddle.net>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: David Howells <dhowells@redhat.com>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Tony Luck <tony.luck@intel.com>
      CC: David S. Miller <davem@davemloft.net>
      CC: Ingo Molnar <mingo@redhat.com>
      CC: Guenter Roeck <linux@roeck-us.net>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Chris Zankel <chris@zankel.net>
      dff22d20
  14. 15 7月, 2015 1 次提交
    • B
      PCI: Shift PCI_CLASS_NOT_DEFINED consistently with other classes · 2b4aed1d
      Bjorn Helgaas 提交于
      The PCI class in dev->class is a three-byte value comprising a base class,
      sub-class, and interface type.  PCI_CLASS_NOT_DEFINED includes the base
      class and sub-class, but not the interface type, so it should be shifted to
      make space for the interface.  It happens that PCI_CLASS_NOT_DEFINED is
      zero, so it doesn't matter in the end, but we should still use it
      consistently with other class definitions.
      
      Treat PCI_CLASS_NOT_DEFINED as a base class/sub-class value that should
      appear in bits 8-23 of dev->class.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      2b4aed1d
  15. 13 6月, 2015 1 次提交
  16. 30 5月, 2015 2 次提交
  17. 22 5月, 2015 1 次提交
    • Y
      PCI: Add dev->has_secondary_link to track downstream PCIe links · d0751b98
      Yijing Wang 提交于
      A PCIe Port is an interface to a Link.  A Root Port is a PCI-PCI bridge in
      a Root Complex and has a Link on its secondary (downstream) side.  For
      other Ports, the Link may be on either the upstream (closer to the Root
      Complex) or downstream side of the Port.
      
      The usual topology has a Root Port connected to an Upstream Port.  We
      previously assumed this was the only possible topology, and that a
      Downstream Port's Link was always on its downstream side, like this:
      
                        +---------------------+
        +------+        |          Downstream |
        | Root |        | Upstream       Port +--Link--
        | Port +--Link--+ Port                |
        +------+        |          Downstream |
                        |                Port +--Link--
                        +---------------------+
      
      But systems do exist (see URL below) where the Root Port is connected to a
      Downstream Port.  In this case, a Downstream Port's Link may be on either
      the upstream or downstream side:
      
                        +---------------------+
        +------+        |            Upstream |
        | Root |        | Downstream     Port +--Link--
        | Port +--Link--+ Port                |
        +------+        |          Downstream |
                        |                Port +--Link--
                        +---------------------+
      
      We can't use the Port type to determine which side the Link is on, so add a
      bit in struct pci_dev to keep track.
      
      A Root Port's Link is always on the Port's secondary side.  A component
      (Endpoint or Port) on the other end of the Link obviously has the Link on
      its upstream side.  If that component is a Port, it is part of a Switch or
      a Bridge.  A Bridge has a PCI or PCI-X bus on its secondary side, not a
      Link.  The internal bus of a Switch connects the Port to another Port whose
      Link is on the downstream side.
      
      [bhelgaas: changelog, comment, cache "type", use if/else]
      Link: http://lkml.kernel.org/r/54EB81B2.4050904@pobox.com
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=94361Suggested-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      d0751b98
  18. 07 5月, 2015 1 次提交
    • M
      PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI · 1851617c
      Michael S. Tsirkin 提交于
      If we enable MSI, then kexec a new kernel, the new kernel may receive MSIs
      it is not prepared for.  Commit d5dea7d9 ("PCI: msi: Disable msi
      interrupts when we initialize a pci device") prevents this, but only if the
      new kernel is built with CONFIG_PCI_MSI=y.
      
      Move the "disable MSI" functionality from drivers/pci/msi.c to a new
      pci_msi_setup_pci_dev() in drivers/pci/probe.c so we can disable MSIs when
      we enumerate devices even if the kernel doesn't include full MSI support.
      
      [bhelgaas: changelog, disable MSIs in pci_setup_device(), put
      pci_msi_setup_pci_dev() at its final destination]
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      1851617c
  19. 09 4月, 2015 1 次提交
  20. 19 3月, 2015 1 次提交
    • Y
      PCI: Assign resources before drivers claim devices (pci_scan_root_bus()) · b97ea289
      Yijing Wang 提交于
      Previously, pci_scan_root_bus() created a root PCI bus, enumerated the
      devices on it, and called pci_bus_add_devices(), which made the devices
      available for drivers to claim them.
      
      Most callers assigned resources to devices after pci_scan_root_bus()
      returns, which may be after drivers have claimed the devices.  This is
      incorrect; the PCI core should not change device resources while a driver
      is managing the device.
      
      Remove pci_bus_add_devices() from pci_scan_root_bus() and do it after any
      resource assignment in the callers.
      
      Note that ARM's pci_common_init_dev() already called pci_bus_add_devices()
      after pci_scan_root_bus(), so we only need to remove the first call:
      
        pci_common_init_dev
          pcibios_init_hw
            pci_scan_root_bus
              pci_bus_add_devices        # first call
          pci_bus_assign_resources
          pci_bus_add_devices            # second call
      
      [bhelgaas: changelog, drop "root_bus" var in alpha common_init_pci(),
      return failure earlier in mn10300, add "return" in x86 pcibios_scan_root(),
      return early if xtensa platform_pcibios_fixup() fails]
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: Richard Henderson <rth@twiddle.net>
      CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      CC: Matt Turner <mattst88@gmail.com>
      CC: David Howells <dhowells@redhat.com>
      CC: Tony Luck <tony.luck@intel.com>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Ralf Baechle <ralf@linux-mips.org>
      CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
      CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
      CC: "David S. Miller" <davem@davemloft.net>
      CC: Chris Metcalf <cmetcalf@ezchip.com>
      CC: Chris Zankel <chris@zankel.net>
      CC: Max Filippov <jcmvbkbc@gmail.com>
      CC: Thomas Gleixner <tglx@linutronix.de>
      b97ea289
  21. 13 3月, 2015 2 次提交
    • Y
      PCI: Assign resources before drivers claim devices (pci_scan_bus()) · c90570d9
      Yijing Wang 提交于
      Previously, pci_scan_bus() created a root PCI bus, enumerated the devices
      on it, and called pci_bus_add_devices(), which made the devices available
      for drivers to claim them.
      
      Most callers assigned resources to devices after pci_scan_bus() returns,
      which may be after drivers have claimed the devices.  This is incorrect;
      the PCI core should not change device resources while a driver is managing
      the device.
      
      Remove pci_bus_add_devices() from pci_scan_bus() and do it after any
      resource assignment in the callers.
      
      [bhelgaas: changelog, check for failure in mcf_pci_init()]
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: "David S. Miller" <davem@davemloft.net>
      CC: Geert Uytterhoeven <geert@linux-m68k.org>
      CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
      CC: Richard Henderson <rth@twiddle.net>
      CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      CC: Matt Turner <mattst88@gmail.com>
      c90570d9
    • M
      PCI: Update DMA configuration from DT · de335bb4
      Murali Karicheri 提交于
      If there is a DT node available for the root bridge's parent device, use
      the DMA configuration from that device node.  For example, Keystone PCI
      devices would require dma_pfn_offset to be set correctly in the device
      structure of the PCI device in order to have the correct DMA mask.  The DT
      node will have dma-ranges defined for this.  Also support using the DT
      property dma-coherent to allow coherent DMA operation by the PCI device.
      
      Use the new helper function of_pci_dma_configure() to update the device DMA
      configuration.  This fixes DMA on systems where DMA addresses are a
      constant offset from CPU physical addresses.
      
      Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> (AMD Seattle)
      Signed-off-by: NMurali Karicheri <m-karicheri2@ti.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      CC: Joerg Roedel <joro@8bytes.org>
      CC: Grant Likely <grant.likely@linaro.org>
      CC: Rob Herring <robh+dt@kernel.org>
      CC: Russell King <linux@arm.linux.org.uk>
      CC: Arnd Bergmann <arnd@arndb.de>
      de335bb4
  22. 05 2月, 2015 1 次提交
  23. 20 11月, 2014 2 次提交
    • M
      PCI: Add informational printk for invalid BARs · 7e79c5f8
      Myron Stowe 提交于
      As a consequence of restoring the detection of invalid BARs, add a new
      informational printk like the following when such occurrences are
      encountered.
      
        pci ssss:bb:dd.f: [Firmware Bug]: reg 0xXX: invalid BAR (can't size)
      Reported-by: NWilliam Unruh <unruh@physics.ubc.ca>
      Reported-by: NMartin Lucina <martin@lucina.net>
      Signed-off-by: NMyron Stowe <myron.stowe@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: Matthew Wilcox <willy@linux.intel.com>
      7e79c5f8
    • Y
      PCI: Support 64-bit bridge windows if we have 64-bit dma_addr_t · 7fc986d8
      Yinghai Lu 提交于
      Aaron reported that a 32-bit x86 kernel with Physical Address Extension
      (PAE) support complains about bridge prefetchable memory windows above 4GB:
      
        pci_bus 0000:00: root bus resource [mem 0x380000000000-0x383fffffffff]
        ...
        pci 0000:03:00.0: reg 0x10: [mem 0x383fffc00000-0x383fffdfffff 64bit pref]
        pci 0000:03:00.0: reg 0x20: [mem 0x383fffe04000-0x383fffe07fff 64bit pref]
        pci 0000:03:00.1: reg 0x10: [mem 0x383fffa00000-0x383fffbfffff 64bit pref]
        pci 0000:03:00.1: reg 0x20: [mem 0x383fffe00000-0x383fffe03fff 64bit pref]
        pci 0000:00:02.2: PCI bridge to [bus 03-04]
        pci 0000:00:02.2:   bridge window [io  0x1000-0x1fff]
        pci 0000:00:02.2:   bridge window [mem 0x91900000-0x91cfffff]
        pci 0000:00:02.2: can't handle 64-bit address space for bridge
      
      In this kernel, unsigned long is 32 bits and dma_addr_t is 64 bits.
      Previously we used "unsigned long" to hold the bridge window address.  But
      this is a bus address, so we should use dma_addr_t instead.
      
      Use dma_addr_t to hold the bridge window base and limit.
      
      The question of whether the CPU can actually *address* the window is
      separate and depends on what the physical address space of the CPU is and
      whether the host bridge does any address translation.
      
      [bhelgaas: fix "shift count > width of type", changelog, stable tag]
      Fixes: d56dbf5b ("PCI: Allocate 64-bit BARs above 4G when possible")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=88131Reported-by: NAaron Ma <mapengyu@gmail.com>
      Tested-by: NAaron Ma <mapengyu@gmail.com>
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org	# v3.14+
      7fc986d8
  24. 14 11月, 2014 1 次提交
  25. 11 11月, 2014 3 次提交
  26. 01 10月, 2014 1 次提交
    • C
      PCI: Add generic domain handling · 670ba0c8
      Catalin Marinas 提交于
      The handling of PCI domains (or PCI segments in ACPI speak) is usually a
      straightforward affair but its implementation is currently left to the
      architectural code, with pci_domain_nr(b) querying the value of the domain
      associated with bus b.
      
      This patch introduces CONFIG_PCI_DOMAINS_GENERIC as an option that can be
      selected if an architecture wants a simple implementation where the value
      of the domain associated with a bus is stored in struct pci_bus.
      
      The architectures that select CONFIG_PCI_DOMAINS_GENERIC will then have to
      implement pci_bus_assign_domain_nr() as a way of setting the domain number
      associated with a root bus.  All child buses except the root bus will
      inherit the domain_nr value from their parent.
      Signed-off-by: NCatalin Marinas <Catalin.Marinas@arm.com>
      [Renamed pci_set_domain_nr() to pci_bus_assign_domain_nr()]
      Signed-off-by: NLiviu Dudau <Liviu.Dudau@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: Arnd Bergmann <arnd@arndb.de>
      670ba0c8
  27. 20 9月, 2014 2 次提交
    • B
      Revert "PCI: Make sure bus number resources stay within their parents bounds" · 12d87069
      Bjorn Helgaas 提交于
      This reverts commit 1820ffdc ("PCI: Make sure bus number resources stay
      within their parents bounds") because it breaks some systems with LSI Logic
      FC949ES Fibre Channel Adapters, apparently by exposing a defect in those
      adapters.
      
      Dirk tested a Tyan VX50 (B4985) with this device that worked like this
      prior to 1820ffdc:
      
          bus: [bus 00-7f] on node 0 link 1
          ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-07])
          pci 0000:00:0e.0: PCI bridge to [bus 0a]
          pci_bus 0000:0a: busn_res: can not insert [bus 0a] under [bus 00-07] (conflicts with (null) [bus 00-07])
          pci 0000:0a:00.0: [1000:0646] type 00 class 0x0c0400 (FC adapter)
      
      Note that the root bridge [bus 00-07] aperture is wrong; this is a BIOS
      defect in the PCI0 _CRS method.  But prior to 1820ffdc, we didn't
      enforce that aperture, and the FC adapter worked fine at 0a:00.0.
      
      After 1820ffdc, we notice that 00:0e.0's aperture is not contained in
      the root bridge's aperture, so we reconfigure it so it *is* contained:
      
          pci 0000:00:0e.0: bridge configuration invalid ([bus 0a-0a]), reconfiguring
          pci 0000:00:0e.0: PCI bridge to [bus 06-07]
      
      This effectively moves the FC device from 0a:00.0 to 07:00.0, which should
      be legal.  But when we enumerate bus 06, the FC device doesn't respond, so
      we don't find anything.  This is probably a defect in the FC device.
      
      Possible fixes (due to Yinghai):
      
          1) Add a quirk to fix the _CRS information based on what amd_bus.c read
             from the hardware
      
          2) Reset the FC device after we change its bus number
      
          3) Revert 1820ffdc
      
      Fix 1 would be relatively easy, but it does sweep the LSI FC issue under
      the rug.  We might want to reconfigure bus numbers in the future for some
      other reason, e.g., hotplug, and then we could trip over this again.
      
      For that reason, I like fix 2, but we don't know whether it actually works,
      and we don't have a patch for it yet.
      
      This revert is fix 3, which also sweeps the LSI FC issue under the rug.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=84281Reported-by: NDirk Gouders <dirk@gouders.net>
      Tested-by: NDirk Gouders <dirk@gouders.net>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org	# v3.15+
      CC: Yinghai Lu <yinghai@kernel.org>
      12d87069
    • B
      Revert "PCI: Don't scan random busses in pci_scan_bridge()" · 7a0b33d4
      Bjorn Helgaas 提交于
      This reverts commit fc1b2531 ("PCI: Don't scan random busses in
      pci_scan_bridge()") because it breaks CardBus on some machines.
      
      David tested a Dell Latitude D505 that worked like this prior to
      fc1b2531:
      
          pci 0000:00:1e.0: PCI bridge to [bus 01]
          pci 0000:01:01.0: CardBus bridge to [bus 02-05]
      
      Note that the 01:01.0 CardBus bridge has a bus number aperture of
      [bus 02-05], but those buses are all outside the 00:1e.0 PCI bridge bus
      number aperture, so accesses to buses 02-05 never reach CardBus.  This is
      later patched up by yenta_fixup_parent_bridge(), which changes the
      subordinate bus number of the 00:1e.0 PCI bridge:
      
          pci_bus 0000:01: Raising subordinate bus# of parent bus (#01) from #01 to #05
      
      With fc1b2531, pci_scan_bridge() fails immediately when it notices that
      we can't allocate a valid secondary bus number for the CardBus bridge, and
      CardBus doesn't work at all:
      
          pci 0000:01:01.0: can't allocate child bus 01 from [bus 01]
      
      I'd prefer to fix this by integrating the yenta_fixup_parent_bridge() logic
      into pci_scan_bridge() so we fix the bus number apertures up front.  But
      I don't think we can do that before v3.17, so I'm going to revert this to
      avoid the problem while we're working on the long-term fix.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=83441
      Link: http://lkml.kernel.org/r/1409303414-5196-1-git-send-email-david.henningsson@canonical.comReported-by: NDavid Henningsson <david.henningsson@canonical.com>
      Tested-by: NDavid Henningsson <david.henningsson@canonical.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org	# v3.15+
      7a0b33d4
  28. 13 9月, 2014 4 次提交
    • B
      PCI: Configure *all* devices, not just hot-added ones · 1302fcf0
      Bjorn Helgaas 提交于
      There's not really a good way to determine whether firmware has already
      configured a device with _HPP/_HPX settings.  On legacy systems, the BIOS
      has probably configured everything, but on UEFI systems it is not required
      to do so.
      
      Per the PCI Firmware Specification, rev 3.1, sec 3.5, if PCI_COMMAND_IO or
      PCI_COMMAND_MEMORY is set, we can assume firmware has set the corresponding
      BARs and maybe we can assume it has configured the rest of the device.  And
      if a bridge has PCI_COMMAND_PARITY or PCI_COMMAND_SERR set, we can assume
      firmware has configured the bridge.  But we can't tell much about devices
      without BARs.
      
      I think it should be safe to apply _HPP and _HPX settings anyway, even if
      firmware has already configured the device, so configure everything we
      find.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      1302fcf0
    • B
      PCI: Preserve MPS and MRRS when applying _HPX settings · 302328c0
      Bjorn Helgaas 提交于
      Linux manages MPS and MRRS settings to keep them consistent across the PCIe
      fabric.  BIOS doesn't participate in this Linux management, so ignore that
      part of any _HPX settings it supplies.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      302328c0
    • B
      PCI: Apply _HPP settings to all hot-added PCI devices · ca0647e0
      Bjorn Helgaas 提交于
      We currently apply _HPP settings only to:
      
          - non-bridge devices, and
          - PCI-to-PCI bridges
      
      i.e., we do not apply them to PCI-to-ISA bridges and the like.  It has been
      that way since _HPP support was added by 40abb96c ("pciehp: Fix
      programming hotplug parameters"), but I don't think there's any reason to
      exclude these other bridges.
      
      Apply _HPP settings to hot-added PCI devices of any type.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      ca0647e0
    • B
      PCI: Preserve BIOS PCI_COMMAND_SERR and PCI_COMMAND_PARITY settings · eab3a0ee
      Bjorn Helgaas 提交于
      Do not clear PCI_COMMAND_SERR or PCI_COMMAND_PARITY based on _HPP.  The
      spec (ACPI rev 5.0, sec 6.2.7) says that when "Enable SERR" is set to 1,
      we should enable SERR in the command register.  It says nothing about
      *disabling* SERR or PERR; in fact, the example in 6.2.7.1 says we should
      leave PERR alone unless "Enable PERR" is 1.
      
      For hot-added devices, this probably doesn't matter because they power up
      with these bits cleared.  But in addition to hot-plugged devices, the spec
      allows the platform to use _HPP for "configuration of PCI devices not
      configured by the BIOS at system boot," and it may make a difference for
      devices present at boot.
      
      This change means that if BIOS enables SERR or PERR on a device, and it
      supplies _HPP or _HPX with the SERR or PERR bits *cleared*, we will now
      leave SERR or PERR reporting enabled on that device instead of disabling it
      as we previously did.
      
      See also 40abb96c ("pciehp: Fix programming hotplug parameters"), where
      this code was first added.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NYinghai Lu <yinghai@kernel.org>
      eab3a0ee