Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp160614rdb; Wed, 18 Oct 2023 23:46:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHONoIIGDWuRWJ9ZXZIfAJwPYvfSinGfhFTYKX9e1kRvfert2AwehOswJs1RxoIdDhX2XXM X-Received: by 2002:a05:6a00:248b:b0:68a:52ec:3d36 with SMTP id c11-20020a056a00248b00b0068a52ec3d36mr1253658pfv.31.1697697986843; Wed, 18 Oct 2023 23:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697697986; cv=none; d=google.com; s=arc-20160816; b=MSAHXvfW4M/NLsllQSe6VPRKaSAFyyrT7R0ZT+1RzzVJe77il7zBGkAQPRGJxQRT3n xjjdWitthJJWXoTvl0XvHa8bAKYpVyrASztZp2xzYpueio/2KI492PArb4OzJpCCjRbL Xzi/2bhc4MuOCq7BdZLKdBu1CTTEStmQ+vLo+R/ClnWx+kjUrt8SmTytz3QZAqTveU0P 5mHX/Syztc2P5YUK5CUB08yeYWtYkpuA5PuSjrizIcZmhCZmXJseWhGrU7rRjoQMZqN/ PTF7hFWus9F1YB6N32jOJB8oTqRqj3Rcf3EgnHVrfITbtz1VzON+/CReGEDtOPyHzio/ 1Hfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Az8Ao8JcuBtli/DPHDS+uWcHUi/uj3aVqqWAP95l31I=; fh=3uvCVHo36cgJDQzJ16lHVcme58BqLGyGHKOQeI/4i9o=; b=1Af2iE2ABckr8vkp3hxvFMSsXvPB0bUcD3i+zx/l3/rBnUoVHu4M1bxk+UQlgZsw5b dzIanIp5ic4CEiTlqM5MNUxYlBWXZYnPd5SiO9PqE2JDCTsQ1QOrO4pbjM3Ojcz6q1F+ madUVOVHXtp6o607FYI/DQD136vfxm+rXDIdD72tJJ43/Mis8AXaw4ei435nsdLLLAYx NwdX6C6OXZppj9ZmnJkX0q0ZIgKR4kSRe//bqVrGd6ECOxkPwHwtLc6vN46BkpwQF7LQ H8c6UQ8tM17bogQbII61Gub1lDX7nBfANhfAMpfPxXllLQ3w7YJBNFM3Wd4/Pymf5bGG u2+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JOmox+3m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id 71-20020a63014a000000b005b57aa8517bsi3894390pgb.91.2023.10.18.23.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 23:46:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JOmox+3m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2C1E9822F8F0; Wed, 18 Oct 2023 23:46:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232752AbjJSGqJ (ORCPT + 99 others); Thu, 19 Oct 2023 02:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232818AbjJSGqG (ORCPT ); Thu, 19 Oct 2023 02:46:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E45F124; Wed, 18 Oct 2023 23:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697697964; x=1729233964; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=qNGiwG6sPEn5ubts1BrNP/8VMfC11VFMYM5s5vJIJZU=; b=JOmox+3mKfj0lafGMacmqd+QL8A4VDLckj9TJsSdkWqzaaPSHwgZ8uWX u4d8A4hkUl5fisXdN/8fkEOKC7fFTfrlu6mc59xfYe94JnegT8Aa43+Uk 4XxHT4l3waQhA20q1xWYsY5Kf6AlYg6g5V21/RCsa9pwWxdtpaJ32P+p5 E0qKTYPMMoSkgc9aMcszt5zFIAn5Xx9p8KNf+++aIpU7jyFWMYnxedjMt QjsSigwpt5CRIfyxhWEMA8CraPb2mf+hXZCBKcGR5zLwc1Z48sbbbVje7 bTqwAa8qInuZvx1C/SYP/EXwsZgdEOt8eYhPT9lYyxjt41hzxtCG/G8C8 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="376560061" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="376560061" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 23:46:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="1088259427" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="1088259427" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga005.fm.intel.com with SMTP; 18 Oct 2023 23:45:59 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Thu, 19 Oct 2023 09:45:58 +0300 Date: Thu, 19 Oct 2023 09:45:58 +0300 From: Heikki Krogerus To: Badhri Jagan Sridharan Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, kyletso@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, rdbabiera@google.com, amitsd@google.com, stable@vger.kernel.org Subject: Re: [PATCH v2] usb: typec: tcpm: Fix sink caps op current check Message-ID: References: <20231015035838.2207567-1-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231015035838.2207567-1-badhri@google.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 23:46:23 -0700 (PDT) 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 Acked-by: Heikki Krogerus > --- > 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 -- heikki