From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Tomasz Figa <tfiga@chromium.org>
Cc: Benson Leung <bleung@chromium.org>,
Bryam Vargas <hexlabsecurity@proton.me>,
chrome-platform@lists.linux.dev, suleiman@chromium.org
Subject: Re: [PATCH v2] platform/chrome: sensorhub: Fix dropped timestamp events and log spam
Date: Wed, 15 Jul 2026 09:28:21 +0000 [thread overview]
Message-ID: <aldStRgbO_1ZhScD@google.com> (raw)
In-Reply-To: <CAAFQd5D5C+TSro3Up3rU-wAmbEnQ0+Vkj6wNCDZUZvcnCNG2aA@mail.gmail.com>
On Wed, Jul 15, 2026 at 04:15:22PM +0900, Tomasz Figa wrote:
> On Wed, Jul 15, 2026 at 11:45 AM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
> >
> > Commit 833740a2333c ("platform/chrome: sensorhub: Bound the EC-reported
> > sensor number") evaluated the `sensor_num` against the bounds limit even
> > for timestamp events. A timestamp event typically has a `sensor_num` of
> > 0xff [1], causing the driver to flag it as invalid and skip to the next
> > event.
> >
> > As a result, we'd see a flooding of "Invalid sensor number 255 from EC"
> > warning logs and these timestamp events were being dropped.
> >
> > Move the bounds-check into cros_ec_sensor_ring_process_event() and
> > evaluate it only after standalone timestamp events have already been
> > processed and returned early.
> >
> > [1] https://crrev.com/219ca6ef82ba266da788b673ee4ad50bd3ea1285/common/motion_sense_fifo.c#427
> >
> > Fixes: 833740a2333c ("platform/chrome: sensorhub: Bound the EC-reported sensor number")
> > Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
> > ---
> > Bryam: sorry for reverting the decision (moving back the check to
> > cros_ec_sensor_ring_process_event()). I realized we need to prevent
> > dropping timestamp events and flooding the logs.
> > ---
> > v2:
> > - Move the check to cros_ec_sensor_ring_process_event().
> > - Return earlier for standalone timestamp events.
> >
> > v1: https://lore.kernel.org/all/20260714065202.3248017-1-tzungbi@kernel.org
> > ---
> > .../platform/chrome/cros_ec_sensorhub_ring.c | 27 ++++++++++---------
> > 1 file changed, 15 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
> > index 92941924c347..d92b60213720 100644
> > --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
> > +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
> > @@ -475,6 +475,21 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
> > fifo_timestamp,
> > *current_timestamp,
> > now);
> > +
> > + /*
> > + * A standalone timestamp event typically has a sensor_num of
> > + * 0xff. Return early here to prevent it from hitting the
> > + * bounds check below and spamming the logs.
> > + */
> > + return false;
> > + }
> > +
> > + /* Skip event if sensor_num from EC is out of bounds. */
> > + if (in->sensor_num >= sensorhub->sensor_num) {
> > + dev_warn_ratelimited(sensorhub->dev,
> > + "Invalid sensor number %u from EC\n",
> > + in->sensor_num);
> > + return false;
> > }
> >
> > if (in->flags & MOTIONSENSE_SENSOR_FLAG_ODR) {
> > @@ -502,10 +517,6 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
> > return true;
> > }
> >
> > - if (in->flags & MOTIONSENSE_SENSOR_FLAG_TIMESTAMP)
> > - /* If we just have a timestamp, skip this entry. */
> > - return false;
> > -
>
> Isn't this still needed for the case of
> MOTIONSENSE_SENSOR_FLAG_TIMESTAMP and (MOTIONSENSE_SENSOR_FLAG_ODR
> and/or MOTIONSENSE_SENSOR_FLAG_FLUSH)?
The block serves for standalone MOTIONSENSE_SENSOR_FLAG_TIMESTAMP events.
If the flags contains ODR or FLUSH, it returns in other branches.
After applying the patch, the flow of cros_ec_sensor_ring_process_event()
looks like:
If TIMESTAMP but (!ODR and !FLUSH):
...
return <--- The patch merges the block and returns early.
Check bounds for sensor_num
If ODR:
...
return
If FLUSH:
...
return
next prev parent reply other threads:[~2026-07-15 9:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 2:44 [PATCH v2] platform/chrome: sensorhub: Fix dropped timestamp events and log spam Tzung-Bi Shih
2026-07-15 7:15 ` Tomasz Figa
2026-07-15 9:28 ` Tzung-Bi Shih [this message]
2026-07-15 9:30 ` Tomasz Figa
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=aldStRgbO_1ZhScD@google.com \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=hexlabsecurity@proton.me \
--cc=suleiman@chromium.org \
--cc=tfiga@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.