Skip to content

Commit

Permalink
usb: typec: tcpm: reset counter when enter into unattached state afte…
Browse files Browse the repository at this point in the history
…r try role

The try_src_count and try_snk_count may still be 1 after enter into
unattached state. This may be caused by below case:
 - SNK_TRY->SNK_TRY_WAIT->SRC_TRYWAIT->SNK_UNATTACHED
 - SRC_TRY->SRC_TRY_WAIT->SNK_TRYWAIT->SNK_UNATTACHED

The port->attached is not true at the end and tcpm_reset_port() will not
be called. This will reset counter into for these cases, otherwise the tcpm
won't try role when new cable attached.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230820151518.1403006-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Xu Yang authored and Greg Kroah-Hartman committed Aug 23, 2023
1 parent c97cd0b commit 2d6d801
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/usb/typec/tcpm/tcpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3720,6 +3720,9 @@ static void tcpm_detach(struct tcpm_port *port)
if (tcpm_port_is_disconnected(port))
port->hard_reset_count = 0;

port->try_src_count = 0;
port->try_snk_count = 0;

if (!port->attached)
return;

Expand Down

0 comments on commit 2d6d801

Please sign in to comment.