linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: Fix wrong handling in GET_SINK_CAP
@ 2021-05-03 17:18 Kyle Tso
  2021-05-03 17:38 ` Guenter Roeck
  2021-05-05  7:55 ` Heikki Krogerus
  0 siblings, 2 replies; 3+ messages in thread
From: Kyle Tso @ 2021-05-03 17:18 UTC (permalink / raw)
  To: linux, heikki.krogerus, gregkh; +Cc: badhri, linux-usb, linux-kernel, Kyle Tso

After receiving Sink Capabilities Message in GET_SINK_CAP AMS, it is
incorrect to call tcpm_pd_handle_state because the Message is expected
and the current state is not Ready states. The result of this incorrect
operation ends in Soft Reset which is definitely wrong. Simply
forwarding to Ready States is enough to finish the AMS.

Fixes: 8dea75e11380 ("usb: typec: tcpm: Protocol Error handling")
Signed-off-by: Kyle Tso <kyletso@google.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 c4fdc00a3bc8..68e04e397e92 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -2390,7 +2390,7 @@ static void tcpm_pd_data_request(struct tcpm_port *port,
 		port->nr_sink_caps = cnt;
 		port->sink_cap_done = true;
 		if (port->ams == GET_SINK_CAPABILITIES)
-			tcpm_pd_handle_state(port, ready_state(port), NONE_AMS, 0);
+			tcpm_set_state(port, ready_state(port), 0);
 		/* Unexpected Sink Capabilities */
 		else
 			tcpm_pd_handle_msg(port,
-- 
2.31.1.527.g47e6f16901-goog


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

* Re: [PATCH] usb: typec: tcpm: Fix wrong handling in GET_SINK_CAP
  2021-05-03 17:18 [PATCH] usb: typec: tcpm: Fix wrong handling in GET_SINK_CAP Kyle Tso
@ 2021-05-03 17:38 ` Guenter Roeck
  2021-05-05  7:55 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-05-03 17:38 UTC (permalink / raw)
  To: Kyle Tso, heikki.krogerus, gregkh; +Cc: badhri, linux-usb, linux-kernel

On 5/3/21 10:18 AM, Kyle Tso wrote:
> After receiving Sink Capabilities Message in GET_SINK_CAP AMS, it is
> incorrect to call tcpm_pd_handle_state because the Message is expected
> and the current state is not Ready states. The result of this incorrect
> operation ends in Soft Reset which is definitely wrong. Simply
> forwarding to Ready States is enough to finish the AMS.
> 
> Fixes: 8dea75e11380 ("usb: typec: tcpm: Protocol Error handling")
> Signed-off-by: Kyle Tso <kyletso@google.com>

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

> ---
>  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 c4fdc00a3bc8..68e04e397e92 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2390,7 +2390,7 @@ static void tcpm_pd_data_request(struct tcpm_port *port,
>  		port->nr_sink_caps = cnt;
>  		port->sink_cap_done = true;
>  		if (port->ams == GET_SINK_CAPABILITIES)
> -			tcpm_pd_handle_state(port, ready_state(port), NONE_AMS, 0);
> +			tcpm_set_state(port, ready_state(port), 0);
>  		/* Unexpected Sink Capabilities */
>  		else
>  			tcpm_pd_handle_msg(port,
> 


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

* Re: [PATCH] usb: typec: tcpm: Fix wrong handling in GET_SINK_CAP
  2021-05-03 17:18 [PATCH] usb: typec: tcpm: Fix wrong handling in GET_SINK_CAP Kyle Tso
  2021-05-03 17:38 ` Guenter Roeck
@ 2021-05-05  7:55 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2021-05-05  7:55 UTC (permalink / raw)
  To: Kyle Tso; +Cc: linux, gregkh, badhri, linux-usb, linux-kernel

On Tue, May 04, 2021 at 01:18:49AM +0800, Kyle Tso wrote:
> After receiving Sink Capabilities Message in GET_SINK_CAP AMS, it is
> incorrect to call tcpm_pd_handle_state because the Message is expected
> and the current state is not Ready states. The result of this incorrect
> operation ends in Soft Reset which is definitely wrong. Simply
> forwarding to Ready States is enough to finish the AMS.
> 
> Fixes: 8dea75e11380 ("usb: typec: tcpm: Protocol Error handling")
> Signed-off-by: Kyle Tso <kyletso@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 c4fdc00a3bc8..68e04e397e92 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2390,7 +2390,7 @@ static void tcpm_pd_data_request(struct tcpm_port *port,
>  		port->nr_sink_caps = cnt;
>  		port->sink_cap_done = true;
>  		if (port->ams == GET_SINK_CAPABILITIES)
> -			tcpm_pd_handle_state(port, ready_state(port), NONE_AMS, 0);
> +			tcpm_set_state(port, ready_state(port), 0);
>  		/* Unexpected Sink Capabilities */
>  		else
>  			tcpm_pd_handle_msg(port,
> -- 
> 2.31.1.527.g47e6f16901-goog

-- 
heikki

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

end of thread, other threads:[~2021-05-05  7:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 17:18 [PATCH] usb: typec: tcpm: Fix wrong handling in GET_SINK_CAP Kyle Tso
2021-05-03 17:38 ` Guenter Roeck
2021-05-05  7:55 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).