mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cheng Yueh <cyueh@google.com>
To: Benson Leung <bleung@chromium.org>, Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Guenter Roeck <groeck@chromium.org>,
	chrome-platform@lists.linux.dev,  linux-kernel@vger.kernel.org,
	kernel-team@android.com,  Cheng Yueh <cyueh@google.com>
Subject: [PATCH] platform/chrome: cros_ec_rpmsg: record last_event_time on host event
Date: Tue,  3 Nov 2026 14:28:02 +0800	[thread overview]
Message-ID: <20261103062802.361878-1-cyueh@google.com> (raw)

Transports with a dedicated interrupt line (ec_dev->irq > 0, such as SPI
and I2C) record ec_dev->last_event_time in the top-half
cros_ec_irq_handler(), while transports without one (ec_dev->irq == 0,
such as LPC in cros_ec_lpc_acpi_notify() and ISHTP in ish_event_cb())
record it in their respective event callbacks.

cros_ec_rpmsg also operates with ec_dev->irq == 0: when an MKBP event
notification (HOST_EVENT_MARK) arrives in cros_ec_rpmsg_callback(), it
schedules host_event_work to invoke the bottom-half cros_ec_irq_thread()
directly, bypassing cros_ec_irq_handler() and leaving
ec_dev->last_event_time as 0.

cros_ec_sensorhub_ring relies on ec_dev->last_event_time (via
fifo_timestamp) as the AP CLOCK_BOOTTIME reference timestamp to calibrate
the offset and clock drift between the remote processor's local hardware
timer and the AP timebase. Without this calibration, IIO sensor sample
timestamps cannot be synchronized to CLOCK_BOOTTIME
(SystemClock.elapsedRealtimeNanos()), failing the Android CTS sensor
specification TimestampClockSourceVerification.

Record ec_dev->last_event_time = cros_ec_get_time_ns() upon receiving
HOST_EVENT_MARK in cros_ec_rpmsg_callback(), matching the other ChromeOS
EC transport drivers.

Fixes: 2de89fd98958 ("platform/chrome: cros_ec: Add EC host command support using rpmsg")
Signed-off-by: Cheng Yueh <cyueh@google.com>
---
 drivers/platform/chrome/cros_ec_rpmsg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/chrome/cros_ec_rpmsg.c b/drivers/platform/chrome/cros_ec_rpmsg.c
index 39d3b50a7c09..07b9e71ac8e3 100644
--- a/drivers/platform/chrome/cros_ec_rpmsg.c
+++ b/drivers/platform/chrome/cros_ec_rpmsg.c
@@ -180,6 +180,7 @@ static int cros_ec_rpmsg_callback(struct rpmsg_device *rpdev, void *data,
 		memcpy(ec_dev->din, resp->data, len);
 		complete(&ec_rpmsg->xfer_ack);
 	} else if (resp->type == HOST_EVENT_MARK) {
+		ec_dev->last_event_time = cros_ec_get_time_ns();
 		/*
 		 * If the host event is sent before cros_ec_register is
 		 * finished, queue the host event.
-- 
2.56.0.385.gac671c819a-goog


                 reply	other threads:[~2026-11-03  6:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261103062802.361878-1-cyueh@google.com \
    --to=cyueh@google.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --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®