thunderbolt: Read DP IN adapter first two dwords in one go
authorMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 19 Sep 2019 11:55:23 +0000 (14:55 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 8 Oct 2019 09:08:01 +0000 (12:08 +0300)
commitfd5c46b754d4799afda8dcdd6851e0390aa4961a
treea30ec060a1a7d0439d0b31d46317bb0b96e5f8b7
parentda0c9ea146cbe92b832f1b0f694840ea8eb33cce
thunderbolt: Read DP IN adapter first two dwords in one go

When we discover existing DP tunnels the code checks whether DP IN
adapter port is enabled by calling tb_dp_port_is_enabled() before it
continues the discovery process. On Light Ridge (gen 1) controller
reading only the first dword of the DP IN config space causes subsequent
access to the same DP IN port path config space to fail or return
invalid data as can be seen in the below splat:

  thunderbolt 0000:07:00.0: CFG_ERROR(0:d): Invalid config space or offset
  Call Trace:
   tb_cfg_read+0xb9/0xd0
   __tb_path_deactivate_hop+0x98/0x210
   tb_path_activate+0x228/0x7d0
   tb_tunnel_restart+0x95/0x200
   tb_handle_hotplug+0x30e/0x630
   process_one_work+0x1b4/0x340
   worker_thread+0x44/0x3d0
   kthread+0xeb/0x120
   ? process_one_work+0x340/0x340
   ? kthread_park+0xa0/0xa0
   ret_from_fork+0x1f/0x30

If both DP In adapter config dwords are read in one go the issue does
not reproduce. This is likely firmware bug but we can work it around by
always reading the two dwords in one go. There should be no harm for
other controllers either so can do it unconditionally.

Link: https://lkml.org/lkml/2019/8/28/160
Reported-by: Brad Campbell <lists2009@fnarfbargle.com>
Tested-by: Brad Campbell <lists2009@fnarfbargle.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/switch.c