Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1334312lqt; Tue, 19 Mar 2024 23:48:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrrSJnqrsu7XAxf4lZpL/7c8NHIM+QmIaP4cAAad10EZcXsuAhSHoEwBM9KMDgTAy7QdB8xbwbmSP0p/Hpgjqz4o26HwBY+fkg/dXSiQ== X-Google-Smtp-Source: AGHT+IHEtftjKBmoL9DpYrD3+olhPZby9jDsioJ9GB4GishVMNP3U4RGKcjWNJh9OZ4/pui8wz3j X-Received: by 2002:a05:6214:242a:b0:696:4656:f92b with SMTP id gy10-20020a056214242a00b006964656f92bmr724349qvb.63.1710917314723; Tue, 19 Mar 2024 23:48:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710917314; cv=pass; d=google.com; s=arc-20160816; b=BeF51LDaaWZuKDnOAysQouSmgf8d8Uz00HPa2wRN07AC8cQ6cYx5ILxhsEfIVC1mfT SmsSxpVFBA0TrUa7GjO9mlbLeCxMpnuNB0x03cUk3vRB843ySNb6S39Vt9UrSOeNHcuG 3ddaxDxSDNLSihBjUB0HXbIPbEiF+uRe2M5xEep0WNimG9eFtKglwjYan45P4h/wYBOu Iq5DfeKKOafEfcU1m4ZFfz/B74I8AoHCoazQ+iFqr+mJZGfEfRbUORxKoTH1xl0c0mZ5 rFj3Kmv3Z811lCQCEUjF0fHCz8js2Xv45D0dXcqA0ZnZaQy5C8tjm7NhGKtL0XpGXnfs SY2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=x/d7hMlJDHp5Snw9mPRxXhVnDDYN9VVC5ff32isofM8=; fh=kh/skOlk6xZzGs2WrwlUCty+Grq9jravT995goHZ/ZA=; b=SUGaNzhOi3z4tf28HYuYnBayYsMOljXHTxlZyNFQFDZu0QdCI4AGqrfN3nFXpx+G5X XkAEs5NwUDujYUaLirvCPF/T9Cx4g6UQwf8WvlbLJMxysK3nNRY3I8Ic0DghHEKx+jR+ gDEFkOzId8mw+epy5RLe6i4UMCtWcOlTQdhOnlaPbg1k4sPIKERbEWKyludUyV9+1QHg ZbeafH9KFefr1Qq3/tct2F3nMU+9tXeqOP7DwGyDdEenV+p4MDe7Bw1EHqAYIy2Cp0zo U0a1BvfAY6AQrMxYCe4hEZSL9+CuiYze2dgI16Be0WETrhudEnQNnGbDPhAAvEHxWNbP J3bQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XtgOwAro; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-108504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 4-20020a056214202400b0068d0c6f5766si12890313qvf.515.2024.03.19.23.48.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 23:48:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XtgOwAro; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-108504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 722E61C21D85 for ; Wed, 20 Mar 2024 06:48:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C16414291; Wed, 20 Mar 2024 06:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XtgOwAro" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF423A3D for ; Wed, 20 Mar 2024 06:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710917307; cv=none; b=DtH98/lL4FY4OeL/Xy1D4CG9VZfmFWlJNAJclB63AwTR5GQwq6xS9U5GOvmnKjnKqn2Ke5hv79os9VJS8IpGPzCB+wYqCKh06vMMSN4JRO8iJFrSXjpy8dQuNE+B8uUsjmoVkR+c+cOZxZ4iz5Ty2MthwDYMIXAnanRWuHBi5PQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710917307; c=relaxed/simple; bh=6ElfNOZ/XMwu2COTpMx7a93NqGekxxAWzc7Fzup9NoA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=tZFZS3NDNQP2I7gvUIkcogQcIkFmAMQ2OtEbxRIil6AMleGb56cTPSej/sgIGwWOz671nPaTTzT4vHdE1MGoosnwJE2tPbVyLWw1WOoyQLwGXKFnGRa/mVPP03igKa6wmzK2rT6Le3091IPmCA3QNHbO0WHIM966yKOBB3oD2B8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XtgOwAro; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710917305; x=1742453305; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6ElfNOZ/XMwu2COTpMx7a93NqGekxxAWzc7Fzup9NoA=; b=XtgOwAroc1hQxea6zMaUZ6P472XX7hGzDFEqp829jFmD5rF3G7q8+7Lx xzwL1n+t6FKTvrH6/CowN4mL9KsfqbT9oXjRsGPZZbjQSWSyK5ulRXdYN iXFGfZvVuiCvhP0ksvPkD/p+B3LPFG95WFP0OFfKNpSLZdKKVox8sgb7i wrpXBPHJu6BSDnO1CzC1sBTuli9IOREL3MqYiTPsL04dlNyF2Gsrevy4q moZxwqDhr5ywnQMNHAyYRiXXK5868CpDb42vbLbQpC3GK1NjON7VSLoYi X30ElpAALKZfvtvGEwOYWxRzk6M+iEuyPXndaoY3B6GVBaf85kjTdigme g==; X-IronPort-AV: E=McAfee;i="6600,9927,11018"; a="16560646" X-IronPort-AV: E=Sophos;i="6.07,139,1708416000"; d="scan'208";a="16560646" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2024 23:48:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,139,1708416000"; d="scan'208";a="13949009" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2024 23:48:23 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 419CA11F853; Wed, 20 Mar 2024 08:48:20 +0200 (EET) Received: from sailus by punajuuri.localdomain with local (Exim 4.96) (envelope-from ) id 1rmpkK-00DhVN-0l; Wed, 20 Mar 2024 08:48:20 +0200 From: Sakari Ailus To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Wentong Wu , Dominik Brodowski Subject: [PATCH RESEND 1/1] mei: vsc: Unregister interrupt handler for system suspend Date: Wed, 20 Mar 2024 08:48:10 +0200 Message-Id: <20240320064810.3265489-1-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Unregister the MEI VSC interrupt handler before system suspend and re-register it at system resume time. This mirrors implementation of other MEI devices. This patch fixes the bug that causes continuous stream of MEI VSC errors after system resume. Fixes: 386a766c4169 ("mei: Add MEI hardware support for IVSC device") Cc: stable@vger.kernel.org # for 6.8 Reported-by: Dominik Brodowski Signed-off-by: Wentong Wu Signed-off-by: Sakari Ailus --- drivers/misc/mei/platform-vsc.c | 17 ++++++- drivers/misc/mei/vsc-tp.c | 84 +++++++++++++++++++++++---------- drivers/misc/mei/vsc-tp.h | 3 ++ 3 files changed, 78 insertions(+), 26 deletions(-) diff --git a/drivers/misc/mei/platform-vsc.c b/drivers/misc/mei/platform-vsc.c index 8d303c6c0000..8db0fcf24e70 100644 --- a/drivers/misc/mei/platform-vsc.c +++ b/drivers/misc/mei/platform-vsc.c @@ -402,25 +402,40 @@ static int mei_vsc_remove(struct platform_device *pdev) static int mei_vsc_suspend(struct device *dev) { struct mei_device *mei_dev = dev_get_drvdata(dev); + struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev); mei_stop(mei_dev); + mei_disable_interrupts(mei_dev); + + vsc_tp_free_irq(hw->tp); + return 0; } static int mei_vsc_resume(struct device *dev) { struct mei_device *mei_dev = dev_get_drvdata(dev); + struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev); int ret; - ret = mei_restart(mei_dev); + ret = vsc_tp_request_irq(hw->tp); if (ret) return ret; + ret = mei_restart(mei_dev); + if (ret) + goto err_free; + /* start timer if stopped in suspend */ schedule_delayed_work(&mei_dev->timer_work, HZ); return 0; + +err_free: + vsc_tp_free_irq(hw->tp); + + return ret; } static DEFINE_SIMPLE_DEV_PM_OPS(mei_vsc_pm_ops, mei_vsc_suspend, mei_vsc_resume); diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 03486bebae09..870c70ef3bb8 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -94,6 +94,27 @@ static const struct acpi_gpio_mapping vsc_tp_acpi_gpios[] = { {} }; +static irqreturn_t vsc_tp_isr(int irq, void *data) +{ + struct vsc_tp *tp = data; + + atomic_inc(&tp->assert_cnt); + + wake_up(&tp->xfer_wait); + + return IRQ_WAKE_THREAD; +} + +static irqreturn_t vsc_tp_thread_isr(int irq, void *data) +{ + struct vsc_tp *tp = data; + + if (tp->event_notify) + tp->event_notify(tp->event_notify_context); + + return IRQ_HANDLED; +} + /* wakeup firmware and wait for response */ static int vsc_tp_wakeup_request(struct vsc_tp *tp) { @@ -383,6 +404,37 @@ int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb, } EXPORT_SYMBOL_NS_GPL(vsc_tp_register_event_cb, VSC_TP); +/** + * vsc_tp_request_irq - request irq for vsc_tp device + * @tp: vsc_tp device handle + */ +int vsc_tp_request_irq(struct vsc_tp *tp) +{ + struct spi_device *spi = tp->spi; + struct device *dev = &spi->dev; + int ret; + + irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); + ret = request_threaded_irq(spi->irq, vsc_tp_isr, vsc_tp_thread_isr, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + dev_name(dev), tp); + if (ret) + return ret; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(vsc_tp_request_irq, VSC_TP); + +/** + * vsc_tp_free_irq - free irq for vsc_tp device + * @tp: vsc_tp device handle + */ +void vsc_tp_free_irq(struct vsc_tp *tp) +{ + free_irq(tp->spi->irq, tp); +} +EXPORT_SYMBOL_NS_GPL(vsc_tp_free_irq, VSC_TP); + /** * vsc_tp_intr_synchronize - synchronize vsc_tp interrupt * @tp: vsc_tp device handle @@ -413,27 +465,6 @@ void vsc_tp_intr_disable(struct vsc_tp *tp) } EXPORT_SYMBOL_NS_GPL(vsc_tp_intr_disable, VSC_TP); -static irqreturn_t vsc_tp_isr(int irq, void *data) -{ - struct vsc_tp *tp = data; - - atomic_inc(&tp->assert_cnt); - - wake_up(&tp->xfer_wait); - - return IRQ_WAKE_THREAD; -} - -static irqreturn_t vsc_tp_thread_isr(int irq, void *data) -{ - struct vsc_tp *tp = data; - - if (tp->event_notify) - tp->event_notify(tp->event_notify_context); - - return IRQ_HANDLED; -} - static int vsc_tp_match_any(struct acpi_device *adev, void *data) { struct acpi_device **__adev = data; @@ -485,10 +516,9 @@ static int vsc_tp_probe(struct spi_device *spi) tp->spi = spi; irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); - ret = devm_request_threaded_irq(dev, spi->irq, vsc_tp_isr, - vsc_tp_thread_isr, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - dev_name(dev), tp); + ret = request_threaded_irq(spi->irq, vsc_tp_isr, vsc_tp_thread_isr, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + dev_name(dev), tp); if (ret) return ret; @@ -522,6 +552,8 @@ static int vsc_tp_probe(struct spi_device *spi) err_destroy_lock: mutex_destroy(&tp->mutex); + free_irq(spi->irq, tp); + return ret; } @@ -532,6 +564,8 @@ static void vsc_tp_remove(struct spi_device *spi) platform_device_unregister(tp->pdev); mutex_destroy(&tp->mutex); + + free_irq(spi->irq, tp); } static const struct acpi_device_id vsc_tp_acpi_ids[] = { diff --git a/drivers/misc/mei/vsc-tp.h b/drivers/misc/mei/vsc-tp.h index f9513ddc3e40..14ca195cbddc 100644 --- a/drivers/misc/mei/vsc-tp.h +++ b/drivers/misc/mei/vsc-tp.h @@ -37,6 +37,9 @@ int vsc_tp_xfer(struct vsc_tp *tp, u8 cmd, const void *obuf, size_t olen, int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb, void *context); +int vsc_tp_request_irq(struct vsc_tp *tp); +void vsc_tp_free_irq(struct vsc_tp *tp); + void vsc_tp_intr_enable(struct vsc_tp *tp); void vsc_tp_intr_disable(struct vsc_tp *tp); void vsc_tp_intr_synchronize(struct vsc_tp *tp); -- 2.39.2