Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp727199rdg; Wed, 11 Oct 2023 04:02:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjmajuOqzCmCTP4QhIiBtJcWA4ZU7DZUJ3sEmDJsFiUnfdlqfiVl48odCnBKykAQ56HCTs X-Received: by 2002:a17:902:ee8b:b0:1c6:2927:fbbd with SMTP id a11-20020a170902ee8b00b001c62927fbbdmr20539751pld.18.1697022164745; 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=m/8S2h1h6tqhG7gnfpEwXAeZWIEln+23fQV+aF6mZ92LQHk7Pw+JSrFbzK95IEqfZv oerydFXvdXj2dBa60GIvtvTs7cxd7nlWay4gPE/dt02is+uc0RByvSAq2W/v55hBss2c s8XcAVLI8seDNK1LNHM5SAtz6jlH87emkNb5W97VmkOuh/rCPEcoS27Ep4fV1ee15r/5 HpR06omoVrncs5IXyv1n88zZYH8/AHrSFAydqCQAkclLXy0ET2K3QhyclJIrtfm6tSvW dgwqwfOKRWZLdO7rWoRg844N7s8VR2scRXhZ5GmJg973XAk0azuLuZ/D+7NLpNtefrJE Wckw== 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 Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w18-20020a170902e89200b001c3b5a1336esi15187211plg.329.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=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 3CF808024AE3; 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 S1346712AbjJKLC0 (ORCPT + 99 others); Wed, 11 Oct 2023 07:02:26 -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 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: 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; } } -- 2.41.0