Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp916235pxf; Wed, 7 Apr 2021 15:00:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLwSIie5Dh2iWVCEm0gwyJYAtNcfLuhrAn84NKlLovJqjFFkymbNAcS/CltWpZssrrfo4E X-Received: by 2002:a63:74c:: with SMTP id 73mr5097026pgh.200.1617832833017; Wed, 07 Apr 2021 15:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617832833; cv=none; d=google.com; s=arc-20160816; b=f+/ha+/lXY6o0CH/+9pmwcB6WSvOMlx3QV3rbwVWS29TKjNjuRn7YCjrJd2eFrjGYt s1eaoqAUBb/6Ibsx5QvZbFPcI/+76u2Oo4R8gdLPXW1Yblu5jcVA2XCbCOvkUqoq7DLk IZEheskxDf4gPvLw+blRApDvveCCvqixZsoPs0HiEJy005cwi9obDBSrtw7PRQMDuyq4 3A+/oDHpTN/3ncdx/Y+3HSNOPp6oNe1vyP78DKAYNOAq4ITCOJN+uXG53km/swam9OsT 9452ELKS3yM7JagUJ+ToyYJWStsKIZTp77FbGRX2spL/u5/5m+FaVKuXYpeb2C4o5mA4 fgcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CuwA5DDBiBdqXrtVYclMzCLGSzTpOYNq7dYaDVgktOY=; b=sKSHlW27nP1JkcysfoxCED0KXdkFiuEAi4xQ6vaDfdcRzmvo9+xaC4hPdcmNJdL2g3 dpt1LEHEao5Xe+ONy54OtJ0xxoebPh41XgDVfopH3TC+m3zsoqEkh12+5vSeUX7xUjJX dVfmO86WfZ9VgHF6PUhMUSRNuDb9mhqO33sQda7RtDUH02oF19Q5Bnur0K2A6hBt+Pxy YoCBxVyb/lv3dd67c+yWNo6bA7zonRS7dMH874fc2gzZkOFb50FN1DMdXsO+1F20xHnG ALzLckfJf5A3stdTjt9POCGXfmPGApx01vJRcQtP/nVbDjsjqrmWr87omP86/c9qs78u dhbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ovf8IDen; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si19067743pls.194.2021.04.07.15.00.20; Wed, 07 Apr 2021 15:00:33 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Ovf8IDen; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355967AbhDGUOL (ORCPT + 99 others); Wed, 7 Apr 2021 16:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234182AbhDGUOK (ORCPT ); Wed, 7 Apr 2021 16:14:10 -0400 Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6740BC061760 for ; Wed, 7 Apr 2021 13:14:00 -0700 (PDT) Received: by mail-ua1-x936.google.com with SMTP id m16so1381195uaq.4 for ; Wed, 07 Apr 2021 13:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CuwA5DDBiBdqXrtVYclMzCLGSzTpOYNq7dYaDVgktOY=; b=Ovf8IDenzsH3TXNKitshzLy21hxzs3a2Zha0LJwXz6auHaFVk7uEae/EsR18I6d7u+ fQM13up6BoxFE8xgL0IT71FWVGvEKy6MWvtuZyNLaIE73VUL0tNvkS2vDhK0/yj6Myyf cHnh95EPFy1vlws5mLRItvq5Ri/uxn+YiPk+yBj5D3cH0hGJ11IlF2FfM/+2YVshMQV8 EOsFIl8gBLBmP0m9LDo6NcE/PfXyijlXEK21nonnSX1uBt7KDnrZ2sq4Taqigc1R7cvS EQXe8KTn4TwZ367zReSield7a2JddCxNi2WCt2hWp9EzNpFUw6tUDp4o9RSD+knUZAne 1I2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CuwA5DDBiBdqXrtVYclMzCLGSzTpOYNq7dYaDVgktOY=; b=UBtRVkTEfMlhZOTFU6iEtAoZdDvVZvGA9ZADd+gb2+Jl4YHRkMghadOCXq1nUIovrJ wfZiyxJnmOku1AjTRnuW2HpLq2zBTsTQTp6jMhXYCrTwS0+hBloWwpqxliN+/pKoGkI4 AKsiZtjlAPqmRs4UtFIQQwAYHGR8cov4bH5+4OXZQ/XB2qbF4bV/PQxYLyNkO2iJdRr1 2UqHkEUQj22KNbr+vCIWfGMnqBCb8jhkeA8sSe5CTD9H7thI96sVxQre1YKPtiC/jvZ2 qqiWwRYcT/+N6553oWiat6FFWS4V7iGFFa8jfuzVmRYlHcD6vUhly+g+lQblEwS3dycG mzUw== X-Gm-Message-State: AOAM533qHtTNJTHi+k8P6dysv9G6w1o7yEDT3Di3byEqtFmX6gux8E8y IOh9Z5ZpP3qFKJ2KqeDVfTPtD/qA4qyUUFhtAFcmCQ== X-Received: by 2002:ab0:2555:: with SMTP id l21mr3574800uan.65.1617826439264; Wed, 07 Apr 2021 13:13:59 -0700 (PDT) MIME-Version: 1.0 References: <20210406013643.3280369-1-badhri@google.com> <20210406013643.3280369-2-badhri@google.com> In-Reply-To: From: Badhri Jagan Sridharan Date: Wed, 7 Apr 2021 13:13:24 -0700 Message-ID: Subject: Re: [PATCH v1 1/6] usb: typec: tcpm: Address incorrect values of tcpm psy for fixed supply To: Adam Thomson Cc: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Rob Herring , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , Kyle Tso Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter and Adam, Thanks for the reviews ! Fixed up the typo in V2. Thanks, Badhri On Wed, Apr 7, 2021 at 9:04 AM Adam Thomson wrote: > > On 06 April 2021 02:37, Badhri Jagan Sridharan wrote: > > > tcpm_pd_build_request overwrites current_limit and supply_voltage > > even before port partner accepts the requests. This leaves stale > > values in current_limit and supply_voltage that get exported by > > "tcpm-source-psy-". Solving this problem by caching the request > > values of current limit/supply voltage in req_current_limit > > and req_supply_voltage. current_limit/supply_voltage gets updated > > once the port partner accepts the request. > > > > Fixes: f2a8aa053c176 ("typec: tcpm: Represent source supply through > > power_supply") > > Signed-off-by: Badhri Jagan Sridharan > > --- > > Looks sensible, typo aside: > > Reviewed-by: Adam Thomson > > > drivers/usb/typec/tcpm/tcpm.c | 17 ++++++++++------- > > 1 file changed, 10 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > > index ca1fc77697fc..03eca5061132 100644 > > --- a/drivers/usb/typec/tcpm/tcpm.c > > +++ b/drivers/usb/typec/tcpm/tcpm.c > > @@ -389,7 +389,10 @@ struct tcpm_port { > > unsigned int operating_snk_mw; > > bool update_sink_caps; > > > > - /* Requested current / voltage */ > > + /* Requested current / voltage to the port partner */ > > + u32 req_current_limit; > > + u32 req_supply_voltage; > > + /* Acutal current / voltage limit of the local port */ > > u32 current_limit; > > u32 supply_voltage; > > > > @@ -2435,8 +2438,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port > > *port, > > case SNK_TRANSITION_SINK: > > if (port->vbus_present) { > > tcpm_set_current_limit(port, > > - port->current_limit, > > - port->supply_voltage); > > + port->req_current_limit, > > + port->req_supply_voltage); > > port->explicit_contract = true; > > tcpm_set_auto_vbus_discharge_threshold(port, > > > > TYPEC_PWR_MODE_PD, > > @@ -2545,8 +2548,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port > > *port, > > break; > > case SNK_NEGOTIATE_PPS_CAPABILITIES: > > port->pps_data.active = true; > > - port->supply_voltage = port->pps_data.out_volt; > > - port->current_limit = port->pps_data.op_curr; > > + port->req_supply_voltage = port->pps_data.out_volt; > > + port->req_current_limit = port->pps_data.op_curr; > > tcpm_set_state(port, SNK_TRANSITION_SINK, 0); > > break; > > case SOFT_RESET_SEND: > > @@ -3195,8 +3198,8 @@ static int tcpm_pd_build_request(struct tcpm_port > > *port, u32 *rdo) > > flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); > > } > > > > - port->current_limit = ma; > > - port->supply_voltage = mv; > > + port->req_current_limit = ma; > > + port->req_supply_voltage = mv; > > > > return 0; > > } > > -- > > 2.31.0.208.g409f899ff0-goog >