From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E158B22FF59 for ; Mon, 23 Jun 2025 08:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668659; cv=none; b=DJ/t9WkpyNAIzhk1m8IKSbd4M8PiWkq9lUIEqTTxoIRUKG+brH6r5JRIp7z36nPYsBm5RMOxkSh3YzkYH1v7AJsIXAKQEl792YwXKKvmSWowAWmHg3xFI/iGHe+OuXH2uRtpUT3JW8SDFAIVu6C7//XcbRe7R+uXjkxlOdMPADQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668659; c=relaxed/simple; bh=/uZSQ/EcB0rNwZGbsbtYX0UqygEGMdYs4umPwvkBw0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n6Du2CcLBqg7HBVeSfU0sP7S5MnFikTN1cfilzBK66vQ5qTUSA6EJ5UWv93F9+mL17j+QUCauc3JevFoSEfghPlRqDXBD5tnuDaKHcwh38gJ6lKJ1beSl7T4bPE+sQxGcvsiFCtUS/vK6LjhjzWCPEPS/lYJNZBOAH65XQfWB+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qZlmLXhw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qZlmLXhw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6AE4C4CEF2; Mon, 23 Jun 2025 08:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668658; bh=/uZSQ/EcB0rNwZGbsbtYX0UqygEGMdYs4umPwvkBw0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZlmLXhwkIjVP81t2ICRxnF6FJlEZdSpsv1p4tv++0nU+xrHF3KlrIR7u0ik3P4Zc 3vPIjk/7bIN1yPDvtVOIh1wwxSrnuoT4+2XvBwFVe0y8ohdnVg0+EZDF8DqAz/kWpi cuajgkY4KJh914Q6RwnZ8zWwCtnyZGGWmTgTHT96cJq4YjH0g7UAhtx1bxF+i4D9u2 ie6PMzNI6xfKG0P02jRuYutCgtJbmINQbBspGACedOlSbGxuwXBFoTMoeErtjapAdX 9RmH3pt7Nru5XNKKHj8ipOz5rwT1c6/ohbA7oWpC1vGx8S/6ZyL+jOiKDH73mDVTLj AVXZA+MPn1mSg== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 01/10] mei: vsc: Drop unused vsc_tp_request_irq() and vsc_tp_free_irq() Date: Mon, 23 Jun 2025 10:50:43 +0200 Message-ID: <20250623085052.12347-2-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop the unused vsc_tp_request_irq() and vsc_tp_free_irq() functions. Signed-off-by: Hans de Goede Reviewed-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 31 ------------------------------- drivers/misc/mei/vsc-tp.h | 3 --- 2 files changed, 34 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 267d0de5fade..99a55451e1fc 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -406,37 +406,6 @@ 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"); =20 -/** - * 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 =3D tp->spi; - struct device *dev =3D &spi->dev; - int ret; - - irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); - ret =3D 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 diff --git a/drivers/misc/mei/vsc-tp.h b/drivers/misc/mei/vsc-tp.h index 14ca195cbddc..f9513ddc3e40 100644 --- a/drivers/misc/mei/vsc-tp.h +++ b/drivers/misc/mei/vsc-tp.h @@ -37,9 +37,6 @@ int vsc_tp_xfer(struct vsc_tp *tp, u8 cmd, const void *ob= uf, size_t olen, int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb, void *context); =20 -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); --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 71838231840 for ; Mon, 23 Jun 2025 08:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668661; cv=none; b=G1X3/OZZY/kjx6SLgQl0ARyi+0HXtDKHjZZBjxHIkuXrx3bSN+xiQVQLZqww4Mnuimyo1IPJJ7NeDsnvu5+p61jX8hikQ4yVULHUWWtGTt6QjSTHrZgmYYjDTHj24eLNKMgaeUtnK3H/tN13R9dmLompxrwP9Fjv/2ITHbRfpOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668661; c=relaxed/simple; bh=03/CqbBBRYZh+o/TBOQRC+HPvVJ9MFfeXziT++jGwQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OB3AK8OuFolttgIPB9yZHs9HQVmT7g6xaz3XC92GCH+E+52eJPSArT34xg96grJjYKtW1OaCCY0DjUy0/ljwHgH1BrWRVp6ySYKwdk0gHyXa/HvJBL5lZkbWDtbXPuMvZGCjvGHliWrVBmGuji+10CWnKcOTIU8babBDrvwjChM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ByFQ4r9U; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ByFQ4r9U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29434C4CEED; Mon, 23 Jun 2025 08:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668661; bh=03/CqbBBRYZh+o/TBOQRC+HPvVJ9MFfeXziT++jGwQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ByFQ4r9Uxl+OLVn9qZ4PrmxbnQxAcrYthjFn/0zvMhmLjXtFiZ+mVe+iu1lB8f93g UkbFrnXkekcdr4QJQZmQG9PyXiJMbcgtHYcZhuQldBwLukm0RnJS8Rcz3OC/o9s+EH kux4wucD4TU+CBg02GKeA6LlEllNI4eEC4qD/tpT59P+2JQTh03i7w8UME/ata6tiZ 5c5NcGuhmx0iRTxPd7YKA1mDL7uM0/mixfOpYHGPBj55epHYj/t2QnNj172OuIpo+w 57lxHwTGiI7TL9WBXMsQBz3uylyXMlTbWPZ0msf4YWggf7CwLOHx7Nzvu0FTrKBCix ABhqi1IQYGF6w== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 02/10] mei: vsc: Don't re-init VSC from mei_vsc_hw_reset() on stop Date: Mon, 23 Jun 2025 10:50:44 +0200 Message-ID: <20250623085052.12347-3-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mei_vsc_hw_reset() gets called from mei_start() and mei_stop() in the latter case we do not need to re-init the VSC by calling vsc_tp_init(). mei_stop() only happens on shutdown and driver unbind. On shutdown we don't need to load + boot the firmware and if the driver later is bound to the device again then mei_start() will do another reset. The intr_enable flag is true when called from mei_start() and false on mei_stop(). Skip vsc_tp_init() when intr_enable is false. This avoids unnecessarily uploading the firmware, which takes 11 seconds. This change reduces the poweroff/reboot time by 11 seconds. Fixes: 386a766c4169 ("mei: Add MEI hardware support for IVSC device") Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/platform-vsc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/misc/mei/platform-vsc.c b/drivers/misc/mei/platform-vs= c.c index 435760b1e86f..1ac85f0251c5 100644 --- a/drivers/misc/mei/platform-vsc.c +++ b/drivers/misc/mei/platform-vsc.c @@ -256,6 +256,9 @@ static int mei_vsc_hw_reset(struct mei_device *mei_dev,= bool intr_enable) =20 vsc_tp_reset(hw->tp); =20 + if (!intr_enable) + return 0; + return vsc_tp_init(hw->tp, mei_dev->dev); } =20 --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C275A22FDFF for ; Mon, 23 Jun 2025 08:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668663; cv=none; b=MKXEW6GCiYVtZlZ1Ndnam6Y/dbDVp/QG/Xe8dYSZt+9Cas/4hcArTuKZeByT/qy+IMeh3yYNB0crI4/JytzPKdDHVLqQwV1yQZGPXhPpJlwy4YS2wLwI9fvpv936uZ3TI5Q+//eal8wxd1TMOi0koyWNV+sp9GY394G7QJX35aY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668663; c=relaxed/simple; bh=CvGjOzlctTl3q9G9haHNMpflDsOOCMomL21LTmJT0B8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HEEd9xxw7oWUOyuciR1h8M2lrpW/KJQ5ildcDPw07guOXikU9Mpjpqvsno1ajo8ew2dSRr7seCvxJkkW5mLzkxAaPxkCdWzuPU04TSpVMkRdqRMDO1hiYZZ+fMdYAj19BdlUJS8+rqJ1wexnm4jR7HE/8VjVM3FmcZOyAF4m964= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u1t0Xniu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u1t0Xniu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80316C4CEF1; Mon, 23 Jun 2025 08:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668663; bh=CvGjOzlctTl3q9G9haHNMpflDsOOCMomL21LTmJT0B8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u1t0XniujzNrSUJ0VxTziCijKv1Cplahnc6RJMnRzDUvqzeqD10DHVd4kG0O6A4Lw U95odJAcCSPuAVtS2L+cnsaOLnS/MnrA97kkfTFZi1bHhCwRjNBoSyz1uvTAExhenx 2jhpLDqi3AO7kGzkCnKj1Sgkg6AvsbWLxmauvoZAyTHN143sElzL5aE+CO5JuvlA/Q AddwP3G1Q6ZOeBPXqheMhr8bokX7VH6zh1hwZ/5eBZku33S0j6dZd9gN2nVF6EPKMQ NvfHfbKTHKzFfD/PaXfK6IgMSF8235hJSutfLa1N3SV6/YqggGfXaEesM3tIvKSW4+ sYO6gMJCRtd3g== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 03/10] mei: vsc: Don't call vsc_tp_reset() a second time on shutdown Date: Mon, 23 Jun 2025 10:50:45 +0200 Message-ID: <20250623085052.12347-4-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that mei_vsc_hw_reset() no longer re-inits the VSC when called from mei_stop(), vsc_tp_shutdown() unregistering the platform-device, which runs mei_stop() is sufficient to put the VSC in a clean state. Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 99a55451e1fc..4a262e2117e4 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -547,8 +547,6 @@ static void vsc_tp_shutdown(struct spi_device *spi) =20 mutex_destroy(&tp->mutex); =20 - vsc_tp_reset(tp); - free_irq(spi->irq, tp); } =20 --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7374F230268 for ; Mon, 23 Jun 2025 08:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668666; cv=none; b=ucPN5Z6v01tanQzynDxg14A9Rvx9+l2QjYVtJqFyD7B/rCt5Lm/GW4wH3iSrZUe9jeg+NKHZd94QnHCwkJqPap3peKgxlAW74xyx+zA5tS+hVs49OGWNSVFUDosZOKBnXo6xQtxCYbA4M+aM49F2Lk1emfoCwEEh0DYcExtiwdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668666; c=relaxed/simple; bh=xhkPViskx4aR3bvHEndACfngha3VrIpBD7rQs5QtKv4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WzC1GsplJM0udIER4KODAZkIzz9eopMQ7O29g9b6hE4Rjo3tEWOfQsklxjyACmxCJA5kpo70YpmmeMGkfNqPgQuoTHd4UHZG88twZPDKC55PfenXnHDDsvDAtny/qRHKAMltOw1YX9YbbkWQmcWj5gSuqVn6nbnyCF/Gm4t7uHo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VE3sMBGf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VE3sMBGf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA12C4CEED; Mon, 23 Jun 2025 08:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668666; bh=xhkPViskx4aR3bvHEndACfngha3VrIpBD7rQs5QtKv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VE3sMBGf75KASic2zpj2HlCS6hDDa/UoCUKkk6Tnyq/N/5FU0f5JXKmbo7kKMDiYj rf21WqfMg8BvtaH4dI4yWopGtFcEu5a8yEnuUYcL/RAqcMZ6HSYzrZd3HUPk1xwNtc Ar/HGXfC9cWDGCBGVFFh7zs1ZfJTskrLBWIHEv75LKZECARKXeKPnq5A/CCuGIIzf1 sORepI2b8WQVhpYMtwfBKDY9MaTPnZ2d5KGrZkiU0zbLoOse2E/ZKtXrhdTmVq9iC8 RKo4DCAKU3BBSDlmaQ1/pT/8OtDVEhW8Z3hEo4mr/oieN+jdxj4PGJk570Dbq8zrVo psfZwhfcefojA== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 04/10] mei: vsc: Use vsc_tp_remove() as shutdown handler Date: Mon, 23 Jun 2025 10:50:46 +0200 Message-ID: <20250623085052.12347-5-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After removing the vsc_tp_reset() call from vsc_tp_shutdown() it is now identical to vsc_tp_remove(). Use vsc_tp_remove() as shutdown handler and remove vsc_tp_shutdown(). Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 4a262e2117e4..f5438a600430 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -528,6 +528,7 @@ static int vsc_tp_probe(struct spi_device *spi) return ret; } =20 +/* Note this is also used for shutdown */ static void vsc_tp_remove(struct spi_device *spi) { struct vsc_tp *tp =3D spi_get_drvdata(spi); @@ -539,17 +540,6 @@ static void vsc_tp_remove(struct spi_device *spi) free_irq(spi->irq, tp); } =20 -static void vsc_tp_shutdown(struct spi_device *spi) -{ - struct vsc_tp *tp =3D spi_get_drvdata(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[] =3D { { "INTC1009" }, /* Raptor Lake */ { "INTC1058" }, /* Tiger Lake */ @@ -562,7 +552,7 @@ MODULE_DEVICE_TABLE(acpi, vsc_tp_acpi_ids); static struct spi_driver vsc_tp_driver =3D { .probe =3D vsc_tp_probe, .remove =3D vsc_tp_remove, - .shutdown =3D vsc_tp_shutdown, + .shutdown =3D vsc_tp_remove, .driver =3D { .name =3D "vsc-tp", .acpi_match_table =3D vsc_tp_acpi_ids, --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8EA5E235066 for ; Mon, 23 Jun 2025 08:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668668; cv=none; b=Fh6TkhW53iTinX/Hb1S1DNn5kxdowzcIvgK1Xm0FQtsi2XY4Xzmt1oxbn6p2ohFsM+Y6iraNZms1xij/SR0R3zFqowIJ1mGSinAeCOine/4IMsbxbAO3u8taY7q8z6opXB5FTL+SVPrKQ2szRs98RWrEtFWim+cdrbR/Ua9WWG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668668; c=relaxed/simple; bh=gAT/2NQIOzLs/La0bdAuHZyLTdYB+hepialGfTZDzKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M0dscAf6xOmJ/RbGpcnLFikpa8SnZTldHqI/YO0hvkMO0SM88DWuwZDDz67Xns0A3v3KJtrqgCCvMORsdcFcdQeuZIbShjjaQ+eyxFF3+OtNTVOrbcX+qMQrEciFItuwIcEO47aD1VnPBmH/hR7QdtaWEgp6GSMjvpYQ80ag/Jg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a/QRhA1U; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a/QRhA1U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83FADC4CEF1; Mon, 23 Jun 2025 08:51:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668668; bh=gAT/2NQIOzLs/La0bdAuHZyLTdYB+hepialGfTZDzKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/QRhA1UT5XR9bSM6n38IdYCFX3virkXjnsBDc5czBFQOWK23fwqt7humyjrdP5dn uewrl9AYjOhORQLVNLBDmhogHEQJ1uLfCKMInqqYio3WTSZHM1Eb+RxW6zt2vtwhvo HzjAB4IR+WQM2BMCeQ969oY9DDZuJjLuVsoV2/6ojbzvmHi3FibnHxyCPVsbeLBNwZ Z6pOGKTdvXI4k4wEvqZZvB467OYEMxjEKGso2h9xPIgoqmuBlGYdvoYuOvAOqqDZqV ODj1v1k8lTEOVoARsta1ERk6C4f73b3A1sREVEkPJTYhU+AEuyjq1pRZInA1BX/BMs fU/g/3I83bb5g== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 05/10] mei: vsc: Destroy mutex after freeing the IRQ Date: Mon, 23 Jun 2025 10:50:47 +0200 Message-ID: <20250623085052.12347-6-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The event_notify callback which runs from vsc_tp_thread_isr may call vsc_tp_xfer() which locks the mutex. So the ISR depends on the mutex. Move the mutex_destroy() call to after free_irq() to ensure that the ISR is not running while the mutex is destroyed. Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device") Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index f5438a600430..0feebffabdb3 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -521,10 +521,10 @@ static int vsc_tp_probe(struct spi_device *spi) return 0; =20 err_destroy_lock: - mutex_destroy(&tp->mutex); - free_irq(spi->irq, tp); =20 + mutex_destroy(&tp->mutex); + return ret; } =20 @@ -535,9 +535,9 @@ static void vsc_tp_remove(struct spi_device *spi) =20 platform_device_unregister(tp->pdev); =20 - mutex_destroy(&tp->mutex); - free_irq(spi->irq, tp); + + mutex_destroy(&tp->mutex); } =20 static const struct acpi_device_id vsc_tp_acpi_ids[] =3D { --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 96FD32367CC for ; Mon, 23 Jun 2025 08:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668670; cv=none; b=oKSNosvTHpNJz2OMSP1twOZ1YLsxkztwUO7Im6bJaufbfJQHXIF3dqTB819nwPji44kiomyO2twzj7zBLO28ERDraanduafAOCE61MiJe1gcTqu8gqdqBHiZXOBkk1tHcg7lsqLySpWvY9lq45cke7gYUEUu93VHE/kAc+Xdql0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668670; c=relaxed/simple; bh=Hwrcx7bSN2Q64gKzKoyNC9kLUgY3eRMYO5s66lvzboM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H6ejlt10a2ILpiwrfbuPdg6pxgMjU9SMChrAHkFpkjuTXlEGywPu2RkI+R7ltHsnoEwAfssgkHCM+9g/37IL0IL15AhuXthPnbPAPpY0bIXmV6SpBldvZ3kP6EyPfeV2z/f1J6WzG9QCOrkvdV1+dIWouWzG6MA2u1pNX+7nDxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BIF7OuxA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BIF7OuxA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00ACAC4CEEA; Mon, 23 Jun 2025 08:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668670; bh=Hwrcx7bSN2Q64gKzKoyNC9kLUgY3eRMYO5s66lvzboM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BIF7OuxAWbyFWv201CpYKfPznnWRed9DUZ3f9YKrPdFJHRpZxb5fcUA2X1eE1Bykw NFXrro+S+AacGrYuaMURQwAWcoLsffnsb5zxyIy3JW4r4ehrI/dRo4e1zp7T0Xb5sC IRIJMWQngY2tkB7mhQOyq3ZlG5mvF6erVLGAUHNo1Pu4/JguoAA0k93H8fGPOL4hHs JnlJFXUgga49VnUcOH0oyyIBKLw4TRMmvTZuepm/vQAfaqZVRLcbcr3G8qe+yP7faq X63JTvhjk4uubV9UL7z6Ac9yvhD6T96Ea/HneNp5wNb/VfgtOlzS3smrT9SNDn5pI1 XHe9x61oGu+aw== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 06/10] mei: vsc: Event notifier fixes Date: Mon, 23 Jun 2025 10:50:48 +0200 Message-ID: <20250623085052.12347-7-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" vsc_tp_register_event_cb() can race with vsc_tp_thread_isr(), add a mutex to protect against this. Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device") Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 0feebffabdb3..76a6aa606a26 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -79,9 +79,8 @@ struct vsc_tp { =20 vsc_tp_event_cb_t event_notify; void *event_notify_context; - - /* used to protect command download */ - struct mutex mutex; + struct mutex event_notify_mutex; /* protects event_notify + context */ + struct mutex mutex; /* protects command download */ }; =20 /* GPIO resources */ @@ -113,6 +112,8 @@ static irqreturn_t vsc_tp_thread_isr(int irq, void *dat= a) { struct vsc_tp *tp =3D data; =20 + guard(mutex)(&tp->event_notify_mutex); + if (tp->event_notify) tp->event_notify(tp->event_notify_context); =20 @@ -399,6 +400,8 @@ EXPORT_SYMBOL_NS_GPL(vsc_tp_need_read, "VSC_TP"); int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb, void *context) { + guard(mutex)(&tp->event_notify_mutex); + tp->event_notify =3D event_cb; tp->event_notify_context =3D context; =20 @@ -499,6 +502,7 @@ static int vsc_tp_probe(struct spi_device *spi) return ret; =20 mutex_init(&tp->mutex); + mutex_init(&tp->event_notify_mutex); =20 /* only one child acpi device */ ret =3D acpi_dev_for_each_child(ACPI_COMPANION(dev), @@ -523,6 +527,7 @@ static int vsc_tp_probe(struct spi_device *spi) err_destroy_lock: free_irq(spi->irq, tp); =20 + mutex_destroy(&tp->event_notify_mutex); mutex_destroy(&tp->mutex); =20 return ret; @@ -537,6 +542,7 @@ static void vsc_tp_remove(struct spi_device *spi) =20 free_irq(spi->irq, tp); =20 + mutex_destroy(&tp->event_notify_mutex); mutex_destroy(&tp->mutex); } =20 --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B6859238144 for ; Mon, 23 Jun 2025 08:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668672; cv=none; b=Db9OKuVpBEvFtruRthKjLhiDrrwFjZSWmbVBtB0q8eTbGdWsQ1p2r4H0+p7yb/bfOkCrwd7lSXkr0NBwDdz9NN+1cWNyqA3Cw3c4eHYcm2ve6e9c5rknKIqR0o+YURB+42qmU/kxf3K9PYb8dOGPmxbHngmB0WP1jeQUBbR/N0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668672; c=relaxed/simple; bh=7YK8h6/s6FeL2OpH/wceg6nUbtWI80YOQxmlwFUPtFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZE0pC49PSnvnbNXYZWsuVyXNenEQbG/JDPQUPrXxQu2zl0nyiZM8QESP+ZlNnjplpSwxhOppKiu4EHR7mQEMFCPPm2uOteVs0EqHHx4H42t0fLGF5As049Q0cH9mHECXu2hIjjnKsn7kvzCZolOIBMMjG9k4QwiXE5YgInLU+T4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P7LSti+W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P7LSti+W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCC08C4CEF1; Mon, 23 Jun 2025 08:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668672; bh=7YK8h6/s6FeL2OpH/wceg6nUbtWI80YOQxmlwFUPtFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P7LSti+Wyvf3rWuAW4qA+iDZSDkKRFZ3dl6zRQ1SVP5fYK3mgu7netaIUUD6JtTpl +OrqFtxIRFbXVQGRHx1B/XOPiyTuT1XynbZESeuC7NQ6XLbRyuJ/ZQxh9pqK8pHIdf 98R3acaf4RQhaBuBurJuTDc6KG0bLaaLg9WGWbYAOJDjVJuMcTAby/VndNCeJ/1+eg q9YJcN4aYEGVRvf42XWK2D8cOqCgi9Qx4KJOCmOwxfWuqo2oa4+nvUffA7LRQPVypV kzZEqSvm4o20cxBB5vcoTfdqmD2iohkaq2cIheYuolv6xQkS/N9XfD9PP9buuAuiGp 6F7Cf1vMSMJ2g== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 07/10] mei: vsc: Unset the event callback on remove and probe errors Date: Mon, 23 Jun 2025 10:50:49 +0200 Message-ID: <20250623085052.12347-8-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make mei_vsc_remove() properly unset the callback to avoid a dead callback sticking around after probe errors or unbinding of the platform driver. Fixes: 386a766c4169 ("mei: Add MEI hardware support for IVSC device") Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/platform-vsc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/misc/mei/platform-vsc.c b/drivers/misc/mei/platform-vs= c.c index 1ac85f0251c5..b2b5a20ae3fa 100644 --- a/drivers/misc/mei/platform-vsc.c +++ b/drivers/misc/mei/platform-vsc.c @@ -380,6 +380,8 @@ static int mei_vsc_probe(struct platform_device *pdev) err_cancel: mei_cancel_work(mei_dev); =20 + vsc_tp_register_event_cb(tp, NULL, NULL); + mei_disable_interrupts(mei_dev); =20 return ret; @@ -388,11 +390,14 @@ static int mei_vsc_probe(struct platform_device *pdev) static void mei_vsc_remove(struct platform_device *pdev) { struct mei_device *mei_dev =3D platform_get_drvdata(pdev); + struct mei_vsc_hw *hw =3D mei_dev_to_vsc_hw(mei_dev); =20 pm_runtime_disable(mei_dev->dev); =20 mei_stop(mei_dev); =20 + vsc_tp_register_event_cb(hw->tp, NULL, NULL); + mei_disable_interrupts(mei_dev); =20 mei_deregister(mei_dev); --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1132C239096 for ; Mon, 23 Jun 2025 08:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668675; cv=none; b=iwkNOv0syuEr/LU0oE1si7OA3O1IpDn9dvvwYZpX0zZgsdhfcCamSO77niTkh+VHSryaENLAQXXQtEDhdZO3QkjxOXyUhUnGUBcb+rNUSYjUsyMk5YTrl0bUdzeXQHC5i74iVkg91wfCMew2O60ClfV5QH5wmxh8OwtD8/7hgc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668675; c=relaxed/simple; bh=CbT+W+tiJULj9yW7xTL6IzQw4d0WxvSiWbMt/Ikfrhg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uUL23jpc5J8omeT+3/yX0pVTDoepK0UNqjOYYb9ihvpc0zT+/Qzp/dmI2duuSCNstHcl5IhoNrOwsXrxnXbAdX4hZ06YzzvMQmMpmMXL7vqgj8kRxwNRqnqPGP7aL3Nq1BvYerzXjWhjjXxg9L604S/b/fndeRpZZRDAesKM4dE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R1gOCDje; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R1gOCDje" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB365C4CEF1; Mon, 23 Jun 2025 08:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668674; bh=CbT+W+tiJULj9yW7xTL6IzQw4d0WxvSiWbMt/Ikfrhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R1gOCDjeMNib6vEqwp3qwarx2z44DXFp6i43dctlavcgz9awDOxXfPZgncDjVn4AR +ezcEJUnkGzwPhKosWaBX34YQ9W6rvKmKmlzFToCy9SRmMXNycD42T1n2qaGfUPsE6 z+0STeMBT+U2kVOickL6Hj7v9R0uf31ZGgEMjR/0iYlQeVP+1jVtM+7V7umbvtGZh1 00FnPksZUhD6fZ/HODHGntY8cudNqGoaFZkb+vGw/yZpXABIsLBQD1Co4WyGwwlcUy uC1C5eJyWEuxELv9KhgpkqSICtUK/5OeBuGs6x36izGliVRhtm6oGWFN+h7JdFzBQ7 ozO2soPnyjsDA== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 08/10] mei: vsc: Run event callback from a workqueue Date: Mon, 23 Jun 2025 10:50:50 +0200 Message-ID: <20250623085052.12347-9-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The event_notify callback in some cases calls vsc_tp_xfer(), which checks tp->assert_cnt and waits for it through the tp->xfer_wait wait-queue. And tp->assert_cnt is increased and the tp->xfer_wait queue is woken o from the interrupt handler. So the interrupt handler which is running the event callback is waiting for itself to signal that it can continue. This happens to work because the event callback runs from the threaded ISR handler and while that is running the hard ISR handler will still get called a second / third time for further interrupts and it is the hard ISR handler which does the atomic_inc() and wake_up() calls. But having the threaded ISR handler wait for its own interrupt to trigger again is not how a threaded ISR handler is supposed to be used. Move the running of the event callback from a threaded interrupt handler to a workqueue since a threaded ISR should not wait for events from its own interrupt. This is a preparation patch for moving the atomic_inc() and wake_up() calls to the threaded ISR handler, which is necessary to fix a locking issue. Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device") Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 76a6aa606a26..f5ea38f22419 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 #include "vsc-tp.h" =20 @@ -76,6 +77,7 @@ struct vsc_tp { =20 atomic_t assert_cnt; wait_queue_head_t xfer_wait; + struct work_struct event_work; =20 vsc_tp_event_cb_t event_notify; void *event_notify_context; @@ -105,19 +107,19 @@ static irqreturn_t vsc_tp_isr(int irq, void *data) =20 wake_up(&tp->xfer_wait); =20 - return IRQ_WAKE_THREAD; + schedule_work(&tp->event_work); + + return IRQ_HANDLED; } =20 -static irqreturn_t vsc_tp_thread_isr(int irq, void *data) +static void vsc_tp_event_work(struct work_struct *work) { - struct vsc_tp *tp =3D data; + struct vsc_tp *tp =3D container_of(work, struct vsc_tp, event_work); =20 guard(mutex)(&tp->event_notify_mutex); =20 if (tp->event_notify) tp->event_notify(tp->event_notify_context); - - return IRQ_HANDLED; } =20 /* wakeup firmware and wait for response */ @@ -495,7 +497,7 @@ static int vsc_tp_probe(struct spi_device *spi) tp->spi =3D spi; =20 irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); - ret =3D request_threaded_irq(spi->irq, vsc_tp_isr, vsc_tp_thread_isr, + ret =3D request_threaded_irq(spi->irq, vsc_tp_isr, NULL, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, dev_name(dev), tp); if (ret) @@ -503,6 +505,7 @@ static int vsc_tp_probe(struct spi_device *spi) =20 mutex_init(&tp->mutex); mutex_init(&tp->event_notify_mutex); + INIT_WORK(&tp->event_work, vsc_tp_event_work); =20 /* only one child acpi device */ ret =3D acpi_dev_for_each_child(ACPI_COMPANION(dev), @@ -527,6 +530,7 @@ static int vsc_tp_probe(struct spi_device *spi) err_destroy_lock: free_irq(spi->irq, tp); =20 + cancel_work_sync(&tp->event_work); mutex_destroy(&tp->event_notify_mutex); mutex_destroy(&tp->mutex); =20 @@ -542,6 +546,7 @@ static void vsc_tp_remove(struct spi_device *spi) =20 free_irq(spi->irq, tp); =20 + cancel_work_sync(&tp->event_work); mutex_destroy(&tp->event_notify_mutex); mutex_destroy(&tp->mutex); } --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2361F22F76E for ; Mon, 23 Jun 2025 08:51:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668677; cv=none; b=XJtmO9ykU0V6zfjwE6ZjpbulVPu7q/TN17GtJSxBEwyuqeG5FOjzaTq0LjbuH1D91+77zE/KRKEvkIfaOGpL1Ap2WcT7GLfFFJQB8DzGQdQ3LIwFq66sySPTXb+szCesv8ec681o+ZIo1kmj7b+iTOzq8fpAL5pPcQS3yXhGRRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668677; c=relaxed/simple; bh=9KXxsPNu2DS9dR67Q0HnHSA3egsXDbdhpklk/Q9iGcI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tuDFiBR5txX4I2ZQjR8Do618jCUnYqU0fIVdcg11BexKMt9BP6ayjy/ZQFXa2RcYp801pdYVKpUWSDxrSbQ0HMhPxetI8Lw+W4hXcl83ltGmn6NueN4YJhEl2ztfyUkzizQL9SU4S/Q3LRlWQJRoMr8pKOiZd8Q81PhOzRsgtoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Lc/BWpDc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Lc/BWpDc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2296FC4CEED; Mon, 23 Jun 2025 08:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668676; bh=9KXxsPNu2DS9dR67Q0HnHSA3egsXDbdhpklk/Q9iGcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lc/BWpDc69aJQn9xhOm3mz02ZwobZUolo57LgD0Dm/g2/TQ2oOivLwqNcs5ITWLfI kbOsEH77w57pC0VVTI+ss3icKkq2iC7dVEJF4IFcOCcvPks4lqmiUkVocuuc5yOcu3 ws/p5ou/w8SlIPAjXdIOVnq9Yf9DFoYxSOageyu1Rqu/L7tcDiOQ4N8kOeJbqIyaia U+POcBFwGxqiwFrvMw4AbOBG9fl16+Vcid47zylYGclALNkjBuk2tW0fu4qxOJRwXP PWby3yOp/dbSBFKBIquqGu61ZPYp22T7r9yiaZd8+oI/LmJXzdJ6ROFxQYx+d7vVwk CPvr+o3/J/Ksg== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 09/10] mei: vsc: Fix "BUG: Invalid wait context" lockdep error Date: Mon, 23 Jun 2025 10:50:51 +0200 Message-ID: <20250623085052.12347-10-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Kernels build with CONFIG_PROVE_RAW_LOCK_NESTING report the following tp-vsc lockdep error: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D [ BUG: Invalid wait context ] ... swapper/10/0 is trying to lock: ffff88819c271888 (&tp->xfer_wait){....}-{3:3}, at: __wake_up (kernel/sched/wait.c:106 kernel/sched/wait.c:127) ... Call Trace: ... __raw_spin_lock_irqsave (./include/linux/spinlock_api_smp.h:111) __wake_up (kernel/sched/wait.c:106 kernel/sched/wait.c:127) vsc_tp_isr (drivers/misc/mei/vsc-tp.c:110) mei_vsc_hw __handle_irq_event_percpu (kernel/irq/handle.c:158) handle_irq_event (kernel/irq/handle.c:195 kernel/irq/handle.c:210) handle_edge_irq (kernel/irq/chip.c:833) ... The root-cause of this is the IRQF_NO_THREAD flag used by the intel-pinctrl code. Setting IRQF_NO_THREAD requires all interrupt handlers for GPIO ISRs to use raw-spinlocks only since normal spinlocks can sleep in PREEMPT-RT kernels and with IRQF_NO_THREAD the interrupt handlers will always run in an atomic context [1]. vsc_tp_isr() calls wake_up(&tp->xfer_wait), which uses a regular spinlock, breaking the raw-spinlocks only rule for Intel GPIO ISRs. Make vsc_tp_isr() run as threaded ISR instead of as hard ISR to fix this. Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device") Link: https://lore.kernel.org/linux-gpio/18ab52bd-9171-4667-a600-0f52ab7017= ac@kernel.org/ [1] Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index f5ea38f22419..5ecf99883996 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -497,7 +497,7 @@ static int vsc_tp_probe(struct spi_device *spi) tp->spi =3D spi; =20 irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); - ret =3D request_threaded_irq(spi->irq, vsc_tp_isr, NULL, + ret =3D request_threaded_irq(spi->irq, NULL, vsc_tp_isr, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, dev_name(dev), tp); if (ret) --=20 2.49.0 From nobody Wed Oct 8 23:42:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3666423ABB2 for ; Mon, 23 Jun 2025 08:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668679; cv=none; b=PKfNFz404kJuBYYxlYCXPf3jQifciq9qxS4EBBHwku46kL3aSQghW3uJu+EacXOvu2mvbF9Sfa4gSgBKaGEVuQFn7wBdSjH2sK1S7yLM+d4RVfCAMBvJoY+dw5RCRzUXYz62gYxCocRE4ysypIR/s0AocNxSenPvhdubkdlI65w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750668679; c=relaxed/simple; bh=L8GWG2KH1o0/TnFj0G0JDU/9Qiu2V2pg/7sTEYriwcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P2caWHivKTZ3n8rp3s5yzyvIbYuvfaEQ6/6S6lbCR7fGqsndtRlWvn3EICGfExKJ0vdtY3RcEzy0jWObStpqZW5YDGUVt+MzCMJycURNXFYpdYmDGrq8xmXTqPR41OjDhomnCtnycqnyZIuLHvJ1A3BnJ0Ci6v37TyZqYHRI5BI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ovllNfrr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ovllNfrr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 616CCC4CEEA; Mon, 23 Jun 2025 08:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750668679; bh=L8GWG2KH1o0/TnFj0G0JDU/9Qiu2V2pg/7sTEYriwcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ovllNfrrWktLR/MezyQQ8zYxdaQbBLfJeWps47/Fzg1dCIa+0PVGIEUtwbaAsMYXL QaKr/KhBq6F05iFLJraSzmIdnTuhfxZi315/kFgue++OLNPEKrTHhYvJc0jvX3L0x5 /wsNFbnkigP+8ro1t6t1853XDEPne7L0f3oySztsu6lFvvNf4vq6MFUfPNcQZv2z4t wkWUQQl4jiVm21GTwOAvCC8a80uZSwi1bhHpksK9lj+bqRHXS+ZKLn9lw1YEL1jUDh WpvLdcX6nwmOJG1mrkXIDR9wtiNuj19Obc4LdFiUMhTRggS+u10T99LUtYMQxjzqFI EY0DQAPqORipA== From: Hans de Goede To: Sakari Ailus , Stanislaw Gruszka , Alexander Usyskin Cc: Hans de Goede , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH 10/10] mei: bus: Check for still connected devices in mei_cl_bus_dev_release() Date: Mon, 23 Jun 2025 10:50:52 +0200 Message-ID: <20250623085052.12347-11-hansg@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250623085052.12347-1-hansg@kernel.org> References: <20250623085052.12347-1-hansg@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mei_cl_bus_dev_release() also frees the mei-client (struct mei_cl) belonging to the device being released. If there are bugs like the just fixed bug in the ACE/CSI2 mei drivers, the mei-client being freed might still be part of the mei_device's file_list and iterating over this list after the freeing will then trigger a use-afer-free bug. Add a check to mei_cl_bus_dev_release() to make sure that the to-be-freed mei-client is not on the mei_device's file_list. Signed-off-by: Hans de Goede Reviewed-by: Alexander Usyskin Reviewed-by: Sakari Ailus --- drivers/misc/mei/bus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 67176caf5416..1958c043ac14 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -1301,10 +1301,16 @@ static void mei_dev_bus_put(struct mei_device *bus) static void mei_cl_bus_dev_release(struct device *dev) { struct mei_cl_device *cldev =3D to_mei_cl_device(dev); + struct mei_device *mdev =3D cldev->cl->dev; + struct mei_cl *cl; =20 mei_cl_flush_queues(cldev->cl, NULL); mei_me_cl_put(cldev->me_cl); mei_dev_bus_put(cldev->bus); + + list_for_each_entry(cl, &mdev->file_list, link) + WARN_ON(cl =3D=3D cldev->cl); + kfree(cldev->cl); kfree(cldev); } --=20 2.49.0