31 Aug, 2016

2 commits


03 May, 2016

1 commit

  • If tb_drom_read() fails, sw->drom is freed but not set to NULL. sw->drom
    is then freed again in the error path of tb_switch_alloc().

    The bug can be triggered by unplugging a thunderbolt device shortly after
    it is detected by the thunderbolt driver.

    Clear sw->drom if tb_drom_read() fails.

    [bhelgaas: add Fixes:, stable versions of interest]
    Fixes: 343fcb8c70d7 ("thunderbolt: Fix nontrivial endpoint devices.")
    Signed-off-by: Andreas Noever
    Signed-off-by: Bjorn Helgaas
    CC: stable@vger.kernel.org # v3.17+
    CC: Lukas Wunner

    Andreas Noever
     

09 Apr, 2016

3 commits

  • 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 [MacBookPro9,1]
    Tested-by: William Brown [MacBookPro8,2]
    Signed-off-by: Lukas Wunner
    Signed-off-by: Bjorn Helgaas
    Acked-by: Andreas Noever

    Lukas Wunner
     
  • 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: Lukas Wunner
    Signed-off-by: Bjorn Helgaas
    Acked-by: Andreas Noever

    Lukas Wunner
     
  • 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: Lukas Wunner
    Signed-off-by: Bjorn Helgaas
    Acked-by: Andreas Noever

    Lukas Wunner
     

21 Sep, 2015

1 commit

  • The pci device ids listed in the thunderbolt driver are to restrictive,
    which prevents the driver from being loaded on recent Apple MacBooks
    using a thunderbolt 2 controller. In particular this prevented any
    hot-plugging functionality for thunderbolt based ethernet dongles
    (i.e. Apples thunderbolt gigabit ethernet broadcom tg3 based dongle
    Model A1433 EMC 2590).

    Changing the subvendor and subdevice to PCI_ANY_ID the thunderbolt driver
    loads and binds to the pci device 07:00.0 System peripheral:
    Intel Corporation Device 156c which is the thunderbolt 2 controller on
    the MacBookPro12,1.

    Successfully tested on MacBookPro12,1. With the patch the thunderbolt
    module gets now loaded on boot. And it provides hot-plugging support both
    for a cold-plugged and a warm-plugged ethernet dongle.

    Signed-off-by: Andreas Noever
    Acked-by: Knuth Posern
    Signed-off-by: Greg Kroah-Hartman

    Knuth Posern
     

27 Aug, 2014

1 commit

  • Zero hops in tb_path_activate before writing a new path.

    This fixes the following scenario:
    - Boot with a coldplugged device
    - Unplug device
    - Plug device back in
    - PCI hotplug fails

    The hotplug operation fails because our new path matches the (now
    defunct) path which was setup by the firmware for the coldplugged
    device. By writing zeros before writing our path configuration we can
    force thunderbolt to retrain the path.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     

14 Jul, 2014

1 commit

  • The advantage of kcalloc is, that will prevent integer overflows
    which could result from the multiplication of number of elements
    and size and it is also a bit nicer to read.

    Signed-off-by: Himangi Saraogi
    Acked-by: Julia Lawall
    Acked-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Himangi Saraogi
     

08 Jul, 2014

1 commit

  • nhi->rx_rings does not have type as struct tb_ring *, as it is a
    double pointer so the elements of the array should have pointer type,
    not structure type.

    The Coccinelle semantic patch that makes this change is as follows:

    //
    @disable sizeof_type_expr@
    type T;
    T **x;
    @@

    x =

    //

    Signed-off-by: Himangi Saraogi
    Acked-by: Julia Lawall
    Cc: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Himangi Saraogi
     

22 Jun, 2014

1 commit


21 Jun, 2014

12 commits


20 Jun, 2014

15 commits

  • Fix issues observed with the Startech docking station:

    Fix the type of the route parameter in tb_ctl_rx. It should be u64 and not
    u8 (which only worked for short routes).

    A thunderbolt cable contains two lanes. If both endpoints support it a
    connection will be established on both lanes. Previously we tried to
    scan below both "dual link ports". Use the information extracted from
    the drom to only scan behind ports with lane_nr == 0.

    Endpoints with more complex thunderbolt controllers have some of their
    ports disabled (for example the NHI port or one of the HDMI/DP ports).
    Accessing them results in an error so we now ignore ports which are
    marked as disabled in the drom.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • All Thunderbolt switches (except the root switch) contain a drom which
    contains information about the device. Right now we only read the UID.

    Add code to read and parse this drom. For now we are only interested in
    which ports are disabled and which ports are "dual link ports" (a
    physical thunderbolt port/socket contains two such ports).

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • We use _noirq since we have to restore the pci tunnels before the pci
    core wakes the tunneled devices.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Add eeprom access code and read the uid during switch initialization.
    The UID will be used to check device identity after suspend.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • A pci downstream and pci upstream port can be connected through a
    tunnel. To establish the tunnel we have to setup two unidirectional
    paths between the two ports.

    Right now we only support paths with two hops (i.e. no chaining) and at
    most one pci device per thunderbolt device.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • A thunderbolt path is a unidirectional channel between two thunderbolt
    ports. Two such paths are needed to establish a pci tunnel.

    This patch introduces struct tb_path as well as a set of tb_path_*
    methods which are used to activate & deactivate paths.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • We receive a plug event callback whenever a thunderbolt device is added
    or removed. This patch fills in the tb_handle_hotplug method and starts
    reacting to these events by adding/removing switches from the hierarchy.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Add utility methods tb_port_state and tb_wait_for_port. Add
    tb_scan_switch which recursively checks for downstream switches.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Thunderbolt switches have a plug events capability. This patch adds the
    tb_plug_events_active method and uses it to activate plug events during
    switch allocation.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Thunderbolt config areas contain capability lists similar to those found
    on pci devices. This patch introduces a tb_find_cap utility method to
    search for capabilities.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • This patch adds the structures tb_switch and tb_port as well as code to
    initialize the root switch.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Every thunderbolt device consists (logically) of a switch with multiple
    ports. Every port contains up to four config regions (HOPS, PORT,
    SWITCH, COUNTERS) which are used to configure the device.

    The tb_regs.h file contains all known registers and capabilities from
    these config regions.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Add struct tb which will contain our view of the thunderbolt bus. For
    now it just contains a pointer to the control channel and a workqueue
    for hotplug events.

    Add thunderbolt_alloc_and_start() and thunderbolt_shutdown_and_free()
    which are responsible for setup and teardown of struct tb.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Thunderbolt devices are configured by reading/writing into their
    configuration space (similar to pci). This is done by sending packets
    through the NHI (native host interface) onto the control channel.

    This patch handles the low level packet based protocol and exposes
    higher level operations like tb_cfg_read/tb_cfg_write.

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever
     
  • Thunderbolt hotplug is supposed to be handled by the firmware. But Apple
    decided to implement thunderbolt at the operating system level. The
    firmare only initializes thunderbolt devices that are present at boot
    time. This driver enables hotplug of thunderbolt of non-chained
    thunderbolt devices on Apple systems with a cactus ridge controller.

    This first patch adds the Kconfig file as well the parts of the driver
    which talk directly to the hardware (that is pci device setup, interrupt
    handling and RX/TX ring management).

    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Andreas Noever