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 <aapo.vienamo@linux.intel.com>
Co-developed-by: R Kannappan <r.kannappan@intel.com>
Signed-off-by: R Kannappan <r.kannappan@intel.com>
Co-developed-by: Rene Sapiens <rene.sapiens@intel.com>
Signed-off-by: Rene Sapiens <rene.sapiens@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
Aapo Vienamo 2024-07-19 21:37:17 +03:00 committed by Mika Westerberg
parent 47ac09b91b
commit 24edc39704
3 changed files with 13 additions and 7 deletions

View File

@ -785,9 +785,8 @@ static int margining_run_write(void *data, u64 val)
margining->time ? "time" : "voltage", dev_name(dev), margining->time ? "time" : "voltage", dev_name(dev),
margining->lanes); margining->lanes);
ret = usb4_port_sw_margin(port, margining->target, margining->index, ret = usb4_port_sw_margin(port, margining->target, margining->index,
margining->lanes, margining->time, margining->lanes, margining->time, margining->right_high,
margining->right_high, USB4_MARGIN_SW_COUNTER_CLEAR, &margining->results[0]);
USB4_MARGIN_SW_COUNTER_CLEAR);
if (ret) if (ret)
goto out_clx; goto out_clx;

View File

@ -1360,7 +1360,7 @@ int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
bool timing, bool right_high, u32 *results); bool timing, bool right_high, u32 *results);
int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target, int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
u8 index, unsigned int lanes, bool timing, u8 index, unsigned int lanes, bool timing,
bool right_high, u32 counter); bool right_high, u32 counter, u32 *results);
int usb4_port_sw_margin_errors(struct tb_port *port, enum usb4_sb_target target, int usb4_port_sw_margin_errors(struct tb_port *port, enum usb4_sb_target target,
u8 index, u32 *errors); u8 index, u32 *errors);

View File

@ -1703,6 +1703,7 @@ int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
* @timing: Perform timing margining instead of voltage * @timing: Perform timing margining instead of voltage
* @right_high: Use Right/high margin instead of left/low * @right_high: Use Right/high margin instead of left/low
* @counter: What to do with the error counter * @counter: What to do with the error counter
* @results: Data word for the operation completion data
* *
* Runs software lane margining on USB4 port. Read back the error * Runs software lane margining on USB4 port. Read back the error
* counters by calling usb4_port_sw_margin_errors(). Returns %0 in * counters by calling usb4_port_sw_margin_errors(). Returns %0 in
@ -1710,7 +1711,7 @@ int usb4_port_hw_margin(struct tb_port *port, enum usb4_sb_target target,
*/ */
int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target, int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
u8 index, unsigned int lanes, bool timing, u8 index, unsigned int lanes, bool timing,
bool right_high, u32 counter) bool right_high, u32 counter, u32 *results)
{ {
u32 val; u32 val;
int ret; int ret;
@ -1728,8 +1729,14 @@ int usb4_port_sw_margin(struct tb_port *port, enum usb4_sb_target target,
if (ret) if (ret)
return ret; return ret;
return usb4_port_sb_op(port, target, index, ret = usb4_port_sb_op(port, target, index,
USB4_SB_OPCODE_RUN_SW_LANE_MARGINING, 2500); USB4_SB_OPCODE_RUN_SW_LANE_MARGINING, 2500);
if (ret)
return ret;
return usb4_port_sb_read(port, target, index, USB4_SB_DATA, results,
sizeof(*results));
} }
/** /**