Message ID | 20231015035838.2207567-1-badhri@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2760691vqb; Sat, 14 Oct 2023 21:01:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvPdi7QzaU56zH/ejrRGg3bECKjRBUJ8TR9JrbHI4y4wyI8iuSpBISa2QMOJA10BQ30fZd X-Received: by 2002:a05:6602:1a07:b0:79d:1c65:9bde with SMTP id bo7-20020a0566021a0700b0079d1c659bdemr31925266iob.1.1697342516278; Sat, 14 Oct 2023 21:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697342516; cv=none; d=google.com; s=arc-20160816; b=U/4aKCHXQNHe5p4o9c1z4QNoyAmSe8sfz0RkkjrapZArofi2jkg8vmX4XjXdKndoDa 4Qg/qvdFUL2rkKsNJIrPxQz0KuOFIxuoBAvUJydQOBcQN6VfFJHtcgCRwVYv4wNQ64lY tiaBTZp+od4+RXY2ucUGT2CMi4mux3VUy2FBPofTch1Exd+QbmDtd/zDx8SdN1nl1NTW 4lsK84pT/B3zvpIeRVfCI2IhQxOeL1+Okv5V+dWuHW31FTNO8G5tkl3fVwwcvDFU7bQX BHNjQkVZWgBW3PrVsN/7p+Di182ImqvWOZlylaJeJa6NE42dueOG9YG8qdH9iPDZ9gdx YYPQ== 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=shh/0TwHJv/d7VwXwypDokr6btLr6DjEH1mcpVIpW4Y=; fh=dlbi/R6da6jUt/W+ZgKgAInYXliMfpHboYZKU0LCsR0=; b=pI7I3ZCPrA5JHShMy0oniD4kEKlPsHehVqPeQKTxY331GawdBvuSJ3n8ejsReVmBgR e8YHFBGXTSBoO7Vlcn7O5CLVEPpPM6z7kmNljzDX4wVsqWodKqmToUqFhiWpHIHml3dR S9u1iVn5YeNVauRo0egb6ZG1GHAe5C+pUfH2qlr/cR1XEzXO+A708zeTdisk4UnAaavY fMHU2AyrIpKOBsUGDbQFHRiLfv1EeXexI20+SYet10dG0Hg8liHk7/rVH5RCPqo9UpN6 +SHhPgPOwZoBxHAyO71ewutE57CNU22aBvmE4iMQ3olyytcslf0505G/REpmK+l98xhZ M5Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Dkrdn8PP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id e12-20020a63db0c000000b00565ecee8793si7984367pgg.875.2023.10.14.21.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 21:01:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Dkrdn8PP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id D09C78066914; Sat, 14 Oct 2023 21:01:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233452AbjJOD6r (ORCPT <rfc822;hjfbswb@gmail.com> + 19 others); Sat, 14 Oct 2023 23:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233390AbjJOD6q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 14 Oct 2023 23:58:46 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7F1DC for <linux-kernel@vger.kernel.org>; Sat, 14 Oct 2023 20:58:42 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-27cefad6c6fso2654761a91.2 for <linux-kernel@vger.kernel.org>; Sat, 14 Oct 2023 20:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697342321; x=1697947121; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=shh/0TwHJv/d7VwXwypDokr6btLr6DjEH1mcpVIpW4Y=; b=Dkrdn8PPycjNl9+oo/M69VPCpl/RIWyeCgx7vfAxSpokgEvCUjBm2LKfiQsqurgITc HBeKxcw/HBYQL1HTQagAd2YKc3+IUpLsoY5Ib90lB+6D60hLjitSys1+auNU/7o6H4L6 K3MLYhBiRSmTadxmY9jJEL448tq/EGEzK2QkDKAwfpIJ+9sJVerXZxD2a27klEzPbGvP p84Z8JWlxdLl/cXtlMMKIjdw3Yy4CKns7RxydaXw/2QLGDYJ2JlNJ7QX4NnzfV6+4wsC WC+nbZYvI+QujG96fiCYZw2HrVURE15wbE3ecdfSo9+Ai0B3jciPKXmJ/iTU+yKSqc0N vK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697342321; x=1697947121; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=shh/0TwHJv/d7VwXwypDokr6btLr6DjEH1mcpVIpW4Y=; b=Etsh+PgWPsSzDuZB/+3cIAy5uHQaDFX2AwALUYJyFDLXN2CkffldgbO2OneLiYFXqX x+jnIxTHpAWgb71pQyM3BYoYKaTmZ7tJOeUkF2TR0NtXw1UVOfesOWAVTZ0rEzTEpTkR 2freTDyIeDwdv19O50j2TI9I7Q1teQ8HnSIgwll4rbPnyfzggU9dzgv++Hjf2KaK/meC O0KJrN42imndL57C2EYwIcdcVQGtef2qpFHW31Xl1DOTVFyvU2bYvy19u7KuEm1XMgvK RdFgwez2qOVX8ZAo48qw1iMmCkfl3fxh5Yo2sjjMnO47ALstdfK2km+otWU32vFNXJ3A Kf9g== X-Gm-Message-State: AOJu0Yz+AHQqxssbl0W1tpHcbWxYbkIxiNlgYrnJsgMQEtVGUAep+xlM v/eeZ1XR/p2Of3XVxyfu+MER046IZnM= X-Received: from badhri.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:6442]) (user=badhri job=sendgmr) by 2002:a05:6a00:1792:b0:68f:a681:390a with SMTP id s18-20020a056a00179200b0068fa681390amr737762pfg.0.1697342321622; Sat, 14 Oct 2023 20:58:41 -0700 (PDT) Date: Sun, 15 Oct 2023 03:58:38 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog Message-ID: <20231015035838.2207567-1-badhri@google.com> Subject: [PATCH v2] usb: typec: tcpm: Fix sink caps op current check From: Badhri Jagan Sridharan <badhri@google.com> 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 <badhri@google.com> 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 pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sat, 14 Oct 2023 21:01:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779792626346444214 X-GMAIL-MSGID: 1779792626346444214 |
Series |
[v2] usb: typec: tcpm: Fix sink caps op current check
|
|
Commit Message
Badhri Jagan Sridharan
Oct. 15, 2023, 3:58 a.m. UTC
TCPM checks for sink caps operational current even when PD is disabled.
This incorrectly sets tcpm_set_charge() when PD is disabled.
Check for sink caps only when PD is enabled.
[ 97.572342] Start toggling
[ 97.578949] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected]
[ 99.571648] CC1: 0 -> 0, CC2: 0 -> 4 [state TOGGLING, polarity 0, connected]
[ 99.571658] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS]
[ 99.571673] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS]
[ 99.741778] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
[ 99.789283] CC1: 0 -> 0, CC2: 4 -> 5 [state SNK_DEBOUNCED, polarity 0, connected]
[ 99.789306] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS]
[ 99.903584] VBUS on
[ 99.903591] state change SNK_DEBOUNCED -> SNK_ATTACHED [rev3 NONE_AMS]
[ 99.903600] polarity 1
[ 99.910155] enable vbus discharge ret:0
[ 99.910160] Requesting mux state 1, usb-role 2, orientation 2
[ 99.946791] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
[ 99.946798] state change SNK_STARTUP -> SNK_DISCOVERY [rev3 NONE_AMS]
[ 99.946800] Setting voltage/current limit 5000 mV 500 mA
[ 99.946803] vbus=0 charge:=1
[ 100.027139] state change SNK_DISCOVERY -> SNK_READY [rev3 NONE_AMS]
[ 100.027145] Setting voltage/current limit 5000 mV 3000 mA
[ 100.466830] VBUS on
Cc: stable@vger.kernel.org
Fixes: 34fde9ec08a3 ("FROMGIT: usb: typec: tcpm: not sink vbus if operational current is 0mA")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
Changes since v1:
* Fix commit title and description to address comments from Guenter Roeck
---
drivers/usb/typec/tcpm/tcpm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
base-commit: 1034cc423f1b4a7a9a56d310ca980fcd2753e11d
Comments
On Sun, Oct 15, 2023 at 03:58:38AM +0000, Badhri Jagan Sridharan wrote: > TCPM checks for sink caps operational current even when PD is disabled. > This incorrectly sets tcpm_set_charge() when PD is disabled. > Check for sink caps only when PD is enabled. > > [ 97.572342] Start toggling > [ 97.578949] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected] > [ 99.571648] CC1: 0 -> 0, CC2: 0 -> 4 [state TOGGLING, polarity 0, connected] > [ 99.571658] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS] > [ 99.571673] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] > [ 99.741778] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms] > [ 99.789283] CC1: 0 -> 0, CC2: 4 -> 5 [state SNK_DEBOUNCED, polarity 0, connected] > [ 99.789306] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS] > [ 99.903584] VBUS on > [ 99.903591] state change SNK_DEBOUNCED -> SNK_ATTACHED [rev3 NONE_AMS] > [ 99.903600] polarity 1 > [ 99.910155] enable vbus discharge ret:0 > [ 99.910160] Requesting mux state 1, usb-role 2, orientation 2 > [ 99.946791] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS] > [ 99.946798] state change SNK_STARTUP -> SNK_DISCOVERY [rev3 NONE_AMS] > [ 99.946800] Setting voltage/current limit 5000 mV 500 mA > [ 99.946803] vbus=0 charge:=1 > [ 100.027139] state change SNK_DISCOVERY -> SNK_READY [rev3 NONE_AMS] > [ 100.027145] Setting voltage/current limit 5000 mV 3000 mA > [ 100.466830] VBUS on > > Cc: stable@vger.kernel.org > Fixes: 34fde9ec08a3 ("FROMGIT: usb: typec: tcpm: not sink vbus if operational current is 0mA") > Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> > --- > Changes since v1: > * Fix commit title and description to address comments from 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 6e843c511b85..994493481c24 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -4268,7 +4268,8 @@ static void run_state_machine(struct tcpm_port *port) > current_lim = PD_P_SNK_STDBY_MW / 5; > tcpm_set_current_limit(port, current_lim, 5000); > /* Not sink vbus if operational current is 0mA */ > - tcpm_set_charge(port, !!pdo_max_current(port->snk_pdo[0])); > + tcpm_set_charge(port, port->pd_supported ? > + !!pdo_max_current(port->snk_pdo[0]) : true); Nit: !port->pd_supported || pdo_max_current(port->snk_pdo[0] seems simpler. Otherwise Reviewed-by: Guenter Roeck <linux@roeck-us.net> > > if (!port->pd_supported) > tcpm_set_state(port, SNK_READY, 0); > > base-commit: 1034cc423f1b4a7a9a56d310ca980fcd2753e11d > -- > 2.42.0.655.g421f12c284-goog >
On Sun, Oct 15, 2023 at 03:58:38AM +0000, Badhri Jagan Sridharan wrote: > TCPM checks for sink caps operational current even when PD is disabled. > This incorrectly sets tcpm_set_charge() when PD is disabled. > Check for sink caps only when PD is enabled. > > [ 97.572342] Start toggling > [ 97.578949] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected] > [ 99.571648] CC1: 0 -> 0, CC2: 0 -> 4 [state TOGGLING, polarity 0, connected] > [ 99.571658] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS] > [ 99.571673] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] > [ 99.741778] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms] > [ 99.789283] CC1: 0 -> 0, CC2: 4 -> 5 [state SNK_DEBOUNCED, polarity 0, connected] > [ 99.789306] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS] > [ 99.903584] VBUS on > [ 99.903591] state change SNK_DEBOUNCED -> SNK_ATTACHED [rev3 NONE_AMS] > [ 99.903600] polarity 1 > [ 99.910155] enable vbus discharge ret:0 > [ 99.910160] Requesting mux state 1, usb-role 2, orientation 2 > [ 99.946791] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS] > [ 99.946798] state change SNK_STARTUP -> SNK_DISCOVERY [rev3 NONE_AMS] > [ 99.946800] Setting voltage/current limit 5000 mV 500 mA > [ 99.946803] vbus=0 charge:=1 > [ 100.027139] state change SNK_DISCOVERY -> SNK_READY [rev3 NONE_AMS] > [ 100.027145] Setting voltage/current limit 5000 mV 3000 mA > [ 100.466830] VBUS on > > Cc: stable@vger.kernel.org > Fixes: 34fde9ec08a3 ("FROMGIT: usb: typec: tcpm: not sink vbus if operational current is 0mA") > Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > Changes since v1: > * Fix commit title and description to address comments from 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 6e843c511b85..994493481c24 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -4268,7 +4268,8 @@ static void run_state_machine(struct tcpm_port *port) > current_lim = PD_P_SNK_STDBY_MW / 5; > tcpm_set_current_limit(port, current_lim, 5000); > /* Not sink vbus if operational current is 0mA */ > - tcpm_set_charge(port, !!pdo_max_current(port->snk_pdo[0])); > + tcpm_set_charge(port, port->pd_supported ? > + !!pdo_max_current(port->snk_pdo[0]) : true); > > if (!port->pd_supported) > tcpm_set_state(port, SNK_READY, 0); > > base-commit: 1034cc423f1b4a7a9a56d310ca980fcd2753e11d > -- > 2.42.0.655.g421f12c284-goog
On Sun, Oct 15, 2023 at 03:58:38AM +0000, Badhri Jagan Sridharan wrote: > TCPM checks for sink caps operational current even when PD is disabled. > This incorrectly sets tcpm_set_charge() when PD is disabled. > Check for sink caps only when PD is enabled. > > [ 97.572342] Start toggling > [ 97.578949] CC1: 0 -> 0, CC2: 0 -> 0 [state TOGGLING, polarity 0, disconnected] > [ 99.571648] CC1: 0 -> 0, CC2: 0 -> 4 [state TOGGLING, polarity 0, connected] > [ 99.571658] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS] > [ 99.571673] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms [rev3 NONE_AMS] > [ 99.741778] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms] > [ 99.789283] CC1: 0 -> 0, CC2: 4 -> 5 [state SNK_DEBOUNCED, polarity 0, connected] > [ 99.789306] state change SNK_DEBOUNCED -> SNK_DEBOUNCED [rev3 NONE_AMS] > [ 99.903584] VBUS on > [ 99.903591] state change SNK_DEBOUNCED -> SNK_ATTACHED [rev3 NONE_AMS] > [ 99.903600] polarity 1 > [ 99.910155] enable vbus discharge ret:0 > [ 99.910160] Requesting mux state 1, usb-role 2, orientation 2 > [ 99.946791] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS] > [ 99.946798] state change SNK_STARTUP -> SNK_DISCOVERY [rev3 NONE_AMS] > [ 99.946800] Setting voltage/current limit 5000 mV 500 mA > [ 99.946803] vbus=0 charge:=1 > [ 100.027139] state change SNK_DISCOVERY -> SNK_READY [rev3 NONE_AMS] > [ 100.027145] Setting voltage/current limit 5000 mV 3000 mA > [ 100.466830] VBUS on > > Cc: stable@vger.kernel.org > Fixes: 34fde9ec08a3 ("FROMGIT: usb: typec: tcpm: not sink vbus if operational current is 0mA") This is obviously not a valid git id in Linus's tree, and our tools reject it :( thanks, greg k-h
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 6e843c511b85..994493481c24 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -4268,7 +4268,8 @@ static void run_state_machine(struct tcpm_port *port) current_lim = PD_P_SNK_STDBY_MW / 5; tcpm_set_current_limit(port, current_lim, 5000); /* Not sink vbus if operational current is 0mA */ - tcpm_set_charge(port, !!pdo_max_current(port->snk_pdo[0])); + tcpm_set_charge(port, port->pd_supported ? + !!pdo_max_current(port->snk_pdo[0]) : true); if (!port->pd_supported) tcpm_set_state(port, SNK_READY, 0);