1. 29 6月, 2017 1 次提交
    • L
      PCI: Initialize bridge release function at bridge allocation · a1c0050a
      Lorenzo Pieralisi 提交于
      The introduction of pci_register_host_bridge() kernel interface allows PCI
      host controller drivers to create the struct pci_host_bridge object,
      initialize it and register it with the kernel so that its corresponding PCI
      bus can be scanned and its devices probed.
      
      The host bridge device release function pci_release_host_bridge_dev() is a
      static function common for all struct pci_host_bridge allocated objects, so
      in its current form cannot be used by PCI host bridge controllers drivers
      to initialize the allocated struct pci_host_bridge, which leaves struct
      pci_host_bridge devices release function uninitialized.
      
      Since pci_release_host_bridge_dev() is a function common to all PCI host
      bridge objects, initialize it in pci_alloc_host_bridge() (ie common host
      bridge allocation interface) so that all struct pci_host_bridge objects
      have their release function initialized by default at allocation time,
      removing the need for exporting the common pci_release_host_bridge_dev()
      function to other compilation units.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      a1c0050a
  2. 20 4月, 2017 1 次提交
  3. 19 4月, 2017 2 次提交
  4. 31 3月, 2017 1 次提交
    • L
      PCI: Recognize Thunderbolt devices · 8531e283
      Lukas Wunner 提交于
      Detect on probe whether a PCI device is part of a Thunderbolt controller.
      Intel uses a Vendor-Specific Extended Capability (VSEC) with ID 0x1234
      on such devices.  Detect presence of this VSEC and cache it in a newly
      added is_thunderbolt bit in struct pci_dev.
      
      Also, add a helper to check whether a given PCI device is situated on a
      Thunderbolt daisy chain (i.e., below a PCI device with is_thunderbolt
      set).
      
      The necessity arises from the following:
      
      * If an external Thunderbolt GPU is connected to a dual GPU laptop,
        that GPU is currently registered with vga_switcheroo even though it
        can neither drive the laptop's panel nor be powered off by the
        platform.  To vga_switcheroo it will appear as if two discrete
        GPUs are present.  As a result, when the external GPU is runtime
        suspended, vga_switcheroo will cut power to the internal discrete GPU
        which may not be runtime suspended at all at this moment.  The
        solution is to not register external GPUs with vga_switcheroo, which
        necessitates a way to recognize if they're on a Thunderbolt daisy
        chain.
      
      * Dual GPU MacBook Pros introduced 2011+ can no longer switch external
        DisplayPort ports between GPUs.  (They're no longer just used for DP
        but have become combined DP/Thunderbolt ports.)  The driver to switch
        the ports, drivers/platform/x86/apple-gmux.c, needs to detect presence
        of a Thunderbolt controller and, if found, keep external ports
        permanently switched to the discrete GPU.
      
      v2: Make kerneldoc for pci_is_thunderbolt_attached() more precise,
          drop portion of commit message pertaining to separate series.
          (Bjorn Helgaas)
      
      Cc: Andreas Noever <andreas.noever@gmail.com>
      Cc: Michael Jamet <michael.jamet@intel.com>
      Cc: Tomas Winkler <tomas.winkler@intel.com>
      Cc: Amir Levy <amir.jer.levy@intel.com>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Link: http://patchwork.freedesktop.org/patch/msgid/0ab165a4a35c0b60f29d4c306c653ead14fcd8f9.1489145162.git.lukas@wunner.de
      8531e283
  5. 10 2月, 2017 1 次提交
  6. 11 1月, 2017 1 次提交
    • B
      PCI: Enumerate switches below PCI-to-PCIe bridges · 51ebfc92
      Bjorn Helgaas 提交于
      A PCI-to-PCIe bridge (a "reverse bridge") has a PCI or PCI-X primary
      interface and a PCI Express secondary interface.  The PCIe interface is a
      Downstream Port that originates a Link.  See the "PCI Express to PCI/PCI-X
      Bridge Specification", rev 1.0, sections 1.2 and A.6.
      
      The bug report below involves a PCI-to-PCIe bridge and a PCIe switch below
      the bridge:
      
        00:1e.0 Intel 82801 PCI Bridge to [bus 01-0a]
        01:00.0 Pericom PI7C9X111SL PCIe-to-PCI Reversible Bridge to [bus 02-0a]
        02:00.0 Pericom Device 8608 [PCIe Upstream Port] to [bus 03-0a]
        03:01.0 Pericom Device 8608 [PCIe Downstream Port] to [bus 0a]
      
      01:00.0 is configured as a PCI-to-PCIe bridge (despite the name printed by
      lspci).  As we traverse a PCIe hierarchy, device connections alternate
      between PCIe Links and internal Switch logic.  Previously we did not
      recognize that 01:00.0 had a secondary link, so we thought the 02:00.0
      Upstream Port *did* have a secondary link.  In fact, it's the other way
      around: 01:00.0 has a secondary link, and 02:00.0 has internal Switch logic
      on its secondary side.
      
      When we thought 02:00.0 had a secondary link, the pci_scan_slot() ->
      only_one_child() path assumed 02:00.0 could have only one child, so 03:00.0
      was the only possible downstream device.  But 03:00.0 doesn't exist, so we
      didn't look for any other devices on bus 03.
      
      Booting with "pci=pcie_scan_all" is a workaround, but we don't want users
      to have to do that.
      
      Recognize that PCI-to-PCIe bridges originate links on their secondary
      interfaces.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=189361
      Fixes: d0751b98 ("PCI: Add dev->has_secondary_link to track downstream PCIe links")
      Tested-by: NBlake Moore <blake.moore@men.de>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org	# v4.2+
      51ebfc92
  7. 03 1月, 2017 1 次提交
    • B
      PCI: Apply _HPX settings only to relevant devices · 977509f7
      Bjorn Helgaas 提交于
      Previously we didn't check the type of device before trying to apply Type 1
      (PCI-X) or Type 2 (PCIe) Setting Records from _HPX.
      
      We don't support PCI-X Setting Records, so this was harmless, but the
      warning was useless.
      
      We do support PCIe Setting Records, and we didn't check whether a device
      was PCIe before applying settings.  I don't think anything bad happened on
      non-PCIe devices because pcie_capability_clear_and_set_word(),
      pcie_cap_has_lnkctl(), etc., would fail before doing any harm.  But it's
      ugly to depend on those internals.
      
      Check the device type before attempting to apply Type 1 and Type 2 Setting
      Records (Type 0 records are applicable to PCI, PCI-X, and PCIe devices).
      
      A side benefit is that this prevents useless "not supported" warnings when
      a BIOS supplies a Type 1 (PCI-X) Setting Record and we try to apply it to
      every single device:
      
        pci 0000:00:00.0: PCI-X settings not supported
      
      After this patch, we'll get the warning only when a BIOS supplies a Type 1
      record and we have a PCI-X device to which it should be applied.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=187731Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      977509f7
  8. 08 12月, 2016 3 次提交
    • T
      PCI: Export host bridge registration interface · a52d1443
      Thierry Reding 提交于
      Allow PCI host bridge drivers to use the new host bridge interfaces to
      register their host bridge.
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NBjorn Helgaas <helgaas@kernel.org>
      a52d1443
    • T
      PCI: Allow driver-specific data in host bridge · 59094065
      Thierry Reding 提交于
      Provide a way to allocate driver-specific data along with a PCI host bridge
      structure. The bridge's ->private field points to this data.
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NBjorn Helgaas <helgaas@kernel.org>
      59094065
    • A
      PCI: Add pci_register_host_bridge() interface · 37d6a0a6
      Arnd Bergmann 提交于
      Make the existing pci_host_bridge structure a proper device that is usable
      by PCI host drivers in a more standard way. In addition to the existing
      pci_scan_bus(), pci_scan_root_bus(), pci_scan_root_bus_msi(), and
      pci_create_root_bus() interfaces, this unfortunately means having to add
      yet another interface doing basically the same thing, and add some extra
      code in the initial step.
      
      However, this time it's more likely to be extensible enough that we won't
      have to do another one again in the future, and we should be able to reduce
      code much more as a result.
      
      The main idea is to pull the allocation of 'struct pci_host_bridge' out of
      the registration, and let individual host drivers and architecture code
      fill the members before calling the registration function.
      
      There are a number of things we can do based on this:
      
      * Use a single memory allocation for the driver-specific structure
        and the generic PCI host bridge
      * consolidate the contents of driver-specific structures by moving
        them into pci_host_bridge
      * Add a consistent interface for removing a PCI host bridge again
        when unloading a host driver module
      * Replace the architecture specific __weak pcibios_*() functions with
        callbacks in a pci_host_bridge device
      * Move common boilerplate code from host drivers into the generic
        function, based on contents of the structure
      * Extend pci_host_bridge with additional members when needed without
        having to add arguments to pci_scan_*().
      * Move members of struct pci_bus into pci_host_bridge to avoid
        having lots of identical copies.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NBjorn Helgaas <helgaas@kernel.org>
      37d6a0a6
  9. 30 11月, 2016 1 次提交
  10. 29 11月, 2016 1 次提交
    • L
      ACPI: Implement acpi_dma_configure · d760a1ba
      Lorenzo Pieralisi 提交于
      On DT based systems, the of_dma_configure() API implements DMA
      configuration for a given device. On ACPI systems an API equivalent to
      of_dma_configure() is missing which implies that it is currently not
      possible to set-up DMA operations for devices through the ACPI generic
      kernel layer.
      
      This patch fills the gap by introducing acpi_dma_configure/deconfigure()
      calls that for now are just wrappers around arch_setup_dma_ops() and
      arch_teardown_dma_ops() and also updates ACPI and PCI core code to use
      the newly introduced acpi_dma_configure/acpi_dma_deconfigure functions.
      
      Since acpi_dma_configure() is used to configure DMA operations, the
      function initializes the dma/coherent_dma masks to sane default values
      if the current masks are uninitialized (also to keep the default values
      consistent with DT systems) to make sure the device has a complete
      default DMA set-up.
      
      The DMA range size passed to arch_setup_dma_ops() is sized according
      to the device coherent_dma_mask (starting at address 0x0), mirroring the
      DT probing path behaviour when a dma-ranges property is not provided
      for the device being probed; this changes the current arch_setup_dma_ops()
      call parameters in the ACPI probing case, but since arch_setup_dma_ops()
      is a NOP on all architectures but ARM/ARM64 this patch does not change
      the current kernel behaviour on them.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: Bjorn Helgaas <bhelgaas@google.com> [pci]
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NTomasz Nowicki <tn@semihalf.com>
      Tested-by: NHanjun Guo <hanjun.guo@linaro.org>
      Tested-by: NTomasz Nowicki <tn@semihalf.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Tomasz Nowicki <tn@semihalf.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      d760a1ba
  11. 24 11月, 2016 1 次提交
    • J
      PCI: Set Read Completion Boundary to 128 iff Root Port supports it (_HPX) · e42010d8
      Johannes Thumshirn 提交于
      Per PCIe spec r3.0, sec 2.3.1.1, the Read Completion Boundary (RCB)
      determines the naturally aligned address boundaries on which a Read Request
      may be serviced with multiple Completions:
      
        - For a Root Complex, RCB is 64 bytes or 128 bytes
          This value is reported in the Link Control Register
      
          Note: Bridges and Endpoints may implement a corresponding command bit
          which may be set by system software to indicate the RCB value for the
          Root Complex, allowing the Bridge/Endpoint to optimize its behavior
          when the Root Complex’s RCB is 128 bytes.
      
        - For all other system elements, RCB is 128 bytes
      
      Per sec 7.8.7, if a Root Port only supports a 64-byte RCB, the RCB of all
      downstream devices must be clear, indicating an RCB of 64 bytes.  If the
      Root Port supports a 128-byte RCB, we may optionally set the RCB of
      downstream devices so they know they can generate larger Completions.
      
      Some BIOSes supply an _HPX that tells us to set RCB, even though the Root
      Port doesn't have RCB set, which may lead to Malformed TLP errors if the
      Endpoint generates completions larger than the Root Port can handle.
      
      The IBM x3850 X6 with BIOS version -[A8E120CUS-1.30]- 08/22/2016 supplies
      such an _HPX and a Mellanox MT27500 ConnectX-3 device fails to initialize:
      
        mlx4_core 0000:41:00.0: command 0xfff timed out (go bit not cleared)
        mlx4_core 0000:41:00.0: device is going to be reset
        mlx4_core 0000:41:00.0: Failed to obtain HW semaphore, aborting
        mlx4_core 0000:41:00.0: Fail to reset HCA
        ------------[ cut here ]------------
        kernel BUG at drivers/net/ethernet/mellanox/mlx4/catas.c:193!
      
      After 6cd33649 ("PCI: Add pci_configure_device() during enumeration")
      and 7a1562d4 ("PCI: Apply _HPX Link Control settings to all devices
      with a link"), we apply _HPX settings to *all* devices, not just those
      hot-added after boot.
      
      Before 7a1562d4, we didn't touch the Mellanox RCB, and the device
      worked.  After 7a1562d4, we set its RCB to 128, and it failed.
      
      Set the RCB to 128 iff the Root Port supports a 128-byte RCB.  Otherwise,
      set RCB to 64 bytes.  This effectively ignores what _HPX tells us about
      RCB.
      
      Note that this change only affects _HPX handling.  If we have no _HPX, this
      does nothing with RCB.
      
      [bhelgaas: changelog, clear RCB if not set for Root Port]
      Fixes: 6cd33649 ("PCI: Add pci_configure_device() during enumeration")
      Fixes: 7a1562d4 ("PCI: Apply _HPX Link Control settings to all devices with a link")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=187781Tested-by: NFrank Danapfel <fdanapfe@redhat.com>
      Signed-off-by: NJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NMyron Stowe <myron.stowe@redhat.com>
      CC: stable@vger.kernel.org	# v3.18+
      e42010d8
  12. 28 9月, 2016 1 次提交
  13. 16 8月, 2016 1 次提交
  14. 26 7月, 2016 1 次提交
  15. 14 6月, 2016 1 次提交
  16. 11 6月, 2016 1 次提交
  17. 17 5月, 2016 1 次提交
    • P
      PCI: Disable all BAR sizing for devices with non-compliant BARs · ad67b437
      Prarit Bhargava 提交于
      b84106b4 ("PCI: Disable IO/MEM decoding for devices with non-compliant
      BARs") disabled BAR sizing for BARs 0-5 of devices that don't comply with
      the PCI spec.  But it didn't do anything for expansion ROM BARs, so we
      still try to size them, resulting in warnings like this on Broadwell-EP:
      
        pci 0000:ff:12.0: BAR 6: failed to assign [mem size 0x00000001 pref]
      
      Move the non-compliant BAR check from __pci_read_base() up to
      pci_read_bases() so it applies to the expansion ROM BAR as well as
      to BARs 0-5.
      
      Note that direct callers of __pci_read_base(), like sriov_init(), will now
      bypass this check.  We haven't had reports of devices with broken SR-IOV
      BARs yet.
      
      [bhelgaas: changelog]
      Fixes: b84106b4 ("PCI: Disable IO/MEM decoding for devices with non-compliant BARs")
      Signed-off-by: NPrarit Bhargava <prarit@redhat.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: stable@vger.kernel.org
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Ingo Molnar <mingo@redhat.com>
      CC: "H. Peter Anvin" <hpa@zytor.com>
      CC: Andi Kleen <ak@linux.intel.com>
      ad67b437
  18. 12 4月, 2016 1 次提交
  19. 09 3月, 2016 1 次提交
  20. 01 3月, 2016 1 次提交
  21. 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
  22. 17 2月, 2016 1 次提交
  23. 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
  24. 21 12月, 2015 1 次提交
  25. 11 12月, 2015 1 次提交
  26. 01 12月, 2015 1 次提交
  27. 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
  28. 20 11月, 2015 1 次提交
  29. 07 11月, 2015 2 次提交
  30. 30 10月, 2015 1 次提交
  31. 16 10月, 2015 2 次提交
  32. 25 9月, 2015 1 次提交
  33. 17 9月, 2015 1 次提交
  34. 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