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+aoKnrsmA/ZbNrC+PVxBtZK/DIBnXQHkbqnlE/mi+RigO5uFy2hXHRlWUSkhYLRuLNCKC1Q4wbYq69tqCiiPKQfolMWRT69cHt8c0s2zfnhfoAdll2TzlpCxuA4fFWM4sohkgzk0S1sNr9Zt1sg0mZpCkpj2jh5HH3dCjfpFfcrygIufl+cLZ8x8O3uHxHE9u+3BdMosuS2bwxmjkV0tNDmKIjUqBeWbWF9fEAEa6hQ06lc/ZWwzxzPcQGISpxpjCH3sS1M2qgQJLiajM2YUUPVh/lHTfKrT/3nFn4zXPCkljgvoBZr4MiqObzr7alzlnSn5KBZiGwGBfZLP0kJ0/p/2cgqY/b5wDQCMYu27hjbxwe9bJGqkCaTJ5La5ij3czPO3lkSEA2ebrCqpi8gTiRqEsUh3X12YAJS4FlP2xX6Np2Wni7gBQixMc33uw3VN/YZjEsMiV5PZudfB8OAM9ARE4l1OlOqeuq9TVLVttcdQ+VGiGEoiPnc6oEqZ16YRmYqcoxk/V+Vl3V1enHbQTh9jxUZb3XzjflSxVcf993JLWLG9sNb9gjoYG3XUBH64aL43xd83eNTbWDN0gICZEDmikovp2zzDarOo/vyFqtJRej+/JDJ4rp1lo7BESQkIiX95l7xqkeeJG+Zz+tC0znETmQkzsYTlwjbdKHxdIytA+O93BVc5blalpf3+NY5O9yXUqNH8CN9lWayK5utJh7TLA+013mh7/ZswHATmZOL2tHhQf5HWzZADYyusTM9PVF18AD0QnNZYvD6Obcb7uzLCdwSLD+j0B053jYw0yY+E5gkIcPKMxR4KcyLytxo5jqDVwgfYyFTL/rz5c0jeZ1DQSqtZXxj4oatvPonDNfSFOg9c6YbXadqAxqg8gMsSsWkEy/Q8sone46WlpLfuZ5Te48i3JgyLskxUjUbqMHth9/y0JU6wECEYn188TFTv0i2F8E9bFVFMiZ34sKYD9Xjf8ezGip0oWv1zEWlh+ha+HomKvug+GYYBT+ZQ/AGAJ3iPyzDpQzN1fxMx3hqRSUaGbOtDrP+5gzW+JpcHjbVSPs+DE3wlHlkfQbxVOn1eA2jyqnH23H70UaKgoBH+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+nO6L4zt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o9x8Vb8ZtkMQ5Y7YsBTS0FpFVKfkHGhvKr6ypBRBco7uwVEB1H3kEwwmpn+yQQbY4gjWa3Hj1ZPMlU6//kU5fWTQGEPULVy1T70X0k7k02B/sJ59eOWFFzN413qqaaMPJDY+DznZ8tt6iRIp447FeD0glmKF+D4eEJ827NVkSgW0ay9ukPB+LyHgh572eKpVxkvwemG5vf8IUTmeCLAXRYY4jDt5VrtUl6Yl+la9BgYsdbPLMieZsrWaymBL6nJ98OsslFjA+jiF5803Moy+2WZQp+E+ZvQRRNjmDQ1mrLz2ZGc9K/e0ZTUBkbhLprLZu3tj0EJozNz5jrGMoCdhfTCXR4WpY3a02tnsCMlwp6Ls6FY2H3KrCcSpjhfGwVqEV6QRaBAgsmLYzM2drOf0R8G+YAzx6X3edviorX/Z9Wdi18/ZS9lbqIvmXW0Lo X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b6cfda5-1d22-4511-ae06-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];