Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp540643pxb; Tue, 14 Sep 2021 03:29:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+39qQBQqnGcNlqF1+AOE/eauD9xjRbwTzo6Txptl6vY/SShQnh3bEpyDFnfCrSFkTqAfK X-Received: by 2002:a6b:611a:: with SMTP id v26mr13241783iob.93.1631615392301; Tue, 14 Sep 2021 03:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631615392; cv=none; d=google.com; s=arc-20160816; b=p+lDxxbIyBAGiaDiBAPy1nPAJEC2QEuJRHkZORXZmELcuPaKHDR8IDlLbAlqOSkSa5 7IECbUdp/DCKiqLy1zAk48+WewLCYf7C+UiYxoBgu3zeLi1DPafCmR7OL4wBnWAUNAib 6TFctufimMNNxse3Yj0jrjo1UUQCDR7K2OdLhnUTeR4MQLlTyLTqwvAHZuw9KHSLG6gn YSfN/KuKHn+5K9kfDUvFExQbJQwh1qdmlaUw1BMklQjkpJG2MIEz2L+kOtiXy3oEQ+R8 l1eog+eCZk++YGyERVMX7pkMeVdxogdMTqtxfCn97g/3FBWEQrQbG9DTCUk2nAWKXdw4 XP6Q== 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=CxoCDdv/9lb+onGinibc19DX8vJzEhrD2RkEFutU1Xs=; b=Yf7Pwp1r4anPEe5WDv1BneC0A3bFKvEhTX3NtQYUTPjCB8rMOQ0b8hnJFTyD4sslKL +ZLttadN0MaPVBAGh5Fr/IzUsE3bx7zn4pesnvEQqtxPHFSPMWTVI/iEqVIiIg9bgHL8 RlRSPyphYbeHMRqPITrasR3+Sdeu4AWiDQJl+CEI7d4L9ZEnujp8NSp/uXqGbSx41vI1 OKLe4d+zC91EWG4ZzLp3+5FWN6Z5uZgpSWEPj/8QtZ/ZUDee8UQs2+oNGdhIP+Mrla7L YTylMYr2s287XGjM9ygfZMwQrxkdqfD1ibC7k7TnHOv+9KsxpUdexuLBfVPeYhjmuwp1 jFGw== 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 m1si8624293jaa.128.2021.09.14.03.29.39; Tue, 14 Sep 2021 03:29:52 -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 S231612AbhINKaP (ORCPT + 99 others); Tue, 14 Sep 2021 06:30:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:52961 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbhINKaN (ORCPT ); Tue, 14 Sep 2021 06:30:13 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10106"; a="307502397" X-IronPort-AV: E=Sophos;i="5.85,292,1624345200"; d="scan'208";a="307502397" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2021 03:28:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,292,1624345200"; d="scan'208";a="609558479" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 14 Sep 2021 03:28:50 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 14 Sep 2021 13:28:49 +0300 Date: Tue, 14 Sep 2021 13:28:49 +0300 From: Heikki Krogerus To: Benson Leung Cc: Adam Thomson , 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 Mon, Sep 13, 2021 at 12:30:58PM -0700, Benson Leung kirjoitti: > Hi Adam and Heikki, > > On Mon, Sep 13, 2021 at 03:15:46PM +0000, Adam Thomson wrote: > > On 13 September 2021 14:30, Heikki Krogerus wrote: > > > > > > My plan is to register a separate power supply for each PDO. So for > > > every source PDO and every sink PDO a port has in its capabilities, > > > you'll have a separate power supply registered, and the same for the > > > partner when it's connected. With every connection there should always > > > be one active (online) source psy and active sink psy (if the port is > > > source, one of the port's source psys will be active and the partner > > > will have the active sink psy, or vise versa - depending on the role). > > > > > > Each PDO represents a "Power Supply" so to me that approach just > > > makes the most sense. It will require a bit of work in kernel, however > > > in user space it should mean that we only have a single new attribute > > > file for the power supplies named "pdo" that returns a single PDO. > > > > > > Let me know if you guys see any obvious problems with the idea. > > > Otherwise, that is how we really need to do this. That will make > > > things much more clear in user space. I have a feeling it will make > > > things easier in kernel as well in the long run. > > > > > > Adding Adam and Guenter. It would be good if you guys could comment > > > the idea as well. > > > > Hi Heikki, > > > > Thanks for CCing me. My two pence worth is that I always envisaged the PSY > > representation as being 1 PSY for 1 power source. I consider this in a > > similar manner to the Regulator framework, where 1 regulator can support a range > > of voltages and currents, but this is covered by 1 regulator instance as it's > > just a single output. For USB-PD we have a number of options for voltage/current > > combos, including PPS which is even lower granularity, but it's still only one > > port. I get the feeling that having PSY instances for each and every PDO might > > be a little confusing and these will never be concurrent. > > > > However, I'd be keen to understand further and see what restrictions/issues are > > currently present as I probably don't have a complete view of this right now. I > > wouldn't want to dismiss something out of turn, especially when you obviously > > have good reason to suggest such an approach. > > I thought of one more potential downside to one-psy-per-pdo: > > Remember that a source or sink's Capabilities may dynamically change without > a port disconnect, and this could make one-psy-per-pdo much more chatty with > power supply deletions and re-registrations on load balancing events. > > At basically any time, a power source may send a new SRC_CAP to the sink which > adjusts, deletes, or adds to the list of PDOs, without the connection state > machine registering a disconnect. > > In a real world case, I have a charger in my kitchen that has 2 USB-C ports > and supports a total of 30W output. When one device is plugged in: > 5V 3A, 9V 3A, 15V 2A > However, when two devices are plugged in, each sees: > 5V 3A > > The load balancing event would result in two power supply deletions, whereas > if it were a single psy per power supply (incorporating the list of PDO choices) > it would just be a single PROP_CHANGED event. > > It seems cleaner to me to have deletions and additions only possible when the > thing is unplugged or plugged. I just argued to Adam that because the capabilities can change in reality at any time, just like you pointed out here, using a psy hierarchy instead of trying to handle everything with a single psy is not only more clear, it's actually safer, and definitely less "hacky" approach. I don't really see why would it be a problem to unregister and register the psys in the hierarchy be a problem? thanks, -- heikki