Linux USB
 help / color / mirror / Atom feed
From: Xu Yang <xu.yang_2@nxp.com>
To: linux@roeck-us.net, heikki.krogerus@linux.intel.com
Cc: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, jun.li@nxp.com
Subject: [PATCH] usb: typec: tcpm: reset counter when enter into unattached state after try role
Date: Sun, 20 Aug 2023 23:15:18 +0800	[thread overview]
Message-ID: <20230820151518.1403006-1-xu.yang_2@nxp.com> (raw)

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


             reply	other threads:[~2023-08-20 15:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-20 15:15 Xu Yang [this message]
2023-08-23  6:52 ` [PATCH] usb: typec: tcpm: reset counter when enter into unattached state after try role 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230820151518.1403006-1-xu.yang_2@nxp.com \
    --to=xu.yang_2@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jun.li@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox