Linux USB
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org,
	gregkh@linuxfoundation.org, jun.li@nxp.com
Subject: Re: [PATCH] usb: typec: tcpm: reset counter when enter into unattached state after try role
Date: Wed, 23 Aug 2023 06:25:30 -0700	[thread overview]
Message-ID: <239ec364-909f-4183-aeab-474e6ef97e48@roeck-us.net> (raw)
In-Reply-To: <20230820151518.1403006-1-xu.yang_2@nxp.com>

On Sun, Aug 20, 2023 at 11:15:18PM +0800, Xu Yang wrote:
> 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: Guenter Roeck <linux@roeck-us.net>

> ---
>  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
> 

  parent reply	other threads:[~2023-08-23 13:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=239ec364-909f-4183-aeab-474e6ef97e48@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jun.li@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=xu.yang_2@nxp.com \
    /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