From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05484606A322 for ; Thu, 3 Dec 2026 21:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=IF37cGD9; 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=oi2dI/5L DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To: Content-Type:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=q3rYKrdvSKAJF1hNrqvVU22blQUz9q96nHoXT4+3WPY=; b=IF37cGD97Q+KYDD8R12mkpZj/i tLRCFYe2OcnDkP8jIgipZQ1eqGsHEbbJ5IHig739F224Pq1vFea/cIumwiLiJ8p9dJTZLd2BLcMcz wW90cjvAr4Y96CnAnOKWQbfowcRYONoOZxXoVI77J8h1biwAv0xUV66rzm/cSg6qmqXEcm2Z3fci8 XGQut3VieXnBBeMLQnBswDuH4TJw5N7l1qrcGYdO1g5eLhKDE5ZpZghnwFUKGd1MXUMI4vkkvEFKR 4MhsfZP2591AN0+h7TnnMm026Lo4VBysWaTT3U35Egof35HC1a2oa26zMpLzKrucnSKG9DsaH6Zlx nR1xUf8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZElQ-0000000G3KO-3hwr; Thu, 03 Dec 2026 21:54:52 +0000 Received: from mail-westeuropeazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c201::3] helo=AS8PR04CU009.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZElL-0000000G3JW-1rVi for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 21:54:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tcvs32KoY2Li4Gbfs9lwkAbrheRgGoyIdC45Yzs/G/OTqfK+7Rq53ViMIBwSyRSoVG1hg8FvoRKu0g3cZgMvhZtuY5Efl7ajr2OlWz0bIVRx2C/SDOezsWmYZXKaBYhLadjV0OnWX5rv80rbNuytNuva0C4qt1Yhb/L2kWoVPhiY4Ar5mGctPYOKCVFKevmAeHkqrdJ9zpe/VuDW2IHVaRHONKjy5RJKSrbEzbqlkXI9t1OKNVOkxvZ7LT1KRlQwMlB7GzXTL0Iu19mKxFqnIfk+8IoXkOvwai38p8UT5ZDARwivCIwqZ1k1diP+vek8X0GYPe8gUYhYktQeVr5EqQ== 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=q3rYKrdvSKAJF1hNrqvVU22blQUz9q96nHoXT4+3WPY=; b=tdCOEkrsCxjizHjyjtqR21jU7NSqiXydJ1nAfc+l2wl66G84gsarClkwxFfAU65z6g5xn514WlpVS8VhYEn1TO/9X7odLb9s49+FTRfdDXS/WSwzvL36Xf0Vt/M/NpJdq/3k3wMTEyQPNU0Fvn6Utrqu5arcKuSZlhgrHNtClFFyUjdhL6nmRnytlNLm5564fmPFQ9xkstRY2eg9tu/CY/YGcA3CIAOytuFHQMtWck0sCqbBXMgIUbm+cNIqQWI84pMslMDUAysytBq15k7yUDf45exSiYjhgh+z1U/IXgzDIsHFjexjvpUY/l7RT/dOW1V/9FaM0y5Vhx9lHJdiIg== 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=q3rYKrdvSKAJF1hNrqvVU22blQUz9q96nHoXT4+3WPY=; b=oi2dI/5L21pdXgZok6mZxYlaDdiRk7YpvL+5vDWPzIQMcTjJdqFrNT+esi/Tu5t0/drG0RRHr1JZvsmDvu68E0OdSMzpWZsRyzb0c59swRvqdOWOd4HnJDFOqc4xVXyCb60iqDUOFPKgmkAKylihK79EnpcqsdqDsW3LGKJ1WY7stqQb/zTqxxID4Sk/2WAeIEwDCUIE4T3C4wYW1BW//SoRaxY2JVngatJViY2WLpR+hVHL4CdYxjOUf9MEUYtxEUfmiHjElfa5zr9FoOkv8W9iI95H4x37czGwsKdnLKGmV1lKjl3jPkTOUEE+Zssd0qNS2HLAwmtJvV5YIaxGkQ== 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:54:42 +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:54:42 +0000 Date: Thu, 3 Dec 2026 15:54:34 -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 09/20] dmaengine: ti: k3-udma: move resource management functions to k3-udma-common.c Message-ID: References: <20261124-dma-upstream-v13-v13-0-bd4251fdc6d4@ti.com> <20261124-dma-upstream-v13-v13-9-bd4251fdc6d4@ti.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261124-dma-upstream-v13-v13-9-bd4251fdc6d4@ti.com> X-ClientProxiedBy: CPBP307CA0013.DNKP307.PROD.OUTLOOK.COM (2603:10a6:380:2::17) To MI3PR04MB12438.eurprd04.prod.outlook.com (2603:10a6:290:76::14) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MI3PR04MB12438:EE_|VI0PR04MB11482:EE_ X-MS-Office365-Filtering-Correlation-Id: a770e4bc-33bf-479f-00a2-08df5188091d 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|261009220027099003|261009221227099003|261009221727099003|261102130727099003|261021123027099003|261102123227099003|261026121527099003|261028144727099003|261021121427099003|261009223327099003|11063799006|18002099003|22082099003|4143699003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: 5WcfTwEX+3QXJfbPvH1HuSaJtv9WOFYcVQ3FlAEJeMs+wwZ8rLaIYmJQ1gkGHYrfIWDiiCUjUaUPlbxgpt7kwUSYaK92p3XyUJFVNG6YgbqyhVGvvd1sjVfhp+CaxoEAtDnZGWiaqtNSUDhnJV4j4WKo7swgHgvVpnRnEQ6+WnyRUPBdhkRUCa3XY5JZ5zGBeCfdJePaKi0nceRr05uiS7jfKAUnpTK7zlWebqZ87+nEljE6Xyi59PMeOk4UY8Ir+GkZZtacFB6cIaFFpeL2qUZIkLWbSqqmMtAm8CzA/3IjzR+/wOKwDm6XaGK6aujOqRwswNeGTcH48qzrcBxi8D2F3R628OVlfJWbXoFE4/NyBTKbuNuES5Y9Sg+kAzU9IED4NbrjfuhcT4zZOyGcVGLP4bCSDfMgNZuj6xZHuztYiR/OGY1Xg3QCQD6jm1DqD1vYgHof6ipH0Q19ez60Z+oqYNF6iazhHSMga7hVJ6S8M1bLzOI6/qK4PRAsYJwNiCHkPCjrnI8qgNFReqT3k+cUQY7eJilrivsM6pgwWkyDaxo+wGZkEzOWEZsaSqQ3nP2HHlr3xxRYr+tJChw0qrmqk8SJKOH9icW0BKp+PDOdA7FQ00O7WKXgFmGzbJbizYuIHmA44jlonV+V6A7ga55TscRg+rdS2Zj8v+C4A64= 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)(261009220027099003)(261009221227099003)(261009221727099003)(261102130727099003)(261021123027099003)(261102123227099003)(261026121527099003)(261028144727099003)(261021121427099003)(261009223327099003)(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?+8941upyyaMPMQH+FKObYE8XDEiBIFbg3DebvDzq8f/QFjm7uWv87iDg+6Px?= =?us-ascii?Q?t0O6XTd+LxDSnkhDNy5Zav/wDMvUD1F7+XqttN2GgxyYMlN/WDync1iQ7+3e?= =?us-ascii?Q?8xcxwPiEs3ZxJQYjIeAoczUjWD8MWfuFb7l1hDMZGavsEtc0Fd2j9tc6haeU?= =?us-ascii?Q?QQQQOvoy93DSKXWEB7dXqStSbJTS7Rqt5zJUzSjxNNWECh9BsXhlx6CyLKXQ?= =?us-ascii?Q?cUhouRq4JWJUPyvRQ9HrCYsLpQRcd9Zu273lrJRZJcVV1Dwj/XbWhyuT+iLp?= =?us-ascii?Q?RToGs25E5mx0HFNSDOyJS19gh8mQfETZ+igJWrG792vCpNCOTsHYKsDX0LEa?= =?us-ascii?Q?NzocfD3iNea22gO2CL1TIc2ZgH95p5v5dYDVzyMg9hF97jtps4gHEBe74Gsk?= =?us-ascii?Q?uu0zAimqKJA8CEmBwtNxLC01h8r3ku/a6ERpG6vNwcizUSuk9x4O2Mshc5w7?= =?us-ascii?Q?feWbdd/fpHEPnirxLY7wrIA1g7XjmBLiANi+uGgUEruXeU7KDkJkrWyPBctD?= =?us-ascii?Q?Eas+x/soUMBshRzPUhLgq8NnXvmMxMyeZTRU8+FFkS4BGe0Pccn/WsSeKLZ9?= =?us-ascii?Q?DtR67dvE0kxvuvvoM/XsW4Ezv5HFRgz5HrPk5S8+QxlnokVCFFGYZ9Pi0Ako?= =?us-ascii?Q?i7xkF7iNV90xa8Astal7ZZwdbvct317GdZtAQz590t1oqPZZoAqS/Wkh+CNm?= =?us-ascii?Q?ZjTMDxomvbh4trAaPKxKkYg9wFwZ4WIIiCFdFvzyAnKV/6dSFznvbzdXHqtm?= =?us-ascii?Q?Aleqti7KFTn6mJqIcdXTt/okuwRFcOj2kgmw4Cv24aH5Fl3g3On2MMzxBeOQ?= =?us-ascii?Q?Po/HXpRDaKJ5UhoLAtB/VpNR9rNbJQJ40AKRqayC+pxE/Q1D0OEO68+Oi5GB?= =?us-ascii?Q?/PNp9cvvLBV85nWSZHzk4rYR1uPKrGeey7SrlqZ1uFXQbxnOTcPwR1JNRgz7?= =?us-ascii?Q?ZCmUqWgy/TRaE0m0zaxaPefX0gjM20X6MDiDk9Smu6q6T7OAiHi7PzalIaFW?= =?us-ascii?Q?Yp9g5sb2GWIj/eo6b2z0IzIGft+oL+LDzG96UQPaw/7B5YNC9j32lnC+F1Nf?= =?us-ascii?Q?dATKsx7v7zkfi4D8dQ89wmHiQjr1TAeNB3Bll7h/ITewiAPuWJ3GauwmvgGk?= =?us-ascii?Q?Qs+8aIpMSZM4RDPS6LnEX535I1EznIxkf0qmDjfl4FDcWdJkSVT8cBkvIBbG?= =?us-ascii?Q?c+M2g+wgzh7wVDYW6mC4xZ4Kjcyx4uHeKeQethFyNhsz+GN56h0Ha9bJEA6N?= =?us-ascii?Q?72pIGwf0osFJdMS/liV4FJWLtqceMufa+eJLf8xW4zITvyMZbqpAWGb7xGat?= =?us-ascii?Q?PXHUn3OH09Wzj+YhzfSxzjkeyOqUo9EBDJKnEb/YkDnpIJgfwuUiFdcm1fql?= =?us-ascii?Q?yprWgV+UTWYM3c2Q6k0vpXEiqqTeldarOZ/M/W/eKkibW7Knm/njMB0YsTez?= =?us-ascii?Q?LpOjhdopuj+iG7h//rWt6sqPVsjY0WLGrKCGDeGbhj3wnmEImiiJz8yenQGY?= =?us-ascii?Q?TOMNtzqHzPWm/7DK5JZEdsA3vg9UTunSBaBvxanZteBPo9jh/IYag7ROboiI?= =?us-ascii?Q?e1vIfoAMgirjzHkAbIRxYCuaLXAeLikkMhlOCmi7cnKy3flRIknWxrQgRv19?= =?us-ascii?Q?JhBNo09CXGJIE+H/tZk5c2ghrE6KtbOrhmmP/xBdfLAn0ZgZV7GMgkGyM5W3?= =?us-ascii?Q?/s6rgljNXhsVAwH2Dg01RC8IZn01fCH+HaUctEgYjTsjffERbllJIQGUPA+0?= =?us-ascii?Q?ch48Fq0nbcRnf5whXVvkj4Vt1B1ztheNSTfc9YNM3blRYgijeFKP?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a770e4bc-33bf-479f-00a2-08df5188091d 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:54:42.3918 (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: J23+JO1vBva9QeAL68wgLAVWlIz4Uvuftdquu0ZTVra4xbU0BAdwfjLNB8OLivO60JEF//qeW+uuaem7tPsW3a3vUmrw+RgiiY1Zl5WIJtXo4QGpKJr4TkN2hiKzfaGd X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB11482 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261203_135450_939690_486FD9EB X-CRM114-Status: GOOD ( 25.75 ) X-Spam-Score: 0.0 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, Nov 24, 2026 at 05:15:11PM +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 > > Move functions responsible for allocation and release of udma > resources such as channels, rings and flows from k3-udma.c > to the common k3-udma-common.c file. > > The implementation of these functions is largely shared between K3 UDMA > and K3 UDMA v2. 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 | 443 ++++++++++++++++++++++++++++++++++++++++ > drivers/dma/ti/k3-udma.c | 423 -------------------------------------- > drivers/dma/ti/k3-udma.h | 21 ++ > 3 files changed, 464 insertions(+), 423 deletions(-) > > diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-common.c > index 54b95490a56a7..fe41c0cdd3c6b 100644 > --- a/drivers/dma/ti/k3-udma-common.c > +++ b/drivers/dma/ti/k3-udma-common.c > @@ -1897,5 +1897,448 @@ enum dmaengine_alignment udma_get_copy_align(struct udma_dev *ud) > } > EXPORT_SYMBOL_GPL(udma_get_copy_align); > > +/** > + * __udma_alloc_gp_rflow_range - alloc range of GP RX flows > + * @ud: UDMA device > + * @from: Start the search from this flow id number > + * @cnt: Number of consecutive flow ids to allocate > + * > + * Allocate range of RX flow ids for future use, those flows can be requested > + * only using explicit flow id number. if @from is set to -1 it will try to find > + * first free range. if @from is positive value it will force allocation only > + * of the specified range of flows. > + * > + * Returns -ENOMEM if can't find free range. > + * -EEXIST if requested range is busy. > + * -EINVAL if wrong input values passed. > + * Returns flow id on success. > + */ > +int __udma_alloc_gp_rflow_range(struct udma_dev *ud, int from, int cnt) > +{ > + int start, tmp_from; > + DECLARE_BITMAP(tmp, K3_UDMA_MAX_RFLOWS); > + > + tmp_from = from; > + if (tmp_from < 0) > + tmp_from = ud->rchan_cnt; > + /* default flows can't be allocated and accessible only by id */ > + if (tmp_from < ud->rchan_cnt) > + return -EINVAL; > + > + if (tmp_from + cnt > ud->rflow_cnt) > + return -EINVAL; > + > + bitmap_or(tmp, ud->rflow_gp_map, ud->rflow_gp_map_allocated, > + ud->rflow_cnt); > + > + start = bitmap_find_next_zero_area(tmp, > + ud->rflow_cnt, > + tmp_from, cnt, 0); > + if (start >= ud->rflow_cnt) > + return -ENOMEM; > + > + if (from >= 0 && start != from) > + return -EEXIST; > + > + bitmap_set(ud->rflow_gp_map_allocated, start, cnt); > + return start; > +} > +EXPORT_SYMBOL_GPL(__udma_alloc_gp_rflow_range); > + > +int __udma_free_gp_rflow_range(struct udma_dev *ud, int from, int cnt) > +{ > + if (from < ud->rchan_cnt) > + return -EINVAL; > + if (from + cnt > ud->rflow_cnt) > + return -EINVAL; > + > + bitmap_clear(ud->rflow_gp_map_allocated, from, cnt); > + return 0; > +} > +EXPORT_SYMBOL_GPL(__udma_free_gp_rflow_range); > + > +struct udma_rflow *__udma_get_rflow(struct udma_dev *ud, int id) > +{ > + /* > + * Attempt to request rflow by ID can be made for any rflow > + * if not in use with assumption that caller knows what's doing. > + * TI-SCI FW will perform additional permission check ant way, it's > + * safe > + */ > + > + if (id < 0 || id >= ud->rflow_cnt) > + return ERR_PTR(-ENOENT); > + > + if (test_bit(id, ud->rflow_in_use)) > + return ERR_PTR(-ENOENT); > + > + if (ud->rflow_gp_map) { > + /* GP rflow has to be allocated first */ > + if (!test_bit(id, ud->rflow_gp_map) && > + !test_bit(id, ud->rflow_gp_map_allocated)) > + return ERR_PTR(-EINVAL); > + } > + > + dev_dbg(ud->dev, "get rflow%d\n", id); > + set_bit(id, ud->rflow_in_use); > + return &ud->rflows[id]; > +} > +EXPORT_SYMBOL_GPL(__udma_get_rflow); > + > +void __udma_put_rflow(struct udma_dev *ud, struct udma_rflow *rflow) > +{ > + if (!test_bit(rflow->id, ud->rflow_in_use)) { > + dev_err(ud->dev, "attempt to put unused rflow%d\n", rflow->id); > + return; > + } > + > + dev_dbg(ud->dev, "put rflow%d\n", rflow->id); > + clear_bit(rflow->id, ud->rflow_in_use); > +} > +EXPORT_SYMBOL_GPL(__udma_put_rflow); > + > +#define UDMA_RESERVE_RESOURCE(res) \ > +struct udma_##res *__udma_reserve_##res(struct udma_dev *ud, \ > + enum udma_tp_level tpl, \ > + int id) \ > +{ \ > + if (id >= 0) { \ > + if (test_bit(id, ud->res##_map)) { \ > + dev_err(ud->dev, "res##%d is in use\n", id); \ > + return ERR_PTR(-ENOENT); \ > + } \ > + } else { \ > + int start; \ > + \ > + if (tpl >= ud->res##_tpl.levels) \ > + tpl = ud->res##_tpl.levels - 1; \ > + \ > + start = ud->res##_tpl.start_idx[tpl]; \ > + \ > + id = find_next_zero_bit(ud->res##_map, ud->res##_cnt, \ > + start); \ > + if (id == ud->res##_cnt) { \ > + return ERR_PTR(-ENOENT); \ > + } \ > + } \ > + \ > + set_bit(id, ud->res##_map); \ > + return &ud->res##s[id]; \ > +} > + > +UDMA_RESERVE_RESOURCE(bchan); > +EXPORT_SYMBOL_GPL(__udma_reserve_bchan); > +UDMA_RESERVE_RESOURCE(tchan); > +EXPORT_SYMBOL_GPL(__udma_reserve_tchan); > +UDMA_RESERVE_RESOURCE(rchan); > +EXPORT_SYMBOL_GPL(__udma_reserve_rchan); > + > +int udma_get_tchan(struct udma_chan *uc) > +{ > + struct udma_dev *ud = uc->ud; > + int ret; > + > + if (uc->tchan) { > + dev_dbg(ud->dev, "chan%d: already have tchan%d allocated\n", > + uc->id, uc->tchan->id); > + return 0; > + } > + > + /* > + * mapped_channel_id is -1 for UDMA, BCDMA and PKTDMA unmapped channels. > + * For PKTDMA mapped channels it is configured to a channel which must > + * be used to service the peripheral. > + */ > + uc->tchan = __udma_reserve_tchan(ud, uc->config.channel_tpl, > + uc->config.mapped_channel_id); > + if (IS_ERR(uc->tchan)) { > + ret = PTR_ERR(uc->tchan); > + uc->tchan = NULL; > + return ret; > + } > + > + if (ud->tflow_cnt) { > + int tflow_id; > + > + /* Only PKTDMA have support for tx flows */ > + if (uc->config.default_flow_id >= 0) > + tflow_id = uc->config.default_flow_id; > + else > + tflow_id = uc->tchan->id; > + > + if (test_bit(tflow_id, ud->tflow_map)) { > + dev_err(ud->dev, "tflow%d is in use\n", tflow_id); > + clear_bit(uc->tchan->id, ud->tchan_map); > + uc->tchan = NULL; > + return -ENOENT; > + } > + > + uc->tchan->tflow_id = tflow_id; > + set_bit(tflow_id, ud->tflow_map); > + } else { > + uc->tchan->tflow_id = -1; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(udma_get_tchan); > + > +int udma_get_rchan(struct udma_chan *uc) > +{ > + struct udma_dev *ud = uc->ud; > + int ret; > + > + if (uc->rchan) { > + dev_dbg(ud->dev, "chan%d: already have rchan%d allocated\n", > + uc->id, uc->rchan->id); > + return 0; > + } > + > + /* > + * mapped_channel_id is -1 for UDMA, BCDMA and PKTDMA unmapped channels. > + * For PKTDMA mapped channels it is configured to a channel which must > + * be used to service the peripheral. > + */ > + uc->rchan = __udma_reserve_rchan(ud, uc->config.channel_tpl, > + uc->config.mapped_channel_id); > + if (IS_ERR(uc->rchan)) { > + ret = PTR_ERR(uc->rchan); > + uc->rchan = NULL; > + return ret; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(udma_get_rchan); > + > +int udma_get_chan_pair(struct udma_chan *uc) > +{ > + struct udma_dev *ud = uc->ud; > + int chan_id, end; > + > + if ((uc->tchan && uc->rchan) && uc->tchan->id == uc->rchan->id) { > + dev_info(ud->dev, "chan%d: already have %d pair allocated\n", > + uc->id, uc->tchan->id); > + return 0; > + } > + > + if (uc->tchan) { > + dev_err(ud->dev, "chan%d: already have tchan%d allocated\n", > + uc->id, uc->tchan->id); > + return -EBUSY; > + } else if (uc->rchan) { > + dev_err(ud->dev, "chan%d: already have rchan%d allocated\n", > + uc->id, uc->rchan->id); > + return -EBUSY; > + } > + > + /* Can be optimized, but let's have it like this for now */ > + end = min(ud->tchan_cnt, ud->rchan_cnt); > + /* > + * Try to use the highest TPL channel pair for MEM_TO_MEM channels > + * Note: in UDMAP the channel TPL is symmetric between tchan and rchan > + */ > + chan_id = ud->tchan_tpl.start_idx[ud->tchan_tpl.levels - 1]; > + for (; chan_id < end; chan_id++) { > + if (!test_bit(chan_id, ud->tchan_map) && > + !test_bit(chan_id, ud->rchan_map)) > + break; > + } > + > + if (chan_id == end) > + return -ENOENT; > + > + set_bit(chan_id, ud->tchan_map); > + set_bit(chan_id, ud->rchan_map); > + uc->tchan = &ud->tchans[chan_id]; > + uc->rchan = &ud->rchans[chan_id]; > + > + /* UDMA does not use tx flows */ > + uc->tchan->tflow_id = -1; > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(udma_get_chan_pair); > + > +int udma_get_rflow(struct udma_chan *uc, int flow_id) > +{ > + struct udma_dev *ud = uc->ud; > + int ret; > + > + if (!uc->rchan) { > + dev_err(ud->dev, "chan%d: does not have rchan??\n", uc->id); > + return -EINVAL; > + } > + > + if (uc->rflow) { > + dev_dbg(ud->dev, "chan%d: already have rflow%d allocated\n", > + uc->id, uc->rflow->id); > + return 0; > + } > + > + uc->rflow = __udma_get_rflow(ud, flow_id); > + if (IS_ERR(uc->rflow)) { > + ret = PTR_ERR(uc->rflow); > + uc->rflow = NULL; > + return ret; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(udma_get_rflow); > + > +void udma_put_rchan(struct udma_chan *uc) > +{ > + struct udma_dev *ud = uc->ud; > + > + if (uc->rchan) { > + dev_dbg(ud->dev, "chan%d: put rchan%d\n", uc->id, > + uc->rchan->id); > + clear_bit(uc->rchan->id, ud->rchan_map); > + uc->rchan = NULL; > + } > +} > +EXPORT_SYMBOL_GPL(udma_put_rchan); > + > +void udma_put_tchan(struct udma_chan *uc) > +{ > + struct udma_dev *ud = uc->ud; > + > + if (uc->tchan) { > + dev_dbg(ud->dev, "chan%d: put tchan%d\n", uc->id, > + uc->tchan->id); > + clear_bit(uc->tchan->id, ud->tchan_map); > + > + if (uc->tchan->tflow_id >= 0) > + clear_bit(uc->tchan->tflow_id, ud->tflow_map); > + > + uc->tchan = NULL; > + } > +} > +EXPORT_SYMBOL_GPL(udma_put_tchan); > + > +void udma_put_rflow(struct udma_chan *uc) > +{ > + struct udma_dev *ud = uc->ud; > + > + if (uc->rflow) { > + dev_dbg(ud->dev, "chan%d: put rflow%d\n", uc->id, > + uc->rflow->id); > + __udma_put_rflow(ud, uc->rflow); > + uc->rflow = NULL; > + } > +} > +EXPORT_SYMBOL_GPL(udma_put_rflow); > + > +void udma_free_tx_resources(struct udma_chan *uc) > +{ > + if (!uc->tchan) > + return; > + > + k3_ringacc_ring_free(uc->tchan->t_ring); > + k3_ringacc_ring_free(uc->tchan->tc_ring); > + uc->tchan->t_ring = NULL; > + uc->tchan->tc_ring = NULL; > + > + udma_put_tchan(uc); > +} > +EXPORT_SYMBOL_GPL(udma_free_tx_resources); > + > +void udma_free_rx_resources(struct udma_chan *uc) > +{ > + if (!uc->rchan) > + return; > + > + if (uc->rflow) { > + struct udma_rflow *rflow = uc->rflow; > + > + k3_ringacc_ring_free(rflow->fd_ring); > + k3_ringacc_ring_free(rflow->r_ring); > + rflow->fd_ring = NULL; > + rflow->r_ring = NULL; > + > + udma_put_rflow(uc); > + } > + > + udma_put_rchan(uc); > +} > +EXPORT_SYMBOL_GPL(udma_free_rx_resources); > + > +void udma_free_chan_resources(struct dma_chan *chan) > +{ > + struct udma_chan *uc = to_udma_chan(chan); > + struct udma_dev *ud = to_udma_dev(chan->device); > + > + udma_terminate_all(chan); > + if (uc->terminated_desc) { > + ud->reset_chan(uc, false); > + udma_reset_rings(uc); > + } > + > + cancel_delayed_work_sync(&uc->tx_drain.work); > + > + if (uc->irq_num_ring > 0) { > + free_irq(uc->irq_num_ring, uc); > + > + uc->irq_num_ring = 0; > + } > + if (uc->irq_num_udma > 0) { > + free_irq(uc->irq_num_udma, uc); > + > + uc->irq_num_udma = 0; > + } > + > + /* Release PSI-L pairing */ > + if (uc->psil_paired) { > + if (ud->psil_unpair) > + ud->psil_unpair(ud, uc->config.src_thread, > + uc->config.dst_thread); > + uc->psil_paired = false; > + } > + > + vchan_free_chan_resources(&uc->vc); > + tasklet_kill(&uc->vc.task); > + > + bcdma_free_bchan_resources(uc); > + udma_free_tx_resources(uc); > + udma_free_rx_resources(uc); > + udma_reset_uchan(uc); > + > + if (uc->use_dma_pool) { > + dma_pool_destroy(uc->hdesc_pool); > + uc->use_dma_pool = false; > + } > +} > +EXPORT_SYMBOL_GPL(udma_free_chan_resources); > + > +void bcdma_put_bchan(struct udma_chan *uc) > +{ > + struct udma_dev *ud = uc->ud; > + > + if (uc->bchan) { > + dev_dbg(ud->dev, "chan%d: put bchan%d\n", uc->id, > + uc->bchan->id); > + clear_bit(uc->bchan->id, ud->bchan_map); > + uc->bchan = NULL; > + uc->tchan = NULL; > + } > +} > +EXPORT_SYMBOL_GPL(bcdma_put_bchan); > + > +void bcdma_free_bchan_resources(struct udma_chan *uc) > +{ > + if (!uc->bchan) > + return; > + > + k3_ringacc_ring_free(uc->bchan->tc_ring); > + k3_ringacc_ring_free(uc->bchan->t_ring); > + uc->bchan->tc_ring = NULL; > + uc->bchan->t_ring = NULL; > + k3_configure_chan_coherency(&uc->vc.chan, 0); > + > + bcdma_put_bchan(uc); > +} > +EXPORT_SYMBOL_GPL(bcdma_free_bchan_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 15a3de16f50f6..9805650df3d09 100644 > --- a/drivers/dma/ti/k3-udma.c > +++ b/drivers/dma/ti/k3-udma.c > @@ -423,135 +423,6 @@ static irqreturn_t udma_udma_irq_handler(int irq, void *data) > return IRQ_HANDLED; > } > > -/** > - * __udma_alloc_gp_rflow_range - alloc range of GP RX flows > - * @ud: UDMA device > - * @from: Start the search from this flow id number > - * @cnt: Number of consecutive flow ids to allocate > - * > - * Allocate range of RX flow ids for future use, those flows can be requested > - * only using explicit flow id number. if @from is set to -1 it will try to find > - * first free range. if @from is positive value it will force allocation only > - * of the specified range of flows. > - * > - * Returns -ENOMEM if can't find free range. > - * -EEXIST if requested range is busy. > - * -EINVAL if wrong input values passed. > - * Returns flow id on success. > - */ > -static int __udma_alloc_gp_rflow_range(struct udma_dev *ud, int from, int cnt) > -{ > - int start, tmp_from; > - DECLARE_BITMAP(tmp, K3_UDMA_MAX_RFLOWS); > - > - tmp_from = from; > - if (tmp_from < 0) > - tmp_from = ud->rchan_cnt; > - /* default flows can't be allocated and accessible only by id */ > - if (tmp_from < ud->rchan_cnt) > - return -EINVAL; > - > - if (tmp_from + cnt > ud->rflow_cnt) > - return -EINVAL; > - > - bitmap_or(tmp, ud->rflow_gp_map, ud->rflow_gp_map_allocated, > - ud->rflow_cnt); > - > - start = bitmap_find_next_zero_area(tmp, > - ud->rflow_cnt, > - tmp_from, cnt, 0); > - if (start >= ud->rflow_cnt) > - return -ENOMEM; > - > - if (from >= 0 && start != from) > - return -EEXIST; > - > - bitmap_set(ud->rflow_gp_map_allocated, start, cnt); > - return start; > -} > - > -static int __udma_free_gp_rflow_range(struct udma_dev *ud, int from, int cnt) > -{ > - if (from < ud->rchan_cnt) > - return -EINVAL; > - if (from + cnt > ud->rflow_cnt) > - return -EINVAL; > - > - bitmap_clear(ud->rflow_gp_map_allocated, from, cnt); > - return 0; > -} > - > -static struct udma_rflow *__udma_get_rflow(struct udma_dev *ud, int id) > -{ > - /* > - * Attempt to request rflow by ID can be made for any rflow > - * if not in use with assumption that caller knows what's doing. > - * TI-SCI FW will perform additional permission check ant way, it's > - * safe > - */ > - > - if (id < 0 || id >= ud->rflow_cnt) > - return ERR_PTR(-ENOENT); > - > - if (test_bit(id, ud->rflow_in_use)) > - return ERR_PTR(-ENOENT); > - > - if (ud->rflow_gp_map) { > - /* GP rflow has to be allocated first */ > - if (!test_bit(id, ud->rflow_gp_map) && > - !test_bit(id, ud->rflow_gp_map_allocated)) > - return ERR_PTR(-EINVAL); > - } > - > - dev_dbg(ud->dev, "get rflow%d\n", id); > - set_bit(id, ud->rflow_in_use); > - return &ud->rflows[id]; > -} > - > -static void __udma_put_rflow(struct udma_dev *ud, struct udma_rflow *rflow) > -{ > - if (!test_bit(rflow->id, ud->rflow_in_use)) { > - dev_err(ud->dev, "attempt to put unused rflow%d\n", rflow->id); > - return; > - } > - > - dev_dbg(ud->dev, "put rflow%d\n", rflow->id); > - clear_bit(rflow->id, ud->rflow_in_use); > -} > - > -#define UDMA_RESERVE_RESOURCE(res) \ > -static struct udma_##res *__udma_reserve_##res(struct udma_dev *ud, \ > - enum udma_tp_level tpl, \ > - int id) \ > -{ \ > - if (id >= 0) { \ > - if (test_bit(id, ud->res##_map)) { \ > - dev_err(ud->dev, "res##%d is in use\n", id); \ > - return ERR_PTR(-ENOENT); \ > - } \ > - } else { \ > - int start; \ > - \ > - if (tpl >= ud->res##_tpl.levels) \ > - tpl = ud->res##_tpl.levels - 1; \ > - \ > - start = ud->res##_tpl.start_idx[tpl]; \ > - \ > - id = find_next_zero_bit(ud->res##_map, ud->res##_cnt, \ > - start); \ > - if (id == ud->res##_cnt) { \ > - return ERR_PTR(-ENOENT); \ > - } \ > - } \ > - \ > - set_bit(id, ud->res##_map); \ > - return &ud->res##s[id]; \ > -} > - > -UDMA_RESERVE_RESOURCE(bchan); > -UDMA_RESERVE_RESOURCE(tchan); > -UDMA_RESERVE_RESOURCE(rchan); > - > static int bcdma_get_bchan(struct udma_chan *uc) > { > struct udma_dev *ud = uc->ud; > @@ -585,223 +456,6 @@ static int bcdma_get_bchan(struct udma_chan *uc) > return 0; > } > > -static int udma_get_tchan(struct udma_chan *uc) > -{ > - struct udma_dev *ud = uc->ud; > - int ret; > - > - if (uc->tchan) { > - dev_dbg(ud->dev, "chan%d: already have tchan%d allocated\n", > - uc->id, uc->tchan->id); > - return 0; > - } > - > - /* > - * mapped_channel_id is -1 for UDMA, BCDMA and PKTDMA unmapped channels. > - * For PKTDMA mapped channels it is configured to a channel which must > - * be used to service the peripheral. > - */ > - uc->tchan = __udma_reserve_tchan(ud, uc->config.channel_tpl, > - uc->config.mapped_channel_id); > - if (IS_ERR(uc->tchan)) { > - ret = PTR_ERR(uc->tchan); > - uc->tchan = NULL; > - return ret; > - } > - > - if (ud->tflow_cnt) { > - int tflow_id; > - > - /* Only PKTDMA have support for tx flows */ > - if (uc->config.default_flow_id >= 0) > - tflow_id = uc->config.default_flow_id; > - else > - tflow_id = uc->tchan->id; > - > - if (test_bit(tflow_id, ud->tflow_map)) { > - dev_err(ud->dev, "tflow%d is in use\n", tflow_id); > - clear_bit(uc->tchan->id, ud->tchan_map); > - uc->tchan = NULL; > - return -ENOENT; > - } > - > - uc->tchan->tflow_id = tflow_id; > - set_bit(tflow_id, ud->tflow_map); > - } else { > - uc->tchan->tflow_id = -1; > - } > - > - return 0; > -} > - > -static int udma_get_rchan(struct udma_chan *uc) > -{ > - struct udma_dev *ud = uc->ud; > - int ret; > - > - if (uc->rchan) { > - dev_dbg(ud->dev, "chan%d: already have rchan%d allocated\n", > - uc->id, uc->rchan->id); > - return 0; > - } > - > - /* > - * mapped_channel_id is -1 for UDMA, BCDMA and PKTDMA unmapped channels. > - * For PKTDMA mapped channels it is configured to a channel which must > - * be used to service the peripheral. > - */ > - uc->rchan = __udma_reserve_rchan(ud, uc->config.channel_tpl, > - uc->config.mapped_channel_id); > - if (IS_ERR(uc->rchan)) { > - ret = PTR_ERR(uc->rchan); > - uc->rchan = NULL; > - return ret; > - } > - > - return 0; > -} > - > -static int udma_get_chan_pair(struct udma_chan *uc) > -{ > - struct udma_dev *ud = uc->ud; > - int chan_id, end; > - > - if ((uc->tchan && uc->rchan) && uc->tchan->id == uc->rchan->id) { > - dev_info(ud->dev, "chan%d: already have %d pair allocated\n", > - uc->id, uc->tchan->id); > - return 0; > - } > - > - if (uc->tchan) { > - dev_err(ud->dev, "chan%d: already have tchan%d allocated\n", > - uc->id, uc->tchan->id); > - return -EBUSY; > - } else if (uc->rchan) { > - dev_err(ud->dev, "chan%d: already have rchan%d allocated\n", > - uc->id, uc->rchan->id); > - return -EBUSY; > - } > - > - /* Can be optimized, but let's have it like this for now */ > - end = min(ud->tchan_cnt, ud->rchan_cnt); > - /* > - * Try to use the highest TPL channel pair for MEM_TO_MEM channels > - * Note: in UDMAP the channel TPL is symmetric between tchan and rchan > - */ > - chan_id = ud->tchan_tpl.start_idx[ud->tchan_tpl.levels - 1]; > - for (; chan_id < end; chan_id++) { > - if (!test_bit(chan_id, ud->tchan_map) && > - !test_bit(chan_id, ud->rchan_map)) > - break; > - } > - > - if (chan_id == end) > - return -ENOENT; > - > - set_bit(chan_id, ud->tchan_map); > - set_bit(chan_id, ud->rchan_map); > - uc->tchan = &ud->tchans[chan_id]; > - uc->rchan = &ud->rchans[chan_id]; > - > - /* UDMA does not use tx flows */ > - uc->tchan->tflow_id = -1; > - > - return 0; > -} > - > -static int udma_get_rflow(struct udma_chan *uc, int flow_id) > -{ > - struct udma_dev *ud = uc->ud; > - int ret; > - > - if (!uc->rchan) { > - dev_err(ud->dev, "chan%d: does not have rchan??\n", uc->id); > - return -EINVAL; > - } > - > - if (uc->rflow) { > - dev_dbg(ud->dev, "chan%d: already have rflow%d allocated\n", > - uc->id, uc->rflow->id); > - return 0; > - } > - > - uc->rflow = __udma_get_rflow(ud, flow_id); > - if (IS_ERR(uc->rflow)) { > - ret = PTR_ERR(uc->rflow); > - uc->rflow = NULL; > - return ret; > - } > - > - return 0; > -} > - > -static void bcdma_put_bchan(struct udma_chan *uc) > -{ > - struct udma_dev *ud = uc->ud; > - > - if (uc->bchan) { > - dev_dbg(ud->dev, "chan%d: put bchan%d\n", uc->id, > - uc->bchan->id); > - clear_bit(uc->bchan->id, ud->bchan_map); > - uc->bchan = NULL; > - uc->tchan = NULL; > - } > -} > - > -static void udma_put_rchan(struct udma_chan *uc) > -{ > - struct udma_dev *ud = uc->ud; > - > - if (uc->rchan) { > - dev_dbg(ud->dev, "chan%d: put rchan%d\n", uc->id, > - uc->rchan->id); > - clear_bit(uc->rchan->id, ud->rchan_map); > - uc->rchan = NULL; > - } > -} > - > -static void udma_put_tchan(struct udma_chan *uc) > -{ > - struct udma_dev *ud = uc->ud; > - > - if (uc->tchan) { > - dev_dbg(ud->dev, "chan%d: put tchan%d\n", uc->id, > - uc->tchan->id); > - clear_bit(uc->tchan->id, ud->tchan_map); > - > - if (uc->tchan->tflow_id >= 0) > - clear_bit(uc->tchan->tflow_id, ud->tflow_map); > - > - uc->tchan = NULL; > - } > -} > - > -static void udma_put_rflow(struct udma_chan *uc) > -{ > - struct udma_dev *ud = uc->ud; > - > - if (uc->rflow) { > - dev_dbg(ud->dev, "chan%d: put rflow%d\n", uc->id, > - uc->rflow->id); > - __udma_put_rflow(ud, uc->rflow); > - uc->rflow = NULL; > - } > -} > - > -static void bcdma_free_bchan_resources(struct udma_chan *uc) > -{ > - if (!uc->bchan) > - return; > - > - k3_ringacc_ring_free(uc->bchan->tc_ring); > - k3_ringacc_ring_free(uc->bchan->t_ring); > - uc->bchan->tc_ring = NULL; > - uc->bchan->t_ring = NULL; > - k3_configure_chan_coherency(&uc->vc.chan, 0); > - > - bcdma_put_bchan(uc); > -} > - > static int bcdma_alloc_bchan_resources(struct udma_chan *uc) > { > struct k3_ring_cfg ring_cfg; > @@ -847,19 +501,6 @@ static int bcdma_alloc_bchan_resources(struct udma_chan *uc) > return ret; > } > > -static void udma_free_tx_resources(struct udma_chan *uc) > -{ > - if (!uc->tchan) > - return; > - > - k3_ringacc_ring_free(uc->tchan->t_ring); > - k3_ringacc_ring_free(uc->tchan->tc_ring); > - uc->tchan->t_ring = NULL; > - uc->tchan->tc_ring = NULL; > - > - udma_put_tchan(uc); > -} > - > static int udma_alloc_tx_resources(struct udma_chan *uc) > { > struct k3_ring_cfg ring_cfg; > @@ -917,25 +558,6 @@ static int udma_alloc_tx_resources(struct udma_chan *uc) > return ret; > } > > -static void udma_free_rx_resources(struct udma_chan *uc) > -{ > - if (!uc->rchan) > - return; > - > - if (uc->rflow) { > - struct udma_rflow *rflow = uc->rflow; > - > - k3_ringacc_ring_free(rflow->fd_ring); > - k3_ringacc_ring_free(rflow->r_ring); > - rflow->fd_ring = NULL; > - rflow->r_ring = NULL; > - > - udma_put_rflow(uc); > - } > - > - udma_put_rchan(uc); > -} > - > static int udma_alloc_rx_resources(struct udma_chan *uc) > { > struct udma_dev *ud = uc->ud; > @@ -2024,51 +1646,6 @@ static int udma_resume(struct dma_chan *chan) > return 0; > } > > -static void udma_free_chan_resources(struct dma_chan *chan) > -{ > - struct udma_chan *uc = to_udma_chan(chan); > - struct udma_dev *ud = to_udma_dev(chan->device); > - > - udma_terminate_all(chan); > - if (uc->terminated_desc) { > - ud->reset_chan(uc, false); > - udma_reset_rings(uc); > - } > - > - cancel_delayed_work_sync(&uc->tx_drain.work); > - > - if (uc->irq_num_ring > 0) { > - free_irq(uc->irq_num_ring, uc); > - > - uc->irq_num_ring = 0; > - } > - if (uc->irq_num_udma > 0) { > - free_irq(uc->irq_num_udma, uc); > - > - uc->irq_num_udma = 0; > - } > - > - /* Release PSI-L pairing */ > - if (uc->psil_paired) { > - ud->psil_unpair(ud, uc->config.src_thread, > - uc->config.dst_thread); > - uc->psil_paired = false; > - } > - > - vchan_free_chan_resources(&uc->vc); > - tasklet_kill(&uc->vc.task); > - > - bcdma_free_bchan_resources(uc); > - udma_free_tx_resources(uc); > - udma_free_rx_resources(uc); > - udma_reset_uchan(uc); > - > - if (uc->use_dma_pool) { > - dma_pool_destroy(uc->hdesc_pool); > - uc->use_dma_pool = false; > - } > -} > - > static struct platform_driver udma_driver; > static struct platform_driver bcdma_driver; > static struct platform_driver pktdma_driver; > diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h > index a6d7aba83a09b..0b0626b67ad19 100644 > --- a/drivers/dma/ti/k3-udma.h > +++ b/drivers/dma/ti/k3-udma.h > @@ -623,6 +623,27 @@ void udma_dbg_summary_show(struct seq_file *s, > struct dma_device *dma_dev); > #endif /* CONFIG_DEBUG_FS */ > > +int __udma_alloc_gp_rflow_range(struct udma_dev *ud, int from, int cnt); > +int __udma_free_gp_rflow_range(struct udma_dev *ud, int from, int cnt); > +struct udma_rflow *__udma_get_rflow(struct udma_dev *ud, int id); > +void __udma_put_rflow(struct udma_dev *ud, struct udma_rflow *rflow); > +int udma_get_tchan(struct udma_chan *uc); > +int udma_get_rchan(struct udma_chan *uc); > +int udma_get_chan_pair(struct udma_chan *uc); > +int udma_get_rflow(struct udma_chan *uc, int flow_id); > +void udma_put_rchan(struct udma_chan *uc); > +void udma_put_tchan(struct udma_chan *uc); > +void udma_put_rflow(struct udma_chan *uc); > +void udma_free_tx_resources(struct udma_chan *uc); > +void udma_free_rx_resources(struct udma_chan *uc); > +void udma_free_chan_resources(struct dma_chan *chan); > +void bcdma_put_bchan(struct udma_chan *uc); > +void bcdma_free_bchan_resources(struct udma_chan *uc); > + > +struct udma_bchan *__udma_reserve_bchan(struct udma_dev *ud, enum udma_tp_level tpl, int id); > +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); > + > /* 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 > >