mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: amitsd@google.com
Cc: Badhri Jagan Sridharan <badhri@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kyle Tso <kyletso@google.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	RD Babiera <rdbabiera@google.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] usb: typec: tcpm: recover after failure to start the frs ams
Date: Mon, 7 Sep 2026 12:39:40 +0200	[thread overview]
Message-ID: <ap6UbOSYDh6GDDhB@black.igk.intel.com> (raw)
In-Reply-To: <20260903-frs-error-handling-v1-1-ad0fee541847@google.com>

On Thu, Sep 03, 2026 at 12:22:21AM +0000, Amit Sunil Dhamne via B4 Relay wrote:
> From: Amit Sunil Dhamne <amitsd@google.com>
> 
> Reset the port if the tcpm fails to start the FAST_ROLE_SWAP AMS by
> initiating error recovery on it.
> 
> This helps in cases where some cables (incorrectly) signal an FRS to
> an FRS capable port during disconnection. The TCPC autonomously starts
> sourcing VBUS on detecting the FRS signal. However, the VBUS sourcing is
> left on when the FAST_ROLE_SWAP AMS fails to start (as tcpm_sink_tx_ok
> is 0 as CC is open due to the cable disconnect). This is because the
> code sets the state to INVALID_STATE without resetting the port state.
> 
> Log snippet before changes:
> [  101.401960] AMS FAST_ROLE_SWAP start
> [  101.401971] Sink TX No Go
> [  101.401982] sourcing vbus
> [  101.401987] VBUS on
> [  101.402159] VBUS on
> [  109.257809] CC1: 0 -> 0, CC2: 5 -> 0 [state SNK_READY, polarity 1, disconnected]
> [  111.267442] VBUS on
> 
> After changes:
> [   70.541211] AMS FAST_ROLE_SWAP start
> [   70.541220] Sink TX No Go
> [   70.541228] state change SNK_READY -> ERROR_RECOVERY [rev3 NONE_AMS]
> [   70.541362] VBUS on
> [   70.541365] sourcing vbus
> [   70.541367] VBUS on
> [   70.541374] state change ERROR_RECOVERY -> PORT_RESET [rev3 NONE_AMS]
> [   70.541410] disable vbus discharge ret:0
> [   70.543028] Setting usb_comm capable false
> [   70.544009] Setting voltage/current limit 0 mV 0 mA
> [   70.544034] polarity 0
> [   70.544239] Requesting mux state 0, usb-role 0, orientation 0
> [   70.555550] cc:=0
> [   70.555595] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev3 NONE_AMS]
> [   70.555697] VBUS off
> [   70.555702] VBUS VSAFE0V
> [   70.555762] CC1: 5 -> 0, CC2: 0 -> 0 [state PORT_RESET, polarity 0, disconnected]
> [   70.587794] VBUS off
> [   70.587799] VBUS VSAFE0V
> [   70.655672] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms]
> [   70.655682] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev3 NONE_AMS]
> [   70.655686] Start toggling
> [   70.656274] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
> 
> Fixes: 0908c5aca31e ("usb: typec: tcpm: AMS and Collision Avoidance")
> Cc: stable@vger.kernel.org
> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>

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

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index a8cd1959c426..c1045d850897 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -7113,7 +7113,7 @@ static void tcpm_pd_event_handler(struct kthread_work *work)
>  				port->upcoming_state = FR_SWAP_SEND;
>  				ret = tcpm_ams_start(port, FAST_ROLE_SWAP);
>  				if (ret == -EAGAIN)
> -					port->upcoming_state = INVALID_STATE;
> +					tcpm_set_state(port, ERROR_RECOVERY, 0);
>  			} else {
>  				tcpm_log(port, "Discarding FRS_SIGNAL! Not in sink ready");
>  			}
> 
> ---
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> change-id: 20260903-frs-error-handling-253b87a09fa2
> 
> Best regards,
> -- 
> Amit Sunil Dhamne <amitsd@google.com>
> 

-- 
heikki

      reply	other threads:[~2026-09-07 10:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  0:22 Amit Sunil Dhamne via B4 Relay
2026-09-07 10:39 ` 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=ap6UbOSYDh6GDDhB@black.igk.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=amitsd@google.com \
    --cc=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kyletso@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rdbabiera@google.com \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®