Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4233348pxb; Tue, 25 Jan 2022 06:21:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyklN9l8XV5yrwLZN76O46spOrqe5WSFlxUyMQdh4FNTXkh914Cpdosab3iK2xTDLOCk2B6 X-Received: by 2002:a05:6a00:d64:b0:4ba:cb6f:87e0 with SMTP id n36-20020a056a000d6400b004bacb6f87e0mr18633665pfv.72.1643120476580; Tue, 25 Jan 2022 06:21:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643120476; cv=none; d=google.com; s=arc-20160816; b=gpBYEO+6t/z2ga+NDep6eAhWJQ68LwABhNNLO1fVdor3Q1Sd5NSaloF9XIjkjQ+p6A fHjJwr07HzLa14kVOlwChLIALdQ378IF9TigtGMJwQz+ULOigPu8jewY6QOaNGpDxgNq 4+w68ZMjEWEl2maAv40XzOKLSCxvvdm0LhB3fqnBNDhFy1foP6VhRu1gFYyHqS9KSz23 MWs3ylh3y3io1suTFx4Yf0gz7dRp8pkgbtkVdhMu+zhVuDtOAhKHZMArhHzqsFnveUPf uPzHPhpiqkldB4RaFLXlF1qAJkCvTWmANDWuWU8/Xq0AIHYGyqOQVTKm4Kkk8bSKXcq9 b21w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LW4QVHXZBk36oOaz9wo+bjvyKtjriuGYthQOXgeYOZU=; b=yu1QiUZUjNIXm7/0x/joE7S5DijXHM9DHZQdauKRvU1JP/xfdnbudfkiUv26EVNZ8F gL4PqGv0nd4d2Gs0LxoKeKKLrKXPT0/udqm8KelslS64D8SR4vlJ02E1n+U++4drKlXN 8J4zIsZC3aAn9sqXITdfZC64Qk/AUurnb/5SSyP4m1xNsL13HFHea3CqZ6k7MxdnuZYa 3c2tR+9kPRBE303t9cmD6Zl2EqB4sE1oriL8sMnbOg6BTzaTEPg/3FdA3kbhDekUgb59 Cd3QzGSh7eCOFvSlWI21R1Ay6XeWLf973jkmcRSXffo4nuMMTE0C7sz7ncHGcNJ3XdMc YKQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=adiD69Ko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k64si8658948pgd.697.2022.01.25.06.21.03; Tue, 25 Jan 2022 06:21:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=adiD69Ko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572967AbiAYJSS (ORCPT + 99 others); Tue, 25 Jan 2022 04:18:18 -0500 Received: from mga01.intel.com ([192.55.52.88]:12212 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1456817AbiAYJNI (ORCPT ); Tue, 25 Jan 2022 04:13:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643101984; x=1674637984; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=hPcnFwQ5EIleBYS17H6mw711aNUx7ZkEMpr7D4Wkijw=; b=adiD69KokN6cxOfHDI0hKZURYKj04JmfqyDvxJE4VnQeZYQOzNkExs4u btOaPfnEmuG2eS5uAyQnVxCvPMfUSf7yLB9mQiCH6sAFwVxc2oqXoPki6 AUg31hU5s91fHIx2me7/UPLlEHIan5Oxp8fGcE/buBBzvquyMpK9YiwKH kEsbO8kAkLWsM9jwpd4DBRhHAvacUTKpdqxP9BS1PzEpus3uN11bkO1Qh TnbU+U1p0oDY7kEyVXSdcuX1qkzV0KT8wvGcF79EuXmLcps2e2uAS1dXE pd0bwcx74/X8kugy6/NJvSow4kWCF5oZI6SsrnMW8S+pONRXdIuvdPNJ6 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="270703135" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="270703135" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 01:01:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="673927372" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 25 Jan 2022 01:01:48 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 25 Jan 2022 11:01:47 +0200 Date: Tue, 25 Jan 2022 11:01:47 +0200 From: Heikki Krogerus To: Badhri Jagan Sridharan Cc: Guenter Roeck , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org Subject: Re: [PATCH v1 1/2] usb: typec: tcpm: Do not disconnect while receiving VBUS off Message-ID: References: <20220122015520.332507-1-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220122015520.332507-1-badhri@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 21, 2022 at 05:55:19PM -0800, Badhri Jagan Sridharan wrote: > With some chargers, vbus might momentarily raise above VSAFE5V and fall > back to 0V before tcpm gets to read port->tcpc->get_vbus. This will > will report a VBUS off event causing TCPM to transition to > SNK_UNATTACHED where it should be waiting in either SNK_ATTACH_WAIT > or SNK_DEBOUNCED state. This patch makes TCPM avoid vbus off events > while in SNK_ATTACH_WAIT or SNK_DEBOUNCED state. > > Stub from the spec: > "4.5.2.2.4.2 Exiting from AttachWait.SNK State > A Sink shall transition to Unattached.SNK when the state of both > the CC1 and CC2 pins is SNK.Open for at least tPDDebounce. > A DRP shall transition to Unattached.SRC when the state of both > the CC1 and CC2 pins is SNK.Open for at least tPDDebounce." > > [23.194131] CC1: 0 -> 0, CC2: 0 -> 5 [state SNK_UNATTACHED, polarity 0, connected] > [23.201777] state change SNK_UNATTACHED -> SNK_ATTACH_WAIT [rev3 NONE_AMS] > [23.209949] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] > [23.300579] VBUS off > [23.300668] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [rev3 NONE_AMS] > [23.301014] VBUS VSAFE0V > [23.301111] Start toggling > > Fixes: f0690a25a140b8 ("staging: typec: USB Type-C Port Manager (tcpm)") > Cc: stable@vger.kernel.org > Signed-off-by: Badhri Jagan Sridharan Acked-by: Heikki Krogerus > --- > 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 59d4fa2443f2..b8afe3d8c882 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -5156,7 +5156,8 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) > case SNK_TRYWAIT_DEBOUNCE: > break; > case SNK_ATTACH_WAIT: > - tcpm_set_state(port, SNK_UNATTACHED, 0); > + case SNK_DEBOUNCED: > + /* Do nothing, as TCPM is still waiting for vbus to reaach VSAFE5V to connect */ > break; > > case SNK_NEGOTIATE_CAPABILITIES: > -- > 2.35.0.rc0.227.g00780c9af4-goog -- heikki