From patchwork Fri Nov 15 10:56:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13876106 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2047.outbound.protection.outlook.com [40.107.20.47]) (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 973E11B4F2A; Fri, 15 Nov 2024 10:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731668223; cv=fail; b=jkSwH2RoW4Io7FCGZFn3/7QC81mDhnS8lbMzie1jGUp1oeUf+fSEp+0be2xaeVLnf01RZ4+RzMWxN0K5rVk+xE0iHJTjBKlgLoeFyfnxJH4JuHPoXC+lXM5hLjwuy8QunCy0wWnmFuDU7+KyY/r4Ax/gHrwKRiUQ1ybYQn2YXgQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731668223; c=relaxed/simple; bh=rMh79KrAMVkhPQt0GUUHsuB7DhF18En26blPigZDcRM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pKQfWQxVdQWgt9HNi/bKzgXfDawMvRNNP+PjIsZcVdvbMepjZTfb2zysrdrQ2OudUbweaWBuRDAQi+DW6jOUy1jqoGH/3MvpqOUNFjXvCYEesRlzGXbJ1YrPxUUAnMiwcQVy6a3uyAplU+O/Sl4WiYlFHdlT8iGL/ksx+MCSn90= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=ir0QuMFP; arc=fail smtp.client-ip=40.107.20.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ir0QuMFP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v6bmKZCM5Gh68crRzQb6tsHngsVhDu2ZgYYPLjaVHHOLtmfaTIBQKSCxSIG/wrIv6sVo540Dg65FUTJCVPwwUOLLB8KV37L5QwW7fPDTnvOvBlmxp7t9krdpH83K3lUz1aFj5hRWYhWZzqa+TrDU33ZEHGjNGBmFNSJVMkiMYKy1N+H3HjeMh9MjGjp5/jVMRLD7GoXM1SsrzNKs2wnchje+zoiDEjSkAZnL7d+VC5bXqQMgKUWuvdxahRRwpmDIPWOoTzPUZ5CNc9kH0BvNsqNLXpcwVkQR0C+evvfUfsw7n+pRoe5OaboFidQmrTKZ1Hwbq5JoG0Wrex6rje1gsQ== 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=q65kXmIixyWranXYOaxt/D1cL8R8/LmZCl6ae/IciN8=; b=pE+3yxqLSqk/DnrpXx+lygoC/1rOQsRD/P9UKfBdcT/CC/cOuXwt0+TbaJdnRM/WBeOMCs39egUZNXOoj/kCSfYErg+R6PutqGUZ5BRU93bEfzlybZPj/KMasU4F0s8xggoOOTxN6YZm4PblRfSSzReZyFNVbAJV1wdrcj/+RTeJWzEsU57yGS5w4NOiAdew5jlnA+vx4u/KUrdRBqpjcM2Z//38bIJDqq0jIarUYbs14+6pBJO6ZbgVQRdSMa9Aw719S3pFD5rHch9jGPrPzL6Yu03TmtvzFFaYF18jAUtvJNEnE0imcFD2nrRRIoeaKNw6GG7EIKbBjIHifZXcnA== 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=q65kXmIixyWranXYOaxt/D1cL8R8/LmZCl6ae/IciN8=; b=ir0QuMFPCJH753Xz0fTyGvDY4Hze2IocpbBWFXJt9TtwIXDz4aVDX/4H7ULUH7G1zMDJ8/KJExrDflI2Jn+/DcRYwpAxKVxdkVrIKuoJ7QtyXHMhdk5P5dgOkWGO+XBHvm8xmDlmQJAFEgXMKo+yyBP5CA2DjoF84LqnlV4dzVDomAILi5IkUcZ2mkVVCsxkpS6AT3Z9KV6O5jtbpKDDl0m/3JXQVA2AMFiNaLbIE5+yj5uvmb/rVArEk3BTwJNHZ2YV0f0wnJ5LITOZY3ls5WftpbxY96PFbUOKX29bDc/DBbhYSy7CvrFpCVHlFxbZr9AZ0RG5JZexhVt1qUbxlw== 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 AM9PR04MB8416.eurprd04.prod.outlook.com (2603:10a6:20b:3b7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.19; Fri, 15 Nov 2024 10:56:59 +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.8158.017; Fri, 15 Nov 2024 10:56:59 +0000 From: "Peng Fan (OSS)" To: Frank Li , Vinod Koul , imx@lists.linux.dev (open list:FREESCALE eDMA DRIVER), dmaengine@vger.kernel.org (open list:FREESCALE eDMA DRIVER), linux-kernel@vger.kernel.org (open list) Cc: Peng Fan Subject: [PATCH V3 2/2] dmaengine: fsl-edma: free irq correctly in remove path Date: Fri, 15 Nov 2024 18:56:29 +0800 Message-Id: <20241115105629.748390-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20241115105629.748390-1-peng.fan@oss.nxp.com> References: <20241115105629.748390-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::14) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|AM9PR04MB8416:EE_ X-MS-Office365-Filtering-Correlation-Id: a7496ac9-e996-4968-a5d3-08dd05643a73 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|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: 8t9+MpUBeGPGs6GqmdiBlYuW4iPS1TAqDVmUSBfok5V5yFF5ADN44lj6X6XGBbbIrAYywXkwoHzBV9t1nqxS/PXVjCsi3+MZiH+bFPLVLCjSpEaNpGI3GvdEM+y4gMwzgb6wG/95r4DdhMLuRYxIWo3LrP8dygIhc5TGEMz4ur/RS6o93FfhiBT+Onas/jO5SPwjewK+DTM7UfTcfH0CAQDLryE/lb+Ak1drXork1pqZJMPI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3DVV1iTQg/3pJAl8bBEscObazBk8sH3oCyRR9LhPVY3/vDGuzRA0KZLwsL/qCZXgo3TzdLz4PNVXCo= 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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rU0i9FxphGnhS2soAobiizvmcVfieZw8RLg/T8MZ3PopPrfl4N/hYFmYdNEHAmOaHIETTxWwtmL42rtu/5FvePxl3MXs1Xk3yVKNNnPG5eFf1wm02dP2ie4Ql/tOBoTHUbxE0AprvxInp3doNOgAX+MB438PVbmBqpF3l+dqR2iaDk0fr+tjJpikVpaJVqUoIy9V28zrr80uZY3oRvtG1tEWKQPoo4xnFwt6fCoaEDCiD74bOT5Djbl/UPHLLy5ceaFqOVlL38kX2a4yJXhIqaJtlplt0MCrft+LZzRhxhR9za7DoHEzpZun+WwEdJEgy+6CIi0jrnOZbO5UOjYw+9+MQkmY9ZiKTIXsMarOQMh7xP5KX0RIdivz4SxKY6BCuWsEZP3sTi6t+eGSX3n4BfAoVsfneaIETOoVM5QZiF+n0SvWOPN/FNVZoBJCfll5m3ka9mpOjFXAULd8CGPp3bdaaAR4fcCFSe2qYmbfdIKCc06V91ZJ8ylCpkwkJk850Z+CgpG4px8tEQM8mIypdK9CB/WV19xCR6b/0V3LSHmZWDPSuKSUjFl5AU1UpR89wIAxImqMS7+IGN6okEMm92RPLjBSOz8+l4dOYSihsgux/DEYTmuaerckPdaHtSXn0a62r+g/GJ6qyv1wl/n+iKhMqB+Rx+bnuFy6Ee5RTrUlVJEONg47CdywewIzdCEUF73yUv18/wrtUw1qBuCm59An54b46h1hcZuqZZkGHzn0iyJPHuLWtQCvhgjnOHDXIZXgUCNpXFiVevIDkN9YzcKFC2JFl10u38HcCo+SGgmFbAHOLZoJb0yYwWJVXr9QWfjrWepA1iCf57SzEVqje7HcIczHTUBEp8WmWUXAKQ4ibRxTmezgPMb/EqEgllRg1AUIbk7VhxQIYIb6975PCa2u32iPigmeX0mPd5rGdrk8fBeSlY5brGr39k172iaO86ynOH+rQzMaDvUmaf5Z5+Iipd9uxfCYbyMaf1gmQWT2mNtI/LZ3eLfYZh8PKp+OZil3F4Q55zgTS2+plPeNqAtSBpZa75LsqLaOcgdBkV6ZnpsIQBHelP1t4MLBpmv6vwQE2hQsP209L7lBu8YIJ+3pRBmBnk1EK+LsBWdfHejLIQ37a4/1opSmPn79aCPDYTnVMFY+fnM2K65fNHhcwMbtzGRJDj4RS/UUpMTI3I9hjEDufmZl0oez+HeEpIJSjmi6hPq5DDb8WgxXrUN0Ww5M4uEM8MBQrPN0GTgxoNPtC/aX/8iytl9QuW3Edj6n+CBtrz2RfKbVYbclhKnyXH76hO33afHNfrIpIEja39eRHo6dQQ28F/5JV1PNmduhyJn0zU7mxhidjj+8mri+lvTxf1D92Hge/ATxFGv9qnzcip2QHbDXxHN682vGPisZ0rDTIeIydCupeCtB/iVh/ieH4YZsixdE1DrPj+u0q0xgJwwfhjoIpURrcMjnJ+tzIckCWnjxozkSzSxqgdyc/BUENGQz8UhVkfMtMqTSHA2yU9Oz5AA7Q1uXitn3x3kM6LZd8kSCLcVKJ78z0FuNzjjrF1jc0TS7sDxjfCJjKsfEa32w/RE9Kr2fAqpIT97N X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7496ac9-e996-4968-a5d3-08dd05643a73 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 10:56:59.3145 (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: /5nf/Vj8F6Yzv4MBWmLtOEm0dyTFwnDv11SZha92WiCPP0DgjHggRycV2OLHk4XZmlpioH4Pl8jMUEBaeNnYIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8416 From: Peng Fan To i.MX9, there is no valid fsl_edma->txirq/errirq, so add a check in fsl_edma_irq_exit to avoid issues. Otherwise there will be kernel dump: WARNING: CPU: 0 PID: 11 at kernel/irq/devres.c:144 devm_free_irq+0x74/0x80 Modules linked in: CPU: 0 UID: 0 PID: 11 Comm: kworker/u8:0 Not tainted 6.12.0-rc7#18 Hardware name: NXP i.MX93 11X11 EVK board (DT) Workqueue: events_unbound deferred_probe_work_func pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : devm_free_irq+0x74/0x80 lr : devm_free_irq+0x48/0x80 Call trace: devm_free_irq+0x74/0x80 (P) devm_free_irq+0x48/0x80 (L) fsl_edma_remove+0xc4/0xc8 platform_remove+0x28/0x44 device_remove+0x4c/0x80 Fixes: 44eb827264de ("dmaengine: fsl-edma: request per-channel IRQ only when channel is allocated") Signed-off-by: Peng Fan Reviewed-by: Frank Li --- V3: Update commit log V2: None drivers/dma/fsl-edma-main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c index 3966320c3d73..03b684d7358c 100644 --- a/drivers/dma/fsl-edma-main.c +++ b/drivers/dma/fsl-edma-main.c @@ -303,6 +303,7 @@ fsl_edma2_irq_init(struct platform_device *pdev, /* The last IRQ is for eDMA err */ if (i == count - 1) { + fsl_edma->errirq = irq; ret = devm_request_irq(&pdev->dev, irq, fsl_edma_err_handler, 0, "eDMA2-ERR", fsl_edma); @@ -322,10 +323,13 @@ static void fsl_edma_irq_exit( struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) { if (fsl_edma->txirq == fsl_edma->errirq) { - devm_free_irq(&pdev->dev, fsl_edma->txirq, fsl_edma); + if (fsl_edma->txirq >= 0) + devm_free_irq(&pdev->dev, fsl_edma->txirq, fsl_edma); } else { - devm_free_irq(&pdev->dev, fsl_edma->txirq, fsl_edma); - devm_free_irq(&pdev->dev, fsl_edma->errirq, fsl_edma); + if (fsl_edma->txirq >= 0) + devm_free_irq(&pdev->dev, fsl_edma->txirq, fsl_edma); + if (fsl_edma->errirq >= 0) + devm_free_irq(&pdev->dev, fsl_edma->errirq, fsl_edma); } } @@ -485,6 +489,8 @@ static int fsl_edma_probe(struct platform_device *pdev) if (!fsl_edma) return -ENOMEM; + fsl_edma->errirq = -EINVAL; + fsl_edma->txirq = -EINVAL; fsl_edma->drvdata = drvdata; fsl_edma->n_chans = chans; mutex_init(&fsl_edma->fsl_edma_mutex);