Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: reset counter when enter into unattached state after try role
@ 2023-08-20 15:15 Xu Yang
  2023-08-23  6:52 ` Heikki Krogerus
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Xu Yang @ 2023-08-20 15:15 UTC (permalink / raw)
  To: linux, heikki.krogerus; +Cc: linux-usb, gregkh, jun.li

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>
---
 drivers/usb/typec/tcpm/tcpm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 5639b9a1e0bf..c9a186a8c58c 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -3719,6 +3719,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;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-03-01 17:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-20 15:15 [PATCH] usb: typec: tcpm: reset counter when enter into unattached state after try role Xu Yang
2023-08-23  6:52 ` Heikki Krogerus
2023-08-23 13:25 ` Guenter Roeck
2024-02-10 17:28 ` Ondřej Jirman
2024-02-19  8:36   ` [EXT] " Xu Yang
2024-02-24  3:42     ` Ondřej Jirman
2024-02-26  2:44       ` Xu Yang
2024-02-26 10:00         ` Ondřej Jirman
2024-02-26 10:32           ` Xu Yang
2024-03-01 17:25     ` Ondřej Jirman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox