1. 26 5月, 2019 1 次提交
  2. 11 8月, 2018 1 次提交
    • A
      PCI: Check for PCIe Link downtraining · 2d1ce5ec
      Alexandru Gagniuc 提交于
      When both ends of a PCIe Link are capable of a higher bandwidth than is
      currently in use, the Link is said to be "downtrained".  A downtrained Link
      may indicate hardware or configuration problems in the system, but it's
      hard to identify such Links from userspace.
      
      Refactor pcie_print_link_status() so it continues to always print PCIe
      bandwidth information, as several NIC drivers desire.
      
      Add a new internal __pcie_print_link_status() to emit a message only when a
      device's bandwidth is constrained by the fabric and call it from the PCI
      core for all devices, which identifies all downtrained Links.  It also
      emits messages for a few cases that are technically not downtrained, such
      as a x4 device in an open-ended x1 slot.
      Signed-off-by: NAlexandru Gagniuc <mr.nuke.me@gmail.com>
      [bhelgaas: changelog, move __pcie_print_link_status() declaration to
      drivers/pci/, rename pcie_check_upstream_link() to
      pcie_report_downtraining()]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      2d1ce5ec
  3. 10 8月, 2018 2 次提交
  4. 01 8月, 2018 1 次提交
    • H
      PCI: Fix is_added/is_busmaster race condition · 44bda4b7
      Hari Vyas 提交于
      When a PCI device is detected, pdev->is_added is set to 1 and proc and
      sysfs entries are created.
      
      When the device is removed, pdev->is_added is checked for one and then
      device is detached with clearing of proc and sys entries and at end,
      pdev->is_added is set to 0.
      
      is_added and is_busmaster are bit fields in pci_dev structure sharing same
      memory location.
      
      A strange issue was observed with multiple removal and rescan of a PCIe
      NVMe device using sysfs commands where is_added flag was observed as zero
      instead of one while removing device and proc,sys entries are not cleared.
      This causes issue in later device addition with warning message
      "proc_dir_entry" already registered.
      
      Debugging revealed a race condition between the PCI core setting the
      is_added bit in pci_bus_add_device() and the NVMe driver reset work-queue
      setting the is_busmaster bit in pci_set_master().  As these fields are not
      handled atomically, that clears the is_added bit.
      
      Move the is_added bit to a separate private flag variable and use atomic
      functions to set and retrieve the device addition state.  This avoids the
      race because is_added no longer shares a memory location with is_busmaster.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=200283Signed-off-by: NHari Vyas <hari.vyas@broadcom.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NLukas Wunner <lukas@wunner.de>
      Acked-by: NMichael Ellerman <mpe@ellerman.id.au>
      44bda4b7
  5. 21 7月, 2018 2 次提交
  6. 20 7月, 2018 5 次提交
  7. 13 7月, 2018 1 次提交
    • J
      PCI: Workaround IDT switch ACS Source Validation erratum · aa667c64
      James Puthukattukaran 提交于
      Some IDT switches incorrectly flag an ACS Source Validation error on
      completions for config read requests even though PCIe r4.0, sec 6.12.1.1,
      says that completions are never affected by ACS Source Validation.  Here's
      the text of IDT 89H32H8G3-YC, erratum #36:
      
        Item #36 - Downstream port applies ACS Source Validation to Completions
        Section 6.12.1.1 of the PCI Express Base Specification 3.1 states that
        completions are never affected by ACS Source Validation.  However,
        completions received by a downstream port of the PCIe switch from a
        device that has not yet captured a PCIe bus number are incorrectly
        dropped by ACS Source Validation by the switch downstream port.
      
        Workaround: Issue a CfgWr1 to the downstream device before issuing the
        first CfgRd1 to the device.  This allows the downstream device to capture
        its bus number; ACS Source Validation no longer stops completions from
        being forwarded by the downstream port.  It has been observed that
        Microsoft Windows implements this workaround already; however, some
        versions of Linux and other operating systems may not.
      
      When doing the first config read to probe for a device, if the device is
      behind an IDT switch with this erratum:
      
        1. Disable ACS Source Validation if enabled
        2. Wait for device to become ready to accept config accesses (by using
           the Config Request Retry Status mechanism)
        3. Do a config write to the endpoint
        4. Enable ACS Source Validation (if it was enabled to begin with)
      
      The workaround suggested by IDT is basically only step 3, but we don't know
      when the device is ready to accept config requests.  That means we need to
      do config reads until we receive a non-Config Request Retry Status, which
      means we need to disable ACS SV temporarily.
      Signed-off-by: NJames Puthukattukaran <james.puthukattukaran@oracle.com>
      [bhelgaas: changelog, clean up whitespace, fold in unused variable fix
      from Anders Roxell <anders.roxell@linaro.org>]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NAlex Williamson <alex.williamson@redhat.com>
      aa667c64
  8. 30 6月, 2018 2 次提交
    • S
      PCI: Make early dump functionality generic · 11eb0e0e
      Sinan Kaya 提交于
      Move early dump functionality into common code so that it is available for
      all architectures.  No need to carry arch-specific reads around as the read
      hooks are already initialized by the time pci_setup_device() is getting
      called during scan.
      Tested-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: NSinan Kaya <okaya@codeaurora.org>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      11eb0e0e
    • J
      PCI/IOV: Reset total_VFs limit after detaching PF driver · 38972375
      Jakub Kicinski 提交于
      The TotalVFs register in the SR-IOV capability is the hardware limit on the
      number of VFs.  A PF driver can limit the number of VFs further with
      pci_sriov_set_totalvfs().  When the PF driver is removed, reset any VF
      limit that was imposed by the driver because that limit may not apply to
      other drivers.
      
      Before 8d85a7a4 ("PCI/IOV: Allow PF drivers to limit total_VFs to 0"),
      pci_sriov_set_totalvfs(pdev, 0) meant "we can enable TotalVFs virtual
      functions", and the nfp driver used that to remove the VF limit when the
      driver unloads.
      
      8d85a7a4 broke that because instead of removing the VF limit,
      pci_sriov_set_totalvfs(pdev, 0) actually sets the limit to zero, and that
      limit persists even if another driver is loaded.
      
      We could fix that by making the nfp driver reset the limit when it unloads,
      but it seems more robust to do it in the PCI core instead of relying on the
      driver.
      
      The regression scenario is:
      
        nfp_pci_probe (driver 1)
        ...
        nfp_pci_remove
          pci_sriov_set_totalvfs(pf->pdev, 0)   # limits VFs to 0
      
        ...
        nfp_pci_probe (driver 2)
          nfp_rtsym_read_le("nfd_vf_cfg_max_vfs")
          # no VF limit from firmware
      
      Now driver 2 is broken because the VF limit is still 0 from driver 1.
      
      Fixes: 8d85a7a4 ("PCI/IOV: Allow PF drivers to limit total_VFs to 0")
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      [bhelgaas: changelog, rename functions]
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      38972375
  9. 03 6月, 2018 1 次提交
  10. 18 5月, 2018 2 次提交
  11. 15 5月, 2018 1 次提交
  12. 01 4月, 2018 1 次提交
  13. 31 3月, 2018 3 次提交
  14. 20 3月, 2018 2 次提交
  15. 12 3月, 2018 1 次提交
  16. 19 12月, 2017 2 次提交
  17. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  18. 25 10月, 2017 1 次提交
  19. 06 10月, 2017 2 次提交
  20. 01 8月, 2017 1 次提交
  21. 13 7月, 2017 1 次提交
    • R
      PCI / PM: Restore PME Enable after config space restoration · 0ce3fcaf
      Rafael J. Wysocki 提交于
      Commit dc15e71e (PCI / PM: Restore PME Enable if skipping wakeup
      setup) introduced a mechanism by which the PME Enable bit can be
      restored by pci_enable_wake() if dev->wakeup_prepared is set in
      case it has been overwritten by PCI config space restoration.
      
      However, that commit overlooked the fact that on some systems (Dell
      XPS13 9360 in particular) the AML handling wakeup events checks PME
      Status and PME Enable and it won't trigger a Notify() for devices
      where those bits are not set while it is running.
      
      That happens during resume from suspend-to-idle when pci_restore_state()
      invoked by pci_pm_default_resume_early() clears PME Enable before the
      wakeup events are processed by AML, effectively causing those wakeup
      events to be ignored.
      
      Fix this issue by restoring the PME Enable configuration right after
      pci_restore_state() has been called instead of doing that in
      pci_enable_wake().
      
      Fixes: dc15e71e (PCI / PM: Restore PME Enable if skipping wakeup setup)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NBjorn Helgaas <bhelgaas@google.com>
      0ce3fcaf
  22. 28 6月, 2017 1 次提交
  23. 15 6月, 2017 1 次提交
  24. 20 4月, 2017 2 次提交
  25. 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
  26. 30 3月, 2017 1 次提交