From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.29 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796358097; b=5X98kFNE9U9MKFWoIG8sZ1nvvRHrvH2psUM5XQr3TcfOfVi3ncSI80GZRcEUr8X+2GEE PzDy1sJcfZOnniX2MjitMe7bFz3Qwb0kr6vrKYr6lrqeEfWur6fNqN58AjNKdNJ0M4tHv HXYC6242uU97KbTeQnHQlZS6HYls21RlNjZ+5/N87akeYx+a+uOCFzWjlIbTcVVTp9+nl FVhnoeFh7dIzBS+g2W+NVc9kCNDEVqm8UqlEmZTV1PxBKDfZdLA4uEofDTennkbomXoEH eskYui10WziypLw1Olf6cX4AR+IOflh7PtO+s5NnykJ4Dk6AZjifOM6BAyjsApBK4ng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796358097; h=DMARC-Filter:DKIM-Signature:Received:References:X-Lms-Return-Path: X-Mailer:From:Date:Message-Id:X-Original-From:Cc: Content-Transfer-Encoding:Content-Type:To:Mime-Version:In-Reply-To: Subject; bh=STzVIPbFZJpPpahGPCLWO2yTqMojy1cqq8hOATvLyyY=; b=3UkN6LP5r8Q197C3wNy3xBLqhLF8bmSvYboghSyzhXmcdU8WqMElKBviaf+UZKmqs30r VdAZLW7+F5r/Yxiz8itKd95UFqUaSWtRWfKZg4Q4ED0ySamc7VZI41aJvA41EW8pDxpAg SRk53H/5PchAUtwv3ngqLn3rkjVSSNRtADbAP/eLad9iQPIbZsYYLckuW09GFqq9UWXTJ UxsPQyFTrvqJhBHe9tRwD/jjltKnuqhxcW0VsPIa0Q+oLYWeuJpbN6Wm+aQuUKGCi0/nq 5hxmIx+aAWmARFwxZ4NWL0yjHJK39SNRs9Ahh8dCXNpboBT2X9TeIrvCuI8wXLeHKLw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=deepcomputing.io; spf=pass smtp.mailfrom=deepcomputing.io; dkim=pass header.d=deepcomputing-io.20200927.dkim.feishu.cn header.i=@deepcomputing-io.20200927.dkim.feishu.cn header.a=rsa-sha256 header.s=s1 header.b=UB2sy97k; arc=none smtp.remote-ip=209.127.231.29 Received: from va-2-29.ptr.blmpb.com (va-2-29.ptr.blmpb.com [209.127.231.29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 700A7606A69C for ; Fri, 4 Dec 2026 04:21:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 700A7606A69C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=deepcomputing.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=deepcomputing.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=deepcomputing-io.20200927.dkim.feishu.cn header.i=@deepcomputing-io.20200927.dkim.feishu.cn header.a=rsa-sha256 header.s=s1 header.b=UB2sy97k DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=deepcomputing-io.20200927.dkim.feishu.cn; t=1796358087; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=STzVIPbFZJpPpahGPCLWO2yTqMojy1cqq8hOATvLyyY=; b=UB2sy97kE34dDBKeDj0swItMT3VeCXOpdFTLlUyAyALxdVB62xyqg0MTgM5zihj3YAMkFl qCZZ0bf2XsDo72LhTetSf01oV72E/zNylrW5Nb+AZSoqiaGtVjnbK5NYskQ4d48m7eS98f clN0WdWYwjlQD/bBfv/LR/expQ9NJhr7zxo86OWXGARFxwTcC+hlmpaMM+WsmiQXzqx3N7 KPZegKhQlWZwjhatCABmeg9VTvPMxlLm59fv+uaKXfBbNkVq2/qe2erGqRf8rJbiKFTSdi TFXv7gz4zOBgl/SgClMrG/uAxr0hBJE8lEyr9GKDqGNWt9PCvzaZoBJDCfB0bw== Received: from ubuntu.. ([183.23.101.24]) by smtp.feishu.cn with ESMTPS; Fri, 04 Dec 2026 12:21:24 +0800 References: <20261204042112.2985112-1-yang.wang@deepcomputing.io> X-Lms-Return-Path: X-Mailer: git-send-email 2.43.0 From: "Wang Yang" Date: Fri, 4 Dec 2026 12:21:01 +0800 Message-Id: <20261204042112.2985112-4-yang.wang@deepcomputing.io> X-Original-From: Wang Yang Cc: "Benson Leung" , "Tzung-Bi Shih" , "Guenter Roeck" , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 To: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 In-Reply-To: <20261204042112.2985112-1-yang.wang@deepcomputing.io> Subject: [PATCH v2 03/13] platform/chrome: Allow transport-specific LPC response timeouts 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 --- 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