Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1838419rdg; Sat, 14 Oct 2023 22:32:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVVnRFgnlAXs8gDvBwEIyVj4r5AGVguf089zEfaMj/1UnhTOjpWQ1wOkdmp+ExMRFpQNMa X-Received: by 2002:a05:6358:3407:b0:134:e3d2:1e50 with SMTP id h7-20020a056358340700b00134e3d21e50mr32566385rwd.18.1697347940362; Sat, 14 Oct 2023 22:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697347940; cv=none; d=google.com; s=arc-20160816; b=07djukIUE3IhHhcjLZYADnxUNDZT23+tc4u+JjPf8EuIsynzRXnVrRTM3NxjYBOmge g9wK6WA7GhFqYnZy/6XrbVc8Gh7dOZnw8Cp7KVJmKnBmlnLWkj30j9SsBXLeeOS+GejQ B1MiJkKUexoBZjSXGTg+8HYGB9QqBzBGxyWMFdWOvnDvvtzT2hFxieb13bSdA3Vn2zp/ LaMDu3JV/67RL70c7ZShsn2YmcBQ18Shi3v/C9qSCbgzmhK7C2vnIj2pXL8wZQgWDzxK rpsFxfsjIDApt6IS6kSHfAeBkX44vI9n0pHvowIao9EarpETbvdOc9gzwNYTuAlRIEGp BtMw== 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=DtQNq1gvU7zKIF2fj6mC9r8wogeTbs5S7+1Rv7+FYSI=; fh=9PK6N11PLsyzA3LsnqKYOrru3br2ainTfeyQbbmwvDY=; b=RqU8RncNFoFLRM8omsNKmDR8I1an1MufXAajWzfjHizRenY5dISPtsbmB25K9PR+eD Ii2Jrd5nY+6F+oDUy1PO2AoKO15NdYa5Z7ZrODst3ZXWsHnU/ssyNICz3TZ5t4JYwGpf bR46dO/opVcrmUggQtAVVz+EQqQ2Ld7jgCeT1FRtZSNSg1VFX/MTvgCWIIRz4IUa1PP3 yYkrEdVg4b5PG8XFfzWqiasTork8A/444ou30BWbhog1JPoGgPifJsci2nhDNlq+Yw3Z ByXTmEUdt8khrVqXJaY/p5U7eH6x4QO3f9v5P1YfAe2m+MxsIAAt4WphA6uuyYGYomMy boXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cRE3Sr3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cl4-20020a056a0032c400b0068a5877bfaesi20196753pfb.382.2023.10.14.22.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 22:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cRE3Sr3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id DDF3F803239C; Sat, 14 Oct 2023 22:32:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233489AbjJOFbQ (ORCPT + 99 others); Sun, 15 Oct 2023 01:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233472AbjJOFbP (ORCPT ); Sun, 15 Oct 2023 01:31:15 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2974CE3 for ; Sat, 14 Oct 2023 22:31:13 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b5a586da6so25192507b3.1 for ; Sat, 14 Oct 2023 22:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697347872; x=1697952672; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=DtQNq1gvU7zKIF2fj6mC9r8wogeTbs5S7+1Rv7+FYSI=; b=cRE3Sr3+OGdFuWvguBdI5OkXvOUa5OUmqnv1HRzc08keZpseXTEon9fGopA41Kej9u 1DTwftREYU8G49bl6e+bbdrc6RsrIWIwkAoUOZ16LzvQw64NzJ0q00XhnefI0HTsdYf6 w7O1QdWTxNQVIGjOy5FaKH5SzmVgAKVvzyu1T33WplM4BWa7vsWFC15C4Ev4w/W1lr37 jJVCMjdYD1Jg8yfu3k+f9pc8aFcDyE+EE1rMl/k74nT7T+YI06m5+jIDVnlmIC8SvOSN v/gmUOKor4Tr2gCS+uo5rbcPkSei7DUSOcPps56uUYT7zpDfFKAhmPZOcXtDxdxyPvFp tpjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697347872; x=1697952672; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DtQNq1gvU7zKIF2fj6mC9r8wogeTbs5S7+1Rv7+FYSI=; b=jcVUtthdFicx8wdeRPpBSkchfcU2YwWxAtaIZceeji52UhBSwZI8ZuPjZReAaBBkMW +oJq7n65klTSPlScAKqGV1lABoq592MwtHiAChcKDw7Bt4OSqkmCUaUSP6q7lZ2rNVyu B+89/l5pnSBHNeEv7kSTSDwurDdj5RwqR7SaIQMt5PW9PWfbbLEqf3dfdtGvuUAWah/j +a/FG+XMuD+7eECx0qspn2r/JYTbQa9FzLXPsX/zMzU9wXk/b22G8aHnN8moLEt6Zugu RPNcVbWA3tzlKUtf9MIv2kMNavOkB7zngwLKFjHxJ0ylqfaImNUa9Jd8RMQwM1nHUCYl qv3w== X-Gm-Message-State: AOJu0YyVKk+QWSw+47isvGZVe/BB6ggqLT1Mq9lk83dPlBffkHauBpe9 l/JP7Tw1Huv+50lXFI/TGRHP8nuaGnM= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a25:aa83:0:b0:d8a:fcdb:d670 with SMTP id t3-20020a25aa83000000b00d8afcdbd670mr125664ybi.1.1697347872345; Sat, 14 Oct 2023 22:31:12 -0700 (PDT) Date: Sun, 15 Oct 2023 05:31:08 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog Message-ID: <20231015053108.2349570-1-badhri@google.com> Subject: [PATCH v2] usb: typec: tcpm: Add additional checks for contaminant 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, stable@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" 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,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 fry.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 (fry.vger.email [0.0.0.0]); Sat, 14 Oct 2023 22:32:18 -0700 (PDT) When transitioning from SNK_DEBOUNCED to unattached, its worthwhile to check for contaminant to mitigate wakeups. ``` [81334.219571] Start toggling [81334.228220] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected] [81334.305147] CC1: 0 -> 0, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected] [81334.305162] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [81334.305187] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [81334.475515] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms] [81334.486480] CC1: 0 -> 0, CC2: 3 -> 0 [state SNK_DEBOUNCED, polarity 0, disconnected] [81334.486495] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS] [81334.486515] pending state change SNK_DEBOUNCED -> SNK_UNATTACHED @ 20 ms [rev3 NONE_AMS] [81334.506621] state change SNK_DEBOUNCED -> SNK_UNATTACHED [delayed 20 ms] [81334.506640] Start toggling [81334.516972] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected] [81334.592759] CC1: 0 -> 0, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected] [81334.592773] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [81334.592792] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [81334.762940] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms] [81334.773557] CC1: 0 -> 0, CC2: 3 -> 0 [state SNK_DEBOUNCED, polarity 0, disconnected] [81334.773570] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS] [81334.773588] pending state change SNK_DEBOUNCED -> SNK_UNATTACHED @ 20 ms [rev3 NONE_AMS] [81334.793672] state change SNK_DEBOUNCED -> SNK_UNATTACHED [delayed 20 ms] [81334.793681] Start toggling [81334.801840] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected] [81334.878655] CC1: 0 -> 0, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected] [81334.878672] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS] [81334.878696] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] [81335.048968] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms] [81335.060684] CC1: 0 -> 0, CC2: 3 -> 0 [state SNK_DEBOUNCED, polarity 0, disconnected] [81335.060754] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS] [81335.060775] pending state change SNK_DEBOUNCED -> SNK_UNATTACHED @ 20 ms [rev3 NONE_AMS] [81335.080884] state change SNK_DEBOUNCED -> SNK_UNATTACHED [delayed 20 ms] [81335.080900] Start toggling ``` Cc: stable@vger.kernel.org Fixes: 599f008c257d ("usb: typec: tcpm: Add callbacks to mitigate wakeups due to contaminant") Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 6e843c511b85..1c7e8dc5282d 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3903,6 +3903,8 @@ static void run_state_machine(struct tcpm_port *port) port->potential_contaminant = ((port->enter_state == SRC_ATTACH_WAIT && port->state == SRC_UNATTACHED) || (port->enter_state == SNK_ATTACH_WAIT && + port->state == SNK_UNATTACHED) || + (port->enter_state == SNK_DEBOUNCED && port->state == SNK_UNATTACHED)); port->enter_state = port->state; base-commit: 1034cc423f1b4a7a9a56d310ca980fcd2753e11d -- 2.42.0.655.g421f12c284-goog