Skip to content

Commit fd5c46b

Browse files
committed
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 <[email protected]> Tested-by: Brad Campbell <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent da0c9ea commit fd5c46b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/thunderbolt/switch.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -896,12 +896,13 @@ int tb_dp_port_set_hops(struct tb_port *port, unsigned int video,
896896
*/
897897
bool tb_dp_port_is_enabled(struct tb_port *port)
898898
{
899-
u32 data;
899+
u32 data[2];
900900

901-
if (tb_port_read(port, &data, TB_CFG_PORT, port->cap_adap, 1))
901+
if (tb_port_read(port, data, TB_CFG_PORT, port->cap_adap,
902+
ARRAY_SIZE(data)))
902903
return false;
903904

904-
return !!(data & (TB_DP_VIDEO_EN | TB_DP_AUX_EN));
905+
return !!(data[0] & (TB_DP_VIDEO_EN | TB_DP_AUX_EN));
905906
}
906907

907908
/**
@@ -914,19 +915,21 @@ bool tb_dp_port_is_enabled(struct tb_port *port)
914915
*/
915916
int tb_dp_port_enable(struct tb_port *port, bool enable)
916917
{
917-
u32 data;
918+
u32 data[2];
918919
int ret;
919920

920-
ret = tb_port_read(port, &data, TB_CFG_PORT, port->cap_adap, 1);
921+
ret = tb_port_read(port, data, TB_CFG_PORT, port->cap_adap,
922+
ARRAY_SIZE(data));
921923
if (ret)
922924
return ret;
923925

924926
if (enable)
925-
data |= TB_DP_VIDEO_EN | TB_DP_AUX_EN;
927+
data[0] |= TB_DP_VIDEO_EN | TB_DP_AUX_EN;
926928
else
927-
data &= ~(TB_DP_VIDEO_EN | TB_DP_AUX_EN);
929+
data[0] &= ~(TB_DP_VIDEO_EN | TB_DP_AUX_EN);
928930

929-
return tb_port_write(port, &data, TB_CFG_PORT, port->cap_adap, 1);
931+
return tb_port_write(port, data, TB_CFG_PORT, port->cap_adap,
932+
ARRAY_SIZE(data));
930933
}
931934

932935
/* switch utility functions */

0 commit comments

Comments
 (0)