public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: tcpm: Skip hard reset when in error recovery
@ 2023-11-01  2:19 Badhri Jagan Sridharan
  2023-11-08  7:33 ` Heikki Krogerus
  2023-11-08 18:41 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Badhri Jagan Sridharan @ 2023-11-01  2:19 UTC (permalink / raw)
  To: gregkh, linux, heikki.krogerus
  Cc: kyletso, linux-usb, linux-kernel, rdbabiera, amitsd, stable,
	Badhri Jagan Sridharan

Hard reset queued prior to error recovery (or) received during
error recovery will make TCPM to prematurely exit error recovery
sequence. Ignore hard resets received during error recovery (or)
port reset sequence.

```
[46505.459688] state change SNK_READY -> ERROR_RECOVERY [rev3 NONE_AMS]
[46505.459706] state change ERROR_RECOVERY -> PORT_RESET [rev3 NONE_AMS]
[46505.460433] disable vbus discharge ret:0
[46505.461226] Setting usb_comm capable false
[46505.467244] Setting voltage/current limit 0 mV 0 mA
[46505.467262] polarity 0
[46505.470695] Requesting mux state 0, usb-role 0, orientation 0
[46505.475621] cc:=0
[46505.476012] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev3 NONE_AMS]
[46505.476020] Received hard reset
[46505.476024] state change PORT_RESET -> HARD_RESET_START [rev3 HARD_RESET]
```

Cc: stable@vger.kernel.org
Fixes: f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 058d5b853b57..b386102f7a3a 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -5391,6 +5391,15 @@ static void _tcpm_pd_hard_reset(struct tcpm_port *port)
 	if (port->bist_request == BDO_MODE_TESTDATA && port->tcpc->set_bist_data)
 		port->tcpc->set_bist_data(port->tcpc, false);
 
+	switch (port->state) {
+	case ERROR_RECOVERY:
+	case PORT_RESET:
+	case PORT_RESET_WAIT_OFF:
+		return;
+	default:
+		break;
+	}
+
 	if (port->ams != NONE_AMS)
 		port->ams = NONE_AMS;
 	if (port->hard_reset_count < PD_N_HARD_RESET_COUNT)

base-commit: c70793fb7632a153862ee9060e6d48131469a29c
-- 
2.42.0.820.g83a721a137-goog


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

* Re: [PATCH v1] usb: typec: tcpm: Skip hard reset when in error recovery
  2023-11-01  2:19 [PATCH v1] usb: typec: tcpm: Skip hard reset when in error recovery Badhri Jagan Sridharan
@ 2023-11-08  7:33 ` Heikki Krogerus
  2023-11-08 18:41 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2023-11-08  7:33 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: gregkh, linux, kyletso, linux-usb, linux-kernel, rdbabiera,
	amitsd, stable

On Wed, Nov 01, 2023 at 02:19:09AM +0000, Badhri Jagan Sridharan wrote:
> Hard reset queued prior to error recovery (or) received during
> error recovery will make TCPM to prematurely exit error recovery
> sequence. Ignore hard resets received during error recovery (or)
> port reset sequence.
> 
> ```
> [46505.459688] state change SNK_READY -> ERROR_RECOVERY [rev3 NONE_AMS]
> [46505.459706] state change ERROR_RECOVERY -> PORT_RESET [rev3 NONE_AMS]
> [46505.460433] disable vbus discharge ret:0
> [46505.461226] Setting usb_comm capable false
> [46505.467244] Setting voltage/current limit 0 mV 0 mA
> [46505.467262] polarity 0
> [46505.470695] Requesting mux state 0, usb-role 0, orientation 0
> [46505.475621] cc:=0
> [46505.476012] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev3 NONE_AMS]
> [46505.476020] Received hard reset
> [46505.476024] state change PORT_RESET -> HARD_RESET_START [rev3 HARD_RESET]
> ```
> 
> Cc: stable@vger.kernel.org
> Fixes: f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

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

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 058d5b853b57..b386102f7a3a 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -5391,6 +5391,15 @@ static void _tcpm_pd_hard_reset(struct tcpm_port *port)
>  	if (port->bist_request == BDO_MODE_TESTDATA && port->tcpc->set_bist_data)
>  		port->tcpc->set_bist_data(port->tcpc, false);
>  
> +	switch (port->state) {
> +	case ERROR_RECOVERY:
> +	case PORT_RESET:
> +	case PORT_RESET_WAIT_OFF:
> +		return;
> +	default:
> +		break;
> +	}
> +
>  	if (port->ams != NONE_AMS)
>  		port->ams = NONE_AMS;
>  	if (port->hard_reset_count < PD_N_HARD_RESET_COUNT)
> 
> base-commit: c70793fb7632a153862ee9060e6d48131469a29c
> -- 
> 2.42.0.820.g83a721a137-goog

-- 
heikki

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

* Re: [PATCH v1] usb: typec: tcpm: Skip hard reset when in error recovery
  2023-11-01  2:19 [PATCH v1] usb: typec: tcpm: Skip hard reset when in error recovery Badhri Jagan Sridharan
  2023-11-08  7:33 ` Heikki Krogerus
@ 2023-11-08 18:41 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2023-11-08 18:41 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, gregkh, heikki.krogerus
  Cc: kyletso, linux-usb, linux-kernel, rdbabiera, amitsd, stable

On 10/31/23 19:19, Badhri Jagan Sridharan wrote:
> Hard reset queued prior to error recovery (or) received during
> error recovery will make TCPM to prematurely exit error recovery
> sequence. Ignore hard resets received during error recovery (or)
> port reset sequence.
> 
> ```
> [46505.459688] state change SNK_READY -> ERROR_RECOVERY [rev3 NONE_AMS]
> [46505.459706] state change ERROR_RECOVERY -> PORT_RESET [rev3 NONE_AMS]
> [46505.460433] disable vbus discharge ret:0
> [46505.461226] Setting usb_comm capable false
> [46505.467244] Setting voltage/current limit 0 mV 0 mA
> [46505.467262] polarity 0
> [46505.470695] Requesting mux state 0, usb-role 0, orientation 0
> [46505.475621] cc:=0
> [46505.476012] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev3 NONE_AMS]
> [46505.476020] Received hard reset
> [46505.476024] state change PORT_RESET -> HARD_RESET_START [rev3 HARD_RESET]
> ```
> 
> Cc: stable@vger.kernel.org
> Fixes: f0690a25a140 ("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 | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 058d5b853b57..b386102f7a3a 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -5391,6 +5391,15 @@ static void _tcpm_pd_hard_reset(struct tcpm_port *port)
>   	if (port->bist_request == BDO_MODE_TESTDATA && port->tcpc->set_bist_data)
>   		port->tcpc->set_bist_data(port->tcpc, false);
>   
> +	switch (port->state) {
> +	case ERROR_RECOVERY:
> +	case PORT_RESET:
> +	case PORT_RESET_WAIT_OFF:
> +		return;
> +	default:
> +		break;
> +	}
> +
>   	if (port->ams != NONE_AMS)
>   		port->ams = NONE_AMS;
>   	if (port->hard_reset_count < PD_N_HARD_RESET_COUNT)
> 
> base-commit: c70793fb7632a153862ee9060e6d48131469a29c


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

end of thread, other threads:[~2023-11-08 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-01  2:19 [PATCH v1] usb: typec: tcpm: Skip hard reset when in error recovery Badhri Jagan Sridharan
2023-11-08  7:33 ` Heikki Krogerus
2023-11-08 18:41 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox