Re: [PATCH v1 0/3] Introduce cros_ec power monitoring
From: Jonathan Cameron
Date: Wed Nov 18 2026 - 17:00:46 EST
On Wed, 18 Nov 2026 20:45:32 +0000
Daniel Balint <dbalint@xxxxxxxxxx> wrote:
> On Sat, 7 Nov 2026 01:03:56 +0000
> Jonathan Cameron <jic23@xxxxxxxxxx> 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