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