From patchwork Fri Jun 21 10:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Zou X-Patchwork-Id: 13707268 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2050.outbound.protection.outlook.com [40.107.14.50]) (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 86B0D172BC7 for ; Fri, 21 Jun 2024 10:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.14.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718966487; cv=fail; b=lG7PggPyQCm+1HVQD4Duu9NKaazMgZAidR9ROvTNATLk7gOhVG++kPWDbr0NuXeCU1OuK6d3BJxJ+9eQ3GT3xkRNjL4hRZtJgLgc1NxggQKRli9sQL6d9tAjcZNwd7Yt/VOZcv3AoV7S+cEzHDU1XPjS5tdF8tsqEUSBYKZG/qA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718966487; c=relaxed/simple; bh=V2GZjVy9d6hIFC65fPx1jk85QtP6FXiWczCAh+s0dPE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VPw2UAa6YEaRATEbhPUUy83lt5KFwnO863FD5s3u7pnRWpzhMR7hhc2QQXy+C4D6UlFVpfMjqPLH3ylyAMEreym7VXGAN78kU2cbSZX3ZblEUz5KAshqSXDa9C2Se3LX3hXSwZ42yfRCLjAjSmcJoQsgRBNNPmUQdIV9wGEZuKo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=JRAZhS79; arc=fail smtp.client-ip=40.107.14.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="JRAZhS79" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jjejqIEWGMkSOm0DqL335JBO/qg82zul5x2kDD1zjSBiddLFdrNeP5h5kxfvFqPnMohYgItKXNRbWwKq589d2eqo477iqmMAOlXSgufnPs7z1HVxmfzZ78YB8FsPwAq/uBh3OfcAEP+HGPeg10FDXYUSQZ0CxIVmGb5DYO37suXrRltfbGmGRXR1fgHsmjdSQWnT7M5wkSNDWUVmHbtj5GpXSsGV2DCNtKV/K5dEKEs5GnBfnF4pJPFpTjTOEVHY596brxtkanJEEDPdq65HQLJfVrccJKOyuAGdKPjycuX30FT3lcJDT+TX1MDquJnTj+tUqMJFpPUVJzioibrb7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=yGVHcmKrcHmkrt25sIGDO9TlY8rLCNdFfdzBKqoDV3k=; b=LtcgU6GPG7CYtv2yacoVah2Cr+Undz9lV432oqE16ZmEi3dBLqG748/JC3HIe23BkdGn2pt787V3F4BExFWZYHy+CYcAM6S5zC3aysGaWXnbpDt8KMGbEHszGStdN/KKeauRLDXfK6z75HsY1O1LxHiEJcFIQIQ1ZDKloYHUEQdvjP1WjJRINu5YndsB+ktghDgBVPU1pIAlGgLhQglbt44LalTo0NuMJs96w/absk3o73gq+4UsHlvxvxw9dSlsbYwwJjJetrKmf2ALz1TtE+MRV1XwFVzwT6CYvuVDmZ12rSDScbbcZ4+V3U0Z+yezaF1O8psVimmlAZzbqv+coQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yGVHcmKrcHmkrt25sIGDO9TlY8rLCNdFfdzBKqoDV3k=; b=JRAZhS791D8mWxZfPHmbeC7SOXSn9/PhoVK0PAbPSrfRb1rRudJG3sDsr3K1R77puatIRhAnbDphpmxU6h9UegHWlgYi7yx1dgVM4Ji/qpFLi2Ce8PG1mPcSjtUiIY5dUixr6TowFqQhf++TjHdwQPMD1UiBMoqKtFvwE8bqiNY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS4PR04MB9386.eurprd04.prod.outlook.com (2603:10a6:20b:4e9::8) by PAWPR04MB9768.eurprd04.prod.outlook.com (2603:10a6:102:381::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.21; Fri, 21 Jun 2024 10:41:22 +0000 Received: from AS4PR04MB9386.eurprd04.prod.outlook.com ([fe80::261e:eaf4:f429:5e1c]) by AS4PR04MB9386.eurprd04.prod.outlook.com ([fe80::261e:eaf4:f429:5e1c%5]) with mapi id 15.20.7698.020; Fri, 21 Jun 2024 10:41:22 +0000 From: Joy Zou To: Frank.Li@nxp.com, vkoul@kernel.org Cc: imx@lists.linux.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] dmaengine: fsl-edma: change to guard(mutex) within fsl_edma3_xlate() Date: Fri, 21 Jun 2024 18:49:31 +0800 Message-Id: <20240621104932.4116137-2-joy.zou@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240621104932.4116137-1-joy.zou@nxp.com> References: <20240621104932.4116137-1-joy.zou@nxp.com> X-ClientProxiedBy: SG2PR06CA0196.apcprd06.prod.outlook.com (2603:1096:4:1::28) To AS4PR04MB9386.eurprd04.prod.outlook.com (2603:10a6:20b:4e9::8) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR04MB9386:EE_|PAWPR04MB9768:EE_ X-MS-Office365-Filtering-Correlation-Id: c197540a-15b0-42ee-6039-08dc91deb176 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|376011|52116011|1800799021|366013|38350700011; X-Microsoft-Antispam-Message-Info: kze4IQT23MAYgI3MTCUyrkRsIqleWAbAaJKF14gXggVYtndwc8TaWHK6TzPZnDQikTWsnd72y3mdbCm25CTle5Q16OwXt58dCsMK0g4Hg4pBTS6qk/YS2N7YCbEV6vZVRqs5imv5cwLQHM7dKOR5zc+nFDvN7kR2gE7ZP7hgAVNV/cNiY8xrrN9ja9hDInF2OAxs8ocqilv1xJTuP9yoRjfeIThzJQ48vJp9LGLZBaZ458wqWpNYnSyhIa5e//Qjn+uMPNGO+i4fI8Po2U6tUNJV83yrQFbbE8yf4x1e1MTvy2i3BTYo2gDMa7lZNnp0kle2yGmT/Afo80atuZjBFmrLV7VM4FuZIqMlxJ9FW8KHcGRx6y9z1d1qufUd5xJfkkAkngYZpN8la9qF3BS3+nizu7laI7tK2H9/yxTpnT3NQJjg8f6Y6Hsh7s1419SJVFgoieu5H3T0gCh6Iga37W1VXiohyP8xUhM6GlkjJ7WKDyKphtBj/E0IzzozO/pXm0qN5NVvCWX4OZzD3hQSyalOfBgvyBraH2vu1ZMV952xykW7aSRy0gY8MeWDWPkLoSHvaFgWUulNgStbRrAAPSaUgwCETjktXD1b5l+hn+Ml/vbjdKPdVXOgL7ywRDIhxqyHOHSOtR+0jjidbzTbmu1Gi8s9LSuVZqHaozA5n9/wsQssxq3Q918PpS65aJZEE0jQ1WxXFaN4JSsOMQ1RxXmlIAArkLhP/6udY87Xqexo3eCjxyRMyd0gi95zGU+X6aXMNwZ5gFEvX4+1KYOeQf5Z5RVCVKyEJmOSIkZYNBu5vjCH48J7PTiyhrZVXL3Ykhk62c1d06rjNrFfAblP9ke7j51QIO0dePaNQ/22nN9HOpfOM4YW8Rwh3R44NiR+RSi0KNCOkSicT2nUzyD2rYb1avYDPvKTvMOrg1XJITPAg2M11Z2DGfmK+p7JYBAdnUi0MiiQmEKAgEoBVHh5/9TyE5bffNlB92CmY9utX5/pjMTjv+hjNjV4YiOCpSyuIlFTOJvCZ31Kxk+ZzDNi8UXOghry/T1wK8cYMcBGuqPx4Dr3TkKBHTk4oLeeED8OKUX6mf9hyzOFz/KHO105y117fq627qQRtNw30yDzvSnLZOsJ0lemlBLAfXuGkmRBuZJgvDjAL1J5B1aY9NXBFCKxP4g6QXdxGDFlnE4zul6UaE+3Vu2gETUV3DesEg3jj/WaCK+DJs9Q/BoTz9SjpD3EXMF8HUHZ6/OtaiqGBnSmZAFfTTnr7Y4d/7LGRSPtABl/g/RFZvLEC9FXlqHejgH+uxJv1sj2JkYHjPKoNFKogPBE9waqLzdTa3r99QhP7GjRxATWuHFHEuPJtZnn0ySC+FSCk6yN7Z4icTsFqEU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS4PR04MB9386.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(376011)(52116011)(1800799021)(366013)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RAXXMsOweIH3y08WWTajwzszBcGCk2YhPBo5AHhzw9zz6+sBPKnFey+9ObmjUqErQEr2Y6g/U9VchdeuoNSaZwFYn7o13u+CjzCCdXg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OGL5pP9mBMKwvQb7KpGCh8LZPqsWzyGPtGZ032QAKXHPDf5J5x+m9DmIpxbAVc/Sb2WRp8CZhhxhJIXXGdlO/B6vksbhwq5ACyYpd7ezY3dETxAn+8VaT79SjXBTAhtfrXpOEyO7tjWU7pLn15on+dtmf9XPP1yAN8jq5cZflfWjWV+iViGjp+rnkItPeyVIrLXrhgCFrz2ljcMDxRpawrHO+ZFQBQqJH8ee5hiTctDLpoMzBw8E9QwBIs/JqR5s4UnVRdkvbYfw/fdIguddAmQTvmMKsTOEkJ7wXl0f0Pga9/QzrnnNCGtBcOUCrRk/F29ydruSKcbQs46yg9YzE7VMVnT6PsOEFs252yNFT7npZSuDNSY+rubckWrrdKEXY85FN9Dy01J8I/RBMqUE+nuT8Z6w X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c197540a-15b0-42ee-6039-08dc91deb176 X-MS-Exchange-CrossTenant-AuthSource: AS4PR04MB9386.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 10:41:22.7311 (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: EPYjUtshK0CGyLV9qNE+2KU4l+dgepBKHEG+h5IWeCuIg9iD6Pj2ftBkQzHeVITq X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9768 Introduce a scope guard to automatically unlock the mutex within fsl_edma3_xlate() to simplify the code. Prepare to add source ID checks in the future. Signed-off-by: Joy Zou Reviewed-by: Frank Li --- drivers/dma/fsl-edma-main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c index c66185c5a199..d4f29ece69f5 100644 --- a/drivers/dma/fsl-edma-main.c +++ b/drivers/dma/fsl-edma-main.c @@ -153,7 +153,7 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, b_chmux = !!(fsl_edma->drvdata->flags & FSL_EDMA_DRV_HAS_CHMUX); - mutex_lock(&fsl_edma->fsl_edma_mutex); + guard(mutex)(&fsl_edma->fsl_edma_mutex); list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) { @@ -177,18 +177,15 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, if (!b_chmux && i == dma_spec->args[0]) { chan = dma_get_slave_channel(chan); chan->device->privatecnt++; - mutex_unlock(&fsl_edma->fsl_edma_mutex); return chan; } else if (b_chmux && !fsl_chan->srcid) { /* if controller support channel mux, choose a free channel */ chan = dma_get_slave_channel(chan); chan->device->privatecnt++; fsl_chan->srcid = dma_spec->args[0]; - mutex_unlock(&fsl_edma->fsl_edma_mutex); return chan; } } - mutex_unlock(&fsl_edma->fsl_edma_mutex); return NULL; } From patchwork Fri Jun 21 10:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joy Zou X-Patchwork-Id: 13707269 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2082.outbound.protection.outlook.com [40.107.8.82]) (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 41255173324 for ; Fri, 21 Jun 2024 10:41:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718966493; cv=fail; b=SxRJ/zs7bafJe/k2VMFhf7+Yy7V10qgq1okHG3X3oOe06UKxjvpQPqFiZ7vBNZLQKHkpOoXayOjzFn1wMQAgvCad2YDHQeMvdc7z+EDwXtWhmspBf68oxOZcYXjr7+pVEbyhvGW1IbEwFu/mFOHCDuTm01m+eV7wRQtyrbvYPcY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718966493; c=relaxed/simple; bh=kvOgTwXcO/zksQsy0DNcMtFU63B5yhNZOtrAY2hUOUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=InjHlc2YmFeg2phon3WBESehOXp86GakqLnyyjq3FZ4ZBlFizL7bkNKUCdWQ/8IHbfelr7iSL2D9zmXDCLDAEm0yffr5rvcfbOqiqZ7IoVE5iNt2wTLUFNpq5+3NBDLS7NPRIDJvvJs4VJAYIYRudHws8b8L/Ui9iu5TptpT9Ao= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=svwwJ0Yb; arc=fail smtp.client-ip=40.107.8.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="svwwJ0Yb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kKbOxx2Wq1bm9BHXMMk1TKayWQBu2K1sMUZnkUv7RQAa3LpM24VJYS8XSSOPDvwjyZUvE7EiBRcVwELe16AUNWg6WCU8wBorDege5TMZRgOIh4M6KuEqab4XqpASKRkOLlOip6RFPqozmR/MiBaiJjLKoWR1Mz5FxioFZ4Ngg6LWNwi9RD23UXk6yz23zeqjV5ht3sItmmGOeO4YjgsfwyyN9HfpabBVjQD7OmauZ0iyATmKsUmv9P4chn17R/MAJZPLPAX1OS4MVyHdh/kBlO6JM4kCsr5RB/ZwhK5fF2ES30dW4CDKiMWowvdzbc4zrR55rty2R5xB8Pm6kuXMYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=KoXrkpXc/GN3H8vCKkwQBfNQvUGmNk0VwDxRWo3GBoE=; b=g2TeW6tZ3Q/+wooGM2KmnJmBvweOiKSjuUnFQWy5JvmdY3X12YTQPou2s6+2/B99bhSW64QUfWJyBHitjqP20LUMcOV4+RN7+YR1wSpZB7w1KC5ewgvJBS2Bj7kioU2rTsDpFNS+sGyiTCkdAOHY4xoJaszNIsU695KqadFQSXpp0BZSnHR+uI0a9Setyp7zVdw3m/TiKFvgpOBXOUkYdGq2TSkQ1WPexvzaZNwUeVlmRWwEaEEW6tvGzPJukZBY5cG62Y9dGFxtV7ZuLWAP4G9s/uO09Xpr1i+2xFRAQvTQoLcLiTs2N5GnCK1q1Rq0H5eby96isTBTQhYFpueoDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KoXrkpXc/GN3H8vCKkwQBfNQvUGmNk0VwDxRWo3GBoE=; b=svwwJ0YbyUf0sfRtkdykBnQh1G/C5hUt/8lIrMuiCLu+4JicyzAqvLjz96z+lrUdOZhEkPIPtdA6Pcqd53MsDtBqxaI99Xu6RPJiYQUUqQ8n9mu6BX0Je4SB/3qbzLCApW2DPbN3g+WrgkPZtW67Lst2klLIhqQnZ/D/NrL0oEU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS4PR04MB9386.eurprd04.prod.outlook.com (2603:10a6:20b:4e9::8) by AS8PR04MB8801.eurprd04.prod.outlook.com (2603:10a6:20b:42c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.21; Fri, 21 Jun 2024 10:41:28 +0000 Received: from AS4PR04MB9386.eurprd04.prod.outlook.com ([fe80::261e:eaf4:f429:5e1c]) by AS4PR04MB9386.eurprd04.prod.outlook.com ([fe80::261e:eaf4:f429:5e1c%5]) with mapi id 15.20.7698.020; Fri, 21 Jun 2024 10:41:28 +0000 From: Joy Zou To: Frank.Li@nxp.com, vkoul@kernel.org Cc: imx@lists.linux.dev, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] dmaengine: fsl-edma: add edma src ID check at request channel Date: Fri, 21 Jun 2024 18:49:32 +0800 Message-Id: <20240621104932.4116137-3-joy.zou@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240621104932.4116137-1-joy.zou@nxp.com> References: <20240621104932.4116137-1-joy.zou@nxp.com> X-ClientProxiedBy: SG2PR06CA0196.apcprd06.prod.outlook.com (2603:1096:4:1::28) To AS4PR04MB9386.eurprd04.prod.outlook.com (2603:10a6:20b:4e9::8) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR04MB9386:EE_|AS8PR04MB8801:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b6cfda5-1d22-4511-ae06-08dc91deb49f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|376011|52116011|366013|38350700011; X-Microsoft-Antispam-Message-Info: xYjugEP2i4dsa4Knx/LYiJpV3XFwPehzlNYupggJsL6CWcn8dJVhlfFmapgTC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wlHlkfQbxVOn1eA2jyqnH23H70UaKgoBH+W2nELXKRM80d1x/qROPtYCNVILCPJ5PA19I2EJHPhCYlnU7NUWsYP+6CvZA/NxiIQ3G8WyukUlHNlE3rc5u1qI6xd5X1e9VUaDyqJXnJ0HlovpsfnxfQVUhoiiptv12kfpi6NRvBq6O99hP0CR0EAUAL/D0dDUMuPUY0fksd/LiekCx7nGSQQ4X+4aApOyvqGjM6WITEAGi6QV6lnZGXXZsrG8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS4PR04MB9386.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(376011)(52116011)(366013)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2jd5oOuOyCDfYvr7AzlS4rDTl5f+JQ2EkOgzTlZycvoXSKX/MKQ4rYJ5VYsVMLdVjve+nO6L4ztCpoHHeJ+YBDbw6xhzsSGdSZ+sG+YCklcgGEt40B9Oxsn3tDPP1gkdd6kdjQVIZ887hBoWjbhsm7V3z+PMV7BKaE3v4grGQU69tPL31Vb31mBw6KvUwMJQyvo4pkyH/ZT3zA/25mEwYMsZzGwRnAP6w0j3uscVsNC5/dl8dDDHIBfDdcrwQEFLwaZkyst/BmdYzl847U9lQGhe7LZ0WvoMAY+1ucH3qOWTU64DmrLZg6kjojiAqkN9OG4+fJaYUOQ8Pcgq2k92Lblvv6cVRkKT1oV8AiTZPPZVGxSLDOmlygs2MKua16GTaBciJACX8lO2ukRRIiyswmN2dVswSlKSrCLi5NWu0i9hRAMo8+e79P51AgTTSs030g6y2jT2CaUGxqlh30JNmaRaCMyXeRaGHmp1r/JvSUM+5FKjvhm9aQ+Fj8ojyX6NRuLIzr+Osj1idTjs6ruJWTDYv+gsUEZzEKv7v7u80fYgpAxSZ5aqpldVs+dJq3bManPVoqquXgzZAw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06-08dc91deb49f X-MS-Exchange-CrossTenant-AuthSource: AS4PR04MB9386.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 10:41:28.1529 (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: Tx6UOAmJ6F2g3yNs+JtOQ+2R1OEayqKp9+Q5+cSaSDN3kLXSLidSTn9tt8fs+9ey X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8801 Check src ID to detect misuse of same src ID for multiple DMA channels. Signed-off-by: Joy Zou Reviewed-by: Frank Li --- drivers/dma/fsl-edma-main.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c index d4f29ece69f5..47939d010e59 100644 --- a/drivers/dma/fsl-edma-main.c +++ b/drivers/dma/fsl-edma-main.c @@ -100,6 +100,22 @@ static irqreturn_t fsl_edma_irq_handler(int irq, void *dev_id) return fsl_edma_err_handler(irq, dev_id); } +static bool fsl_edma_srcid_in_use(struct fsl_edma_engine *fsl_edma, u32 srcid) +{ + struct fsl_edma_chan *fsl_chan; + int i; + + for (i = 0; i < fsl_edma->n_chans; i++) { + fsl_chan = &fsl_edma->chans[i]; + + if (fsl_chan->srcid && srcid == fsl_chan->srcid) { + dev_err(&fsl_chan->pdev->dev, "The srcid is using! Can't use repeatly."); + return true; + } + } + return false; +} + static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { @@ -117,6 +133,10 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec, list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) { if (chan->client_count) continue; + + if (fsl_edma_srcid_in_use(fsl_edma, dma_spec->args[1])) + return NULL; + if ((chan->chan_id / chans_per_mux) == dma_spec->args[0]) { chan = dma_get_slave_channel(chan); if (chan) { @@ -161,6 +181,8 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, continue; fsl_chan = to_fsl_edma_chan(chan); + if (fsl_edma_srcid_in_use(fsl_edma, dma_spec->args[0])) + return NULL; i = fsl_chan - fsl_edma->chans; fsl_chan->priority = dma_spec->args[1];