Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3278784pxj; Tue, 11 May 2021 00:22:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwspPjcBK7NA4Yj2m+9F+N46iiBhMC2S33/YXkgp86UgD8IbtVXAIW0pml+gsyMKQCCXq5c X-Received: by 2002:a92:650d:: with SMTP id z13mr11000197ilb.193.1620717760592; Tue, 11 May 2021 00:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620717760; cv=none; d=google.com; s=arc-20160816; b=upM/mjDjde02iXs0zRlCSIND7gR/4IOvir78KL/Bm7FWlG43NgHtgim4Fo6p9OCcGs nPSBwWTLbCIKlkxbPUfrSbipWVqVg7FowOoi0ycfxfxgP5HlWWBy7gjTUS9jG2RGg6x2 VelO/E8+pfiuSmlbfcN4BUD1d5rKf6tIhoi63UT+UwJxh6hgg69T3BdNEBgk2ynWMiFr vXoWNNu0+S0Nl7BYKjHrmMyyOvnNx/e2vLwXOa4wXyPrTvnNWzQJRXlcUTD2ygff/MrF ajTRP2U8RHV1YHGJKx6UiSmAXlG6d16XpQg2tejwz/t1+oYn9YQYKSFYhfHvfPF4XaVf zv6Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=H5Txg327ztMVjlywc2/eZ7hFzsJ/Xhyo3e6MFvlwbcU=; b=U24LBz5PKl7w0a5XS+fOv6PFplLY/+oPyGc9MQLagAkkAamRxHa7gqLK3Bev4hfcDn j/3E9Rt6dCYxhCHylwBLfjV/lhRc7/UxXJI3WA5KRCA+AYsZeyJ9oeW/+JMCF1SMXpJj TQ/jVIBa7HzEWt9wLS3t2xfHo3D0Daza2XP9/rQNGtxdFSmVlr9kXGZ6p6JDQGRa4VsK zrnU7wXDzBr3arsO6hx/xEYogYjCYJCxs6xHKpF5HC1oiUjFjiL5RvKDFyoOZZiku4Ms RBEbeSci7tjcdj8FFE9I8hfpVE0o+y1L79DZhAi0bfhNvGT11iA+ipNskY+N5xSxsTQn VJAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si18258825jao.3.2021.05.11.00.22.28; Tue, 11 May 2021 00:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbhEKHV5 (ORCPT + 99 others); Tue, 11 May 2021 03:21:57 -0400 Received: from mga17.intel.com ([192.55.52.151]:27863 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbhEKHV4 (ORCPT ); Tue, 11 May 2021 03:21:56 -0400 IronPort-SDR: Cm6er4fitZVHvPeaboeT/nxBu3qDUn8dBos8RktEyi4pKK1o+fLdbjDd5P2l3rWxW4/pb0rjAZ aNtRGnRlf+Jw== X-IronPort-AV: E=McAfee;i="6200,9189,9980"; a="179639943" X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="179639943" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 00:20:50 -0700 IronPort-SDR: nZVmxloKpCeJWz6VllrIepWHZH3IFc5Se0cjV6eMWtBP2OVKyR+6lo7hN//4a0B6Mh8Dq21z1o xdq0rwBtCZow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="536873648" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 11 May 2021 00:20:48 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 11 May 2021 10:20:47 +0300 Date: Tue, 11 May 2021 10:20:47 +0300 From: Heikki Krogerus To: Badhri Jagan Sridharan Cc: Guenter Roeck , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso Subject: Re: [PATCH] usb: typec: tcpm: Fix SINK_DISCOVERY current limit for Rp-default Message-ID: References: <20210510211756.3346954-1-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210510211756.3346954-1-badhri@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 10, 2021 at 02:17:56PM -0700, Badhri Jagan Sridharan wrote: > This is a regression introduced by > <1373fefc6243cc96b3565f0ffffadfac4ccfb977> > "Allow slow charging loops to comply to pSnkStby". > > When Source advertises Rp-default, tcpm would request 500mA when in > SINK_DISCOVERY, Type-C spec advises the sink to follow BC1.2 current > limits when Rp-default is advertised. > [12750.503381] Requesting mux state 1, usb-role 2, orientation 1 > [12750.503837] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS] > [12751.003891] state change SNK_STARTUP -> SNK_DISCOVERY > [12751.003900] Setting voltage/current limit 5000 mV 500 mA > > This patch restores the behavior where the tcpm would request 0mA when > Rp-default is advertised by the source. > [ ? 73.174252] Requesting mux state 1, usb-role 2, orientation 1 > [ ? 73.174749] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS] > [ ? 73.674800] state change SNK_STARTUP -> SNK_DISCOVERY > [ ? 73.674808] Setting voltage/current limit 5000 mV 0 mA > > During SNK_DISCOVERY, Cap the current limit to PD_P_SNK_STDBY_MW / 5 only > for slow_charger_loop case. > > Fixes: 1373fefc6243 ("Allow slow charging loops to comply to pSnkStby") > Signed-off-by: Badhri Jagan Sridharan Acked-by: Heikki Krogerus > --- > drivers/usb/typec/tcpm/tcpm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index c4fdc00a3bc8..a73299a08ef7 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -4055,7 +4055,7 @@ static void run_state_machine(struct tcpm_port *port) > if (port->vbus_present) { > u32 current_lim = tcpm_get_current_limit(port); > > - if (port->slow_charger_loop || (current_lim > PD_P_SNK_STDBY_MW / 5)) > + if (port->slow_charger_loop && (current_lim > PD_P_SNK_STDBY_MW / 5)) > current_lim = PD_P_SNK_STDBY_MW / 5; > tcpm_set_current_limit(port, current_lim, 5000); > tcpm_set_charge(port, true); > -- > 2.31.1.607.g51e8a6a459-goog -- heikki