All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: gregkh@linuxfoundation.org, rdbabiera@google.com,
	linux@roeck-us.net, badhri@google.com, kyletso@google.com,
	linux-usb@vger.kernel.org, imx@lists.linux.dev, jun.li@nxp.com
Subject: Re: [PATCH] Revert "usb: typec: tcpm: clear pd_event queue in PORT_RESET"
Date: Mon, 12 Aug 2024 09:08:56 +0300	[thread overview]
Message-ID: <Zrmm+KOGaG2GwRP/@kuha.fi.intel.com> (raw)
In-Reply-To: <20240809112901.535072-1-xu.yang_2@nxp.com>

On Fri, Aug 09, 2024 at 07:29:01PM +0800, Xu Yang wrote:
> This reverts commit bf20c69cf3cf9c6445c4925dd9a8a6ca1b78bfdf.
> 
> During tcpm_init() stage, if the VBUS is still present after
> tcpm_reset_port(), then we assume that VBUS will off and goto safe0v
> after a specific discharge time. Following a TCPM_VBUS_EVENT event if
> VBUS reach to off state. TCPM_VBUS_EVENT event may be set during
> PORT_RESET handling stage. If pd_events reset to 0 after TCPM_VBUS_EVENT
> set, we will lost this VBUS event. Then the port state machine may stuck
> at one state.
> 
> Before:
> 
> [    2.570172] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev1 NONE_AMS]
> [    2.570179] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms]
> [    2.570182] pending state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED @ 920 ms [rev1 NONE_AMS]
> [    3.490213] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [delayed 920 ms]
> [    3.490220] Start toggling
> [    3.546050] CC1: 0 -> 0, CC2: 0 -> 2 [state TOGGLING, polarity 0, connected]
> [    3.546057] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
> 
> After revert this patch, we can see VBUS off event and the port will goto
> expected state.
> 
> [    2.441992] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev1 NONE_AMS]
> [    2.441999] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms]
> [    2.442002] pending state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED @ 920 ms [rev1 NONE_AMS]
> [    2.442122] VBUS off
> [    2.442125] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev1 NONE_AMS]
> [    2.442127] VBUS VSAFE0V
> [    2.442351] CC1: 0 -> 0, CC2: 0 -> 0 [state SNK_UNATTACHED, polarity 0, disconnected]
> [    2.442357] Start toggling
> [    2.491850] CC1: 0 -> 0, CC2: 0 -> 2 [state TOGGLING, polarity 0, connected]
> [    2.491858] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
> [    2.491863] pending state change SRC_ATTACH_WAIT -> SNK_TRY @ 200 ms [rev1 NONE_AMS]
> [    2.691905] state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms]
> 
> Fixes: bf20c69cf3cf ("usb: typec: tcpm: clear pd_event queue in PORT_RESET")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index cce39818e99a..4b02d6474259 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -5655,7 +5655,6 @@ static void run_state_machine(struct tcpm_port *port)
>  		break;
>  	case PORT_RESET:
>  		tcpm_reset_port(port);
> -		port->pd_events = 0;
>  		if (port->self_powered)
>  			tcpm_set_cc(port, TYPEC_CC_OPEN);
>  		else
> -- 
> 2.34.1

-- 
heikki

      reply	other threads:[~2024-08-12  6:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 11:29 [PATCH] Revert "usb: typec: tcpm: clear pd_event queue in PORT_RESET" Xu Yang
2024-08-12  6:08 ` Heikki Krogerus [this message]

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=Zrmm+KOGaG2GwRP/@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=kyletso@google.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rdbabiera@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.