Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751356AbdH0RZt (ORCPT ); Sun, 27 Aug 2017 13:25:49 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:60526 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182AbdH0RZs (ORCPT ); Sun, 27 Aug 2017 13:25:48 -0400 Date: Sun, 27 Aug 2017 10:25:46 -0700 From: Guenter Roeck To: Badhri Jagan Sridharan Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/11] staging: typec: tcpm: add cc change handling in src states Message-ID: <20170827172546.GR22819@roeck-us.net> References: <20170827065031.3105-1-Badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170827065031.3105-1-Badhri@google.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2345 Lines: 61 On Sat, Aug 26, 2017 at 11:50:31PM -0700, Badhri Jagan Sridharan wrote: > In the case that the lower layer driver reports a cc change directly > from SINK state to SOURCE state, TCPM doesn't handle these cc change > in SRC_SEND_CAPABILITIES, SRC_READY states. And with SRC_ATTACHED > state, the change is not handled as the port is still considered > connected. > > [49606.131672] state change DRP_TOGGLING -> SRC_ATTACH_WAIT > [49606.131701] pending state change SRC_ATTACH_WAIT -> SRC_ATTACHED @ > 200 ms > [49606.329952] state change SRC_ATTACH_WAIT -> SRC_ATTACHED [delayed 200 > ms] > [49606.329978] polarity 0 > [49606.329989] Requesting mux mode 1, config 0, polarity 0 > [49606.349416] vbus:=1 charge=0 > [49606.372274] pending state change SRC_ATTACHED -> SRC_UNATTACHED @ 480 > ms > [49606.372431] VBUS on > [49606.372488] state change SRC_ATTACHED -> SRC_STARTUP > ... > (the lower layer driver reports a direct change from source to sink) > [49606.536927] pending state change SRC_SEND_CAPABILITIES -> > SRC_SEND_CAPABILITIES @ 150 ms > [49606.547244] CC1: 2 -> 5, CC2: 0 -> 0 [state SRC_SEND_CAPABILITIES, > polarity 0, connected] > > This can happen when the lower layer driver and/or the hardware > handles a portion of the Type-C state machine work, and quietly goes > through the unattached state. > > Originally-from: Yueyao Zhu > Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck > --- > drivers/staging/typec/tcpm.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c > index 645f43ee83df..1f6827f32b29 100644 > --- a/drivers/staging/typec/tcpm.c > +++ b/drivers/staging/typec/tcpm.c > @@ -2874,10 +2874,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1, > tcpm_set_state(port, SRC_ATTACH_WAIT, 0); > break; > case SRC_ATTACHED: > - if (tcpm_port_is_disconnected(port)) > + case SRC_SEND_CAPABILITIES: > + case SRC_READY: > + if (tcpm_port_is_disconnected(port) || > + !tcpm_port_is_source(port)) > tcpm_set_state(port, SRC_UNATTACHED, 0); > break; > - > case SNK_UNATTACHED: > if (tcpm_port_is_sink(port)) > tcpm_set_state(port, SNK_ATTACH_WAIT, 0); > -- > 2.14.1.342.g6490525c54-goog >