From nobody Sat Sep 26 18:54:51 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 91D9F3E5A0B for ; Mon, 31 Aug 2026 11:38:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176325; cv=none; b=WkiLec76RrTwuwTWj2RqgaJ+RbXfaPhH/Wa21qlB0tRISQU/whbE3tgFQYe7d/tgi+sU++W7ue6JyAB108coMTi3wW3hZ0seGUaFvjENLLM1ldMHClccAF6A4Lt1XjqfcNSHCUJ4GBaQSBd+IF+hJAH3Qx3tLoN3Bj4XQEk6QW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176325; c=relaxed/simple; bh=hwmMhCYK3a8hrYjtNGCx1Y4KisTSk2GO7CBfRf7aNxU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iXZyXa2Ib8DIFjAzpIH9bvYXdCQ5G0TYdoeMKsFzPhg80RBfb5UHpLvSM14AIgUgSuOkmn15oCLefxVRBjGYDD3Rdwk2CYdL/JvKRv08RBIBFPIxAR+I3hF4uNRgvVvWs34iQzJFdZmdTtu3TR8gkquDdpcFJVyebGsox4Up3AE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nu1auKKG; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nu1auKKG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788176323; x=1819712323; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hwmMhCYK3a8hrYjtNGCx1Y4KisTSk2GO7CBfRf7aNxU=; b=nu1auKKGWBVV9hPXVEh1Yr3evGMqYFxDtRD2BYygCyeyxCZIbT2jPCF3 ks3BNSXQWPYWbis89+Cs39hxeE2N6jvS3w+mgcKO3j/x4zPzb6ZAk50Ib 0tYzx9EAzPezzNMFCn0LrZLnN/y1LtMG/ZY4tg+U8K2ZQYrFdScw+pVt4 bhPo4sRnXR9ql1+He9kw9HUbzL7XBUlKHSNAI9JhkwgLpcQ5YwlTdS4WB 9xIosgNkGZXjj7sOmNlko8xl2/YSYAx2vNbRX2KGxjz2LtNS4R0zsC8Yd zVezjdqpii5uGN6GlgkuYTduJbnAaQIAzKRH/qROC1TyutdmxpvE8p5pQ A==; X-CSE-ConnectionGUID: cFALQ5q3TWiPkw9wUqhj6Q== X-CSE-MsgGUID: tzwnlRaFTS6Az9ZL1JHtiA== X-IronPort-AV: E=McAfee;i="6800,10657,11891"; a="76129324" X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="76129324" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:43 -0700 X-CSE-ConnectionGUID: QMHlCdtdRyifUEhbDWpOeg== X-CSE-MsgGUID: BPA5cbmWQ+mYfrX121x9gQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="262645106" Received: from sannilnx-dsk.jer.intel.com (HELO [127.0.1.1]) ([10.12.231.107]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:42 -0700 From: Alexander Usyskin Date: Mon, 31 Aug 2026 14:38:31 +0300 Subject: [PATCH char-misc-next 1/4] mei: make polling wait interruptible Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-cri_polling-v1-1-d927315e6598@intel.com> References: <20260831-cri_polling-v1-0-d927315e6598@intel.com> In-Reply-To: <20260831-cri_polling-v1-0-d927315e6598@intel.com> To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Alexander Usyskin , Menachem Adin X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788176320; l=1426; i=alexander.usyskin@intel.com; s=20260315; h=from:subject:message-id; bh=hwmMhCYK3a8hrYjtNGCx1Y4KisTSk2GO7CBfRf7aNxU=; b=MddRt+qCW2c6GwWqb/yDM5MGm37nqt1wnc+ETtVg+MMIKn4NBa2aMU8TpGU4QHBN5k09gDgzu bkHRPMZK7L1Ctp5um1H+vAH7KUIFcQ/mWS3ICrkkeBWci9yrHJ0J6lV X-Developer-Key: i=alexander.usyskin@intel.com; a=ed25519; pk=X+qoF/nFCdDOV04IForWSxnkyoCAbUE10egZi6PSfcU= Polling thread wait should be interruptible to avoid stuck task. Reviewed-by: Menachem Adin Signed-off-by: Alexander Usyskin --- drivers/misc/mei/gsc-me.c | 2 +- drivers/misc/mei/hw-me.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/mei/gsc-me.c b/drivers/misc/mei/gsc-me.c index 376840b2c354..b38ddb04f2e8 100644 --- a/drivers/misc/mei/gsc-me.c +++ b/drivers/misc/mei/gsc-me.c @@ -242,7 +242,7 @@ static int __maybe_unused mei_gsc_pm_runtime_resume(str= uct device *device) =20 if (mei_me_hw_use_polling(hw)) { hw->is_active =3D true; - wake_up(&hw->wait_active); + wake_up_interruptible(&hw->wait_active); } =20 mutex_unlock(&dev->device_lock); diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index e7fbc02fb70f..ef7e1289ad7e 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c @@ -1441,9 +1441,9 @@ int mei_me_polling_thread(void *_dev) struct mei_me_hw *hw =3D to_me_hw(dev); u32 hcsr; =20 - wait_event_timeout(hw->wait_active, - hw->is_active || kthread_should_stop(), - msecs_to_jiffies(MEI_POLLING_TIMEOUT_IDLE)); + wait_event_interruptible_timeout(hw->wait_active, + hw->is_active || kthread_should_stop(), + msecs_to_jiffies(MEI_POLLING_TIMEOUT_IDLE)); =20 if (kthread_should_stop()) break; --=20 2.53.0 From nobody Sat Sep 26 18:54:51 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 B43063F39EE for ; Mon, 31 Aug 2026 11:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176326; cv=none; b=TASVN0sSBrpBqS338+ZuxGIeasptpybO5KZAJhtQwYkRlLf6rOBZyDDENM3mCdtZX/hhgW7X167+0ggFlklIaK7oC+G3POJHV1umlGGqAdiTfiaWkNrJdn/WQUTWTDLZU6yKrj6TsbDqfCSso5xbSXyL0EUEqBKcpNHoC+rRm1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176326; c=relaxed/simple; bh=G2wkGOHoI0v2yjNnkkXd5xcOv4EsesC6pU3GWngMgNQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XH33v9vNOI0xIfeyYM8audheshvd5uDFjgos3uGYE3na9v09M22RGDpfAk+7ZpC2gmpRq8VrJc1UnyUFXhS+p9jlMCkkJtVAyWuo/7LYlBUmAiTkeej3gZjvr5smNZlUgo3l+zPkBJs88v/IxmQD8BFilqeua2tRPGXBqy+D7I0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RwFGXqWj; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RwFGXqWj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788176325; x=1819712325; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=G2wkGOHoI0v2yjNnkkXd5xcOv4EsesC6pU3GWngMgNQ=; b=RwFGXqWj4OyxE/nhLL24Mn9LiqZgLNJSbYfe+/WegAcvxlqWu0Ia08Yd cwmRjQy/GAsGz7GuyYKlQWLhWZ+1FfE3W9q+VH/J9dZZjWhJ4b1/TvRDA gYLiS8JbBltWfO4bo1/prgHhd6LOJnkK7Abr3Qtd7/PMjycS76iO22iuU dMrAysZciA7CxIqEjhuGniY2w/RMHomihy42/h9S8RAK7VoWv70lVjK65 jJDit90ceuCWklg8UYy3yWcpBodmCPS1vfgnLDVRnfVfhVfucmFu3J4Fm 22us7UXpkD5Hu2NsuAyg8N0UwKdW2hM+iMDXK/q9fk3vl/OGxmWA/O+vw Q==; X-CSE-ConnectionGUID: 2clFmcEjSe22ps+Oi20Kug== X-CSE-MsgGUID: mfEToKmYRjuc0dgLz4T2Eg== X-IronPort-AV: E=McAfee;i="6800,10657,11891"; a="76129328" X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="76129328" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:44 -0700 X-CSE-ConnectionGUID: KuzqMe6cSmuTIfjlhiXH2w== X-CSE-MsgGUID: sfOAddfkSw29DUwnij687w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="262645109" Received: from sannilnx-dsk.jer.intel.com (HELO [127.0.1.1]) ([10.12.231.107]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:43 -0700 From: Alexander Usyskin Date: Mon, 31 Aug 2026 14:38:32 +0300 Subject: [PATCH char-misc-next 2/4] mei: csc: add option for polling and enable it Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-cri_polling-v1-2-d927315e6598@intel.com> References: <20260831-cri_polling-v1-0-d927315e6598@intel.com> In-Reply-To: <20260831-cri_polling-v1-0-d927315e6598@intel.com> To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Alexander Usyskin , Menachem Adin X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788176320; l=4439; i=alexander.usyskin@intel.com; s=20260315; h=from:subject:message-id; bh=G2wkGOHoI0v2yjNnkkXd5xcOv4EsesC6pU3GWngMgNQ=; b=eS/DlOklX26covREgrskhc+4UfKyb6FVznXt6ioU5c+3jCUHLjeq2asVVT4LnGvnli00Ajc1p M2QTf+G5FD6AVQhC0QOHQ0X+Nbnipmbp0WaWM9WXnow4KNco3GQI7VY X-Developer-Key: i=alexander.usyskin@intel.com; a=ed25519; pk=X+qoF/nFCdDOV04IForWSxnkyoCAbUE10egZi6PSfcU= Add option to poll instead of waiting for the interrupt to wallpaper over hardware not releasing the interrupt line. Enable this workaround and leave option to use interrupts when hardware is fixed. Reviewed-by: Menachem Adin Signed-off-by: Alexander Usyskin --- drivers/misc/mei/pci-csc.c | 71 +++++++++++++++++++++++++++++++++++-------= ---- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/drivers/misc/mei/pci-csc.c b/drivers/misc/mei/pci-csc.c index 6e1e8008f267..f50ef93e27dc 100644 --- a/drivers/misc/mei/pci-csc.c +++ b/drivers/misc/mei/pci-csc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,10 @@ =20 #define MEI_CSC_HECI2_OFFSET 0x1000 =20 +static bool use_polling =3D true; +module_param(use_polling, bool, 0600); +MODULE_PARM_DESC(use_polling, "Use polling instead of interrupts"); + static int mei_csc_read_fws(const struct mei_device *mdev, int where, cons= t char *name, u32 *val) { struct mei_me_hw *hw =3D to_me_hw(mdev); @@ -87,20 +92,40 @@ static int mei_csc_probe(struct pci_dev *pdev, const st= ruct pci_device_id *ent) =20 pci_set_drvdata(pdev, mdev); =20 - err =3D pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_INTX | PCI_IRQ_MSI); - if (err < 0) { - dev_err_probe(dev, err, "Failed to allocate IRQ.\n"); - goto err_mei_unreg; + if (use_polling) { + dev_dbg(dev, "Using polling thread\n"); + hw->irq =3D -1; } =20 - hw->irq =3D pci_irq_vector(pdev, 0); - - /* request and enable interrupt */ - err =3D request_threaded_irq(hw->irq, - mei_me_irq_quick_handler, mei_me_irq_thread_handler, - IRQF_SHARED | IRQF_ONESHOT, KBUILD_MODNAME, mdev); - if (err) - goto err_free_irq_vectors; + /* use polling */ + if (mei_me_hw_use_polling(hw)) { + mei_disable_interrupts(mdev); + mei_clear_interrupts(mdev); + init_waitqueue_head(&hw->wait_active); + hw->is_active =3D true; /* start in active mode for initialization */ + hw->polling_thread =3D kthread_run(mei_me_polling_thread, mdev, + "kmecscirqd/%s", dev_name(dev)); + if (IS_ERR(hw->polling_thread)) { + err =3D PTR_ERR(hw->polling_thread); + dev_err_probe(dev, err, "unable to create kernel thread.\n"); + goto err_mei_unreg; + } + } else { + err =3D pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_INTX | PCI_IRQ_MSI); + if (err < 0) { + dev_err_probe(dev, err, "Failed to allocate IRQ.\n"); + goto err_mei_unreg; + } + + hw->irq =3D pci_irq_vector(pdev, 0); + + /* request and enable interrupt */ + err =3D request_threaded_irq(hw->irq, + mei_me_irq_quick_handler, mei_me_irq_thread_handler, + IRQF_SHARED | IRQF_ONESHOT, KBUILD_MODNAME, mdev); + if (err) + goto err_free_irq_vectors; + } =20 /* * Continue to char device setup in spite of firmware handshake failure. @@ -126,7 +151,8 @@ static int mei_csc_probe(struct pci_dev *pdev, const st= ruct pci_device_id *ent) return 0; =20 err_free_irq_vectors: - pci_free_irq_vectors(pdev); + if (!mei_me_hw_use_polling(hw)) + pci_free_irq_vectors(pdev); err_mei_unreg: mei_deregister(mdev); return err; @@ -141,9 +167,14 @@ static void mei_csc_shutdown(struct pci_dev *pdev) =20 mei_stop(mdev); =20 + if (mei_me_hw_use_polling(hw)) + kthread_stop(hw->polling_thread); + mei_disable_interrupts(mdev); - free_irq(hw->irq, mdev); - pci_free_irq_vectors(pdev); + if (!mei_me_hw_use_polling(hw)) { + free_irq(hw->irq, mdev); + pci_free_irq_vectors(pdev); + } } =20 static void mei_csc_remove(struct pci_dev *pdev) @@ -210,6 +241,9 @@ static int mei_csc_pm_runtime_suspend(struct device *de= v) return -EAGAIN; =20 hw->pg_state =3D MEI_PG_ON; + if (mei_me_hw_use_polling(hw)) + hw->is_active =3D false; + return 0; } =20 @@ -219,8 +253,13 @@ static int mei_csc_pm_runtime_resume(struct device *de= v) struct mei_me_hw *hw =3D to_me_hw(mdev); irqreturn_t irq_ret; =20 - scoped_guard(mutex, &mdev->device_lock) + scoped_guard(mutex, &mdev->device_lock) { hw->pg_state =3D MEI_PG_OFF; + if (mei_me_hw_use_polling(hw)) { + hw->is_active =3D true; + wake_up_interruptible(&hw->wait_active); + } + } =20 /* Process all queues that wait for resume */ irq_ret =3D mei_me_irq_thread_handler(1, mdev); --=20 2.53.0 From nobody Sat Sep 26 18:54:51 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 4E5583F4DC5 for ; Mon, 31 Aug 2026 11:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176328; cv=none; b=WfzS7OTPkBCwQiI0fl+40bszINV7ni5unbf3mI0dk59UXlb0XyUONWp6v0yiPrro8+tpmllQU8eMigvvzS2mueMaAQoa3vjWW4j3OvLjd+OX2z2P1838YNK+DorenISKD1VVumXjQqhCNvkTQmbaI9aegccHGrdtWoUqOFwHhvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176328; c=relaxed/simple; bh=Tz+k3ne/kB51P7Czgm9pe3f0ZMF20JJimKgMhl8hJhg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I8bBikH4G3mmhhZRgS+bSJ7zYPdfYSSBAe9AS2xGwxA+lEELAx4M6FXi5OQUgXm1jTZeVJd+Mu455aMLZNTeNAGVAI/IX1gAmDnCfmzZ9LrE3r1Hz944XRaOP5PrN0KX8nG+HRrB+AbaAjkYyDRZpr7C8/nUrGUW4e5Gx4oN3n8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MHsOyikh; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MHsOyikh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788176326; x=1819712326; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Tz+k3ne/kB51P7Czgm9pe3f0ZMF20JJimKgMhl8hJhg=; b=MHsOyikhhJhbAt3ZSM/FCr6c2hxQTGsCW8MF/GIuYDHRjM6M6rwHyfet 6T5IzzvtHNePeN4et2Rp9OO/aKmefhI/kxmwfnOwxNnylZoPosdguA979 3FkqPWvhAXpSFkILUEwtwoI8NDJuA/Qhwe5vk+gpDxJhosdpDhNmUx47c eqsFyKQMco3skNt0QtYzerODuXAJaGyty1dSJYR2JPO6Qqm8jUEqJsThP mHjZHqMXF5ngEg58+qNPDTFz7I9ZQZHIhxkAoo8qvVBT1poVcgLvvUnFA jwTJ8m21ImF6x77Stfyv0nuBxKgr7E33jUTLwEXXn96g7y20WFKp2pieV A==; X-CSE-ConnectionGUID: hbxxu1xOQ1Wij8sHGSsy4g== X-CSE-MsgGUID: LcqLsomsTPyARoC7pJl20w== X-IronPort-AV: E=McAfee;i="6800,10657,11891"; a="76129331" X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="76129331" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:46 -0700 X-CSE-ConnectionGUID: o7N+LDchRFeaPCF4CKMqHQ== X-CSE-MsgGUID: 2jrTmbfhT9CeMFXxyHxNGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="262645114" Received: from sannilnx-dsk.jer.intel.com (HELO [127.0.1.1]) ([10.12.231.107]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:45 -0700 From: Alexander Usyskin Date: Mon, 31 Aug 2026 14:38:33 +0300 Subject: [PATCH char-misc-next 3/4] mei: me: avoid hw access in polling when not active Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-cri_polling-v1-3-d927315e6598@intel.com> References: <20260831-cri_polling-v1-0-d927315e6598@intel.com> In-Reply-To: <20260831-cri_polling-v1-0-d927315e6598@intel.com> To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Alexander Usyskin , Menachem Adin X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788176320; l=5493; i=alexander.usyskin@intel.com; s=20260315; h=from:subject:message-id; bh=Tz+k3ne/kB51P7Czgm9pe3f0ZMF20JJimKgMhl8hJhg=; b=mjB85NcrJqjiblt4v/r9jWIXm40wM28xnph6vsGu8gSL8poSzDWnS1pjS4T65tGKb0OuRRg/z K2PGEVYh+8rCROJJh9/vCgS/3U4rMQfex5a9qLlhldUQ0+p1PW44hML X-Developer-Key: i=alexander.usyskin@intel.com; a=ed25519; pk=X+qoF/nFCdDOV04IForWSxnkyoCAbUE10egZi6PSfcU= Polling thread should not access hardware when not active. Check for active state under device lock to avoid such access when hardware is powered down. Reviewed-by: Menachem Adin Signed-off-by: Alexander Usyskin --- drivers/misc/mei/hw-me.c | 99 +++++++++++++++++++++++++++++---------------= ---- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index ef7e1289ad7e..f3d833be0e1a 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c @@ -5,6 +5,7 @@ */ =20 #include +#include #include #include #include @@ -1290,28 +1291,15 @@ irqreturn_t mei_me_irq_quick_handler(int irq, void = *dev_id) } EXPORT_SYMBOL_GPL(mei_me_irq_quick_handler); =20 -/** - * mei_me_irq_thread_handler - function called after ISR to handle the int= errupt - * processing. - * - * @irq: The irq number - * @dev_id: pointer to the device structure - * - * Return: irqreturn_t - * - */ -irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id) +static irqreturn_t __mei_me_irq_thread_handler(struct mei_device *dev) { - struct mei_device *dev =3D (struct mei_device *) dev_id; struct list_head cmpl_list; bool pg_blocked; s32 slots; u32 hcsr; int rets =3D 0; =20 - dev_dbg(&dev->dev, "function called after ISR to handle the interrupt pro= cessing.\n"); /* initialize our complete list */ - mutex_lock(&dev->device_lock); =20 hcsr =3D mei_hcsr_read(dev); me_intr_clear(dev, hcsr); @@ -1406,13 +1394,33 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void= *dev_id) end: dev_dbg(&dev->dev, "interrupt thread end ret =3D %d\n", rets); mei_me_intr_enable(dev); - mutex_unlock(&dev->device_lock); return IRQ_HANDLED; } + +/** + * mei_me_irq_thread_handler - function called after ISR to handle the int= errupt + * processing. + * + * @irq: The irq number + * @dev_id: pointer to the device structure + * + * Return: irqreturn_t + * + */ +irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id) +{ + struct mei_device *dev =3D (struct mei_device *) dev_id; + + dev_dbg(&dev->dev, "function called after ISR to handle the interrupt pro= cessing.\n"); + + guard(mutex)(&dev->device_lock); + + return __mei_me_irq_thread_handler(dev); +} EXPORT_SYMBOL_GPL(mei_me_irq_thread_handler); =20 -#define MEI_POLLING_TIMEOUT_ACTIVE 100 -#define MEI_POLLING_TIMEOUT_IDLE 500 +#define MEI_POLL_ACTIVE_MS 100 +#define MEI_POLL_IDLE_MS 500 =20 /** * mei_me_polling_thread - interrupt register polling thread @@ -1420,48 +1428,59 @@ EXPORT_SYMBOL_GPL(mei_me_irq_thread_handler); * @_dev: mei device * * The thread monitors the interrupt source register and calls - * mei_me_irq_thread_handler() to handle the firmware + * __mei_me_irq_thread_handler() to handle the firmware * input. * - * The function polls in MEI_POLLING_TIMEOUT_ACTIVE timeout + * The function polls in MEI_POLL_ACTIVE_MS timeout * in case there was an event, in idle case the polling - * time increases yet again by MEI_POLLING_TIMEOUT_ACTIVE - * up to MEI_POLLING_TIMEOUT_IDLE. + * time increases yet again by MEI_POLL_ACTIVE_MS + * up to MEI_POLL_IDLE_MS. * * Return: always 0 */ int mei_me_polling_thread(void *_dev) { struct mei_device *dev =3D _dev; - irqreturn_t irq_ret; - long polling_timeout =3D MEI_POLLING_TIMEOUT_ACTIVE; + long polling_timeout =3D MEI_POLL_ACTIVE_MS; + bool have_interrupt; =20 dev_dbg(&dev->dev, "kernel thread is running\n"); while (!kthread_should_stop()) { struct mei_me_hw *hw =3D to_me_hw(dev); u32 hcsr; =20 - wait_event_interruptible_timeout(hw->wait_active, - hw->is_active || kthread_should_stop(), - msecs_to_jiffies(MEI_POLLING_TIMEOUT_IDLE)); + if (!hw->is_active) + wait_event_interruptible(hw->wait_active, + hw->is_active || kthread_should_stop()); + else + wait_event_interruptible_timeout(hw->wait_active, + hw->is_active || kthread_should_stop(), + msecs_to_jiffies(MEI_POLL_IDLE_MS)); =20 if (kthread_should_stop()) break; =20 - hcsr =3D mei_hcsr_read(dev); - if (me_intr_src(hcsr)) { - polling_timeout =3D MEI_POLLING_TIMEOUT_ACTIVE; - irq_ret =3D mei_me_irq_thread_handler(1, dev); - if (irq_ret !=3D IRQ_HANDLED) - dev_err(&dev->dev, "irq_ret %d\n", irq_ret); - } else { - /* - * Increase timeout by MEI_POLLING_TIMEOUT_ACTIVE - * up to MEI_POLLING_TIMEOUT_IDLE - */ - polling_timeout =3D clamp_val(polling_timeout + MEI_POLLING_TIMEOUT_ACT= IVE, - MEI_POLLING_TIMEOUT_ACTIVE, - MEI_POLLING_TIMEOUT_IDLE); + scoped_guard(mutex, &dev->device_lock) { + if (!hw->is_active) { + have_interrupt =3D false; + } else { + hcsr =3D mei_hcsr_read(dev); + have_interrupt =3D !!me_intr_src(hcsr); + } + + if (have_interrupt) { + polling_timeout =3D MEI_POLL_ACTIVE_MS; + dev_dbg(&dev->dev, "polling interrupt processing\n"); + __mei_me_irq_thread_handler(dev); + } else { + /* + * Increase timeout by MEI_POLL_ACTIVE_MS + * up to MEI_POLL_IDLE_MS + */ + polling_timeout =3D clamp_val(polling_timeout + MEI_POLL_ACTIVE_MS, + MEI_POLL_ACTIVE_MS, + MEI_POLL_IDLE_MS); + } } =20 schedule_timeout_interruptible(msecs_to_jiffies(polling_timeout)); --=20 2.53.0 From nobody Sat Sep 26 18:54:51 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 D44A53F660D for ; Mon, 31 Aug 2026 11:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176329; cv=none; b=lT3pW5Db35V+MDSAvBxTduUY631ApQKS0dpTRkATwZ3E22GFUXBFVcoM4G8ZFf0CQtYPNxN4cpmmms7AceBwY0VyPMAp1epws+xg1RICXOK7HT4z43vBCsr2YmZoIqrXYhaTKMVQK8xhguwhxFzywr6aLOLHBFHK/GLJCb19SS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788176329; c=relaxed/simple; bh=0lqRixQx8HKxz8ZeamIlgys7DhhVCsN7PWVK8RrLMs0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VYvAsDitLgrwosodST/wqov/AVrovHGuI7ioVTrRtb+K1HmdVOqehpNBWvn/yap7Irgns1AvzozhntUGVvrg7QgRTKqTeTc8wC/vgb9WqoelG0VC48saWUqbcJ8RnZWVQDdDGnfNqMQjeEjr/dOmlHJgPq1esHlOM9jThwXYUMA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GSV/tPMP; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GSV/tPMP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788176328; x=1819712328; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=0lqRixQx8HKxz8ZeamIlgys7DhhVCsN7PWVK8RrLMs0=; b=GSV/tPMPASMsFb8Vr76hQaLA7pMfA7jXja/V3l6YwH37gQtA6XgWjzWf m/sCOysXtijVLNGbMjVxsZCXpCfGl4TVUyMVJ8zyEJwtrMxV0NJhI6ipR Hc7UNgegxFziR5L395On4NeHxv3mS5N+fSPHwJUV40bkacF+zkK4vhhvt sT7wIFGd4HbS66ua6SYGJ3HOSJwv4d3vDtfCB+n3F9R/mH8O5UCi+DoZ4 SWAnMHA1Rc4LKAloVpokqY5BeJSsmFEFOoJhD+jnZ6D1Je+5ms+Qw5U55 5gYT6H4QgDuaq3ABFsQl9m3CvP4YEhNMDqD35Matfv5hdblRLGVT4kkXa A==; X-CSE-ConnectionGUID: uoEJDDnrSL6HpsYAGo2kqw== X-CSE-MsgGUID: jp6kqYaFQqK56ucmEiWL0w== X-IronPort-AV: E=McAfee;i="6800,10657,11891"; a="76129335" X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="76129335" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:48 -0700 X-CSE-ConnectionGUID: nyxNUT6RRZWsXWQVQ0T3+Q== X-CSE-MsgGUID: et3ok5OHShSd4zoedJm6YA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,254,1779174000"; d="scan'208";a="262645118" Received: from sannilnx-dsk.jer.intel.com (HELO [127.0.1.1]) ([10.12.231.107]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2026 04:38:46 -0700 From: Alexander Usyskin Date: Mon, 31 Aug 2026 14:38:34 +0300 Subject: [PATCH char-misc-next 4/4] mei: me: reduce active polling timeout to 20 ms Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-cri_polling-v1-4-d927315e6598@intel.com> References: <20260831-cri_polling-v1-0-d927315e6598@intel.com> In-Reply-To: <20260831-cri_polling-v1-0-d927315e6598@intel.com> To: Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Alexander Usyskin , Menachem Adin X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788176320; l=901; i=alexander.usyskin@intel.com; s=20260315; h=from:subject:message-id; bh=0lqRixQx8HKxz8ZeamIlgys7DhhVCsN7PWVK8RrLMs0=; b=PTSGJvp4oSy1G24GsqeaiqRpPq13GH6sA7qQbk5FvEbE901EG7tp8scgC2f6u4dktgT5nbsu0 LOIdljOOa74DWamza2dWmuve/iXG1yNJGduJDujsI+Vz+gtr/lULjLK X-Developer-Key: i=alexander.usyskin@intel.com; a=ed25519; pk=X+qoF/nFCdDOV04IForWSxnkyoCAbUE10egZi6PSfcU= Improve performance of polling by reducing active timeout. 20 ms active timeout helps increase channel throughtput and significately reduces data transfer times. Our tests have prooved that timeout decrease does no ill effects for core CPU utilization. Reviewed-by: Menachem Adin Signed-off-by: Alexander Usyskin --- drivers/misc/mei/hw-me.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index f3d833be0e1a..1c3ab9eb8b1b 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c @@ -1419,7 +1419,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *= dev_id) } EXPORT_SYMBOL_GPL(mei_me_irq_thread_handler); =20 -#define MEI_POLL_ACTIVE_MS 100 +#define MEI_POLL_ACTIVE_MS 20 #define MEI_POLL_IDLE_MS 500 =20 /** --=20 2.53.0