Skip to content
Snippets Groups Projects
  1. Aug 21, 2020
  2. Jun 28, 2017
  3. May 26, 2017
  4. Apr 19, 2017
    • Bjorn Helgaas's avatar
      PCI: Include PCI-to-PCIe bridges as "Downstream Ports" · 9b70ae49
      Bjorn Helgaas authored
      
      A PCI/PCI-X to PCI Express bridge, sometimes referred to as a "reverse
      bridge", is a bridge with conventional PCI or PCI-X on its primary side and
      a PCI Express Port on its secondary (downstream) side.
      
      That PCIe Port is a Downstream Port and could be connected to a slot, just
      like a Root Port or a Switch Downstream Port.  Make pcie_downstream_port()
      return true for them, so we can access the Slot registers in the PCIe
      capability.
      
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      9b70ae49
  5. Apr 04, 2017
  6. Mar 30, 2017
  7. Mar 02, 2017
  8. Feb 03, 2017
  9. Jan 30, 2017
    • Bjorn Helgaas's avatar
      PCI: Avoid possible deadlock on pci_lock and p->pi_lock · cdcb33f9
      Bjorn Helgaas authored
      pci_lock is an IRQ-safe spinlock that protects all accesses to PCI
      configuration space (see PCI_OP_READ() and PCI_OP_WRITE() in pci/access.c).
      
      The pci_cfg_access_unlock() path acquires pci_lock, then p->pi_lock (inside
      wake_up_all()).  According to lockdep, there is a possible path involving
      snbep_uncore_pci_read_counter() that could acquire them in the reverse
      order: acquiring p->pi_lock, then pci_lock, which could result in a
      deadlock.  Lockdep details are in the bugzilla below.
      
      Avoid the possible deadlock by dropping pci_lock before waking up any
      config access waiters.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=192901
      
      
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      cdcb33f9
  10. Nov 21, 2016
  11. Apr 15, 2016
  12. Mar 10, 2016
    • Bjorn Helgaas's avatar
      PCI: Sleep rather than busy-wait for VPD access completion · c521b014
      Bjorn Helgaas authored
      
      Use usleep_range() instead of udelay() while waiting for a VPD access to
      complete.  This is not a performance path, so no need to hog the CPU.
      
      Rationale for usleep_range() parameters:
      
        We clear PCI_VPD_ADDR_F for a read (or set it for a write), then wait for
        the device to change it.  For a device that updates PCI_VPD_ADDR between
        our config write and subsequent config read, we won't sleep at all and
        can get the device's maximum rate.
      
        Sleeping a minimum of 10 usec per 4-byte access limits throughput to
        about 400Kbytes/second.  VPD is small (32K bytes at most), and most
        devices use only a fraction of that.
      
        We back off exponentially up to 1024 usec per iteration.  If we reach
        1024, we've already waited up to 1008 usec (16 + 32 + ... + 512), so if
        we miss an update and wait an extra 1024 usec, we can still get about
        1/2 of the device's maximum rate.
      
      Tested-by: default avatarShane Seymour <shane.seymour@hpe.com>
      Tested-by: default avatarBabu Moger <babu.moger@oracle.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      c521b014
  13. Feb 29, 2016
  14. Jan 08, 2016
  15. Sep 24, 2015
  16. Jul 21, 2015
    • Mark Rustad's avatar
      PCI: Add dev_flags bit to access VPD through function 0 · 932c435c
      Mark Rustad authored
      
      Add a dev_flags bit, PCI_DEV_FLAGS_VPD_REF_F0, to access VPD through
      function 0 to provide VPD access on other functions.  This is for hardware
      devices that provide copies of the same VPD capability registers in
      multiple functions.  Because the kernel expects that each function has its
      own registers, both the locking and the state tracking are affected by VPD
      accesses to different functions.
      
      On such devices for example, if a VPD write is performed on function 0,
      *any* later attempt to read VPD from any other function of that device will
      hang.  This has to do with how the kernel tracks the expected value of the
      F bit per function.
      
      Concurrent accesses to different functions of the same device can not only
      hang but also corrupt both read and write VPD data.
      
      When hangs occur, typically the error message:
      
        vpd r/w failed.  This is likely a firmware bug on this device.
      
      will be seen.
      
      Never set this bit on function 0 or there will be an infinite recursion.
      
      Signed-off-by: default avatarMark Rustad <mark.d.rustad@intel.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarAlexander Duyck <alexander.h.duyck@redhat.com>
      CC: stable@vger.kernel.org
      932c435c
  17. Jul 14, 2015
    • Bjorn Helgaas's avatar
      PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports) · ffb4d602
      Bjorn Helgaas authored
      
      As used in the PCIe spec, "Downstream Port" includes both Root Ports and
      Switch Downstream Ports.  We sometimes checked for PCI_EXP_TYPE_DOWNSTREAM
      when we should have checked for PCI_EXP_TYPE_ROOT_PORT or
      PCI_EXP_TYPE_DOWNSTREAM.
      
      For a Root Port without a slot, the effect of this was that using
      pcie_capability_read_word() to read PCI_EXP_SLTSTA returned zero instead of
      showing the Presence Detect State bit hardwired to one as the PCIe Spec,
      r3.0, sec 7.8, requires.  (This read is completed in software because
      previous PCIe spec versions didn't require PCI_EXP_SLTSTA to exist at all.)
      
      Nothing in the kernel currently depends on this (pciehp only reads
      PCI_EXP_SLTSTA on ports with slots), so this is a cleanup and not a
      functional change.
      
      Add a pcie_downstream_port() helper function and use it.
      
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ffb4d602
  18. Jan 22, 2015
    • Rob Herring's avatar
      PCI: Add generic config accessors · 1f94a94f
      Rob Herring authored
      
      Many PCI controllers' configuration space accesses are memory-mapped and
      vary only in address calculation and access checks.  There are 2 main
      access methods: a decoded address space such as ECAM or a single address
      and data register similar to x86.  This implementation can support both
      cases as well as be used in cases that need additional pre- or post-access
      handling.
      
      Add a new pci_ops member, map_bus, which can do access checks and any
      necessary setup.  It returns the address to use for the configuration space
      access.  The access types supported are 32-bit only accesses or correct
      byte, word, or dword sized accesses.
      
      Tested-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarThierry Reding <treding@nvidia.com>
      1f94a94f
  19. Nov 13, 2014
  20. Jun 11, 2014
  21. May 27, 2014
  22. Jan 13, 2014
  23. Aug 29, 2013
  24. Aug 28, 2013
  25. Feb 15, 2013
  26. Jan 31, 2013
  27. Aug 23, 2012
    • Jiang Liu's avatar
      PCI: Add accessors for PCI Express Capability · 8c0d3a02
      Jiang Liu authored
      
      The PCI Express Capability (PCIe spec r3.0, sec 7.8) comes in two
      versions, v1 and v2.  In v1 Capability structures (PCIe spec r1.0 and
      r1.1), some fields are optional, so the structure size depends on the
      device type.
      
      This patch adds functions to access this capability so drivers don't
      have to be aware of the differences between v1 and v2.  Note that these
      new functions apply only to the "PCI Express Capability," not to any of
      the other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.)
      
      Function pcie_capability_read_word/dword() reads the PCIe Capabilities
      register and returns the value in the reference parameter "val".  If
      the PCIe Capabilities register is not implemented on the PCIe device,
      "val" is set to 0.
      
      Function pcie_capability_write_word/dword() writes the value to the
      specified PCIe Capability register.
      
      Function pcie_capability_clear_and_set_word/dword() sets and/or clears bits
      of a PCIe Capability register.
      
      [bhelgaas: changelog, drop "pci_" prefixes, don't export
      pcie_capability_reg_implemented()]
      Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
      Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      8c0d3a02
  28. Jun 12, 2012
  29. Jan 06, 2012
    • Jan Kiszka's avatar
      PCI: Introduce INTx check & mask API · a2e27787
      Jan Kiszka authored
      
      These new PCI services allow to probe for 2.3-compliant INTx masking
      support and then use the feature from PCI interrupt handlers. The
      services are properly synchronized with concurrent config space access
      via sysfs or on device reset.
      
      This enables generic PCI device drivers like uio_pci_generic or KVM's
      device assignment to implement the necessary kernel-side IRQ handling
      without any knowledge about device-specific interrupt status and control
      registers.
      
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
      a2e27787
    • Jan Kiszka's avatar
      PCI: Rework config space blocking services · fb51ccbf
      Jan Kiszka authored
      
      pci_block_user_cfg_access was designed for the use case that a single
      context, the IPR driver, temporarily delays user space accesses to the
      config space via sysfs. This assumption became invalid by the time
      pci_dev_reset was added as locking instance. Today, if you run two loops
      in parallel that reset the same device via sysfs, you end up with a
      kernel BUG as pci_block_user_cfg_access detect the broken assumption.
      
      This reworks the pci_block_user_cfg_access to a sleeping service
      pci_cfg_access_lock and an atomic-compatible variant called
      pci_cfg_access_trylock. The former not only blocks user space access as
      before but also waits if access was already locked. The latter service
      just returns false in this case, allowing the caller to resolve the
      conflict instead of raising a BUG.
      
      Adaptions of the ipr driver were originally written by Brian King.
      
      Acked-by: default avatarBrian King <brking@linux.vnet.ibm.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
      fb51ccbf
Loading