Chrome platform driver development
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: cros_ec_sensorhub: Increase MAX_DRIFT_PPM to 5000LL
@ 2026-10-13 10:58 Satyam Gupta
  2026-10-14  6:49 ` Tzung-Bi Shih
  0 siblings, 1 reply; 2+ messages in thread
From: Satyam Gupta @ 2026-10-13 10:58 UTC (permalink / raw)
  To: Benson Leung, Tzung-Bi Shih
  Cc: Guenter Roeck, Gwendal Grignou, Scott Collyer, chrome-platform,
	linux-kernel, Satyam Gupta

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-14  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 10:58 [PATCH] platform/chrome: cros_ec_sensorhub: Increase MAX_DRIFT_PPM to 5000LL Satyam Gupta
2026-10-14  6:49 ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox