From patchwork Fri Dec 6 08:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 13896656 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2043.outbound.protection.outlook.com [40.107.247.43]) (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 E71321B4122 for ; Fri, 6 Dec 2024 08:48:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733474940; cv=fail; b=KjepGJyZTIGj+GWQqvuQ5bctDI3K7/4H4MQhMxhfOh6tR4lUPQ3e51dZTy59/JItdAuHX1waec940VrbIWJhGD+PBsuAJiCK8QNZ7dUj0GiRL3TvpzZl9z2QleR1u8Zfyixud0gPljVzZViO7Z3lXohJZs9Ut5MBW1WA2laPZk0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733474940; c=relaxed/simple; bh=Tr7B9ERWtXV9fytB1VL8OYTOWorWfCTX1R74Hcyr0iI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=InQr1ydzy7g0cjyY2oP3TFevJrDJvR3MGYxOZTweAc/NZlDO1ermKQO8x4UAPfTUQJbRPkMrFbouxvRmwwgkTt60xsezG1X/qZhit08KHPMyvgj09iqhOghNGSnQC70lpDo8LZo4ULRCPyRImM4cTPitOzfsqGdT3ICO9Y96x7Q= 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=S2TPzT0S; arc=fail smtp.client-ip=40.107.247.43 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="S2TPzT0S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TBSHmWqfyLhuz0DPI0ITg97Hprq0bF+YC0S0hze9p6t+ZxcgJlcao5wz8HMnykMaNG0cP7pu371KOzg8ts3JSy/RQWtn/dyNQ/BCXeqj/j4a5fswyJqHloYKavqhudFU8sHesS+/q36zR8YejcmktG7x5knkGZV7kHmS9e6658xI0uPTSOP5Bj+9OK6kShYb3yAmuoBtaJm8kne4uw2mQ8A463+Cx6fs9IBKOnpg97b9f/VUtebGPTwzcANDeEtPopeQMQGNneyGFwtMOasXIDrvU7SkoWxSofbSS2wYv7tUrtGEy7R55uZVw5JlswdPV9mpRu/COdiasIk/1fPB9Q== 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=vqCGfV4CoGa26D5xYRB642zCvwy3oUGLjXqpd2WvmL8=; b=ESW3ffsVT1QJEMtTyQD+Lct+VkD2BxX4MS7LjHbAyKB5ycwKoEizv9TPmVk8LdVu+apq4XgQNgSnvKKe4LyYasRhxhS88keO0aSGhLRIaHGt9HYLHSFqxCZtnltsJhrJhHKDXWWv8Bao4UBmkqGnef42gWrTVPfFpvFPIzjAcxIfTb1GvN1pHW/+4a5g8GWbsHa6DxXKckpPe280uap74oaSVFhEvWpGie40Z8tkgfta/YDDj5P7sFenK/hZWp4J/Unmmr83NH+ndTyjagQognWFTorwBa8oLlfQ+qRdISR7ouZx6gQJAB1D75BFXq9qMzdBO2eChs5VVh168kvVDw== 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=vqCGfV4CoGa26D5xYRB642zCvwy3oUGLjXqpd2WvmL8=; b=S2TPzT0SvNoNoG4AAB8JZ6BoJBEKjlz+eFxCP1th3yNVbymp0FVe9dZH4kbsExd6TKe9GveJuUHzOVbf5FODMfRfYMwyZfQdn39s4d64aOyOKbbcdtuU6an1eUlYzkS0srs8Flc9Jm1mZIX/gUc8aBcezZMDl5VgHyfH9s9VPAWaT0T0T1eYTyw5+dJPmmpseRZ1EqZnZyaH/sT1bxcZrfERslPFQ2jdoYcnaM0s3QAAbgmfNNqhKL4NIDWxx71E2jyH8DyTSBsWpcP05ZQ3qftpIPR8KvsNEW8YanB3EVFZWzeC1SSleKMNwRBYclinVN2Zq6vgBZROSMK8q7n5DA== 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 GVXPR04MB10301.eurprd04.prod.outlook.com (2603:10a6:150:1dd::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Fri, 6 Dec 2024 08:48:48 +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.8230.010; Fri, 6 Dec 2024 08:48:48 +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 V4 2/2] dmaengine: fsl-edma: free irq correctly in remove path Date: Fri, 6 Dec 2024 16:48:16 +0800 Message-Id: <20241206084817.3799312-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20241206084817.3799312-1-peng.fan@oss.nxp.com> References: <20241206084817.3799312-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SG2PR06CA0223.apcprd06.prod.outlook.com (2603:1096:4:68::31) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|GVXPR04MB10301:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a729444-85d7-4cfe-a587-08dd15d2ccb8 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|376014|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: phGPYVUhEWhuu98bwPCi9LXEloLPHhEhV4/BaDvgIS2ZSuQEgrK6/wHTUSJnBhdqS5pYGJZd8fkNFKQ5tDC6T2bkFjgoqDJ9c8XD0g7J2UB9Fhzd5sbNQ2BHOBsgfG2J674pIcTj6pJmxb7LpQMz67eRx5xly+IghrAtZSVgmhM7bZets4gjgfySFsAVhwcOrVSW3ASb/Y8FhXtXLiCMy36Mjn0U1BdSEojyYThpXdCwicVTpsu5SxP0SA7ttjG9JwFbpzUZZv1czeCXWXlzTxk9LfqhyRiN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xXhjGGMPJD80QUJnTPVXQc6L2DocF9qvL59Z7pG87F6ots1XLrwakT+Vg== 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)(376014)(366016)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1pmmAexjACUnKK9WxUWrz5/nKc8fodyBR/sc1CPcXsNbTOdKdhnNrwoBuf+pY1WNi31RnByuf+Z/EIiFfEa+jpfSg5xZsAHQMM0hcfxNYN7+nVWBFIAwhixfWa2hvSErW3MnQtjnXJmnufifSj8YciuVqP6nQoDtR9n4d/ZabtHnr4L+SqijEvwmETpXF9i75+90oPMq47UU3pVKrkWOu6cewwggFT0B35eMXdsf9uphDRu93M+dWeIVx/in3sdHNGrxFIlnVspZs9wuaz7vPdYBCbc5AWTMpbw5NSCAVSJpXrVq2Ykx/m98ao8UWdFp0PNfpPbQH+JKvl393w4E/1XlGY75Q38IvEwtzIlUF1wwZqvSnfXcXVUYUAUF2L9ty7C1Z2df0D1tyJCKSZUZQ2A6MkoSDJnVyZ96hp5jt8wc9/je9g2xns/DCxRKZROJqOrTo4NVZLv5R60W39s6orev0rKmuOOHoIQRTcp9FuW+Pipuqevvs2aPAy9kkeWm6eUTo5U/cBggyWkZBYKF9SnKZO068Xs82XvLUEAwn7x2HukhJ7MbEqZhFPDl6gxR4Y9vFmufJSoAwzPcHS6qdes3cN9Pyq7sGg/eqGv2JBlKcUfaQSa1/dm+X1+lOFDn+D/pE9Ayp11rM57ZSsiRgFdJADSMPxSqkT0pvNzVuyusaFduG9CH8E+wI7U/sv9gsuoANFOTT1LPWujdLhTNn/Seb5o58k3trnmf/w1EX9QFR61ZCalo/Wqb6AAkzl2dqf3z6og9dYJ1qjCLqdRFdq528Ca23aeDoipuDpbUiyaMgPEFockM98ndq2VJTq7DGrdWdCpoVC7Xsc0FmpwhSnTIR+UuUOUbzS6TCD1VQ+Gw68V9wjZCVWcld+ytTtA2SnhcQgXUsna+pGDY4CwnRF/Yl6cpRXPDfm/jLBtRVrLVdi5VnbVeBrJdX2PvQAtVZzgxgt7X6W9Mq0heCXPZ50iEnAp6m+rY/4DPaeX7n5DF1Lze2KJYPBqmknkRiSvL+RtYJt45aRLa33wFQWLPwiXc6UfgwqwDFoOYNtALR9FgFl6AoyamC365P3WHj/ixwXbRdl6vRP0YaUDT1arTeE1bGGeQ2fX0XwD16mRnMuUBAstydH7YCBgoWxLdE1v1/Ojfhps5m/QhmwuuzahDPRbW+mtg3ULTdxzqmYKaxJDFuctgqZWFPzju+9Oc7qpt5t3qyGE2+HhZW2bNguIBhplwnrhgY2bRFxLtopjRXRJKqgX/92OkIU4vpuQetGnAdkWCUn4LRhOgFbvWP/IHAa8GUqAaG4lUjVNNzelYmY1zr1OUtFS/+lWTM5NxDGmk65L0CNNGs/m7h0SMSJSuz3Ko59mrh9i3SkDrH5SoTlwN4SZVImODU95Rui2BtK9GZXUHNDUYCp8FJl5RxAn48uGDF1LwABUbpwwWJZ5aHv90f2+GQgfTE+btFoxAvNNTF25K3UAzrBk1zQyzDoteeL1OCcGm19YBlELg+eJogkyCjsLrpvvOAi0/1n41iKvKhmfc+3daXq2fC7Q16adQjl/liJkUI3GuKX0vrtjodfCC/wYAskXsxzRicg5bf4oA X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a729444-85d7-4cfe-a587-08dd15d2ccb8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 08:48:48.0609 (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: t9mNDUuZDNEJW4UngdyPDMQaMKFr2QrhjVlUm1xGh+jxy9Dz6/EMA8hl9NO7bvrFStbcsZKg/HsckCNx9xrVLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10301 From: Peng Fan Add fsl_edma->txirq/errirq check to avoid below warning because no errirq at i.MX9 platform. 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") Reviewed-by: Frank Li Signed-off-by: Peng Fan --- V4: Update commit log per Frank Add R-b 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);