Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4772372pxb; Tue, 25 Jan 2022 19:10:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpo1pDtuG9LfyYm9T1XduHiXrF9BVBo8KEV5Xv41EhG/TnNV5cgtvOwg6KBgdlSUPhbqUo X-Received: by 2002:a17:903:32cd:b0:14b:59c1:11e7 with SMTP id i13-20020a17090332cd00b0014b59c111e7mr10315481plr.167.1643166615842; Tue, 25 Jan 2022 19:10:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643166615; cv=none; d=google.com; s=arc-20160816; b=lO1uVHg/gOq3Zs3w5IP/PxWcKgjoHBTgNGDrEo0swQbE5jlRxXK1FITYLiq8rhiPpZ NGUywsSj2zWv1XzWPouikBpVz+r/oLqkSOvQ3vNX/PT2izZZReReyANN0qxF/SIK8HGt edxPYjB3aVNakeflUwV/1fAukbcl48hni8NL0MvBWVKxyTBtk7CNwsZtmywQLaMoNICK QXXPrJwuX3hx78P/DZKFV12CfKmvm6haDNkmMozSOb/7SsTy+5W51rK16R9Up6wjxZCd zmz8+7hE4BRN9JjKGChUX7BzM9AAT3mHSrcttwUehoZMLNhX7DVj+bMfrZs+aun7A0Ak fqRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=GkhoMW3s8ud4mUDqS56CMazGwsmOxKoOKQYICxTpIPc=; b=hyTsRMv9d/tLFEoYr1cUXCO0skqCnQxNt293qNyxMYhwMca3ZSCE68ry8DGRZ+1Aiw /KRqK5mP9yKFQ4+Xn0Xl/YO/NY9pL9nsrZsfXptrujzH/bEp797aySqhjLAztxgZQJTP znlQTtn514+1s+77/5R8WN6w5PxJ9b+txJHHvsRm+Y1M5nvwA20ATb2aPPrl44UdssK9 Sh3deAtpdGrMsOdsH1q/fRjsNWigrOP0M14pZYS8T6an4aL+ezwOSz+VZL3TFxCUmZPo wnHMNeB2XazzBO9HIRfNulVZ0ZQTyfq2lH9YETtCYsYMWcPjNwVeRpXrB5DBbQ2SPtat DKoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VcCaq0WR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r20si16470574pgu.89.2022.01.25.19.10.03; Tue, 25 Jan 2022 19:10:15 -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=@gmail.com header.s=20210112 header.b=VcCaq0WR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239819AbiAYRmk (ORCPT + 99 others); Tue, 25 Jan 2022 12:42:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384365AbiAYRmS (ORCPT ); Tue, 25 Jan 2022 12:42:18 -0500 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A448C06173B; Tue, 25 Jan 2022 09:42:17 -0800 (PST) Received: by mail-oi1-x232.google.com with SMTP id s127so32474467oig.2; Tue, 25 Jan 2022 09:42:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=GkhoMW3s8ud4mUDqS56CMazGwsmOxKoOKQYICxTpIPc=; b=VcCaq0WRXcTDQDefya7gPvZxSy6EoRZq/oGJX6encxp6qzQiBibyt90XN/oRVGjmsS rsn9fLxoAxpp2oORsL0UU+ZO7zuvHI98RIDnwwMeytFwzmwyK9M8Phj1yDBeeTASoP4v hpLe+VxKNXNsOWKobgHY68cVMc3LGgyDG2v/wFwccUEAPuatvbjIW1gWHXhAKDw9IGVm mBgGgCqRCyBgO+EZXP0sI5fV2JppiHmSzLTIPJSzfqVppQWxaVlUSWiETJy3Em7r29Jh TDs45cazm+o62LcBFpuY7spCbWiLQM3YSw9+xLWnnIVG7eG9mHTfCtLe884bMXPNfg7q YvXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=GkhoMW3s8ud4mUDqS56CMazGwsmOxKoOKQYICxTpIPc=; b=Ek0Q2DtqntWZ8WZKg0HdxkzL9QwUA5UJZxMO7pDGwc06M7fh3v5/75YWbP11n7P+NT qDIxBHand550nVTNwlUzAbI7zUF4fjl6BmbVYUTnXVMCV+E/IR96NsWqCBILw+vajdvE LXIiQ74DZalPcJB3g52/Cd1hlxeTtFl8TRaJhe6t4x+kk0GJhpVTwA1hePB2/j/7CH+y XT5/szPtDknnq+pnXSQZ3yuKFxhNqhIQPhWgNYPAgY4ql+nQBXblwRpbfFUyp6oxgI+4 MbOZH2WltIqX7rJ/ycb9DUKdipmhRHxvAImIDrRN3CBm4MMoptTD6nUWSB4ucJPZPS8R i+tQ== X-Gm-Message-State: AOAM532WJOCa+keTFX+wOG0aJA+8/4AcTKhK5au4wyHjOCBcsJvtuX4+ 9DFkLBfkbgQjajsHLbIJiIK0U52VFYc= X-Received: by 2002:a54:4694:: with SMTP id k20mr1429660oic.136.1643132536671; Tue, 25 Jan 2022 09:42:16 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n12sm4292688oop.5.2022.01.25.09.42.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jan 2022 09:42:15 -0800 (PST) Sender: Guenter Roeck Message-ID: <796d26d7-fc67-1a97-7166-578367e141e4@roeck-us.net> Date: Tue, 25 Jan 2022 09:42:13 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v1 1/2] usb: typec: tcpm: Do not disconnect while receiving VBUS off Content-Language: en-US To: Badhri Jagan Sridharan , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org References: <20220122015520.332507-1-badhri@google.com> From: Guenter Roeck In-Reply-To: <20220122015520.332507-1-badhri@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/21/22 17:55, 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 s/will will/will/ > 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 > --- > 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 */ s/reaach/reach/ Other than that, Reviewed-by: Guenter Roeck > break; > > case SNK_NEGOTIATE_CAPABILITIES: