Re: [PATCH] usb: typec: tcpm: Fix if vbus before cc, hard_reset_count not reset issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 02, 2020 at 11:35:33PM +0800, cy_huang wrote:
> From: ChiYuan Huang <cy_huang@xxxxxxxxxxx>
> 
> Fix: If vbus event is before cc_event trigger, hard_reset_count
> won't bt reset for some case.
> 
> Signed-off-by: ChiYuan Huang <cy_huang@xxxxxxxxxxx>
> ---
> Below's the flow.
> 
> _tcpm_pd_vbus_off() -> run_state_machine to change state to SNK_UNATTACHED
> call tcpm_snk_detach() -> tcpm_snk_detach() -> tcpm_detach()
> tcpm_port_is_disconnected() will be called.
> But port->attached is still true and port->cc1=open and port->cc2=open
> 
> It cause tcpm_port_is_disconnected return false, then hard_reset_count won't be reset.
> After that, tcpm_reset_port() is called.
> port->attached become false.
> 
> After that, cc now trigger cc_change event, the hard_reset_count will be kept.
> Even tcpm_detach will be called, due to port->attached is false, tcpm_detach()
> will directly return.
> 
> CC_EVENT will only trigger drp toggling again.
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index a48e3f90..5c73e1d 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2797,8 +2797,7 @@ static void tcpm_detach(struct tcpm_port *port)
>  		port->tcpc->set_bist_data(port->tcpc, false);
>  	}
>  
> -	if (tcpm_port_is_disconnected(port))
> -		port->hard_reset_count = 0;
> +	port->hard_reset_count = 0;
>  

Doesn't that mean that the state machine will never enter
error recovery ?

Guenter

>  	tcpm_reset_port(port);
>  }
> -- 
> 2.7.4
> 



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux