[PATCH v1] usb: typec: tcpm: Query Source partner for FRS capability only if it is DRP

Kyle Tso posted 1 patch 2 years ago
drivers/usb/typec/tcpm/tcpm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH v1] usb: typec: tcpm: Query Source partner for FRS capability only if it is DRP
Posted by Kyle Tso 2 years ago
Source-only port partner will always respond NOT_SUPPORTED to
GET_SINK_CAP. Avoid this redundant AMS by bailing out querying the FRS
capability if the Source port partner is not DRP.

Signed-off-by: Kyle Tso <kyletso@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 50cbc52386b3..192c103e0d10 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4401,7 +4401,8 @@ static void run_state_machine(struct tcpm_port *port)
 			tcpm_set_current_limit(port, tcpm_get_current_limit(port), 5000);
 		tcpm_swap_complete(port, 0);
 		tcpm_typec_connect(port);
-		mod_enable_frs_delayed_work(port, 0);
+		if (port->pd_capable && port->source_caps[0] & PDO_FIXED_DUAL_ROLE)
+			mod_enable_frs_delayed_work(port, 0);
 		tcpm_pps_complete(port, port->pps_status);
 
 		if (port->ams != NONE_AMS)
-- 
2.43.0.472.g3155946c3a-goog
Re: [PATCH v1] usb: typec: tcpm: Query Source partner for FRS capability only if it is DRP
Posted by Guenter Roeck 2 years ago
On 12/4/23 23:47, Kyle Tso wrote:
> Source-only port partner will always respond NOT_SUPPORTED to
> GET_SINK_CAP. Avoid this redundant AMS by bailing out querying the FRS
> capability if the Source port partner is not DRP.
> 
> Signed-off-by: Kyle Tso <kyletso@google.com>

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

> ---
>   drivers/usb/typec/tcpm/tcpm.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 50cbc52386b3..192c103e0d10 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4401,7 +4401,8 @@ static void run_state_machine(struct tcpm_port *port)
>   			tcpm_set_current_limit(port, tcpm_get_current_limit(port), 5000);
>   		tcpm_swap_complete(port, 0);
>   		tcpm_typec_connect(port);
> -		mod_enable_frs_delayed_work(port, 0);
> +		if (port->pd_capable && port->source_caps[0] & PDO_FIXED_DUAL_ROLE)
> +			mod_enable_frs_delayed_work(port, 0);
>   		tcpm_pps_complete(port, port->pps_status);
>   
>   		if (port->ams != NONE_AMS)
Re: [PATCH v1] usb: typec: tcpm: Query Source partner for FRS capability only if it is DRP
Posted by Heikki Krogerus 2 years ago
On Tue, Dec 05, 2023 at 03:47:46PM +0800, Kyle Tso wrote:
> Source-only port partner will always respond NOT_SUPPORTED to
> GET_SINK_CAP. Avoid this redundant AMS by bailing out querying the FRS
> capability if the Source port partner is not DRP.
> 
> Signed-off-by: Kyle Tso <kyletso@google.com>

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

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 50cbc52386b3..192c103e0d10 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4401,7 +4401,8 @@ static void run_state_machine(struct tcpm_port *port)
>  			tcpm_set_current_limit(port, tcpm_get_current_limit(port), 5000);
>  		tcpm_swap_complete(port, 0);
>  		tcpm_typec_connect(port);
> -		mod_enable_frs_delayed_work(port, 0);
> +		if (port->pd_capable && port->source_caps[0] & PDO_FIXED_DUAL_ROLE)
> +			mod_enable_frs_delayed_work(port, 0);
>  		tcpm_pps_complete(port, port->pps_status);
>  
>  		if (port->ams != NONE_AMS)
> -- 
> 2.43.0.472.g3155946c3a-goog

-- 
heikki