From patchwork Wed Nov 1 02:19:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 160422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp144264vqx; Tue, 31 Oct 2023 19:19:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF04KeaUyWNXJ9akQKswilbUlwtgR1tkPlkRvIgzo6xE5mX5Wn16Ly2J0uAiPc307MmgiNl X-Received: by 2002:a05:6358:6f12:b0:168:e73f:c9c2 with SMTP id r18-20020a0563586f1200b00168e73fc9c2mr17947162rwn.8.1698805168139; Tue, 31 Oct 2023 19:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698805168; cv=none; d=google.com; s=arc-20160816; b=WOtsSnwNn4Xk0Yq1rRrg4UFsU71+dHOls7Ha3IgzQscdtc5D2C302myHd6Xq9B3lXH QwcgqW1c1tBelgP+S3vBVdrYUfgO1Kn9cyhlskX/zKF8odFAfUEiJQpkrqFnmm0pS+Aq 2ZstJT7U7uk5L3aoVTko5J6giyoDfK58NUZMqUWc/Ga42Ltia8eda2kKNEaaZh15VlUo 2ZIQyQ4YOFGuz5r6jfCdzKcaFF+SYXXTzgVCCdTZGWYfEO5FQr6yyLKOC4nkvnADOVYb PolTCCmyFOFRbEGUtDGFnDZWz21AYjB5XUCYjcr3WG2Z1IPSX8pTp8n2uA3SwWXpaAc4 umWg== 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:message-id:mime-version:date :dkim-signature; bh=YxMLCnvrWc25EU4H4xs2rJSBgkcEn2A7t+6WriOcpdA=; fh=dlbi/R6da6jUt/W+ZgKgAInYXliMfpHboYZKU0LCsR0=; b=vVWxdKIZ+frzgmb3cDnAN2G0hre5auw/IAjgn1yS2B7EiTHyN8m/pEM6afxx8yFqRb bX5qhtIGyFrMtrsVJOvj3hatHSPyC+gpDSShjNlfyLGucA/yO7PUElVJ/2ik9LbCqHkk IKbbB7C6PP9ohkKtCBwUmszeZSklEtyTQAzRFxyx2DWbgw6zSAAWICecdLfVEnVal2+n P2m8wcwvnYhvOsStmdZAaGWw9vTUmE4riWAHOsagtb4kYJrtO71SMWFUTuVeXHB5u+65 sYEYxrDmpfFpllsSrOmX/bblUdKMr9tqrYfmVrwQNkU4aOMgqV/H1gzRpKGeXtZPC8bI ZoBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QiAXIgx8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r29-20020a63205d000000b0058572c8d5d5si1922381pgm.233.2023.10.31.19.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 19:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QiAXIgx8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 060C18025B48; Tue, 31 Oct 2023 19:19:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231822AbjKACTS (ORCPT + 34 others); Tue, 31 Oct 2023 22:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbjKACTR (ORCPT ); Tue, 31 Oct 2023 22:19:17 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A0FF3 for ; Tue, 31 Oct 2023 19:19:14 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-5b7f3f47547so4699286a12.3 for ; Tue, 31 Oct 2023 19:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698805154; x=1699409954; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=YxMLCnvrWc25EU4H4xs2rJSBgkcEn2A7t+6WriOcpdA=; b=QiAXIgx8BWbe7hw4awJHYl6/U2/l+ROHgBNVlkSD30Gb99uEQ2bdhkO7MLWQEXNa00 BJfdVKe0AtA7YwbxV0K2HbYcpv78wL3V/VcJ4je2dLWmactBdkwYkQBQLqtn6Lz7em9s b1PH7UJ45SUSJ6Ye0qIVs7RMy3XFVrH+s7Kt7WTcQr6+ZL/W6ClFkvDc3CeEh7l6TkY3 L2uOQBbvqt/Hkm8QEtKc/uhoSpZK1L9EmezEJEU9Nb5PLJzURJ4v9nt2492zptkbYdwI YNnplLVJQLIl5ifpfIqdEk5h4B88y4E9jyhfsPl8XJtcVKlb43lPaAbH+GNsuHou+dG7 THtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698805154; x=1699409954; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=YxMLCnvrWc25EU4H4xs2rJSBgkcEn2A7t+6WriOcpdA=; b=wWdU9pjyKsYtOaQ+G9YRBwQf5iV+rbD9JL4smzXJi/AtdkXz13N0/YDpM5p2VS8etM ZNz1IsqOb6aTMC6LHf3dCO/NM69wpenfw6wijOHjPOtu1l5hEtN2T/H4LOlX5q9/fA95 +Scj2tidToo7aXv/11pMZ7XuesRNK/iT0skqFAaWbE7VKaVhVYsXKyyMDWL0ROQA9NVC 7zPNYDzMCB7fy56xrE/VKnVMka49fP8exBo64wwZEr0MFH5t/dOnmugi8JIAQZsyt63t r17GqU+GOWm5kGu1MVNmbkWe9FwW+ISbJ831x6dtiu+KjEL7hujDTHARFXS2A5r9y4te kMrg== X-Gm-Message-State: AOJu0Yx9NPaMwCHeg0qx89FrNmGda9SexnsnbOlLpskEmIa7VozvKbV2 qFod3DvFHWio9scEhCaQ15rpzdSgjJA= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a63:344b:0:b0:5a9:fb7b:7f1d with SMTP id b72-20020a63344b000000b005a9fb7b7f1dmr255710pga.0.1698805153730; Tue, 31 Oct 2023 19:19:13 -0700 (PDT) Date: Wed, 1 Nov 2023 02:19:09 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231101021909.2962679-1-badhri@google.com> Subject: [PATCH v1] usb: typec: tcpm: Skip hard reset when in error recovery From: Badhri Jagan Sridharan To: gregkh@linuxfoundation.org, linux@roeck-us.net, heikki.krogerus@linux.intel.com Cc: kyletso@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, rdbabiera@google.com, amitsd@google.com, stable@vger.kernel.org, Badhri Jagan Sridharan X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 19:19:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781326327960186456 X-GMAIL-MSGID: 1781326327960186456 Hard reset queued prior to error recovery (or) received during error recovery will make TCPM to prematurely exit error recovery sequence. Ignore hard resets received during error recovery (or) port reset sequence. ``` [46505.459688] state change SNK_READY -> ERROR_RECOVERY [rev3 NONE_AMS] [46505.459706] state change ERROR_RECOVERY -> PORT_RESET [rev3 NONE_AMS] [46505.460433] disable vbus discharge ret:0 [46505.461226] Setting usb_comm capable false [46505.467244] Setting voltage/current limit 0 mV 0 mA [46505.467262] polarity 0 [46505.470695] Requesting mux state 0, usb-role 0, orientation 0 [46505.475621] cc:=0 [46505.476012] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms [rev3 NONE_AMS] [46505.476020] Received hard reset [46505.476024] state change PORT_RESET -> HARD_RESET_START [rev3 HARD_RESET] ``` Cc: stable@vger.kernel.org Fixes: f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)") Signed-off-by: Badhri Jagan Sridharan Acked-by: Heikki Krogeus Reviewed-by: Guenter Roeck --- drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++ 1 file changed, 9 insertions(+) base-commit: c70793fb7632a153862ee9060e6d48131469a29c diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 058d5b853b57..b386102f7a3a 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -5391,6 +5391,15 @@ static void _tcpm_pd_hard_reset(struct tcpm_port *port) if (port->bist_request == BDO_MODE_TESTDATA && port->tcpc->set_bist_data) port->tcpc->set_bist_data(port->tcpc, false); + switch (port->state) { + case ERROR_RECOVERY: + case PORT_RESET: + case PORT_RESET_WAIT_OFF: + return; + default: + break; + } + if (port->ams != NONE_AMS) port->ams = NONE_AMS; if (port->hard_reset_count < PD_N_HARD_RESET_COUNT)