On Tue, Aug 17, 2021 at 06:32:55PM +0800, Kyle Tso wrote: > On Tue, Aug 17, 2021 at 5:39 PM Heikki Krogerus > <heikki.krogerus@xxxxxxxxxxxxxxx> wrote: > > > > On Mon, Aug 16, 2021 at 03:54:49PM +0800, Kyle Tso wrote: > > > If the port is going to send Discover_Identity Message, vdm_sm_running > > > flag was intentionally set before entering Ready States in order to > > > avoid the conflict because the port and the port partner might start > > > AMS at almost the same time after entering Ready States. > > > > > > However, the original design has a problem. When the port is doing > > > DR_SWAP from Device to Host, it raises the flag. Later in the > > > tcpm_send_discover_work, the flag blocks the procedure of sending the > > > Discover_Identity and it might never be cleared until disconnection. > > > > This is a bit off-topic, but I just asked this in another thread: Why > > do we have to do discovery with data role swap? > > > > thanks, > > > > This can be separated into two cases: > > 1. in PD2: If the port is originally UFP, it cannot send > Discover_Identity Message according to the Spec. And then DR_SWAP > happens. The port becomes DFP, and now it can do that. > > 2. in PD3: DFP and UFP are allowed to send Discover_Identity Message > and the responses may differ based on which roles they are active on. > > Quote from the PD3 Spec: > ``` > The Discover Identity Command Shall be used to determine the identity > and/or capabilities of the Port Partner. The following products Shall > return a Discover Identity Command ACK in response to a Discover > Identity Command request sent to SOP: > > • A PD-Capable UFP that supports Modal Operation. > • A PD-Capable product that has multiple DFPs. > • A PD-Capable [USB4] product. > ``` Got it. Thanks for the explanation. > > > Since there exists another flag send_discover representing that the port > > > is going to send Discover_Identity or not, it is enough to use that flag > > > to prevent the conflict. Also change the timing of the set/clear of > > > vdm_sm_running to indicate whether the VDM SM is actually running or > > > not. > > > > > > Fixes: c34e85fa69b9 ("usb: typec: tcpm: Send DISCOVER_IDENTITY from dedicated work") > > > Cc: Badhri Jagan Sridharan <badhri@xxxxxxxxxx> > > > Signed-off-by: Kyle Tso <kyletso@xxxxxxxxxx> FWIW: Acked-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx> thanks, -- heikki