All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Wang Yang" <yang.wang@deepcomputing.io>
To: <linux-kernel@vger.kernel.org>
Cc: "Benson Leung" <bleung@chromium.org>,
	 "Tzung-Bi Shih" <tzungbi@kernel.org>,
	 "Guenter Roeck" <groeck@chromium.org>,
	<chrome-platform@lists.linux.dev>
Subject: [PATCH v2 03/13] platform/chrome: Allow transport-specific LPC response timeouts
Date: Fri,  4 Dec 2026 12:21:01 +0800	[thread overview]
Message-ID: <20261204042112.2985112-4-yang.wang@deepcomputing.io> (raw)
In-Reply-To: <20261204042112.2985112-1-yang.wang@deepcomputing.io>

Preserve the LPC default of one second and -EIO. Let a transport
supply a deadline and timeout error without copying the polling loop.

Prepared with OpenAI Codex assistance.

Signed-off-by: Wang Yang <yang.wang@deepcomputing.io>
---
 drivers/platform/chrome/cros_ec_lpc_proto.c | 9 +++++----
 drivers/platform/chrome/cros_ec_lpc_proto.h | 4 ++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc_proto.c b/drivers/platform/chrome/cros_ec_lpc_proto.c
index 1dfc32a6ecd7..f0bd70e70a9c 100644
--- a/drivers/platform/chrome/cros_ec_lpc_proto.c
+++ b/drivers/platform/chrome/cros_ec_lpc_proto.c
@@ -13,7 +13,8 @@
 static int ec_response_timed_out(struct cros_ec_device *ec,
 				 const struct cros_ec_lpc_io *io)
 {
-	unsigned long one_second = jiffies + HZ;
+	unsigned long timeout = jiffies + (io->response_timeout_ms ?
+		msecs_to_jiffies(io->response_timeout_ms) : HZ);
 	u8 data;
 	int ret;
 
@@ -25,7 +26,7 @@ static int ec_response_timed_out(struct cros_ec_device *ec,
 		if (!(data & EC_LPC_STATUS_BUSY_MASK))
 			return 0;
 		usleep_range(100, 200);
-	} while (time_before(jiffies, one_second));
+	} while (time_before(jiffies, timeout));
 
 	return 1;
 }
@@ -59,7 +60,7 @@ int cros_ec_lpc_pkt_xfer(struct cros_ec_device *ec,
 		goto done;
 	if (ret) {
 		dev_warn(ec->dev, "EC response timed out\n");
-		ret = -EIO;
+		ret = io->timeout_error ?: -EIO;
 		goto done;
 	}
 
@@ -158,7 +159,7 @@ int cros_ec_lpc_cmd_xfer(struct cros_ec_device *ec,
 		goto done;
 	if (ret) {
 		dev_warn(ec->dev, "EC response timed out\n");
-		ret = -EIO;
+		ret = io->timeout_error ?: -EIO;
 		goto done;
 	}
 
diff --git a/drivers/platform/chrome/cros_ec_lpc_proto.h b/drivers/platform/chrome/cros_ec_lpc_proto.h
index 7f884ffe823a..9276fb09807d 100644
--- a/drivers/platform/chrome/cros_ec_lpc_proto.h
+++ b/drivers/platform/chrome/cros_ec_lpc_proto.h
@@ -11,12 +11,16 @@ struct cros_ec_command;
  * struct cros_ec_lpc_io - byte access to an LPC-style EC interface
  * @read: Read bytes, returning their checksum or a negative error.
  * @write: Write bytes, returning their checksum or a negative error.
+ * @response_timeout_ms: Response timeout in milliseconds, or zero for one second.
+ * @timeout_error: Negative timeout error, or zero for the LPC default (-EIO).
  */
 struct cros_ec_lpc_io {
 	int (*read)(struct cros_ec_device *ec, unsigned int offset,
 		    unsigned int length, u8 *dest);
 	int (*write)(struct cros_ec_device *ec, unsigned int offset,
 		     unsigned int length, const u8 *src);
+	unsigned int response_timeout_ms;
+	int timeout_error;
 };
 
 int cros_ec_lpc_pkt_xfer(struct cros_ec_device *ec,
-- 
2.43.0

  parent reply	other threads:[~2026-12-04  4:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  4:20 [PATCH v2 00/13] Add SpacemiT K3 FML13V05 EC keyboard support Wang Yang
2026-12-04  4:20 ` Wang Yang
2026-12-04  4:20 ` [PATCH v2 01/13] platform/chrome: Correct LPC EC readmem bounds Wang Yang
2026-12-04  4:21 ` [PATCH v2 02/13] platform/chrome: Extract LPC-style EC protocol helpers Wang Yang
2026-12-04  4:21 ` Wang Yang [this message]
2026-12-04  4:21 ` [PATCH v2 04/13] platform/chrome: Allow transports to select EC IRQ flags Wang Yang
2026-12-04  4:21 ` [PATCH v2 05/13] dt-bindings: embedded-controller: Add SpacemiT K3 EC window Wang Yang
2026-12-04  4:21   ` Wang Yang
2026-12-04  4:32   ` sashiko-bot
2026-12-04  4:21 ` [PATCH v2 06/13] dt-bindings: bus: Add SpacemiT K3 Intel eSPI controller Wang Yang
2026-12-04  4:21   ` Wang Yang
2026-12-04  4:44   ` sashiko-bot
2026-12-04  4:21 ` [PATCH v2 07/13] bus: Add SpacemiT K3 eSPI controller support Wang Yang
2026-12-04  4:21   ` Wang Yang
2026-12-04  4:21 ` [PATCH v2 08/13] platform/chrome: Allow ChromeOS platform support on RISC-V Wang Yang
2026-12-04  4:21 ` [PATCH v2 09/13] platform/chrome: Add SpacemiT K3 eSPI EC transport Wang Yang
2026-12-04  4:21   ` Wang Yang
2026-12-04  4:21 ` [PATCH v2 10/13] riscv: dts: spacemit: Add K3 eSPI pin group Wang Yang
2026-12-04  4:21   ` Wang Yang
2026-12-04  4:41   ` sashiko-bot
2026-12-04  4:21 ` [PATCH v2 11/13] riscv: dts: spacemit: Describe the K3 eSPI controller Wang Yang
2026-12-04  4:21   ` Wang Yang
2026-12-04  4:48   ` sashiko-bot
2026-12-04  4:21 ` [PATCH v2 12/13] riscv: dts: spacemit: Enable the FML13V05 EC keyboard Wang Yang
2026-12-04  4:21   ` Wang Yang
2026-12-04  4:21 ` [PATCH v2 13/13] riscv: defconfig: Enable the FML13V05 EC keyboard modules Wang Yang
2026-12-04  4:21   ` Wang Yang

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=20261204042112.2985112-4-yang.wang@deepcomputing.io \
    --to=yang.wang@deepcomputing.io \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.