Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp872553pxf; Thu, 18 Mar 2021 13:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMljcwIA0sD3sN7XNVVLGuEsR84tHFLc6EYKE2EFYoERJkVqyKMHkRJgbfGAs8xWzWuVnq X-Received: by 2002:a05:6402:110b:: with SMTP id u11mr6127725edv.356.1616100141908; Thu, 18 Mar 2021 13:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616100141; cv=none; d=google.com; s=arc-20160816; b=EqgPBwJpSmWcwktYqjKH4+f0PlYcyLAvePw9digdQJLWIqGRJC3XSwSAJPGaF9LM6s OPVqyrY0vpgE/pH8OmtN8eNsCMTPcHTEK+GjnpyWORFDDNs7/2Yd+CoLu0xAxULtyEei snySkQwKgakoU8WQpWVZUT5HhLsIELYv0Qjq+5MO3kFtUCr9ogblhM0l+IxqHQJhdvxa f1qaC3KZc7P69oRK6MJnViKmOCpJSJ5zFybJyA4kNVM+lqDo4L+m/yURTLY0TTTy0DTl MPGarZPXcPqDhwFhkb5PRlPr8GRLdHKdIJVPrRvfcRxhlEVUmqD0Qw9wT3tuvjMbGd8w nbjA== 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=xol55/9H4SiYpqW9PDFqK2rSIMyEWIaJbvYIxkmuGOA=; b=TO+4O1XvhBV4NQU4YAsIOCuNN3KiiYUtOpqINhjve1cbLvuLwul030KM6QdJEMt+DA aDvojBwZsBecDeCHwjgD56dhcxm8mqJW/HMUlS/6n72zALjAphQlvXLEK7k0+OPtySUe PTNzezlBzb7gb2vkj3dOhPxq9xchwSIykQayyEOnD/otvIFo3cAPcBsCH1KvoA7uFcx+ 3NxjvuAnrYcaMoKTjXFIRulr1hMWLc73bQfVByZA6yk76prcBv8vhAlg6u/DwYyYlHIj z5rzVODcF9xHWgnNG/h3T3vXjbGM+6mEGhCBQirJA1JPY7yor7okmrvD7YCi67+hYRdZ p2YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=D1ja9+Cs; 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 d17si2542172edj.284.2021.03.18.13.41.59; Thu, 18 Mar 2021 13:42:21 -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=D1ja9+Cs; 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 S231137AbhCRUlB (ORCPT + 99 others); Thu, 18 Mar 2021 16:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbhCRUkp (ORCPT ); Thu, 18 Mar 2021 16:40:45 -0400 Received: from mail-vk1-xa30.google.com (mail-vk1-xa30.google.com [IPv6:2607:f8b0:4864:20::a30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07DA8C06175F for ; Thu, 18 Mar 2021 13:40:44 -0700 (PDT) Received: by mail-vk1-xa30.google.com with SMTP id u144so1606740vkb.13 for ; Thu, 18 Mar 2021 13:40:44 -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=xol55/9H4SiYpqW9PDFqK2rSIMyEWIaJbvYIxkmuGOA=; b=D1ja9+Cs7QVmfxGC2t4MBWS4rYjTTsocGFOGexTP0gi+5M1B8TFSVQYS/Mr+tWfIJ1 /qPtxE3EdhkgArFi8zW5u9kGkJijPDuS5AnlhlhkjXcr0YItpI5bX4jQ7gluT8JkiZsI N9Tq9o5+Szipn+eGj7vv2Q4hbfzsP5AYjH0qBDOhPOsq5heHR6JGkHQxpT9PDfd6KcrW z5mswn4Yc4rB/0i48ZdNeomjdXzBJ7C/xjxkj6R6EVs392CG5PB9E/I0F3ySq3ow8ikF x0pn6B1ZQJnXWeRmm3V7Q47+XX2V1LK69/DSaSJstWTbsx7JkvpxggDC0GJQcedjnD2w 6DxQ== 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=xol55/9H4SiYpqW9PDFqK2rSIMyEWIaJbvYIxkmuGOA=; b=iQg+yINYpDH+XsTA1QshBYJ+Y4Gr/K8im6MpQcuSU6S3Tr2SWL89oIhTZm18Zhw5Ds jv0m71GOZMUOG2O+LGiZZ+kXhIHvHM/RFUcUUkaFLcwAz5GSyIgcSlMMlthfBWh0G/4m jY6e1VMJmFJ1KvK9sW3fLjETfhJbH9GEzIDqd09FCKznL1d5n4/VIcyJGQYwMdG4SbdW CWJDWKx2TRZzMI+YDtNL3+gPTwhkLkzNQHOjn1dhkLh/GEIy2RZtZqmXbhiwA8dCeNLj X8V8ct6L2fA/djD47RuQJY1XIIf4UIonWNWVcR8Pji9jAP/z75zvCgWDxocIUN0YqzIO Ygnw== X-Gm-Message-State: AOAM5312F1qu/1M7B4XFz9I9Qy21Kra+77rNR+qm2Ud+0TxkLtgla10I FOWrlZLhJlmEwH4gSEwRQksrPB3xmABqSG88w+AYSw== X-Received: by 2002:a1f:a5d7:: with SMTP id o206mr966897vke.22.1616100041505; Thu, 18 Mar 2021 13:40:41 -0700 (PDT) MIME-Version: 1.0 References: <20210317181249.1062995-1-badhri@google.com> In-Reply-To: From: Badhri Jagan Sridharan Date: Thu, 18 Mar 2021 13:40:05 -0700 Message-ID: Subject: Re: [PATCH v2] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- To: Adam Thomson Cc: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 18, 2021 at 8:26 AM Adam Thomson wrote: > > On 17 March 2021 18:13, Badhri Jagan Sridharan wrote: > > > tcpm-source-psy- does not invoke power_supply_changed API when > > one of the published power supply properties is changed. > > power_supply_changed needs to be called to notify > > userspace clients(uevents) and kernel clients. > > > > Fixes: f2a8aa053c176("typec: tcpm: Represent source supply through > > power_supply") > > Signed-off-by: Badhri Jagan Sridharan > > Reviewed-by: Guenter Roeck > > Reviewed-by: Heikki Krogerus > > --- > > Changes since V1: > > - Fixed commit message as per Guenter's suggestion > > - Added Reviewed-by tags > > - cc'ed stable > > --- > > drivers/usb/typec/tcpm/tcpm.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > > index 11d0c40bc47d..e8936ea17f80 100644 > > --- a/drivers/usb/typec/tcpm/tcpm.c > > +++ b/drivers/usb/typec/tcpm/tcpm.c > > @@ -945,6 +945,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, > > u32 max_ma, u32 mv) > > > > port->supply_voltage = mv; > > port->current_limit = max_ma; > > + power_supply_changed(port->psy); > > > > if (port->tcpc->set_current_limit) > > ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv); > > @@ -2931,6 +2932,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, > > int *sink_pdo, > > > > port->pps_data.supported = false; > > port->usb_type = POWER_SUPPLY_USB_TYPE_PD; > > + power_supply_changed(port->psy); > > > > /* > > * Select the source PDO providing the most power which has a > > @@ -2955,6 +2957,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, > > int *sink_pdo, > > port->pps_data.supported = true; > > port->usb_type = > > POWER_SUPPLY_USB_TYPE_PD_PPS; > > + power_supply_changed(port->psy); > > } > > continue; > > default: > > @@ -3112,6 +3115,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct > > tcpm_port *port) > > port->pps_data.out_volt)); > > port->pps_data.op_curr = min(port->pps_data.max_curr, > > port->pps_data.op_curr); > > + power_supply_changed(port->psy); > > } > > > > return src_pdo; > > Regarding selecting PDOs or PPS APDOs, surely we should only notify of a change > when we reach SNK_READY which means a new contract has been established? Until > that point it's possible any requested change could be rejected so why inform > clients before we know the settings have taken effect? I could be missing > something here as it's been a little while since I delved into this, but this > doesn't seem to make sense to me. I was trying to keep the power_supply_changed call close to the variables which are used to infer the power supply property values. Since port->pps_data.max_curr is already updated here and that's used to infer the CURRENT_MAX a client could still read this before the request goes through right ? > > > @@ -3347,6 +3351,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool > > charge) > > return ret; > > } > > port->vbus_charge = charge; > > + power_supply_changed(port->psy); > > return 0; > > } > > > > @@ -3530,6 +3535,7 @@ static void tcpm_reset_port(struct tcpm_port *port) > > port->try_src_count = 0; > > port->try_snk_count = 0; > > port->usb_type = POWER_SUPPLY_USB_TYPE_C; > > + power_supply_changed(port->psy); > > This is already taken care of at the end of this function, isn't it? I thought I deleted that. Looks like I didn't. Will send in a patch to remove that. Will wait for what we decide for the PPS case so that I can send in both in the same patch. Thanks, Badhri > > > port->nr_sink_caps = 0; > > port->sink_cap_done = false; > > if (port->tcpc->enable_frs) > > @@ -5957,7 +5963,7 @@ static int tcpm_psy_set_prop(struct power_supply > > *psy, > > ret = -EINVAL; > > break; > > } > > - > > + power_supply_changed(port->psy); > > return ret; > > } > > > > @@ -6110,6 +6116,7 @@ struct tcpm_port *tcpm_register_port(struct device > > *dev, struct tcpc_dev *tcpc) > > err = devm_tcpm_psy_register(port); > > if (err) > > goto out_role_sw_put; > > + power_supply_changed(port->psy); > > > > port->typec_port = typec_register_port(port->dev, &port->typec_caps); > > if (IS_ERR(port->typec_port)) { > > -- > > 2.31.0.rc2.261.g7f71774620-goog >