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,
mwojtas@google.com
Subject: Re: [PATCH v1 0/3] Introduce cros_ec power monitoring
Date: Sun, 22 Nov 2026 20:56:48 +0000 [thread overview]
Message-ID: <20261122205648.73f3cf17@jic23-hlaptop> (raw)
In-Reply-To: <20261120091022.1459658-1-dbalint@google.com>
On Fri, 20 Nov 2026 09:10:22 +0000
Daniel Balint <dbalint@google.com> wrote:
> On Wed, 18 Nov 2026 22:00:33 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
>
> > 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.
>
> Sure, I can provide more context. Usecases are broad, but an example
> would be that we calculate per-rail drain contributions over short
> time windows for comparative analysis between device states (device state
> transitions like screen on/off trigger snapshot), or for debugging and
> power profiling purposes we correlate fine-grained ODPM data frames
> (~1s intervals) with other timestamped system diagnostics in our tracing
> tools (e.g. perform per-process-per-rail energy attribution), so math
> happens server side, and the relative energy deltas between channels
> within a frame are just as important to us as their absolute values.
> In general, data from a single channel makes sense in the context of
> other channels, there wouldn't be a client that requests only one
> channel.
>
> At higher userspace sampling frequencies, e.g. ~1s trigger intervals,
> which can happen in both abovementioned cases, interchannel skid becomes
> an issue if we read individually.
> Because the latching and data delivery (up to 64 MKBP events)
> roundtrip between EC and kernel takes non-trivial bus time that's in the
> ~10 ms range, latching per sysfs read across 64 files spreads channels
> across a hundreds of ms long interval, which would compromise coherency
> and render the data minimally useful. It would also make the EC
> unnecessarily busy with redundant work, so latching per channel read
> isn't really an option.
> But to Guenter's point, this could be solved by driver-side caching.
>
>
> On Wed, 18 Nov 2026 15:00:20 -0800
> Guenter Roeck <linux@roeck-us.net> wrote:
>
> > You could accomplish that the same way many hwmon drivers are doing it:
> > Read all attributes in one go from the hardware, then cache it for a period
> > of time.
>
> I should have mentioned the importance of timekeeping earlier. As we're
> correlating the snapshots with other diagnostic time-series data,
> userspace needs to know when accumulators were latched as accurately as
> possible.
> In contrast to IIO, in hwmon:
> (1) There is no timestamp ABI to propagate latch times, so userspace has
> to rely on its own timestamp when initiating a read.
> (2) There is no trigger ABI to force a fresh latch on demand (e.g. on a
> device state transition), so a userspace timestamp only marks the
> start of a sysfs read sweep rather than the actual hardware latch.
>
> So, unless I missed something, with a timeout-based cache in hwmon, a
> reader has no visibility into whether it's hitting newly latched or
> cached data or when the cache was actually latched (skewing time-series
> alignment) or whether the cache has expired mid-sweep across 64 sysfs
> reads.
>
> We could probably tune a short enough cache timeout where time skew
> would be negligible and mid-sweep expiries would still be infrequent,
> then it's a trade-off between accuracy and more mid-sweep expirations
> (more EC roundtrips). It could work, although we still would do 64
> sysfs reads instead of 1 on each trigger.
> So I guess it's not a must to send the coherent snapshot in one go, and
> I cannot provide any data to claim that hwmon would be a suboptimal
> solution to IIO, but our technical judgement is that IIO's explicit
> trigger, latch timestamp and single buffer read is a cleaner fit for
> power monitoring via the ChromeOS EC.
This is all good information. Capture a short version of it in cover
letter for v2 and include a link back to here for anyone wanting
the full gory details!
Jonathan
next prev parent reply other threads:[~2026-11-22 20:56 UTC|newest]
Thread overview: 14+ 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
2026-11-20 9:10 ` Daniel Balint
2026-11-22 20:56 ` 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=20261122205648.73f3cf17@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=mwojtas@google.com \
--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®