linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform: chrome: Fix EC timestamp overflow
@ 2020-06-30  7:52 Gwendal Grignou
  2020-07-01  9:11 ` Enric Balletbo i Serra
  0 siblings, 1 reply; 2+ messages in thread
From: Gwendal Grignou @ 2020-06-30  7:52 UTC (permalink / raw)
  To: bleung, enric.balletbo, bhanumaiya; +Cc: groeck, linux-kernel, Gwendal Grignou

EC is using 32 bit timestamps (us), and before converting it to 64bit
they were not casted, so it would overflow every 4s.
Regular overflow every ~70 minutes was not taken into acoun either.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 drivers/platform/chrome/cros_ec_sensorhub_ring.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
index 23960f3acc0b1..641d91088cee2 100644
--- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
@@ -465,9 +465,7 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
 			 * Disable filtering since we might add more jitter
 			 * if b is in a random point in time.
 			 */
-			new_timestamp = fifo_timestamp -
-					fifo_info->timestamp  * 1000 +
-					in->timestamp * 1000;
+			new_timestamp = c - b * 1000 + a * 1000;
 			/*
 			 * The timestamp can be stale if we had to use the fifo
 			 * info timestamp.
-- 
2.27.0.212.ge8ba1cc988-goog


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

* Re: [PATCH] platform: chrome: Fix EC timestamp overflow
  2020-06-30  7:52 [PATCH] platform: chrome: Fix EC timestamp overflow Gwendal Grignou
@ 2020-07-01  9:11 ` Enric Balletbo i Serra
  0 siblings, 0 replies; 2+ messages in thread
From: Enric Balletbo i Serra @ 2020-07-01  9:11 UTC (permalink / raw)
  To: Gwendal Grignou, bleung, bhanumaiya; +Cc: groeck, linux-kernel

Hi Gwendal,

Thank you for your patch.

On 30/6/20 9:52, Gwendal Grignou wrote:
> EC is using 32 bit timestamps (us), and before converting it to 64bit
> they were not casted, so it would overflow every 4s.
> Regular overflow every ~70 minutes was not taken into acoun either.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>

Applied for 5.9 with a slightly modified subject, platform/chrome:
cros_ec_sensorhub: ...

> ---
>  drivers/platform/chrome/cros_ec_sensorhub_ring.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
> index 23960f3acc0b1..641d91088cee2 100644
> --- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
> +++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
> @@ -465,9 +465,7 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
>  			 * Disable filtering since we might add more jitter
>  			 * if b is in a random point in time.
>  			 */
> -			new_timestamp = fifo_timestamp -
> -					fifo_info->timestamp  * 1000 +
> -					in->timestamp * 1000;
> +			new_timestamp = c - b * 1000 + a * 1000;
>  			/*
>  			 * The timestamp can be stale if we had to use the fifo
>  			 * info timestamp.
> 

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

end of thread, other threads:[~2020-07-01  9:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30  7:52 [PATCH] platform: chrome: Fix EC timestamp overflow Gwendal Grignou
2020-07-01  9:11 ` Enric Balletbo i Serra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).