Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2757444pxb; Sat, 6 Feb 2021 06:51:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRtt7ezOuVb96vztKmpShaCp5dxtcUvuxx9BStqBi+yA4qP5d3vawU3e7EAppkURiDd+a7 X-Received: by 2002:a17:907:7347:: with SMTP id dq7mr9402357ejc.385.1612623102182; Sat, 06 Feb 2021 06:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612623102; cv=none; d=google.com; s=arc-20160816; b=cBO0TNUYcgncUIz+tlHjYqXbGDmp6pBqzQQ+CY1HvdrS7EMvcQ6DmCz2zFtBzj5k5N 3+xXC1zNcmZHDMybD1xupsLYNcEAK1B52aIDfGaNdl7r2/eB3WYStWMP6ac8Nvmyy9dR 8HCt2+Hpddpn1OXZOgjWfwr2N9AVubTiWeVHPptOz2bZdiWivmy0O95sWuFSvHK7elZn fZ3Stc7XEyLrE6Aymer5RGMt3oJs1Zw0//vlJyljlIc/Lv9f/HzP2O564zCBY7+8Pfxk w/JbjgveuCniaoo2X1uFtCs9PjY8eFY1pZsh1Dpx3WY0GSs5s+r6vLxzHCMkTNGtS+Ys 2GyQ== 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 :ironport-sdr:ironport-sdr; bh=s4Er6QSfxdUezthueV41uVIEgB0Q3cT/1nZ0ai/aIRo=; b=K0JiOqSmCVl+kBvUeBWYCvg9PXFLE4wXsjiEXpGzohJqayyWL4qnWipDmI+lc+ysJx PFqZMGy/tfgPUBdlnrwHSpdfbUpV1BDGjI26LPxTzbmg9K+SIRrW4H0Q7tA/ulqVG3ub 13xxvDtfzeUMXDywR04MDf55s9NYX6vU5eXgQGq84bQdnWeZ7RI9BhMEtjLuMukIR4Ez 3qThrVJGLlN00gNKBp55K00NSd/ZVVmzb6LyD8jY63U/DVyvkBSWogsO1Z7k0bItJo3R 6ecxVqIcTiJoZEC/jLcIttwawP1T1Ay49anOSNKlYFfYrZawXu9sOfX9uAvrf7DluWXM IfGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a14si7653921edx.54.2021.02.06.06.51.18; Sat, 06 Feb 2021 06:51:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbhBFOon (ORCPT + 99 others); Sat, 6 Feb 2021 09:44:43 -0500 Received: from mga01.intel.com ([192.55.52.88]:38616 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbhBFOoV (ORCPT ); Sat, 6 Feb 2021 09:44:21 -0500 IronPort-SDR: RLFBkWLYOyyjj2j09f+W95lUoHI+f4srOwCAqnruZj2zZaAWNrwUUXhAvIAEEqKL2VHPrXxq8T z4oCIL9Cip7w== X-IronPort-AV: E=McAfee;i="6000,8403,9886"; a="200566034" X-IronPort-AV: E=Sophos;i="5.81,158,1610438400"; d="scan'208";a="200566034" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 06:43:40 -0800 IronPort-SDR: OmgNEOnVa9a8s3GVbWo6iwle/t/upJuhle324zvxYqpU5WyvNkY9Kyi9gwdV5t5r4Kxrn6wLu/ 5kjRo753tNLA== X-IronPort-AV: E=Sophos;i="5.81,158,1610438400"; d="scan'208";a="394360214" Received: from twinkler-lnx.jer.intel.com ([10.12.91.138]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 06:43:39 -0800 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, Tomas Winkler Subject: [char-misc-next 2/6] mei: allow clients on bus to communicate in remove callback Date: Sat, 6 Feb 2021 16:43:21 +0200 Message-Id: <20210206144325.25682-2-tomas.winkler@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210206144325.25682-1-tomas.winkler@intel.com> References: <20210206144325.25682-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Usyskin Introduce new intermediate state to allow the clients on the bus to communicate with the firmware from the remove handler. This is to enable to perform a clean shutdown. Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- drivers/misc/mei/bus.c | 6 ++++-- drivers/misc/mei/client.c | 3 ++- drivers/misc/mei/init.c | 5 ++++- drivers/misc/mei/mei_dev.h | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 2907db260fba..34fb5e541fe5 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -44,7 +44,8 @@ ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, u8 vtag, bus = cl->dev; mutex_lock(&bus->device_lock); - if (bus->dev_state != MEI_DEV_ENABLED) { + if (bus->dev_state != MEI_DEV_ENABLED && + bus->dev_state != MEI_DEV_POWERING_DOWN) { rets = -ENODEV; goto out; } @@ -128,7 +129,8 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag, bus = cl->dev; mutex_lock(&bus->device_lock); - if (bus->dev_state != MEI_DEV_ENABLED) { + if (bus->dev_state != MEI_DEV_ENABLED && + bus->dev_state != MEI_DEV_POWERING_DOWN) { rets = -ENODEV; goto out; } diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index beb6cdff20fb..d3f060dce4a6 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c @@ -990,7 +990,8 @@ int mei_cl_disconnect(struct mei_cl *cl) return 0; } - if (dev->dev_state == MEI_DEV_POWER_DOWN) { + if (dev->dev_state == MEI_DEV_POWERING_DOWN || + dev->dev_state == MEI_DEV_POWER_DOWN) { cl_dbg(dev, cl, "Device is powering down, don't bother with disconnection\n"); mei_cl_set_disconnected(cl); return 0; diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index bcee77768b91..5c8cb679b997 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c @@ -303,9 +303,12 @@ void mei_stop(struct mei_device *dev) dev_dbg(dev->dev, "stopping the device.\n"); mutex_lock(&dev->device_lock); - mei_set_devstate(dev, MEI_DEV_POWER_DOWN); + mei_set_devstate(dev, MEI_DEV_POWERING_DOWN); mutex_unlock(&dev->device_lock); mei_cl_bus_remove_devices(dev); + mutex_lock(&dev->device_lock); + mei_set_devstate(dev, MEI_DEV_POWER_DOWN); + mutex_unlock(&dev->device_lock); mei_cancel_work(dev); diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 8c395bfdf6f3..585a6f615bf8 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h @@ -57,6 +57,7 @@ enum mei_dev_state { MEI_DEV_ENABLED, MEI_DEV_RESETTING, MEI_DEV_DISABLED, + MEI_DEV_POWERING_DOWN, MEI_DEV_POWER_DOWN, MEI_DEV_POWER_UP }; -- 2.26.2