From patchwork Mon Mar 31 11:22:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 14033503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EDD4C3600B for ; Mon, 31 Mar 2025 11:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Wpl+zOtvHfhSrvLnU9vwpxlHNgY7HPO5Rwqdt0urMGo=; b=lLzxmVNRF9jb90bNJrK+/gyxVt H+TKIM28GshZiKzbIqivnKLLbpcQUJ3B0OXQlJbRQdTLIrwsK+hjkGIv9AOaZwU2Z86P+Xpz51YdE sHHPrUK3aZAgcB8fiUPO2y58Er1E2M+eU1ijo4jta8DHEx1Hwr56xXROYrVsTtcOSTOHR0p9Uesxn 0Rv1ZP/SnjT49B9Vjy+ozD8frtgGrkcIZzAseZ3keuzkc6IF08SVY3zrv8C9+PA2vHH2x0k+Tbvan 7abBCkVsKa381BPU0/NT1hoxS2Da1BBINOfrAJ5ZwJz0evkARWQNsYrM6D0zaMXBuVvewXaQJbqK2 u7rimwqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzDH8-00000000CfG-463A; Mon, 31 Mar 2025 11:25:54 +0000 Received: from mail-am6eur05on20620.outbound.protection.outlook.com ([2a01:111:f403:2612::620] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzDFR-00000000CYc-0iSs for linux-arm-kernel@lists.infradead.org; Mon, 31 Mar 2025 11:24:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PEDWlxAJrvxWAHXDZiINMAbgsxQhHEzPSWj3jPNEwhGdzKjN455uDNqTnH6AvsmQX83DCnvCMALIlU8DZjpSZKdXz7wDeE6ZQlCUpO1hzMTg/K8yzAGLdKw2G2j1dSOKuutR/S440eHBGSJ6OV/Laz05j7Gk6OWkVxRYGPlbhPXtHWeBu4bEh0EsbrI7hThdvy/kZG5XJfjs86AZjEDerATDS1ukpJ6ijL9Bg9sgrrV6FaM7kRblcQjUJMHGv4VAV3aFHYEISPVDMgktZbzZzJ1lfG2vSJHEfBjr5oBPxqrrBL02+yV8u4cKlKdWWhNZVqsA8FPUebRMwT9P6+pBlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Wpl+zOtvHfhSrvLnU9vwpxlHNgY7HPO5Rwqdt0urMGo=; b=dAVkWx8r38GFWijB+NFt+4CCZn/p4saREMRA/DBiRASy/8hkYtGEYoyzfiHgDVNyiZl//lRiDB4Xfnw2DmcUlaTFz+IszGP8DX/vFX2oqTSGGZ0I7ze9N4eXh2J/n/jJCINqjKZKX+kcPL17ugwZFxIt0vK5hPOWZAhLj1rW69IgBMF2/DLlvlgxt9QvwxHDpGt1E2orSOYof4rhyb9xpMkyS6VlAi1YjNXqPHCc+tpQYDQI/nuXHGNKg0tth9GVxzc/A+P4DVsIbEc294OEr/uBHdmA6BIM6F86c7TeUPfCXLg/l8lpzuo3zcsLeuHHcar/vo9YnTkYq9TYjekWcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wpl+zOtvHfhSrvLnU9vwpxlHNgY7HPO5Rwqdt0urMGo=; b=JRbf4NGuO/ZOaKj1mKPSkvCNV/KLH7CgXo3xOi7jRA3MdW+R561DNZte4iDbmKOa06UirBLMd11xKyQ8olkoXpx91RA7+Rv0sEi7UVT2kF1POH//y/2rYeOg+5LscCSX2vyasqR/0R465/X41WWhZf7jiZ3VYca+o97ukpcx+ziOIpxqXj6upaH+0odo0bOQLoL8knpmMtJhrtG2hRjuPZHBx9mut+pflNjcdkGPAJPUK4lFCaveyf5MOOpvumz3NRa06JyatixIU8LKKD7+R7tvOOY3yrnaDkhKIgbwugJUobUKy53CgBmYuK8Np0C6lpkrHTWS07NnnBifodbM/Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by GVXPR04MB10476.eurprd04.prod.outlook.com (2603:10a6:150:1e2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.50; Mon, 31 Mar 2025 11:24:00 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8534.048; Mon, 31 Mar 2025 11:24:00 +0000 From: "Peng Fan (OSS)" To: Bjorn Andersson , Mathieu Poirier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , linux-remoteproc@vger.kernel.org (open list:REMOTE PROCESSOR (REMOTEPROC) SUBSYSTEM), imx@lists.linux.dev (open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Cc: Peng Fan Subject: [PATCH] remoteproc: imx_rproc: Add mutex protection for workqueue Date: Mon, 31 Mar 2025 19:22:45 +0800 Message-Id: <20250331112246.2407276-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SG2PR01CA0110.apcprd01.prod.exchangelabs.com (2603:1096:4:40::14) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|GVXPR04MB10476:EE_ X-MS-Office365-Filtering-Correlation-Id: e9cc590e-6e46-451b-940b-08dd70468892 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|52116014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: 51zhq02UmDVpVbQ3RghY3VASp2o4oG/6Ix57f4LS2SWJv1OsmriSO1J7+fgU2itlK7ZhVhZ1Ub/78O0VTqELivFPOFjZzAHhIp3t0rKuH4J6zBMqGpslTVCoDS734ubdBpCwCQrg192rC1qycOiNvfBD1uxK6uwcQHXuMj3qn/r2GPJ7YT1r4fQQ2VgFgrg3yNiVIELtW0TRAt+q/qkUpdmOjv6IHRKdIW7GaYtU9C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Igw+ZIQRi4lakdfHSqcTlndevHu53GS14tV/Ju+DkPJqiCbKEcaLpY+9y8L0A4g82ien/x6tvDpKDHXsBr1LiuaHICOQjz7EJUrj7Tw+uvrrIJESLzpMOVddTgLsZDdN8zTfoSVcv1/ylun628NIHwVrT0yG7Sg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(7416014)(376014)(52116014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a/bwNfDJCNz40fzxWLvy6TRs4OtdSlbdGMeS+tBrmElkZSc/FHgkA9a15ilmrVLXCfKthvC/H3KxVl+RiXuF+pSvsG2ozcubOlwwuelqNtQHYMAMaLenP7o+et8QxcEbxN7z+oGrBskBME5h3zSFi7TRGBnVqCSyhH6Ui1m7ipNwrE6Twj8EWHu79MRsYCagDLZVQ+T5Yj/TLY5OJioPbTaac+jDuNQoLNNMRCNzJ4+vUvthqWeTGqoXr8vftGAaGRWU22ISsP9pGQxCbYcMyziGv0XjinoglqCvYyGOVsci7dQQCHhgupRUzctBM/EYPAndApK2pv8+S5NAtfNdnDTyXHied0zzciqUFJbq42lcdYxTQa38QwnuuOi0pSCrhrpLSWuAT4FVWyvAmn89mlFjg5gNgCmSt4nahHzBGlSB5fzW3oj8WtD9dNpg1bIo3bFaoW12IMnTuOeRTOadRL29NBL5dhZ/kWvjWDU2w/GzKGR8E9MvH7Iy5QSNomlpKEXyy2Wn27LlTjNhkfUKV3az18enphV3UF9qeDX0ZYeih3n8x1e/Q6en40H9yj4AORd5pjMFTASjUgLFu69hdTaLPYysjqYQVb0KYmZb1lenA07qCZMq3p4klI9KZOlgZe9R1+3dXyxHHAMWIVj5jx9EeTFwiNQ+K3GpKbMl/jkpmiprOjKcDp6uXyLvnvBAIeyR1lCIemwVSThG3/X9eMvVUj8goazxbB0bubdlx9aQMp7fK3c3kAMpNDwPGuYgVelNou+jORbcfHCtK0VT+k0e5lPM353oBblqWnsOxnZk2FP0eWWjHgpLp72vmfDuOAPZuIo/bvLJK4av8OoGQL2THtX8cOu0w/ty4haBAUqHYKbVgrEPAXCfzGJMP/+a8GmQ4SRMvSG41WxJ4Fn1DXlF2xPPaGekwSivm4Z+f8GpzGuz7uG8ov9StSjaKJzOcTu2ibnaIh5MmgMxQuSliH1QkZu7YacYptnl7H5rEiBojb106evphSuhLEnKsw3+jQsbrLVdXhjeP8dfi5XUBmhqwQBZKSx+s/N3eWzRf7ug8vWUfFpQ2ES2kSckQxhxYoDakUnGyfaB+xhyaVJ9g9rg1AuGaZgZNq8ziNaDN308CrnAAIgocpWeuwsuaLL7fkSbZx85cUA2KQqoJPy/+e63Ma2/q2glZ9u9zNf9nKlSkAyYLS9/PxAwBHEb9JXreiUMbLKi97MheCnoI0LKecEBEOuu+wRlh7pAjADUVGPtQo1jrkfmU2Mlub7osQHKLhXAW8Tq2DZtqa6aSLcfCxyUtWKYc2NfJIqADNa9eb03uyAvHENE3CxgeEwIg1zcjls+1AauPN1dsGmSwujY0PJQ/OTklX7qdFOnwmDKMsgT4MDXvUNO/uhaK8B2HM9dw3+hghvBo4LRdRVWzrNYOV5N5dVVGfx+VVZ3pSxoW+EVg8A7x2u9tDQLWL8A3F38LlkAG/0fwqoZXFWS/FqE+davKcn+on7lffRVGWIA4OZKceIEHJvsnAetRrOkO0wv6gozQW/r8lo2+SuYCDLDwDRQ3aWptQsCA3uAxrs0MWSwbPvEQcwNX3hhFeNABtmd X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9cc590e-6e46-451b-940b-08dd70468892 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 11:24:00.2123 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pNlo/pwITRVTkV+kMgvfgkqBVEohr6TMRUp6unCDOHWlJtd0BzvNDI2QnpCCtO+SvTBm2+jXTnU7P0O7idiJeg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10476 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250331_042409_225430_2EFEE157 X-CRM114-Status: UNSURE ( 9.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Same as commit 47e6ab07018e ("remoteproc: imx_dsp_rproc: Add mutex protection for workqueue") and commit 35bdafda40cc ("remoteproc: stm32_rproc: Add mutex protection for workqueue"), imx_rproc driver also has similar issue, although no issue reported until now. Reuse the commit log from the fix to imx_dsp_rproc: The workqueue may execute late even after remoteproc is stopped or stopping, some resources (rpmsg device and endpoint) have been released in rproc_stop_subdevices(), then rproc_vq_interrupt() accessing these resources will cause kennel dump. Call trace: virtqueue_add_split virtqueue_add_inbuf rpmsg_recv_done vring_interrupt rproc_vq_interrupt imx_rproc_vq_work process_one_work worker_thread kthread ret_from_fork Signed-off-by: Peng Fan Reviewed-by: Frank Li --- drivers/remoteproc/imx_rproc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 74299af1d7f1..f933c8f4fc8b 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -785,6 +786,11 @@ static void imx_rproc_vq_work(struct work_struct *work) rproc_work); struct rproc *rproc = priv->rproc; + guard(mutex)(&rproc->lock); + + if (rproc->state != RPROC_RUNNING) + return; + idr_for_each(&rproc->notifyids, imx_rproc_notified_idr_cb, rproc); }