1. 05 6月, 2018 3 次提交
    • M
      PCI: Improve "partially hidden behind bridge" log message · e412d63d
      Mika Westerberg 提交于
      pci_scan_child_bus_extend() complains when we assign an unreachable
      secondary bus number to a bridge.  For example, given the topology below:
      
        +-1b.0-[01-39]----00.0-[02-3a]--+-00.0-[03]----00.0
                                        +-01.0-[04-39]--
                                        \-02.0-[3a]----00.0
      
      it logs the following messages:
      
        pci_bus 0000:3a: [bus 3a] partially hidden behind bridge 0000:02 [bus 02-39]
        pci_bus 0000:3a: [bus 3a] partially hidden behind bridge 0000:01 [bus 01-39]
      
      These messages are incorrect (0000:02 is a bus, not a bridge) and
      confusing.  Make the message more understandable:
      
        pci 0000:02:02.0: devices behind bridge are unusable because [bus 3a] cannot be assigned for them
      
      Also, remove the reference to CardBus, because this issue affects all
      varieties of PCI, not just CardBus.
      Suggested-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      [bhelgaas: changelog]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      e412d63d
    • M
      PCI: Improve pci_scan_bridge() and pci_scan_bridge_extend() doc · 70f7880d
      Mika Westerberg 提交于
      It is not immediately clear what the two functions actually return so
      add kernel-doc comment explaining it a bit better.
      Suggested-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      70f7880d
    • M
      PCI: Account for all bridges on bus when distributing bus numbers · 3374c545
      Mika Westerberg 提交于
      When distributing extra bus number space to hotplug bridges for future
      extension, we don't account for the fact that there might be non-hotplug
      bridges on the bus after the hotplug bridges.  For example:
      
        01:00.0 --+- 02:00.0 (HotPlug-) -- Thunderbolt host controller
                  +- 02:01.0 (HotPlug+)
                  \- 02:02.0 (HotPlug-) -- xHCI host controller
      
      pci_scan_child_bus_extend() is supposed to distribute the remaining bus
      numbers to the hotplug bridge at 02:01.0, but only after accounting for all
      bridges on bus 02.  Since we don't check whether there's another
      non-hotplug bridge after the hotplug bridge 02:01.0, it may not leave space
      for the non-hotplug bridge:
      
        pci 0000:00:1b.0: PCI bridge to [bus 01-39]  (Root Port)
        pci 0000:01:00.0: PCI bridge to [bus 02-39]
        ...
        pci 0000:02:00.0: PCI bridge to [bus 03]
        pci 0000:02:01.0: PCI bridge to [bus 04]
        pci_bus 0000:04: [bus 04-39] extended by 0x35
        pci_bus 0000:04: bus scan returning with max=39
        pci_bus 0000:04: busn_res: [bus 04-39] end is updated to 39
        pci 0000:02:02.0: scanning [bus 00-00] behind bridge, pass 1
        pci_bus 0000:3a: scanning bus
        pci_bus 0000:3a: bus scan returning with max=3a
        pci_bus 0000:3a: busn_res: [bus 3a] end is updated to 3a
        pci_bus 0000:3a: [bus 3a] partially hidden behind bridge 0000:02 [bus 02-39]
        pci_bus 0000:3a: [bus 3a] partially hidden behind bridge 0000:01 [bus 01-39]
        pci_bus 0000:02: bus scan returning with max=3a
        pci_bus 0000:02: busn_res: [bus 02-39] end can not be updated to 3a
      
      The resulting 'lspci -t' output looks like this:
      
        +-1b.0-[01-39]----00.0-[02-3a]--+-00.0-[03]----00.0
                                   ^^   +-01.0-[04-39]--
                                        \-02.0-[3a]----00.0
                                                ^^
      The xHCI host controller behind 02:02.0 is not usable because it would have
      to be assigned bus 3a, which is not accessible through 00:1b.0.
      
      To fix this, reserve at least one bus for each bridge while scanning
      already configured bridges.  Then use this information in the second
      scan to correct the available extra bus space for hotplug bridges.
      
      After this change the 'lspci -t' output is what is expected:
      
        +-1b.0-[01-39]----00.0-[02-39]--+-00.0-[03]----00.0
                                        +-01.0-[04-38]--
                                        \-02.0-[39]----00.0
      
      The xHCI controller is now on bus 39, where it is usable.
      
      Fixes: 1c02ea81 ("PCI: Distribute available buses to hotplug-capable bridges")
      Reported-by: NMario Limonciello <mario.limonciello@dell.com>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      [bhelgaas: changelog]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: stable@vger.kernel.org
      3374c545
  2. 02 6月, 2018 2 次提交
  3. 01 4月, 2018 1 次提交
  4. 31 3月, 2018 1 次提交
    • B
      PCI/portdrv: Simplify PCIe feature permission checking · 02bfeb48
      Bjorn Helgaas 提交于
      Some PCIe features (AER, DPC, hotplug, PME) can be managed by either the
      platform firmware or the OS, so the host bridge driver may have to request
      permission from the platform before using them.  On ACPI systems, this is
      done by negotiate_os_control() in acpi_pci_root_add().
      
      The PCIe port driver later uses pcie_port_platform_notify() and
      pcie_port_acpi_setup() to figure out whether it can use these features.
      But all we need is a single bit for each service, so these interfaces are
      needlessly complicated.
      
      Simplify this by adding bits in the struct pci_host_bridge to show when the
      OS has permission to use each feature:
      
        + unsigned int native_aer:1;       /* OS may use PCIe AER */
        + unsigned int native_hotplug:1;   /* OS may use PCIe hotplug */
        + unsigned int native_pme:1;       /* OS may use PCIe PME */
      
      These are set when we create a host bridge, and the host bridge driver can
      clear the bits corresponding to any feature the platform doesn't want us to
      use.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      02bfeb48
  5. 22 3月, 2018 1 次提交
  6. 20 3月, 2018 2 次提交
  7. 08 3月, 2018 1 次提交
  8. 05 3月, 2018 1 次提交
  9. 17 2月, 2018 1 次提交
    • B
      PCI: Probe for device reset support during enumeration · 5b0764ca
      Bjorn Helgaas 提交于
      Previously we called pci_probe_reset_function() in this path:
      
        pci_sysfs_init                              # late_initcall
          for_each_pci_dev(dev)
            pci_create_sysfs_dev_files(dev)
              pci_create_capabilities_sysfs(dev)
                pci_probe_reset_function
                  pci_dev_specific_reset
                  pcie_has_flr
                    pcie_capability_read_dword
      
      pci_sysfs_init() is a late_initcall, and a driver may have already claimed
      one of these devices and enabled runtime power management for it, so the
      device could already be in D3 by the time we get to pci_sysfs_init().
      
      The device itself should respond to the config read even while it's in
      D3hot, but if an upstream bridge is also in D3hot, the read won't even
      reach the device because the bridge won't forward it downstream to the
      device.  If the bridge is a PCIe port, it should complete the read as an
      Unsupported Request, which may be reported to the CPU as an exception or as
      invalid data.
      
      Avoid this case by probing for reset support from pci_init_capabilities(),
      before a driver can claim the device.  The device may be in D3hot, but any
      bridges leading to it should be in D0, so the device's config space should
      be fully accessible at that point.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5b0764ca
  10. 31 1月, 2018 1 次提交
  11. 27 1月, 2018 1 次提交
  12. 19 1月, 2018 1 次提交
  13. 19 12月, 2017 3 次提交
  14. 07 11月, 2017 5 次提交
    • M
      PCI: Distribute available buses to hotplug-capable bridges · 1c02ea81
      Mika Westerberg 提交于
      System BIOS sometimes allocates extra bus space for hotplug-capable PCIe
      root/downstream ports. This space is needed if the device plugged to the
      port will have more hotplug-capable downstream ports. A good example of
      this is Thunderbolt. Each Thunderbolt device contains a PCIe switch and
      one or more hotplug-capable PCIe downstream ports where the daisy chain
      can be extended.
      
      Currently Linux only allocates minimal bus space to make sure all the
      enumerated devices barely fit there. The BIOS reserved extra space is
      not taken into consideration at all. Because of this we run out of bus
      space pretty quickly when more PCIe devices are attached to hotplug
      downstream ports in order to extend the chain.
      
      Modify the PCI core so we distribute the available BIOS allocated bus space
      equally between hotplug-capable bridges to make sure there is enough bus
      space for extending the hierarchy later on.
      
      Update kernel docs of the affected functions.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      1c02ea81
    • M
      PCI: Do not allocate more buses than available in parent · a20c7f36
      Mika Westerberg 提交于
      One can ask more buses to be reserved for hotplug bridges by passing
      pci=hpbussize=N in the kernel command line.  If the parent bus does not
      have enough bus space available we incorrectly create child bus with the
      requested number of subordinate buses.
      
      In the example below hpbussize is set to one more than we have available
      buses in the root port:
      
        pci 0000:07:00.0: [8086:1578] type 01 class 0x060400
        pci 0000:07:00.0: scanning [bus 00-00] behind bridge, pass 0
        pci 0000:07:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
        pci 0000:07:00.0: scanning [bus 00-00] behind bridge, pass 1
        pci_bus 0000:08: busn_res: can not insert [bus 08-ff] under [bus 07-3f] (conflicts with (null) [bus 07-3f])
        pci_bus 0000:08: scanning bus
        ...
        pci_bus 0000:0a: bus scan returning with max=40
        pci_bus 0000:0a: busn_res: [bus 0a-ff] end is updated to 40
        pci_bus 0000:0a: [bus 0a-40] partially hidden behind bridge 0000:07 [bus 07-3f]
        pci_bus 0000:08: bus scan returning with max=40
        pci_bus 0000:08: busn_res: [bus 08-ff] end is updated to 40
      
      Instead of allowing this, limit the subordinate number to be less than or
      equal the maximum subordinate number allocated for the parent bus (if it
      has any).
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      [bhelgaas: remove irrelevant dmesg messages]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      a20c7f36
    • M
      PCI: Open-code the two pass loop when scanning bridges · 4147c2fd
      Mika Westerberg 提交于
      The current scanning code is really hard to understand because it calls
      the same function in a loop where pass value is changed without any
      comments explaining it:
      
        for (pass = 0; pass < 2; pass++)
          for_each_pci_bridge(dev, bus)
            max = pci_scan_bridge(bus, dev, max, pass);
      
      Unfamiliar reader cannot tell easily what is the purpose of this loop
      without looking at internals of pci_scan_bridge().
      
      In order to make this bit easier to understand, open-code the loop in
      pci_scan_child_bus() and pci_hp_add_bridge() with added comments.
      
      No functional changes intended.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      4147c2fd
    • M
      PCI: Move pci_hp_add_bridge() to drivers/pci/probe.c · 95e3ba97
      Mika Westerberg 提交于
      There is not much point of having a file with a single function in it.
      Instead we can just move pci_hp_add_bridge() to drivers/pci/probe.c and
      make it available always when PCI core is enabled.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      [bhelgaas: convert printk to dev_err()]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      95e3ba97
    • A
      PCI: Add for_each_pci_bridge() helper · 24a0c654
      Andy Shevchenko 提交于
      The following pattern is often used:
      
        list_for_each_entry(dev, &bus->devices, bus_list) {
          if (pci_is_bridge(dev)) {
            ...
          }
        }
      
      Add a for_each_pci_bridge() helper to make that code easier to write and
      read by reducing indentation level.  It also saves one or few lines of code
      in each occurrence.
      
      Convert PCI core parts here at the same time.
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      [bhelgaas: fold in http://lkml.kernel.org/r/20171013165352.25550-1-andriy.shevchenko@linux.intel.com]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      24a0c654
  15. 30 8月, 2017 4 次提交
    • S
      PCI: Warn periodically while waiting for non-CRS ("device ready") status · e78e661f
      Sinan Kaya 提交于
      Add a print statement in pci_bus_wait_crs() so that user observes the
      progress of device polling instead of silently waiting for timeout to be
      reached.
      Signed-off-by: NSinan Kaya <okaya@codeaurora.org>
      [bhelgaas: check for timeout first so we don't print "waiting, giving up",
      always print time we've slept (not the actual timeout, print a "ready"
      message if we've printed a "waiting" message]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      e78e661f
    • S
      PCI: Factor out pci_bus_wait_crs() · 6a802ef0
      Sinan Kaya 提交于
      Configuration Request Retry Status (CRS) was previously hidden inside
      pci_bus_read_dev_vendor_id().  We want to add support for CRS in other
      situations, such as waiting for a device to become ready after a Function
      Level Reset.
      
      Move CRS handling into pci_bus_wait_crs() so it can be called from other
      places.
      Signed-off-by: NSinan Kaya <okaya@codeaurora.org>
      [bhelgaas: pass pointer, not value, to pci_bus_wait_crs() so caller gets
      correct Vendor ID]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      6a802ef0
    • S
      PCI: Add pci_bus_crs_vendor_id() to detect CRS response data · 62bc6a6f
      Sinan Kaya 提交于
      Add pci_bus_crs_vendor_id() to determine whether data returned for a config
      read of the Vendor ID indicates a Configuration Request Retry Status (CRS)
      response.
      
      Per PCIe r3.1, sec 2.3.2, this data is only returned if:
      
        - CRS Software Visibility is enabled,
        - a config read includes both bytes of the Vendor ID, and
        - the read receives a CRS completion
      Signed-off-by: NSinan Kaya <okaya@codeaurora.org>
      [bhelgaas: changelog, change name to pci_bus_crs_vendor_id(), make static
      in probe.c, use it in pci_bus_read_dev_vendor_id()]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      62bc6a6f
    • B
      PCI: Always check for non-CRS response before timeout · 9f982756
      Bjorn Helgaas 提交于
      While waiting for a device to become ready (i.e., to return a non-CRS
      completion to a read of its Vendor ID), if we got a valid response to the
      very last read before timing out, we printed a warning and gave up on the
      device even though it was actually ready.
      
      For a typical 60s timeout, we wait about 65s (it's not exact because of the
      exponential backoff), but we treated devices that became ready between 33s
      and 65s as though they failed.
      
      Move the Device ID read later so we check whether the device is ready
      before checking for a timeout.
      
      Thanks to Sinan Kaya <okaya@codeaurora.org>, reorder reads so we always
      check device presence after sleep, since it's pointless to sleep unless we
      recheck afterwards.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      9f982756
  16. 15 8月, 2017 1 次提交
  17. 03 8月, 2017 1 次提交
  18. 01 8月, 2017 1 次提交
  19. 03 7月, 2017 1 次提交
    • L
      PCI: Remove pci_scan_root_bus_msi() · 9ee8a1c4
      Lorenzo Pieralisi 提交于
      The pci_scan_root_bus_bridge() function allows passing a parameterized
      struct pci_host_bridge and scanning the resulting PCI bus; since the struct
      msi_controller is part of the struct pci_host_bridge and the struct
      pci_host_bridge can now be passed to pci_scan_root_bus_bridge() explicitly,
      there is no need for a scan interface with a MSI controller parameter.
      
      With all PCI host controller drivers and platform code relying on
      pci_scan_root_bus_msi() converted over to pci_scan_root_bus_bridge() the
      pci_scan_root_bus_msi() becomes obsolete and can be removed.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      9ee8a1c4
  20. 29 6月, 2017 6 次提交
    • B
      PCI: Enable ECRC only if device supports it · 675734ba
      Bjorn Helgaas 提交于
      John reported that an Intel QuickAssist crypto accelerator didn't work in a
      Dell PowerEdge R730.  The problem seems to be that we enabled ECRC when the
      device doesn't support it:
      
        85:00.0 Co-processor [0b40]: Intel Corporation DH895XCC Series QAT [8086:0435]
          Capabilities: [100 v1] Advanced Error Reporting
            AERCap: First Error Pointer: 00, GenCap- CGenEn+ ChkCap- ChkEn+
      
      1302fcf0 ("PCI: Configure *all* devices, not just hot-added ones")
      exposed the problem because it applies settings from the _HPX method to all
      devices, not just hot-added ones.  The R730 supplies an _HPX method that
      allows the kernel to enable ECRC.
      
      Only enable ECRC if the device advertises support for it.
      
      Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1571798
      Fixes: 1302fcf0 ("PCI: Configure *all* devices, not just hot-added ones")
      Reported-by: NJohn Mazzie <john_mazzie@dell.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      675734ba
    • L
      PCI: Make pci_register_host_bridge() PCI core internal · cea9bc0b
      Lorenzo Pieralisi 提交于
      With the introduction of pci_scan_root_bus_bridge() there is no need to
      export pci_register_host_bridge() to other kernel subsystems other than the
      PCI compilation unit that needs it.
      
      Make pci_register_host_bridge() static to its compilation unit and convert
      the existing drivers usage over to pci_scan_root_bus_bridge().
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      cea9bc0b
    • L
      PCI: Add pci_scan_root_bus_bridge() interface · 1228c4b6
      Lorenzo Pieralisi 提交于
      The current pci_scan_root_bus() interface is made up of two main code
      paths:
      
        - pci_create_root_bus()
        - pci_scan_child_bus()
      
      pci_create_root_bus() is a wrapper function that allows to create a struct
      pci_host_bridge structure, initialize it with the passed parameters and
      register it with the kernel.
      
      As the struct pci_host_bridge require additional struct members,
      pci_create_root_bus() parameters list has grown in time, making it unwieldy
      to add further parameters to it in case the struct pci_host_bridge gains
      more members fields to augment its functionality.
      
      Since PCI core code provides functions to allocate struct pci_host_bridge,
      instead of forcing the pci_create_root_bus() interface to add new
      parameters to cater for new struct pci_host_bridge functionality, it is
      more suitable to add an interface in PCI core code to scan a PCI bus
      straight from a struct pci_host_bridge created and customized by each
      specific PCI host controller driver.
      
      Add a pci_scan_root_bus_bridge() function to allow PCI host controller
      drivers to create and initialize struct pci_host_bridge and scan the
      resulting bus.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      1228c4b6
    • L
      PCI: Add devm_pci_alloc_host_bridge() interface · 5c3f18cc
      Lorenzo Pieralisi 提交于
      Struct pci_host_bridge can be allocated by PCI host bridge drivers which
      usually allocate and map memory through devm managed interfaces.
      
      Add a devm version for the pci_alloc_host_bridge() interface to simplify
      PCI host controller driver porting and simplify the driver failure paths.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      5c3f18cc
    • L
      PCI: Add pci_free_host_bridge() interface · dff79b91
      Lorenzo Pieralisi 提交于
      Commit a52d1443 ("PCI: Export host bridge registration interface")
      exported the pci_alloc_host_bridge() interface so that PCI host controllers
      drivers can make use of it.
      
      Introduce pci_alloc_host_bridge() kernel counterpart to free the host
      bridge data structures, pci_free_host_bridge(), export it and update kernel
      functions releasing host bridge objects allocated memory to make use of it.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      dff79b91
    • 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
  21. 17 6月, 2017 1 次提交
  22. 20 4月, 2017 1 次提交