From patchwork Tue Apr 1 14:04:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 14034924 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 CCBCCC36014 for ; Tue, 1 Apr 2025 14:08:11 +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=kv1MdOZz9W6G8ZWkf+Wwr0HmeQ5BqW7PQowU/52ty/o=; b=2aF9iI05p7RoG/RrualNpfSIVa 0ceTiJCE2RoJ3ukS7ECzLbGsytYtTPDqVwmQ6fJM1Csvrz/uWzUvaTrbYZYtO28L6Hm8ty9WaD4Sk O9GQuOQ/Qa1lcnbGw4moAnpo1wW1dg/X2bOdiwn5R8T4ewgAx7fhHgMSKO/ofOTBZnmlGI56m516c 5a2ArzO0BseFNDxfQ5X0gu3whAZfllcRpP7IH0sQ/cT2p7lWyvywXck99MrhjUkPIABSU3QrGdV79 q3xM/joZGyBFRBaZNalbdFnJjkassPa33LRl0p6PBjPf07DB4ctbE9BSb65qOD+NHtChesNGjId+6 Q46BYomA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzcHZ-00000003Xlm-0D32; Tue, 01 Apr 2025 14:08:01 +0000 Received: from mail-am7eur03on20600.outbound.protection.outlook.com ([2a01:111:f403:260e::600] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1tzcF4-00000003XRE-10RC for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2025 14:05:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HTansKIpT+oqQvypMeFD4x3ZiSCVZafcEpjo9rz/256MpaIq4AAeUXSAe1VpKCNbpbucu/fYhNoaJcI8+uU3JcwD4x4jxrbNWGWVeeFuP4+248U59rGAIUeoiIGhWY5pcURZnpbGAyv1waWePzsDWwhR4NzVhRBCFIfONf7jw6IqysQTv8y9TWsg35q/KngrGgI3YAvSPaWpcDijD4y4iJbZpscz+qo/nZ1LPHQobunAJe88bReAmPHUOLDzTd2EdvhTM7nAdv6OKh++pOyV+qfw5AaEpolJCq/iVI3gUzxhER5jXLmjbI9ZmCyHvvolgsqfCVJiHr5ouYAcyHDCgQ== 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=kv1MdOZz9W6G8ZWkf+Wwr0HmeQ5BqW7PQowU/52ty/o=; b=r5/xi81RFPPNKBwRN/fPHCCcxo1cWsAl354saqNRhfeC5oY9+hoLas92PzARggmscso6v3nm2rZETlPPtJnMXbCwch94rXXaB4vDS+DdN2htq+3Kz8LX0Ntj/j8iYbLEFLK1Yk0ZC3IJ6IVscfIu7m3cxexDnu3cZ55NJYQk3Rgr6OTbLTyj5DE1F0PeOeXNuOWgrfxrKyZDhJGr6iqp5/iJN5jWygBIVi90gkabfvic5uCf8S/fkcM1ejZcx+5yS9bwB4Gx6iM9K4/j+eXapD2lm+M+rtr8smNcp33y+SKGokpGy+Basov2n86KB/sokeBM/NqvkkMryslNcpQyXg== 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=kv1MdOZz9W6G8ZWkf+Wwr0HmeQ5BqW7PQowU/52ty/o=; b=PUMdXOsW1/VzcsNQUdNlv20EZSwg9cz7XQ4Sfdj7ACaTlShUYR6/UB6ZsucnySGhSs2yfnbWJGoeMZ4yRMe+e5wPBYJzVFwf7Q2Dp3rjO2fbvCBuh+MFfsEirLbFJmy0IOuq7wHi+sLDwoA7gHExqplBuyrK4Fd444UVZypaNhnlfDytJ+lu3AeeUgn6Mc9eKBNwm9KZYtIX3dwmdhYOg265FLxqjA++skfC21rqZF+5i6gxDupWOLopIQYUgKlaVuJd8m0KojJFFZzmIE+tRQ08qeziqGXF1yKCnjNQGa9NUB07q+FW36yoNNRmFz+BmTME3VpXYhsCSQAkBi4MQQ== 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 VI1PR04MB9906.eurprd04.prod.outlook.com (2603:10a6:800:1e1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 14:05:20 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 14:05:20 +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 , Frank Li Subject: [PATCH V2] remoteproc: imx_rproc: Add mutex protection for workqueue Date: Tue, 1 Apr 2025 22:04:02 +0800 Message-Id: <20250401140402.3676049-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SG3P274CA0001.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::13) 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_|VI1PR04MB9906:EE_ X-MS-Office365-Filtering-Correlation-Id: 85707e17-1c9e-403e-37de-08dd71263caf 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|1800799024|366016|376014|52116014|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: rOJoV2+fs/mtBkjW1J9nOWJyWX+PbdG2TIW27FRAto+v2Sw7n+1+V3ml+RjkGuUhZhnkFgRonWk5LYWQkxxCjUf3CX2kgoOPw1ZNPGJde3c+N0YBAZKMqQjCUqXXIBm6E3VekpntlO5F8hOEzAQvafPsXGLPFgvq8rK5aLQmFEt9/LhdTw48W2pWAJvOzYm4ZpKq3fGz/lcJHSh3fSgIZIxHQRcrBLVDtd5It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AfJCbtfOWv3rN8n6hmy8dr4Lx3VOD1nq2/njiVoNK+e550O/RLQKtBr51IhyY0Iwb6w1ToxxBLfU+TTrm6uwZyLJ15VoltjtBkT96+Ob2TL1QErPwY4neQwJdBtpgwktEocz4aqI/aEEHqDwRvqB9LlZH/Qm0oavJSDAfK1XSU3XO3FMMzjL+kpQw4AOs1kkWw= 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)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3v9nFL+MX5Qf6OmxDg2OU9KShfBu8NVDVMZFCOvbXz7L4USVe1kBtTCFA/8kph2OndEjizNnIROxNB6LbzUrIk4q8vc5npI/tC6ahmRqrSCZBgjjZI2tfsEOSGq3k2MolvlSnfghfFpXGko8tAqHoKKjoIY6G8cM/c9fEw7bw1yV0I2W+xxgdLBNgKa5V3spy99yUgs3IToCLb7xrhseTRDRaZRCzfODEeACQdz5+nCxrhmED5WVcPVqRTihZvNJiQ6/MLKVbCTc59HpWM4Ua0Oi6omgRtZIBwmznoft1nAtfgO9zF4yyl15mFARj/+KNNVxuSkNwUY5GN21RmTKqa/QZxOyDRdOVuqt7cdAWr6dOXfk+xSqvaptVFYWGBPDwtoxp2FPxDVlI5pqCyzK743c/hZTfOC/YeswINUWFksaFDvax+uBwm35SdC8RDE5sxn/Kbdjzm2XMJ2n9VTF4UNBLxUFaMMb276INt5r+utzwESuPOEEWDPAo+er3MHATgCshpmLRNbRFJVC17IwuzGTWVSQcLooal+pR8n5oeegiai0XdzpfJRyyfc+yT8WsXRyCkbxb3HlcUsdjxgyBJDwbOftdGsbZt3Ur22XOaDIFZFikljo/lrd7ZSGRyp3a1QGiw06t4rPgqG9Iqyn2I/N/EymLHj6xQKfpjEZMkWvXcFqxtwrWWydC3U25cTXUJzMHtqRsv2YFWs5qJbZBrKXmuuybHtp9zluU7PRoXF2d2ZKHBgk+8pvBh+K0ov1Qc77yo6MR8YdZPliD9Py9K6CnNogKdgVfBIXF7+nHmugN+Fo3eN2qlP7owcCTILwMmQYXeMOziZ8Th4n48kveWe+y+A1ZpDWPEj49jnRyHfhxI66XlmNqQ7DeG0nlpyi8t/NrHUH3Bo6SFpV2XSwTWsYrD9HLBDb4N1rnYgTd29vKNFtMRsYP/r4oRXp981bXci+uDoqdEZnUFTtvYOrrrLzWQ8HuMspbutc19lnTJcZuUR20P+WVveP178C6DKd2zE4/ZOtzrWgZczFUDKXlvw5wnLWwisPKhUiFTL4j2ObatkRSbUQztVgh5QsGjOlYy35OzE/mqbIIX8hUGuFB/5EJiGKsiT5CWkz8TH00GybOnGF0wZxewv1afmeM4f5Hp5QLRpCHTy5Srv+A3CdmwLAicE0XQ13PtPoa7076tBkHL/8D0gipQjofQ1A1EuFlW585PPy+tHJ2FkXa12DzSMoMGx/KFY9cwmFTG1t+RpG6EsEFBJDB4rGIs+IOAg21hE0D8AqbOCHCnpHWHz/5Iu3e8xrmAjCMxCBDbeMv1LO3bcBn2ciLogbu6VxWJ52vPpeTSWzvIx1zQrfanzngMu6JB6kzzxuTMVnqYR1mFKy4LMTvmYvsx9lq94q+z+yAsJ5FnBGvNYqkb6oaCr81Fpr5HpQqTyX8wTJRpRyoXrkCVNLUjwa1WmMjMqFXW6B+x7rNeCFqrtH5HHqtAiIk4AaWY8lIot1YJXXIkrdEfZtQ584GyUFsu1hct71VC/50zmU37AsGi2HGwdER+83O4Yk+mEOL4i6ZUwEgnnYoEpJGyksTS+qaM/WcreMQpIS X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85707e17-1c9e-403e-37de-08dd71263caf X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 14:05:20.1852 (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: rM0qi0JDg8Z4CompRh9tu3FLr9ezPDz4CVB/C+axiCqZ5gTHmdCL3vxKMZGC/ud86Beky1s7T6zOLgY5kEkO2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9906 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250401_070526_289796_5A3D5C3E X-CRM114-Status: UNSURE ( 9.00 ) 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. 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 Reviewed-by: Frank Li Signed-off-by: Peng Fan --- V2: Add RPROC_ATTACHED check, because i.MX supports remote cores started by bootloader. Update commit and add R-b from Frank 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..4819a9e57543 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 && rproc->state != RPROC_ATTACHED) + return; + idr_for_each(&rproc->notifyids, imx_rproc_notified_idr_cb, rproc); }