Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp727204rdg; Wed, 11 Oct 2023 04:02:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFU/m0yic56IBEykLP2m2Ki+G1Ug4ZdKhLI1+fHTlWFED6/MnMsL2dipvG7ugZVo1IdUj1D X-Received: by 2002:a17:90a:ce87:b0:27c:ef06:38c3 with SMTP id g7-20020a17090ace8700b0027cef0638c3mr3916859pju.21.1697022164914; Wed, 11 Oct 2023 04:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022164; cv=none; d=google.com; s=arc-20160816; b=f0GOc8T3GfAF288EVgo/x7bxKXyLRz4MlQYbrP9cJnz2pTC5Iohr9e2U3S3CcvNonz yd6lYpn1SEQyMFXnBViHE7/RVhuroxSCj1/khQ6RsQq27jBP7MJKtJY8FJXbxk5PZ1kD U7qWwF5kzteCjobJKvFDgkfsw3AxDaLSCDFkyJDxPlcOVctCrjWWRqEMEdkg8yDTfOjC +f/RPLL1KvITRpOSboQYkYSkl72W8bRqZIvxEAGbA8ne3UN40eUX4Te39RFxLLdR+JZy xZbCLiZVJzRvcV0+wzbAoSiLNv1/KpAOLCY7DBMWKdF9FC90to34EQwtj8TQCFbTQ6vG un0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2szCXzrPfyN34/e44isb+u8re8RHDpLR6viZbDhbX50=; fh=2YBdpFWZEnGvnEE29/DshKCRvJhAQXTDnV2k5FsjgR0=; b=M2Ir+tRygRridLXQ/Kequ8jiJj4gJdW3cHMSA/A01LxVsHWjU5BgMOZq1jkrhpiXoL HfjgYw7ubdSUE2eaupFbosyvoojEqkpnyr2fqjr4Vy7Pvbb5DpjLbWUsRmfwGi1YDSDr 6sC0gmqN4cyJb76YG6roJH3zEZAMnBRUSflWGorBC21+hr6phY6WXirmCA6XHhf9u15v 0je4bgAdz5RuXVX1fw9PiCDns+6eQlzprplhPBgYQotrjf0DzBTA7rDjZg9tBsJS4WkN ZJCOGkrsPL4w3T/A3PVIdsf+z+Pwyw7dFS0rEwxOAafZkyHg778US7PFcD6YwY1fQXMY KTUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="lbA/JU3I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id d13-20020a17090ad98d00b0027450695a78si15365555pjv.172.2023.10.11.04.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:02:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="lbA/JU3I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3D1808024AE6; Wed, 11 Oct 2023 04:02:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234808AbjJKLCd (ORCPT + 99 others); Wed, 11 Oct 2023 07:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346674AbjJKLCU (ORCPT ); Wed, 11 Oct 2023 07:02:20 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9491A9 for ; Wed, 11 Oct 2023 04:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697022137; x=1728558137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AX4VHlWO9XCZX/4XDdhwVkemO2KD/0VLOBZhVIMd1zE=; b=lbA/JU3IXl+cjgVq7KSe/6BdZDn6+f3dcX114HkGocuz4L1kTxF/uQtx gh4F2EUR8gYomae20U+gLrtt5tOcyxAtoO/gJlGTvteRMmI/F8HkGfPC4 NRJK1ypImF6uiCOgxvXjsGNu6xYqrQQphVo/YnVY3mDovBkwSgQMPL5Eg BUAlalEZrIc94WHkMmnwveZNdf7nbiGKW5v6X98zGkoHNy9yYJ/9KpUVK PIPuVrWr41BcPjk+huA9Q/4vWVzqw/rkukKtFvJr8SEPKPmJYFjRqDJrr bmXeYR88DiIwSUHGxAUVDPPgOv8yry1wZtTUvDFi7fQFb10OaDmTUVIoi A==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="369696917" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="369696917" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 04:02:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="788960311" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="788960311" Received: from twinkler-lnx.jer.intel.com ([10.12.231.216]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 04:02:15 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , Vitaly Lubart , linux-kernel@vger.kernel.org, Alan Previn , Tomas Winkler Subject: [char-misc-next 4/4] mei: update mei-pxp's component interface with timeouts Date: Wed, 11 Oct 2023 14:01:57 +0300 Message-ID: <20231011110157.247552-5-tomas.winkler@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231011110157.247552-1-tomas.winkler@intel.com> References: <20231011110157.247552-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 04:02:42 -0700 (PDT) X-Spam-Level: ** From: Alan Previn In debugging platform or firmware related MEI-PXP connection issues, having a timeout when clients (such as i915) calling into mei-pxp's send/receive functions have proven useful as opposed to blocking forever until the kernel triggers a watchdog panic (when platform issues are experienced). Update the mei-pxp component interface send and receive functions to take in timeouts. Signed-off-by: Alan Previn Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- drivers/gpu/drm/i915/pxp/intel_pxp_tee.c | 8 ++++-- drivers/misc/mei/pxp/mei_pxp.c | 33 +++++++++++++++++++----- include/drm/i915_pxp_tee_interface.h | 6 +++-- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c index 80bb0018986525f16d410e56..dfc2878426fc2226ccb55270 100644 --- a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c @@ -20,6 +20,8 @@ #include "intel_pxp_tee.h" #include "intel_pxp_types.h" +#define PXP_TRANSPORT_TIMEOUT_MS 5000 /* 5 sec */ + static bool is_fw_err_platform_config(u32 type) { @@ -71,13 +73,15 @@ static int intel_pxp_tee_io_message(struct intel_pxp *pxp, goto unlock; } - ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size); + ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size, + PXP_TRANSPORT_TIMEOUT_MS); if (ret) { drm_err(&i915->drm, "Failed to send PXP TEE message\n"); goto unlock; } - ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size); + ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size, + PXP_TRANSPORT_TIMEOUT_MS); if (ret < 0) { drm_err(&i915->drm, "Failed to receive PXP TEE message\n"); goto unlock; diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c index 9875d16445bb03efcfb31cd9..f77d78fa50549e69f0a0873b 100644 --- a/drivers/misc/mei/pxp/mei_pxp.c +++ b/drivers/misc/mei/pxp/mei_pxp.c @@ -46,10 +46,20 @@ static inline int mei_pxp_reenable(const struct device *dev, struct mei_cl_devic * @dev: device corresponding to the mei_cl_device * @message: a message buffer to send * @size: size of the message - * Return: 0 on Success, <0 on Failure + * @timeout_ms: timeout in milliseconds, zero means wait indefinitely. + * + * Returns: 0 on Success, <0 on Failure with the following defined failures. + * -ENODEV: Client was not connected. + * Caller may attempt to try again immediately. + * -ENOMEM: Internal memory allocation failure experienced. + * Caller may sleep to allow kernel reclaim before retrying. + * -EINTR : Calling thread received a signal. Caller may choose + * to abandon with the same thread id. + * -ETIME : Request is timed out. + * Caller may attempt to try again immediately. */ static int -mei_pxp_send_message(struct device *dev, const void *message, size_t size) +mei_pxp_send_message(struct device *dev, const void *message, size_t size, unsigned long timeout_ms) { struct mei_cl_device *cldev; ssize_t byte; @@ -60,7 +70,7 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) cldev = to_mei_cl_device(dev); - byte = mei_cldev_send(cldev, message, size); + byte = mei_cldev_send_timeout(cldev, message, size, timeout_ms); if (byte < 0) { dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte); switch (byte) { @@ -84,10 +94,21 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) * @dev: device corresponding to the mei_cl_device * @buffer: a message buffer to contain the received message * @size: size of the buffer - * Return: bytes sent on Success, <0 on Failure + * @timeout_ms: timeout in milliseconds, zero means wait indefinitely. + * + * Returns: number of bytes send on Success, <0 on Failure with the following defined failures. + * -ENODEV: Client was not connected. + * Caller may attempt to try again from send immediately. + * -ENOMEM: Internal memory allocation failure experienced. + * Caller may sleep to allow kernel reclaim before retrying. + * -EINTR : Calling thread received a signal. Caller will need to repeat calling + * (with a different owning thread) to retrieve existing unclaimed response + * (and may discard it). + * -ETIME : Request is timed out. + * Caller may attempt to try again from send immediately. */ static int -mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) +mei_pxp_receive_message(struct device *dev, void *buffer, size_t size, unsigned long timeout_ms) { struct mei_cl_device *cldev; ssize_t byte; @@ -100,7 +121,7 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) cldev = to_mei_cl_device(dev); retry: - byte = mei_cldev_recv(cldev, buffer, size); + byte = mei_cldev_recv_timeout(cldev, buffer, size, timeout_ms); if (byte < 0) { dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte); switch (byte) { diff --git a/include/drm/i915_pxp_tee_interface.h b/include/drm/i915_pxp_tee_interface.h index a702b6ec17f7ca95eda7d225..7d96985f2d05327151b0dfc1 100644 --- a/include/drm/i915_pxp_tee_interface.h +++ b/include/drm/i915_pxp_tee_interface.h @@ -22,8 +22,10 @@ struct i915_pxp_component_ops { */ struct module *owner; - int (*send)(struct device *dev, const void *message, size_t size); - int (*recv)(struct device *dev, void *buffer, size_t size); + int (*send)(struct device *dev, const void *message, size_t size, + unsigned long timeout_ms); + int (*recv)(struct device *dev, void *buffer, size_t size, + unsigned long timeout_ms); ssize_t (*gsc_command)(struct device *dev, u8 client_id, u32 fence_id, struct scatterlist *sg_in, size_t total_in_len, struct scatterlist *sg_out); -- 2.41.0