1. 12 4月, 2016 1 次提交
  2. 09 3月, 2016 1 次提交
  3. 01 3月, 2016 1 次提交
  4. 26 2月, 2016 1 次提交
    • B
      PCI: Disable IO/MEM decoding for devices with non-compliant BARs · b84106b4
      Bjorn Helgaas 提交于
      The PCI config header (first 64 bytes of each device's config space) is
      defined by the PCI spec so generic software can identify the device and
      manage its usage of I/O, memory, and IRQ resources.
      
      Some non-spec-compliant devices put registers other than BARs where the
      BARs should be.  When the PCI core sizes these "BARs", the reads and writes
      it does may have unwanted side effects, and the "BAR" may appear to
      describe non-sensical address space.
      
      Add a flag bit to mark non-compliant devices so we don't touch their BARs.
      Turn off IO/MEM decoding to prevent the devices from consuming address
      space, since we can't read the BARs to find out what that address space
      would be.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Tested-by: NAndi Kleen <ak@linux.intel.com>
      CC: stable@vger.kernel.org
      b84106b4
  5. 17 2月, 2016 1 次提交
  6. 06 2月, 2016 2 次提交
    • B
      PCI: Remove includes of empty asm-generic/pci-bridge.h · 5bd28338
      Bjorn Helgaas 提交于
      include/asm-generic/pci-bridge.h is now empty, so remove every #include of
      it.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: Will Deacon <will.deacon@arm.com> (arm64)
      5bd28338
    • B
      PCI: Move pci_set_flags() from asm-generic/pci-bridge.h to linux/pci.h · 5bbe029f
      Bjorn Helgaas 提交于
      The PCI flag management constants and functions were previously declared in
      include/asm-generic/pci-bridge.h.  But they are not specific to bridges,
      and arches did not include pci-bridge.h consistently.
      
      Move the following interfaces and related constants to include/linux/pci.h
      and remove pci-bridge.h:
      
        pci_set_flags()
        pci_add_flags()
        pci_clear_flags()
        pci_has_flag()
      
      This fixes these warnings when building for some arches:
      
        drivers/pci/host/pcie-designware.c:562:20: error: 'PCI_PROBE_ONLY' undeclared (first use in this function)
        drivers/pci/host/pcie-designware.c:562:7: error: implicit declaration of function 'pci_has_flag' [-Werror=implicit-function-declaration]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      5bbe029f
  7. 21 12月, 2015 1 次提交
  8. 11 12月, 2015 1 次提交
  9. 01 12月, 2015 1 次提交
  10. 25 11月, 2015 1 次提交
    • G
      PCI/MSI: Initialize MSI capability for all architectures · e80e7edc
      Guilherme G. Piccoli 提交于
      1851617c ("PCI/MSI: Disable MSI at enumeration even if kernel doesn't
      support MSI") moved dev->msi_cap and dev->msix_cap initialization from the
      pci_init_capabilities() path (used on all architectures) to the
      pci_setup_device() path (not used on Open Firmware architectures).
      
      This broke MSI or MSI-X on Open Firmware machines.  4d9aac39
      ("powerpc/PCI: Disable MSI/MSI-X interrupts at PCI probe time in OF case")
      fixed it for PowerPC but not for SPARC.
      
      Set up MSI and MSI-X (initialize msi_cap and msix_cap and disable MSI and
      MSI-X) in pci_init_capabilities() so all architectures do it the same way.
      
      This reverts 4d9aac39 since this patch fixes the problem generically
      for both PowerPC and SPARC.
      
      [bhelgaas: changelog, make pci_msi_setup_pci_dev() static]
      Fixes: 1851617c ("PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI")
      Signed-off-by: NGuilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      e80e7edc
  11. 20 11月, 2015 1 次提交
  12. 07 11月, 2015 2 次提交
  13. 30 10月, 2015 1 次提交
  14. 16 10月, 2015 2 次提交
  15. 25 9月, 2015 1 次提交
  16. 17 9月, 2015 1 次提交
  17. 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
  18. 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
  19. 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
  20. 21 8月, 2015 2 次提交
  21. 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
  22. 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
  23. 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
  24. 31 7月, 2015 1 次提交
  25. 30 7月, 2015 2 次提交
  26. 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
  27. 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
  28. 13 6月, 2015 1 次提交
  29. 30 5月, 2015 2 次提交
  30. 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
  31. 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
  32. 09 4月, 2015 1 次提交
  33. 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
  34. 13 3月, 2015 1 次提交
    • 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