Skip to content

Commit 24edc39

Browse files
Aapo Vienamowesteri
authored andcommitted
thunderbolt: Add missing usb4_port_sb_read() to usb4_port_sw_margin()
Synchronize the operation completion by reading back the software margining operation completion metadata into margining->results. Signed-off-by: Aapo Vienamo <[email protected]> Co-developed-by: R Kannappan <[email protected]> Signed-off-by: R Kannappan <[email protected]> Co-developed-by: Rene Sapiens <[email protected]> Signed-off-by: Rene Sapiens <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent 47ac09b commit 24edc39

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

drivers/thunderbolt/debugfs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,8 @@ static int margining_run_write(void *data, u64 val)
785785
margining->time ? "time" : "voltage", dev_name(dev),
786786
margining->lanes);
787787
ret = usb4_port_sw_margin(port, margining->target, margining->index,
788-
margining->lanes, margining->time,
789-
margining->right_high,
790-
USB4_MARGIN_SW_COUNTER_CLEAR);
788+
margining->lanes, margining->time, margining->right_high,
789+
USB4_MARGIN_SW_COUNTER_CLEAR, &margining->results[0]);
791790
if (ret)
792791
goto out_clx;
793792

drivers/thunderbolt/tb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
13601360
bool timing, bool right_high, u32 *results);
13611361
int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
13621362
u8 index, unsigned int lanes, bool timing,
1363-
bool right_high, u32 counter);
1363+
bool right_high, u32 counter, u32 *results);
13641364
int usb4_port_sw_margin_errors(struct tb_port *port, enum usb4_sb_target target,
13651365
u8 index, u32 *errors);
13661366

drivers/thunderbolt/usb4.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,14 +1703,15 @@ int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
17031703
* @timing: Perform timing margining instead of voltage
17041704
* @right_high: Use Right/high margin instead of left/low
17051705
* @counter: What to do with the error counter
1706+
* @results: Data word for the operation completion data
17061707
*
17071708
* Runs software lane margining on USB4 port. Read back the error
17081709
* counters by calling usb4_port_sw_margin_errors(). Returns %0 in
17091710
* success and negative errno otherwise.
17101711
*/
17111712
int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
17121713
u8 index, unsigned int lanes, bool timing,
1713-
bool right_high, u32 counter)
1714+
bool right_high, u32 counter, u32 *results)
17141715
{
17151716
u32 val;
17161717
int ret;
@@ -1728,8 +1729,14 @@ int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
17281729
if (ret)
17291730
return ret;
17301731

1731-
return usb4_port_sb_op(port, target, index,
1732-
USB4_SB_OPCODE_RUN_SW_LANE_MARGINING, 2500);
1732+
ret = usb4_port_sb_op(port, target, index,
1733+
USB4_SB_OPCODE_RUN_SW_LANE_MARGINING, 2500);
1734+
if (ret)
1735+
return ret;
1736+
1737+
return usb4_port_sb_read(port, target, index, USB4_SB_DATA, results,
1738+
sizeof(*results));
1739+
17331740
}
17341741

17351742
/**

0 commit comments

Comments
 (0)