From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.72.61 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796334943; b=FXa/zYfSeobB/LsE2GQaB2mUD8DTcjWMoD1rpYiW74u7oy7TZss5QHbx51M1SGp6Gc8r 5zx//Lsjd4louXLte8DSM9UZWpBED1xxnk+8H1ZFSD9ADom+Cvok/AuB0IeDjFGYiLjrT bKf1eRiXy8a15p5YoASFWqoA+lRFyoX23aNRe1BJHKkgvxqQTsWv5Z19IS6Mm/5Pe1Tzs cBiukPvDEpRyKDOkLj1Bd2yr9a7usKZ6YI5Z8FW4pmotiWoSNga7mQpL1D8/K+rDH1EvS PN29VdLOwSC/cw70/zHykQtQJgrVIbZfjjuQqY1I81kyQ2WTVSTxNhzgA+wDLu3uLSw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796334943; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:Content-Type:Content-Disposition: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=EIsHe1UBluQFs1FjLg65kgaRYsqMGF2sAnbT14vQQ1Q=; b=xggf5wZ0ey3EsnTfvLv5H6uyT9BOFkrS6mXejiAfXn6XvpX1nzpLweku0W1rxJtNnZpE Sa67PmGSLMuuzH7PStCDJUo5FkdYbK0Z2M8/ONOxF5IqYzSWfZdbxMqj6c2SMDyCD7c7O V1jPVsJ8vxG6CO5uLYSoZtUDIQrSk3vCPZATuR6gGewpC4qQjcjqNPWLs930bVJD+jZr4 XlGYYlmBGltgpfWLe05fHZVP2z3XMoXnYiPOSNQYM6G2ZK/6WVjpKY64AtY9P72B3qtfv VigCdIMMRfiW11a1odub1OSO3m9o/aeAK4tDXPrMZOusLmb2pY0//m+U6MWC5+6f2Kg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-NXP1-onmicrosoft-com header.b=EchmNSS3; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.72.61 Received: from AM0PR02CU008.outbound.protection.outlook.com (mail-westeuropeazon11013061.outbound.protection.outlook.com [52.101.72.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39031606A32C; Thu, 3 Dec 2026 21:55:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 39031606A32C 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.a=rsa-sha256 header.s=selector1-NXP1-onmicrosoft-com header.b=EchmNSS3 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SpvtEkj8wFMbD3DGYVLVZT/SYOdQGfOzpAOD0xJ6csUXPttuvZMmlkGrYCqGczFS9suBOSaz2dvB0GENvdONr/nxammkdHQqpEiqoNhpWNgJiPwRcE1hXfYp0DIKBbupgRogSI8Mq/2nxT57cwitwi4iVMjV+vXWSSc/jIxZy6aDFCjBs2iVAx58iXnTlTblNf/FwdvUVVLSjnsR37MM81JuZM9iDqI9KxGfs2SvE2MAXglnv6B2I3uQdWknBoSzfZMY5vABR8E09S8MeFMKuA/jj0YuThw7L/ih9LdLFiSz9jc58Zh2Gg15wutBRFGgYaUK0tMv4YkxezsbudHLJg== 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=EIsHe1UBluQFs1FjLg65kgaRYsqMGF2sAnbT14vQQ1Q=; b=xIlc/2sV5sf/EWeq32kxqvAzQWVClDCx13Lw83Hm6ackkEzcxGkPEBcl3OSEFz1mRu+lFrJzBHXvwAgGr5OdozRq5FXSUEOjewEtAzUFegY+lFQFgw+uDcMhiQu+8PA1/hOxCw/fv2vDV3SX3kimeaJ2BUbBXOMEx6TeoWg9gT0SFGJo6ESvewJ3z5i+64dEs3GbYU8PD3a/H3Mv06O6xA1cSCO8EXy7VLp7j31SwIZQEE6nZOKP0ra1IdMgg+nUyAJKQSdmM6iP19sDAK7qE3IZgzB1aVVQBTf2Y8qMevDBU0vRibXZ9UvJWwZpkD+5B21wVYoEi8QQ45fW8JUodQ== 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=EIsHe1UBluQFs1FjLg65kgaRYsqMGF2sAnbT14vQQ1Q=; b=EchmNSS3s8nHXVne0lSyD+J5y4B2mdAp12R7BQH1XNv+8ACCsPcfx4TyZG6Wwc+5kRpUT54dxrCsXUj5UF9zOdo7YVHI0nayQJDLbVpSg3wMrka+STrp4J6IP2ygaMIrfGkfbcAaocJ7lye2kx2625rVnqQI2zsp4k4iTiYsz536uFGe3J4djXubjGjCl5OFN3pQ4ezFiLerFm/1bAKtyoA6fos/nEa22j4EEm40YsO351ftG+MgNawEVsZZXDXjsKpZYP6eF8tLjejwnXlMX3gdumBzxhOXY+X+CjP6A5LrpJVhYV8oBK7pPWQ673zvs4ksIZUH6Gb70z6XniRFtQ== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from MI3PR04MB12438.eurprd04.prod.outlook.com (2603:10a6:290:76::14) by VI0PR04MB11482.eurprd04.prod.outlook.com (2603:10a6:800:2c9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Thu, 3 Dec 2026 21:55:38 +0000 Received: from MI3PR04MB12438.eurprd04.prod.outlook.com ([fe80::c715:c32:8bb1:b70b]) by MI3PR04MB12438.eurprd04.prod.outlook.com ([fe80::c715:c32:8bb1:b70b%4]) with mapi id 15.21.0688.009; Thu, 3 Dec 2026 21:55:38 +0000 Date: Thu, 3 Dec 2026 15:55:30 -0600 From: Frank Li To: s-adivi@ti.com Cc: Vignesh Raghavendra , Vinod Koul , Frank Li , Peter Ujfalusi , Nishanth Menon , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, sebin.francis@ti.com Subject: Re: [PATCH v13 10/20] dmaengine: ti: k3-udma: refactor resource setup functions Message-ID: References: <20261124-dma-upstream-v13-v13-0-bd4251fdc6d4@ti.com> <20261124-dma-upstream-v13-v13-10-bd4251fdc6d4@ti.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261124-dma-upstream-v13-v13-10-bd4251fdc6d4@ti.com> X-ClientProxiedBy: CPBP307CA0003.DNKP307.PROD.OUTLOOK.COM (2603:10a6:380:1::15) To MI3PR04MB12438.eurprd04.prod.outlook.com (2603:10a6:290:76::14) X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MI3PR04MB12438:EE_|VI0PR04MB11482:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c4376a1-728b-4629-4af0-08df51882a9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|23010399003|366016|1800799024|19092799006|261026140227099003|56012099006|10067099003|261022075727099003|261022105027099003|261009223027099003|261009221227099003|261102130727099003|261021123027099003|261102123227099003|261026121527099003|261028144727099003|261021121427099003|11063799006|18002099003|22082099003|4143699003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: awj0zOZNhc+FQZd0pEn2JZSso69cEkgWSGEa1XXglKIce604JjFG00CbhLrr9LJA5xStKpo0pRYRt9qYRyvfUhm8WxSNFBn9TOws+p1zxW2c2l5SXVHabwM9MjFZQb8RwAN83IdDjZHSPsJyj6r0ASJ9yysGb/zEq/j9GU0tnGb6GW8G/isyK+vmmHbmBvsZDZX+qJkwzBKdVC7p0YWnsxTsjrU8QJ1Xs0ohoMNE0/K69Yzi/AndZIdES3jUeY4Yg4dJ6LgMNdaj/I+ihGhChNdAV9J3bjyDnBHQXntHRY3atDVYBBX+i3yj5pef2hq6uvO8zAlDa85zNdmiaGxb5Xe3rkEi1TV11UefvQcjcxbPCA5LIQQj5jUpukBpz6qUAhSAKbYBE0aPChbpUzytMEWmCEJG/lo2DI07AYaxfXwtnVPqY9Tl5nud+yCsESxCubgQ3yqwP4VYTHJvi6m41HlY+NNSbP7AsaAQP+gI9wHCjONLnwOjJEiu5b+0x2EYbEho1b1wuJ683jsc9EjBHa61uXd8lGfxq3OMjIrsEmM65FQqzAbCvm2NySkQzmNZFGnoat9Q5u2ZLpHj3Dg0CMPmmXGJ53kjYtYtcb/cd9bTw7y9Pm26RSnkDrE3LdFT2+jEEx+fr5kKKYbYgCbuR/7sxGT3PhuZKGGswxIGMiA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MI3PR04MB12438.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(23010399003)(366016)(1800799024)(19092799006)(261026140227099003)(56012099006)(10067099003)(261022075727099003)(261022105027099003)(261009223027099003)(261009221227099003)(261102130727099003)(261021123027099003)(261102123227099003)(261026121527099003)(261028144727099003)(261021121427099003)(11063799006)(18002099003)(22082099003)(4143699003)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?UHQkNngFohRRSWW2y0qsSS/YUIZnd0aDtnpt1eUuiImVRGsoHvcP/A6XsIlh?= =?us-ascii?Q?nHBiLMnwmculWzJfxxmAe7ceMhZnJM8jDpit2oiXYMBXXP74HmEZeqdvWJf1?= =?us-ascii?Q?JSGS6E8l6cvIBk9/QG72DzqYl+b4GrI/aJR2WZ+oX1jHyIc9BSLL0q+Z1O4M?= =?us-ascii?Q?UI0+YIcO+Q6hcNU/El3re2IFUszphVpJr/4Pa7+SzHlDNm2TQc72AUqB4gIT?= =?us-ascii?Q?jwIQjxtucIKHqeAjMvlmBCcbV/KhQeIyz3I6HfvJ5GbFGh47JWJX05/bG1bp?= =?us-ascii?Q?nLf8hCRqg+ADz8qroPA+w9bzIa9YeSK+cCNPq5YS7eLZtNOjp81f/NgSBSiM?= =?us-ascii?Q?xvCb6srMG732XoYcidunVAecbsjdF6TGRAOUtvzX6oM04AKBu9T2bO6H3LhX?= =?us-ascii?Q?q5UodzS/URizV5eEl+qi6QI1kL78gODyLAfuUmOJa0l5U8f5ZdXaLslx9WBP?= =?us-ascii?Q?2yVnIjgBM/1dibisFTKdOOY/9gp77t/p64Kqfl2h9e7qEfARCy2O0HlTzDzT?= =?us-ascii?Q?JSDSOGyxXsK0N1oSLfVf8mpvF4myYaJMmL7RrgtSFUuFiCd4HhmPu9CsN7vj?= =?us-ascii?Q?eZIjNcwZ3aEmy4rnWlz9NJ3b0ZcKHix9lTkDdMGfq/IxlGBvBjMAb3jWj7p9?= =?us-ascii?Q?61II8HL9A+fI4qzudCpUhKFudyKRavU9LqOc9nN6PGU4IymVZvdZDgSUwAWF?= =?us-ascii?Q?qPEoP+QX5RoKTAlwC1cyb4Q70U1bLgH7m8B+tiA75s8NSznyzaxxrojgiWM9?= =?us-ascii?Q?XDx29frKs5ICkY4Hz4CSJNyiEShx4lpW5uLnjDNy/7+ktNSkFRDLJndrvwgo?= =?us-ascii?Q?wkavfbpWItVk6Fn3A48yI394mmVDZWbsMRY4QDYrW6rVnfrdsDPVwcrT92px?= =?us-ascii?Q?YyFcd/TuesnPMg8/d1IWw50MU8821R7ggMWRA49qJLKb66eCfv1kZPmzZPc8?= =?us-ascii?Q?4QK4+WaSov85ems7mHvA0DMPvo0O8e7bWyEOVpqFUj03utQAXtBl70SG5uFV?= =?us-ascii?Q?Ed8MO0nQSwusPanm6BaRYC0VBkrK2PjxIcQrOPDzNgG3iANhXLkLqdxLwKDq?= =?us-ascii?Q?PZuknJGEOoE8kDQDL2lfwGKGacVZ5qhdWLfu0VakUWx8a9yoHVS3jzrDjPIj?= =?us-ascii?Q?1pQSo2squR5uYss2dhaYZSI7AH3M8qI4yyozzwHms6Lva9ARJsU3BmjR84Cj?= =?us-ascii?Q?ld8kAGb2O2qSBPLdyWqd8IlW+xpXSllrlcq/IQL+G+4jPcEonDzdem9Z+9XN?= =?us-ascii?Q?8bF6I7OvGiMs6a4w26IE1/kTbITNQTwln5LAdPsQWkFionDhbuJEJN3aWKAT?= =?us-ascii?Q?O1eIb6CEYL5J+LLypLb5QEZrldkkBXc8xhlpjgT9VpX5RFEhRy5eaLP2fO0C?= =?us-ascii?Q?jobKWz7GDum/8TTdlkb9/m93wxDLfpgefGahhcZz6qwBKpJ0TXqf9ajkWrs9?= =?us-ascii?Q?rybB7k81kffMG/Yr6dMN4BJiB7qFc0jzMa9u9NFc19g+aZTAxqhE9yeUH4wZ?= =?us-ascii?Q?mksOvFDvqPMIZnKxf0ryXQOHdZTIFyI0Bb59qm0RDFQIrR9HIQDHgA8wP+ML?= =?us-ascii?Q?AE+pGh26B1Kcv6COf+gsP0S9EQwQ0g6d1owCpdOOtDxVjr4uQ7B3lVo91+cC?= =?us-ascii?Q?F63ucuUxMM3w8Qp7g05gVRH1K4T/MG2/rB2QLaJGusg+9OL4ew8Sorup9Pao?= =?us-ascii?Q?ChI2ZNxX7z74Hqqc+aLh4bPYxGwtCmrnDvvyFoUEBQ1tYDstPsSSEqvos6Rs?= =?us-ascii?Q?OI7Aqk5jDqM6utrbZhWptr67+eFJVBNhzV96u2B7j8/R25f0Z+p4?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c4376a1-728b-4629-4af0-08df51882a9a X-MS-Exchange-CrossTenant-AuthSource: MI3PR04MB12438.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 21:55:38.4453 (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: diXj+IHPBqVURRLs667wGXc3Ew5c0OOby2A3XuogFafqjq/ub5N0m5aS/BXXAKXXE78DvISIFslA0ejcFklxpdq0xFFwjCj8dO9L8tyujURcua3cx1OWG+A0580J5w6V X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB11482 On Tue, Nov 24, 2026 at 05:15:12PM +0530, Sai Sree Kartheek Adivi via B4 Relay wrote: > [You don't often get email from devnull+s-adivi.ti.com@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] > > From: Sai Sree Kartheek Adivi > > The implementation of setup_resources, bcdma_setup_resources and > pktdma_setup_resources is largely shared between all K3 UDMA variants > with the only major difference being SCI resources setup. So, > - Move the functions to k3-udma-common.c. > - Split SCI resource setup for bcdma and pktdma into separate functions > in variant specific driver (k3-udma.c). > - Add function pointers for setup_sci_resources in udma_dev and call > them as part of the actual resource setup implementations in > k3-udma-common.c to retain the existing functionality. > - Also since setup_resources call udma_setup_resources which is not > required for all K3 UDMA variants, Add a function pointer in udma_dev > and use that to call udma_setup_resources. > - Rename setup_resources to k3_udma_setup_resources to avoid polluting > global kernel namespace with generic symbol. > > This refactor improves code reuse and maintainability across multiple > variants. > > No functional changes intended. > > Signed-off-by: Sai Sree Kartheek Adivi > --- Reviewed-by: Frank Li > drivers/dma/ti/k3-udma-common.c | 196 ++++++++++++++++++++++++++++++++++++++++ > drivers/dma/ti/k3-udma.c | 174 ++--------------------------------- > drivers/dma/ti/k3-udma.h | 6 ++ > 3 files changed, 209 insertions(+), 167 deletions(-) > > diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-common.c > index fe41c0cdd3c6b..7c44f5dcb117c 100644 > --- a/drivers/dma/ti/k3-udma-common.c > +++ b/drivers/dma/ti/k3-udma-common.c > @@ -8,7 +8,9 @@ > #include > #include > #include > +#include > #include > +#include > #include > #include > > @@ -2340,5 +2342,199 @@ void bcdma_free_bchan_resources(struct udma_chan *uc) > } > EXPORT_SYMBOL_GPL(bcdma_free_bchan_resources); > > +static int bcdma_setup_resources(struct udma_dev *ud) > +{ > + int ret; > + struct device *dev = ud->dev; > + u32 cap; > + > + /* Set up the throughput level start indexes */ > + cap = udma_read(ud->mmrs[MMR_GCFG], 0x2c); > + if (BCDMA_CAP3_UBCHAN_CNT(cap)) { > + ud->bchan_tpl.levels = 3; > + ud->bchan_tpl.start_idx[1] = BCDMA_CAP3_UBCHAN_CNT(cap); > + ud->bchan_tpl.start_idx[0] = BCDMA_CAP3_HBCHAN_CNT(cap); > + } else if (BCDMA_CAP3_HBCHAN_CNT(cap)) { > + ud->bchan_tpl.levels = 2; > + ud->bchan_tpl.start_idx[0] = BCDMA_CAP3_HBCHAN_CNT(cap); > + } else { > + ud->bchan_tpl.levels = 1; > + } > + > + cap = udma_read(ud->mmrs[MMR_GCFG], 0x30); > + if (BCDMA_CAP4_URCHAN_CNT(cap)) { > + ud->rchan_tpl.levels = 3; > + ud->rchan_tpl.start_idx[1] = BCDMA_CAP4_URCHAN_CNT(cap); > + ud->rchan_tpl.start_idx[0] = BCDMA_CAP4_HRCHAN_CNT(cap); > + } else if (BCDMA_CAP4_HRCHAN_CNT(cap)) { > + ud->rchan_tpl.levels = 2; > + ud->rchan_tpl.start_idx[0] = BCDMA_CAP4_HRCHAN_CNT(cap); > + } else { > + ud->rchan_tpl.levels = 1; > + } > + > + if (BCDMA_CAP4_UTCHAN_CNT(cap)) { > + ud->tchan_tpl.levels = 3; > + ud->tchan_tpl.start_idx[1] = BCDMA_CAP4_UTCHAN_CNT(cap); > + ud->tchan_tpl.start_idx[0] = BCDMA_CAP4_HTCHAN_CNT(cap); > + } else if (BCDMA_CAP4_HTCHAN_CNT(cap)) { > + ud->tchan_tpl.levels = 2; > + ud->tchan_tpl.start_idx[0] = BCDMA_CAP4_HTCHAN_CNT(cap); > + } else { > + ud->tchan_tpl.levels = 1; > + } > + > + ud->bchan_map = devm_bitmap_zalloc(dev, ud->bchan_cnt, GFP_KERNEL); > + ud->bchans = devm_kzalloc_objs(dev, *ud->bchans, ud->bchan_cnt); > + ud->tchan_map = devm_bitmap_zalloc(dev, ud->tchan_cnt, GFP_KERNEL); > + ud->tchans = devm_kzalloc_objs(dev, *ud->tchans, ud->tchan_cnt); > + ud->rchan_map = devm_bitmap_zalloc(dev, ud->rchan_cnt, GFP_KERNEL); > + ud->rchans = devm_kzalloc_objs(dev, *ud->rchans, ud->rchan_cnt); > + /* BCDMA do not really have flows, but the driver expect it */ > + ud->rflow_in_use = devm_kzalloc_objs(dev, unsigned long, > + BITS_TO_LONGS(ud->rchan_cnt)); > + ud->rflows = devm_kzalloc_objs(dev, *ud->rflows, ud->rchan_cnt); > + > + if (!ud->bchan_map || !ud->tchan_map || !ud->rchan_map || > + !ud->rflow_in_use || !ud->bchans || !ud->tchans || !ud->rchans || > + !ud->rflows) > + return -ENOMEM; > + > + if (!ud->bcdma_setup_sci_resources) { > + dev_err(dev, "bcdma_setup_sci_resources is required\n"); > + return -EINVAL; > + } > + > + ret = ud->bcdma_setup_sci_resources(ud); > + if (ret) > + return ret; > + > + return 0; > +} > + > +static int pktdma_setup_resources(struct udma_dev *ud) > +{ > + int ret; > + struct device *dev = ud->dev; > + u32 cap3; > + > + /* Set up the throughput level start indexes */ > + cap3 = udma_read(ud->mmrs[MMR_GCFG], 0x2c); > + if (UDMA_CAP3_UCHAN_CNT(cap3)) { > + ud->tchan_tpl.levels = 3; > + ud->tchan_tpl.start_idx[1] = UDMA_CAP3_UCHAN_CNT(cap3); > + ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); > + } else if (UDMA_CAP3_HCHAN_CNT(cap3)) { > + ud->tchan_tpl.levels = 2; > + ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); > + } else { > + ud->tchan_tpl.levels = 1; > + } > + > + ud->rchan_tpl.levels = ud->tchan_tpl.levels; > + ud->rchan_tpl.start_idx[0] = ud->tchan_tpl.start_idx[0]; > + ud->rchan_tpl.start_idx[1] = ud->tchan_tpl.start_idx[1]; > + > + ud->tchan_map = devm_bitmap_zalloc(dev, ud->tchan_cnt, GFP_KERNEL); > + ud->tchans = devm_kzalloc_objs(dev, *ud->tchans, ud->tchan_cnt); > + ud->rchan_map = devm_bitmap_zalloc(dev, ud->rchan_cnt, GFP_KERNEL); > + ud->rchans = devm_kzalloc_objs(dev, *ud->rchans, ud->rchan_cnt); > + ud->rflow_in_use = devm_kzalloc_objs(dev, unsigned long, > + BITS_TO_LONGS(ud->rflow_cnt)); > + ud->rflows = devm_kzalloc_objs(dev, *ud->rflows, ud->rflow_cnt); > + ud->tflow_map = devm_bitmap_zalloc(dev, ud->tflow_cnt, GFP_KERNEL); > + > + if (!ud->tchan_map || !ud->rchan_map || !ud->tflow_map || !ud->tchans || > + !ud->rchans || !ud->rflows || !ud->rflow_in_use) > + return -ENOMEM; > + > + if (!ud->pktdma_setup_sci_resources) { > + dev_err(dev, "pktdma_setup_sci_resources is required\n"); > + return -EINVAL; > + } > + > + ret = ud->pktdma_setup_sci_resources(ud); > + if (ret) > + return ret; > + > + return 0; > +} > + > +int k3_udma_setup_resources(struct udma_dev *ud) > +{ > + struct device *dev = ud->dev; > + int ch_count, ret; > + > + switch (ud->match_data->type) { > + case DMA_TYPE_UDMA: > + if (!ud->udma_setup_resources) > + return -EINVAL; > + ret = ud->udma_setup_resources(ud); > + break; > + case DMA_TYPE_BCDMA: > + ret = bcdma_setup_resources(ud); > + break; > + case DMA_TYPE_PKTDMA: > + ret = pktdma_setup_resources(ud); > + break; > + default: > + return -EINVAL; > + } > + > + if (ret) > + return ret; > + > + ch_count = ud->bchan_cnt + ud->tchan_cnt + ud->rchan_cnt; > + if (ud->bchan_cnt) > + ch_count -= bitmap_weight(ud->bchan_map, ud->bchan_cnt); > + ch_count -= bitmap_weight(ud->tchan_map, ud->tchan_cnt); > + ch_count -= bitmap_weight(ud->rchan_map, ud->rchan_cnt); > + if (!ch_count) > + return -ENODEV; > + > + ud->channels = devm_kzalloc_objs(dev, *ud->channels, ch_count); > + if (!ud->channels) > + return -ENOMEM; > + > + switch (ud->match_data->type) { > + case DMA_TYPE_UDMA: > + dev_info(dev, > + "Channels: %d (tchan: %u, rchan: %u, gp-rflow: %u)\n", > + ch_count, > + ud->tchan_cnt - bitmap_weight(ud->tchan_map, > + ud->tchan_cnt), > + ud->rchan_cnt - bitmap_weight(ud->rchan_map, > + ud->rchan_cnt), > + ud->rflow_cnt - bitmap_weight(ud->rflow_gp_map, > + ud->rflow_cnt)); > + break; > + case DMA_TYPE_BCDMA: > + dev_info(dev, > + "Channels: %d (bchan: %u, tchan: %u, rchan: %u)\n", > + ch_count, > + ud->bchan_cnt - bitmap_weight(ud->bchan_map, > + ud->bchan_cnt), > + ud->tchan_cnt - bitmap_weight(ud->tchan_map, > + ud->tchan_cnt), > + ud->rchan_cnt - bitmap_weight(ud->rchan_map, > + ud->rchan_cnt)); > + break; > + case DMA_TYPE_PKTDMA: > + dev_info(dev, > + "Channels: %d (tchan: %u, rchan: %u)\n", > + ch_count, > + ud->tchan_cnt - bitmap_weight(ud->tchan_map, > + ud->tchan_cnt), > + ud->rchan_cnt - bitmap_weight(ud->rchan_map, > + ud->rchan_cnt)); > + break; > + default: > + break; > + } > + > + return ch_count; > +} > +EXPORT_SYMBOL_GPL(k3_udma_setup_resources); > + > MODULE_DESCRIPTION("Texas Instruments K3 UDMA Common Library"); > MODULE_LICENSE("GPL v2"); > diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c > index 9805650df3d09..c5de54d2a24a6 100644 > --- a/drivers/dma/ti/k3-udma.c > +++ b/drivers/dma/ti/k3-udma.c > @@ -2083,7 +2083,7 @@ static const char * const range_names[] = { > [RM_RANGE_TFLOW] = "ti,sci-rm-range-tflow", > }; > > -static int udma_setup_resources(struct udma_dev *ud) > +int udma_setup_resources(struct udma_dev *ud) > { > int ret, i, j; > struct device *dev = ud->dev; > @@ -2238,69 +2238,13 @@ static int udma_setup_resources(struct udma_dev *ud) > return 0; > } > > -static int bcdma_setup_resources(struct udma_dev *ud) > +static int bcdma_setup_sci_resources(struct udma_dev *ud) > { > int ret, i, j; > struct device *dev = ud->dev; > struct ti_sci_resource *rm_res, irq_res; > struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; > const struct udma_oes_offsets *oes = &ud->soc_data->oes; > - u32 cap; > - > - /* Set up the throughput level start indexes */ > - cap = udma_read(ud->mmrs[MMR_GCFG], 0x2c); > - if (BCDMA_CAP3_UBCHAN_CNT(cap)) { > - ud->bchan_tpl.levels = 3; > - ud->bchan_tpl.start_idx[1] = BCDMA_CAP3_UBCHAN_CNT(cap); > - ud->bchan_tpl.start_idx[0] = BCDMA_CAP3_HBCHAN_CNT(cap); > - } else if (BCDMA_CAP3_HBCHAN_CNT(cap)) { > - ud->bchan_tpl.levels = 2; > - ud->bchan_tpl.start_idx[0] = BCDMA_CAP3_HBCHAN_CNT(cap); > - } else { > - ud->bchan_tpl.levels = 1; > - } > - > - cap = udma_read(ud->mmrs[MMR_GCFG], 0x30); > - if (BCDMA_CAP4_URCHAN_CNT(cap)) { > - ud->rchan_tpl.levels = 3; > - ud->rchan_tpl.start_idx[1] = BCDMA_CAP4_URCHAN_CNT(cap); > - ud->rchan_tpl.start_idx[0] = BCDMA_CAP4_HRCHAN_CNT(cap); > - } else if (BCDMA_CAP4_HRCHAN_CNT(cap)) { > - ud->rchan_tpl.levels = 2; > - ud->rchan_tpl.start_idx[0] = BCDMA_CAP4_HRCHAN_CNT(cap); > - } else { > - ud->rchan_tpl.levels = 1; > - } > - > - if (BCDMA_CAP4_UTCHAN_CNT(cap)) { > - ud->tchan_tpl.levels = 3; > - ud->tchan_tpl.start_idx[1] = BCDMA_CAP4_UTCHAN_CNT(cap); > - ud->tchan_tpl.start_idx[0] = BCDMA_CAP4_HTCHAN_CNT(cap); > - } else if (BCDMA_CAP4_HTCHAN_CNT(cap)) { > - ud->tchan_tpl.levels = 2; > - ud->tchan_tpl.start_idx[0] = BCDMA_CAP4_HTCHAN_CNT(cap); > - } else { > - ud->tchan_tpl.levels = 1; > - } > - > - ud->bchan_map = devm_kmalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->bchan_cnt)); > - ud->bchans = devm_kzalloc_objs(dev, *ud->bchans, ud->bchan_cnt); > - ud->tchan_map = devm_kmalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->tchan_cnt)); > - ud->tchans = devm_kzalloc_objs(dev, *ud->tchans, ud->tchan_cnt); > - ud->rchan_map = devm_kmalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->rchan_cnt)); > - ud->rchans = devm_kzalloc_objs(dev, *ud->rchans, ud->rchan_cnt); > - /* BCDMA do not really have flows, but the driver expect it */ > - ud->rflow_in_use = devm_kzalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->rchan_cnt)); > - ud->rflows = devm_kzalloc_objs(dev, *ud->rflows, ud->rchan_cnt); > - > - if (!ud->bchan_map || !ud->tchan_map || !ud->rchan_map || > - !ud->rflow_in_use || !ud->bchans || !ud->tchans || !ud->rchans || > - !ud->rflows) > - return -ENOMEM; > > /* Get resource ranges from tisci */ > for (i = 0; i < RM_RANGE_LAST; i++) { > @@ -2464,47 +2408,13 @@ static int bcdma_setup_resources(struct udma_dev *ud) > return 0; > } > > -static int pktdma_setup_resources(struct udma_dev *ud) > +static int pktdma_setup_sci_resources(struct udma_dev *ud) > { > int ret, i, j; > struct device *dev = ud->dev; > struct ti_sci_resource *rm_res, irq_res; > struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; > const struct udma_oes_offsets *oes = &ud->soc_data->oes; > - u32 cap3; > - > - /* Set up the throughput level start indexes */ > - cap3 = udma_read(ud->mmrs[MMR_GCFG], 0x2c); > - if (UDMA_CAP3_UCHAN_CNT(cap3)) { > - ud->tchan_tpl.levels = 3; > - ud->tchan_tpl.start_idx[1] = UDMA_CAP3_UCHAN_CNT(cap3); > - ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); > - } else if (UDMA_CAP3_HCHAN_CNT(cap3)) { > - ud->tchan_tpl.levels = 2; > - ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); > - } else { > - ud->tchan_tpl.levels = 1; > - } > - > - ud->rchan_tpl.levels = ud->tchan_tpl.levels; > - ud->rchan_tpl.start_idx[0] = ud->tchan_tpl.start_idx[0]; > - ud->rchan_tpl.start_idx[1] = ud->tchan_tpl.start_idx[1]; > - > - ud->tchan_map = devm_kmalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->tchan_cnt)); > - ud->tchans = devm_kzalloc_objs(dev, *ud->tchans, ud->tchan_cnt); > - ud->rchan_map = devm_kmalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->rchan_cnt)); > - ud->rchans = devm_kzalloc_objs(dev, *ud->rchans, ud->rchan_cnt); > - ud->rflow_in_use = devm_kzalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->rflow_cnt)); > - ud->rflows = devm_kzalloc_objs(dev, *ud->rflows, ud->rflow_cnt); > - ud->tflow_map = devm_kmalloc_objs(dev, unsigned long, > - BITS_TO_LONGS(ud->tflow_cnt)); > - > - if (!ud->tchan_map || !ud->rchan_map || !ud->tflow_map || !ud->tchans || > - !ud->rchans || !ud->rflows || !ud->rflow_in_use) > - return -ENOMEM; > > /* Get resource ranges from tisci */ > for (i = 0; i < RM_RANGE_LAST; i++) { > @@ -2615,79 +2525,6 @@ static int pktdma_setup_resources(struct udma_dev *ud) > return 0; > } > > -static int setup_resources(struct udma_dev *ud) > -{ > - struct device *dev = ud->dev; > - int ch_count, ret; > - > - switch (ud->match_data->type) { > - case DMA_TYPE_UDMA: > - ret = udma_setup_resources(ud); > - break; > - case DMA_TYPE_BCDMA: > - ret = bcdma_setup_resources(ud); > - break; > - case DMA_TYPE_PKTDMA: > - ret = pktdma_setup_resources(ud); > - break; > - default: > - return -EINVAL; > - } > - > - if (ret) > - return ret; > - > - ch_count = ud->bchan_cnt + ud->tchan_cnt + ud->rchan_cnt; > - if (ud->bchan_cnt) > - ch_count -= bitmap_weight(ud->bchan_map, ud->bchan_cnt); > - ch_count -= bitmap_weight(ud->tchan_map, ud->tchan_cnt); > - ch_count -= bitmap_weight(ud->rchan_map, ud->rchan_cnt); > - if (!ch_count) > - return -ENODEV; > - > - ud->channels = devm_kzalloc_objs(dev, *ud->channels, ch_count); > - if (!ud->channels) > - return -ENOMEM; > - > - switch (ud->match_data->type) { > - case DMA_TYPE_UDMA: > - dev_info(dev, > - "Channels: %d (tchan: %u, rchan: %u, gp-rflow: %u)\n", > - ch_count, > - ud->tchan_cnt - bitmap_weight(ud->tchan_map, > - ud->tchan_cnt), > - ud->rchan_cnt - bitmap_weight(ud->rchan_map, > - ud->rchan_cnt), > - ud->rflow_cnt - bitmap_weight(ud->rflow_gp_map, > - ud->rflow_cnt)); > - break; > - case DMA_TYPE_BCDMA: > - dev_info(dev, > - "Channels: %d (bchan: %u, tchan: %u, rchan: %u)\n", > - ch_count, > - ud->bchan_cnt - bitmap_weight(ud->bchan_map, > - ud->bchan_cnt), > - ud->tchan_cnt - bitmap_weight(ud->tchan_map, > - ud->tchan_cnt), > - ud->rchan_cnt - bitmap_weight(ud->rchan_map, > - ud->rchan_cnt)); > - break; > - case DMA_TYPE_PKTDMA: > - dev_info(dev, > - "Channels: %d (tchan: %u, rchan: %u)\n", > - ch_count, > - ud->tchan_cnt - bitmap_weight(ud->tchan_map, > - ud->tchan_cnt), > - ud->rchan_cnt - bitmap_weight(ud->rchan_map, > - ud->rchan_cnt)); > - break; > - default: > - break; > - } > - > - return ch_count; > -} > - > static int udma_probe(struct platform_device *pdev) > { > struct device_node *navss_node = pdev->dev.parent->of_node; > @@ -2730,6 +2567,9 @@ static int udma_probe(struct platform_device *pdev) > ud->decrement_byte_counters = udma_decrement_byte_counters; > ud->psil_pair = navss_psil_pair; > ud->psil_unpair = navss_psil_unpair; > + ud->udma_setup_resources = udma_setup_resources; > + ud->bcdma_setup_sci_resources = bcdma_setup_sci_resources; > + ud->pktdma_setup_sci_resources = pktdma_setup_sci_resources; > > ret = udma_get_mmrs(pdev, ud); > if (ret) > @@ -2859,7 +2699,7 @@ static int udma_probe(struct platform_device *pdev) > INIT_LIST_HEAD(&ud->ddev.channels); > INIT_LIST_HEAD(&ud->desc_to_purge); > > - ch_count = setup_resources(ud); > + ch_count = k3_udma_setup_resources(ud); > if (ch_count <= 0) > return ch_count; > > diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h > index 0b0626b67ad19..4dd597ef435b8 100644 > --- a/drivers/dma/ti/k3-udma.h > +++ b/drivers/dma/ti/k3-udma.h > @@ -358,6 +358,9 @@ struct udma_dev { > u32 dst_thread); > int (*psil_unpair)(struct udma_dev *ud, u32 src_thread, > u32 dst_thread); > + int (*udma_setup_resources)(struct udma_dev *ud); > + int (*bcdma_setup_sci_resources)(struct udma_dev *ud); > + int (*pktdma_setup_sci_resources)(struct udma_dev *ud); > }; > > struct udma_desc { > @@ -644,6 +647,9 @@ struct udma_bchan *__udma_reserve_bchan(struct udma_dev *ud, enum udma_tp_level > struct udma_tchan *__udma_reserve_tchan(struct udma_dev *ud, enum udma_tp_level tpl, int id); > struct udma_rchan *__udma_reserve_rchan(struct udma_dev *ud, enum udma_tp_level tpl, int id); > > +int udma_setup_resources(struct udma_dev *ud); > +int k3_udma_setup_resources(struct udma_dev *ud); > + > /* Direct access to UDMA low lever resources for the glue layer */ > int xudma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); > int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, > > -- > 2.55.0 > >