Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2612480pxb; Tue, 21 Sep 2021 03:58:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJDE1iIrhMHO+WfK6fylzsOmtdbK014r1h5rx5/rrj0c8hcqIg7i/LvVPBXFuCD+H3G66M X-Received: by 2002:a50:eac4:: with SMTP id u4mr34374577edp.259.1632221909262; Tue, 21 Sep 2021 03:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632221909; cv=none; d=google.com; s=arc-20160816; b=ZOAPLjoi2g4uN5RNQA9uUAWJF7WdLPposnBcFQg+SuzJ80LNzMvlilaHbg8GyAbRTf tdpr4x+nhPIsXMAHsvrigzlg5672jRYlIy0Wu75Sa2+fIV2Cu3Q3NcH7pVVVlm2MyBEY PUvDC4f0QIXqLsti0nOJTN2PGm3HAPOps/p68MDePd+1zXK7Oa0yp+HrWO0VlT2MMPKz +8DlahLlfDxhPZx8WO8c9v72JkvQFQKQhIhxjC42nL1UvTihOmnHzcTYkOEuvzDMH+6b YIH3D748lNCRwL8dU07sXeLrNtJ9vmX9o7W8MmNt4uNGp4SOCADFLffSngfpzB1nwyLf ELJQ== 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; bh=Is7kZvh8g6XMcD14rrcjbSb1yybl8vdu4jUSCp1yqCk=; b=ANH3s9QVToDkCC9EVT1Y0+8wvtfQpd8lzXyFuFKlW/dtj82DSBuSyKOFB2xZKmnp3l WGAq5ZynoGAg2l8V65jUVoTZPp63AqcDCoJwRnaxlEqgu979d0UKfnh3NnrTkn0tR8zR 1jEecMoRPEgbYN0e6NuBh7fxNs/aSDC8By6VRwF+JftoG1xephOQaEiSc9M5m1BPO3zr uh9K+PgL2yaFNHLTopDNUVw85zaFN2rHpz2VZaUKaG4jOi2Sht8iT188rtJFhO4Fd9Iw 5bLi2DgiE1PLgkkVJiX744HaJ2F2GpnBX/tsCzCOHW0SsZ712VM8B79KD4QRSsMD1/op jBig== 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 i16si12129361ejd.241.2021.09.21.03.58.05; Tue, 21 Sep 2021 03:58:29 -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 S232172AbhIUKzL (ORCPT + 99 others); Tue, 21 Sep 2021 06:55:11 -0400 Received: from mga12.intel.com ([192.55.52.136]:26569 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231969AbhIUKzK (ORCPT ); Tue, 21 Sep 2021 06:55:10 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10113"; a="202823384" X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="202823384" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2021 03:53:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="612931945" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 21 Sep 2021 03:53:38 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 21 Sep 2021 13:53:37 +0300 Date: Tue, 21 Sep 2021 13:53:37 +0300 From: Heikki Krogerus To: Adam Thomson Cc: Benson Leung , Prashant Malani , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-pm@vger.kernel.org" , "bleung@chromium.org" , "badhri@google.com" , Greg Kroah-Hartman , Sebastian Reichel , Guenter Roeck Subject: Re: [RFC PATCH 2/3] power: supply: Add support for PDOs props Message-ID: References: <20210902213500.3795948-1-pmalani@chromium.org> <20210902213500.3795948-3-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 02:12:23PM +0000, Adam Thomson wrote: > On 16 September 2021 11:23, Heikki Krogerus wrote: > > > > Thanks for providing the clarification. So you're proposing a port-psy and a > > > port-partner-psy that are connected to each other (one supplying the other). > > > If PD is not present, those two will exist per port and partner, and there > > > will be information about Type-C current (and possibly BC 1.2 and other > > > methods?) > > > > Yes, exactly. > > > > > Do you have an example hierarchy you could share that explains what it would > > > look like in /sys/class/power_supply with PD with Source Caps and Sink Caps on > > > both sides? > > > > I don't yet, but I'll prepare something. I did notice already that the > > power supply class does not seem to display the suppliers nor > > supplicants in sysfs. But we can always improve the class. > > > > I probable should not talk about "hierarchy". Maybe taking about > > simply "chain" of power supplies is more correct? > > > > > I think this all makes sense if the connector class is a read interface > > > for this info. Have you considered how the type-c connector class and this pd > > > psy support will handle dynamic PDO changes for advertisement FROM the > > ports? > > > > > > For example, let's say you wanted the kernel and user to manage two USB-C > > ports > > > with higher power support (meaning, 5V, 9V, 15V, 20V capable), but then your > > > kernel and user needs to edit the Source Caps on the fly based on load > > > balancing. > > > > > > If caps are represented as a group of psys together, how do you as a kernel > > > and user create an modify the set of Source_Caps you put out on a port? > > > > My idea is to utilise the "present" property with the ports. You would > > always display all the possible supplies, but only the ones that you > > expose in your current capabilities will be present. > > > > The idea is also that the ports are always supplied by normal power > > supplies of type "battery", "AC" and what have you. Those you can use > > to see the maximum power your port can get, and to determine the > > currently available power by checking the other ports that consume the > > same supply. Going back here a bit... It now looks like this second part is not possible, which sucks, but it only means registering a separate object (psy) for each PDO is even more important. > > So if you need more power for one port, you most likely will need to > > attempt to adjust the power levels of the source PDO power supplies of > > the other ports that share the base supply (like battery), or possibly > > disable them, and that way enable (make present) more source supplies > > for your port. That is the idea, but I admit I have not thought of > > everything, so I'm not completely sure would it work exactly like > > that, but the power balancing should in any case be possible with the > > chain of power supplies one way or the other. > > > > I hope I understood your question correctly, and I hope I was able to > > give you an answer :-) > > Thanks for the additional updates. So is the intention here to move control of > PDO selection away from TCPM, or add more flexibility to it? As I understand it > from previous efforts around all of this, the intention was that TCPM makes the > decision as to which PDO to select (and which APDO for PPS) based on the offered > capabilities of the source and the sink capabilities which are described in FW. > Am just trying to envisage the use-cases here and how the kernel/user is > involved in selecting PDOs/voltages/currents. If we can leave the decision about the selection to TCPM, that would be great! I'm not against that at all. As I said, I have not though through the control aspect. Right now I'm mostly concerned about how we expose the information to the user. The only reason why I have considered the control part at all is because how ever we decide to expose the information to the user, it has to work with control as well. > IIRC there used to be functions for updating source/sink capabilities but these > never had users and were subsequently removed. I guess this would be essentially > the functional replacement for those APIs? > > Personally, I think the idea of source/sink PSY instances supplying each other > seems reasonable. Right now we represent the external PD/Type-C supply (partner) > through TCPM as a PSY instance which is always present for the associated port, > although obviously when no source partner exists we're marked as offline. For > the partner side I'm guessing the PSY instance will be dynamically > created/destroyed? From previous experience PSY classes have tended to be > statically included so would be interested in seeing what this looks like in > reality. If there is anything that should be improved in the PSY class itself (and I'm sure there's plenty), then we improve it. > Am still unsure on using PSY to expose individual PDOs though and this still > feels quite heavyweight. I assume we're not wanting to expose everything in PDOs > really, just the voltage/current info? Feels like we should be able to do this > with individual properties which a user can be notified of changes to through > the normal prop notifier, rather than a collection of PSY class instances. > However, I'm happy to be convinced the other way so will await further > details. :) The final PSYs and the supply chains they create as well as the individual properties I'm more than happy to talk about, but having a separate object for the smallest thing that we can see (PDO) is the right thing to do here IMO. Trying to concatenate things into single objects especially in sysfs, despite how nice it always would seem, has taken me to the brink of disaster in the past far too many times. In this case we don't need to take the risk of having to duplicated information or in worst case deprecate something that is also exposed to the sysfs in the future. So the question is not why should we registers every individual PDO separately. The question is, why shouldn't we do that? And saying that it's "heavyweight" I'm afraid is not good enough. :-) Right now I simply don't see any other way that would be as flexible, or that could even handle all the different platforms in uniform way (this needs to work with TCPM, UCSI, and everything else), as registering separate object (psy) for every single PDO. thanks, -- heikki