1. 30 3月, 2017 1 次提交
  2. 02 3月, 2017 1 次提交
  3. 04 2月, 2017 1 次提交
  4. 31 1月, 2017 1 次提交
    • B
      PCI: Avoid possible deadlock on pci_lock and p->pi_lock · cdcb33f9
      Bjorn Helgaas 提交于
      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=192901Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      cdcb33f9
  5. 22 11月, 2016 1 次提交
  6. 16 4月, 2016 1 次提交
  7. 11 3月, 2016 1 次提交
    • B
      PCI: Sleep rather than busy-wait for VPD access completion · c521b014
      Bjorn Helgaas 提交于
      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: NShane Seymour <shane.seymour@hpe.com>
      Tested-by: NBabu Moger <babu.moger@oracle.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      c521b014
  8. 01 3月, 2016 7 次提交
  9. 09 1月, 2016 1 次提交
  10. 25 9月, 2015 2 次提交
  11. 22 7月, 2015 1 次提交
    • M
      PCI: Add dev_flags bit to access VPD through function 0 · 932c435c
      Mark Rustad 提交于
      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: NMark Rustad <mark.d.rustad@intel.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NAlexander Duyck <alexander.h.duyck@redhat.com>
      CC: stable@vger.kernel.org
      932c435c
  12. 15 7月, 2015 1 次提交
    • B
      PCI: Add pcie_downstream_port() (true for Root and Switch Downstream Ports) · ffb4d602
      Bjorn Helgaas 提交于
      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: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ffb4d602
  13. 23 1月, 2015 1 次提交
    • R
      PCI: Add generic config accessors · 1f94a94f
      Rob Herring 提交于
      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: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NThierry Reding <treding@nvidia.com>
      1f94a94f
  14. 14 11月, 2014 1 次提交
  15. 11 6月, 2014 1 次提交
  16. 28 5月, 2014 1 次提交
  17. 14 1月, 2014 1 次提交
  18. 29 8月, 2013 4 次提交
  19. 16 2月, 2013 1 次提交
  20. 31 1月, 2013 1 次提交
  21. 23 8月, 2012 1 次提交
    • J
      PCI: Add accessors for PCI Express Capability · 8c0d3a02
      Jiang Liu 提交于
      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: NJiang Liu <jiang.liu@huawei.com>
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      8c0d3a02
  22. 12 6月, 2012 1 次提交
  23. 07 1月, 2012 2 次提交
    • J
      PCI: Introduce INTx check & mask API · a2e27787
      Jan Kiszka 提交于
      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: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      a2e27787
    • J
      PCI: Rework config space blocking services · fb51ccbf
      Jan Kiszka 提交于
      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: NBrian King <brking@linux.vnet.ibm.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      fb51ccbf
  24. 11 5月, 2011 2 次提交
  25. 19 5月, 2010 1 次提交
  26. 12 5月, 2010 1 次提交
  27. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  28. 17 6月, 2009 1 次提交