From patchwork Wed Nov 25 02:07:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 332750 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75A16C63798 for ; Wed, 25 Nov 2020 02:07:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 185E321741 for ; Wed, 25 Nov 2020 02:07:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UTLaRp8v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727247AbgKYCHI (ORCPT ); Tue, 24 Nov 2020 21:07:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727209AbgKYCHH (ORCPT ); Tue, 24 Nov 2020 21:07:07 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E348BC0613D4 for ; Tue, 24 Nov 2020 18:07:07 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id f3so674577plb.11 for ; Tue, 24 Nov 2020 18:07:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=chU6/PiPNUBnmLnxFg8uICWgwVV6llfRaSWUbIwbJ/w=; b=UTLaRp8vPJgoAOH6mrWpt2j98UWI5fLdLu412Yd2bQp300kqstWLg4kKDobxf6CA48 Lzy/ByBaBJmi9fBnfHlwzJcS6EqkK3qgswqS154YK7r2Yqs9LjCrRhkOJwdWR44kqhCY BZH+Xl0KJvjU216zBFfNKUSEImeVAj8abJH3T9LKoBlNv6dcfsKBuhQKln07XF7odySc zXBmu8/BdUwfnoQ9+0nZIQjXhCugfhPcUoy4rxpiq4XjRfJWtkahCY2rHeHz+5K4XC9n 776eUmP+kenIKl9foTTZMooN5u2s5nNkHgXBpfDxnec2symz3byUSmkAULLC0l6OH7Rz rbJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=chU6/PiPNUBnmLnxFg8uICWgwVV6llfRaSWUbIwbJ/w=; b=od6gkRMBK6u43UQfuhv4NyiTZE3tZ3ZkEmv38Ad8Lv/15oUNyJ13Tycbwy2vAQfoRC +jSG7bjbdkycWNMb5POThXxSFadfVrj5HT1VNzWl20IEDzyOM+QqcfoYfxM8GNEvRkh6 8DcRnSXZUa1AXvhlYkNhogBw2TKzPFmAkFR5tyoNp5lPbRfMn7KcF6cSiea87/co0Q9J BG9Fmsd3wNaE1WEKBX0R+3Dtc8BeZajXl2PhzULxZqSpaZCBNR9wUaxDlBZmNtOuW1Pt N7XoZB2M191h3gdgrUgkcrk0W7SBkapsbAaIOBCmBvugFLLB+HHyDJYUq8RCQoCN4Vs8 HlKg== X-Gm-Message-State: AOAM5305YIUOblq9JEb7Oe0EPSe6BZD6jUQNu+ZrDVAZzcH6Gepg5dFf boUiCUw/Y4SjoZ4HqI/jscgPA5yhLUA= X-Google-Smtp-Source: ABdhPJyw6WU2f269qHG5mSTkkL/U3GF4SEVsMs6EyJmYN9dl3a9cCp/rDiXkxcn+JoUhc3zBEWnUZGekyOU= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a62:8006:0:b029:196:33f2:4dd7 with SMTP id j6-20020a6280060000b029019633f24dd7mr1137566pfd.38.1606270027414; Tue, 24 Nov 2020 18:07:07 -0800 (PST) Date: Tue, 24 Nov 2020 18:07:03 -0800 Message-Id: <20201125020703.1604979-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v1] usb: typec: tcpm: Disregard vbus off while in PR_SWAP_SNK_SRC_SOURCE_ON From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org During PR_SWAP sequence, when TCPM is waiting in PR_SWAP_SNK_SRC_SOURCE_ON for the vbus source to ramp up, TCPM would prematurely exit PR_SWAP_SNK_SRC_SOURCE_ON and transition to SNK_UNATTACHED state when a vbus off notification is received. This should not be the case as vbus can still be off while in PR_SWAP_SNK_SRC_SOURCE_ON and the vbus source has PD_T_NEWSRC to ramp up. Signed-off-by: Badhri Jagan Sridharan Acked-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 4aac0efdb720..277b9d4d9c84 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -4218,6 +4218,14 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) /* Do nothing, expected */ break; + case PR_SWAP_SNK_SRC_SOURCE_ON: + /* + * Do nothing when vbus off notification is received. + * TCPM can wait for PD_T_NEWSRC in PR_SWAP_SNK_SRC_SOURCE_ON + * for the vbus source to ramp up. + */ + break; + case PORT_RESET_WAIT_OFF: tcpm_set_state(port, tcpm_default_state(port), 0); break;