Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1908173pxb; Mon, 11 Oct 2021 16:08:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIqLuJc6BKRZmYJdgb5YKNVn2eI/KRVxT4v1cVJDzVZAPB5Uka1u4PZ4pGZqnjAegsmhtH X-Received: by 2002:a17:906:4d19:: with SMTP id r25mr29109030eju.264.1633993699186; Mon, 11 Oct 2021 16:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633993699; cv=none; d=google.com; s=arc-20160816; b=UOj7h4G1cfqinssZkcouLRfGeoj2YidWicdhrlDHRYh6WDmNhRwUaX/R2h11ZSpOtt JfY5/UFMZyWdpeQtw36Uqy81UlXuHGUq1jm41vvcbCmOgZ+Xt8M/o5QHs6a3q8lyBSCn V6JJ8QSa2HyOyHL3oONYSUso7hOM2U3EvYsm9OzZbIw7XboGt10lzFuOdFDzFJ4bC2QX 3MXBlvplgVeRRcDxHvzJXVbcN9ywdL3g7sxf7lcadHE3FJzicGWUheAboVqjdoGjNa7t B+SSgU0KvScBCRVBzKVmbMmuYlhTRKPgSzesNuuWBrBrhvAHBlbrtjJiZ3wtkquPDpZ8 rbPA== 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=R8fdhpqjIZc5EtaDg2AIHsp2JYrHU9qkmtFNONywXlw=; b=FK3E0p0UL7tkZzMyiAyIwrRs0FQ2Fe0NSBTnf1MG0LguqbNW1is68CWgIK+b3uJxlC kKo+dubkwFrVhQASwmjxddv2pIN7bcfp4rpL4s7EDkNyiQyD/okhpXBgWqZhssFTRlMJ DjRNCI1GxIO2xZr4nd1LMEtvd4LD5swa1FKERN9wS6FQ6DEpQq6BmeQdFSZsvz7PeiZ1 tkWWpEW6V0BFt1wxXLsrAtsp7c6mHjR4ARIilM/lU91YOn3xLBHXA+RmZdee9w8UDy/r XtqkvgeP3GaqnqAXK9cmnwcDBIRFnZx78nENodf4/vHRWp8vmFErs06csn5+GljuMeAf o0ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bcQYPbnP; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd16si12214212edb.501.2021.10.11.16.07.45; Mon, 11 Oct 2021 16:08:19 -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=@chromium.org header.s=google header.b=bcQYPbnP; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235620AbhJKXH3 (ORCPT + 99 others); Mon, 11 Oct 2021 19:07:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235569AbhJKXH2 (ORCPT ); Mon, 11 Oct 2021 19:07:28 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8C79C061570 for ; Mon, 11 Oct 2021 16:05:27 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id i1so16734634qtr.6 for ; Mon, 11 Oct 2021 16:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=R8fdhpqjIZc5EtaDg2AIHsp2JYrHU9qkmtFNONywXlw=; b=bcQYPbnPnO7DKhRn1ghmHgQGV1QnAk0vGUcGkFvX9uJml6DMK21V1u0BNUEloYjEr0 ErJ+bctjGQsZjeUZVjNhWrx5FrPRdNIn09wQz25g7oVj0l7J8RllwbG/UlTZ3Zp2hsqO hD3ESj1o1p6IZyaabEk1au8TGENnPAm3WtJ9w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=R8fdhpqjIZc5EtaDg2AIHsp2JYrHU9qkmtFNONywXlw=; b=uygyAKhDSWE0f6wuWdKWGc0l6SfpSVgiWUgaXVTsUtE+s/4IYSrkizdyZcLOmQLfSt VJkJqBGgKUZM2UEm7HSJdhADt3yVnT7Ru54ueW3AV6Ac/qj8RudPc1c/bmr7jtxS8onk 9ZFzmSEe1bKlU7Z1d7aMzUoLoB2Wh65m3dxM/N0HYuY62+Ux/ZjSgduTo0yXqTuILxcU HaS2v/3PQVK8LXN4Q036HsmU3stzdQTt4zEqKnkjxnAwhFDeoxpB7EDRq8Q1miv3x7M2 OVJeyP6aLDQz0d08gc3V5bwFCK4Lbsyqd3ew/Ejwnv6rrlXofb9UuX7nMqDDDhnakYNC Go2w== X-Gm-Message-State: AOAM5317JVf4mS8By0aJUGJoRyGcxSurl7Ot/WjpL7Chb07o4B6PeJdE hKPGk3zo74mfNN1L/lw1EEIGiwFFdOyNCFaRiZEDfA== X-Received: by 2002:ac8:4155:: with SMTP id e21mr18459684qtm.312.1633993526899; Mon, 11 Oct 2021 16:05:26 -0700 (PDT) MIME-Version: 1.0 References: <20210902213500.3795948-3-pmalani@chromium.org> In-Reply-To: From: Prashant Malani Date: Mon, 11 Oct 2021 16:05:15 -0700 Message-ID: Subject: Re: [RFC PATCH 2/3] power: supply: Add support for PDOs props To: Heikki Krogerus Cc: Adam Thomson , Benson Leung , "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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Heikki, On Fri, Oct 8, 2021 at 4:10 AM Heikki Krogerus wrote: > > On Thu, Oct 07, 2021 at 03:32:27PM -0700, Prashant Malani wrote: > > Hi folks, > > > > Thanks for the comments and discussion on this RFC series. > > > > On Fri, Sep 24, 2021 at 8:38 AM Adam Thomson > > wrote: > > > > > > On 21 September 2021 11:54, Heikki Krogerus wrote: > > > > > > > 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. > > > > > > Well part of the discussion has to be about the role that the user plays in > > > the control. What does and doesn't need to be controlled further up the stack, > > > and what will be taken care of by, for example, TCPM? Surely that dictates to > > > some degree what and how we expose all of this? Right now we have a simple means > > > to read and control voltages and currents through a PSY class, without the need > > > for the user to know any details of what a PDO/APDO is. Do we continue with > > > abstracting away to the user or instead let the user decipher this itself and > > > decide? Am just trying to understand the needs going forward. > > > > > > > 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. :-) > > > > > > That was my initial feeling on the suggestion based on the idea of a PSY per PDO > > > and I still don't feel that fits as your creating a whole class of resources > > > to expose something that's pretty small. To me the PSY represents the source as > > > whole, and the PDOs are simply options/configurations for that source. If we're > > > needing to expose PDOs then I don't disagree with separating them out > > > individually and I certainly wouldn't want that all concatenated as one > > > property. However I think something like dynamically generated properties > > > might be a nicer solution to expose each PDO, or even groups of properties if > > > you wanted to split PDOs even further into constituent parts to the user. > > > > To downscope this issue for the time being, one of our immediate goals > > is to expose the PDOs > > to userspace for metrics reporting and potentially for some power > > policy control through other > > channels (like Chrome OS Embedded Controller). > > > > Would it be acceptable to revise this series to drop the power supply > > support for now (since I don't yet > > see a consensus on how to implement it for the partner), and just add > > sysfs nodes for each PDO ? > > This would be akin to how it's being done for identity VDOs right now. > > > > So we would have : > > > > /sys/class/typec/-partner/source_pdos/pdo{1-13} > > > > and > > > > /sys/class/typec/-partner/sink_pdos/pdo{1-13} > > > > and similarly for the port device. > > > > If we want to add additional parsing of the Fixed Supply PDO into > > individual properties for the partner/port, > > those can of course be added later. > > > > WDYT? > > I don't think we should use sysfs to expose and control any of these > objects. It does not really matter under which subsystem we are > working. Sysfs is just the wrong interface for this kind of data. > > I'm now preparing a proof-of-concept patches where I create character > device for every USB PD capable device (port, plug and partner). The > idea is that we could use those char devices to tap into the USB PD > protocol directly. Right now I'm thinking the nodes would look like > this (with the first Type-C port): > > /dev/pd0/port > /dev/pd0/plug0 - you only get this node with full featured cables > /dev/pd0/plug1 - ditto > /dev/pd0/partner - and this is here only if you are connected > > So in this case you would use those char devices to send the actual > Get_Source_Cap and Get_Sink_Cap messages to get the PDOs. Interesting. Is this ABI going to need to be defined explicitly, or is the plan to just mimic the PD protocol messages as much as possible? I'm assuming the PDOs themselves will still need to be stored in the connector class port/partner data structures, right? > > The problem is that it's not going to be possible to always support > every type of command. For example with UCSI we are pretty much > limited to the capability control messages. But I still think this is > the right way to do this. > > Let me know what you think. Sounds good. I look forward to trying out your series when it's ready. Best regards, -Prashant