All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect
@ 2021-11-24 22:40 Badhri Jagan Sridharan
  2021-11-24 22:50 ` Guenter Roeck
  2021-11-25  6:00 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Badhri Jagan Sridharan @ 2021-11-24 22:40 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Kyle Tso, stable, Badhri Jagan Sridharan

Stub from the spec:
"4.5.2.2.4.2 Exiting from AttachWait.SNK State
A Sink shall transition to Unattached.SNK when the state of both
the CC1 and CC2 pins is SNK.Open for at least tPDDebounce.
A DRP shall transition to Unattached.SRC when the state of both
the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."

This change makes TCPM to wait in SNK_DEBOUNCED state until
CC1 and CC2 pins is SNK.Open for at least tPDDebounce. Previously,
TCPM resets the port if vbus is not present in PD_T_PS_SOURCE_ON.
This causes TCPM to loop continuously when connected to a
faulty power source that does not present vbus. Waiting in
SNK_DEBOUNCED also ensures that TCPM is adherant to
"4.5.2.2.4.2 Exiting from AttachWait.SNK State" requirements.

[ 6169.280751] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
[ 6169.280759] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
[ 6169.280771] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
[ 6169.282427] CC1: 0 -> 0, CC2: 5 -> 5 [state SNK_ATTACH_WAIT, polarity 0, connected]
[ 6169.450825] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
[ 6169.450834] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
[ 6169.930892] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
[ 6169.931296] disable vbus discharge ret:0
[ 6169.931301] Setting usb_comm capable false
[ 6169.932783] Setting voltage/current limit 0 mV 0 mA
[ 6169.932802] polarity 0
[ 6169.933706] Requesting mux state 0, usb-role 0, orientation 0
[ 6169.936689] cc:=0
[ 6169.936812] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
[ 6169.937157] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]
[ 6170.036880] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms]
[ 6170.036890] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev2 NONE_AMS]
[ 6170.036896] Start toggling
[ 6170.041412] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
[ 6170.042973] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
[ 6170.042976] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
[ 6170.042981] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
[ 6170.213014] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
[ 6170.213019] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
[ 6170.693068] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
[ 6170.693304] disable vbus discharge ret:0
[ 6170.693308] Setting usb_comm capable false
[ 6170.695193] Setting voltage/current limit 0 mV 0 mA
[ 6170.695210] polarity 0
[ 6170.695990] Requesting mux state 0, usb-role 0, orientation 0
[ 6170.701896] cc:=0
[ 6170.702181] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
[ 6170.703343] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]

Fixes: f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 7f2f3ff1b391..6010b9901126 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4110,11 +4110,7 @@ static void run_state_machine(struct tcpm_port *port)
 				       tcpm_try_src(port) ? SRC_TRY
 							  : SNK_ATTACHED,
 				       0);
-		else
-			/* Wait for VBUS, but not forever */
-			tcpm_set_state(port, PORT_RESET, PD_T_PS_SOURCE_ON);
 		break;
-
 	case SRC_TRY:
 		port->try_src_count++;
 		tcpm_set_cc(port, tcpm_rp_cc(port));
-- 
2.34.0.rc2.393.gf8c9666880-goog


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

* Re: [PATCH v1] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect
  2021-11-24 22:40 [PATCH v1] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect Badhri Jagan Sridharan
@ 2021-11-24 22:50 ` Guenter Roeck
  2021-11-25  6:00 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-11-24 22:50 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Kyle Tso, stable

On 11/24/21 2:40 PM, Badhri Jagan Sridharan wrote:
> Stub from the spec:
> "4.5.2.2.4.2 Exiting from AttachWait.SNK State
> A Sink shall transition to Unattached.SNK when the state of both
> the CC1 and CC2 pins is SNK.Open for at least tPDDebounce.
> A DRP shall transition to Unattached.SRC when the state of both
> the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."
> 
> This change makes TCPM to wait in SNK_DEBOUNCED state until
> CC1 and CC2 pins is SNK.Open for at least tPDDebounce. Previously,
> TCPM resets the port if vbus is not present in PD_T_PS_SOURCE_ON.
> This causes TCPM to loop continuously when connected to a
> faulty power source that does not present vbus. Waiting in
> SNK_DEBOUNCED also ensures that TCPM is adherant to
> "4.5.2.2.4.2 Exiting from AttachWait.SNK State" requirements.
> 
> [ 6169.280751] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
> [ 6169.280759] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
> [ 6169.280771] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
> [ 6169.282427] CC1: 0 -> 0, CC2: 5 -> 5 [state SNK_ATTACH_WAIT, polarity 0, connected]
> [ 6169.450825] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> [ 6169.450834] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
> [ 6169.930892] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
> [ 6169.931296] disable vbus discharge ret:0
> [ 6169.931301] Setting usb_comm capable false
> [ 6169.932783] Setting voltage/current limit 0 mV 0 mA
> [ 6169.932802] polarity 0
> [ 6169.933706] Requesting mux state 0, usb-role 0, orientation 0
> [ 6169.936689] cc:=0
> [ 6169.936812] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
> [ 6169.937157] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]
> [ 6170.036880] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms]
> [ 6170.036890] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev2 NONE_AMS]
> [ 6170.036896] Start toggling
> [ 6170.041412] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
> [ 6170.042973] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
> [ 6170.042976] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
> [ 6170.042981] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
> [ 6170.213014] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> [ 6170.213019] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
> [ 6170.693068] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
> [ 6170.693304] disable vbus discharge ret:0
> [ 6170.693308] Setting usb_comm capable false
> [ 6170.695193] Setting voltage/current limit 0 mV 0 mA
> [ 6170.695210] polarity 0
> [ 6170.695990] Requesting mux state 0, usb-role 0, orientation 0
> [ 6170.701896] cc:=0
> [ 6170.702181] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
> [ 6170.703343] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]
> 
> Fixes: f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)")
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/usb/typec/tcpm/tcpm.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 7f2f3ff1b391..6010b9901126 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4110,11 +4110,7 @@ static void run_state_machine(struct tcpm_port *port)
>   				       tcpm_try_src(port) ? SRC_TRY
>   							  : SNK_ATTACHED,
>   				       0);
> -		else
> -			/* Wait for VBUS, but not forever */
> -			tcpm_set_state(port, PORT_RESET, PD_T_PS_SOURCE_ON);
>   		break;
> -
>   	case SRC_TRY:
>   		port->try_src_count++;
>   		tcpm_set_cc(port, tcpm_rp_cc(port));
> 


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

* Re: [PATCH v1] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect
  2021-11-24 22:40 [PATCH v1] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect Badhri Jagan Sridharan
  2021-11-24 22:50 ` Guenter Roeck
@ 2021-11-25  6:00 ` Greg Kroah-Hartman
  2021-11-30  0:21   ` Badhri Jagan Sridharan
  1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-11-25  6:00 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: Guenter Roeck, Heikki Krogerus, linux-usb, linux-kernel,
	Kyle Tso, stable

On Wed, Nov 24, 2021 at 02:40:36PM -0800, Badhri Jagan Sridharan wrote:
> Stub from the spec:
> "4.5.2.2.4.2 Exiting from AttachWait.SNK State
> A Sink shall transition to Unattached.SNK when the state of both
> the CC1 and CC2 pins is SNK.Open for at least tPDDebounce.
> A DRP shall transition to Unattached.SRC when the state of both
> the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."
> 
> This change makes TCPM to wait in SNK_DEBOUNCED state until
> CC1 and CC2 pins is SNK.Open for at least tPDDebounce. Previously,
> TCPM resets the port if vbus is not present in PD_T_PS_SOURCE_ON.
> This causes TCPM to loop continuously when connected to a
> faulty power source that does not present vbus. Waiting in
> SNK_DEBOUNCED also ensures that TCPM is adherant to
> "4.5.2.2.4.2 Exiting from AttachWait.SNK State" requirements.
> 
> [ 6169.280751] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
> [ 6169.280759] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
> [ 6169.280771] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
> [ 6169.282427] CC1: 0 -> 0, CC2: 5 -> 5 [state SNK_ATTACH_WAIT, polarity 0, connected]
> [ 6169.450825] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> [ 6169.450834] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
> [ 6169.930892] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
> [ 6169.931296] disable vbus discharge ret:0
> [ 6169.931301] Setting usb_comm capable false
> [ 6169.932783] Setting voltage/current limit 0 mV 0 mA
> [ 6169.932802] polarity 0
> [ 6169.933706] Requesting mux state 0, usb-role 0, orientation 0
> [ 6169.936689] cc:=0
> [ 6169.936812] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
> [ 6169.937157] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]
> [ 6170.036880] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms]
> [ 6170.036890] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev2 NONE_AMS]
> [ 6170.036896] Start toggling
> [ 6170.041412] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
> [ 6170.042973] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
> [ 6170.042976] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
> [ 6170.042981] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
> [ 6170.213014] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> [ 6170.213019] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
> [ 6170.693068] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
> [ 6170.693304] disable vbus discharge ret:0
> [ 6170.693308] Setting usb_comm capable false
> [ 6170.695193] Setting voltage/current limit 0 mV 0 mA
> [ 6170.695210] polarity 0
> [ 6170.695990] Requesting mux state 0, usb-role 0, orientation 0
> [ 6170.701896] cc:=0
> [ 6170.702181] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
> [ 6170.703343] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]
> 
> Fixes: f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)")
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 4 ----
>  1 file changed, 4 deletions(-)


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

* Re: [PATCH v1] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect
  2021-11-25  6:00 ` Greg Kroah-Hartman
@ 2021-11-30  0:21   ` Badhri Jagan Sridharan
  0 siblings, 0 replies; 4+ messages in thread
From: Badhri Jagan Sridharan @ 2021-11-30  0:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Guenter Roeck, Heikki Krogerus, linux-usb, linux-kernel,
	Kyle Tso, stable

Thanks Greg ! Missed the "Cc: stable@vger.kernel.org". Have updated
the commit message and sent it as V2.

Regards,
Badhri


On Wed, Nov 24, 2021 at 10:00 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Wed, Nov 24, 2021 at 02:40:36PM -0800, Badhri Jagan Sridharan wrote:
> > Stub from the spec:
> > "4.5.2.2.4.2 Exiting from AttachWait.SNK State
> > A Sink shall transition to Unattached.SNK when the state of both
> > the CC1 and CC2 pins is SNK.Open for at least tPDDebounce.
> > A DRP shall transition to Unattached.SRC when the state of both
> > the CC1 and CC2 pins is SNK.Open for at least tPDDebounce."
> >
> > This change makes TCPM to wait in SNK_DEBOUNCED state until
> > CC1 and CC2 pins is SNK.Open for at least tPDDebounce. Previously,
> > TCPM resets the port if vbus is not present in PD_T_PS_SOURCE_ON.
> > This causes TCPM to loop continuously when connected to a
> > faulty power source that does not present vbus. Waiting in
> > SNK_DEBOUNCED also ensures that TCPM is adherant to
> > "4.5.2.2.4.2 Exiting from AttachWait.SNK State" requirements.
> >
> > [ 6169.280751] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
> > [ 6169.280759] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
> > [ 6169.280771] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
> > [ 6169.282427] CC1: 0 -> 0, CC2: 5 -> 5 [state SNK_ATTACH_WAIT, polarity 0, connected]
> > [ 6169.450825] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> > [ 6169.450834] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
> > [ 6169.930892] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
> > [ 6169.931296] disable vbus discharge ret:0
> > [ 6169.931301] Setting usb_comm capable false
> > [ 6169.932783] Setting voltage/current limit 0 mV 0 mA
> > [ 6169.932802] polarity 0
> > [ 6169.933706] Requesting mux state 0, usb-role 0, orientation 0
> > [ 6169.936689] cc:=0
> > [ 6169.936812] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
> > [ 6169.937157] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]
> > [ 6170.036880] state change PORT_RESET -> PORT_RESET_WAIT_OFF [delayed 100 ms]
> > [ 6170.036890] state change PORT_RESET_WAIT_OFF -> SNK_UNATTACHED [rev2 NONE_AMS]
> > [ 6170.036896] Start toggling
> > [ 6170.041412] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
> > [ 6170.042973] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected]
> > [ 6170.042976] state change TOGGLING -> SNK_ATTACH_WAIT [rev2 NONE_AMS]
> > [ 6170.042981] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev2 NONE_AMS]
> > [ 6170.213014] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> > [ 6170.213019] pending state change SNK_DEBOUNCED -> PORT_RESET @ 480 ms [rev2 NONE_AMS]
> > [ 6170.693068] state change SNK_DEBOUNCED -> PORT_RESET [delayed 480 ms]
> > [ 6170.693304] disable vbus discharge ret:0
> > [ 6170.693308] Setting usb_comm capable false
> > [ 6170.695193] Setting voltage/current limit 0 mV 0 mA
> > [ 6170.695210] polarity 0
> > [ 6170.695990] Requesting mux state 0, usb-role 0, orientation 0
> > [ 6170.701896] cc:=0
> > [ 6170.702181] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev2 NONE_AMS]
> > [ 6170.703343] CC1: 0 -> 0, CC2: 5 -> 0 [state PORT_RESET, polarity 0, disconnected]
> >
> > Fixes: f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)")
> > Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
> > ---
> >  drivers/usb/typec/tcpm/tcpm.c | 4 ----
> >  1 file changed, 4 deletions(-)
>
>
> <formletter>
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree.  Please read:
>     https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
>
> </formletter>

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

end of thread, other threads:[~2021-11-30  0:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 22:40 [PATCH v1] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect Badhri Jagan Sridharan
2021-11-24 22:50 ` Guenter Roeck
2021-11-25  6:00 ` Greg Kroah-Hartman
2021-11-30  0:21   ` Badhri Jagan Sridharan

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.