All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: skip checking port->send_discover in PD3.0
@ 2023-11-16  8:32 Guan-Yu Lin
  2023-11-21 14:15 ` Heikki Krogerus
  2023-11-21 14:47 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Guan-Yu Lin @ 2023-11-16  8:32 UTC (permalink / raw)
  To: linux, heikki.krogerus, gregkh
  Cc: linux-usb, linux-kernel, badhri, kyletso, albertccwang, Guan-Yu Lin

The original Collison Avoidance mechanism, port->send_discover, avoids
the conflict when port partners start AMS almost the same time. However,
this mechanism is replaced by SINK_TX_OK and SINK_TX_NG. Skip the check
in PD3.0 to avoid the deadlock when source is requesting DR_SWAP where
sink is requesting DISCOVER_IDENTITY.

Signed-off-by: Guan-Yu Lin <guanyulin@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 058d5b853b57..ff3c171a3a75 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -2847,7 +2847,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 					   PD_MSG_CTRL_NOT_SUPP,
 					   NONE_AMS);
 		} else {
-			if (port->send_discover) {
+			if (port->send_discover && port->negotiated_rev < PD_REV30) {
 				tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
 				break;
 			}
@@ -2863,7 +2863,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 					   PD_MSG_CTRL_NOT_SUPP,
 					   NONE_AMS);
 		} else {
-			if (port->send_discover) {
+			if (port->send_discover && port->negotiated_rev < PD_REV30) {
 				tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
 				break;
 			}
@@ -2872,7 +2872,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
 		}
 		break;
 	case PD_CTRL_VCONN_SWAP:
-		if (port->send_discover) {
+		if (port->send_discover && port->negotiated_rev < PD_REV30) {
 			tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
 			break;
 		}
-- 
2.43.0.rc0.421.g78406f8d94-goog


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

* Re: [PATCH] usb: typec: tcpm: skip checking port->send_discover in PD3.0
  2023-11-16  8:32 [PATCH] usb: typec: tcpm: skip checking port->send_discover in PD3.0 Guan-Yu Lin
@ 2023-11-21 14:15 ` Heikki Krogerus
  2023-11-21 14:47 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2023-11-21 14:15 UTC (permalink / raw)
  To: Guan-Yu Lin
  Cc: linux, gregkh, linux-usb, linux-kernel, badhri, kyletso, albertccwang

On Thu, Nov 16, 2023 at 04:32:16PM +0800, Guan-Yu Lin wrote:
> The original Collison Avoidance mechanism, port->send_discover, avoids
> the conflict when port partners start AMS almost the same time. However,
> this mechanism is replaced by SINK_TX_OK and SINK_TX_NG. Skip the check
> in PD3.0 to avoid the deadlock when source is requesting DR_SWAP where
> sink is requesting DISCOVER_IDENTITY.
> 
> Signed-off-by: Guan-Yu Lin <guanyulin@google.com>

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

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 058d5b853b57..ff3c171a3a75 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2847,7 +2847,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>  					   PD_MSG_CTRL_NOT_SUPP,
>  					   NONE_AMS);
>  		} else {
> -			if (port->send_discover) {
> +			if (port->send_discover && port->negotiated_rev < PD_REV30) {
>  				tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
>  				break;
>  			}
> @@ -2863,7 +2863,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>  					   PD_MSG_CTRL_NOT_SUPP,
>  					   NONE_AMS);
>  		} else {
> -			if (port->send_discover) {
> +			if (port->send_discover && port->negotiated_rev < PD_REV30) {
>  				tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
>  				break;
>  			}
> @@ -2872,7 +2872,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>  		}
>  		break;
>  	case PD_CTRL_VCONN_SWAP:
> -		if (port->send_discover) {
> +		if (port->send_discover && port->negotiated_rev < PD_REV30) {
>  			tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
>  			break;
>  		}
> -- 
> 2.43.0.rc0.421.g78406f8d94-goog

-- 
heikki

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

* Re: [PATCH] usb: typec: tcpm: skip checking port->send_discover in PD3.0
  2023-11-16  8:32 [PATCH] usb: typec: tcpm: skip checking port->send_discover in PD3.0 Guan-Yu Lin
  2023-11-21 14:15 ` Heikki Krogerus
@ 2023-11-21 14:47 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2023-11-21 14:47 UTC (permalink / raw)
  To: Guan-Yu Lin, heikki.krogerus, gregkh
  Cc: linux-usb, linux-kernel, badhri, kyletso, albertccwang

On 11/16/23 00:32, Guan-Yu Lin wrote:
> The original Collison Avoidance mechanism, port->send_discover, avoids
> the conflict when port partners start AMS almost the same time. However,
> this mechanism is replaced by SINK_TX_OK and SINK_TX_NG. Skip the check
> in PD3.0 to avoid the deadlock when source is requesting DR_SWAP where
> sink is requesting DISCOVER_IDENTITY.
> 
> Signed-off-by: Guan-Yu Lin <guanyulin@google.com>

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

> ---
>   drivers/usb/typec/tcpm/tcpm.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 058d5b853b57..ff3c171a3a75 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2847,7 +2847,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>   					   PD_MSG_CTRL_NOT_SUPP,
>   					   NONE_AMS);
>   		} else {
> -			if (port->send_discover) {
> +			if (port->send_discover && port->negotiated_rev < PD_REV30) {
>   				tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
>   				break;
>   			}
> @@ -2863,7 +2863,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>   					   PD_MSG_CTRL_NOT_SUPP,
>   					   NONE_AMS);
>   		} else {
> -			if (port->send_discover) {
> +			if (port->send_discover && port->negotiated_rev < PD_REV30) {
>   				tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
>   				break;
>   			}
> @@ -2872,7 +2872,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>   		}
>   		break;
>   	case PD_CTRL_VCONN_SWAP:
> -		if (port->send_discover) {
> +		if (port->send_discover && port->negotiated_rev < PD_REV30) {
>   			tcpm_queue_message(port, PD_MSG_CTRL_WAIT);
>   			break;
>   		}


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

end of thread, other threads:[~2023-11-21 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16  8:32 [PATCH] usb: typec: tcpm: skip checking port->send_discover in PD3.0 Guan-Yu Lin
2023-11-21 14:15 ` Heikki Krogerus
2023-11-21 14:47 ` Guenter Roeck

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.