Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5222731pxb; Wed, 26 Jan 2022 07:22:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJypBvUO6ke6it3kWtJU11li/aE1FEdLMkDKyJ71WcovDM1jX1omERzL1zm2bvk/a6yubExp X-Received: by 2002:a63:48b:: with SMTP id 133mr9640460pge.367.1643210554360; Wed, 26 Jan 2022 07:22:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643210554; cv=none; d=google.com; s=arc-20160816; b=GjsB8V02LAIhsf4Vq4l8vyLoCnOiN2juEZi3D1Lj3NbVzIvXU7Yuuk2bgGSG0xLGFT OGe5O4urOJ6peIwVW7B106ChIwtTX9fvsNf123ADduFvMmmvV/hqIqJ2sA6GEUVytJv0 rywWJOI5PFipXwQW+GHW8JakQhGLXsWlAZbiukHYE7tn7VJmgbZNibvBZOnMHJYD/W1Z WMGFkl2ACHkAGiECxDbIfSN51w0oaXBLNRxJetLY0XqO/z9Qz/G6M3L//99BHofjuyPc FFQcbI1wAj0KLb5m3KNZrRvF2iW88u7sIpUaME6YfpH+iwtMsnFMwSRXjdoe7NM6EKa4 fVsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=kRF0DIpm+1X7TVEtpuLwufuaaYhaX1D4iAM/RZ5ifBU=; b=BbvMmdX2wfaXvZjsEiLQf4CuZg2jiI8oDVx9gL8VB3M3ghFnI9CtIOfnqt+o98YnJ8 bl3/bMMctCN2WDIUIC9OcBoBy6Ob51d6Inl+wQrCozEqbZZCMQQy2R2bs0GiWDn0Jvhd cApYcyf2O1+KE4YKEbcO5eW2/FatsUdLNQ5z/Z1mfLtN48EE+LC6aAatJGfZkWyjPatA B9Kj9fu2xBUXjStSww/hK4llQMUtMI0nCv2BeF0UZD5lWsmHkc71ch6G9pLY7pAAHjhs B1WVhqcdB3PbXtfPC6P5Msfu5wNuCau8cEshFHJlycMXo1zm7wUOS1yDeNtIZwjqcbyj Uffw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mZi6Fx2j; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nu15si1892135pjb.152.2022.01.26.07.22.21; Wed, 26 Jan 2022 07:22:34 -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=@google.com header.s=20210112 header.b=mZi6Fx2j; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236093AbiAZCA3 (ORCPT + 99 others); Tue, 25 Jan 2022 21:00:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236091AbiAZCAY (ORCPT ); Tue, 25 Jan 2022 21:00:24 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 858C8C06173B for ; Tue, 25 Jan 2022 18:00:24 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 2-20020a251302000000b006118f867dadso45366581ybt.12 for ; Tue, 25 Jan 2022 18:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=kRF0DIpm+1X7TVEtpuLwufuaaYhaX1D4iAM/RZ5ifBU=; b=mZi6Fx2jqpQSFDEvYVLiX63ZP5KThUtDgI7rcawn3RPj10LWxDXuDPGG04yoak7F7e 1x/xB+OK8cjxUin+sBNf3JX50l3+WjkXkOuSvDnGZF/9zWte89txF/FeiD9/d9Y1saSy MG1iKLRDgT+vXjcfC46M2nRnqF+v7nn40d3eqiY1JrH3WdPfHQVWlEssP6NcZ/3S7bVN o8ZzZbRx8qXkJcVCMSj5OYKyca18XN0M9D9J4ZCDg+KIXqqifTcQxTeIcooJhM7smKdS CUGDTi36FCXS0fJuhq/NfG1406D0a17obNjgd6lOnriUhtSwqGE4pFmqtzLAIv+IHtOb wP5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=kRF0DIpm+1X7TVEtpuLwufuaaYhaX1D4iAM/RZ5ifBU=; b=6NCgl0rP7GuwhqgMQZBCjcMtwkzBjsT1BzGNGKSfDlxOU6SNFi9BaXgRdNwH1iIvMr Y+1ix+/F+hiSZL6o5EVfjRs6kcCKUE9fbqqRsfg0wKHolw4XCF6HrgvqIF2wPpxYE820 2wsZQo0ltdPyRj9A6tRmRQOMQWAypqBvjKx/a/jjjhs9x9LvKLWjQ9K/poQWF9qaWqBx CoF6pOQ+mEAqTXK2T8/JnSQyfnFIEeFCNU1myuYXrNN+NGRucNYc+pbTtF2ihD1/5lyW s6X1oZYqWGP69ydYLP65Koq/362uroyzvW/Tpse20I8e4MXwaLMRZrlhzucICLxlVD7U ByfA== X-Gm-Message-State: AOAM532zNYgE1D+/B/65hQyh1zEDKPkgJcbG/0nNgNFhUQZa8/eALd68 /X5MyoHxjHcn6//KRtrxZhwLmXguTD8= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f4a7:8e16:f301:160]) (user=badhri job=sendgmr) by 2002:a25:1f41:: with SMTP id f62mr32575122ybf.118.1643162422615; Tue, 25 Jan 2022 18:00:22 -0800 (PST) Date: Tue, 25 Jan 2022 18:00:15 -0800 Message-Id: <20220126020016.3159598-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog Subject: [PATCH v2 1/2] usb: typec: tcpm: Do not disconnect while receiving VBUS off From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 --- Changes since v1: - Fix typos stated by Guenter Roeck. --- 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..3bf79f52bd34 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 reach VSAFE5V to connect */ break; case SNK_NEGOTIATE_CAPABILITIES: -- 2.35.0.rc0.227.g00780c9af4-goog