Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thunderbolt: Add dummy read after port capability list walk on Light Ridge

Light Ridge has an issue where reading the next capability pointer
location in port config space the read data is not cleared. It is fine
to read capabilities each after another so only thing we need to do is
to make sure we issue dummy read after tb_port_find_cap() is finished to
avoid the issue in next read.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

+16
+16
drivers/thunderbolt/cap.c
··· 52 52 return tb_sw_write(sw, &value, TB_CFG_SWITCH, offset, 1); 53 53 } 54 54 55 + static void tb_port_dummy_read(struct tb_port *port) 56 + { 57 + /* 58 + * When reading from next capability pointer location in port 59 + * config space the read data is not cleared on LR. To avoid 60 + * reading stale data on next read perform one dummy read after 61 + * port capabilities are walked. 62 + */ 63 + if (tb_switch_is_lr(port->sw)) { 64 + u32 dummy; 65 + 66 + tb_port_read(port, &dummy, TB_CFG_PORT, 0, 1); 67 + } 68 + } 69 + 55 70 static int __tb_port_find_cap(struct tb_port *port, enum tb_port_cap cap) 56 71 { 57 72 u32 offset = 1; ··· 107 92 108 93 ret = __tb_port_find_cap(port, cap); 109 94 95 + tb_port_dummy_read(port); 110 96 tb_port_enable_tmu(port, false); 111 97 112 98 return ret;