1. 26 Nov, 2018 1 commit
  2. 02 Oct, 2018 3 commits
  3. 25 Jul, 2018 1 commit
    • Mika Westerberg's avatar
      thunderbolt: Add support for runtime PM · 2d8ff0b5
      Mika Westerberg authored
      When Thunderbolt host controller is set to RTD3 mode (Runtime D3) it is
      present all the time. Because of this it is important to runtime suspend
      the controller whenever possible. In case of ICM we have following rules
      which all needs to be true before the host controller can be put to D3:
        - The controller firmware reports to support RTD3
        - All the connected devices announce support for RTD3
        - There is no active XDomain connection
      Implement this using standard Linux runtime PM APIs so that when all the
      children devices are runtime suspended, the Thunderbolt host controller
      PCI device is runtime suspended as well. The ICM firmware then starts
      powering down power domains towards RTD3 but it can prevent this if it
      detects that there is an active Display Port stream (this is not visible
      to the software, though).
      The Thunderbolt host controller will be runtime resumed either when
      there is a remote wake event (device is connected or disconnected), or
      when there is access from userspace that requires hardware access.
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  4. 09 Mar, 2018 5 commits
  5. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      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
      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: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  6. 02 Oct, 2017 1 commit
    • Mika Westerberg's avatar
      thunderbolt: Add support for XDomain discovery protocol · d1ff7024
      Mika Westerberg authored
      When two hosts are connected over a Thunderbolt cable, there is a
      protocol they can use to communicate capabilities supported by the host.
      The discovery protocol uses automatically configured control channel
      (ring 0) and is build on top of request/response transactions using
      special XDomain primitives provided by the Thunderbolt base protocol.
      The capabilities consists of a root directory block of basic properties
      used for identification of the host, and then there can be zero or more
      directories each describing a Thunderbolt service and its capabilities.
      Once both sides have discovered what is supported the two hosts can
      setup high-speed DMA paths and transfer data to the other side using
      whatever protocol was agreed based on the properties. The software
      protocol used to communicate which DMA paths to enable is service
      This patch adds support for the XDomain discovery protocol to the
      Thunderbolt bus. We model each remote host connection as a Linux XDomain
      device. For each Thunderbolt service found supported on the XDomain
      device, we create Linux Thunderbolt service device which Thunderbolt
      service drivers can then bind to based on the protocol identification
      information retrieved from the property directory describing the
      This code is based on the work done by Amir Levy and Michael Jamet.
      Signed-off-by: default avatarMichael Jamet <michael.jamet@intel.com>
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: default avatarYehezkel Bernat <yehezkel.bernat@intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  7. 28 Aug, 2017 3 commits
  8. 24 Jul, 2017 1 commit
  9. 17 Jul, 2017 1 commit
  10. 09 Jun, 2017 10 commits
  11. 13 Nov, 2016 1 commit
    • Lukas Wunner's avatar
      thunderbolt: Use Device ROM retrieved from EFI · c9cc3aaa
      Lukas Wunner authored
      Macs with Thunderbolt 1 do not have a unit-specific DROM: The DROM is
      empty with uid 0x1000000000000. (Apple started factory-burning a unit-
      specific DROM with Thunderbolt 2.)
      Instead, the NHI EFI driver supplies a DROM in a device property. Use
      it if available. It's only available when booting with the efistub.
      If it's not available, silently fall back to our hardcoded DROM.
      The size of the DROM is always 256 bytes. The number is hardcoded into
      the NHI EFI driver. This commit can deal with an arbitrary size however,
      just in case they ever change that.
      Background information: The EFI firmware volume contains ROM files for
      the NHI, GMUX and several other chips as well as key material. This
      strategy allows Apple to deploy ROM or key updates by simply publishing
      an EFI firmware update on their website. Drivers do not access those
      files directly but rather through a file server via EFI protocol
      AC5E4829-A8FD-440B-AF33-9FFE013B12D8. Files are identified by GUID, the
      NHI DROM has 339370BD-CFC6-4454-8EF7-704653120818.
      The NHI EFI driver amends that file with a unit-specific uid. The uid
      has 64 bit but its entropy is much lower: 24 bit represent the model,
      24 bit are taken from a serial number, 16 bit are fixed. The NHI EFI
      driver obtains the serial number via the DataHub protocol, copies it
      into the DROM, calculates the CRC and submits the result as a device
      A modification is needed in the resume code where we currently read the
      uid of all switches in the hierarchy to detect plug events that occurred
      during sleep. On Thunderbolt 1 root switches this will now lead to a
      mismatch between the uid of the empty DROM and the EFI DROM. Exempt the
      root switch from this check: It's built in, so the uid should never
      change. However we continue to *read* the uid of the root switch, this
      seems like a good way to test its reachability after resume.
      Tested-by: Lukas Wunner <lukas@wunner.de> [MacBookPro9,1]
      Tested-by: Pierre Moreau <pierre.morrow@free.fr> [MacBookPro11,3]
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
      Acked-by: default avatarAndreas Noever <andreas.noever@gmail.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Pedro Vilaça <reverser@put.as>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20161112213237.8804-10-matt@codeblueprint.co.ukSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
  12. 31 Aug, 2016 1 commit
  13. 08 Apr, 2016 3 commits
    • Lukas Wunner's avatar
      thunderbolt: Support 1st gen Light Ridge controller · 19bf4d4f
      Lukas Wunner authored
      Add support for the 1st gen Light Ridge controller, which is built into
      these systems:
        iMac12,1       2011  21.5"
        iMac12,2       2011  27"
        Macmini5,1     2011  i5 2.3 GHz
        Macmini5,2     2011  i5 2.5 GHz
        Macmini5,3     2011  i7 2.0 GHz
        MacBookPro8,1  2011  13"
        MacBookPro8,2  2011  15"
        MacBookPro8,3  2011  17"
        MacBookPro9,1  2012  15"
        MacBookPro9,2  2012  13"
      Light Ridge (CV82524) was the very first copper Thunderbolt controller,
      introduced 2010 alongside its fiber-optic cousin Light Peak (CVL2510).
      Consequently the chip suffers from some teething troubles:
        - MSI is broken for hotplug signaling on the downstream bridges: The chip
          just never sends an interrupt.  It requests 32 MSIs for each of its six
          bridges and the pcieport driver only allocates one per bridge.  However
          I've verified that even if 32 MSIs are allocated there's no interrupt
          on hotplug.  The only option is thus to disable MSI, which is also what
          OS X does.  Apparently all Thunderbolt chips up to revision 1 of Cactus
          Ridge 4C are plagued by this issue so quirk those as well.
        - The chip supports a maximum hop_count of 32, unlike its successors
          which support only 12.  Fixup ring_interrupt_active() to cope with
          values >= 32.
        - Another peculiarity is that the chip supports a maximum of 13 ports
          whereas its successors support 12.  However the additional port (#5)
          seems to be unusable as reading its TB_CFG_PORT config space results in
          TB_CFG_ERROR_INVALID_CONFIG_SPACE.  Add a quirk to mark the port
          disabled on the root switch, assuming that's necessary on all Macs
          using this chip.
      Tested-by: Lukas Wunner <lukas@wunner.de> [MacBookPro9,1]
      Tested-by: William Brown <william@blackhats.net.au> [MacBookPro8,2]
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarAndreas Noever <andreas.noever@gmail.com>
    • Lukas Wunner's avatar
      thunderbolt: Fix typos and magic number · aae20bb6
      Lukas Wunner authored
      Fix typo in tb_cfg_print_error() message.  Fix bytecount in struct
      tb_drom_entry_port comment.  Replace magic number in tb_switch_alloc().
      Rename tb_sw_set_unpplugged() and TB_CAL_IECS to fix typos.
      [bhelgaas: no functional change intended]
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarAndreas Noever <andreas.noever@gmail.com>
    • Lukas Wunner's avatar
      PCI: Add Intel Thunderbolt device IDs · 1d111406
      Lukas Wunner authored
      Intel Gen 1 and 2 chips use the same ID for NHI, bridges and switch.  Gen 3
      chips and onward use a distinct ID for the NHI.
      No functional change intended.
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarAndreas Noever <andreas.noever@gmail.com>
  14. 20 Jun, 2014 2 commits
  15. 19 Jun, 2014 6 commits