mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Daniel Balint <dbalint@google.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
	linux-hwmon@vger.kernel.org, Benson Leung <bleung@chromium.org>,
	Lee Jones <lee@kernel.org>, Tzung-Bi Shih <tzungbi@kernel.org>,
	linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev,
	mfd@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 0/3] Introduce cros_ec power monitoring
Date: Wed, 18 Nov 2026 22:00:33 +0000	[thread overview]
Message-ID: <20261118220033.70425495@jic23-hlaptop> (raw)
In-Reply-To: <20261118204532.257423-1-dbalint@google.com>

On Wed, 18 Nov 2026 20:45:32 +0000
Daniel Balint <dbalint@google.com> wrote:

> On Sat, 7 Nov 2026 01:03:56 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > Hi Daniel
> > 
> > I'm not necessarily against this but when adding monitoring components
> > to IIO the usual question is why not hwmon?  What features are not
> > well supported by that framework?
> > 
> > Note historically I suspect we accepted one or two drives into IIO that
> > would have fitted better there so precedence isn't a strong argument.
> > 
> > Convention for these somewhat borderline case is +CC hmwon maintainer
> > and list as well as IIO with that explanation in the cover letter.
> > That avoids any last minute surprises!  
> 
> Hi Jonathan,
> 
> Thanks for taking a look!
> The main reason for choosing IIO over hwmon is that for On-Device Power
> Monitoring, userspace needs an atomic, untorn snapshot across all rails
> (up to 64) over the same integration window, triggered on demand from
> userspace and read out in a single buffer read rather than repeated
> per-channel sysfs reads.
> 
> Reflecting that requirement, EC_PWRMON_LATCH on the EC is a global,
> stateful command: a single latch simultaneously snapshots all onboard
> power accumulators and resets their accumulation window on the EC, so
> individual channels cannot be latched independently. As far as I know,
> hwmon only exposes independent per-channel sysfs attributes with no
> multi-channel buffer or on-demand trigger ABI, whereas IIO's triggered
> buffer interface is well suited for this kind of pattern.

Ok, but that's not in the driver yet. I see you refer to that below
as a v2 thing, so not a problem.

Do you need that coherent snapshot to get to userspace in one go? 

For accumulator channels the way they are normally done to sysfs
style reads is to snapshot on each read, update an internal store
of accumulation since enable then provide whichever one was requested.
That way no data is lost - but you don't get an aligned snapshot.
So it depends on what maths you are going to do with them, whether
it can be done in kernel and if not how much interchannel skid
matters.

So tell us more on why you need that coherent snapshot to userspace.

I agree that if you do, then hwmon wouldn't currently be a good fit
(unless I'm also missing a way to do it).

> 
> CC'ing hwmon maintainer and list to keep me honest.
> 
> If there is no objection to adding the driver to IIO, I will clean up the
> custom energy_value attribute and replace it with the standard IIO
> triggered buffer interface in v2, along with addressing other review
> comments and including the above explanation in the v2 cover letter.
> 
> Thanks,
> Daniel


  reply	other threads:[~2026-11-18 22:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 19:31 Daniel Balint
2026-11-06 19:31 ` [PATCH v1 1/3] platform/chrome: cros_ec: fix alignment of ec_params_pwrmon Daniel Balint
2026-11-07 23:53   ` Benson Leung
2026-11-06 19:31 ` [PATCH v1 2/3] iio: adc: add cros_ec_pwrmon driver Daniel Balint
2026-11-07  1:25   ` Jonathan Cameron
2026-11-06 19:31 ` [PATCH v1 3/3] mfd: cros_ec: load cros_ec_pwrmon on supported ECs Daniel Balint
2026-11-18 19:48   ` Lee Jones
2026-11-07  1:03 ` [PATCH v1 0/3] Introduce cros_ec power monitoring Jonathan Cameron
2026-11-18 20:45   ` Daniel Balint
2026-11-18 22:00     ` Jonathan Cameron [this message]
2026-11-18 23:00     ` Guenter Roeck
2026-11-09  2:05 ` (subset) " Tzung-Bi Shih

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=20261118220033.70425495@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dbalint@google.com \
    --cc=lee@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mfd@lists.linux.dev \
    --cc=tzungbi@kernel.org \
    /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

all inboxes | Powered by JetHome®