From patchwork Wed Oct 11 11:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Winkler X-Patchwork-Id: 151264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp451759vqb; Wed, 11 Oct 2023 04:03:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcHziqLTw7U5t739emFIAb/+86xHB9CUUztE+IuC5MVEitIc3eFl01Vbh8Fz0wyqutUPGb X-Received: by 2002:a17:902:e5d2:b0:1c4:1cd3:8062 with SMTP id u18-20020a170902e5d200b001c41cd38062mr23542118plf.2.1697022186275; Wed, 11 Oct 2023 04:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022186; cv=none; d=google.com; s=arc-20160816; b=n+JKh2Ek8TTldk3UpiCdiwuq9h88asdypXM3dArMIfDguRqtU4ElAYuMay7dFe+VU6 PV0m+c9Cnr9WygAxPRpFB0ArzhTEnMsd9j68agwSuj8EL7i0KItrNmIdN9CXROh69CJe kxlGcUH+onIo63xC793Pxb8GtGJt2W/QRArucwruBS4lpuZX96OknA6ypSAGNwfnvTpq BdDm0pd0y85nx2FWHVHm4jRzv7k6pMLns2OFBHT6LpY5ej74mCPFpCNa1fNuMflTxxJU 4yrMjCur9gXD2oIkNIgqixF7B3MuyXcS43XxNr6a2LMgkh5eQMZ+ROrytBu+9ARZ5QTk D7OQ== 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=ymZpjsU4pNShe3LMspv55m8UHWXGnygY6l28w6eHvvo=; fh=2YBdpFWZEnGvnEE29/DshKCRvJhAQXTDnV2k5FsjgR0=; b=FqyRA3WyOh7jJDEy2g3+JD8n76oPjRQof+IZLjvs466Rtc7bk5tLuUGGs//QJAa+84 TOkOoYD7g1C4lUZIoA4WmqdNYS6GOvrb8JXeC/pKWW/Bl6ABJ0UU3coSetmLhaSYmY5B eUji6j2S52Uxm3TN19uVI1EHXx71CzrDyiVkflqa0E9oJtgGO2oQK+TRF7g3uUW+yPZX lBXWmVVzEpOY5oKpKPB/4e3QTAcddtK0k3T7Bd7Y+21AonXRPS9EAV183+TPCNGEHXPd XrGQ41HRk2/7jYsPyA5mBl33iOg8qY/NP2yQizl1cCClbZZso05yFSsbPkKtkzGT03Sm DUGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UPzaMpsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id q4-20020a17090311c400b001b86ddfd49bsi14648279plh.6.2023.10.11.04.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:03:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UPzaMpsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 2602780EE764; Wed, 11 Oct 2023 04:03:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346618AbjJKLCS (ORCPT + 18 others); Wed, 11 Oct 2023 07:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346329AbjJKLCN (ORCPT ); Wed, 11 Oct 2023 07:02:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4880898 for ; Wed, 11 Oct 2023 04:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697022132; x=1728558132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jX49b7tx6A7Zo7jAUVrcHlfA6tQul/wKjIem8aDMzX0=; b=UPzaMpsvTLrfxBDZRT7mvEKvkBH2tK8E5V93SW+4u+Ik1oBtuJXYMH/z hIyqbVm5A5NxfwNjkj9mlU9IlSqZrAq5EVrUDk/g01elFAFDvlJbYKd/D nm0EjTSgxs+ltd+6b17xcByn+DU1gWOU84LezMCRxoPx8co0e3fZH0M+V aRu2Muv1jpTz5bldHe8WgRmoDBychLvZQ4+cD0ynMPZ/P9oyMx38SLdnq cM7k6p8bSuS+qri3kONH7GieI55YtFPMKP789tASXaIZ+OETxbx4wae5N rCLUsvwTCRfzzO5XmYeBzbuWjBjG8PWj73mzhkx5yjpvMikUIAjBhZuUj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="369696904" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="369696904" 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:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="788960271" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="788960271" 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:09 -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 1/4] mei: bus: add send and recv api with timeout Date: Wed, 11 Oct 2023 14:01:54 +0300 Message-ID: <20231011110157.247552-2-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 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, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 04:03:03 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779456736181092055 X-GMAIL-MSGID: 1779456736181092055 From: Alexander Usyskin Add variation of the send and recv functions on bus that define timeout. Caller can use such functions in flow that can stuck to bail out and not to put down the whole system. Signed-off-by: Alexander Usyskin Signed-off-by: Alan Previn Signed-off-by: Tomas Winkler --- drivers/misc/mei/bus.c | 88 +++++++++++++++++++++++++++++++++++++- include/linux/mei_cl_bus.h | 8 ++++ 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 67557c67bd214415b8dc6747..f9bcff197615128d72f17590 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -257,7 +257,7 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag, } /** - * mei_cldev_send_vtag - me device send with vtag (write) + * mei_cldev_send_vtag - me device send with vtag (write) * * @cldev: me client device * @buf: buffer to send @@ -278,6 +278,29 @@ ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf, } EXPORT_SYMBOL_GPL(mei_cldev_send_vtag); +/** + * mei_cldev_send_vtag_timeout - me device send with vtag and timeout (write) + * + * @cldev: me client device + * @buf: buffer to send + * @length: buffer length + * @vtag: virtual tag + * @timeout: send timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * written size in bytes + * * < 0 on error + */ + +ssize_t mei_cldev_send_vtag_timeout(struct mei_cl_device *cldev, const u8 *buf, + size_t length, u8 vtag, unsigned long timeout) +{ + struct mei_cl *cl = cldev->cl; + + return __mei_cl_send_timeout(cl, buf, length, vtag, MEI_CL_IO_TX_BLOCKING, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_send_vtag_timeout); + /** * mei_cldev_recv_vtag - client receive with vtag (read) * @@ -323,7 +346,49 @@ ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf, EXPORT_SYMBOL_GPL(mei_cldev_recv_nonblock_vtag); /** - * mei_cldev_send - me device send (write) + * mei_cldev_recv_timeout - client receive with timeout (read) + * + * @cldev: me client device + * @buf: buffer to receive + * @length: buffer length + * @timeout: send timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * read size in bytes + * * < 0 on error + */ +ssize_t mei_cldev_recv_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + unsigned long timeout) +{ + return mei_cldev_recv_vtag_timeout(cldev, buf, length, NULL, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_recv_timeout); + +/** + * mei_cldev_recv_vtag_timeout - client receive with vtag (read) + * + * @cldev: me client device + * @buf: buffer to receive + * @length: buffer length + * @vtag: virtual tag + * @timeout: recv timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * read size in bytes + * * < 0 on error + */ + +ssize_t mei_cldev_recv_vtag_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + u8 *vtag, unsigned long timeout) +{ + struct mei_cl *cl = cldev->cl; + + return __mei_cl_recv(cl, buf, length, vtag, 0, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_recv_vtag_timeout); + +/** + * mei_cldev_send - me device send (write) * * @cldev: me client device * @buf: buffer to send @@ -339,6 +404,25 @@ ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, size_t length } EXPORT_SYMBOL_GPL(mei_cldev_send); +/** + * mei_cldev_send_timeout - me device send with timeout (write) + * + * @cldev: me client device + * @buf: buffer to send + * @length: buffer length + * @timeout: send timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * written size in bytes + * * < 0 on error + */ +ssize_t mei_cldev_send_timeout(struct mei_cl_device *cldev, const u8 *buf, size_t length, + unsigned long timeout) +{ + return mei_cldev_send_vtag_timeout(cldev, buf, length, 0, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_send_timeout); + /** * mei_cldev_recv - client receive (read) * diff --git a/include/linux/mei_cl_bus.h b/include/linux/mei_cl_bus.h index c9af62e54577033bf9bae0e4..b38a56a13f39277f948c53b8 100644 --- a/include/linux/mei_cl_bus.h +++ b/include/linux/mei_cl_bus.h @@ -94,15 +94,23 @@ void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv); ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, size_t length); +ssize_t mei_cldev_send_timeout(struct mei_cl_device *cldev, const u8 *buf, + size_t length, unsigned long timeout); ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length); ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf, size_t length); +ssize_t mei_cldev_recv_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + unsigned long timeout); ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf, size_t length, u8 vtag); +ssize_t mei_cldev_send_vtag_timeout(struct mei_cl_device *cldev, const u8 *buf, + size_t length, u8 vtag, unsigned long timeout); ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length, u8 *vtag); ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length, u8 *vtag); +ssize_t mei_cldev_recv_vtag_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + u8 *vtag, unsigned long timeout); int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb); int mei_cldev_register_notif_cb(struct mei_cl_device *cldev, From patchwork Wed Oct 11 11:01:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Winkler X-Patchwork-Id: 151262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp451510vqb; Wed, 11 Oct 2023 04:02:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4Hu3Z1douYYZlJirwxmOfswby0KmcMetQBshMjqa8w2vVgr3sm0iEUmlCtNghJnTgMY7L X-Received: by 2002:a17:902:f54e:b0:1c2:c60:8387 with SMTP id h14-20020a170902f54e00b001c20c608387mr23271729plf.0.1697022167262; Wed, 11 Oct 2023 04:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022167; cv=none; d=google.com; s=arc-20160816; b=V6AvQSSzcJWmT6qt/vSTK/zm/v3MxWS46bzEsKUVMUq5naIglVqytq9C5mXv77tCYe vQeETuHubKF5xiFu9YQ11Ovxlj6KkAjoBKGe91V/00spCV+iSDdTgveQvEUspiwIBd++ 0Ws8XJPOLSTnRkONfxOor5TTtaOOkFNBWoeubDN+fw7pELR2Jx4KtXq+Ad6EgtSSF4aR dOEfSX4oDHl3sCWdApju20H07YmcAA73aXYJg0v2kLuvvmKFZn/95DmgDgCP3ufk0360 8lhlyFnnu798Rbldzk56myQIY/rwxQ2eG1cJegeyXbc4uoG3ZCji2rZvdqDHmsQJVGJ3 FFCg== 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=RN0WhYFFQNaAZ8D5OX6dbIHe5xYyJ6wAw1BXGuopOeM=; fh=2YBdpFWZEnGvnEE29/DshKCRvJhAQXTDnV2k5FsjgR0=; b=fYsuQAY+LXoJpZtJcK3cLpz5d28fyQ+mZGl0mngq9VET+hjGCS3jy+BYSYejtTOBbW eZfL9CfJW7X8k62a32yRMnanjLCFl9nksp4X5oENf2TWkNd7AtlIqdsZy5U3TrJQJDDv AiqkPnhcv0pIoF4OFCz6iCHKBLjmSDnL7S8eKw1fGdQGNZZlQkmdmjO/tauop5T8ACTb rvEjmGIYVhLJDroxjNLAJbHjuozH/M2xu83YJ6DZACnYFBi03t+ahvTVix7BaleIhfeh 3e3CPosrmPI1hhaNpNUEADylw+jepRrskWonQJkCIFGHvawqL7rifdZr5WffHwo75pQh kAPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QeZInN7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id l1-20020a170903244100b001b89551a392si14809198pls.113.2023.10.11.04.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:02:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QeZInN7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id E72E380FF016; Wed, 11 Oct 2023 04:02:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346694AbjJKLCV (ORCPT + 18 others); Wed, 11 Oct 2023 07:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346600AbjJKLCP (ORCPT ); Wed, 11 Oct 2023 07:02:15 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AB23C9 for ; Wed, 11 Oct 2023 04:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697022134; x=1728558134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CyglcibgiNb0VhODVxX7aqzQHuGwSaBbHCQgN+Wjg8o=; b=QeZInN7qH+x0OHCKGIK1r57f+5M6kbsCWbr+/O5sIdHGW8wo4JYa1xeN l2qwX03cGGohpCUi7bcTH3oSrQFYfw46PFQSPyHS3o8CpODog+edhfWsl P028Ec+ZX3ZL1V05tdfv23EiekILaHOZ6bY398RjJL591d8EQnMo5hBkc EBvkXmDD0imd2jD/53hfMYxmUXpgGvwT/Pp462USyENjm75E/bsY0IkGO 8hc6voMQ43VXRkBNG0Ws+fD2ihvnUs0jH0LQhTLlT7UOUd+1qcQ/61qwa aIpaQquKrzuC+oIKhPV+/8YA3Qwg6X4Sn8FsXQa9mYlaJ5gUdQqK9LQX1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="369696908" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="369696908" 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:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="788960280" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="788960280" 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:11 -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 2/4] mei: pxp: recover from recv fail under memory pressure Date: Wed, 11 Oct 2023 14:01:55 +0300 Message-ID: <20231011110157.247552-3-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 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 04:02:44 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779456715903565451 X-GMAIL-MSGID: 1779456715903565451 From: Alexander Usyskin Under memory pressure recv fails due to kmalloc failure, and if drivers(pxp) retry send/receive, send blocks indefinitely. Send without recv leaves the channel in a bad state. Retry send attempt after small timeout and reset the channel if the retry failed on kmalloc failure too. Signed-off-by: Alexander Usyskin Signed-off-by: Alan Previn Signed-off-by: Tomas Winkler --- drivers/misc/mei/pxp/mei_pxp.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c index 2dcb9169e404c3bcbbccc7b4..c6cdd6a47308ebcc72f34c38 100644 --- a/drivers/misc/mei/pxp/mei_pxp.c +++ b/drivers/misc/mei/pxp/mei_pxp.c @@ -11,6 +11,7 @@ * negotiation messages to ME FW command payloads and vice versa. */ +#include #include #include #include @@ -61,16 +62,38 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) { struct mei_cl_device *cldev; ssize_t byte; + bool retry = false; if (!dev || !buffer) return -EINVAL; cldev = to_mei_cl_device(dev); +retry: byte = mei_cldev_recv(cldev, buffer, size); if (byte < 0) { dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte); - return byte; + if (byte != -ENOMEM) + return byte; + + /* Retry the read when pages are reclaimed */ + msleep(20); + if (!retry) { + retry = true; + goto retry; + } else { + dev_warn(dev, "No memory on data receive after retry, trying to reset the channel...\n"); + byte = mei_cldev_disable(cldev); + if (byte < 0) + dev_warn(dev, "mei_cldev_disable failed. %zd\n", byte); + /* + * Explicitly ignoring disable failure, + * enable may fix the states and succeed + */ + byte = mei_cldev_enable(cldev); + if (byte < 0) + dev_err(dev, "mei_cldev_enable failed. %zd\n", byte); + } } return byte; From patchwork Wed Oct 11 11:01:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Winkler X-Patchwork-Id: 151263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp451600vqb; Wed, 11 Oct 2023 04:02:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4mMy2/kOtEgY2yrMoL0SolTmmEan0xkTWNJhEPDTPYG786533hTU+0s/dAT0RB0/4zJ+f X-Received: by 2002:a05:6a20:3d04:b0:13d:d5bd:758f with SMTP id y4-20020a056a203d0400b0013dd5bd758fmr25789078pzi.6.1697022173938; Wed, 11 Oct 2023 04:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022173; cv=none; d=google.com; s=arc-20160816; b=gh1yoqRm9skKuLl1gfsQxwClEYHqQGA7EZCswbRRyKng64B8OXeY/KRVR7jucR1nOV CA0xntB9CXgRP8+lISjTKC9Cs5aeZfFp2CQiQxQ7f2LsbU7LFrxMqMEe4Bv1mMqxRSuI Jxw2DkiT9eRDhlZZlTHDJ3AonKmVSYGwP5zT4qGp4nQugyuQkTgIPAh8FhSVrKk1PjZj q4osLNqZ1yu9OxCMGS7TmTloORNeTzaW/zKZwii3pteTd74s6BiL76QTovqezkbM5MCP 9uT9qj73TF4DY0bXtYVpwg9i0SdJtGEkNPNR/Dqdd33irbK8KPPHu5FafFZl/m/pdefv GUqQ== 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=paKj4zb66+u4kiOfaCPDiTzCQdse+gETvb6eqR38cNU=; fh=np4jDbLVnoqkv3+sUYlitby5vs5P86AOvvZOqGHaBE8=; b=vY6rNS1+fmG6ygtJ3AN5UWDCuGqLXrP5JdxkGfIP2ZpXnzqnXZeyseTnn6h8Ypi0pR QnwVkFuhfymb+1DPqTWAx9MDTKM8M3Tl1YUXW5dHlunqEL+zpiyG0q9dBUMIHzHtkMZt aQPXCjsqNPamZJvqWeDZu7OGnXUSJoz1yfWFiH9amPazGzby4PFNKoS3BOgxr6N7+g8G tki4ZctePMoYM6JJgNljzYepaZd5Jo75GWAWbkGFit9V2P12z9EjK4Wvk+tGeXV51dAd 1UyzFAuRDUZFxNWB6LxA4aY5iRlVmzux/o/sqoP+9c+lPE620PUrcpAEK4hQi32bVTlo LwIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nCoUNbiQ; 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p18-20020a17090b011200b0026f4d1e6940si3504632pjz.160.2023.10.11.04.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:02:53 -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=nCoUNbiQ; 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 B5D7E8023EDB; Wed, 11 Oct 2023 04:02:51 -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 S1346715AbjJKLC2 (ORCPT + 18 others); Wed, 11 Oct 2023 07:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346572AbjJKLCR (ORCPT ); Wed, 11 Oct 2023 07:02:17 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98ADC98 for ; Wed, 11 Oct 2023 04:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697022135; x=1728558135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uD4MYHG5qvyyAF6HKIr6E+xlIfaGIPkL5F9+Pwgm4B4=; b=nCoUNbiQM9684QLAYT9MP1QNhP6+xfsxUoqLAdeb/up/GlGXb7HN0hLN pDp2qNG5vDDnvrWkYLDuvNby2JEZeZxCyLbnsOsCzgaRXlJnXc0HJCh8u 4qmTj3Ep0VPF8fvy9Cq+URPnJPy4mcQxEpuCEEZfXWBw2v2VhoKOT9v8Q x10gMnwMJZXtKcOMGkaP4pXCBMKCL1+6zbHnD8XG7Eu9F0uc7UkCVn657 sQNXCUntMHdqRfYDEdypI1f4IW2I1PL23KfbFK0pOiF/rZbFNTbr7pdIl C3XLj80nNAbvLnib39UZeUTS2368jlJqw3KiTz0I6qWms/PMqupceq+Qm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="369696912" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="369696912" 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:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="788960297" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="788960297" 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:13 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , Vitaly Lubart , linux-kernel@vger.kernel.org, Tomas Winkler Subject: [char-misc-next 3/4] mei: pxp: re-enable client on errors Date: Wed, 11 Oct 2023 14:01:56 +0300 Message-ID: <20231011110157.247552-4-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 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:51 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779456722865264272 X-GMAIL-MSGID: 1779456722865264272 From: Alexander Usyskin Disable and enable mei-pxp client on errors to clean the internal state. Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- drivers/misc/mei/pxp/mei_pxp.c | 70 +++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/drivers/misc/mei/pxp/mei_pxp.c b/drivers/misc/mei/pxp/mei_pxp.c index c6cdd6a47308ebcc72f34c38..9875d16445bb03efcfb31cd9 100644 --- a/drivers/misc/mei/pxp/mei_pxp.c +++ b/drivers/misc/mei/pxp/mei_pxp.c @@ -23,6 +23,24 @@ #include "mei_pxp.h" +static inline int mei_pxp_reenable(const struct device *dev, struct mei_cl_device *cldev) +{ + int ret; + + dev_warn(dev, "Trying to reset the channel...\n"); + ret = mei_cldev_disable(cldev); + if (ret < 0) + dev_warn(dev, "mei_cldev_disable failed. %d\n", ret); + /* + * Explicitly ignoring disable failure, + * enable may fix the states and succeed + */ + ret = mei_cldev_enable(cldev); + if (ret < 0) + dev_err(dev, "mei_cldev_enable failed. %d\n", ret); + return ret; +} + /** * mei_pxp_send_message() - Sends a PXP message to ME FW. * @dev: device corresponding to the mei_cl_device @@ -35,6 +53,7 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) { struct mei_cl_device *cldev; ssize_t byte; + int ret; if (!dev || !message) return -EINVAL; @@ -44,10 +63,20 @@ mei_pxp_send_message(struct device *dev, const void *message, size_t size) byte = mei_cldev_send(cldev, message, size); if (byte < 0) { dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte); - return byte; + switch (byte) { + case -ENOMEM: + fallthrough; + case -ENODEV: + fallthrough; + case -ETIME: + ret = mei_pxp_reenable(dev, cldev); + if (ret) + byte = ret; + break; + } } - return 0; + return byte; } /** @@ -63,6 +92,7 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) struct mei_cl_device *cldev; ssize_t byte; bool retry = false; + int ret; if (!dev || !buffer) return -EINVAL; @@ -73,26 +103,22 @@ mei_pxp_receive_message(struct device *dev, void *buffer, size_t size) byte = mei_cldev_recv(cldev, buffer, size); if (byte < 0) { dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte); - if (byte != -ENOMEM) - return byte; - - /* Retry the read when pages are reclaimed */ - msleep(20); - if (!retry) { - retry = true; - goto retry; - } else { - dev_warn(dev, "No memory on data receive after retry, trying to reset the channel...\n"); - byte = mei_cldev_disable(cldev); - if (byte < 0) - dev_warn(dev, "mei_cldev_disable failed. %zd\n", byte); - /* - * Explicitly ignoring disable failure, - * enable may fix the states and succeed - */ - byte = mei_cldev_enable(cldev); - if (byte < 0) - dev_err(dev, "mei_cldev_enable failed. %zd\n", byte); + switch (byte) { + case -ENOMEM: + /* Retry the read when pages are reclaimed */ + msleep(20); + if (!retry) { + retry = true; + goto retry; + } + fallthrough; + case -ENODEV: + fallthrough; + case -ETIME: + ret = mei_pxp_reenable(dev, cldev); + if (ret) + byte = ret; + break; } } From patchwork Wed Oct 11 11:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Winkler X-Patchwork-Id: 151261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp451504vqb; Wed, 11 Oct 2023 04:02:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwRSXYMzYDlnitfqCgea+dOKbTq4ikACp9JPjVHHZk9D388yX87/paBEIuX6sKgBnV/A1j X-Received: by 2002:a05:6e02:9a:b0:357:4682:d128 with SMTP id bc26-20020a056e02009a00b003574682d128mr2623352ilb.1.1697022166899; Wed, 11 Oct 2023 04:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022166; cv=none; d=google.com; s=arc-20160816; b=e2wkSjD54+mdOXpE7VfKGH0Zes3y0X1cjr9TCO0qHGOgzmSfN0n5bOtPG64jAcPPA1 sL7esJfq6t7It1NxTPRprlbYji4CCpCgmMAz+l3QsL8iWbm3qo9Q7Aef9BVRgrj+nmcN n+jN/u3yV0w9HSRjBXECKOLXdX0HcWkoV7FbDxOeaoksow7H6NplifqlHGHaZMMUW3e/ B2TSoZ+fg01L191LXP7pxJqbhlfa5XLrVCq1FDENKo/7FNF6XI8pFb/SLtenGfhUh1N5 CoJwi8JYI9R573ivIUqnKO0edViNvQQhoEOC7sYjgishSCGEo5V4qwY6kZnCAgeely+y ttAg== 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.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j190-20020a6380c7000000b005859de837c9si13833135pgd.105.2023.10.11.04.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:02:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; 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.31 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 morse.vger.email (Postfix) with ESMTP id 99F0280FF03D; Wed, 11 Oct 2023 04:02:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234856AbjJKLCe (ORCPT + 18 others); Wed, 11 Oct 2023 07:02:34 -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 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 04:02:43 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779456715815263437 X-GMAIL-MSGID: 1779456715815263437 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);