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

From: ChiYuan Huang
Date: Tue Oct 06 2020 - 00:37:25 EST


Guenter Roeck <linux@xxxxxxxxxxxx> 於 2020年10月5日 週一 下午11:30寫道:
>
> On 10/5/20 4:08 AM, Greg KH wrote:
> [ ... ]
> >>> What ever happened with this patch, is there still disagreement?
> >>>
> >>
> >> Yes, there is. I wouldn't have added the conditional without reason,
> >> and I am concerned that removing it entirely will open another problem.
> >> Feel free to apply, though - I can't prove that my concern is valid,
> >> and after all we'll get reports from the field later if it is.
> >
> > Ok, can I get an ack so I know who to come back to in the future if
> > there are issues? :)
> >
>
> Not from me, for the reasons I stated. I would be ok with something like:
>
> - if (tcpm_port_is_disconnected(port))
> + if (tcpm_port_is_disconnected(port) ||
> + (tcpm_cc_is_open(port->cc1) && tcpm_cc_is_open(port->cc2)))
>
> to narrow down the condition.

I have tried the above comment and It doesn't work.
How about to change the judgement like as below

- if (tcpm_port_is_disconnected(port))
+ if (tcpm_port_is_disconnected(port) || !port->vbus_present)

The hard_reset_count not reset issue is following by the below order
1. VBUS off ( at the same time, cc is still detected as attached)
port->attached become false and cc is not open
2. After that, cc detached.
due to port->attached is false, tcpm_detach() directly return.

And that's why hard_reset_count is not reset to 0.
>
> Guenter