From: Satyam Gupta <sgsatyam@google.com>
To: Benson Leung <bleung@chromium.org>, Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Guenter Roeck <groeck@chromium.org>,
Gwendal Grignou <gwendal@chromium.org>,
Scott Collyer <scollyer@google.com>,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
Satyam Gupta <sgsatyam@google.com>
Subject: [PATCH] platform/chrome: cros_ec_sensorhub: Increase MAX_DRIFT_PPM to 5000LL
Date: Tue, 13 Oct 2026 10:58:06 +0000 [thread overview]
Message-ID: <20261013105806.1371175-1-sgsatyam@google.com> (raw)
MAX_DRIFT_PPM was introduced to prevent large swings in frequency drift
estimation (such as batched mode interrupt jitter exceeding 20,000 Parts
Per Million (PPM)) from corrupting the median filter and causing Out Of
Order (OOO) sensor events.
The initial limit of 200 PPM was chosen based on platforms where sensors
are connected to an Integrated Sensor Hub (ISH) running on clocks derived
from the same PLL as the CPU. However, on platforms where sensors are
connected to a standalone Embedded Controller (EC) running on its own
independent crystal/PLL, the actual clock frequency drift between the EC
and AP can be around 2,500 PPM. Clamping at 200 PPM is too strict for
these configurations and causes an accumulating offset error that
triggers sample drops and timestamp synchronization failures.
Increase MAX_DRIFT_PPM from 200LL to 5000LL so the filter can track
expected clock drift across both ISH and standalone EC configurations,
while still rejecting large interrupt jitter spikes and bounding the
worst-case cumulative batch error (~2.1 ms, well within the fastest 5 ms
sample period).
Signed-off-by: Satyam Gupta <sgsatyam@google.com>
---
drivers/platform/chrome/cros_ec_sensorhub_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
index 20fa47cbee32..a5215955470f 100644
--- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
@@ -22,7 +22,7 @@
/* Precision of fixed point for the m values from the filter */
#define M_PRECISION BIT(23)
-#define MAX_DRIFT_PPM 200LL
+#define MAX_DRIFT_PPM 5000LL
#define MAX_M ((s64)(MAX_DRIFT_PPM * M_PRECISION / 1000000))
/* Only activate the filter once we have at least this many elements. */
@@ -278,7 +278,7 @@ cros_ec_sensor_ring_ts_filter_update(struct cros_ec_sensors_ts_filter_state
dy = (state->y_history[0] + state->y_offset) - y;
m = div64_s64(dy * M_PRECISION, dx);
/*
- * Clamp the calculated slope to a realistic range (+/- 200 ppm).
+ * Clamp the calculated slope to a realistic range (+/- 5000 ppm).
* Temporary large jitter spikes can produce huge slopes (e.g. +/- 20000 ppm)
* that would otherwise corrupt the median filter history.
*/
--
2.56.0.385.gd3acb90ef8-goog
next reply other threads:[~2026-10-13 10:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 10:58 Satyam Gupta [this message]
2026-10-14 6:49 ` 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=20261013105806.1371175-1-sgsatyam@google.com \
--to=sgsatyam@google.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=gwendal@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=scollyer@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®