Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp727118rdg; Wed, 11 Oct 2023 04:02:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMYfBGYtz7hDOpqxBnX8HAyK3ZJ/SPSACifnrKvN9jEyvtYuixf8vqSzKg45srkH1jSLJR X-Received: by 2002:a05:6a20:918d:b0:14c:a2e1:65fd with SMTP id v13-20020a056a20918d00b0014ca2e165fdmr23144266pzd.9.1697022157447; Wed, 11 Oct 2023 04:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022157; cv=none; d=google.com; s=arc-20160816; b=NVTw3E+rsYuktUIxaZ8DQK0xyC1ng/Zt6MxTgRL1gYL5nyNOwqxR04AOYIAhYx3GTW m9qeE6RyOhI9JOYVHk7c/8q6S1OPAeq7ArckhqJYqyZrU/D86l0hnLStQOB8NY2rvNUV TWEX9ra9yvxNC31sSMLxUifcRklN66A7S/WufSy5pPczZt24uUj/pobYJB1JM56nH0nK ugw0LWmUu2bK3x1XE3VHJdsVwEVpKQOESnvQFFubs3BCAbj7dxw0TpqTAecs7OYUEpgA XkXs2P2u9AdB/vmSifD0/VXMyB0R4MqRJKTfIhcP8YMp8mVzfq6mSH4YQ09KdfhOml4r RYCw== 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 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 Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id f23-20020a63dc57000000b00588fa0def27si13930683pgj.796.2023.10.11.04.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:02:37 -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=QeZInN7q; 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 52FE080FE942; Wed, 11 Oct 2023 04:02:34 -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 S1346689AbjJKLCU (ORCPT + 99 others); Wed, 11 Oct 2023 07:02:20 -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 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 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:34 -0700 (PDT) X-Spam-Level: ** 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; -- 2.41.0