platform/chrome: cros_ec_sensorhub: Increase MAX_DRIFT_PPM to 5000LL
Subsystems (2)
PATCH 1/1 platform/chrome: cros_ec_sensorhub: Increase MAX_DRIFT_PPM to 5000LL
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).
--- drivers/platform/chrome/cros_ec_sensorhub_ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec_sensorhub_ring.c +2 -2
@@ -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. */
Signature · 1 line
2.56.0.385.gd3acb90ef8-goog
Quoted 14 lines · Satyam Gupta
drivers/platform/chrome/cros_ec_sensorhub_ring.c +1
-1@@ -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. */
drivers/platform/chrome/cros_ec_sensorhub_ring.c cros_ec_sensor_ring_ts_filter_update(struct cros_ec_sensors_ts_filter_state · line 284
Quoted 8 lines
drivers/platform/chrome/cros_ec_sensorhub_ring.c +1
-1@@ -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. */
Applying: platform/chrome: cros_ec_sensorhub: Increase MAX_DRIFT_PPM to 5000LL
error: patch failed: drivers/platform/chrome/cros_ec_sensorhub_ring.c:22
error: drivers/platform/chrome/cros_ec_sensorhub_ring.c: patch does not apply
Until I realized this should apply after [1].
NACK, you should either form them a series or squash the fix into [1].