From: Guenter Roeck <linux@roeck-us.net>
To: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: jdelvare@suse.com, corbet@lwn.net, afd@ti.com,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH 1/2] hwmon: ina3221: Add power sysfs nodes
Date: Wed, 26 Sep 2018 12:45:34 -0700 [thread overview]
Message-ID: <20180926194534.GB18731@roeck-us.net> (raw)
In-Reply-To: <20180926182006.GB6329@Asurada-Nvidia.nvidia.com>
Hi Nicolin,
On Wed, Sep 26, 2018 at 11:20:06AM -0700, Nicolin Chen wrote:
> On Wed, Sep 26, 2018 at 05:34:53AM -0700, Guenter Roeck wrote:
> > Hi Nicolin,
> >
> > On 09/25/2018 11:42 PM, Nicolin Chen wrote:
> > > The hwmon sysfs ABI supports powerX_input and powerX_crit. This
> > > can ease user space programs who care more about power in total
> > > than voltage or current individually.
> > >
> > > So this patch adds these two sysfs nodes for INA3221 driver.
>
> > Ah, sorry, we can't do that. The sysfs nodes are for chips providing power
> > registers, not for kernel drivers to provide calculations based on voltage
> > and current measurements.
>
> Hmm..I saw ina2xx.c and ltc4215.c are doing similar calculations...
>
ina2xx.c doesn't; the chips supported by the driver do have a register
reporting the power (0x03). ltc4215.c was not reviewed by a hwmon
maintainer. I think I mentioned before that you can find anything you want
in the Linux kernel. That doesn't make it right.
> > Basic guideline is that we report what is there, not some calculation based
> > on it.
>
> I could feel the back thoughts behind the guideline, but this does
> give user space programs some trouble -- I have a few programs that
> were used to read ina2xx driver which provides power nodes, but now
> those programs will have to implement another function to read the
> voltage and current separately to do further calculations.
>
> Do you know any better solution for this situation?
>
Userspace simply must not assume that power attributes exist and calculate
it from voltage and current attributes if needed.
> > This is even more true for power limits: We can not assume that the power limit
> > is (max voltage * max current). or (current voltage * max_current), or anything
> > else. We simply don't have the knowledge to make that assumption.
>
> I agree that power limit is a bit tricky here as the voltage could
> change depending on the user space, Yes, I assumed that users who
> set_power() should be aware of it (whether fixed or dynamical) so
> as to decide to configure power limit or just current limit.
>
You just can not make any such assumptions, sorry. Limit attributes
absolutely must be reflected in hardware.
Thanks,
Guenter
next prev parent reply other threads:[~2018-09-26 19:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-26 6:42 [PATCH 0/2] hwmon: ina3221: Add power and enable sysfs nodes Nicolin Chen
2018-09-26 6:42 ` [PATCH 1/2] hwmon: ina3221: Add power " Nicolin Chen
2018-09-26 12:34 ` Guenter Roeck
2018-09-26 18:20 ` Nicolin Chen
2018-09-26 19:45 ` Guenter Roeck [this message]
2018-09-26 19:49 ` Nicolin Chen
2018-09-26 6:42 ` [PATCH 2/2] hwmon: ina3221: Add enable " Nicolin Chen
2018-09-26 13:06 ` Guenter Roeck
2018-09-26 18:02 ` Nicolin Chen
2018-09-26 19:58 ` Guenter Roeck
2018-09-26 20:25 ` Nicolin Chen
2018-09-26 20:44 ` Guenter Roeck
2018-09-26 21:55 ` Nicolin Chen
2018-09-27 16:05 ` Guenter Roeck
2018-09-27 18:39 ` Nicolin Chen
2018-09-27 22:26 ` Nicolin Chen
2018-09-27 22:52 ` Guenter Roeck
2018-09-27 23:14 ` Nicolin Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180926194534.GB18731@roeck-us.net \
--to=linux@roeck-us.net \
--cc=afd@ti.com \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicoleotsuka@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).