From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 54BDC427F85; Fri, 24 Jul 2026 10:21:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888514; cv=fail; b=OzKNsEVl9JAYIEqEqZP/t1qlAiNCsO+1rIcDMwOM5o77z9NwgE4IAjwMThkT382qJ2bYm9NC42JimWfFe6Hn/3roVgsyHhoU000Fx39A3FUCz/RYQHKmLnaML5KIFfFF0MX3f8siot3nGSTMAqK0TYuL3Bw0dmsAvyAea/N5JZI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888514; c=relaxed/simple; bh=CLWs30bM4rdb9SptEfdnX07cQImLdMRoX+quREV4Vv4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JpNHZ/zaPhYMgbzqCfY7Qr32B0VkQgYZqtG4TJTZgOYpXvdBfJiY1b6F6r3JAQAXwb6GyUedoa/T1qVAh9asiOt7sqMp0R2d5KUu3imfTAPVu4kCjX0sdBFgepXaX1F1m+KaV5zzp3ZfI2hJPRPenyLqQbsJ1RpHDlXWOLmLeOY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=WuW6+uc2; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=KQy/Plpt; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="WuW6+uc2"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="KQy/Plpt" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAF8KI2796751; Fri, 24 Jul 2026 05:21:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=EPWDEmvEVzUQf5oEGlvVWe6wtqyk8cbFBWHDBECuw LI=; b=WuW6+uc2OOx5Mj9l2v67Pj503h7CjTK9uY7b4IeaGahaesJQoVhUK0lDi 3rC9bbFaGSnm5+fJ49VCkkZBkOfnHx732qpJK5kdP40zMrHxIps/JSLenLufl+Lh 1cbGMt7xbMOR0/pXwVAUaL+eTKNgIdeeyOFWneje32NV1CL1iMcNtOfnAOwet/RO LQdjz6qbgwfkblG7wks89AurJJ3ZW9rPglpwpxBR14D4lRmwZUgWAzR+jMwBY/Dx KoOzQ4z2vHmW7k3eqVG9ZvL2EepOaA18t2A9lOroGuEniCAbZDckaqQWY6hRxqvB RP3SIE9pkT/RW3T0pDk4RB0zozOxw== Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azon11010048.outbound.protection.outlook.com [52.101.56.48]) by m0384305.ppops.net (PPS) with ESMTPS id 4fm3v38psn-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:21:40 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tyUGNUg7sBa6UPLJx7RvUJRGkQK1uTf63u7x2TtgwHO1s5Nz00OS9SH0HUk1pVsNATZt6hOLcoLxiTxTnQN1xQ2caH3d+xpjCym4KfeMiJxlXVYSSstlvmrDPCxCCBF7sjUVhjocx8cBsp7+48Erx2LsNywTHsqihdyMMcqwuEbIUEuYNasfwsUHtj7B/AxL8OBxAyfAlprKlQjboC4iQCReOIBjzwGqD0h4JE12hDVDdnzEWzL2FVq7lmVw1bQT5fuLULkezlkHhK0V27WoegxZ5oN/pTHy8mKJi3NHWo1I6AMDD+4X04fvJGR6qKghJ0Te/UOr05+L5H1SSlAkSw== 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=EPWDEmvEVzUQf5oEGlvVWe6wtqyk8cbFBWHDBECuwLI=; b=hJ6BPON/v6YD6nqb2MFOKt7j28JRR8Y4DH+bX4cjm14Mw3PBWmuSRFWzr5yh0hoa4/qTIIkcMrO8b5gIvRGfk6A59ete8eIkr5cSjEF1mm7+LiB5zzsb59ZiVQZUrg9adBvg6Xyf/ud7SHyrMpCHn+J+NzwwqoZQCYGEtp/el1dbbHPiT8e7PKEkd+/yaMIB0rEexepgd1i7V6GO4sj6RyqMdjJC7tNyCmUjg4iT58NIlYjJdamlhAZ9KyYwF43pVYCv0iiY6evO8SRhvbp3wMM85r7avuhmj17KK3X57rlb9dT2o/S6G7xoUTjFZhcKPYCcv5hirASidRS9V00/YQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EPWDEmvEVzUQf5oEGlvVWe6wtqyk8cbFBWHDBECuwLI=; b=KQy/Plpt9558tzd9u4PMz9Ey8tQahlwiHgjEBZhQejgOGMG7Sb+ugVHC2ZBUApaqmhqqZIbIw40NKPn0cj0xpMEoYuif261KWYn9M2Jj63qNzc1QIOAvgZ7EhrVhrcEQSYmOpK5/dp6Dp815JAs2PK8YYzbnuIKBkmuGExGnU5s= Received: from SJ0PR05CA0135.namprd05.prod.outlook.com (2603:10b6:a03:33d::20) by PH8PR10MB6501.namprd10.prod.outlook.com (2603:10b6:510:22b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:21:35 +0000 Received: from SJ1PEPF00002310.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::8f) by SJ0PR05CA0135.outlook.office365.com (2603:10b6:a03:33d::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:21:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF00002310.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:21:33 +0000 Received: from DLEE202.ent.ti.com (157.170.170.77) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:32 -0500 Received: from DLEE210.ent.ti.com (157.170.170.112) by DLEE202.ent.ti.com (157.170.170.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:32 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:21:32 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFG3017088; Fri, 24 Jul 2026 05:21:28 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 01/19] dmaengine: ti: k3-udma: Fix sporadic crash on AM62x Date: Fri, 24 Jul 2026 15:50:34 +0530 Message-ID: <20260724102115.2854-2-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002310:EE_|PH8PR10MB6501:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fc9db1a-6c62-4447-0640-08dee96d55eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700016|23010399003|18002099003|22082099003|56012099006|10067099003|921020; X-Microsoft-Antispam-Message-Info: RUtR+Yb8vK8Xfr9mbNHbdVnXcFOO2ZV0e/wTEOyi7cyiPsJHNzO9ptR5in3muLw1IMucytGHORLIEyp1zqpxL6iQEWoBVqfhK68fGtEhb7TuGfqtpNJhw2IPQ7fAzeqt7FYLstH1+juAi4vs8D0sp06vYfRxfH5EiO7RJh3aTYmPo/tBFEkXA5U2d2+Vup5H8qub8Q7ufs3LymBnn0mwyE+AjyJz6DwH01cf7qoGPpWhouqDcrwep7LzW+JmirOoWoBosIDNP3teLmit1ZMOjEi9XcvJZHUg7KgndVaIFKqmj9JN5E7zmnObQ51R4NcZYPvjICpUb3sRcgVJFmcCvkV6xh3JxIEwFMvAZStQpYdN7bNxJwTzaXt015CdoFmEsUhAExyaAFrLuyF2hZaKx1A8n+WksHmvuNUvSdmsPargTNFidBLHWjVOarCygcd36HVnMV7JKJMpXKZ39oBPNy7u8EtZCRuL97j2j8SjcYQaFNZRCBGo/pG1q6aSbfUAZgxxWe0qimvTLZKurxbgp73bdvU2Y15K6rG2yf+Kd0ttAshdjfXHRdZj4bs7/WUmXN/aHw2LtdbsA0AlvK9P8X0LgjsTBVpyIgRLJiEjCoa6kh1kEGebWW4OCsBIRQlQqffODmKV+TIFlDRU/kYQrBbUZ7C15D6Is8dJtodzqYvKNi8VfAkb9F1ghDwOpyLZEBEfWqNti4P/slp09+nyfU4GLl6wxJhu6kHc+Fn5/dOm8BgdmZBsotbKqhintJM4 X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700016)(23010399003)(18002099003)(22082099003)(56012099006)(10067099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NJtqwzfZ+Ckh+Ii4fCrQ9bdn2ZWuf1VUeZbJmyPOwSHmQcZPYceHkFfZs/wSXzAFOmWhqRqEsbjcbpeVtWTbwX6yXj5jYBE2aSkgqNooNd9juZh04ZlPGquhJjAnIypVPLQtfExFNrBpY+YPo+jXZpHxENkHK32AsIBUh2FM6WuoQcA3PXrZRolIhmhHKfNhYv8qt694sWf+tASaLmjO8AwmhSIgkf9ZG0hCU0dX9SJR2d+jFTz1iblhK+la4aInXaeAUM+CXnBiwEsWyWIY0GLgyiovzNaQ76cRKGyOayGy5imU+GcuzIkqS8ffea4nbF2mOSlg22qaqMbOhfAAMA04zjhQB+nzxApxY6Tbm3a2TMUgeYmCErT2fDNYMRohNCQEyLvCM0QMcX1tOBmWk9TJYbcf5/Hpdbsq7aPHMGY2odUsXdxot2xtQnAwPMNo X-Exchange-RoutingPolicyChecked: eCsficXDReXw/IxY4aVBz/x8aibHugzd0MvfQx+dyWDyicxGTHz6BMh2+pkiiL3UkCP8uOczOxXL+/1jXLUM9xeNrCqP0oZekyra1D73kKr+uX+aCicLEej7X82taSCWtkTkQ4l9ff7UqLL9DLm6aaacX4o/56bpC3lCrkkzzkKoNW43IBfzbM8WMqRKozjzMFooJOsX2STUjwqF/e7Eygeh1k6h/ofmPjHA5v2up1nPXHwkrnw91O+PVV2CdL7YjzA21x7XFAddmjWHmrM8MmqsSivp7/DYePQ3D9QmsnvFq+Lxp3FxjGUa7/MuCx9SFnp0eyYfz9/Oy2hUfO5Axg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:21:33.4087 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fc9db1a-6c62-4447-0640-08dee96d55eb X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002310.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6501 X-Proofpoint-GUID: RLR7mqidmo_056kRDKcErBJirCJYzxYb X-Proofpoint-ORIG-GUID: RLR7mqidmo_056kRDKcErBJirCJYzxYb X-Authority-Analysis: v=2.4 cv=dLWWXuZb c=1 sm=1 tr=0 ts=6a633cb4 cx=c_pps a=TQumU+mCWarTt0EIZfG+ng==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=YS4YLeW4SzYDQNh2yKMA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfXwZeevSunhlTY jriThZn1B3CsP2GRYCYnvWeQ3GPpu/dnR2ZB2hHvZ4aJuvAXXsS4VTg5k8V+cRBjAwMnWxdHiIe zyYUeT+3d/UiQEFGJK/I2kuztNlVY5uOU14S44sQyXXaM0gEwz8dZcWOt+y9ReDM3aCUSimcGDy h3wSsAnqrenYiOHduDdoAwi8Hm+DQdvzjhsU/PRROiPr68IugAyMj8goKy6ZGq7IqpyBytSkJK9 mvYpvYVI+kWU/39NFdv19nUe2rk9NQp9n53Xox8ZUTHk4gaqPlwz0TJ6B0UU6AKfO+WpVaS6qMf ioQRUcq42jBHHyKtabya31qEngpUpE5HPhV39nB6A8quyJbVQpFJMc3d6CdACDJUixI4km63/42 JW2IPDdG9usgOJ2pXibaXS+kNjFB7C4IHm6Cw6VKvWhO8G6oVxTg/wOrOY1xCrYSLfpC+NB1Lce Hy7PnYGcDsQwU1YtMQQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX2XKufJffZk1R //akE0oaxnMVpl84tMfhGDOSkdMlBwvKZfGsj8n693p51RUW5PAZk70Y6bAPasKjGpjgbFwSwVv v3OiJS9Zn4Heb4SB4uO0hF3yIE5ZIz4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 clxscore=1011 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" From: Vignesh Raghavendra ring_init_data is declared on stack and thus can contain garbage which can lead to k3_ringacc_dmarings use junk address for ringrt base leading to below crash during ring pop [ 1.998239] cadence-qspi fc40000.spi: couldn't determine phase-detect-se= lector [ 2.532106] Unable to handle kernel paging request at virtual address ff= ff800081a84b98 [ 2.540051] Mem abort info: [...] [ 2.629987] Workqueue: events_unbound deferred_probe_work_func [ 2.635832] pstate: 800000c5 (Nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE= =3D--) [ 2.642787] pc : k3_ringacc_ring_pop+0x48/0x94 [ 2.647234] lr : udma_pop_from_ring+0x7c/0xb4 [...] [ 2.726250] Call trace: [ 2.728691] k3_ringacc_ring_pop+0x48/0x94 [ 2.732786] udma_ring_irq_handler+0x34/0x218 [ 2.737141] __handle_irq_event_percpu+0x60/0x14c [ 2.741846] handle_irq_event+0x4c/0xa8 Fix this by explicitly initializing the variable to 0. Signed-off-by: Vignesh Raghavendra --- drivers/dma/ti/k3-udma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index fb21e0df5ab7b..48f4db777d924 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -5484,7 +5484,7 @@ static int udma_probe(struct platform_device *pdev) if (ud->match_data->type =3D=3D DMA_TYPE_UDMA) { ud->ringacc =3D of_k3_ringacc_get_by_phandle(dev->of_node, "ti,ringacc"); } else { - struct k3_ringacc_init_data ring_init_data; + struct k3_ringacc_init_data ring_init_data =3D { 0 }; =20 ring_init_data.tisci =3D ud->tisci_rm.tisci; ring_init_data.tisci_dev_id =3D ud->tisci_rm.tisci_dev_id; --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 73E74427FB8; Fri, 24 Jul 2026 10:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888537; cv=fail; b=POpRb1G+z7VxQDFPxgESWAj2zHCUn9CPI3rRyYy6qkavZ0Cp2LhjhDLekP3ugAtOSQtl7L4araD9PuESapEivhuqZk4eJck7oPTmb/NpfSChj1xn+GG1Si7UVNrkdklze9/K+5Jj6uMPKzcuONf9ZK2ww+FQrsSsRjWm0ovwvQI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888537; c=relaxed/simple; bh=WJY3AKaNC/gLHlGSPe/4jNEwo2M0/91u1xIHBwRpW6I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f2O58S09aobtxREtuLnIbFWjcoKSzbUG/IOFTVvUq9kmIiQ3fEO6kW0FBvAf8iY8Fwsd/RpU60r6IoZ2k34CskN0WapWqW9QCxakZq9iieVeis/lCaEqS0hURSaUyZEmS0g5VKy1/drR4MGqODN89c2tQKXScM9byeqstnEnECM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=C5EB/Lhu; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=X3Uvx+sb; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="C5EB/Lhu"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="X3Uvx+sb" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFsFj786385; Fri, 24 Jul 2026 05:21:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=2ovHrghrGMqdefLDMIOud273eAp2uf6U5cQKsE+TF zs=; b=C5EB/LhuiuEjj6DS2KYAIM67evVlj3raU2GHonS/60Q8/F/Cp9p+2dOmW LCC/0ZPqGb7cxZICOK+ofnm5QapxdlCxRY5vS555wRgj4H7Q7YjJkYPH2k3LJh/C buWjQUgwhHDRo2TDzJkRNfLYgw3rl9hekqJzCEQfy5Xw/gkFGeUCXc4RpruoQWwD fc0xqop6ugmneNfxpHtZNtmaGqlxI3WUPymXBrBcy+EvR+CuyepEBOm7w+Q6jsB1 lvRBFiE0nzjNryROq5cWUuu3bHOOuL8N3KBhXzkllc7tVOAyc6P47KbUf+xgdQnY syY11EqYbcALNnpLU4rxy9AO3A+bA== Received: from sn4pr0501cu005.outbound.protection.outlook.com (mail-southcentralusazon11011014.outbound.protection.outlook.com [40.93.194.14]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fm5p304hh-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:21:45 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vbaJ+o4X+sdceTngdoiOUA8R+cvBKgdBU9RO9dOOYfcJVnihUqe1PRV+oLcAO20Gg6QIFR0CEu3Ljv808CvxUWGqe/0WoovPab/0J9MgfQnARzg3Mu/ICl6dSrVbhidWP2wne9Tz/j/UMJK9SAV8kstQE6/Ay/MO2X41E7aoxfL6BZftRzQ7ZjV7NoQQ6VjRzbOZxehlPs7ndMxSMETA/C9KJiLAUy482ioE6sw1WAs+GcPQzkDJik06GZ+Gv+YqhBkt4VbLK1rFBacimVsyMllmyjQpJPmRvyxaqSEsglkRKiOxmbl5ldoz+Q5CsNtXkPCfOPfXWXgARGboCKQ7eQ== 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=2ovHrghrGMqdefLDMIOud273eAp2uf6U5cQKsE+TFzs=; b=MYFc7drkVd68BLonOhc7nu06KfanBm8GYELwBHd366BpxFqnb7FPTLUWKGkwS/b1+TUZ8ppUOKUHpHVT2OZICO1a7V0NKV++5prWLZKBElOoBFR4bCWMJzA+VLOMQj2ZNarftXLeUCg7Bawzqq+v6bryrw0RwWu4HjPAFH8KaSMT/S5t3cBP0FGXnenuBFL5N2SlidMbNBPOjscY5sk1wyen+jv8725CH23vUbJ/rICMCNAntOY4XjXC0kvz8ataor+M9fQe5kH1bC5/DVCL7p+AJBl+ytOrZUS7PPApm6E0eoQ/0f/qj7qqdOqWl8W8FcRW0+aQxBU7lBhDdcKNzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2ovHrghrGMqdefLDMIOud273eAp2uf6U5cQKsE+TFzs=; b=X3Uvx+sbDQZjzE1Kre7ayDlLm9DQVBHpUMQs9KwqHkL/AzSPFVb5shjwzOVhVG1SaDqL0A7S4MpbWIUJ7j4r+l1gqzKZULDjBnuKMDzFCWd6+rCBVrnW8cZS68Sh3Tz4fvzcJmSJ9P5L/mj570bznl9DeGtLue+X1rzvogDHU+M= Received: from MN2PR06CA0018.namprd06.prod.outlook.com (2603:10b6:208:23d::23) by PH0PR10MB4487.namprd10.prod.outlook.com (2603:10b6:510:40::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:21:40 +0000 Received: from BL02EPF00021F6B.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::92) by MN2PR06CA0018.outlook.office365.com (2603:10b6:208:23d::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:21:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by BL02EPF00021F6B.mail.protection.outlook.com (10.167.249.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:21:39 +0000 Received: from DFLE215.ent.ti.com (10.64.6.73) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:37 -0500 Received: from DFLE203.ent.ti.com (10.64.6.61) by DFLE215.ent.ti.com (10.64.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:37 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE203.ent.ti.com (10.64.6.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:21:37 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFH3017088; Fri, 24 Jul 2026 05:21:33 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 02/19] dmaengine: ti: k3-udma: move macros to header file Date: Fri, 24 Jul 2026 15:50:35 +0530 Message-ID: <20260724102115.2854-3-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F6B:EE_|PH0PR10MB4487:EE_ X-MS-Office365-Filtering-Correlation-Id: 24026b8f-0938-4a29-123f-08dee96d5996 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|23010399003|7416014|376014|36860700016|56012099006|10067099003|22082099003|18002099003|921020; X-Microsoft-Antispam-Message-Info: rmXZgTqqLh/BeYjYNwEOoYTQPDqwsI4g/qoiy5qTGyEjp7yyAh4po0nD5PpA93EMTMc9pj7KaUaKu+y6Tvrepl08fXZup6EcK7PWmdHvL/U7/TTzdUukAJAVyK0pSskkzFOn9N94bFMTfkeP6PdEhvCZigv8y4TgozlTOO046Hz4EQ9YomhS2qtr4XySpobPfnWjWJbLVV0CHxDy7dnkp+4aJmD59CYEy2ISVxegERhS81Wcc+rN61s1P21oUEdceEoIv7bo6UPilKEtk3Z4v4aNpsMNgBtJe7XyMP0RPb95zDXBsLb/yaFwAGZRn1UlOSLbvSb0cuQ1fUA7+AMOBLWCXzjyTNLWozAWTcJMS4gkf7bVET4uEAl90QlkyeggsE1tZiuIuzDRLuCi024UiP+Ivx8yIFbd9AB9Qa8R6lRX50trnHXLMxeDnGDq+X5uvDGa2vQTklh3Yb9y3+VE3syzOeMFDar2Pw8TM4atTrmAdaghyMttyPCiwvMNEyeeo15CAmfmbsE5XWwEZ6yeX4Z67yvOfbCL3rm8Wi8sIVM3QtHghqVlCq0hlKoBCObdHSK8/ynDnQF8bPgVNa3GI2uT+b28Bz3zDjcMjAhxfN0fkHn27ksQLbxxGpYCEzv5YzkjObByIJqNoGGm/WbgSRyIRUbmRPPRHM35b28IyYb3A30kflFKdxBqADkeXSCauohGVhQtgfsMeCrCRc3P/HBn8DEZQSAiHwRpu7kaLBzR7q2v3v2I5+4ulUlLk2lb X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(23010399003)(7416014)(376014)(36860700016)(56012099006)(10067099003)(22082099003)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WiHWqWdMEp4jJfaQ6LCvz/ZvmGsX2hHWVV0Ht1TktueTE7PPDl0D9k2pc72ke7Lc3khC1JhLXwnEBXv0GGEV6TDPVh1n4LcpzPnlSyoXBFD27ALa30jbL0TY6NLE/lpkhkDBtpeNcPwDlc0QPL9hSal3jMPCuH27QuFCD8bEaCWe/EikIkyUD13leuFv+Rop2ZX66tFb6xvVhJwhOLVYyUIcv1RMwadjdGPvVmTixySYMAX91jwmh2G6KyIUG8ot37GKCidQCDLiMz9gonWU1cMmcy2NPnNqhOrCMWCIraF3uKDem7V6bWsSbem+som7f70TONfDfwLFE0RG2D7K5Y0v4F5Yoe6F23CiigRaWc+byA8pOoJT7SQmwmcxpTOVj2XJOIunIvvYMIh2HRXpnQS3XLibs9Kx3JbHerCls+IMFOxzP/vMRJDlDVN2r7Af X-Exchange-RoutingPolicyChecked: rXQObPWttAMhyI/iq3f/NSc4tunpK2Kx8dVs5Ljd+p2iUokxVY2oT6SNXCSf1mvRtcHJaS4JJNDijU55WhGIaeL4ZrN2mbTIGiCUygAYlgy2p5X+/22nOtlapa9sQbTaCBvMTgTu9KaraRg/r9SK+6HAMzjavszrfA4rcjM06xO/1PSYC4350Qf0uB1159C2DB1ZPQQf9XneYPsGrvzIEc7/cWpanuhihmp3gOPomu01M1sHFquQgJMUcrvP0mBZK/Oq/kSo6ERtW5yHwWQ1dlaLIHm21tRUwJQN3i8wTAJOV9KZDOQQa02AqwmEisq9Pdc8SrJm0tdI/YYTi3AnGQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:21:39.5785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24026b8f-0938-4a29-123f-08dee96d5996 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F6B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4487 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX/akKJ5+4ZL0r svRM/jCrzHDHSFMHi4KYIsW422Yo65SSAGhBBM0kmt3VyU5xWiw0koqzAzyYvmp8VTVQoegVt79 t0nfJLAo796gesiI+DmdhNSarkV0cAmGlt0ZvRxrJmTUJizxMWmzocb026qNMOM+6iT8f/yb7oX 5sTkZzd6Pqug/9gutxqAWaapuBEQ5RAfv/DXryiKBz6z0KZfCJG6nMCJu7pjkqWUfrbg4wVNHhz JnN19klQVxKGOeQjt8r4JgYtTcIwbPYqAbXzJLEq4APuc+FpyHEiLQskxqCiiiy+K66QQjiueyb noPjYtMBGMQLzvd1Q8rI+MCh1CjKXKj8ftKEgSlSHJ4jWEILkmkl6Hi0J5Fl5H942/icwjZq2VK hCLxzfvujc0kSN3wI66XYWdJUmq4Z9Qv8OYpTg8WbUAm0U6ivkJ2feu6XYT0UKpkrACL1hJ/Iub HYH/YM+naaDTb9OCowg== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfXxFNKi5LrNa/z ZzbCPedkoOxm2LASV4fWRA7SmHQZyG6fU4hj66QShRNj4OvTGMUvRMQmwXjfFa9PzqxP04/p/t1 zmkVednU93QtUQNWRZ3PcTdI72b8e3c= X-Proofpoint-GUID: Gy4hQJtHK_zIfuzNCv98z78ckLxsTi3U X-Proofpoint-ORIG-GUID: Gy4hQJtHK_zIfuzNCv98z78ckLxsTi3U X-Authority-Analysis: v=2.4 cv=C8PZDwP+ c=1 sm=1 tr=0 ts=6a633cb9 cx=c_pps a=u5a0R1DJIqwdmu/eAz29vw==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=8AirrxEcAAAA:8 a=sozttTNsAAAA:8 a=u0Ry9gnqgf_Ls9jc7UwA:9 a=ST-jHhOKWsTCqRlWije3:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Move macros defined in k3-udma.c to k3-udma.h for better separation and reuse. Reviewed-by: Frank Li Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma.c | 62 --------------------------------------- drivers/dma/ti/k3-udma.h | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 48f4db777d924..a066862e2c699 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -39,21 +39,6 @@ struct udma_static_tr { u16 bstcnt; /* RPSTR1 */ }; =20 -#define K3_UDMA_MAX_RFLOWS 1024 -#define K3_UDMA_DEFAULT_RING_SIZE 16 - -/* How SRC/DST tag should be updated by UDMA in the descriptor's Word 3 */ -#define UDMA_RFLOW_SRCTAG_NONE 0 -#define UDMA_RFLOW_SRCTAG_CFG_TAG 1 -#define UDMA_RFLOW_SRCTAG_FLOW_ID 2 -#define UDMA_RFLOW_SRCTAG_SRC_TAG 4 - -#define UDMA_RFLOW_DSTTAG_NONE 0 -#define UDMA_RFLOW_DSTTAG_CFG_TAG 1 -#define UDMA_RFLOW_DSTTAG_FLOW_ID 2 -#define UDMA_RFLOW_DSTTAG_DST_TAG_LO 4 -#define UDMA_RFLOW_DSTTAG_DST_TAG_HI 5 - struct udma_chan; =20 enum k3_dma_type { @@ -118,15 +103,6 @@ struct udma_oes_offsets { u32 pktdma_rchan_flow; }; =20 -#define UDMA_FLAG_PDMA_ACC32 BIT(0) -#define UDMA_FLAG_PDMA_BURST BIT(1) -#define UDMA_FLAG_TDTYPE BIT(2) -#define UDMA_FLAG_BURST_SIZE BIT(3) -#define UDMA_FLAGS_J7_CLASS (UDMA_FLAG_PDMA_ACC32 | \ - UDMA_FLAG_PDMA_BURST | \ - UDMA_FLAG_TDTYPE | \ - UDMA_FLAG_BURST_SIZE) - struct udma_match_data { enum k3_dma_type type; u32 psil_base; @@ -1837,38 +1813,6 @@ static int udma_alloc_rx_resources(struct udma_chan = *uc) return ret; } =20 -#define TISCI_BCDMA_BCHAN_VALID_PARAMS ( \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_EXTENDED_CH_TYPE_VALID) - -#define TISCI_BCDMA_TCHAN_VALID_PARAMS ( \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID) - -#define TISCI_BCDMA_RCHAN_VALID_PARAMS ( \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID) - -#define TISCI_UDMA_TCHAN_VALID_PARAMS ( \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_EINFO_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_PSWORDS_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID) - -#define TISCI_UDMA_RCHAN_VALID_PARAMS ( \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_SHORT_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_LONG_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_START_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID | \ - TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID) - static int udma_tisci_m2m_channel_config(struct udma_chan *uc) { struct udma_dev *ud =3D uc->ud; @@ -5398,12 +5342,6 @@ static enum dmaengine_alignment udma_get_copy_align(= struct udma_dev *ud) } } =20 -#define TI_UDMAC_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ - BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ - BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \ - BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ - BIT(DMA_SLAVE_BUSWIDTH_8_BYTES)) - static int udma_probe(struct platform_device *pdev) { struct device_node *navss_node =3D pdev->dev.parent->of_node; diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 9062a237cd167..750720cd06911 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -97,6 +97,69 @@ /* Address Space Select */ #define K3_ADDRESS_ASEL_SHIFT 48 =20 +#define K3_UDMA_MAX_RFLOWS 1024 +#define K3_UDMA_DEFAULT_RING_SIZE 16 + +/* How SRC/DST tag should be updated by UDMA in the descriptor's Word 3 */ +#define UDMA_RFLOW_SRCTAG_NONE 0 +#define UDMA_RFLOW_SRCTAG_CFG_TAG 1 +#define UDMA_RFLOW_SRCTAG_FLOW_ID 2 +#define UDMA_RFLOW_SRCTAG_SRC_TAG 4 + +#define UDMA_RFLOW_DSTTAG_NONE 0 +#define UDMA_RFLOW_DSTTAG_CFG_TAG 1 +#define UDMA_RFLOW_DSTTAG_FLOW_ID 2 +#define UDMA_RFLOW_DSTTAG_DST_TAG_LO 4 +#define UDMA_RFLOW_DSTTAG_DST_TAG_HI 5 + +#define UDMA_FLAG_PDMA_ACC32 BIT(0) +#define UDMA_FLAG_PDMA_BURST BIT(1) +#define UDMA_FLAG_TDTYPE BIT(2) +#define UDMA_FLAG_BURST_SIZE BIT(3) +#define UDMA_FLAGS_J7_CLASS (UDMA_FLAG_PDMA_ACC32 | \ + UDMA_FLAG_PDMA_BURST | \ + UDMA_FLAG_TDTYPE | \ + UDMA_FLAG_BURST_SIZE) + +#define TI_UDMAC_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ + BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ + BIT(DMA_SLAVE_BUSWIDTH_8_BYTES)) + +/* TI_SCI Params */ +#define TISCI_BCDMA_BCHAN_VALID_PARAMS ( \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_EXTENDED_CH_TYPE_VALID) + +#define TISCI_BCDMA_TCHAN_VALID_PARAMS ( \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID) + +#define TISCI_BCDMA_RCHAN_VALID_PARAMS ( \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID) + +#define TISCI_UDMA_TCHAN_VALID_PARAMS ( \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_EINFO_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_PSWORDS_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID) + +#define TISCI_UDMA_RCHAN_VALID_PARAMS ( \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_SHORT_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_LONG_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_START_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID | \ + TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID) + struct udma_dev; struct udma_tchan; struct udma_rchan; --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 181124908B5; Fri, 24 Jul 2026 10:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888528; cv=fail; b=DU9/OoZhy0U3ANO/t1BzChxSsTjNTT9WBt0DfkLcJ8xF97cPBZlBXZ43b4/Hkzq0O7LHDB/EiHD5X/F3Ix3t6z1O0GgKg+9UnWCTp0udXBy5tm4rLoYMmt2WRaze3g/OaOSs3Zric8i0s12ZMhUSBjjZCH/yjwAw9N50QX5+bg0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888528; c=relaxed/simple; bh=dAZSqEoSxTBTu0kU8J+uJtdjIzNsSrDJ2D7swCkbV6A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UJe4RSIGH3ah2qrE9qPjpSHui4nwv1qUm8Cme7aY+CexENjE4aOkAIQH0ueusOq2KWPjHKYSd1H8L9p7dqw5kjvRYyMb0VKscguj4S/07amSzjkxeDaTB5D+jlFMhGH1XQKf4wicj9L+JfSgLuqR2gnSwFiSHi71pKUJWMIaELE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=c984iXYH; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=bNcfbrz2; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="c984iXYH"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="bNcfbrz2" Received: from pps.filterd (m0380145.ppops.net [127.0.0.1]) by m0380145.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAExI4820879; Fri, 24 Jul 2026 05:21:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=VXr33scVtYdUEw5DUOBN8G3xmUkJKlNDOmQ8EPUWu aY=; b=c984iXYHclamW0GhlI6h+elaxREFOrtB9iyrcnnBgXwkbF/S4HOVYtCc3 QjeP2ARYG8TbeJdnk5s85TzHgRMUbXqlSMROmqdQS0PmniZipTye6yyCsfX00HMD VQQgPhMSEiLrljOk8jrzJX/xLjRhyuSUTHiEWlH7g0aq0aGQZPBlFqvudjuDCZuG 2lf4Nz+jLVVtyVXPHMJF/Wy/tPhJrvmQF0wjPvsfOtngGQ0ogDtUCHuydwGlYcAy OmFRqpnDo5d7ubbAykMXPfvFcQ7C9313IRoiaXx13AO0eOYwZczY1cpx5Egm7EWU xZiQmyJqFSzAKjdKpqUW9AgWG5MMA== Received: from bn8pr05cu002.outbound.protection.outlook.com (mail-eastus2azon11011001.outbound.protection.outlook.com [52.101.57.1]) by m0380145.ppops.net (PPS) with ESMTPS id 4fm4vw0d3t-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:21:53 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yLYLrM/sIn5EaXNR89Zk4RT33PG3zBJQGXT1HKxoYqGr0tFUwR0lg8SywjZQELVusAuptEIB6vtBKdG/qMogOmxK+ODio3Rx1Lq7WCJdAEsAtYGJftfa9tm6P7Ya3Ro86A4/GUGSvefR8wIl5yGtGj/B31gCKeQyuNNC2AlQljLFIkmT0hp5Y55/2mpj70qYfZE29vZcJpU7kxmGPNncvJqf28uLwXb80ECN/L2df4Jt5Rrq8HWYPzFeZ9+bRuZuwdiVgqCGVtEMW9SIKMHJhIT//JTG0rBJQbpm7QvBY28W5mdF4sMoIZPQ/FfCAm/kddnbLpSZONc4FRi7f57/sg== 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=VXr33scVtYdUEw5DUOBN8G3xmUkJKlNDOmQ8EPUWuaY=; b=OvzevlVqoQAJaKlD6cgEtlvJ/KeGGZezWSLW95wwjXsMfxFRyfTjh1Hi7Snn+GSh/jPXB3YwokxZZHQl9ON8eGS9RTpzC6OKX5YYE8/8iSS1/Kf1oPOYIjEhQQp7ilWscu1Ja2Z2s6NnHyIgevWs6YwUukoYDsa5yC0RchZ1uvlhAx7VWl4w3Q48neYUvhrhTmcp8oj9oB1MS9qmgIRpm3SN+3AReUeHl7nPJpEjkRvFw2JoyGX4cgs4AmdwfDa1rh0erAD2rFybtNbY75vNU29VU3WuU0wqr+78ewBJ4SB/2tjoaFwy/G/AtcUd0Q7H1oamHVjEuspMiEawtxXpIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VXr33scVtYdUEw5DUOBN8G3xmUkJKlNDOmQ8EPUWuaY=; b=bNcfbrz2ikbQ3fBBjoebuh7/LeNgrG2wRqVu1lwTRtovwDSYOBdXAFcj5rYpvBwGB9XYIZbXBv7IFwcCeE5cyIhaIV3XLjkZhiOF3i2/GFMt5u6cHE8480jrOZqPywtTg6xYaL2Kl0NqkIM6UNH+LtdkGXh4I3X4pnonm6gfjkM= Received: from PH8PR05CA0018.namprd05.prod.outlook.com (2603:10b6:510:2cc::21) by CY5PR10MB6072.namprd10.prod.outlook.com (2603:10b6:930:38::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.12; Fri, 24 Jul 2026 10:21:48 +0000 Received: from SJ1PEPF00002315.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::41) by PH8PR05CA0018.outlook.office365.com (2603:10b6:510:2cc::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.6 via Frontend Transport; Fri, 24 Jul 2026 10:21:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF00002315.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:21:47 +0000 Received: from DLEE209.ent.ti.com (157.170.170.98) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:43 -0500 Received: from DLEE210.ent.ti.com (157.170.170.112) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:43 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:21:43 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFI3017088; Fri, 24 Jul 2026 05:21:38 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 03/19] dmaengine: ti: k3-udma: move structs and enums to header file Date: Fri, 24 Jul 2026 15:50:36 +0530 Message-ID: <20260724102115.2854-4-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002315:EE_|CY5PR10MB6072:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d28f751-99ca-4e25-3fec-08dee96d5e70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|23010399003|82310400026|1800799024|36860700016|921020|6133799003|18002099003|22082099003|3023799007|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: M3C3QHtHieRIpSgDgZw6eUhLSWWqlgj/3xCZ68oC5A/Z9MZrlCaaRFvjLp4C7S5d0pssniMZ+Vd6tzuPaoYfMr+2VmLu3vzCUvjzau1/JNNQXTMIqUFgHDDGXHsRcKURazo4IWWqa702c/Gs1QGVCpsejcFJshczVA3Kk9zcPcdC7nKAUVnI3t38ov/HjVi5MC4YcsHd1ERv6eIp23z4CsYpEdlZozpU5EiA/hdL9zo02NmXAjf2sbNz7aqhDBMI8nQY3qGSuJ+cOpyGeUakqOlwdp9hvvHC+8OOvdACgInvd+BZLfm1LLVDE+16uMbHvS1G7n6xtp533VsfOJyathrSzftH5gS3YyVtJnnhWABgmjEc8N5JUuMsoFEe4Gg7A5L6bSatjUmYc5nwBQmYW3QplEJ8qN5e5oWyXcXZ1NlGchFGLk6pTN+Lcr+rAcvrAfvtmIzSPyzdSVUIPHI/xBpV04e6iEYy7BfUuqWHwNwJpkNE0q7rInyZTQ2okB1pzQgR+BdgFcqoC1oWLq/1TRPUz7YE8ZXGFsnYMu32l4H+JWAtm6Mr1QORS4ML9HYctfEiRMqLJrqKv4kJ4Y6rCQT6c8Ldy5g0l2diOmUmYakyvW6gxG0cxy/rO8BOKSsqP3WefhTkwn2UnUdGQoX6KQtBq+FJ40SlCHNkBJBFIKBWyXCBmsujRh+afAbAfEyThtUjoHTB5L4cx69fc2+d236RRy/eGuPlFO1JQNAK/iv//9z+7VxbrMl8D5nl1of1 X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(23010399003)(82310400026)(1800799024)(36860700016)(921020)(6133799003)(18002099003)(22082099003)(3023799007)(56012099006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UtiBkRrHzVDNGoxoNKW6YmcNb26YNLng60UHbhYCgo690QchBq0kLFTN8m+tA3IoVI02TjLBk7ODVdzvSfUQa7O/D7grMrbtYdd/nz0hQ6j/1dHyA4UcCNQzQrrYjicJD9b5xQLMvf+DHiKomDb1VsuzaXQodfDqau/lhgoPdz84Abk4HdSJYhMn6OxsLW72eLErHDPwkfPus8s20YmwYOM8eGoCttBwa8wnn6N0Y5qfVtF0y+Li3bbryV2b1YLbARL73k3hQxwd5oNDcI+ReQ4fczhroRRJbuokz4ARaeq8LzF/cAUcAc3XBcVItsvVyngRwGLyEeXzz9HScRyqDhQYai/5A4Z4hA3YSdVwusjGG4cO8QaSzVf0yTcBm72jb/+9KUxo7jZLqPReTBUVTVRbH5oCqgMYiVulKVupJNnyksHz3Atba1hE3W3S/6nv X-Exchange-RoutingPolicyChecked: U87XjpPGSilHw5/Pj6tLsO3Ayk0rg94RJB/f4Q/dsIvGsUu9e+Xo6JlgaBOBL1C/vkcnLbuEgEODzm+nIGs9VULfMItZqjgtb5aRwy6DTgAtG/64OLBo2GQVgwhHshjLhEEIEYPeXDjCsEg1Py3Cv/lbU66QCrM+PSk/vQTzm7WnNSJmF5DssJtpRIfLjp1d8kg+I0ZTtNaMZjSpHtKTgXDbwJeDC4VJB6vToYEzMMCS3/o+L/5GYZe7uI1n3z/uaR/a3pGHIYDPCKDaFBz8/FNAO7V0OtU38HPPk5z2RD2RHx6sW41aUC5mnGHZRb0G0VLiq1VUTgmSI4WqyzSZIg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:21:47.7084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d28f751-99ca-4e25-3fec-08dee96d5e70 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002315.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6072 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX0S7k4/g0z8df ei3Ax8gTblfxF8pU3IgkAvLXya4saqq/AnxAyXCjSP873W0Cl3XH5IGkaU0MtomJT9RSVZE1TiS Dht3YXP16zBdLXS5zy6j33GPpCddS3fv3NZsErwNuFmRTTa2mZoKt1TlzwEnvwwVcuQyWJk3wkY 93nbfmlXJdOEqwzB1Pnf3w3173CsJKBJQIk8dh9p8p9tWpJyvmyFdu3Q2gCLeBz6hNTvEbIRL33 jYVHrMYvVB1UhtzKwVrqntt0G+B0MoACr/2dwMdTqboA2sTI6T7YNlUL+RXnPQr0oYpCzMuKn8/ SP8lrcW3YxrJ4smYvkvg/+wg7w1L+7dYsaejmOZZhyav3V3EWXMpTqLkw17mcWNpKZTq7jHE1x2 TP2+nxSVz1cxTNPOMaAeEZYtt03Kwvs2q/81cxcqcUPzRBMbFlLEx1tbRKc1byOy6Qgofa0TJYy a2ro4XUP3yVtFQt1yXA== X-Proofpoint-GUID: llH16EWSDVUuQLq3N0-6CsBAQLebE3Qn X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX9k47pG0WJGGT 9QzgVu1twWf/SnapAO+ldgPNqZtetoi0ZH/waeNcZCPlxmxIzg0E7x36u/pRHT8I/oiDFZW617k zIlevQD8ucRBOsM6+RR1OJRTYfsCPsY= X-Proofpoint-ORIG-GUID: llH16EWSDVUuQLq3N0-6CsBAQLebE3Qn X-Authority-Analysis: v=2.4 cv=feadDUQF c=1 sm=1 tr=0 ts=6a633cc1 cx=c_pps a=/9/UiQo4Js8eZu4DIT4oEg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=1JpllqVW-1LRWXCuGuAA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 adultscore=0 impostorscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Move struct and enum definitions in k3-udma.c to k3-udma.h header file for better separation and reuse. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma.c | 259 +------------------------------------- drivers/dma/ti/k3-udma.h | 265 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+), 258 deletions(-) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index a066862e2c699..ce706033143ad 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -24,8 +24,8 @@ #include #include #include -#include #include +#include #include #include =20 @@ -33,28 +33,6 @@ #include "k3-udma.h" #include "k3-psil-priv.h" =20 -struct udma_static_tr { - u8 elsize; /* RPSTR0 */ - u16 elcnt; /* RPSTR0 */ - u16 bstcnt; /* RPSTR1 */ -}; - -struct udma_chan; - -enum k3_dma_type { - DMA_TYPE_UDMA =3D 0, - DMA_TYPE_BCDMA, - DMA_TYPE_PKTDMA, -}; - -enum udma_mmr { - MMR_GCFG =3D 0, - MMR_BCHANRT, - MMR_RCHANRT, - MMR_TCHANRT, - MMR_LAST, -}; - static const char * const mmr_names[] =3D { [MMR_GCFG] =3D "gcfg", [MMR_BCHANRT] =3D "bchanrt", @@ -62,234 +40,6 @@ static const char * const mmr_names[] =3D { [MMR_TCHANRT] =3D "tchanrt", }; =20 -struct udma_tchan { - void __iomem *reg_rt; - - int id; - struct k3_ring *t_ring; /* Transmit ring */ - struct k3_ring *tc_ring; /* Transmit Completion ring */ - int tflow_id; /* applicable only for PKTDMA */ - -}; - -#define udma_bchan udma_tchan - -struct udma_rflow { - int id; - struct k3_ring *fd_ring; /* Free Descriptor ring */ - struct k3_ring *r_ring; /* Receive ring */ -}; - -struct udma_rchan { - void __iomem *reg_rt; - - int id; -}; - -struct udma_oes_offsets { - /* K3 UDMA Output Event Offset */ - u32 udma_rchan; - - /* BCDMA Output Event Offsets */ - u32 bcdma_bchan_data; - u32 bcdma_bchan_ring; - u32 bcdma_tchan_data; - u32 bcdma_tchan_ring; - u32 bcdma_rchan_data; - u32 bcdma_rchan_ring; - - /* PKTDMA Output Event Offsets */ - u32 pktdma_tchan_flow; - u32 pktdma_rchan_flow; -}; - -struct udma_match_data { - enum k3_dma_type type; - u32 psil_base; - bool enable_memcpy_support; - u32 flags; - u32 statictr_z_mask; - u8 burst_size[3]; - struct udma_soc_data *soc_data; -}; - -struct udma_soc_data { - struct udma_oes_offsets oes; - u32 bcdma_trigger_event_offset; -}; - -struct udma_hwdesc { - size_t cppi5_desc_size; - void *cppi5_desc_vaddr; - dma_addr_t cppi5_desc_paddr; - - /* TR descriptor internal pointers */ - void *tr_req_base; - struct cppi5_tr_resp_t *tr_resp_base; -}; - -struct udma_rx_flush { - struct udma_hwdesc hwdescs[2]; - - size_t buffer_size; - void *buffer_vaddr; - dma_addr_t buffer_paddr; -}; - -struct udma_tpl { - u8 levels; - u32 start_idx[3]; -}; - -struct udma_dev { - struct dma_device ddev; - struct device *dev; - void __iomem *mmrs[MMR_LAST]; - const struct udma_match_data *match_data; - const struct udma_soc_data *soc_data; - - struct udma_tpl bchan_tpl; - struct udma_tpl tchan_tpl; - struct udma_tpl rchan_tpl; - - size_t desc_align; /* alignment to use for descriptors */ - - struct udma_tisci_rm tisci_rm; - - struct k3_ringacc *ringacc; - - struct work_struct purge_work; - struct list_head desc_to_purge; - spinlock_t lock; - - struct udma_rx_flush rx_flush; - - int bchan_cnt; - int tchan_cnt; - int echan_cnt; - int rchan_cnt; - int rflow_cnt; - int tflow_cnt; - unsigned long *bchan_map; - unsigned long *tchan_map; - unsigned long *rchan_map; - unsigned long *rflow_gp_map; - unsigned long *rflow_gp_map_allocated; - unsigned long *rflow_in_use; - unsigned long *tflow_map; - - struct udma_bchan *bchans; - struct udma_tchan *tchans; - struct udma_rchan *rchans; - struct udma_rflow *rflows; - - struct udma_chan *channels; - u32 psil_base; - u32 atype; - u32 asel; -}; - -struct udma_desc { - struct virt_dma_desc vd; - - bool terminated; - - enum dma_transfer_direction dir; - - struct udma_static_tr static_tr; - u32 residue; - - unsigned int sglen; - unsigned int desc_idx; /* Only used for cyclic in packet mode */ - unsigned int tr_idx; - - u32 metadata_size; - void *metadata; /* pointer to provided metadata buffer (EPIP, PSdata) */ - - unsigned int hwdesc_count; - struct udma_hwdesc hwdesc[]; -}; - -enum udma_chan_state { - UDMA_CHAN_IS_IDLE =3D 0, /* not active, no teardown is in progress */ - UDMA_CHAN_IS_ACTIVE, /* Normal operation */ - UDMA_CHAN_IS_TERMINATING, /* channel is being terminated */ -}; - -struct udma_tx_drain { - struct delayed_work work; - ktime_t tstamp; - u32 residue; -}; - -struct udma_chan_config { - bool pkt_mode; /* TR or packet */ - bool needs_epib; /* EPIB is needed for the communication or not */ - u32 psd_size; /* size of Protocol Specific Data */ - u32 metadata_size; /* (needs_epib ? 16:0) + psd_size */ - u32 hdesc_size; /* Size of a packet descriptor in packet mode */ - bool notdpkt; /* Suppress sending TDC packet */ - int remote_thread_id; - u32 atype; - u32 asel; - u32 src_thread; - u32 dst_thread; - enum psil_endpoint_type ep_type; - bool enable_acc32; - bool enable_burst; - enum udma_tp_level channel_tpl; /* Channel Throughput Level */ - - u32 tr_trigger_type; - unsigned long tx_flags; - - /* PKDMA mapped channel */ - int mapped_channel_id; - /* PKTDMA default tflow or rflow for mapped channel */ - int default_flow_id; - - enum dma_transfer_direction dir; -}; - -struct udma_chan { - struct virt_dma_chan vc; - struct dma_slave_config cfg; - struct udma_dev *ud; - struct device *dma_dev; - struct udma_desc *desc; - struct udma_desc *terminated_desc; - struct udma_static_tr static_tr; - char *name; - - struct udma_bchan *bchan; - struct udma_tchan *tchan; - struct udma_rchan *rchan; - struct udma_rflow *rflow; - - bool psil_paired; - - int irq_num_ring; - int irq_num_udma; - - bool cyclic; - bool paused; - - enum udma_chan_state state; - struct completion teardown_completed; - - struct udma_tx_drain tx_drain; - - /* Channel configuration parameters */ - struct udma_chan_config config; - /* Channel configuration parameters (backup) */ - struct udma_chan_config backup_config; - - /* dmapool for packet mode descriptors */ - bool use_dma_pool; - struct dma_pool *hdesc_pool; - - u32 id; -}; - static inline struct udma_dev *to_udma_dev(struct dma_device *d) { return container_of(d, struct udma_dev, ddev); @@ -4073,13 +3823,6 @@ static struct platform_driver udma_driver; static struct platform_driver bcdma_driver; static struct platform_driver pktdma_driver; =20 -struct udma_filter_param { - int remote_thread_id; - u32 atype; - u32 asel; - u32 tr_trigger_type; -}; - static bool udma_dma_filter_fn(struct dma_chan *chan, void *param) { struct udma_chan_config *ucc; diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 750720cd06911..11d08adb0d69f 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -6,7 +6,16 @@ #ifndef K3_UDMA_H_ #define K3_UDMA_H_ =20 +#include #include +#include +#include +#include +#include +#include + +#include "../virt-dma.h" +#include "k3-psil-priv.h" =20 /* Global registers */ #define UDMA_REV_REG 0x0 @@ -164,6 +173,7 @@ struct udma_dev; struct udma_tchan; struct udma_rchan; struct udma_rflow; +struct udma_chan; =20 enum udma_rm_range { RM_RANGE_BCHAN =3D 0, @@ -186,6 +196,261 @@ struct udma_tisci_rm { struct ti_sci_resource *rm_ranges[RM_RANGE_LAST]; }; =20 +struct udma_static_tr { + u8 elsize; /* RPSTR0 */ + u16 elcnt; /* RPSTR0 */ + u16 bstcnt; /* RPSTR1 */ +}; + +enum k3_dma_type { + DMA_TYPE_UDMA =3D 0, + DMA_TYPE_BCDMA, + DMA_TYPE_PKTDMA, +}; + +enum udma_mmr { + MMR_GCFG =3D 0, + MMR_BCHANRT, + MMR_RCHANRT, + MMR_TCHANRT, + MMR_LAST, +}; + +struct udma_filter_param { + int remote_thread_id; + u32 atype; + u32 asel; + u32 tr_trigger_type; +}; + +struct udma_tchan { + void __iomem *reg_rt; + + int id; + struct k3_ring *t_ring; /* Transmit ring */ + struct k3_ring *tc_ring; /* Transmit Completion ring */ + int tflow_id; /* applicable only for PKTDMA */ + +}; + +#define udma_bchan udma_tchan + +struct udma_rflow { + int id; + struct k3_ring *fd_ring; /* Free Descriptor ring */ + struct k3_ring *r_ring; /* Receive ring */ +}; + +struct udma_rchan { + void __iomem *reg_rt; + + int id; +}; + +struct udma_oes_offsets { + /* K3 UDMA Output Event Offset */ + u32 udma_rchan; + + /* BCDMA Output Event Offsets */ + u32 bcdma_bchan_data; + u32 bcdma_bchan_ring; + u32 bcdma_tchan_data; + u32 bcdma_tchan_ring; + u32 bcdma_rchan_data; + u32 bcdma_rchan_ring; + + /* PKTDMA Output Event Offsets */ + u32 pktdma_tchan_flow; + u32 pktdma_rchan_flow; +}; + +struct udma_match_data { + enum k3_dma_type type; + u32 psil_base; + bool enable_memcpy_support; + u32 flags; + u32 statictr_z_mask; + u8 burst_size[3]; + struct udma_soc_data *soc_data; +}; + +struct udma_soc_data { + struct udma_oes_offsets oes; + u32 bcdma_trigger_event_offset; +}; + +struct udma_hwdesc { + size_t cppi5_desc_size; + void *cppi5_desc_vaddr; + dma_addr_t cppi5_desc_paddr; + + /* TR descriptor internal pointers */ + void *tr_req_base; + struct cppi5_tr_resp_t *tr_resp_base; +}; + +struct udma_rx_flush { + struct udma_hwdesc hwdescs[2]; + + size_t buffer_size; + void *buffer_vaddr; + dma_addr_t buffer_paddr; +}; + +struct udma_tpl { + u8 levels; + u32 start_idx[3]; +}; + +struct udma_dev { + struct dma_device ddev; + struct device *dev; + void __iomem *mmrs[MMR_LAST]; + const struct udma_match_data *match_data; + const struct udma_soc_data *soc_data; + + struct udma_tpl bchan_tpl; + struct udma_tpl tchan_tpl; + struct udma_tpl rchan_tpl; + + size_t desc_align; /* alignment to use for descriptors */ + + struct udma_tisci_rm tisci_rm; + + struct k3_ringacc *ringacc; + + struct work_struct purge_work; + struct list_head desc_to_purge; + spinlock_t lock; + + struct udma_rx_flush rx_flush; + + int bchan_cnt; + int tchan_cnt; + int echan_cnt; + int rchan_cnt; + int rflow_cnt; + int tflow_cnt; + unsigned long *bchan_map; + unsigned long *tchan_map; + unsigned long *rchan_map; + unsigned long *rflow_gp_map; + unsigned long *rflow_gp_map_allocated; + unsigned long *rflow_in_use; + unsigned long *tflow_map; + + struct udma_bchan *bchans; + struct udma_tchan *tchans; + struct udma_rchan *rchans; + struct udma_rflow *rflows; + + struct udma_chan *channels; + u32 psil_base; + u32 atype; + u32 asel; +}; + +struct udma_desc { + struct virt_dma_desc vd; + + bool terminated; + + enum dma_transfer_direction dir; + + struct udma_static_tr static_tr; + u32 residue; + + unsigned int sglen; + unsigned int desc_idx; /* Only used for cyclic in packet mode */ + unsigned int tr_idx; + + u32 metadata_size; + void *metadata; /* pointer to provided metadata buffer (EPIP, PSdata) */ + + unsigned int hwdesc_count; + struct udma_hwdesc hwdesc[]; +}; + +enum udma_chan_state { + UDMA_CHAN_IS_IDLE =3D 0, /* not active, no teardown is in progress */ + UDMA_CHAN_IS_ACTIVE, /* Normal operation */ + UDMA_CHAN_IS_TERMINATING, /* channel is being terminated */ +}; + +struct udma_tx_drain { + struct delayed_work work; + ktime_t tstamp; + u32 residue; +}; + +struct udma_chan_config { + bool pkt_mode; /* TR or packet */ + bool needs_epib; /* EPIB is needed for the communication or not */ + u32 psd_size; /* size of Protocol Specific Data */ + u32 metadata_size; /* (needs_epib ? 16:0) + psd_size */ + u32 hdesc_size; /* Size of a packet descriptor in packet mode */ + bool notdpkt; /* Suppress sending TDC packet */ + int remote_thread_id; + u32 atype; + u32 asel; + u32 src_thread; + u32 dst_thread; + enum psil_endpoint_type ep_type; + bool enable_acc32; + bool enable_burst; + enum udma_tp_level channel_tpl; /* Channel Throughput Level */ + + u32 tr_trigger_type; + unsigned long tx_flags; + + /* PKDMA mapped channel */ + int mapped_channel_id; + /* PKTDMA default tflow or rflow for mapped channel */ + int default_flow_id; + + enum dma_transfer_direction dir; +}; + +struct udma_chan { + struct virt_dma_chan vc; + struct dma_slave_config cfg; + struct udma_dev *ud; + struct device *dma_dev; + struct udma_desc *desc; + struct udma_desc *terminated_desc; + struct udma_static_tr static_tr; + char *name; + + struct udma_bchan *bchan; + struct udma_tchan *tchan; + struct udma_rchan *rchan; + struct udma_rflow *rflow; + + bool psil_paired; + + int irq_num_ring; + int irq_num_udma; + + bool cyclic; + bool paused; + + enum udma_chan_state state; + struct completion teardown_completed; + + struct udma_tx_drain tx_drain; + + /* Channel configuration parameters */ + struct udma_chan_config config; + /* Channel configuration parameters (backup) */ + struct udma_chan_config backup_config; + + /* dmapool for packet mode descriptors */ + bool use_dma_pool; + struct dma_pool *hdesc_pool; + + u32 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_thr= ead); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 06AA7427FB3; Fri, 24 Jul 2026 10:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888529; cv=fail; b=hY3UU6NkcQ3De33Yqe29ytxtfiLTTcL7tAbGzA0trqW/e+PAv8c6ghW/1yn9hRzpelfu8qXfL5ye9y6j4sPNwuNjsBRbA1PDstYuCzw8/4IZvAWUSplYkfuzWK7wAnuPnUr2+MCA0G8oexOMkqo2L+A7dHQGABks4TQ0w1EQyCI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888529; c=relaxed/simple; bh=CrhmwH9eBvGjcoh4biS6CACk15jQpXN9y4ObDGlFFck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GGG6kl5WmAvomMj2d798vxLegvXPg4maB+LftoalN/PybhfhoV6Q9YNYIAM5heh7aVsLf+Ies2HEIDXGlOErbhRDI8M/Ue2cxGebZlTR4S8gJZqIYbvTgQred0vzYH2f5m+Zaj3kCllx42uFGMMxS15Mh0Er910P/XTkI59LIuo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=GnxJefKX; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=hYN0iZqa; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="GnxJefKX"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="hYN0iZqa" Received: from pps.filterd (m0380145.ppops.net [127.0.0.1]) by m0380145.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAFHI4821421; Fri, 24 Jul 2026 05:21:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=uPMyrI1kGg32mzpEJpABjRZNA56YwScsWpTg+w/+i nM=; b=GnxJefKX0gX1rk8nuL+QGGFBnzUvN/F969n2fqPdjy9j7Ipnb8xxLOOpo n1jus+TV12ZSyzS2ykRguH2w40NDvQ8GZbC9VoIBT5Lz4l1YRYIQuam4ylFlDVYd WubyY7y/mmfXDSsvYSdfpQ1YjuPbjDWJgnnNmpML206ZpA0arHYeW/ILXFAzBe8T d8fmQAgoX9BfchO6EmP9+q3Xu/2pHA/szAhMQzrw6SLtLD7pm+XdZGobCGNURK6d 3iTpEnoPmtZ1cgznQomzP83K/eo0aK2T9x2kP0dv0RsKOtzCxrEZIG6LgOvULkk2 Nqe84DebKCZG9lsiA6mGfRPF2VSMQ== Received: from dm1pr04cu001.outbound.protection.outlook.com (mail-centralusazon11010062.outbound.protection.outlook.com [52.101.61.62]) by m0380145.ppops.net (PPS) with ESMTPS id 4fm4vw0d40-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:21:58 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ETv1BN1iBxkU12pwtpvzvljyizSYgQyo4BgKnVQTYgDRabB7sySe79BOPE0hjD756HSRbYOtcOWMi18AcfNQa+oSXjlsjMIKLa7zygBwZpa7eXjHUahANlGyHYnmjWHhpoKE0Tn09jH8GMElDj2f6Xj5uX2qPd1EbJgYykF5eC3oDj/Qf09ABIbvagMmRnWXAHH4/S7D8mFYvW4zvWCvEbuLZVEpOcmdRvO4rWQLnReN2I15phAp4tt/ivyfV3kIvwu/EgIu5GJxqM73jYA+8HCI5t2y4jngp7XJgc+mH93D41k5m9PTzwEIjnLiYVss4fU1+Uf7zQhrczaj4vZipA== 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=uPMyrI1kGg32mzpEJpABjRZNA56YwScsWpTg+w/+inM=; b=ZJRh7Dt0abEgRIE/4bF8oWfc7HDTOi4ga1UHFCfALiJhAdVFt8FxyXmtv3OPKi5GoOGPSOCIpO87Cy5RVquiM71yGX+PgqUR3VksP3uO0bN/B6J40yvc4uj2nNVCasmIoddPobf4gFhbvVbg5tF8G/taxQwI++4hDfY2rFWe3sllrPnN6HO7bWERMKqPt/UurxIt3Sdrk5kOK/1vPe5OsTDr7sL74HO6x4a/kV/CSohB+d/TLNq81zZa0ZVh9YiAHSyRqURSVr0xje5RFPkU0OupwuuJzE0n4Xg4GqQgSVjtytOmdmgJoj5OVpIjOhe9vdGa8CWYYQ9iaCXvCmh5WA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uPMyrI1kGg32mzpEJpABjRZNA56YwScsWpTg+w/+inM=; b=hYN0iZqaFwT24DCloqvs2gwHUoSH9IsQP3XvhEPcSM0UlKbVbGvYKpOpGP1r25t0Y5U/4Kh+rvgnkStpo5siCjYOK/jFex3mQ06NPLqn81tez7CrkQNsH10rH2TUAVs3zZYAPg/Mo4BLlxk4hqiRnGndd/pVSM5DJ5xeQUDNLQA= Received: from SJ0PR03CA0372.namprd03.prod.outlook.com (2603:10b6:a03:3a1::17) by DM3PPF3D2127785.namprd10.prod.outlook.com (2603:10b6:f:fc00::c20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.12; Fri, 24 Jul 2026 10:21:52 +0000 Received: from MWH0EPF000C6193.namprd02.prod.outlook.com (2603:10b6:a03:3a1:cafe::f) by SJ0PR03CA0372.outlook.office365.com (2603:10b6:a03:3a1::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:21:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by MWH0EPF000C6193.mail.protection.outlook.com (10.167.249.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:21:50 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:48 -0500 Received: from DFLE210.ent.ti.com (10.64.6.68) by DFLE207.ent.ti.com (10.64.6.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:48 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:21:48 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFJ3017088; Fri, 24 Jul 2026 05:21:43 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 04/19] dmaengine: ti: k3-udma: move static inline helper functions to header file Date: Fri, 24 Jul 2026 15:50:37 +0530 Message-ID: <20260724102115.2854-5-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6193:EE_|DM3PPF3D2127785:EE_ X-MS-Office365-Filtering-Correlation-Id: 87b0454a-e4f5-4607-7dce-08dee96d6037 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|1800799024|376014|7416014|23010399003|10067099003|56012099006|6133799003|921020|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: HaVwGU4UpWJa86PBFs5bQ3Gt0diDfXnpnVHUrTO5z9W0qgib5TFPQh34pyJD+3Qv9wukLOhmJ4HCJ1XGx1aYN3GEJOyc4r4e4TtRmoov2IA/lOsEmiBYLplpNdvcnIw96fjh48QYs6He2VkA51875ZpjMrwN/adBIkMBDqc8Lwx8/F1RVNQKbP6BuvO677ZFW1yxzNItCL3BS+Bd3VqBAN4KK7c7pmpvAKJNe6Xq0R0kEcVuiks9R9Wx/x5oORZT6nX2SfnjqaNIfgr3zLy2Pi4Khd2vN/OwljHiqqCXuoT6BsS3tX9VDaPIbjw5ylXECsk1yebA8Da8ry8gV9r0tEvZOuYOu3IAeiT4bs0Q9Wj0Jtzn+3FGMy8Y6+rEsFKCnV+I8R16BUlJi140NojsrGbIhFCwKv3z+MNgp2TzEdZNdqshi8Z78JLd+aReUPzw0pyyqoWzXeDLSd9ynGeTuFm8S1opyYCz7o6A45M9NKKIVq+z7gUr7LSyRhU31Lb+ozrDjPnvZmXF3/QzBp3IYKhggwJiNUbumZKYHoR8L0OVTbsLsOQghZef+NLw/ATEeWm0OCxfQW26mGvkbbbMfDSvJ0WogJV7YwrMn7IpSBjQKsbowXG0KQTdmZvOVIpJsbdoC5QCWhvHhG5NbLi78kl6UT009uQ8BBOUEQXaoyc5gE6fqQlHl4P1EicTPvrXCNVKFVoh5iiYEkR59UWxO5r8F6wpWCBwLH1c5ZQipibvu4uPKc8uosCnsqB0cyoR X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(1800799024)(376014)(7416014)(23010399003)(10067099003)(56012099006)(6133799003)(921020)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aEa50KymMqOgEClULVJB0ncBYrV8/u2HMmT91JiUS30ReX9dXtGiMYf79iR/EucPz/kqoxf2Iay2gKwi8twA14SBvc/hpW4JgIW47TIoNhTZuHgUVMHTFBwMXlubliODRd8QF5oRgThHjh5D8kImTInRj8rlmMmZRoPOiaAdhIBnDeOoDFGDU/ku9OOgbfZWI9pXWogckWVUedbgABzgjx02n8jhXRkAdhaeYcdB6lpDuQKy9nUqyGnn6ECK8V2oZ24P1qSKLB/EQ3jNJwvNFEY38mvvplOnBdUV5wNfkMUNBAGL9uT6FCBjG19bt2GTqedKV1XtNUVSljVXeTG8Dm2lXNz4AmPZY1BLrfV2UsyoahPiXpdG+kJ5LuUzqubmxpu9MebJjiMPXmKA6K4E0/WxwFqfwJBMfbnG1T+VdU2OINub+XUQQqxx+JkAeh6r X-Exchange-RoutingPolicyChecked: hSYb7b9UmGNUWSAvbHXtk/qeqafUNv/ae802n5/DyUVsWh26fB0fEn6v/pUyoSCCnfrhj+1gdJeubQRYzrr4XqqplYNj8If8KZu6U9H9u9SoKKe672mXetNepdsr9a7+lowmuaeLMBKbbnvqlqx6m6Hux0Aez6qv4XBv9PnAPq68m3zy1Tb+ZNWs6waK1gZdx/+IwHYV443W95GIujZwyrnK1jwGeKiK+cq4kHgprz8uVrPnHNCBMHKAGGONulYITLkTHjs4aiNuXuIotPz1+nnv2RWvrW8yVb1VBc6eKl4naB1y5tEzUQYfFTwnhG0rcGpF2dlu7Gv7WjDRNqOZdA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:21:50.6874 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87b0454a-e4f5-4607-7dce-08dee96d6037 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6193.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PPF3D2127785 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX5YKCIcFnVNNq 6mnwex28nxB0c1iKnfohFmVhwprrue1AIhhK8EaBigA+L5uWDHbsLmzZnWoRh3ldVxPZPcAGkWa nml0mYrlhBY9B+eR0IZYbPNLkpE883hNPQZYlkpQq3wBLbws4FqSALAMgtmKjPtS65TMr9VLjqB kpLRdlgS/jqB2d6gDBXQp6aTowFpsKHsoP4+46a3jgzeOJC40bLSeg8vZjBrfxguKeWRHMcyo6j N5DOJgFcJnJnSUt3mkARerAFKxWMFqxBVhwb38M1uoFpimW34V2TArF2yUGsaC6ck7c4CRLK7MZ vgQx5WUu64RLV1C2afPRaTx9DWj+U11LkjBdOkubTv949GnqVScozv2YBU+hCfZAS4iSsIEPbjy AUOxxEbvb7CfP0/DiluVJH2jxoAVsgWwbVvI5B5U0ehjoM9sXg78MdBLCEkzAv9QPXQC5lO931F /wdsDYCrQdM7fcPXM4A== X-Proofpoint-GUID: GjHLFzIUV8mq_jqO74MGNuUorQnCeYp0 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX0WeHnehQ+Ntm vp/dkPAKn1twqzOOSQtQwNnTs9xODY0Ii3lzGnSq1dgzZ+3u2DIF2cqy4J97QV/nOemUn0Elq6c Vj8yBwDWFcE3E8GNG29ORoz+9xrsqWg= X-Proofpoint-ORIG-GUID: GjHLFzIUV8mq_jqO74MGNuUorQnCeYp0 X-Authority-Analysis: v=2.4 cv=feadDUQF c=1 sm=1 tr=0 ts=6a633cc6 cx=c_pps a=rA8xTxhMCG4Q6PG1LLvkJA==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=8AirrxEcAAAA:8 a=sozttTNsAAAA:8 a=grpEhN_aSmkWsCgVS3MA:9 a=ST-jHhOKWsTCqRlWije3:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 adultscore=0 impostorscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Move static inline helper functions in k3-udma.c to k3-udma.h header file for better separation and reuse. Reviewed-by: Frank Li Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma.c | 108 -------------------------------------- drivers/dma/ti/k3-udma.h | 109 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 108 deletions(-) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index ce706033143ad..0eaa06b7ae988 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -40,91 +40,6 @@ static const char * const mmr_names[] =3D { [MMR_TCHANRT] =3D "tchanrt", }; =20 -static inline struct udma_dev *to_udma_dev(struct dma_device *d) -{ - return container_of(d, struct udma_dev, ddev); -} - -static inline struct udma_chan *to_udma_chan(struct dma_chan *c) -{ - return container_of(c, struct udma_chan, vc.chan); -} - -static inline struct udma_desc *to_udma_desc(struct dma_async_tx_descripto= r *t) -{ - return container_of(t, struct udma_desc, vd.tx); -} - -/* Generic register access functions */ -static inline u32 udma_read(void __iomem *base, int reg) -{ - return readl(base + reg); -} - -static inline void udma_write(void __iomem *base, int reg, u32 val) -{ - writel(val, base + reg); -} - -static inline void udma_update_bits(void __iomem *base, int reg, - u32 mask, u32 val) -{ - u32 tmp, orig; - - orig =3D readl(base + reg); - tmp =3D orig & ~mask; - tmp |=3D (val & mask); - - if (tmp !=3D orig) - writel(tmp, base + reg); -} - -/* TCHANRT */ -static inline u32 udma_tchanrt_read(struct udma_chan *uc, int reg) -{ - if (!uc->tchan) - return 0; - return udma_read(uc->tchan->reg_rt, reg); -} - -static inline void udma_tchanrt_write(struct udma_chan *uc, int reg, u32 v= al) -{ - if (!uc->tchan) - return; - udma_write(uc->tchan->reg_rt, reg, val); -} - -static inline void udma_tchanrt_update_bits(struct udma_chan *uc, int reg, - u32 mask, u32 val) -{ - if (!uc->tchan) - return; - udma_update_bits(uc->tchan->reg_rt, reg, mask, val); -} - -/* RCHANRT */ -static inline u32 udma_rchanrt_read(struct udma_chan *uc, int reg) -{ - if (!uc->rchan) - return 0; - return udma_read(uc->rchan->reg_rt, reg); -} - -static inline void udma_rchanrt_write(struct udma_chan *uc, int reg, u32 v= al) -{ - if (!uc->rchan) - return; - udma_write(uc->rchan->reg_rt, reg, val); -} - -static inline void udma_rchanrt_update_bits(struct udma_chan *uc, int reg, - u32 mask, u32 val) -{ - if (!uc->rchan) - return; - udma_update_bits(uc->rchan->reg_rt, reg, mask, val); -} - static int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_th= read) { struct udma_tisci_rm *tisci_rm =3D &ud->tisci_rm; @@ -216,17 +131,6 @@ static void udma_dump_chan_stdata(struct udma_chan *uc) } } =20 -static inline dma_addr_t udma_curr_cppi5_desc_paddr(struct udma_desc *d, - int idx) -{ - return d->hwdesc[idx].cppi5_desc_paddr; -} - -static inline void *udma_curr_cppi5_desc_vaddr(struct udma_desc *d, int id= x) -{ - return d->hwdesc[idx].cppi5_desc_vaddr; -} - static struct udma_desc *udma_udma_desc_from_paddr(struct udma_chan *uc, dma_addr_t paddr) { @@ -369,11 +273,6 @@ static bool udma_is_chan_paused(struct udma_chan *uc) return false; } =20 -static inline dma_addr_t udma_get_rx_flush_hwdesc_paddr(struct udma_chan *= uc) -{ - return uc->ud->rx_flush.hwdescs[uc->config.pkt_mode].cppi5_desc_paddr; -} - static int udma_push_to_ring(struct udma_chan *uc, int idx) { struct udma_desc *d =3D uc->desc; @@ -775,13 +674,6 @@ static void udma_cyclic_packet_elapsed(struct udma_cha= n *uc) d->desc_idx =3D (d->desc_idx + 1) % d->sglen; } =20 -static inline void udma_fetch_epib(struct udma_chan *uc, struct udma_desc = *d) -{ - struct cppi5_host_desc_t *h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; - - memcpy(d->metadata, h_desc->epib, d->metadata_size); -} - static bool udma_is_desc_really_done(struct udma_chan *uc, struct udma_des= c *d) { u32 peer_bcnt, bcnt; diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 11d08adb0d69f..54e1757c3de38 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -451,6 +451,115 @@ struct udma_chan { u32 id; }; =20 +/* K3 UDMA helper functions */ +static inline struct udma_dev *to_udma_dev(struct dma_device *d) +{ + return container_of(d, struct udma_dev, ddev); +} + +static inline struct udma_chan *to_udma_chan(struct dma_chan *c) +{ + return container_of(c, struct udma_chan, vc.chan); +} + +static inline struct udma_desc *to_udma_desc(struct dma_async_tx_descripto= r *t) +{ + return container_of(t, struct udma_desc, vd.tx); +} + +/* Generic register access functions */ +static inline u32 udma_read(void __iomem *base, int reg) +{ + return readl(base + reg); +} + +static inline void udma_write(void __iomem *base, int reg, u32 val) +{ + writel(val, base + reg); +} + +static inline void udma_update_bits(void __iomem *base, int reg, + u32 mask, u32 val) +{ + u32 tmp, orig; + + orig =3D readl(base + reg); + tmp =3D orig & ~mask; + tmp |=3D (val & mask); + + if (tmp !=3D orig) + writel(tmp, base + reg); +} + +/* TCHANRT */ +static inline u32 udma_tchanrt_read(struct udma_chan *uc, int reg) +{ + if (!uc->tchan) + return 0; + return udma_read(uc->tchan->reg_rt, reg); +} + +static inline void udma_tchanrt_write(struct udma_chan *uc, int reg, u32 v= al) +{ + if (!uc->tchan) + return; + udma_write(uc->tchan->reg_rt, reg, val); +} + +static inline void udma_tchanrt_update_bits(struct udma_chan *uc, int reg, + u32 mask, u32 val) +{ + if (!uc->tchan) + return; + udma_update_bits(uc->tchan->reg_rt, reg, mask, val); +} + +/* RCHANRT */ +static inline u32 udma_rchanrt_read(struct udma_chan *uc, int reg) +{ + if (!uc->rchan) + return 0; + return udma_read(uc->rchan->reg_rt, reg); +} + +static inline void udma_rchanrt_write(struct udma_chan *uc, int reg, u32 v= al) +{ + if (!uc->rchan) + return; + udma_write(uc->rchan->reg_rt, reg, val); +} + +static inline void udma_rchanrt_update_bits(struct udma_chan *uc, int reg, + u32 mask, u32 val) +{ + if (!uc->rchan) + return; + udma_update_bits(uc->rchan->reg_rt, reg, mask, val); +} + +static inline dma_addr_t udma_curr_cppi5_desc_paddr(struct udma_desc *d, + int idx) +{ + return d->hwdesc[idx].cppi5_desc_paddr; +} + +static inline void *udma_curr_cppi5_desc_vaddr(struct udma_desc *d, int id= x) +{ + return d->hwdesc[idx].cppi5_desc_vaddr; +} + +static inline dma_addr_t udma_get_rx_flush_hwdesc_paddr(struct udma_chan *= uc) +{ + return uc->ud->rx_flush.hwdescs[uc->config.pkt_mode].cppi5_desc_paddr; +} + +static inline void udma_fetch_epib(struct udma_chan *uc, struct udma_desc = *d) +{ + struct cppi5_host_desc_t *h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; + + memcpy(d->metadata, h_desc->epib, d->metadata_size); +} + /* 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_thr= ead); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 CF26742EEAA; Fri, 24 Jul 2026 10:22:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888549; cv=fail; b=W3HWdRKrK4zBA0tn2pqixbuKXqJ8Qwphwl6sBfKpI10msDouk0pvQHhrC86wChEX1QaWLMjRiwpQVekNkJYjUM+PdjFFiDtRqFPimxwy/cCpuns+KbtaeGxUFmYNsCOktjK2a0Xwp6PCt35N5s91e6L89l59hHsv4OcwKE28TJo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888549; c=relaxed/simple; bh=U+wkwYRJuwV9MPoINjMokgVVIuG9ZI7ca6UXS4K/rrk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VtDShrELTETFflsBGzBtTIFUmGBCkdpRtprhXU+fSSRy4kP9XijZparLqkxp4GeUPl7L6dvHyjOfLyEFg8myfFkAsMjLN96LDvq/oW71hIEea2jImxGf+waeU7nhc7CATgQHD5JkwmOPQs43UbumWqnX5qMbRMvB+7T778bj5Z0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=nMB/pNv6; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=vd9nFhqg; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="nMB/pNv6"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="vd9nFhqg" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFlYb785956; Fri, 24 Jul 2026 05:22:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=11mPg0XOoOd5J6NgkXHOPJI6Oi9PwGY7GFfzzGnPL K4=; b=nMB/pNv6TwIppV5vfz7QLLh/9OTCCsLntYHkYOr0guDYjaktDnaImtpK/ 2tyalqCtMNxDH1tpKF+acb8H6rKB8O4Qez8RUnwe2WyLzWAVH3Gnc3+QXsw+bqSO 1s49aUcMEb2KGeLAkrkVDurlyywKgK51FOSNSmAB9BWeVRHFIlO04bXt38u7vNeT 20qSkrInlkQLDRKTREEXUeQyO2clHamh7IIgD/SqC0V4+KZ+7U0czsrw+LLtW5tX rgbJLWPWryG4UvXEEYucUq2fWh0ukZmiF8HGnrKVsfIBkbrO1Ubv9h47BrWRzC5w iQoyHyr2/ufrfMhKsw38K/nvNYwMg== Received: from cy3pr05cu001.outbound.protection.outlook.com (mail-westcentralusazon11013051.outbound.protection.outlook.com [40.93.201.51]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fm5p304jp-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:06 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EEV3skto5oCz3dAztYsUtaxXzu66JVo4gUmTmYf1tUxUf8eqNGjlWknYXx+qi5hKMxJAQuZmJatDHI40GOTum1YtbJoX0Ujy3cvVfl5iK6dD9ceTPUNhzUv2uDXPqnEvHrN5s9H1TMQy7M3yqPFIHb4HUsX7CSPPsjIAFXGa1gvyVpcn2SfvFfAXs7IhnCxdMY3TOiNaaH20KNGJkkvY52OLhVGRaX8EpPnAdm9PIqztFb0xoayzuH+2ZiOf9F74okl9sjsAswPXAJ+ETe6zYm5XEzjftg0HUvodflFaorTnrmKwYUGokH7V6W8kX/HxrB3LGoyaYxSyP0wnUq2SIw== 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=11mPg0XOoOd5J6NgkXHOPJI6Oi9PwGY7GFfzzGnPLK4=; b=KgJRe/ZOLyEDtE/vkAEg6ALBy5dipCCYJE5mE3tRLF1ByhqUmbqK/dJ9/mhWAQU6e7YRRvcslHazo5EIWdMYTR4f0Qzl5fMEQLrcoiLFDf2aC8jddePQB5tu0IQ0OaBNxs+LHnn/luC7lmVGdyQa/mgtfS3un9B61F+RQccLr8eu57R3ktu3lTobDrW178D58DoJaK790zFRBJN8FFJQmNcrdSutnUauo14Mjegzzw+4R3mLd7Ag65rbRkYA3CfOmg07/koUs7XCZ33Phz0gqnDbJeCvV5acRM0MEDCFDH2rYY5wlEntNJSBf2iy+j0Kg0GxwAJZZ93fM0xils2DOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=11mPg0XOoOd5J6NgkXHOPJI6Oi9PwGY7GFfzzGnPLK4=; b=vd9nFhqgBHII7wNXerbXxFJR77+zlBiiGbegvmIIzGRiiw5cKA4BzUltlKOj3QwAH44BMU4VMFgryHuQGQJSUQEbDP/gIUliC/y8wkhg2SSZ+xBDaGPIdpb8D5ZZPjXwMI7OhuPKhBdfVGSWGixPtQPeeK9Ylr461iDZN1xVAcU= Received: from PH8PR05CA0010.namprd05.prod.outlook.com (2603:10b6:510:2cc::15) by DS0PR10MB6728.namprd10.prod.outlook.com (2603:10b6:8:11c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:21:59 +0000 Received: from SJ1PEPF00002315.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::a6) by PH8PR05CA0010.outlook.office365.com (2603:10b6:510:2cc::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.7 via Frontend Transport; Fri, 24 Jul 2026 10:21:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF00002315.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:21:59 +0000 Received: from DLEE215.ent.ti.com (157.170.170.118) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:53 -0500 Received: from DLEE202.ent.ti.com (157.170.170.77) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:53 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE202.ent.ti.com (157.170.170.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:21:53 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFK3017088; Fri, 24 Jul 2026 05:21:48 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 05/19] dmaengine: ti: k3-udma: move descriptor management to k3-udma-common.c Date: Fri, 24 Jul 2026 15:50:38 +0530 Message-ID: <20260724102115.2854-6-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002315:EE_|DS0PR10MB6728:EE_ X-MS-Office365-Filtering-Correlation-Id: 6695c62b-2513-469a-cf1c-08dee96d654b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|1800799024|23010399003|376014|7416014|5023799004|10067099003|56012099006|6133799003|10063799003|18002099003|22082099003|3023799007|921020|13003099007; X-Microsoft-Antispam-Message-Info: fw+s2YnwFvw/TFEgmqhbT0CjR42mf+sleDbGgfBJ/8tRg0nV3oUEaO+zc/t2vST2cx36iJMXlA/A4Qw2j7Nh/F3m6O4eXc0vwp5AIg9jYVG/iDOAgo7b+0SGuch782IN4ElMAb6E3ovDAwpgm3RDjvjnM0tzYcx8cJqdyIwxfeFsFLPuA3O8DZNPTDHAUsN6fyPPaBTbmAgFwHQSHdcWIWIEB2zmFPOAF3atYxfUnudjsP8dvEIpwOUnS+A24n7NM0OTMoL5Vu5VGEhsu0xDBv4J6zn/GNWGGNoIVLcVFV/Yiw/tpZQRCt3nkTOUgIk4vxjMCcNIilRY8CwVZOGQbkRr1O043ETrEVqhZzyuD43J68bUOilSN94B1pa1xecpAsQ4ACCJSTsBZUwvjM3kKnl4cj20ejTYflmm1ephd87QGLrjh5m638HGVp7N04ewALMilHDfb+49K1ICapkGaSTem5O12+WuyN5byV8dBdmWTJXMHNoZKPViVRb729DHIHO3xp3yK4zgk/anul0xljxgyvbhf18NyzBobySX9PlS2ip5PxypeoeakLjhaQAgY990hTP7S0YOh/jq34EwUIBRUXLjQ2O8D82VO13/WfE3X9RRvmAK1oxzYo7dKvfDjm6Xlw2NjnqCbXcE6veTi01ZkbG1SbCHYJwAk2J586tduFeoXmqVcZ5/FzwI16wh X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(1800799024)(23010399003)(376014)(7416014)(5023799004)(10067099003)(56012099006)(6133799003)(10063799003)(18002099003)(22082099003)(3023799007)(921020)(13003099007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iOzl+dy1U0SNXrr1fm4NoXpywpVYJhP6CET6F86zudm2EmsxoS3YQS75fG09XMUNkkW+7kgDqVq8+l/6ikihBS8d1gsCyrNtrk86t0DzK7O530ntzNRz7jrv2iSB9ZvieQeRve/Kt3JeiUhDk8R7dBbbrgKK3YseOOc9rWOLAY8HIia/m/2LZReMi+faqnH80v1fVPiOQtBsMTA3zjCBWiGtALTp7tNOwVTAYHW0BQ0F8QUvmor13pZCD9wil24pOH4XkmghpJlaT8fKIl3mqXa8uBoErdVI1Wj2aC9Paa0GZUm2rNrAn3T550sXX8HIwiT0xSOvJOimmbha24kz5NSy1b9XBcG5JNR0M6PyYqL6wRVNpfW3It7kQTbCjRMRSL/9ZNsJC7DKA2T0taADx2txyqW6OsRzrkgwZ935E8FSK4z4GX8rLgjAI1DK0S4Y X-Exchange-RoutingPolicyChecked: BuAJhNAbl4udbDZgrAgjzeUXzqsVjOE/dg+vinVGmyMn0wHQIxwrreB6Xv7EBeURTyXYeCTr+fJpS1c0IDs3Oh4BUPPiwwKNzID9VHDo+L6H0TvKz1l9T9kClPjm74s0R1rG7Xo00FVZuZhjcUmXvzLdhokkPmwXLbPkNRu+vBBQ2Qg17Qrvmh3xoXpmo5Hljzf14wxmtCH4Y7DhRHeNY11boLmekUiC5Jf1rnatCK3CZSoupILSpyG0gVcvWjZ62Ff3XOc+bQjuG2OLFmo188Q1XE19t/xEIZCWkoqMJor5mFoZ3OwplcYrluftZeM2akB6GpLb4FKeHTmweCEf9A== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:21:59.2033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6695c62b-2513-469a-cf1c-08dee96d654b X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002315.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6728 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX4utJ5MF2HmR2 tF3p8O+asY7SQB6mg8DlpQMHPec9I+o+nwPu3iaXZfMLD5VvM+qLThqvteH738je3UJGkg/vRFk 8aLXFoIkkJ8EnnauujVOb2RRj2OJxOYOyyajGwBiI05zqkhmLNNJXAk0HggeQ7lPhez6DQCi7Wp OKA8tTRAUXRv766DSeOaMMqzBDCIPdWxoR2Tjpt2TV2SPFI6tXOfdVT3ugZ+4hGCt4TLXvEU+3m /5Hu3TH3aKHgGjyvQNxRQyQH9u18WymNsV22H1PWDEN1l75smXHNWhYpbxHdJXjuU9gkqqGv2Pp GoRJGr8DWOitjz8ij8Uvh2HlK8ubqtJXqKilzBiP/m4M408K9V8ZV+R+JmcCvlfEapzYDiItdSw lbwxHPlENbcvyi06/z+1DrVO+BYRWDnTZ8ly0imyH6weZAWRegx2lR9phKHEDrlW1JyyxH+ArAq ainhVty5jCfeD+r5NZA== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX8iWkPYDBGZY1 QQIwfACF+3RpKU4vw6PfKD16wM8uFW9hCHmRSUYZh8KPITiiHgV5iPgaTGKKQP4Km8Rz1TovC+p aTDFJFn+YYB3ovHBotVi+yqriTYuBjw= X-Proofpoint-GUID: 9_aY8trZfRoPTTR6OEFiIiMzHZgQ94og X-Proofpoint-ORIG-GUID: 9_aY8trZfRoPTTR6OEFiIiMzHZgQ94og X-Authority-Analysis: v=2.4 cv=C8PZDwP+ c=1 sm=1 tr=0 ts=6a633ccf cx=c_pps a=xsj2MuQvL1s4LVRwU0hgyg==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=9fA4dagTuIDSJ7NYoQoA:9 a=x_a8ZKo73Tz1WADx:21 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Refactor the K3 UDMA driver by moving all DMA descriptor handling functions from k3-udma.c to a new common library, k3-udma-common.c. This prepares the driver for supporting new K3 UDMA v2 variant (used in AM62L) that can reuse the same descriptor handling logic. To ensure this common code works correctly across all build configurations (built-in vs modules), introduce a hidden Kconfig symbol: CONFIG_TI_K3_UDMA_COMMON. No functional changes intended. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/Kconfig | 5 + drivers/dma/ti/Makefile | 1 + drivers/dma/ti/k3-udma-common.c | 1243 +++++++++++++++++++++++++++++++ drivers/dma/ti/k3-udma.c | 1218 ------------------------------ drivers/dma/ti/k3-udma.h | 54 ++ 5 files changed, 1303 insertions(+), 1218 deletions(-) create mode 100644 drivers/dma/ti/k3-udma-common.c diff --git a/drivers/dma/ti/Kconfig b/drivers/dma/ti/Kconfig index cbc30ab627832..712e456015459 100644 --- a/drivers/dma/ti/Kconfig +++ b/drivers/dma/ti/Kconfig @@ -42,12 +42,17 @@ config TI_K3_UDMA select DMA_ENGINE select DMA_VIRTUAL_CHANNELS select SOC_TI + select TI_K3_UDMA_COMMON select TI_K3_RINGACC select TI_K3_PSIL help Enable support for the TI UDMA (Unified DMA) controller. This DMA engine is used in AM65x and j721e. =20 +config TI_K3_UDMA_COMMON + tristate + default n + config TI_K3_UDMA_GLUE_LAYER tristate "Texas Instruments UDMA Glue layer for non DMAengine users" depends on ARCH_K3 || COMPILE_TEST diff --git a/drivers/dma/ti/Makefile b/drivers/dma/ti/Makefile index d376c117cecf6..3b91c02e55eaf 100644 --- a/drivers/dma/ti/Makefile +++ b/drivers/dma/ti/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_TI_CPPI41) +=3D cppi41.o obj-$(CONFIG_TI_EDMA) +=3D edma.o obj-$(CONFIG_DMA_OMAP) +=3D omap-dma.o obj-$(CONFIG_TI_K3_UDMA) +=3D k3-udma.o +obj-$(CONFIG_TI_K3_UDMA_COMMON) +=3D k3-udma-common.o obj-$(CONFIG_TI_K3_UDMA_GLUE_LAYER) +=3D k3-udma-glue.o k3-psil-lib-objs :=3D k3-psil.o \ k3-psil-am654.o \ diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c new file mode 100644 index 0000000000000..daf5f19dfb3ab --- /dev/null +++ b/drivers/dma/ti/k3-udma-common.c @@ -0,0 +1,1243 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com + * Author: Peter Ujfalusi + */ + +#include +#include +#include +#include +#include + +#include "k3-udma.h" + +const struct dma_descriptor_metadata_ops metadata_ops =3D { + .attach =3D udma_attach_metadata, + .get_ptr =3D udma_get_metadata_ptr, + .set_len =3D udma_set_metadata_len, +}; + +struct udma_desc *udma_udma_desc_from_paddr(struct udma_chan *uc, + dma_addr_t paddr) +{ + struct udma_desc *d =3D uc->terminated_desc; + + if (d) { + dma_addr_t desc_paddr =3D udma_curr_cppi5_desc_paddr(d, + d->desc_idx); + + if (desc_paddr !=3D paddr) + d =3D NULL; + } + + if (!d) { + d =3D uc->desc; + if (d) { + dma_addr_t desc_paddr =3D udma_curr_cppi5_desc_paddr(d, + d->desc_idx); + + if (desc_paddr !=3D paddr) + d =3D NULL; + } + } + + return d; +} +EXPORT_SYMBOL_GPL(udma_udma_desc_from_paddr); + +void udma_free_hwdesc(struct udma_chan *uc, struct udma_desc *d) +{ + if (uc->use_dma_pool) { + int i; + + for (i =3D 0; i < d->hwdesc_count; i++) { + if (!d->hwdesc[i].cppi5_desc_vaddr) + continue; + + dma_pool_free(uc->hdesc_pool, + d->hwdesc[i].cppi5_desc_vaddr, + d->hwdesc[i].cppi5_desc_paddr); + + d->hwdesc[i].cppi5_desc_vaddr =3D NULL; + } + } else if (d->hwdesc[0].cppi5_desc_vaddr) { + dma_free_coherent(uc->dma_dev, d->hwdesc[0].cppi5_desc_size, + d->hwdesc[0].cppi5_desc_vaddr, + d->hwdesc[0].cppi5_desc_paddr); + + d->hwdesc[0].cppi5_desc_vaddr =3D NULL; + } +} + +void udma_purge_desc_work(struct work_struct *work) +{ + struct udma_dev *ud =3D container_of(work, typeof(*ud), purge_work); + struct virt_dma_desc *vd, *_vd; + unsigned long flags; + LIST_HEAD(head); + + spin_lock_irqsave(&ud->lock, flags); + list_splice_tail_init(&ud->desc_to_purge, &head); + spin_unlock_irqrestore(&ud->lock, flags); + + list_for_each_entry_safe(vd, _vd, &head, node) { + struct udma_chan *uc =3D to_udma_chan(vd->tx.chan); + struct udma_desc *d =3D to_udma_desc(&vd->tx); + + udma_free_hwdesc(uc, d); + list_del(&vd->node); + kfree(d); + } + + /* If more to purge, schedule the work again */ + if (!list_empty(&ud->desc_to_purge)) + schedule_work(&ud->purge_work); +} +EXPORT_SYMBOL_GPL(udma_purge_desc_work); + +void udma_desc_free(struct virt_dma_desc *vd) +{ + struct udma_dev *ud =3D to_udma_dev(vd->tx.chan->device); + struct udma_chan *uc =3D to_udma_chan(vd->tx.chan); + struct udma_desc *d =3D to_udma_desc(&vd->tx); + unsigned long flags; + + if (uc->terminated_desc =3D=3D d) + uc->terminated_desc =3D NULL; + + if (uc->use_dma_pool) { + udma_free_hwdesc(uc, d); + kfree(d); + return; + } + + spin_lock_irqsave(&ud->lock, flags); + list_add_tail(&vd->node, &ud->desc_to_purge); + spin_unlock_irqrestore(&ud->lock, flags); + + schedule_work(&ud->purge_work); +} +EXPORT_SYMBOL_GPL(udma_desc_free); + +bool udma_desc_is_rx_flush(struct udma_chan *uc, dma_addr_t addr) +{ + if (uc->config.dir !=3D DMA_DEV_TO_MEM) + return false; + + if (addr =3D=3D udma_get_rx_flush_hwdesc_paddr(uc)) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(udma_desc_is_rx_flush); + +bool udma_is_desc_really_done(struct udma_chan *uc, struct udma_desc *d) +{ + u32 peer_bcnt, bcnt; + + /* + * Only TX towards PDMA is affected. + * If DMA_PREP_INTERRUPT is not set by consumer then skip the transfer + * completion calculation, consumer must ensure that there is no stale + * data in DMA fabric in this case. + */ + if (uc->config.ep_type =3D=3D PSIL_EP_NATIVE || + uc->config.dir !=3D DMA_MEM_TO_DEV || !(uc->config.tx_flags & DMA_PRE= P_INTERRUPT)) + return true; + + peer_bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_PEER_BCNT_REG); + bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); + + /* Transfer is incomplete, store current residue and time stamp */ + if (peer_bcnt < bcnt) { + uc->tx_drain.residue =3D bcnt - peer_bcnt; + uc->tx_drain.tstamp =3D ktime_get(); + return false; + } + + return true; +} +EXPORT_SYMBOL_GPL(udma_is_desc_really_done); + +struct udma_desc *udma_alloc_tr_desc(struct udma_chan *uc, + size_t tr_size, int tr_count, + enum dma_transfer_direction dir) +{ + struct udma_hwdesc *hwdesc; + struct cppi5_desc_hdr_t *tr_desc; + struct udma_desc *d; + u32 reload_count =3D 0; + u32 ring_id; + + switch (tr_size) { + case 16: + case 32: + case 64: + case 128: + break; + default: + dev_err(uc->ud->dev, "Unsupported TR size of %zu\n", tr_size); + return NULL; + } + + /* We have only one descriptor containing multiple TRs */ + d =3D kzalloc(sizeof(*d) + sizeof(d->hwdesc[0]), GFP_NOWAIT); + if (!d) + return NULL; + + d->sglen =3D tr_count; + + d->hwdesc_count =3D 1; + hwdesc =3D &d->hwdesc[0]; + + /* Allocate memory for DMA ring descriptor */ + if (uc->use_dma_pool) { + hwdesc->cppi5_desc_size =3D uc->config.hdesc_size; + hwdesc->cppi5_desc_vaddr =3D dma_pool_zalloc(uc->hdesc_pool, + GFP_NOWAIT, + &hwdesc->cppi5_desc_paddr); + } else { + hwdesc->cppi5_desc_size =3D cppi5_trdesc_calc_size(tr_size, + tr_count); + hwdesc->cppi5_desc_size =3D ALIGN(hwdesc->cppi5_desc_size, + uc->ud->desc_align); + hwdesc->cppi5_desc_vaddr =3D dma_alloc_coherent(uc->ud->dev, + hwdesc->cppi5_desc_size, + &hwdesc->cppi5_desc_paddr, + GFP_NOWAIT); + } + + if (!hwdesc->cppi5_desc_vaddr) { + kfree(d); + return NULL; + } + + /* Start of the TR req records */ + hwdesc->tr_req_base =3D hwdesc->cppi5_desc_vaddr + tr_size; + /* Start address of the TR response array */ + hwdesc->tr_resp_base =3D hwdesc->tr_req_base + tr_size * tr_count; + + tr_desc =3D hwdesc->cppi5_desc_vaddr; + + if (uc->cyclic) + reload_count =3D CPPI5_INFO0_TRDESC_RLDCNT_INFINITE; + + if (dir =3D=3D DMA_DEV_TO_MEM) + ring_id =3D k3_ringacc_get_ring_id(uc->rflow->r_ring); + else + ring_id =3D k3_ringacc_get_ring_id(uc->tchan->tc_ring); + + cppi5_trdesc_init(tr_desc, tr_count, tr_size, 0, reload_count); + cppi5_desc_set_pktids(tr_desc, uc->id, + CPPI5_INFO1_DESC_FLOWID_DEFAULT); + cppi5_desc_set_retpolicy(tr_desc, 0, ring_id); + + return d; +} + +/** + * udma_get_tr_counters - calculate TR counters for a given length + * @len: Length of the transfer + * @align_to: Preferred alignment + * @tr0_cnt0: First TR icnt0 + * @tr0_cnt1: First TR icnt1 + * @tr1_cnt0: Second (if used) TR icnt0 + * + * For len < SZ_64K only one TR is enough, tr1_cnt0 is not updated + * For len >=3D SZ_64K two TRs are used in a simple way: + * First TR: SZ_64K-alignment blocks (tr0_cnt0, tr0_cnt1) + * Second TR: the remaining length (tr1_cnt0) + * + * Returns the number of TRs the length needs (1 or 2) + * -EINVAL if the length can not be supported + */ +int udma_get_tr_counters(size_t len, unsigned long align_to, + u16 *tr0_cnt0, u16 *tr0_cnt1, u16 *tr1_cnt0) +{ + if (len < SZ_64K) { + *tr0_cnt0 =3D len; + *tr0_cnt1 =3D 1; + + return 1; + } + + if (align_to > 3) + align_to =3D 3; + +realign: + *tr0_cnt0 =3D SZ_64K - BIT(align_to); + if (len / *tr0_cnt0 >=3D SZ_64K) { + if (align_to) { + align_to--; + goto realign; + } + return -EINVAL; + } + + *tr0_cnt1 =3D len / *tr0_cnt0; + *tr1_cnt0 =3D len % *tr0_cnt0; + + return 2; +} + +struct udma_desc * +udma_prep_slave_sg_tr(struct udma_chan *uc, struct scatterlist *sgl, + unsigned int sglen, enum dma_transfer_direction dir, + unsigned long tx_flags, void *context) +{ + struct scatterlist *sgent; + struct udma_desc *d; + struct cppi5_tr_type1_t *tr_req =3D NULL; + u16 tr0_cnt0, tr0_cnt1, tr1_cnt0; + unsigned int i; + size_t tr_size; + int num_tr =3D 0; + int tr_idx =3D 0; + u64 asel; + + /* estimate the number of TRs we will need */ + for_each_sg(sgl, sgent, sglen, i) { + if (sg_dma_len(sgent) < SZ_64K) + num_tr++; + else + num_tr +=3D 2; + } + + /* Now allocate and setup the descriptor. */ + tr_size =3D sizeof(struct cppi5_tr_type1_t); + d =3D udma_alloc_tr_desc(uc, tr_size, num_tr, dir); + if (!d) + return NULL; + + d->sglen =3D sglen; + + if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) + asel =3D 0; + else + asel =3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; + + tr_req =3D d->hwdesc[0].tr_req_base; + for_each_sg(sgl, sgent, sglen, i) { + dma_addr_t sg_addr =3D sg_dma_address(sgent); + + num_tr =3D udma_get_tr_counters(sg_dma_len(sgent), __ffs(sg_addr), + &tr0_cnt0, &tr0_cnt1, &tr1_cnt0); + if (num_tr < 0) { + dev_err(uc->ud->dev, "size %u is not supported\n", + sg_dma_len(sgent)); + udma_free_hwdesc(uc, d); + kfree(d); + return NULL; + } + + cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, false, + false, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + cppi5_tr_csf_set(&tr_req[tr_idx].flags, CPPI5_TR_CSF_SUPR_EVT); + + sg_addr |=3D asel; + tr_req[tr_idx].addr =3D sg_addr; + tr_req[tr_idx].icnt0 =3D tr0_cnt0; + tr_req[tr_idx].icnt1 =3D tr0_cnt1; + tr_req[tr_idx].dim1 =3D tr0_cnt0; + tr_idx++; + + if (num_tr =3D=3D 2) { + cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, + false, false, + CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + cppi5_tr_csf_set(&tr_req[tr_idx].flags, + CPPI5_TR_CSF_SUPR_EVT); + + tr_req[tr_idx].addr =3D sg_addr + tr0_cnt1 * tr0_cnt0; + tr_req[tr_idx].icnt0 =3D tr1_cnt0; + tr_req[tr_idx].icnt1 =3D 1; + tr_req[tr_idx].dim1 =3D tr1_cnt0; + tr_idx++; + } + + d->residue +=3D sg_dma_len(sgent); + } + + cppi5_tr_csf_set(&tr_req[tr_idx - 1].flags, + CPPI5_TR_CSF_SUPR_EVT | CPPI5_TR_CSF_EOP); + + return d; +} + +struct udma_desc * +udma_prep_slave_sg_triggered_tr(struct udma_chan *uc, struct scatterlist *= sgl, + unsigned int sglen, + enum dma_transfer_direction dir, + unsigned long tx_flags, void *context) +{ + struct scatterlist *sgent; + struct cppi5_tr_type15_t *tr_req =3D NULL; + enum dma_slave_buswidth dev_width; + u32 csf =3D CPPI5_TR_CSF_SUPR_EVT; + u16 tr_cnt0, tr_cnt1; + dma_addr_t dev_addr; + struct udma_desc *d; + unsigned int i; + size_t tr_size, sg_len; + int num_tr =3D 0; + int tr_idx =3D 0; + u32 burst, trigger_size, port_window; + u64 asel; + + if (dir =3D=3D DMA_DEV_TO_MEM) { + dev_addr =3D uc->cfg.src_addr; + dev_width =3D uc->cfg.src_addr_width; + burst =3D uc->cfg.src_maxburst; + port_window =3D uc->cfg.src_port_window_size; + } else if (dir =3D=3D DMA_MEM_TO_DEV) { + dev_addr =3D uc->cfg.dst_addr; + dev_width =3D uc->cfg.dst_addr_width; + burst =3D uc->cfg.dst_maxburst; + port_window =3D uc->cfg.dst_port_window_size; + } else { + dev_err(uc->ud->dev, "%s: bad direction?\n", __func__); + return NULL; + } + + if (!burst) + burst =3D 1; + + if (port_window) { + if (port_window !=3D burst) { + dev_err(uc->ud->dev, + "The burst must be equal to port_window\n"); + return NULL; + } + + tr_cnt0 =3D dev_width * port_window; + tr_cnt1 =3D 1; + } else { + tr_cnt0 =3D dev_width; + tr_cnt1 =3D burst; + } + trigger_size =3D tr_cnt0 * tr_cnt1; + + /* estimate the number of TRs we will need */ + for_each_sg(sgl, sgent, sglen, i) { + sg_len =3D sg_dma_len(sgent); + + if (sg_len % trigger_size) { + dev_err(uc->ud->dev, + "Not aligned SG entry (%zu for %u)\n", sg_len, + trigger_size); + return NULL; + } + + if (sg_len / trigger_size < SZ_64K) + num_tr++; + else + num_tr +=3D 2; + } + + /* Now allocate and setup the descriptor. */ + tr_size =3D sizeof(struct cppi5_tr_type15_t); + d =3D udma_alloc_tr_desc(uc, tr_size, num_tr, dir); + if (!d) + return NULL; + + d->sglen =3D sglen; + + if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) { + asel =3D 0; + csf |=3D CPPI5_TR_CSF_EOL_ICNT0; + } else { + asel =3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; + dev_addr |=3D asel; + } + + tr_req =3D d->hwdesc[0].tr_req_base; + for_each_sg(sgl, sgent, sglen, i) { + u16 tr0_cnt2, tr0_cnt3, tr1_cnt2; + dma_addr_t sg_addr =3D sg_dma_address(sgent); + + sg_len =3D sg_dma_len(sgent); + num_tr =3D udma_get_tr_counters(sg_len / trigger_size, 0, + &tr0_cnt2, &tr0_cnt3, &tr1_cnt2); + if (num_tr < 0) { + dev_err(uc->ud->dev, "size %zu is not supported\n", + sg_len); + udma_free_hwdesc(uc, d); + kfree(d); + return NULL; + } + + cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE15, false, + true, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + cppi5_tr_csf_set(&tr_req[tr_idx].flags, csf); + cppi5_tr_set_trigger(&tr_req[tr_idx].flags, + uc->config.tr_trigger_type, + CPPI5_TR_TRIGGER_TYPE_ICNT2_DEC, 0, 0); + + sg_addr |=3D asel; + if (dir =3D=3D DMA_DEV_TO_MEM) { + tr_req[tr_idx].addr =3D dev_addr; + tr_req[tr_idx].icnt0 =3D tr_cnt0; + tr_req[tr_idx].icnt1 =3D tr_cnt1; + tr_req[tr_idx].icnt2 =3D tr0_cnt2; + tr_req[tr_idx].icnt3 =3D tr0_cnt3; + tr_req[tr_idx].dim1 =3D (-1) * tr_cnt0; + + tr_req[tr_idx].daddr =3D sg_addr; + tr_req[tr_idx].dicnt0 =3D tr_cnt0; + tr_req[tr_idx].dicnt1 =3D tr_cnt1; + tr_req[tr_idx].dicnt2 =3D tr0_cnt2; + tr_req[tr_idx].dicnt3 =3D tr0_cnt3; + tr_req[tr_idx].ddim1 =3D tr_cnt0; + tr_req[tr_idx].ddim2 =3D trigger_size; + tr_req[tr_idx].ddim3 =3D trigger_size * tr0_cnt2; + } else { + tr_req[tr_idx].addr =3D sg_addr; + tr_req[tr_idx].icnt0 =3D tr_cnt0; + tr_req[tr_idx].icnt1 =3D tr_cnt1; + tr_req[tr_idx].icnt2 =3D tr0_cnt2; + tr_req[tr_idx].icnt3 =3D tr0_cnt3; + tr_req[tr_idx].dim1 =3D tr_cnt0; + tr_req[tr_idx].dim2 =3D trigger_size; + tr_req[tr_idx].dim3 =3D trigger_size * tr0_cnt2; + + tr_req[tr_idx].daddr =3D dev_addr; + tr_req[tr_idx].dicnt0 =3D tr_cnt0; + tr_req[tr_idx].dicnt1 =3D tr_cnt1; + tr_req[tr_idx].dicnt2 =3D tr0_cnt2; + tr_req[tr_idx].dicnt3 =3D tr0_cnt3; + tr_req[tr_idx].ddim1 =3D (-1) * tr_cnt0; + } + + tr_idx++; + + if (num_tr =3D=3D 2) { + cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE15, + false, true, + CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + cppi5_tr_csf_set(&tr_req[tr_idx].flags, csf); + cppi5_tr_set_trigger(&tr_req[tr_idx].flags, + uc->config.tr_trigger_type, + CPPI5_TR_TRIGGER_TYPE_ICNT2_DEC, + 0, 0); + + sg_addr +=3D trigger_size * tr0_cnt2 * tr0_cnt3; + if (dir =3D=3D DMA_DEV_TO_MEM) { + tr_req[tr_idx].addr =3D dev_addr; + tr_req[tr_idx].icnt0 =3D tr_cnt0; + tr_req[tr_idx].icnt1 =3D tr_cnt1; + tr_req[tr_idx].icnt2 =3D tr1_cnt2; + tr_req[tr_idx].icnt3 =3D 1; + tr_req[tr_idx].dim1 =3D (-1) * tr_cnt0; + + tr_req[tr_idx].daddr =3D sg_addr; + tr_req[tr_idx].dicnt0 =3D tr_cnt0; + tr_req[tr_idx].dicnt1 =3D tr_cnt1; + tr_req[tr_idx].dicnt2 =3D tr1_cnt2; + tr_req[tr_idx].dicnt3 =3D 1; + tr_req[tr_idx].ddim1 =3D tr_cnt0; + tr_req[tr_idx].ddim2 =3D trigger_size; + } else { + tr_req[tr_idx].addr =3D sg_addr; + tr_req[tr_idx].icnt0 =3D tr_cnt0; + tr_req[tr_idx].icnt1 =3D tr_cnt1; + tr_req[tr_idx].icnt2 =3D tr1_cnt2; + tr_req[tr_idx].icnt3 =3D 1; + tr_req[tr_idx].dim1 =3D tr_cnt0; + tr_req[tr_idx].dim2 =3D trigger_size; + + tr_req[tr_idx].daddr =3D dev_addr; + tr_req[tr_idx].dicnt0 =3D tr_cnt0; + tr_req[tr_idx].dicnt1 =3D tr_cnt1; + tr_req[tr_idx].dicnt2 =3D tr1_cnt2; + tr_req[tr_idx].dicnt3 =3D 1; + tr_req[tr_idx].ddim1 =3D (-1) * tr_cnt0; + } + tr_idx++; + } + + d->residue +=3D sg_len; + } + + cppi5_tr_csf_set(&tr_req[tr_idx - 1].flags, csf | CPPI5_TR_CSF_EOP); + + return d; +} + +int udma_configure_statictr(struct udma_chan *uc, struct udma_desc *d, + enum dma_slave_buswidth dev_width, + u16 elcnt) +{ + if (uc->config.ep_type !=3D PSIL_EP_PDMA_XY) + return 0; + + /* Bus width translates to the element size (ES) */ + switch (dev_width) { + case DMA_SLAVE_BUSWIDTH_1_BYTE: + d->static_tr.elsize =3D 0; + break; + case DMA_SLAVE_BUSWIDTH_2_BYTES: + d->static_tr.elsize =3D 1; + break; + case DMA_SLAVE_BUSWIDTH_3_BYTES: + d->static_tr.elsize =3D 2; + break; + case DMA_SLAVE_BUSWIDTH_4_BYTES: + d->static_tr.elsize =3D 3; + break; + case DMA_SLAVE_BUSWIDTH_8_BYTES: + d->static_tr.elsize =3D 4; + break; + default: /* not reached */ + return -EINVAL; + } + + d->static_tr.elcnt =3D elcnt; + + if (uc->config.pkt_mode || !uc->cyclic) { + /* + * PDMA must close the packet when the channel is in packet mode. + * For TR mode when the channel is not cyclic we also need PDMA + * to close the packet otherwise the transfer will stall because + * PDMA holds on the data it has received from the peripheral. + */ + unsigned int div =3D dev_width * elcnt; + + if (uc->cyclic) + d->static_tr.bstcnt =3D d->residue / d->sglen / div; + else + d->static_tr.bstcnt =3D d->residue / div; + } else if (uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA && + uc->config.dir =3D=3D DMA_DEV_TO_MEM && + uc->cyclic) { + /* + * For cyclic mode with BCDMA we have to set EOP in each TR to + * prevent short packet errors seen on channel teardown. So the + * PDMA must close the packet after every TR transfer by setting + * burst count equal to the number of bytes transferred. + */ + struct cppi5_tr_type1_t *tr_req =3D d->hwdesc[0].tr_req_base; + + d->static_tr.bstcnt =3D + (tr_req->icnt0 * tr_req->icnt1) / dev_width; + } else { + d->static_tr.bstcnt =3D 0; + } + + if (uc->config.dir =3D=3D DMA_DEV_TO_MEM && + d->static_tr.bstcnt > uc->ud->match_data->statictr_z_mask) + return -EINVAL; + + return 0; +} + +struct udma_desc * +udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl, + unsigned int sglen, enum dma_transfer_direction dir, + unsigned long tx_flags, void *context) +{ + struct scatterlist *sgent; + struct cppi5_host_desc_t *h_desc =3D NULL; + struct udma_desc *d; + u32 ring_id; + unsigned int i; + u64 asel; + + d =3D kzalloc(struct_size(d, hwdesc, sglen), GFP_NOWAIT); + if (!d) + return NULL; + + d->sglen =3D sglen; + d->hwdesc_count =3D sglen; + + if (dir =3D=3D DMA_DEV_TO_MEM) + ring_id =3D k3_ringacc_get_ring_id(uc->rflow->r_ring); + else + ring_id =3D k3_ringacc_get_ring_id(uc->tchan->tc_ring); + + if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) + asel =3D 0; + else + asel =3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; + + for_each_sg(sgl, sgent, sglen, i) { + struct udma_hwdesc *hwdesc =3D &d->hwdesc[i]; + dma_addr_t sg_addr =3D sg_dma_address(sgent); + struct cppi5_host_desc_t *desc; + size_t sg_len =3D sg_dma_len(sgent); + + hwdesc->cppi5_desc_vaddr =3D dma_pool_zalloc(uc->hdesc_pool, + GFP_NOWAIT, + &hwdesc->cppi5_desc_paddr); + if (!hwdesc->cppi5_desc_vaddr) { + dev_err(uc->ud->dev, + "descriptor%d allocation failed\n", i); + + udma_free_hwdesc(uc, d); + kfree(d); + return NULL; + } + + d->residue +=3D sg_len; + hwdesc->cppi5_desc_size =3D uc->config.hdesc_size; + desc =3D hwdesc->cppi5_desc_vaddr; + + if (i =3D=3D 0) { + cppi5_hdesc_init(desc, 0, 0); + /* Flow and Packed ID */ + cppi5_desc_set_pktids(&desc->hdr, uc->id, + CPPI5_INFO1_DESC_FLOWID_DEFAULT); + cppi5_desc_set_retpolicy(&desc->hdr, 0, ring_id); + } else { + cppi5_hdesc_reset_hbdesc(desc); + cppi5_desc_set_retpolicy(&desc->hdr, 0, 0xffff); + } + + /* attach the sg buffer to the descriptor */ + sg_addr |=3D asel; + cppi5_hdesc_attach_buf(desc, sg_addr, sg_len, sg_addr, sg_len); + + /* Attach link as host buffer descriptor */ + if (h_desc) + cppi5_hdesc_link_hbdesc(h_desc, + hwdesc->cppi5_desc_paddr | asel); + + if (uc->ud->match_data->type =3D=3D DMA_TYPE_PKTDMA || + dir =3D=3D DMA_MEM_TO_DEV) + h_desc =3D desc; + } + + if (d->residue >=3D SZ_4M) { + dev_err(uc->ud->dev, + "%s: Transfer size %u is over the supported 4M range\n", + __func__, d->residue); + udma_free_hwdesc(uc, d); + kfree(d); + return NULL; + } + + h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; + cppi5_hdesc_set_pktlen(h_desc, d->residue); + + return d; +} + +int udma_attach_metadata(struct dma_async_tx_descriptor *desc, + void *data, size_t len) +{ + struct udma_desc *d =3D to_udma_desc(desc); + struct udma_chan *uc =3D to_udma_chan(desc->chan); + struct cppi5_host_desc_t *h_desc; + u32 psd_size =3D len; + u32 flags =3D 0; + + if (!uc->config.pkt_mode || !uc->config.metadata_size) + return -EOPNOTSUPP; + + if (!data || len > uc->config.metadata_size) + return -EINVAL; + + if (uc->config.needs_epib && len < CPPI5_INFO0_HDESC_EPIB_SIZE) + return -EINVAL; + + h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; + if (d->dir =3D=3D DMA_MEM_TO_DEV) + memcpy(h_desc->epib, data, len); + + if (uc->config.needs_epib) + psd_size -=3D CPPI5_INFO0_HDESC_EPIB_SIZE; + + d->metadata =3D data; + d->metadata_size =3D len; + if (uc->config.needs_epib) + flags |=3D CPPI5_INFO0_HDESC_EPIB_PRESENT; + + cppi5_hdesc_update_flags(h_desc, flags); + cppi5_hdesc_update_psdata_size(h_desc, psd_size); + + return 0; +} + +void *udma_get_metadata_ptr(struct dma_async_tx_descriptor *desc, + size_t *payload_len, size_t *max_len) +{ + struct udma_desc *d =3D to_udma_desc(desc); + struct udma_chan *uc =3D to_udma_chan(desc->chan); + struct cppi5_host_desc_t *h_desc; + + if (!uc->config.pkt_mode || !uc->config.metadata_size) + return ERR_PTR(-EOPNOTSUPP); + + h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; + + *max_len =3D uc->config.metadata_size; + + *payload_len =3D cppi5_hdesc_epib_present(&h_desc->hdr) ? + CPPI5_INFO0_HDESC_EPIB_SIZE : 0; + *payload_len +=3D cppi5_hdesc_get_psdata_size(h_desc); + + return h_desc->epib; +} + +int udma_set_metadata_len(struct dma_async_tx_descriptor *desc, + size_t payload_len) +{ + struct udma_desc *d =3D to_udma_desc(desc); + struct udma_chan *uc =3D to_udma_chan(desc->chan); + struct cppi5_host_desc_t *h_desc; + u32 psd_size =3D payload_len; + u32 flags =3D 0; + + if (!uc->config.pkt_mode || !uc->config.metadata_size) + return -EOPNOTSUPP; + + if (payload_len > uc->config.metadata_size) + return -EINVAL; + + if (uc->config.needs_epib && payload_len < CPPI5_INFO0_HDESC_EPIB_SIZE) + return -EINVAL; + + h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; + + if (uc->config.needs_epib) { + psd_size -=3D CPPI5_INFO0_HDESC_EPIB_SIZE; + flags |=3D CPPI5_INFO0_HDESC_EPIB_PRESENT; + } + + cppi5_hdesc_update_flags(h_desc, flags); + cppi5_hdesc_update_psdata_size(h_desc, psd_size); + + return 0; +} + +struct dma_async_tx_descriptor * +udma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, + unsigned int sglen, enum dma_transfer_direction dir, + unsigned long tx_flags, void *context) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + enum dma_slave_buswidth dev_width; + struct udma_desc *d; + u32 burst; + + if (dir !=3D uc->config.dir && + (uc->config.dir =3D=3D DMA_MEM_TO_MEM && !uc->config.tr_trigger_type)= ) { + dev_err(chan->device->dev, + "%s: chan%d is for %s, not supporting %s\n", + __func__, uc->id, + dmaengine_get_direction_text(uc->config.dir), + dmaengine_get_direction_text(dir)); + return NULL; + } + + if (dir =3D=3D DMA_DEV_TO_MEM) { + dev_width =3D uc->cfg.src_addr_width; + burst =3D uc->cfg.src_maxburst; + } else if (dir =3D=3D DMA_MEM_TO_DEV) { + dev_width =3D uc->cfg.dst_addr_width; + burst =3D uc->cfg.dst_maxburst; + } else { + dev_err(chan->device->dev, "%s: bad direction?\n", __func__); + return NULL; + } + + if (!burst) + burst =3D 1; + + uc->config.tx_flags =3D tx_flags; + + if (uc->config.pkt_mode) + d =3D udma_prep_slave_sg_pkt(uc, sgl, sglen, dir, tx_flags, + context); + else if (is_slave_direction(uc->config.dir)) + d =3D udma_prep_slave_sg_tr(uc, sgl, sglen, dir, tx_flags, + context); + else + d =3D udma_prep_slave_sg_triggered_tr(uc, sgl, sglen, dir, + tx_flags, context); + + if (!d) + return NULL; + + d->dir =3D dir; + d->desc_idx =3D 0; + d->tr_idx =3D 0; + + /* static TR for remote PDMA */ + if (udma_configure_statictr(uc, d, dev_width, burst)) { + dev_err(uc->ud->dev, + "%s: StaticTR Z is limited to maximum %u (%u)\n", + __func__, uc->ud->match_data->statictr_z_mask, + d->static_tr.bstcnt); + + udma_free_hwdesc(uc, d); + kfree(d); + return NULL; + } + + if (uc->config.metadata_size) + d->vd.tx.metadata_ops =3D &metadata_ops; + + return vchan_tx_prep(&uc->vc, &d->vd, tx_flags); +} +EXPORT_SYMBOL_GPL(udma_prep_slave_sg); + +struct udma_desc * +udma_prep_dma_cyclic_tr(struct udma_chan *uc, dma_addr_t buf_addr, + size_t buf_len, size_t period_len, + enum dma_transfer_direction dir, unsigned long flags) +{ + struct udma_desc *d; + size_t tr_size, period_addr; + struct cppi5_tr_type1_t *tr_req; + unsigned int periods =3D buf_len / period_len; + u16 tr0_cnt0, tr0_cnt1, tr1_cnt0; + unsigned int i; + int num_tr; + u32 period_csf =3D 0; + + num_tr =3D udma_get_tr_counters(period_len, __ffs(buf_addr), &tr0_cnt0, + &tr0_cnt1, &tr1_cnt0); + if (num_tr < 0) { + dev_err(uc->ud->dev, "size %zu is not supported\n", + period_len); + return NULL; + } + + /* Now allocate and setup the descriptor. */ + tr_size =3D sizeof(struct cppi5_tr_type1_t); + d =3D udma_alloc_tr_desc(uc, tr_size, periods * num_tr, dir); + if (!d) + return NULL; + + tr_req =3D d->hwdesc[0].tr_req_base; + if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) + period_addr =3D buf_addr; + else + period_addr =3D buf_addr | + ((u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT); + + /* + * For BCDMA <-> PDMA transfers, the EOP flag needs to be set on the + * last TR of a descriptor, to mark the packet as complete. + * This is required for getting the teardown completion message in case + * of TX, and to avoid short-packet error in case of RX. + * + * As we are in cyclic mode, we do not know which period might be the + * last one, so set the flag for each period. + */ + if (uc->config.ep_type =3D=3D PSIL_EP_PDMA_XY && + uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { + period_csf =3D CPPI5_TR_CSF_EOP; + } + + for (i =3D 0; i < periods; i++) { + int tr_idx =3D i * num_tr; + + cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, false, + false, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + + tr_req[tr_idx].addr =3D period_addr; + tr_req[tr_idx].icnt0 =3D tr0_cnt0; + tr_req[tr_idx].icnt1 =3D tr0_cnt1; + tr_req[tr_idx].dim1 =3D tr0_cnt0; + + if (num_tr =3D=3D 2) { + cppi5_tr_csf_set(&tr_req[tr_idx].flags, + CPPI5_TR_CSF_SUPR_EVT); + tr_idx++; + + cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, + false, false, + CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + + tr_req[tr_idx].addr =3D period_addr + tr0_cnt1 * tr0_cnt0; + tr_req[tr_idx].icnt0 =3D tr1_cnt0; + tr_req[tr_idx].icnt1 =3D 1; + tr_req[tr_idx].dim1 =3D tr1_cnt0; + } + + if (!(flags & DMA_PREP_INTERRUPT)) + period_csf |=3D CPPI5_TR_CSF_SUPR_EVT; + + if (period_csf) + cppi5_tr_csf_set(&tr_req[tr_idx].flags, period_csf); + + period_addr +=3D period_len; + } + + return d; +} + +struct udma_desc * +udma_prep_dma_cyclic_pkt(struct udma_chan *uc, dma_addr_t buf_addr, + size_t buf_len, size_t period_len, + enum dma_transfer_direction dir, unsigned long flags) +{ + struct udma_desc *d; + u32 ring_id; + int i; + int periods =3D buf_len / period_len; + + if (periods > (K3_UDMA_DEFAULT_RING_SIZE - 1)) + return NULL; + + if (period_len >=3D SZ_4M) + return NULL; + + d =3D kzalloc(struct_size(d, hwdesc, periods), GFP_NOWAIT); + if (!d) + return NULL; + + d->hwdesc_count =3D periods; + + /* TODO: re-check this... */ + if (dir =3D=3D DMA_DEV_TO_MEM) + ring_id =3D k3_ringacc_get_ring_id(uc->rflow->r_ring); + else + ring_id =3D k3_ringacc_get_ring_id(uc->tchan->tc_ring); + + if (uc->ud->match_data->type !=3D DMA_TYPE_UDMA) + buf_addr |=3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; + + for (i =3D 0; i < periods; i++) { + struct udma_hwdesc *hwdesc =3D &d->hwdesc[i]; + dma_addr_t period_addr =3D buf_addr + (period_len * i); + struct cppi5_host_desc_t *h_desc; + + hwdesc->cppi5_desc_vaddr =3D dma_pool_zalloc(uc->hdesc_pool, + GFP_NOWAIT, + &hwdesc->cppi5_desc_paddr); + if (!hwdesc->cppi5_desc_vaddr) { + dev_err(uc->ud->dev, + "descriptor%d allocation failed\n", i); + + udma_free_hwdesc(uc, d); + kfree(d); + return NULL; + } + + hwdesc->cppi5_desc_size =3D uc->config.hdesc_size; + h_desc =3D hwdesc->cppi5_desc_vaddr; + + cppi5_hdesc_init(h_desc, 0, 0); + cppi5_hdesc_set_pktlen(h_desc, period_len); + + /* Flow and Packed ID */ + cppi5_desc_set_pktids(&h_desc->hdr, uc->id, + CPPI5_INFO1_DESC_FLOWID_DEFAULT); + cppi5_desc_set_retpolicy(&h_desc->hdr, 0, ring_id); + + /* attach each period to a new descriptor */ + cppi5_hdesc_attach_buf(h_desc, + period_addr, period_len, + period_addr, period_len); + } + + return d; +} + +struct dma_async_tx_descriptor * +udma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t bu= f_len, + size_t period_len, enum dma_transfer_direction dir, + unsigned long flags) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + enum dma_slave_buswidth dev_width; + struct udma_desc *d; + u32 burst; + + if (dir !=3D uc->config.dir) { + dev_err(chan->device->dev, + "%s: chan%d is for %s, not supporting %s\n", + __func__, uc->id, + dmaengine_get_direction_text(uc->config.dir), + dmaengine_get_direction_text(dir)); + return NULL; + } + + uc->cyclic =3D true; + + if (dir =3D=3D DMA_DEV_TO_MEM) { + dev_width =3D uc->cfg.src_addr_width; + burst =3D uc->cfg.src_maxburst; + } else if (dir =3D=3D DMA_MEM_TO_DEV) { + dev_width =3D uc->cfg.dst_addr_width; + burst =3D uc->cfg.dst_maxburst; + } else { + dev_err(uc->ud->dev, "%s: bad direction?\n", __func__); + return NULL; + } + + if (!burst) + burst =3D 1; + + if (uc->config.pkt_mode) + d =3D udma_prep_dma_cyclic_pkt(uc, buf_addr, buf_len, period_len, + dir, flags); + else + d =3D udma_prep_dma_cyclic_tr(uc, buf_addr, buf_len, period_len, + dir, flags); + + if (!d) + return NULL; + + d->sglen =3D buf_len / period_len; + + d->dir =3D dir; + d->residue =3D buf_len; + + /* static TR for remote PDMA */ + if (udma_configure_statictr(uc, d, dev_width, burst)) { + dev_err(uc->ud->dev, + "%s: StaticTR Z is limited to maximum %u (%u)\n", + __func__, uc->ud->match_data->statictr_z_mask, + d->static_tr.bstcnt); + + udma_free_hwdesc(uc, d); + kfree(d); + return NULL; + } + + if (uc->config.metadata_size) + d->vd.tx.metadata_ops =3D &metadata_ops; + + return vchan_tx_prep(&uc->vc, &d->vd, flags); +} +EXPORT_SYMBOL_GPL(udma_prep_dma_cyclic); + +struct dma_async_tx_descriptor * +udma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t sr= c, + size_t len, unsigned long tx_flags) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + struct udma_desc *d; + struct cppi5_tr_type15_t *tr_req; + int num_tr; + size_t tr_size =3D sizeof(struct cppi5_tr_type15_t); + u16 tr0_cnt0, tr0_cnt1, tr1_cnt0; + u32 csf =3D CPPI5_TR_CSF_SUPR_EVT; + + if (uc->config.dir !=3D DMA_MEM_TO_MEM) { + dev_err(chan->device->dev, + "%s: chan%d is for %s, not supporting %s\n", + __func__, uc->id, + dmaengine_get_direction_text(uc->config.dir), + dmaengine_get_direction_text(DMA_MEM_TO_MEM)); + return NULL; + } + + num_tr =3D udma_get_tr_counters(len, __ffs(src | dest), &tr0_cnt0, + &tr0_cnt1, &tr1_cnt0); + if (num_tr < 0) { + dev_err(uc->ud->dev, "size %zu is not supported\n", + len); + return NULL; + } + + d =3D udma_alloc_tr_desc(uc, tr_size, num_tr, DMA_MEM_TO_MEM); + if (!d) + return NULL; + + d->dir =3D DMA_MEM_TO_MEM; + d->desc_idx =3D 0; + d->tr_idx =3D 0; + d->residue =3D len; + + if (uc->ud->match_data->type !=3D DMA_TYPE_UDMA) { + src |=3D (u64)uc->ud->asel << K3_ADDRESS_ASEL_SHIFT; + dest |=3D (u64)uc->ud->asel << K3_ADDRESS_ASEL_SHIFT; + } else { + csf |=3D CPPI5_TR_CSF_EOL_ICNT0; + } + + tr_req =3D d->hwdesc[0].tr_req_base; + + cppi5_tr_init(&tr_req[0].flags, CPPI5_TR_TYPE15, false, true, + CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + cppi5_tr_csf_set(&tr_req[0].flags, csf); + + tr_req[0].addr =3D src; + tr_req[0].icnt0 =3D tr0_cnt0; + tr_req[0].icnt1 =3D tr0_cnt1; + tr_req[0].icnt2 =3D 1; + tr_req[0].icnt3 =3D 1; + tr_req[0].dim1 =3D tr0_cnt0; + + tr_req[0].daddr =3D dest; + tr_req[0].dicnt0 =3D tr0_cnt0; + tr_req[0].dicnt1 =3D tr0_cnt1; + tr_req[0].dicnt2 =3D 1; + tr_req[0].dicnt3 =3D 1; + tr_req[0].ddim1 =3D tr0_cnt0; + + if (num_tr =3D=3D 2) { + cppi5_tr_init(&tr_req[1].flags, CPPI5_TR_TYPE15, false, true, + CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + cppi5_tr_csf_set(&tr_req[1].flags, csf); + + tr_req[1].addr =3D src + tr0_cnt1 * tr0_cnt0; + tr_req[1].icnt0 =3D tr1_cnt0; + tr_req[1].icnt1 =3D 1; + tr_req[1].icnt2 =3D 1; + tr_req[1].icnt3 =3D 1; + + tr_req[1].daddr =3D dest + tr0_cnt1 * tr0_cnt0; + tr_req[1].dicnt0 =3D tr1_cnt0; + tr_req[1].dicnt1 =3D 1; + tr_req[1].dicnt2 =3D 1; + tr_req[1].dicnt3 =3D 1; + } + + cppi5_tr_csf_set(&tr_req[num_tr - 1].flags, csf | CPPI5_TR_CSF_EOP); + + if (uc->config.metadata_size) + d->vd.tx.metadata_ops =3D &metadata_ops; + + return vchan_tx_prep(&uc->vc, &d->vd, tx_flags); +} +EXPORT_SYMBOL_GPL(udma_prep_dma_memcpy); + +void udma_desc_pre_callback(struct virt_dma_chan *vc, + struct virt_dma_desc *vd, + struct dmaengine_result *result) +{ + struct udma_chan *uc =3D to_udma_chan(&vc->chan); + struct udma_desc *d; + u8 status; + + if (!vd) + return; + + d =3D to_udma_desc(&vd->tx); + + if (d->metadata_size) + udma_fetch_epib(uc, d); + + if (result) { + void *desc_vaddr =3D udma_curr_cppi5_desc_vaddr(d, d->desc_idx); + + if (cppi5_desc_get_type(desc_vaddr) =3D=3D + CPPI5_INFO0_DESC_TYPE_VAL_HOST) { + /* Provide residue information for the client */ + result->residue =3D d->residue - + cppi5_hdesc_get_pktlen(desc_vaddr); + if (result->residue) + result->result =3D DMA_TRANS_ABORTED; + else + result->result =3D DMA_TRANS_NOERROR; + } else { + result->residue =3D 0; + /* Propagate TR Response errors to the client */ + status =3D d->hwdesc[0].tr_resp_base->status; + if (status) + result->result =3D DMA_TRANS_ABORTED; + else + result->result =3D DMA_TRANS_NOERROR; + } + } +} +EXPORT_SYMBOL_GPL(udma_desc_pre_callback); + +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 0eaa06b7ae988..ae8b8ebd5dddd 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -131,105 +131,6 @@ static void udma_dump_chan_stdata(struct udma_chan *u= c) } } =20 -static struct udma_desc *udma_udma_desc_from_paddr(struct udma_chan *uc, - dma_addr_t paddr) -{ - struct udma_desc *d =3D uc->terminated_desc; - - if (d) { - dma_addr_t desc_paddr =3D udma_curr_cppi5_desc_paddr(d, - d->desc_idx); - - if (desc_paddr !=3D paddr) - d =3D NULL; - } - - if (!d) { - d =3D uc->desc; - if (d) { - dma_addr_t desc_paddr =3D udma_curr_cppi5_desc_paddr(d, - d->desc_idx); - - if (desc_paddr !=3D paddr) - d =3D NULL; - } - } - - return d; -} - -static void udma_free_hwdesc(struct udma_chan *uc, struct udma_desc *d) -{ - if (uc->use_dma_pool) { - int i; - - for (i =3D 0; i < d->hwdesc_count; i++) { - if (!d->hwdesc[i].cppi5_desc_vaddr) - continue; - - dma_pool_free(uc->hdesc_pool, - d->hwdesc[i].cppi5_desc_vaddr, - d->hwdesc[i].cppi5_desc_paddr); - - d->hwdesc[i].cppi5_desc_vaddr =3D NULL; - } - } else if (d->hwdesc[0].cppi5_desc_vaddr) { - dma_free_coherent(uc->dma_dev, d->hwdesc[0].cppi5_desc_size, - d->hwdesc[0].cppi5_desc_vaddr, - d->hwdesc[0].cppi5_desc_paddr); - - d->hwdesc[0].cppi5_desc_vaddr =3D NULL; - } -} - -static void udma_purge_desc_work(struct work_struct *work) -{ - struct udma_dev *ud =3D container_of(work, typeof(*ud), purge_work); - struct virt_dma_desc *vd, *_vd; - unsigned long flags; - LIST_HEAD(head); - - spin_lock_irqsave(&ud->lock, flags); - list_splice_tail_init(&ud->desc_to_purge, &head); - spin_unlock_irqrestore(&ud->lock, flags); - - list_for_each_entry_safe(vd, _vd, &head, node) { - struct udma_chan *uc =3D to_udma_chan(vd->tx.chan); - struct udma_desc *d =3D to_udma_desc(&vd->tx); - - udma_free_hwdesc(uc, d); - list_del(&vd->node); - kfree(d); - } - - /* If more to purge, schedule the work again */ - if (!list_empty(&ud->desc_to_purge)) - schedule_work(&ud->purge_work); -} - -static void udma_desc_free(struct virt_dma_desc *vd) -{ - struct udma_dev *ud =3D to_udma_dev(vd->tx.chan->device); - struct udma_chan *uc =3D to_udma_chan(vd->tx.chan); - struct udma_desc *d =3D to_udma_desc(&vd->tx); - unsigned long flags; - - if (uc->terminated_desc =3D=3D d) - uc->terminated_desc =3D NULL; - - if (uc->use_dma_pool) { - udma_free_hwdesc(uc, d); - kfree(d); - return; - } - - spin_lock_irqsave(&ud->lock, flags); - list_add_tail(&vd->node, &ud->desc_to_purge); - spin_unlock_irqrestore(&ud->lock, flags); - - schedule_work(&ud->purge_work); -} - static bool udma_is_chan_running(struct udma_chan *uc) { u32 trt_ctl =3D 0; @@ -303,17 +204,6 @@ static int udma_push_to_ring(struct udma_chan *uc, int= idx) return k3_ringacc_ring_push(ring, &paddr); } =20 -static bool udma_desc_is_rx_flush(struct udma_chan *uc, dma_addr_t addr) -{ - if (uc->config.dir !=3D DMA_DEV_TO_MEM) - return false; - - if (addr =3D=3D udma_get_rx_flush_hwdesc_paddr(uc)) - return true; - - return false; -} - static int udma_pop_from_ring(struct udma_chan *uc, dma_addr_t *addr) { struct k3_ring *ring =3D NULL; @@ -674,33 +564,6 @@ static void udma_cyclic_packet_elapsed(struct udma_cha= n *uc) d->desc_idx =3D (d->desc_idx + 1) % d->sglen; } =20 -static bool udma_is_desc_really_done(struct udma_chan *uc, struct udma_des= c *d) -{ - u32 peer_bcnt, bcnt; - - /* - * Only TX towards PDMA is affected. - * If DMA_PREP_INTERRUPT is not set by consumer then skip the transfer - * completion calculation, consumer must ensure that there is no stale - * data in DMA fabric in this case. - */ - if (uc->config.ep_type =3D=3D PSIL_EP_NATIVE || - uc->config.dir !=3D DMA_MEM_TO_DEV || !(uc->config.tx_flags & DMA_PRE= P_INTERRUPT)) - return true; - - peer_bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_PEER_BCNT_REG); - bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); - - /* Transfer is incomplete, store current residue and time stamp */ - if (peer_bcnt < bcnt) { - uc->tx_drain.residue =3D bcnt - peer_bcnt; - uc->tx_drain.tstamp =3D ktime_get(); - return false; - } - - return true; -} - static void udma_check_tx_completion(struct work_struct *work) { struct udma_chan *uc =3D container_of(work, typeof(*uc), @@ -2344,1047 +2207,6 @@ static int udma_slave_config(struct dma_chan *chan, return 0; } =20 -static struct udma_desc *udma_alloc_tr_desc(struct udma_chan *uc, - size_t tr_size, int tr_count, - enum dma_transfer_direction dir) -{ - struct udma_hwdesc *hwdesc; - struct cppi5_desc_hdr_t *tr_desc; - struct udma_desc *d; - u32 reload_count =3D 0; - u32 ring_id; - - switch (tr_size) { - case 16: - case 32: - case 64: - case 128: - break; - default: - dev_err(uc->ud->dev, "Unsupported TR size of %zu\n", tr_size); - return NULL; - } - - /* We have only one descriptor containing multiple TRs */ - d =3D kzalloc(sizeof(*d) + sizeof(d->hwdesc[0]), GFP_NOWAIT); - if (!d) - return NULL; - - d->sglen =3D tr_count; - - d->hwdesc_count =3D 1; - hwdesc =3D &d->hwdesc[0]; - - /* Allocate memory for DMA ring descriptor */ - if (uc->use_dma_pool) { - hwdesc->cppi5_desc_size =3D uc->config.hdesc_size; - hwdesc->cppi5_desc_vaddr =3D dma_pool_zalloc(uc->hdesc_pool, - GFP_NOWAIT, - &hwdesc->cppi5_desc_paddr); - } else { - hwdesc->cppi5_desc_size =3D cppi5_trdesc_calc_size(tr_size, - tr_count); - hwdesc->cppi5_desc_size =3D ALIGN(hwdesc->cppi5_desc_size, - uc->ud->desc_align); - hwdesc->cppi5_desc_vaddr =3D dma_alloc_coherent(uc->ud->dev, - hwdesc->cppi5_desc_size, - &hwdesc->cppi5_desc_paddr, - GFP_NOWAIT); - } - - if (!hwdesc->cppi5_desc_vaddr) { - kfree(d); - return NULL; - } - - /* Start of the TR req records */ - hwdesc->tr_req_base =3D hwdesc->cppi5_desc_vaddr + tr_size; - /* Start address of the TR response array */ - hwdesc->tr_resp_base =3D hwdesc->tr_req_base + tr_size * tr_count; - - tr_desc =3D hwdesc->cppi5_desc_vaddr; - - if (uc->cyclic) - reload_count =3D CPPI5_INFO0_TRDESC_RLDCNT_INFINITE; - - if (dir =3D=3D DMA_DEV_TO_MEM) - ring_id =3D k3_ringacc_get_ring_id(uc->rflow->r_ring); - else - ring_id =3D k3_ringacc_get_ring_id(uc->tchan->tc_ring); - - cppi5_trdesc_init(tr_desc, tr_count, tr_size, 0, reload_count); - cppi5_desc_set_pktids(tr_desc, uc->id, - CPPI5_INFO1_DESC_FLOWID_DEFAULT); - cppi5_desc_set_retpolicy(tr_desc, 0, ring_id); - - return d; -} - -/** - * udma_get_tr_counters - calculate TR counters for a given length - * @len: Length of the trasnfer - * @align_to: Preferred alignment - * @tr0_cnt0: First TR icnt0 - * @tr0_cnt1: First TR icnt1 - * @tr1_cnt0: Second (if used) TR icnt0 - * - * For len < SZ_64K only one TR is enough, tr1_cnt0 is not updated - * For len >=3D SZ_64K two TRs are used in a simple way: - * First TR: SZ_64K-alignment blocks (tr0_cnt0, tr0_cnt1) - * Second TR: the remaining length (tr1_cnt0) - * - * Returns the number of TRs the length needs (1 or 2) - * -EINVAL if the length can not be supported - */ -static int udma_get_tr_counters(size_t len, unsigned long align_to, - u16 *tr0_cnt0, u16 *tr0_cnt1, u16 *tr1_cnt0) -{ - if (len < SZ_64K) { - *tr0_cnt0 =3D len; - *tr0_cnt1 =3D 1; - - return 1; - } - - if (align_to > 3) - align_to =3D 3; - -realign: - *tr0_cnt0 =3D SZ_64K - BIT(align_to); - if (len / *tr0_cnt0 >=3D SZ_64K) { - if (align_to) { - align_to--; - goto realign; - } - return -EINVAL; - } - - *tr0_cnt1 =3D len / *tr0_cnt0; - *tr1_cnt0 =3D len % *tr0_cnt0; - - return 2; -} - -static struct udma_desc * -udma_prep_slave_sg_tr(struct udma_chan *uc, struct scatterlist *sgl, - unsigned int sglen, enum dma_transfer_direction dir, - unsigned long tx_flags, void *context) -{ - struct scatterlist *sgent; - struct udma_desc *d; - struct cppi5_tr_type1_t *tr_req =3D NULL; - u16 tr0_cnt0, tr0_cnt1, tr1_cnt0; - unsigned int i; - size_t tr_size; - int num_tr =3D 0; - int tr_idx =3D 0; - u64 asel; - - /* estimate the number of TRs we will need */ - for_each_sg(sgl, sgent, sglen, i) { - if (sg_dma_len(sgent) < SZ_64K) - num_tr++; - else - num_tr +=3D 2; - } - - /* Now allocate and setup the descriptor. */ - tr_size =3D sizeof(struct cppi5_tr_type1_t); - d =3D udma_alloc_tr_desc(uc, tr_size, num_tr, dir); - if (!d) - return NULL; - - d->sglen =3D sglen; - - if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) - asel =3D 0; - else - asel =3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; - - tr_req =3D d->hwdesc[0].tr_req_base; - for_each_sg(sgl, sgent, sglen, i) { - dma_addr_t sg_addr =3D sg_dma_address(sgent); - - num_tr =3D udma_get_tr_counters(sg_dma_len(sgent), __ffs(sg_addr), - &tr0_cnt0, &tr0_cnt1, &tr1_cnt0); - if (num_tr < 0) { - dev_err(uc->ud->dev, "size %u is not supported\n", - sg_dma_len(sgent)); - udma_free_hwdesc(uc, d); - kfree(d); - return NULL; - } - - cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, false, - false, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req[tr_idx].flags, CPPI5_TR_CSF_SUPR_EVT); - - sg_addr |=3D asel; - tr_req[tr_idx].addr =3D sg_addr; - tr_req[tr_idx].icnt0 =3D tr0_cnt0; - tr_req[tr_idx].icnt1 =3D tr0_cnt1; - tr_req[tr_idx].dim1 =3D tr0_cnt0; - tr_idx++; - - if (num_tr =3D=3D 2) { - cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, - false, false, - CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req[tr_idx].flags, - CPPI5_TR_CSF_SUPR_EVT); - - tr_req[tr_idx].addr =3D sg_addr + tr0_cnt1 * tr0_cnt0; - tr_req[tr_idx].icnt0 =3D tr1_cnt0; - tr_req[tr_idx].icnt1 =3D 1; - tr_req[tr_idx].dim1 =3D tr1_cnt0; - tr_idx++; - } - - d->residue +=3D sg_dma_len(sgent); - } - - cppi5_tr_csf_set(&tr_req[tr_idx - 1].flags, - CPPI5_TR_CSF_SUPR_EVT | CPPI5_TR_CSF_EOP); - - return d; -} - -static struct udma_desc * -udma_prep_slave_sg_triggered_tr(struct udma_chan *uc, struct scatterlist *= sgl, - unsigned int sglen, - enum dma_transfer_direction dir, - unsigned long tx_flags, void *context) -{ - struct scatterlist *sgent; - struct cppi5_tr_type15_t *tr_req =3D NULL; - enum dma_slave_buswidth dev_width; - u32 csf =3D CPPI5_TR_CSF_SUPR_EVT; - u16 tr_cnt0, tr_cnt1; - dma_addr_t dev_addr; - struct udma_desc *d; - unsigned int i; - size_t tr_size, sg_len; - int num_tr =3D 0; - int tr_idx =3D 0; - u32 burst, trigger_size, port_window; - u64 asel; - - if (dir =3D=3D DMA_DEV_TO_MEM) { - dev_addr =3D uc->cfg.src_addr; - dev_width =3D uc->cfg.src_addr_width; - burst =3D uc->cfg.src_maxburst; - port_window =3D uc->cfg.src_port_window_size; - } else if (dir =3D=3D DMA_MEM_TO_DEV) { - dev_addr =3D uc->cfg.dst_addr; - dev_width =3D uc->cfg.dst_addr_width; - burst =3D uc->cfg.dst_maxburst; - port_window =3D uc->cfg.dst_port_window_size; - } else { - dev_err(uc->ud->dev, "%s: bad direction?\n", __func__); - return NULL; - } - - if (!burst) - burst =3D 1; - - if (port_window) { - if (port_window !=3D burst) { - dev_err(uc->ud->dev, - "The burst must be equal to port_window\n"); - return NULL; - } - - tr_cnt0 =3D dev_width * port_window; - tr_cnt1 =3D 1; - } else { - tr_cnt0 =3D dev_width; - tr_cnt1 =3D burst; - } - trigger_size =3D tr_cnt0 * tr_cnt1; - - /* estimate the number of TRs we will need */ - for_each_sg(sgl, sgent, sglen, i) { - sg_len =3D sg_dma_len(sgent); - - if (sg_len % trigger_size) { - dev_err(uc->ud->dev, - "Not aligned SG entry (%zu for %u)\n", sg_len, - trigger_size); - return NULL; - } - - if (sg_len / trigger_size < SZ_64K) - num_tr++; - else - num_tr +=3D 2; - } - - /* Now allocate and setup the descriptor. */ - tr_size =3D sizeof(struct cppi5_tr_type15_t); - d =3D udma_alloc_tr_desc(uc, tr_size, num_tr, dir); - if (!d) - return NULL; - - d->sglen =3D sglen; - - if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) { - asel =3D 0; - csf |=3D CPPI5_TR_CSF_EOL_ICNT0; - } else { - asel =3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; - dev_addr |=3D asel; - } - - tr_req =3D d->hwdesc[0].tr_req_base; - for_each_sg(sgl, sgent, sglen, i) { - u16 tr0_cnt2, tr0_cnt3, tr1_cnt2; - dma_addr_t sg_addr =3D sg_dma_address(sgent); - - sg_len =3D sg_dma_len(sgent); - num_tr =3D udma_get_tr_counters(sg_len / trigger_size, 0, - &tr0_cnt2, &tr0_cnt3, &tr1_cnt2); - if (num_tr < 0) { - dev_err(uc->ud->dev, "size %zu is not supported\n", - sg_len); - udma_free_hwdesc(uc, d); - kfree(d); - return NULL; - } - - cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE15, false, - true, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req[tr_idx].flags, csf); - cppi5_tr_set_trigger(&tr_req[tr_idx].flags, - uc->config.tr_trigger_type, - CPPI5_TR_TRIGGER_TYPE_ICNT2_DEC, 0, 0); - - sg_addr |=3D asel; - if (dir =3D=3D DMA_DEV_TO_MEM) { - tr_req[tr_idx].addr =3D dev_addr; - tr_req[tr_idx].icnt0 =3D tr_cnt0; - tr_req[tr_idx].icnt1 =3D tr_cnt1; - tr_req[tr_idx].icnt2 =3D tr0_cnt2; - tr_req[tr_idx].icnt3 =3D tr0_cnt3; - tr_req[tr_idx].dim1 =3D (-1) * tr_cnt0; - - tr_req[tr_idx].daddr =3D sg_addr; - tr_req[tr_idx].dicnt0 =3D tr_cnt0; - tr_req[tr_idx].dicnt1 =3D tr_cnt1; - tr_req[tr_idx].dicnt2 =3D tr0_cnt2; - tr_req[tr_idx].dicnt3 =3D tr0_cnt3; - tr_req[tr_idx].ddim1 =3D tr_cnt0; - tr_req[tr_idx].ddim2 =3D trigger_size; - tr_req[tr_idx].ddim3 =3D trigger_size * tr0_cnt2; - } else { - tr_req[tr_idx].addr =3D sg_addr; - tr_req[tr_idx].icnt0 =3D tr_cnt0; - tr_req[tr_idx].icnt1 =3D tr_cnt1; - tr_req[tr_idx].icnt2 =3D tr0_cnt2; - tr_req[tr_idx].icnt3 =3D tr0_cnt3; - tr_req[tr_idx].dim1 =3D tr_cnt0; - tr_req[tr_idx].dim2 =3D trigger_size; - tr_req[tr_idx].dim3 =3D trigger_size * tr0_cnt2; - - tr_req[tr_idx].daddr =3D dev_addr; - tr_req[tr_idx].dicnt0 =3D tr_cnt0; - tr_req[tr_idx].dicnt1 =3D tr_cnt1; - tr_req[tr_idx].dicnt2 =3D tr0_cnt2; - tr_req[tr_idx].dicnt3 =3D tr0_cnt3; - tr_req[tr_idx].ddim1 =3D (-1) * tr_cnt0; - } - - tr_idx++; - - if (num_tr =3D=3D 2) { - cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE15, - false, true, - CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req[tr_idx].flags, csf); - cppi5_tr_set_trigger(&tr_req[tr_idx].flags, - uc->config.tr_trigger_type, - CPPI5_TR_TRIGGER_TYPE_ICNT2_DEC, - 0, 0); - - sg_addr +=3D trigger_size * tr0_cnt2 * tr0_cnt3; - if (dir =3D=3D DMA_DEV_TO_MEM) { - tr_req[tr_idx].addr =3D dev_addr; - tr_req[tr_idx].icnt0 =3D tr_cnt0; - tr_req[tr_idx].icnt1 =3D tr_cnt1; - tr_req[tr_idx].icnt2 =3D tr1_cnt2; - tr_req[tr_idx].icnt3 =3D 1; - tr_req[tr_idx].dim1 =3D (-1) * tr_cnt0; - - tr_req[tr_idx].daddr =3D sg_addr; - tr_req[tr_idx].dicnt0 =3D tr_cnt0; - tr_req[tr_idx].dicnt1 =3D tr_cnt1; - tr_req[tr_idx].dicnt2 =3D tr1_cnt2; - tr_req[tr_idx].dicnt3 =3D 1; - tr_req[tr_idx].ddim1 =3D tr_cnt0; - tr_req[tr_idx].ddim2 =3D trigger_size; - } else { - tr_req[tr_idx].addr =3D sg_addr; - tr_req[tr_idx].icnt0 =3D tr_cnt0; - tr_req[tr_idx].icnt1 =3D tr_cnt1; - tr_req[tr_idx].icnt2 =3D tr1_cnt2; - tr_req[tr_idx].icnt3 =3D 1; - tr_req[tr_idx].dim1 =3D tr_cnt0; - tr_req[tr_idx].dim2 =3D trigger_size; - - tr_req[tr_idx].daddr =3D dev_addr; - tr_req[tr_idx].dicnt0 =3D tr_cnt0; - tr_req[tr_idx].dicnt1 =3D tr_cnt1; - tr_req[tr_idx].dicnt2 =3D tr1_cnt2; - tr_req[tr_idx].dicnt3 =3D 1; - tr_req[tr_idx].ddim1 =3D (-1) * tr_cnt0; - } - tr_idx++; - } - - d->residue +=3D sg_len; - } - - cppi5_tr_csf_set(&tr_req[tr_idx - 1].flags, csf | CPPI5_TR_CSF_EOP); - - return d; -} - -static int udma_configure_statictr(struct udma_chan *uc, struct udma_desc = *d, - enum dma_slave_buswidth dev_width, - u16 elcnt) -{ - if (uc->config.ep_type !=3D PSIL_EP_PDMA_XY) - return 0; - - /* Bus width translates to the element size (ES) */ - switch (dev_width) { - case DMA_SLAVE_BUSWIDTH_1_BYTE: - d->static_tr.elsize =3D 0; - break; - case DMA_SLAVE_BUSWIDTH_2_BYTES: - d->static_tr.elsize =3D 1; - break; - case DMA_SLAVE_BUSWIDTH_3_BYTES: - d->static_tr.elsize =3D 2; - break; - case DMA_SLAVE_BUSWIDTH_4_BYTES: - d->static_tr.elsize =3D 3; - break; - case DMA_SLAVE_BUSWIDTH_8_BYTES: - d->static_tr.elsize =3D 4; - break; - default: /* not reached */ - return -EINVAL; - } - - d->static_tr.elcnt =3D elcnt; - - if (uc->config.pkt_mode || !uc->cyclic) { - /* - * PDMA must close the packet when the channel is in packet mode. - * For TR mode when the channel is not cyclic we also need PDMA - * to close the packet otherwise the transfer will stall because - * PDMA holds on the data it has received from the peripheral. - */ - unsigned int div =3D dev_width * elcnt; - - if (uc->cyclic) - d->static_tr.bstcnt =3D d->residue / d->sglen / div; - else - d->static_tr.bstcnt =3D d->residue / div; - } else if (uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA && - uc->config.dir =3D=3D DMA_DEV_TO_MEM && - uc->cyclic) { - /* - * For cyclic mode with BCDMA we have to set EOP in each TR to - * prevent short packet errors seen on channel teardown. So the - * PDMA must close the packet after every TR transfer by setting - * burst count equal to the number of bytes transferred. - */ - struct cppi5_tr_type1_t *tr_req =3D d->hwdesc[0].tr_req_base; - - d->static_tr.bstcnt =3D - (tr_req->icnt0 * tr_req->icnt1) / dev_width; - } else { - d->static_tr.bstcnt =3D 0; - } - - if (uc->config.dir =3D=3D DMA_DEV_TO_MEM && - d->static_tr.bstcnt > uc->ud->match_data->statictr_z_mask) - return -EINVAL; - - return 0; -} - -static struct udma_desc * -udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl, - unsigned int sglen, enum dma_transfer_direction dir, - unsigned long tx_flags, void *context) -{ - struct scatterlist *sgent; - struct cppi5_host_desc_t *h_desc =3D NULL; - struct udma_desc *d; - u32 ring_id; - unsigned int i; - u64 asel; - - d =3D kzalloc_flex(*d, hwdesc, sglen, GFP_NOWAIT); - if (!d) - return NULL; - - d->sglen =3D sglen; - d->hwdesc_count =3D sglen; - - if (dir =3D=3D DMA_DEV_TO_MEM) - ring_id =3D k3_ringacc_get_ring_id(uc->rflow->r_ring); - else - ring_id =3D k3_ringacc_get_ring_id(uc->tchan->tc_ring); - - if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) - asel =3D 0; - else - asel =3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; - - for_each_sg(sgl, sgent, sglen, i) { - struct udma_hwdesc *hwdesc =3D &d->hwdesc[i]; - dma_addr_t sg_addr =3D sg_dma_address(sgent); - struct cppi5_host_desc_t *desc; - size_t sg_len =3D sg_dma_len(sgent); - - hwdesc->cppi5_desc_vaddr =3D dma_pool_zalloc(uc->hdesc_pool, - GFP_NOWAIT, - &hwdesc->cppi5_desc_paddr); - if (!hwdesc->cppi5_desc_vaddr) { - dev_err(uc->ud->dev, - "descriptor%d allocation failed\n", i); - - udma_free_hwdesc(uc, d); - kfree(d); - return NULL; - } - - d->residue +=3D sg_len; - hwdesc->cppi5_desc_size =3D uc->config.hdesc_size; - desc =3D hwdesc->cppi5_desc_vaddr; - - if (i =3D=3D 0) { - cppi5_hdesc_init(desc, 0, 0); - /* Flow and Packed ID */ - cppi5_desc_set_pktids(&desc->hdr, uc->id, - CPPI5_INFO1_DESC_FLOWID_DEFAULT); - cppi5_desc_set_retpolicy(&desc->hdr, 0, ring_id); - } else { - cppi5_hdesc_reset_hbdesc(desc); - cppi5_desc_set_retpolicy(&desc->hdr, 0, 0xffff); - } - - /* attach the sg buffer to the descriptor */ - sg_addr |=3D asel; - cppi5_hdesc_attach_buf(desc, sg_addr, sg_len, sg_addr, sg_len); - - /* Attach link as host buffer descriptor */ - if (h_desc) - cppi5_hdesc_link_hbdesc(h_desc, - hwdesc->cppi5_desc_paddr | asel); - - if (uc->ud->match_data->type =3D=3D DMA_TYPE_PKTDMA || - dir =3D=3D DMA_MEM_TO_DEV) - h_desc =3D desc; - } - - if (d->residue >=3D SZ_4M) { - dev_err(uc->ud->dev, - "%s: Transfer size %u is over the supported 4M range\n", - __func__, d->residue); - udma_free_hwdesc(uc, d); - kfree(d); - return NULL; - } - - h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; - cppi5_hdesc_set_pktlen(h_desc, d->residue); - - return d; -} - -static int udma_attach_metadata(struct dma_async_tx_descriptor *desc, - void *data, size_t len) -{ - struct udma_desc *d =3D to_udma_desc(desc); - struct udma_chan *uc =3D to_udma_chan(desc->chan); - struct cppi5_host_desc_t *h_desc; - u32 psd_size =3D len; - u32 flags =3D 0; - - if (!uc->config.pkt_mode || !uc->config.metadata_size) - return -ENOTSUPP; - - if (!data || len > uc->config.metadata_size) - return -EINVAL; - - if (uc->config.needs_epib && len < CPPI5_INFO0_HDESC_EPIB_SIZE) - return -EINVAL; - - h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; - if (d->dir =3D=3D DMA_MEM_TO_DEV) - memcpy(h_desc->epib, data, len); - - if (uc->config.needs_epib) - psd_size -=3D CPPI5_INFO0_HDESC_EPIB_SIZE; - - d->metadata =3D data; - d->metadata_size =3D len; - if (uc->config.needs_epib) - flags |=3D CPPI5_INFO0_HDESC_EPIB_PRESENT; - - cppi5_hdesc_update_flags(h_desc, flags); - cppi5_hdesc_update_psdata_size(h_desc, psd_size); - - return 0; -} - -static void *udma_get_metadata_ptr(struct dma_async_tx_descriptor *desc, - size_t *payload_len, size_t *max_len) -{ - struct udma_desc *d =3D to_udma_desc(desc); - struct udma_chan *uc =3D to_udma_chan(desc->chan); - struct cppi5_host_desc_t *h_desc; - - if (!uc->config.pkt_mode || !uc->config.metadata_size) - return ERR_PTR(-ENOTSUPP); - - h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; - - *max_len =3D uc->config.metadata_size; - - *payload_len =3D cppi5_hdesc_epib_present(&h_desc->hdr) ? - CPPI5_INFO0_HDESC_EPIB_SIZE : 0; - *payload_len +=3D cppi5_hdesc_get_psdata_size(h_desc); - - return h_desc->epib; -} - -static int udma_set_metadata_len(struct dma_async_tx_descriptor *desc, - size_t payload_len) -{ - struct udma_desc *d =3D to_udma_desc(desc); - struct udma_chan *uc =3D to_udma_chan(desc->chan); - struct cppi5_host_desc_t *h_desc; - u32 psd_size =3D payload_len; - u32 flags =3D 0; - - if (!uc->config.pkt_mode || !uc->config.metadata_size) - return -ENOTSUPP; - - if (payload_len > uc->config.metadata_size) - return -EINVAL; - - if (uc->config.needs_epib && payload_len < CPPI5_INFO0_HDESC_EPIB_SIZE) - return -EINVAL; - - h_desc =3D d->hwdesc[0].cppi5_desc_vaddr; - - if (uc->config.needs_epib) { - psd_size -=3D CPPI5_INFO0_HDESC_EPIB_SIZE; - flags |=3D CPPI5_INFO0_HDESC_EPIB_PRESENT; - } - - cppi5_hdesc_update_flags(h_desc, flags); - cppi5_hdesc_update_psdata_size(h_desc, psd_size); - - return 0; -} - -static const struct dma_descriptor_metadata_ops metadata_ops =3D { - .attach =3D udma_attach_metadata, - .get_ptr =3D udma_get_metadata_ptr, - .set_len =3D udma_set_metadata_len, -}; - -static struct dma_async_tx_descriptor * -udma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, - unsigned int sglen, enum dma_transfer_direction dir, - unsigned long tx_flags, void *context) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - enum dma_slave_buswidth dev_width; - struct udma_desc *d; - u32 burst; - - if (dir !=3D uc->config.dir && - (uc->config.dir =3D=3D DMA_MEM_TO_MEM && !uc->config.tr_trigger_type)= ) { - dev_err(chan->device->dev, - "%s: chan%d is for %s, not supporting %s\n", - __func__, uc->id, - dmaengine_get_direction_text(uc->config.dir), - dmaengine_get_direction_text(dir)); - return NULL; - } - - if (dir =3D=3D DMA_DEV_TO_MEM) { - dev_width =3D uc->cfg.src_addr_width; - burst =3D uc->cfg.src_maxburst; - } else if (dir =3D=3D DMA_MEM_TO_DEV) { - dev_width =3D uc->cfg.dst_addr_width; - burst =3D uc->cfg.dst_maxburst; - } else { - dev_err(chan->device->dev, "%s: bad direction?\n", __func__); - return NULL; - } - - if (!burst) - burst =3D 1; - - uc->config.tx_flags =3D tx_flags; - - if (uc->config.pkt_mode) - d =3D udma_prep_slave_sg_pkt(uc, sgl, sglen, dir, tx_flags, - context); - else if (is_slave_direction(uc->config.dir)) - d =3D udma_prep_slave_sg_tr(uc, sgl, sglen, dir, tx_flags, - context); - else - d =3D udma_prep_slave_sg_triggered_tr(uc, sgl, sglen, dir, - tx_flags, context); - - if (!d) - return NULL; - - d->dir =3D dir; - d->desc_idx =3D 0; - d->tr_idx =3D 0; - - /* static TR for remote PDMA */ - if (udma_configure_statictr(uc, d, dev_width, burst)) { - dev_err(uc->ud->dev, - "%s: StaticTR Z is limited to maximum %u (%u)\n", - __func__, uc->ud->match_data->statictr_z_mask, - d->static_tr.bstcnt); - - udma_free_hwdesc(uc, d); - kfree(d); - return NULL; - } - - if (uc->config.metadata_size) - d->vd.tx.metadata_ops =3D &metadata_ops; - - return vchan_tx_prep(&uc->vc, &d->vd, tx_flags); -} - -static struct udma_desc * -udma_prep_dma_cyclic_tr(struct udma_chan *uc, dma_addr_t buf_addr, - size_t buf_len, size_t period_len, - enum dma_transfer_direction dir, unsigned long flags) -{ - struct udma_desc *d; - size_t tr_size, period_addr; - struct cppi5_tr_type1_t *tr_req; - unsigned int periods =3D buf_len / period_len; - u16 tr0_cnt0, tr0_cnt1, tr1_cnt0; - unsigned int i; - int num_tr; - u32 period_csf =3D 0; - - num_tr =3D udma_get_tr_counters(period_len, __ffs(buf_addr), &tr0_cnt0, - &tr0_cnt1, &tr1_cnt0); - if (num_tr < 0) { - dev_err(uc->ud->dev, "size %zu is not supported\n", - period_len); - return NULL; - } - - /* Now allocate and setup the descriptor. */ - tr_size =3D sizeof(struct cppi5_tr_type1_t); - d =3D udma_alloc_tr_desc(uc, tr_size, periods * num_tr, dir); - if (!d) - return NULL; - - tr_req =3D d->hwdesc[0].tr_req_base; - if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA) - period_addr =3D buf_addr; - else - period_addr =3D buf_addr | - ((u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT); - - /* - * For BCDMA <-> PDMA transfers, the EOP flag needs to be set on the - * last TR of a descriptor, to mark the packet as complete. - * This is required for getting the teardown completion message in case - * of TX, and to avoid short-packet error in case of RX. - * - * As we are in cyclic mode, we do not know which period might be the - * last one, so set the flag for each period. - */ - if (uc->config.ep_type =3D=3D PSIL_EP_PDMA_XY && - uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { - period_csf =3D CPPI5_TR_CSF_EOP; - } - - for (i =3D 0; i < periods; i++) { - int tr_idx =3D i * num_tr; - - cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, false, - false, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - - tr_req[tr_idx].addr =3D period_addr; - tr_req[tr_idx].icnt0 =3D tr0_cnt0; - tr_req[tr_idx].icnt1 =3D tr0_cnt1; - tr_req[tr_idx].dim1 =3D tr0_cnt0; - - if (num_tr =3D=3D 2) { - cppi5_tr_csf_set(&tr_req[tr_idx].flags, - CPPI5_TR_CSF_SUPR_EVT); - tr_idx++; - - cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, - false, false, - CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - - tr_req[tr_idx].addr =3D period_addr + tr0_cnt1 * tr0_cnt0; - tr_req[tr_idx].icnt0 =3D tr1_cnt0; - tr_req[tr_idx].icnt1 =3D 1; - tr_req[tr_idx].dim1 =3D tr1_cnt0; - } - - if (!(flags & DMA_PREP_INTERRUPT)) - period_csf |=3D CPPI5_TR_CSF_SUPR_EVT; - - if (period_csf) - cppi5_tr_csf_set(&tr_req[tr_idx].flags, period_csf); - - period_addr +=3D period_len; - } - - return d; -} - -static struct udma_desc * -udma_prep_dma_cyclic_pkt(struct udma_chan *uc, dma_addr_t buf_addr, - size_t buf_len, size_t period_len, - enum dma_transfer_direction dir, unsigned long flags) -{ - struct udma_desc *d; - u32 ring_id; - int i; - int periods =3D buf_len / period_len; - - if (periods > (K3_UDMA_DEFAULT_RING_SIZE - 1)) - return NULL; - - if (period_len >=3D SZ_4M) - return NULL; - - d =3D kzalloc_flex(*d, hwdesc, periods, GFP_NOWAIT); - if (!d) - return NULL; - - d->hwdesc_count =3D periods; - - /* TODO: re-check this... */ - if (dir =3D=3D DMA_DEV_TO_MEM) - ring_id =3D k3_ringacc_get_ring_id(uc->rflow->r_ring); - else - ring_id =3D k3_ringacc_get_ring_id(uc->tchan->tc_ring); - - if (uc->ud->match_data->type !=3D DMA_TYPE_UDMA) - buf_addr |=3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; - - for (i =3D 0; i < periods; i++) { - struct udma_hwdesc *hwdesc =3D &d->hwdesc[i]; - dma_addr_t period_addr =3D buf_addr + (period_len * i); - struct cppi5_host_desc_t *h_desc; - - hwdesc->cppi5_desc_vaddr =3D dma_pool_zalloc(uc->hdesc_pool, - GFP_NOWAIT, - &hwdesc->cppi5_desc_paddr); - if (!hwdesc->cppi5_desc_vaddr) { - dev_err(uc->ud->dev, - "descriptor%d allocation failed\n", i); - - udma_free_hwdesc(uc, d); - kfree(d); - return NULL; - } - - hwdesc->cppi5_desc_size =3D uc->config.hdesc_size; - h_desc =3D hwdesc->cppi5_desc_vaddr; - - cppi5_hdesc_init(h_desc, 0, 0); - cppi5_hdesc_set_pktlen(h_desc, period_len); - - /* Flow and Packed ID */ - cppi5_desc_set_pktids(&h_desc->hdr, uc->id, - CPPI5_INFO1_DESC_FLOWID_DEFAULT); - cppi5_desc_set_retpolicy(&h_desc->hdr, 0, ring_id); - - /* attach each period to a new descriptor */ - cppi5_hdesc_attach_buf(h_desc, - period_addr, period_len, - period_addr, period_len); - } - - return d; -} - -static struct dma_async_tx_descriptor * -udma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t bu= f_len, - size_t period_len, enum dma_transfer_direction dir, - unsigned long flags) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - enum dma_slave_buswidth dev_width; - struct udma_desc *d; - u32 burst; - - if (dir !=3D uc->config.dir) { - dev_err(chan->device->dev, - "%s: chan%d is for %s, not supporting %s\n", - __func__, uc->id, - dmaengine_get_direction_text(uc->config.dir), - dmaengine_get_direction_text(dir)); - return NULL; - } - - uc->cyclic =3D true; - - if (dir =3D=3D DMA_DEV_TO_MEM) { - dev_width =3D uc->cfg.src_addr_width; - burst =3D uc->cfg.src_maxburst; - } else if (dir =3D=3D DMA_MEM_TO_DEV) { - dev_width =3D uc->cfg.dst_addr_width; - burst =3D uc->cfg.dst_maxburst; - } else { - dev_err(uc->ud->dev, "%s: bad direction?\n", __func__); - return NULL; - } - - if (!burst) - burst =3D 1; - - if (uc->config.pkt_mode) - d =3D udma_prep_dma_cyclic_pkt(uc, buf_addr, buf_len, period_len, - dir, flags); - else - d =3D udma_prep_dma_cyclic_tr(uc, buf_addr, buf_len, period_len, - dir, flags); - - if (!d) - return NULL; - - d->sglen =3D buf_len / period_len; - - d->dir =3D dir; - d->residue =3D buf_len; - - /* static TR for remote PDMA */ - if (udma_configure_statictr(uc, d, dev_width, burst)) { - dev_err(uc->ud->dev, - "%s: StaticTR Z is limited to maximum %u (%u)\n", - __func__, uc->ud->match_data->statictr_z_mask, - d->static_tr.bstcnt); - - udma_free_hwdesc(uc, d); - kfree(d); - return NULL; - } - - if (uc->config.metadata_size) - d->vd.tx.metadata_ops =3D &metadata_ops; - - return vchan_tx_prep(&uc->vc, &d->vd, flags); -} - -static struct dma_async_tx_descriptor * -udma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t sr= c, - size_t len, unsigned long tx_flags) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - struct udma_desc *d; - struct cppi5_tr_type15_t *tr_req; - int num_tr; - size_t tr_size =3D sizeof(struct cppi5_tr_type15_t); - u16 tr0_cnt0, tr0_cnt1, tr1_cnt0; - u32 csf =3D CPPI5_TR_CSF_SUPR_EVT; - - if (uc->config.dir !=3D DMA_MEM_TO_MEM) { - dev_err(chan->device->dev, - "%s: chan%d is for %s, not supporting %s\n", - __func__, uc->id, - dmaengine_get_direction_text(uc->config.dir), - dmaengine_get_direction_text(DMA_MEM_TO_MEM)); - return NULL; - } - - num_tr =3D udma_get_tr_counters(len, __ffs(src | dest), &tr0_cnt0, - &tr0_cnt1, &tr1_cnt0); - if (num_tr < 0) { - dev_err(uc->ud->dev, "size %zu is not supported\n", - len); - return NULL; - } - - d =3D udma_alloc_tr_desc(uc, tr_size, num_tr, DMA_MEM_TO_MEM); - if (!d) - return NULL; - - d->dir =3D DMA_MEM_TO_MEM; - d->desc_idx =3D 0; - d->tr_idx =3D 0; - d->residue =3D len; - - if (uc->ud->match_data->type !=3D DMA_TYPE_UDMA) { - src |=3D (u64)uc->ud->asel << K3_ADDRESS_ASEL_SHIFT; - dest |=3D (u64)uc->ud->asel << K3_ADDRESS_ASEL_SHIFT; - } else { - csf |=3D CPPI5_TR_CSF_EOL_ICNT0; - } - - tr_req =3D d->hwdesc[0].tr_req_base; - - cppi5_tr_init(&tr_req[0].flags, CPPI5_TR_TYPE15, false, true, - CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req[0].flags, csf); - - tr_req[0].addr =3D src; - tr_req[0].icnt0 =3D tr0_cnt0; - tr_req[0].icnt1 =3D tr0_cnt1; - tr_req[0].icnt2 =3D 1; - tr_req[0].icnt3 =3D 1; - tr_req[0].dim1 =3D tr0_cnt0; - - tr_req[0].daddr =3D dest; - tr_req[0].dicnt0 =3D tr0_cnt0; - tr_req[0].dicnt1 =3D tr0_cnt1; - tr_req[0].dicnt2 =3D 1; - tr_req[0].dicnt3 =3D 1; - tr_req[0].ddim1 =3D tr0_cnt0; - - if (num_tr =3D=3D 2) { - cppi5_tr_init(&tr_req[1].flags, CPPI5_TR_TYPE15, false, true, - CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req[1].flags, csf); - - tr_req[1].addr =3D src + tr0_cnt1 * tr0_cnt0; - tr_req[1].icnt0 =3D tr1_cnt0; - tr_req[1].icnt1 =3D 1; - tr_req[1].icnt2 =3D 1; - tr_req[1].icnt3 =3D 1; - - tr_req[1].daddr =3D dest + tr0_cnt1 * tr0_cnt0; - tr_req[1].dicnt0 =3D tr1_cnt0; - tr_req[1].dicnt1 =3D 1; - tr_req[1].dicnt2 =3D 1; - tr_req[1].dicnt3 =3D 1; - } - - cppi5_tr_csf_set(&tr_req[num_tr - 1].flags, csf | CPPI5_TR_CSF_EOP); - - if (uc->config.metadata_size) - d->vd.tx.metadata_ops =3D &metadata_ops; - - return vchan_tx_prep(&uc->vc, &d->vd, tx_flags); -} - static void udma_issue_pending(struct dma_chan *chan) { struct udma_chan *uc =3D to_udma_chan(chan); @@ -3587,46 +2409,6 @@ static void udma_synchronize(struct dma_chan *chan) udma_reset_rings(uc); } =20 -static void udma_desc_pre_callback(struct virt_dma_chan *vc, - struct virt_dma_desc *vd, - struct dmaengine_result *result) -{ - struct udma_chan *uc =3D to_udma_chan(&vc->chan); - struct udma_desc *d; - u8 status; - - if (!vd) - return; - - d =3D to_udma_desc(&vd->tx); - - if (d->metadata_size) - udma_fetch_epib(uc, d); - - if (result) { - void *desc_vaddr =3D udma_curr_cppi5_desc_vaddr(d, d->desc_idx); - - if (cppi5_desc_get_type(desc_vaddr) =3D=3D - CPPI5_INFO0_DESC_TYPE_VAL_HOST) { - /* Provide residue information for the client */ - result->residue =3D d->residue - - cppi5_hdesc_get_pktlen(desc_vaddr); - if (result->residue) - result->result =3D DMA_TRANS_ABORTED; - else - result->result =3D DMA_TRANS_NOERROR; - } else { - result->residue =3D 0; - /* Propagate TR Response errors to the client */ - status =3D d->hwdesc[0].tr_resp_base->status; - if (status) - result->result =3D DMA_TRANS_ABORTED; - else - result->result =3D DMA_TRANS_NOERROR; - } - } -} - /* * This tasklet handles the completion of a DMA descriptor by * calling its callback and freeing it. diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 54e1757c3de38..62c15b0cc9ae7 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -560,6 +560,60 @@ static inline void udma_fetch_epib(struct udma_chan *u= c, struct udma_desc *d) memcpy(d->metadata, h_desc->epib, d->metadata_size); } =20 +/* Common functions */ +struct udma_desc *udma_udma_desc_from_paddr(struct udma_chan *uc, + dma_addr_t paddr); +void udma_free_hwdesc(struct udma_chan *uc, struct udma_desc *d); +void udma_purge_desc_work(struct work_struct *work); +void udma_desc_free(struct virt_dma_desc *vd); +bool udma_desc_is_rx_flush(struct udma_chan *uc, dma_addr_t addr); +bool udma_is_desc_really_done(struct udma_chan *uc, struct udma_desc *d); +struct udma_desc *udma_alloc_tr_desc(struct udma_chan *uc, + size_t tr_size, int tr_count, + enum dma_transfer_direction dir); +int udma_get_tr_counters(size_t len, unsigned long align_to, + u16 *tr0_cnt0, u16 *tr0_cnt1, u16 *tr1_cnt0); +struct udma_desc *udma_prep_slave_sg_tr(struct udma_chan *uc, + struct scatterlist *sgl, unsigned int sglen, + enum dma_transfer_direction dir, + unsigned long tx_flags, void *context); +struct udma_desc *udma_prep_slave_sg_triggered_tr(struct udma_chan *uc, + struct scatterlist *sgl, unsigned int sglen, + enum dma_transfer_direction dir, + unsigned long tx_flags, void *context); +int udma_configure_statictr(struct udma_chan *uc, struct udma_desc *d, + enum dma_slave_buswidth dev_width, u16 elcnt); +struct udma_desc *udma_prep_slave_sg_pkt(struct udma_chan *uc, + struct scatterlist *sgl, unsigned int sglen, + enum dma_transfer_direction dir, + unsigned long tx_flags, void *context); +int udma_attach_metadata(struct dma_async_tx_descriptor *desc, + void *data, size_t len); +void *udma_get_metadata_ptr(struct dma_async_tx_descriptor *desc, + size_t *payload_len, size_t *max_len); +int udma_set_metadata_len(struct dma_async_tx_descriptor *desc, + size_t payload_len); +struct dma_async_tx_descriptor *udma_prep_slave_sg(struct dma_chan *chan, + struct scatterlist *sgl, unsigned int sglen, + enum dma_transfer_direction dir, + unsigned long tx_flags, void *context); +struct udma_desc *udma_prep_dma_cyclic_tr(struct udma_chan *uc, + dma_addr_t buf_addr, size_t buf_len, size_t period_len, + enum dma_transfer_direction dir, unsigned long flags); +struct udma_desc *udma_prep_dma_cyclic_pkt(struct udma_chan *uc, + dma_addr_t buf_addr, size_t buf_len, size_t period_len, + enum dma_transfer_direction dir, unsigned long flags); +struct dma_async_tx_descriptor *udma_prep_dma_cyclic(struct dma_chan *chan= , dma_addr_t buf_addr, + size_t buf_len, size_t period_len, + enum dma_transfer_direction dir, + unsigned long flags); +struct dma_async_tx_descriptor *udma_prep_dma_memcpy(struct dma_chan *chan, + dma_addr_t dest, dma_addr_t src, + size_t len, unsigned long tx_flags); +void udma_desc_pre_callback(struct virt_dma_chan *vc, + struct virt_dma_desc *vd, + struct dmaengine_result *result); + /* 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_thr= ead); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 D758C42AFA3; Fri, 24 Jul 2026 10:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888539; cv=fail; b=XRUSCi43Hvn7RSwEze371EqUAiHmn+A4WTidPvWy8tbhAN3wvKFg/jIOvmORg2AzarzO34s51KIRPviDxCjJBzUDhSnVGoXoeZmwkFHdE19UmcEfhulDrJuBJxurkBfJ7Yycb6J1GZXrHn/uMA6vHLUBtEAV/cGup0eabIiCxzw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888539; c=relaxed/simple; bh=1+jVKqFnkFa7Oz4h9xcp/NBdfUc42n0Khp0YbWOJNFo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qNjhWCMqott6OU7azJIiaWY5VGbd8gDCOpX42ObFF9yV64WmvVT9tC0czROuLtnjqWLFc2rCRz/M5U2FLukRb0AieskdQyIUQXpiudKvaavG9ZS9CC1o+58xlknSDat1bKSw9MeMj+iFSlevYuJ+GsCssVTpoZgp3IL03WBUP50= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=WV6udbUJ; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=HDCLwCOD; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="WV6udbUJ"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="HDCLwCOD" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAF2KF2796675; Fri, 24 Jul 2026 05:22:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=4pTtY5yw7qWEB9frocphqK4WU1uhBZUdb/xq6mJWT Q4=; b=WV6udbUJ0IBn7glT7AvkEUQ4IjW3aPsvkCvY1GDZi0uQMzyFLhAh6kD0C WT7ZDW8EQJuy0RanRsmp8qfTe+b77d1k/CbfvHmwEVdPGb8mS1Jz4KY5pZlyjyyx X+mXBByB2xnwg2op/4i1UgZuxLLG9irV2CVONILI13tYzYBbWXosQ3OeGMo+GbRW vCkhoWi78b1f8+euwSRdevJ3K20bxYs1X3WzyFmCRnPZZMAHhCFJ2AnUkRDGFVLx VrBSdOB7BT82/KaYsXH5BjReT3oh4oDRkRAMUSaFG5Y6izCna7KZmUr8WBSTQH/3 SZS7AWlM3gwf7r0K56SVxnXnNF0tw== Received: from ph7pr06cu001.outbound.protection.outlook.com (mail-westus3azon11010070.outbound.protection.outlook.com [52.101.201.70]) by m0384305.ppops.net (PPS) with ESMTPS id 4fm3v38pu7-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:06 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pqSpBltRmu0+7HVSQepXRNK9MfqnnIvYDHAnQ0zcFXiBOqKusokn66c4ByWAU1QrLoBM3LGZdheE+bB12qRuhZmYVc/q1c7LGxwTz9Axsj3kmhhRg6irwnA5ZRDUjT3fs69NOB4wh0SVgcJRGo20xpkNadFutXvmxnIcaeGsaPqlQGwHBGWJj+QOc/mYOJgqWwQHV+NGJKJEa6O+/xo5xBMHwYunismCj/CnqgcnAfcehEWjiRas9iwTZZcPHV9iAam3J6zxNrOqF8LqeRV5TCr5OkXzwVEkwlhYFN5GQ+J6oCopko0gqj2N+x74UxPtPb+fqKn70j2fwvROxoXlEw== 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=4pTtY5yw7qWEB9frocphqK4WU1uhBZUdb/xq6mJWTQ4=; b=ZiNpg+3TX3CDXPoyBrcThwqH4m8oxeB4az9lFL6aAp80fZlH8Ze9Ndom3xE5e0h63ISwo2VA8lSnIQQkdkRkZzfaSht0iMZIUrH2sX3hK+INELHt5L8I7/6XWxYIChLlS6e6OuBpHtLualNX4RpTSo9yn/oS/RWxa8Ik1uHBcx1FIezi+LBYmvsc6SK6QKodE6T2waIOEIZvQIZAlcZjOegvAwf0ey43aDCAIqyEOX4Mo6/NYeFPKQKIZiljgENNiMS6p8BUv9veAh5IzdRPjii6oSDNQNlSiDDrlC0KlmT69P8SIuA1VYXMNoFNd/0MknHFGxSHg2OK4xyDKcIrjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4pTtY5yw7qWEB9frocphqK4WU1uhBZUdb/xq6mJWTQ4=; b=HDCLwCODIdG0eQ07H9uicA11NLhJP0+HZziwkiy0Q3Hiacz/uhlw/DhmtXcpDrKdqgjqyBkwj8TzGMtXw+1OCeWt8uRX9vfGPkxVUasYw7Q4CdPeekiH4U6VYUX6HdHKV4vH3Ew/KV6UuGLtua0GctZiViNTww7u6bc8qovIRLM= Received: from PH8PR05CA0021.namprd05.prod.outlook.com (2603:10b6:510:2cc::9) by SA1PR10MB6296.namprd10.prod.outlook.com (2603:10b6:806:253::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Fri, 24 Jul 2026 10:22:01 +0000 Received: from SJ1PEPF00002315.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::2f) by PH8PR05CA0021.outlook.office365.com (2603:10b6:510:2cc::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.7 via Frontend Transport; Fri, 24 Jul 2026 10:22:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF00002315.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:01 +0000 Received: from DLEE213.ent.ti.com (157.170.170.116) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:58 -0500 Received: from DLEE209.ent.ti.com (157.170.170.98) by DLEE213.ent.ti.com (157.170.170.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:21:58 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:21:58 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFL3017088; Fri, 24 Jul 2026 05:21:53 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 06/19] dmaengine: ti: k3-udma: move ring management functions to k3-udma-common.c Date: Fri, 24 Jul 2026 15:50:39 +0530 Message-ID: <20260724102115.2854-7-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002315:EE_|SA1PR10MB6296:EE_ X-MS-Office365-Filtering-Correlation-Id: 2896bf63-ab12-4f0f-9a0c-08dee96d666f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|82310400026|7416014|376014|23010399003|56012099006|10067099003|6133799003|18002099003|22082099003|3023799007|921020; X-Microsoft-Antispam-Message-Info: ejq2kYbXeMtgxcWaGhuSS9cu3Snwa53suFpymGbLXOSZy6RlK2pBe/kTBkxjM4tL9OovNU3c/8JdY7onYNfNZAr8amF911QF6HSMrD8VPkrfkQZiZqPvtZe6TnYZrUYWWeeD6GHxZa+tslwMmOUQDUnWsMbbamzNcjennBM8cOrpnlM+1Bp+RqiCEsPoFQPv/pthY8I6JanOIfOKE2eg3pPix4lAw/CFnz9im4hYiEhhtuJP1QFeMGm3sl6V0qfiihWg+XwlHHfEX3FmqOOhrRhtmhktOyEUuAdAmuVSaqikd45pPdfD+64KMAWvVfVa0G9+U9Mtb4wflhpBM4CeR/hJ9huKAz1KDeS/KfPeGfJEgFhjeumqJ+0EBgaubFR6F27j3Uz7QrEtbzj9RrnJ89/ctazsiMfaJzm/U2dI4q0PaGbCe+VSEHrPbhXKKh6o92ptyF2wftB0jJM6Fs5zIULcFnFIc3PX7ZQR7vEvqx06SibOPkKa6efdzIaXfq32F25Z+YWbJxWXQaY6MkQJpudags0/i7ZUy3uXmLlgIdoWfqj6d8zrFQ9CKICd/sORK1eiMuxuQoJreANgVwnpOo21CZoXNDxzT76al5mDMEAW1eneog2UMEXQKL2ZEo6rMS8AxRvaDoRP0hb1u0imXFhnL5anmUZ3iwntWb71JrQe2lwxVe65xwXvHuOeuI+rFvvQkOxuxyIB6JeoAm0NJHnzRVSgykL1esJ7CkhOAsAauegEWk58YALoMJS2Xo6d X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(82310400026)(7416014)(376014)(23010399003)(56012099006)(10067099003)(6133799003)(18002099003)(22082099003)(3023799007)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lGYYJs4AcCaKXk7J/yy4fY/S5mu/vdk18OyHniIYktsX2vO+qF4To2w0pPbrnAWYVH9Y8qA7C615dfi2UPNj1vOuYIanly/pqhEKJV6tiv3NsdA2VYEKW9vEzOQ/aN1+6cGEouY5J4w6KUg6tArwVyJrBduqXg/McVejotBqDv8D5vVoRKXM7Yas3y9ZTuWhKcPMoqTEZchLalEFV3sfh6AISeg6cmkPQj7Oao4g1u39EUR3n+ixop/NDNC2g3T97D9U1aLozy5HmIyRMhHIlGzMaAIvtJb/MzdCJoMijNZrden4PzUKl048Y82Mw9lOH7nd9Ip8OU8JDvnyQ4HAAYmJVNvudOlkk1eTxlAmRlt6jbCZD5e9gIkFhmAWeEwLYJRUSV2yqJEKJyIcIBhY2XEN+kDvgpQhVV0YrcDZDcyXDHrKliVaSXgd2Yz98TZM X-Exchange-RoutingPolicyChecked: NOpxZvuyrjYdONLb4lt194PkJxTTcu/ujWyNgYsHVwjhXO6RYELjgSrmjzmP7YBTzhJUPxtSVGvpPNmc0voyZ+IrrXYAot8IiR31pSDw0eNPXRhd+6kHqTVrJ5mFwefwht2TL+r4MQfaZ7esx1uJimw1JvgY2VMoaUVKj/Jm00hoU0Ui42Nor9Jv/lnBqnw7hvoBLDVTbCJtJPky5gRtFhiy2qvAMx2iTT9R14NAlUPNhKC7Fam2ecFf+tXlWjzA+4rJtFYdhF9tS5w1IJD9+DpZue4Hu5nZFbFLXOeuM4kIxJOJ/YF2rfwZiWvP1tLgdLnLZMnX95sBFHbjtJ5huA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:01.1214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2896bf63-ab12-4f0f-9a0c-08dee96d666f X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002315.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6296 X-Proofpoint-GUID: AW9xo2TsqYgu0zHJ5OUeZPnUvNhLT9Yc X-Proofpoint-ORIG-GUID: AW9xo2TsqYgu0zHJ5OUeZPnUvNhLT9Yc X-Authority-Analysis: v=2.4 cv=dLWWXuZb c=1 sm=1 tr=0 ts=6a633cce cx=c_pps a=RGUNHxVObgwraRyadLFC+w==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=8AirrxEcAAAA:8 a=sozttTNsAAAA:8 a=g6TaX78G5PB857Cctd4A:9 a=ST-jHhOKWsTCqRlWije3:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX5We+W8uiD/Q2 JNcsqsy5y7du9Dze4F6c5R+G+nziyoy1dgdTBfT5g56ai6w/xhclP7uPzz/U9j5m+XB8e/Tnht3 ROPt0QLPosI6KhkxEKOsL9f/7r5jJjKvkTfay2jgfXOauMckA4mnoLGBQ9ZWs7sMQKsqt0JlVS6 PFnhfiBcS2b1eseToBsUa+vnCKmKNf6QDCDMUzV9pq0VXiJLsgqx9w6R1B18eRH8WGjiMNCl2gD 86fp6qY/gBenxOhX88k/JrH579Hpd0UcZcQOaplzn18/2om47hcQlC9bveuBB+NbHLQMHaRp/Kn qzDXh92JF+ENYJjXPzO0ijskKycbzrwzbRd2riW9u2tmXURR5l2unr4xhAjlwznzJxPVuztfuGn XdU7yv0InWK8AQRThFnXNgkIM1OwMeCl2/ldUqg5USKeqNHY/Mz/schVLT56u8/JM8+uiEFfdd2 t4t1XeCDgLiluMW8D8g== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX3+CHfZfKQdvU tXHjEjOV2hRV2lvTmHw3yEV8VPuwWp82FNcDHZnImwbyiASlql3CTc+gA0vjKb9OHHjmbSFxV0P UJVDV99emfTybm8rwiUat8egsNBWohE= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Relocate the ring management functions such as push, pop, and reset from k3-udma.c to k3-udma-common.c file. These operations are common across multiple K3 UDMA variants and will be reused by future implementations like K3 UDMA v2. No functional changes intended. Reviewed-by: Frank Li Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma-common.c | 103 ++++++++++++++++++++++++++++++++ drivers/dma/ti/k3-udma.c | 100 ------------------------------- drivers/dma/ti/k3-udma.h | 4 ++ 3 files changed, 107 insertions(+), 100 deletions(-) diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index daf5f19dfb3ab..fc5e2c99ee28a 100644 --- a/drivers/dma/ti/k3-udma-common.c +++ b/drivers/dma/ti/k3-udma-common.c @@ -1239,5 +1239,108 @@ void udma_desc_pre_callback(struct virt_dma_chan *v= c, } EXPORT_SYMBOL_GPL(udma_desc_pre_callback); =20 +int udma_push_to_ring(struct udma_chan *uc, int idx) +{ + struct udma_desc *d =3D uc->desc; + struct k3_ring *ring =3D NULL; + dma_addr_t paddr; + + switch (uc->config.dir) { + case DMA_DEV_TO_MEM: + ring =3D uc->rflow->fd_ring; + break; + case DMA_MEM_TO_DEV: + case DMA_MEM_TO_MEM: + ring =3D uc->tchan->t_ring; + break; + default: + return -EINVAL; + } + + /* RX flush packet: idx =3D=3D -1 is only passed in case of DEV_TO_MEM */ + if (idx =3D=3D -1) { + paddr =3D udma_get_rx_flush_hwdesc_paddr(uc); + } else { + paddr =3D udma_curr_cppi5_desc_paddr(d, idx); + + wmb(); /* Ensure that writes are not moved over this point */ + } + + return k3_ringacc_ring_push(ring, &paddr); +} +EXPORT_SYMBOL_GPL(udma_push_to_ring); + +int udma_pop_from_ring(struct udma_chan *uc, dma_addr_t *addr) +{ + struct k3_ring *ring =3D NULL; + int ret; + + switch (uc->config.dir) { + case DMA_DEV_TO_MEM: + ring =3D uc->rflow->r_ring; + break; + case DMA_MEM_TO_DEV: + case DMA_MEM_TO_MEM: + ring =3D uc->tchan->tc_ring; + break; + default: + return -ENOENT; + } + + ret =3D k3_ringacc_ring_pop(ring, addr); + if (ret) + return ret; + + rmb(); /* Ensure that reads are not moved before this point */ + + /* Teardown completion */ + if (cppi5_desc_is_tdcm(*addr)) + return 0; + + /* Check for flush descriptor */ + if (udma_desc_is_rx_flush(uc, *addr)) + return -ENOENT; + + return 0; +} +EXPORT_SYMBOL_GPL(udma_pop_from_ring); + +void udma_reset_rings(struct udma_chan *uc) +{ + struct k3_ring *ring1 =3D NULL; + struct k3_ring *ring2 =3D NULL; + + switch (uc->config.dir) { + case DMA_DEV_TO_MEM: + if (uc->rchan) { + ring1 =3D uc->rflow->fd_ring; + ring2 =3D uc->rflow->r_ring; + } + break; + case DMA_MEM_TO_DEV: + case DMA_MEM_TO_MEM: + if (uc->tchan) { + ring1 =3D uc->tchan->t_ring; + ring2 =3D uc->tchan->tc_ring; + } + break; + default: + break; + } + + if (ring1) + k3_ringacc_ring_reset_dma(ring1, + k3_ringacc_ring_get_occ(ring1)); + if (ring2) + k3_ringacc_ring_reset(ring2); + + /* make sure we are not leaking memory by stalled descriptor */ + if (uc->terminated_desc) { + udma_desc_free(&uc->terminated_desc->vd); + uc->terminated_desc =3D NULL; + } +} +EXPORT_SYMBOL_GPL(udma_reset_rings); + 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 ae8b8ebd5dddd..40ba114ac81dd 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -174,106 +174,6 @@ static bool udma_is_chan_paused(struct udma_chan *uc) return false; } =20 -static int udma_push_to_ring(struct udma_chan *uc, int idx) -{ - struct udma_desc *d =3D uc->desc; - struct k3_ring *ring =3D NULL; - dma_addr_t paddr; - - switch (uc->config.dir) { - case DMA_DEV_TO_MEM: - ring =3D uc->rflow->fd_ring; - break; - case DMA_MEM_TO_DEV: - case DMA_MEM_TO_MEM: - ring =3D uc->tchan->t_ring; - break; - default: - return -EINVAL; - } - - /* RX flush packet: idx =3D=3D -1 is only passed in case of DEV_TO_MEM */ - if (idx =3D=3D -1) { - paddr =3D udma_get_rx_flush_hwdesc_paddr(uc); - } else { - paddr =3D udma_curr_cppi5_desc_paddr(d, idx); - - wmb(); /* Ensure that writes are not moved over this point */ - } - - return k3_ringacc_ring_push(ring, &paddr); -} - -static int udma_pop_from_ring(struct udma_chan *uc, dma_addr_t *addr) -{ - struct k3_ring *ring =3D NULL; - int ret; - - switch (uc->config.dir) { - case DMA_DEV_TO_MEM: - ring =3D uc->rflow->r_ring; - break; - case DMA_MEM_TO_DEV: - case DMA_MEM_TO_MEM: - ring =3D uc->tchan->tc_ring; - break; - default: - return -ENOENT; - } - - ret =3D k3_ringacc_ring_pop(ring, addr); - if (ret) - return ret; - - rmb(); /* Ensure that reads are not moved before this point */ - - /* Teardown completion */ - if (cppi5_desc_is_tdcm(*addr)) - return 0; - - /* Check for flush descriptor */ - if (udma_desc_is_rx_flush(uc, *addr)) - return -ENOENT; - - return 0; -} - -static void udma_reset_rings(struct udma_chan *uc) -{ - struct k3_ring *ring1 =3D NULL; - struct k3_ring *ring2 =3D NULL; - - switch (uc->config.dir) { - case DMA_DEV_TO_MEM: - if (uc->rchan) { - ring1 =3D uc->rflow->fd_ring; - ring2 =3D uc->rflow->r_ring; - } - break; - case DMA_MEM_TO_DEV: - case DMA_MEM_TO_MEM: - if (uc->tchan) { - ring1 =3D uc->tchan->t_ring; - ring2 =3D uc->tchan->tc_ring; - } - break; - default: - break; - } - - if (ring1) - k3_ringacc_ring_reset_dma(ring1, - k3_ringacc_ring_get_occ(ring1)); - if (ring2) - k3_ringacc_ring_reset(ring2); - - /* make sure we are not leaking memory by stalled descriptor */ - if (uc->terminated_desc) { - udma_desc_free(&uc->terminated_desc->vd); - uc->terminated_desc =3D NULL; - } -} - static void udma_decrement_byte_counters(struct udma_chan *uc, u32 val) { if (uc->desc->dir =3D=3D DMA_DEV_TO_MEM) { diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 62c15b0cc9ae7..767b73021390d 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -614,6 +614,10 @@ void udma_desc_pre_callback(struct virt_dma_chan *vc, struct virt_dma_desc *vd, struct dmaengine_result *result); =20 +int udma_push_to_ring(struct udma_chan *uc, int idx); +int udma_pop_from_ring(struct udma_chan *uc, dma_addr_t *addr); +void udma_reset_rings(struct udma_chan *uc); + /* 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_thr= ead); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 B5A92422E36; Fri, 24 Jul 2026 10:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888547; cv=fail; b=hLRG48edhW8UmpptZsvnG381+MDioLzNDpfkYkr/cGFkGxHHBZ7ZY8UfGcdlmsHTHGJTqRXG6m71jrHDXcRpC4FVcOaeclZuo9XOVQ2oLcY5Abpd+DJsMdwoCrpWubZgy80H6a4H6NGY4YL4cl5cAFPEipwBWgZvnfN/5amMVWE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888547; c=relaxed/simple; bh=GVpatDnPYVYydKc+KSbBokFHube3THZrvNmZ6PZXWaA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rBLheOwogOSB7bNIWFxyy8yOyfAenUQRAsGoEL5ntwdzuw22ti8eIxdRF5/bbV7z3HYwM5RLmqQ5tT55jsLMU577LDEMUQeyj9M0j+EKmvwTjcwUn+OOfnNn78l1lz9EZTMaF27MvBFEZlSCOnmotQLAY9qmfidu0Gv/LQ3s97U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=PjL1jVha; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=mz+X2yGU; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="PjL1jVha"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="mz+X2yGU" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFhit785710; Fri, 24 Jul 2026 05:22:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=JpsvSYeqwobyQ6en6O0BGPE1FNoXibP3ieou4zJeT Vc=; b=PjL1jVhatTB8N/H3A/nIab5XOASjuJESSupjXAOc5wzDoL/7Kmc3LNVdC ZiY/MKbZ8HnQeebEikMc1MlamZkuN1BS08y3+ONMdFVUbRYu6sCe6Y/rEk3An2VR Hyun07AAfE7Cb1qFIrZsMOwCkoFY0YM0/hx62UCxAcG1MqkTcZT2VeRcQTT9GU+w 6l/8nJVT3tBntiKqPZbdk8LuVy6qdr41wZdYyDAiU9UTgy158Ql9qi53UZwSegzN ETL1QZrJUvL+WtzmieKwMdvDrOAvn8VCUep/xu8plVAwTXUK/j7X/qXo8QqWxgvf 7FLyVBk3z5kPqSmsRqjE0IETX95kA== Received: from sn4pr0501cu005.outbound.protection.outlook.com (mail-southcentralusazon11011026.outbound.protection.outlook.com [40.93.194.26]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fm5p304jx-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:09 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hOPjx+/isx/hCpNdiu7eqg/kSqsOmnHUdpepyUHPjtoUfkSF5P5Rx6HE2YpMTvGzNktMRpsFUllZ6id9ejBCwOdFidccWQYKjSGPRf1tngbphfbBfWcaH8kX0tkkvI48dJmhIiB+4hlzO5a/w+UuxHjabvpff2Q+Y4KmOQFZ6Mk3Y9LgorzpWH2UNJqhJD5TAc8CAxnrx6YgtpuFBJbFlu1pIiD55GvUPenB5k7ZWoQprBcNhxGwJq0mdn+o0ZCo533qy31gLJG8NOFYM/mSsdewbCTTJIAZ8Wx7QPox0gy4foOpoosYNuwVP/o76+907v3zqZ2pCnIqKw+DhtHTPA== 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=JpsvSYeqwobyQ6en6O0BGPE1FNoXibP3ieou4zJeTVc=; b=kC05RfTRJLzAUieR3uQmvKwwtjRBDrwCNRyuZgiIKKe/g3IdpNjgrlsxArZLY9/ewMjgb3HAbDGvH5u7epPa1QlAmlqhk2tVAJMAdwkesNy6nk6B0hJpIVBxQuG1HdooCJir5xNCr90P7Iiaw0IOchCyLvBH9INvFndDSF5+AMMxO5Fl9xRuc6lqkaAZQq+kNlZIlPTdAHllYzBkkHMRf/6qVlTYfDxTzUIAfd9tGJVfOnwTM1gop1EQTRanGLZxpZktvBwSZ9wESWIpcCEXtU/jF3TNhM23LgoMbn7NKhTaWLW8k+xGVTmaAH7KWY7R0IO7JHmYpWZ+hGkc0XINgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JpsvSYeqwobyQ6en6O0BGPE1FNoXibP3ieou4zJeTVc=; b=mz+X2yGUS6z9slKKjZsWppgvioRIIOx4lN4lSm1EPEkLzwtBrf+Lc/8LRlj6qNAmFbj584siFspmrtSNa7XraETgw+/pUWftdzvibruYoyDyJv8OahuRSVjKlqlsxm6OTOqpvTtMnQvC+lBOKaCuErsGQEn8XuipESZZlBDmQSo= Received: from MN2PR06CA0027.namprd06.prod.outlook.com (2603:10b6:208:23d::32) by SN7PR10MB6547.namprd10.prod.outlook.com (2603:10b6:806:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Fri, 24 Jul 2026 10:22:05 +0000 Received: from BL02EPF00021F6B.namprd02.prod.outlook.com (2603:10b6:208:23d:cafe::61) by MN2PR06CA0027.outlook.office365.com (2603:10b6:208:23d::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:22:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by BL02EPF00021F6B.mail.protection.outlook.com (10.167.249.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:04 +0000 Received: from DFLE204.ent.ti.com (10.64.6.62) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:03 -0500 Received: from DFLE203.ent.ti.com (10.64.6.61) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:03 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE203.ent.ti.com (10.64.6.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:03 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFM3017088; Fri, 24 Jul 2026 05:21:58 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 07/19] dmaengine: ti: k3-udma: Add variant-specific function pointers to udma_dev Date: Fri, 24 Jul 2026 15:50:40 +0530 Message-ID: <20260724102115.2854-8-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F6B:EE_|SN7PR10MB6547:EE_ X-MS-Office365-Filtering-Correlation-Id: 48f348f0-1c36-45c1-eb32-08dee96d683a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|1800799024|23010399003|7416014|376014|22082099003|18002099003|10067099003|56012099006|921020|6133799003; X-Microsoft-Antispam-Message-Info: PH+F4gODSz/K05Mi53F3p6RCIPgEM5p+gBo2EaqMGviz7Mw+4MeLSVD1jr1B+NG5+gBzBMCluZ/pEFywivGV37zS6KrVsQG7nq0VTTNxcADGImyfkcAenELlPikNkP5n692FL+OSToapHORQ0z8s4LHidqt23u+7BHEZ0zonC7lBp4O/750uMQS6HpDH1QcqXqJUHgoNzpQkHxSS7xqli8ksODZ5dpPlXx0BWTKX8sBf5kUXZm2WM+FiBS7pIZ0xDhthuFfcngIH6AaBWpnC0THq0hAP6BOKqKbGnZvT8U262WkJIXA2jnpx+OEC4Vsw6EYCJk9GQnogd9JqhUZ8Og187RO1q3E4YB/FMqNqkbqve6Z7ui5I7K0btuRRt+ELKvS/X7ZthTnsvzSVgUBb/CSVGVg9cvsJ+e6bZ5uMnHeGJyRdd1ndlSYpftBe2p+QQdo25+zdEOr7GEjXB+O6BhmLNhaht8prB/VZ1et1gCzHbcpOIMzLg9JypX1HwgTDMg5TR0SiycDYvUdh3PnNMjQ7bYYCQlHSoYhLCKGf9xLJFFCOpIBM3ZKBbOJ2suyLDR359XLkUh1mMhS+zDXLbwiZ4hnadwHTcY9xvIsHm/8Ej0/Tl+SNBsMhZ154A6XDMeVUyxF9KaCF0GDvquzNOIxjrziXxTgTbgeyR4Re2pdigjKLBnYHx/fYyOfKg26+QthCtRSDwv0TPdF9oWB4ec6seMaRgNMGqILd0o9mjds= X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(1800799024)(23010399003)(7416014)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(921020)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KT2GSby9nHTL/Uu7WJHvnJK0iwnl6h9USyMgMa5p2veQvECgsb2BTYT4E+sFyCe27Y1YkYkf2s0aXskbB3hUHiScCOzL14paFzl27BufWpJvaGEkTU6ghhMKopW1XbFSqW6Vxl1+AmrIjnPwlNnSr9oYy+03sSHqhWL69RpTCPrf/MvOsGZGmEfdDozEqmtr8uJBOicmKgamN0CaGhdM008BogO1P78PoPSU+W2EqfphMi5QPC3NF/94kGrfLZUprWIHqL8q9fVf7qPx7FwHpL5YIwQDwVX4fqX2B8X/ROHjkb5G72LVWEEjjnuNS0LPefF0uRowGq8mjGWwEhX/CiQZWAo7wJCbx/cWxMO7RubaOV5vxinRC2iPErcAW8YTWPL5qPon8YVneNFQQD7jOLRU9K5O3SgKkdk5681OYMOLdsRWnvk1GS6t9zz4czlV X-Exchange-RoutingPolicyChecked: l8E4nlRuWzhgUCx0QXEJXxluWLWJTIW0pBFgc/8fZUXD9Sx6ZgzWTJaUVUgBpXI8pVZl4kniWiynzdKSoHfV9vgCGKRhIj3s16ScHO3+LlZilCAt/kd6Av55Iyn70UgA0NyaTlsV8GMpzjon0L1Pw0AZL0jT9WYs7ncAIhjV4AEMgAYBs8MqvFVBlIx9YWJ/h+YTR3OVCLVLZvC0oS7+w9mJXS9l4XbkCVwh8timTAk+c0N+dVeZ3Y5a+p+iAynVq93MqBIq5O/qfphIfdT0jc0QBfR0HdORW55vgLZ3JoRrZbom9yfMx64bxemWU80FYzaPiSUHRLCmjRVTk9FdBg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:04.1434 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48f348f0-1c36-45c1-eb32-08dee96d683a X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F6B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6547 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX6kkzc/pHyonE psboPjX2B6lt62KwbPyaG3MPOoSRq8nKActkzjl/N9vS5ewzxYfrus5rjnAs63sW0pQp9PnijLQ avLYXmB9bEsYuBqiymBlDcxOOP/83nr3yavMM5KEcParK4BCcYe2SJonQgLiaGJ5dIFDBvhOFyd 0/EEC0VoY5etywEGSmucnIWFzQ7XKfe+MSkOHZyV5olJaZLd4BNL95Ej3F55GC3uDpzvpcXoKoa bgY/FTmMDzdcQKxO+3qBdeAx3mGcYIaxoEuRRW8JYNHbGq4enW23JIoy9tF7mHHAGJk1PmhhyMF DjS+H/oyvU9jEilM22pNFfjhQ3z2toOz+ZFWI4cTQlmqB7xi3IHdx+p5oVeRk5lIeD/J9ebt0Od F4cFoGHbJkxmLwkdm1XDNAhz0FVvhNU9xtd4ZCO/kk4K0xpAhcqp1gflj6koQvjIR9ztU8vewCy ExFFuRLmMBIMLjNb35Q== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX0EjSRLq6TeIg P/5PM15rWfeJIoUWPW2h6dPHaPMIZ35DPHFGITQmAISHAFJ8iTVGV/ux6FxBPZ+p78XLNoeb237 Wg0irGE9fTMmOu3WIcVF77DXeT64ZcY= X-Proofpoint-GUID: KnFCCXyflENfXHw5iBRAELQrO1aMdqXR X-Proofpoint-ORIG-GUID: KnFCCXyflENfXHw5iBRAELQrO1aMdqXR X-Authority-Analysis: v=2.4 cv=C8PZDwP+ c=1 sm=1 tr=0 ts=6a633cd1 cx=c_pps a=HGE+/hAEzspoXCOliImplg==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=8AirrxEcAAAA:8 a=sozttTNsAAAA:8 a=t8SHgtbNc-4yMX3RsRgA:9 a=ST-jHhOKWsTCqRlWije3:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Introduce function pointers in the udma_dev structure to allow variant-specific implementations for certain operations. This prepares the driver for supporting multiple K3 UDMA variants, such as UDMA v2, with minimal code duplication. No functional changes intended in this commit. Reviewed-by: Frank Li Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma-private.c | 10 +++++-- drivers/dma/ti/k3-udma.c | 46 +++++++++++++++++++------------- drivers/dma/ti/k3-udma.h | 12 +++++++++ 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/drivers/dma/ti/k3-udma-private.c b/drivers/dma/ti/k3-udma-priv= ate.c index 624360423ef17..44c097fff5ee6 100644 --- a/drivers/dma/ti/k3-udma-private.c +++ b/drivers/dma/ti/k3-udma-private.c @@ -8,13 +8,19 @@ =20 int xudma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thr= ead) { - return navss_psil_pair(ud, src_thread, dst_thread); + if (ud->psil_pair) + return ud->psil_pair(ud, src_thread, dst_thread); + + return 0; } EXPORT_SYMBOL(xudma_navss_psil_pair); =20 int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, u32 dst_t= hread) { - return navss_psil_unpair(ud, src_thread, dst_thread); + if (ud->psil_unpair) + return ud->psil_unpair(ud, src_thread, dst_thread); + + return 0; } EXPORT_SYMBOL(xudma_navss_psil_unpair); =20 diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 40ba114ac81dd..195ff948548c3 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -40,7 +40,7 @@ static const char * const mmr_names[] =3D { [MMR_TCHANRT] =3D "tchanrt", }; =20 -static int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_th= read) +int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) { struct udma_tisci_rm *tisci_rm =3D &ud->tisci_rm; =20 @@ -50,8 +50,8 @@ static int navss_psil_pair(struct udma_dev *ud, u32 src_t= hread, u32 dst_thread) src_thread, dst_thread); } =20 -static int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, - u32 dst_thread) +int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, + u32 dst_thread) { struct udma_tisci_rm *tisci_rm =3D &ud->tisci_rm; =20 @@ -329,7 +329,7 @@ static int udma_start(struct udma_chan *uc) } =20 /* Make sure that we clear the teardown bit, if it is set */ - udma_reset_chan(uc, false); + uc->ud->reset_chan(uc, false); =20 /* Push descriptors before we start the channel */ udma_start_desc(uc); @@ -521,8 +521,8 @@ static void udma_check_tx_completion(struct work_struct= *work) if (uc->desc) { struct udma_desc *d =3D uc->desc; =20 - udma_decrement_byte_counters(uc, d->residue); - udma_start(uc); + uc->ud->decrement_byte_counters(uc, d->residue); + uc->ud->start(uc); vchan_cookie_complete(&d->vd); break; } @@ -554,7 +554,7 @@ static irqreturn_t udma_ring_irq_handler(int irq, void = *data) } =20 if (!uc->desc) - udma_start(uc); + uc->ud->start(uc); =20 goto out; } @@ -576,8 +576,8 @@ static irqreturn_t udma_ring_irq_handler(int irq, void = *data) vchan_cyclic_callback(&d->vd); } else { if (udma_is_desc_really_done(uc, d)) { - udma_decrement_byte_counters(uc, d->residue); - udma_start(uc); + uc->ud->decrement_byte_counters(uc, d->residue); + uc->ud->start(uc); vchan_cookie_complete(&d->vd); } else { schedule_delayed_work(&uc->tx_drain.work, @@ -612,8 +612,8 @@ static irqreturn_t udma_udma_irq_handler(int irq, void = *data) vchan_cyclic_callback(&d->vd); } else { /* TODO: figure out the real amount of data */ - udma_decrement_byte_counters(uc, d->residue); - udma_start(uc); + uc->ud->decrement_byte_counters(uc, d->residue); + uc->ud->start(uc); vchan_cookie_complete(&d->vd); } } @@ -1654,7 +1654,7 @@ static int udma_alloc_chan_resources(struct dma_chan = *chan) =20 if (udma_is_chan_running(uc)) { dev_warn(ud->dev, "chan%d: is running!\n", uc->id); - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) { dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); ret =3D -EBUSY; @@ -1821,7 +1821,7 @@ static int bcdma_alloc_chan_resources(struct dma_chan= *chan) =20 if (udma_is_chan_running(uc)) { dev_warn(ud->dev, "chan%d: is running!\n", uc->id); - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) { dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); ret =3D -EBUSY; @@ -2014,7 +2014,7 @@ static int pktdma_alloc_chan_resources(struct dma_cha= n *chan) =20 if (udma_is_chan_running(uc)) { dev_warn(ud->dev, "chan%d: is running!\n", uc->id); - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) { dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); ret =3D -EBUSY; @@ -2123,7 +2123,7 @@ static void udma_issue_pending(struct dma_chan *chan) */ if (!(uc->state =3D=3D UDMA_CHAN_IS_TERMINATING && udma_is_chan_running(uc))) - udma_start(uc); + uc->ud->start(uc); } =20 spin_unlock_irqrestore(&uc->vc.lock, flags); @@ -2265,7 +2265,7 @@ static int udma_terminate_all(struct dma_chan *chan) spin_lock_irqsave(&uc->vc.lock, flags); =20 if (udma_is_chan_running(uc)) - udma_stop(uc); + uc->ud->stop(uc); =20 if (uc->desc) { uc->terminated_desc =3D uc->desc; @@ -2297,11 +2297,11 @@ static void udma_synchronize(struct dma_chan *chan) dev_warn(uc->ud->dev, "chan%d teardown timeout!\n", uc->id); udma_dump_chan_stdata(uc); - udma_reset_chan(uc, true); + uc->ud->reset_chan(uc, true); } } =20 - udma_reset_chan(uc, false); + uc->ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) dev_warn(uc->ud->dev, "chan%d refused to stop!\n", uc->id); =20 @@ -2355,7 +2355,7 @@ static void udma_free_chan_resources(struct dma_chan = *chan) =20 udma_terminate_all(chan); if (uc->terminated_desc) { - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); udma_reset_rings(uc); } =20 @@ -3694,6 +3694,14 @@ static int udma_probe(struct platform_device *pdev) ud->soc_data =3D soc->data; } =20 + // Setup function pointers + ud->start =3D udma_start; + ud->stop =3D udma_stop; + ud->reset_chan =3D udma_reset_chan; + ud->decrement_byte_counters =3D udma_decrement_byte_counters; + ud->psil_pair =3D navss_psil_pair; + ud->psil_unpair =3D navss_psil_unpair; + ret =3D udma_get_mmrs(pdev, ud); if (ret) return ret; diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 767b73021390d..16de0b218d8ad 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -348,6 +348,15 @@ struct udma_dev { u32 psil_base; u32 atype; u32 asel; + + int (*start)(struct udma_chan *uc); + int (*stop)(struct udma_chan *uc); + int (*reset_chan)(struct udma_chan *uc, bool hard); + void (*decrement_byte_counters)(struct udma_chan *uc, u32 val); + int (*psil_pair)(struct udma_dev *ud, u32 src_thread, + u32 dst_thread); + int (*psil_unpair)(struct udma_dev *ud, u32 src_thread, + u32 dst_thread); }; =20 struct udma_desc { @@ -618,6 +627,9 @@ int udma_push_to_ring(struct udma_chan *uc, int idx); int udma_pop_from_ring(struct udma_chan *uc, dma_addr_t *addr); void udma_reset_rings(struct udma_chan *uc); =20 +int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); +int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); + /* 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_thr= ead); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 19E3A42BC39; Fri, 24 Jul 2026 10:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888550; cv=fail; b=Y7nzuYMIG6rnP5sgmMMHV+KYgob9KB1zDp3SIfoZPstjkMJFBac48UonnllEvDdPAOfisKXu0nfWu+l1bzFxDLtFcSIGCHBVZVpGyTAGfx6uodK9J79rsw33rIuuF91kW2Bt1R1sn0p7GVmtRjCwXUWqP4+k6jOzNI4ygKfk6MQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888550; c=relaxed/simple; bh=sFwvcjjoMGSRQsXWKnuyW515g66pv1YKYEOiSQftFwo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hOkklQbplYxU8WVBaskZyvvAyKEAyL+3U/wlWlg+kJ8Kwzupb5CbS+xzfR7tvm5W1PwNh6s93LWdsbTpyelYAG0johtrXn/WCkkUZXt4oOG05hCAxjF7nlyQdNqwmoqdLe0kj4TZr83DqwIejJ+2FxbFg7W80M9ZriH4u1RoQUk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=TAyFiw3P; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=qnsrgQsF; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="TAyFiw3P"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="qnsrgQsF" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFTTq1093779; Fri, 24 Jul 2026 05:22:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=zrebkiMGBZNbtJYxl/QbWwqr4JB1gEgZ5kZ3ZpUs4 i8=; b=TAyFiw3Pvpnw8UefXbNxrXnGVANh4UoVcuHrQQxqK/QdGlhEn2Qevb2lJ DENnMkJLAvjHj/sPLQw2eKOkm5y290EfSWi79EHgYuymUEoLZ6ZOF0gkNNoKRXdl nTCrdc0ikGtMlTnP97ZLzITyvhLUy+IOEJBN0g/A3EOio61h31FWvfn2v4HYrT9o L0NwEKK+L0nuEV5WM4uEdN597ljT4oza3xPnj1ASzJwuQS3o1ImjSxcXlBzH8K7C GTPt8CqGVhtW/N8o0uPCNo/SDLmG4Y5U4I2VgZr6+Vpl0EH3fmz1BIzHz6oBlNRv 2nyb/ClYmhl4PxpJH0IGotvWfkqzg== Received: from sn4pr0501cu005.outbound.protection.outlook.com (mail-southcentralusazon11011039.outbound.protection.outlook.com [40.93.194.39]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkyp7j3xh-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:16 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kywPLaFwYNvj40i4WcD2ToXiZDmp2ZaxjBQOwqFtNpKjI0HmxdzEfkD2CQNuEYXxnLBWAZcMuRIlF0An8pAcgBErBr9NPSmaiQ+eXjr6DYoT6KUleKo944fn9BmUGSVHYnENvmaCCASxO6yyfVmrsiyww0sM6iMx61/oNwHSFdyZjrhjq5SEFWansSsd8cUtl64YHd2RKoGFHpN0zUMypItP0m70uOkLJfOdUtGc3NpzjuzGpXKnpk4eJjaT8DeQfTv++LOGPGERs5s+A12WLwbNHvAeXQp7C147sPczDhkAtu7J00H9EBkcc5u1vI6oALPYPBS9r8+/bvzsFfgzzQ== 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=zrebkiMGBZNbtJYxl/QbWwqr4JB1gEgZ5kZ3ZpUs4i8=; b=DXcSdEPJjR0DDh8/2xVvMJXNy52+sDZqJu18Ce/Iv3DCMPbYr0gwgPrNCIMsCWooqcLXSJBMIzvuKH2VAEIYpnTwrE8ZenSgjFTkQDQadV0A8TPeG4OyMlUeg23mSRD5OKRUrXSGnWTnMYgLmVwHYUpOYqTYlTPTr8ngpOT+UHGTZzjpDgdpzJ7x77DyWePfuSHSCoKvPQa+WnLxpFso11E48DrIK1bR1rBe52DsvMv4iV4UioPZjEacNuV6LZnaKz91qLPe2W4sYVNQfII3t1XKlS+Ss44i8pLlDVZfVCXstI1AwDfQzHQwmV7TXBVhB6nR8y7X9VTaTIZKf1De0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zrebkiMGBZNbtJYxl/QbWwqr4JB1gEgZ5kZ3ZpUs4i8=; b=qnsrgQsF3HxOPXs2hPClTWEVwKL33HK7Z0BLZ9HlQqPDq6XIyVBGE6cF9dPIEHhMqGJXjZgkyoPAI8RjYzej8xVwhaWirXCXN6OXk0lArhguND7eB3jdIG+V7Of+hIS8l85UyMJ91LYeLKqMhkhFxIWzhejXyZUuJ3jwXljXxFQ= Received: from MW4P222CA0019.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::24) by CYXPR10MB7976.namprd10.prod.outlook.com (2603:10b6:930:df::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:22:11 +0000 Received: from MWH0EPF000C6194.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::58) by MW4P222CA0019.outlook.office365.com (2603:10b6:303:114::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:22:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by MWH0EPF000C6194.mail.protection.outlook.com (10.167.249.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:10 +0000 Received: from DFLE204.ent.ti.com (10.64.6.62) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:08 -0500 Received: from DFLE208.ent.ti.com (10.64.6.66) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:08 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE208.ent.ti.com (10.64.6.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:08 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFN3017088; Fri, 24 Jul 2026 05:22:04 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 08/19] dmaengine: ti: k3-udma: move udma utility functions to k3-udma-common.c Date: Fri, 24 Jul 2026 15:50:41 +0530 Message-ID: <20260724102115.2854-9-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6194:EE_|CYXPR10MB7976:EE_ X-MS-Office365-Filtering-Correlation-Id: cc25f8c5-a1e1-40f4-666e-08dee96d6be7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|7416014|376014|82310400026|1800799024|921020|6133799003|56012099006|10067099003|5023799004|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: B++kmizM1jYxmfRaXYH3GOdvNsjLEoZ6APBTW+hV+zdlW9c6XGORJ74gc0JTtwiTYJL1Mw4F1BsfW0kdC1laWfqblm3OJjV6KJ7l2ZsH7BalZQxGJVE84hY2rE5TcNG7J4jJMDDMDl/NrpqxXfxqLsF8eolOjJDJeU0TNLn9Jr2cbQbPUPpeMAtVJLM/J402zsB3EOs6T8NHPsdNSPoClnjfqk1BJRD301he3rGVnv2LVmOKE5ZfLNToMtChgGN/hUydYIIt5T6UAWag1wbePO9rKJLJn6FzUU8Il+W4uZUnHsLEGG/H/B52FWg9Nk5tw2HvwfXdSD3onr19RbiqIrL+BmtvwBsLOengQBTe3tSPyVIR4I3DXScIYgZjOn2vCoI9eUvyTbfwGC6/xuHXQujMYELjIcOS8zVNRKYn06C+6bMP+V8oFU3xZ62WbjY75iy6JflWuRdoI0GT6lSBtHhZW3MtpiYH3ryj/JObsyxrTLqGhHzKF3T/NcbPSshlcRK8+2dDtYDs5ZQ03gEZpBiW+//3pCKKb2nWnZtT0w+aUBD9PD035t+JdkCTLePCU6748EahW27jaTwKuRuHu13hsZ1L5Ns6p4oPgTstRKg3wiqaw/dE4wFe5UciZVdB7ln2Hkir5VM1Uf/b7rxeltRWugn1x7yWsPNtXQefGkytuzexoL0YpY0rGyHkyFDaHT4g+WABMgQfknv2BKBH82sB0crbFe6YVCCVjIaobMBmFZgZDcatWFW73APyuSn0 X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(7416014)(376014)(82310400026)(1800799024)(921020)(6133799003)(56012099006)(10067099003)(5023799004)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fm2/t8F6PnAxgmaeJe7tDBCU7skIKF8i36pxPwaQZASGWPu+W8WHLuGDoBGceFniOPeAVWVTfJ5EvO+96vN7YfQ8RKuSR5jkW1c4KvgJ34WYh1En1KgfdQQ2RqmiCybSPBZMQXPXdw5/OxpCUE+a+2l4wqlo5vHA2EiQJBq1qDF8Hi4APu1NKCydI6q9sJpm3+LloFoCCTjj1Y7nJFLmDfK3uwrlt6LPdhPHFATOKscrR43anvzbDGKvuyVj3nJajmWsCozTWj5JBjTgxIxoUa3LmwoDnv0UXMmiIuqW1/TOMHIQw6lf2xwaYTkTlS91QFezJj4I9r2L2RZtZt1MjmvYB0rWMgNi5e2P27rJV8QyQtwgpbxVOjLY3gZd1LXHoZWO1tUxLV4+0Pde9aLm9kPJyCxPxDppsR5+kzCVxbuFjqT+SCt7R64LCMHG6HwJ X-Exchange-RoutingPolicyChecked: jK7oDnensGMd4d8HL4Pw+YQ97husIY09hnuEvfDFtyGbVuvTe++tr2xzbE17NzerdfiVJSbI98hJ26fQvZX1yDccnJxZvB8skN+2vcruu+c/QE/9YSYAmQf8JFzEOHFmRX+QvUXEjzW0Nf/R4Hn54D/To4xmifwHRBM1xHhVLMJrmkP+5dx9PXsGO+K/qCoCmapIn/Twgzgncf/3beZVYOFZH0y+dMp1OEbgGe1fPRKaTl4rPUuJLJPBDApPljeUpNmwhDW1dQYCxBhJMO+QyZ4R8teH/X51dQ04aufE7xaM7MAnLB98YO0ISXFvN2HgQslDExejELzdOqfCecOT/g== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:10.2423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc25f8c5-a1e1-40f4-666e-08dee96d6be7 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6194.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7976 X-Authority-Analysis: v=2.4 cv=M4p97Sws c=1 sm=1 tr=0 ts=6a633cd9 cx=c_pps a=ChtxJ3izA4DGUCEzIvXZbg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=bI_GjgVLxrynCmwSAzAA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX8mFKRnDdFHhK eii1hDuQ8eZT+erIpnqr/6geWszapEZCu1nW+E8GffefHtHhQZF6I9SO4QXs0Zdz8FkJZ5AsKRU 8mxQZv+0WWkXMTCGpW270GXCQRGsKts= X-Proofpoint-ORIG-GUID: rjc1aLqpWskSRTAgPQEVduSMzNaUlZnz X-Proofpoint-GUID: rjc1aLqpWskSRTAgPQEVduSMzNaUlZnz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX5YE9yfGYE837 LdFWPUiHUlYqGKS0b9d2RGMgz11BjIhJaeIOdirWrU0hGbYF8y8NaNF3lKsbi6r1FG8BWSGMpmZ FgHiapl9t4QzGMeomaU6IUCvviP/zKB33XaU6FQWsYPxcUj2vM1oMVSSvk6Fqe35m+jXBkbPNex x1818xnYHIVem0AGiBKFA38RmiXzy/9rZWfhLYferwTZpoUNCODOMdkTReX3RHbJOQxGbwtcJ08 StA4xE2Pw1gctyAtVJH28yBusSE1aEclact4zvxUD2LjeI6uJwjqP08s8jA8xZuRlLZmuB3Rj11 UIoxyhlknXrsujXnPOWhWWnoSe2aXArVXBuSs3nACj9lvL9ezCpmn6plyd88z0aK5IwN2BUdKzC Q2HACjLcmvpzxF+kkgAW6zkvmjf7eUwQaZbW77tYKUptV9wiTIhyaobdiza8cXZUNDw0xC4p/Ss EmCeI//EXHD1JrZNvQA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Relocate udma utility functions from k3-udma.c to 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 --- drivers/dma/ti/k3-udma-common.c | 549 ++++++++++++++++++++++++++++++++ drivers/dma/ti/k3-udma.c | 531 ------------------------------ drivers/dma/ti/k3-udma.h | 28 ++ 3 files changed, 577 insertions(+), 531 deletions(-) diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index fc5e2c99ee28a..01aea77c25715 100644 --- a/drivers/dma/ti/k3-udma-common.c +++ b/drivers/dma/ti/k3-udma-common.c @@ -4,6 +4,7 @@ * Author: Peter Ujfalusi */ =20 +#include #include #include #include @@ -46,6 +47,28 @@ struct udma_desc *udma_udma_desc_from_paddr(struct udma_= chan *uc, } EXPORT_SYMBOL_GPL(udma_udma_desc_from_paddr); =20 +void udma_start_desc(struct udma_chan *uc) +{ + struct udma_chan_config *ucc =3D &uc->config; + + if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA && ucc->pkt_mode && + (uc->cyclic || ucc->dir =3D=3D DMA_DEV_TO_MEM)) { + int i; + + /* + * UDMA only: Push all descriptors to ring for packet mode + * cyclic or RX + * PKTDMA supports pre-linked descriptor and cyclic is not + * supported + */ + for (i =3D 0; i < uc->desc->sglen; i++) + udma_push_to_ring(uc, i); + } else { + udma_push_to_ring(uc, 0); + } +} +EXPORT_SYMBOL_GPL(udma_start_desc); + void udma_free_hwdesc(struct udma_chan *uc, struct udma_desc *d) { if (uc->use_dma_pool) { @@ -1342,5 +1365,531 @@ void udma_reset_rings(struct udma_chan *uc) } EXPORT_SYMBOL_GPL(udma_reset_rings); =20 +u8 udma_get_chan_tpl_index(struct udma_tpl *tpl_map, int chan_id) +{ + int i; + + for (i =3D 0; i < tpl_map->levels; i++) { + if (chan_id >=3D tpl_map->start_idx[i]) + return i; + } + + return 0; +} +EXPORT_SYMBOL_GPL(udma_get_chan_tpl_index); + +void k3_configure_chan_coherency(struct dma_chan *chan, u32 asel) +{ + struct device *chan_dev =3D &chan->dev->device; + + if (asel =3D=3D 0) { + /* No special handling for the channel */ + chan->dev->chan_dma_dev =3D false; + + dev_clear_dma_coherent(chan_dev); + chan_dev->dma_parms =3D NULL; + } else if (asel =3D=3D 14 || asel =3D=3D 15) { + chan->dev->chan_dma_dev =3D true; + + dev_set_dma_coherent(chan_dev); + dma_coerce_mask_and_coherent(chan_dev, DMA_BIT_MASK(48)); + chan_dev->dma_parms =3D chan_dev->parent->dma_parms; + } else { + dev_warn(chan->device->dev, "Invalid ASEL value: %u\n", asel); + + dev_clear_dma_coherent(chan_dev); + chan_dev->dma_parms =3D NULL; + } +} +EXPORT_SYMBOL_GPL(k3_configure_chan_coherency); + +void udma_reset_uchan(struct udma_chan *uc) +{ + memset(&uc->config, 0, sizeof(uc->config)); + uc->config.remote_thread_id =3D -1; + uc->config.mapped_channel_id =3D -1; + uc->config.default_flow_id =3D -1; + uc->state =3D UDMA_CHAN_IS_IDLE; +} +EXPORT_SYMBOL_GPL(udma_reset_uchan); + +void udma_dump_chan_stdata(struct udma_chan *uc) +{ + struct device *dev =3D uc->ud->dev; + u32 offset; + int i; + + if (uc->config.dir =3D=3D DMA_MEM_TO_DEV || uc->config.dir =3D=3D DMA_MEM= _TO_MEM) { + dev_dbg(dev, "TCHAN State data:\n"); + for (i =3D 0; i < 32; i++) { + offset =3D UDMA_CHAN_RT_STDATA_REG + i * 4; + dev_dbg(dev, "TRT_STDATA[%02d]: 0x%08x\n", i, + udma_tchanrt_read(uc, offset)); + } + } + + if (uc->config.dir =3D=3D DMA_DEV_TO_MEM || uc->config.dir =3D=3D DMA_MEM= _TO_MEM) { + dev_dbg(dev, "RCHAN State data:\n"); + for (i =3D 0; i < 32; i++) { + offset =3D UDMA_CHAN_RT_STDATA_REG + i * 4; + dev_dbg(dev, "RRT_STDATA[%02d]: 0x%08x\n", i, + udma_rchanrt_read(uc, offset)); + } + } +} + +bool udma_is_chan_running(struct udma_chan *uc) +{ + u32 trt_ctl =3D 0; + u32 rrt_ctl =3D 0; + + if (uc->tchan) + trt_ctl =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_CTL_REG); + if (uc->rchan) + rrt_ctl =3D udma_rchanrt_read(uc, UDMA_CHAN_RT_CTL_REG); + + if (trt_ctl & UDMA_CHAN_RT_CTL_EN || rrt_ctl & UDMA_CHAN_RT_CTL_EN) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(udma_is_chan_running); + +bool udma_chan_needs_reconfiguration(struct udma_chan *uc) +{ + /* Only PDMAs have staticTR */ + if (uc->config.ep_type =3D=3D PSIL_EP_NATIVE) + return false; + + /* Check if the staticTR configuration has changed for TX */ + if (memcmp(&uc->static_tr, &uc->desc->static_tr, sizeof(uc->static_tr))) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(udma_chan_needs_reconfiguration); + +void udma_cyclic_packet_elapsed(struct udma_chan *uc) +{ + struct udma_desc *d =3D uc->desc; + struct cppi5_host_desc_t *h_desc; + + h_desc =3D d->hwdesc[d->desc_idx].cppi5_desc_vaddr; + cppi5_hdesc_reset_to_original(h_desc); + udma_push_to_ring(uc, d->desc_idx); + d->desc_idx =3D (d->desc_idx + 1) % d->sglen; +} +EXPORT_SYMBOL_GPL(udma_cyclic_packet_elapsed); + +void udma_check_tx_completion(struct work_struct *work) +{ + struct udma_chan *uc =3D container_of(work, typeof(*uc), + tx_drain.work.work); + bool desc_done =3D true; + u32 residue_diff; + ktime_t time_diff; + unsigned long delay; + unsigned long flags; + + while (1) { + spin_lock_irqsave(&uc->vc.lock, flags); + + if (uc->desc) { + /* Get previous residue and time stamp */ + residue_diff =3D uc->tx_drain.residue; + time_diff =3D uc->tx_drain.tstamp; + /* + * Get current residue and time stamp or see if + * transfer is complete + */ + desc_done =3D udma_is_desc_really_done(uc, uc->desc); + } + + if (!desc_done) { + /* + * Find the time delta and residue delta w.r.t + * previous poll + */ + time_diff =3D ktime_sub(uc->tx_drain.tstamp, + time_diff) + 1; + residue_diff -=3D uc->tx_drain.residue; + if (residue_diff) { + /* + * Try to guess when we should check + * next time by calculating rate at + * which data is being drained at the + * peer device + */ + delay =3D (time_diff / residue_diff) * + uc->tx_drain.residue; + } else { + /* No progress, check again in 1 second */ + schedule_delayed_work(&uc->tx_drain.work, HZ); + break; + } + + spin_unlock_irqrestore(&uc->vc.lock, flags); + + usleep_range(ktime_to_us(delay), + ktime_to_us(delay) + 10); + continue; + } + + if (uc->desc) { + struct udma_desc *d =3D uc->desc; + + uc->ud->decrement_byte_counters(uc, d->residue); + uc->ud->start(uc); + vchan_cookie_complete(&d->vd); + break; + } + + break; + } + + spin_unlock_irqrestore(&uc->vc.lock, flags); +} +EXPORT_SYMBOL_GPL(udma_check_tx_completion); + +int udma_slave_config(struct dma_chan *chan, + struct dma_slave_config *cfg) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + + memcpy(&uc->cfg, cfg, sizeof(uc->cfg)); + + return 0; +} +EXPORT_SYMBOL_GPL(udma_slave_config); + +void udma_issue_pending(struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + unsigned long flags; + + spin_lock_irqsave(&uc->vc.lock, flags); + + /* If we have something pending and no active descriptor, then */ + if (vchan_issue_pending(&uc->vc) && !uc->desc) { + /* + * start a descriptor if the channel is NOT [marked as + * terminating _and_ it is still running (teardown has not + * completed yet)]. + */ + if (!(uc->state =3D=3D UDMA_CHAN_IS_TERMINATING && + udma_is_chan_running(uc))) + uc->ud->start(uc); + } + + spin_unlock_irqrestore(&uc->vc.lock, flags); +} +EXPORT_SYMBOL_GPL(udma_issue_pending); + +int udma_terminate_all(struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + unsigned long flags; + LIST_HEAD(head); + + spin_lock_irqsave(&uc->vc.lock, flags); + + if (udma_is_chan_running(uc)) + uc->ud->stop(uc); + + if (uc->desc) { + uc->terminated_desc =3D uc->desc; + uc->desc =3D NULL; + uc->terminated_desc->terminated =3D true; + cancel_delayed_work(&uc->tx_drain.work); + } + + uc->paused =3D false; + + vchan_get_all_descriptors(&uc->vc, &head); + spin_unlock_irqrestore(&uc->vc.lock, flags); + vchan_dma_desc_free_list(&uc->vc, &head); + + return 0; +} +EXPORT_SYMBOL_GPL(udma_terminate_all); + +void udma_synchronize(struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + unsigned long timeout =3D msecs_to_jiffies(1000); + + vchan_synchronize(&uc->vc); + + if (uc->state =3D=3D UDMA_CHAN_IS_TERMINATING) { + timeout =3D wait_for_completion_timeout(&uc->teardown_completed, + timeout); + if (!timeout) { + dev_warn(uc->ud->dev, "chan%d teardown timeout!\n", + uc->id); + udma_dump_chan_stdata(uc); + uc->ud->reset_chan(uc, true); + } + } + + uc->ud->reset_chan(uc, false); + if (udma_is_chan_running(uc)) + dev_warn(uc->ud->dev, "chan%d refused to stop!\n", uc->id); + + cancel_delayed_work_sync(&uc->tx_drain.work); + udma_reset_rings(uc); +} +EXPORT_SYMBOL_GPL(udma_synchronize); + +/* + * This tasklet handles the completion of a DMA descriptor by + * calling its callback and freeing it. + */ +void udma_vchan_complete(struct tasklet_struct *t) +{ + struct virt_dma_chan *vc =3D from_tasklet(vc, t, task); + struct virt_dma_desc *vd, *_vd; + struct dmaengine_desc_callback cb; + LIST_HEAD(head); + + spin_lock_irq(&vc->lock); + list_splice_tail_init(&vc->desc_completed, &head); + vd =3D vc->cyclic; + if (vd) { + vc->cyclic =3D NULL; + dmaengine_desc_get_callback(&vd->tx, &cb); + } else { + memset(&cb, 0, sizeof(cb)); + } + spin_unlock_irq(&vc->lock); + + udma_desc_pre_callback(vc, vd, NULL); + dmaengine_desc_callback_invoke(&cb, NULL); + + list_for_each_entry_safe(vd, _vd, &head, node) { + struct dmaengine_result result; + + dmaengine_desc_get_callback(&vd->tx, &cb); + + list_del(&vd->node); + + udma_desc_pre_callback(vc, vd, &result); + dmaengine_desc_callback_invoke(&cb, &result); + + vchan_vdesc_fini(vd); + } +} +EXPORT_SYMBOL_GPL(udma_vchan_complete); + +void udma_mark_resource_ranges(struct udma_dev *ud, unsigned long *map, + struct ti_sci_resource_desc *rm_desc, + char *name) +{ + bitmap_clear(map, rm_desc->start, rm_desc->num); + bitmap_clear(map, rm_desc->start_sec, rm_desc->num_sec); + dev_dbg(ud->dev, "ti_sci resource range for %s: %d:%d | %d:%d\n", name, + rm_desc->start, rm_desc->num, rm_desc->start_sec, + rm_desc->num_sec); +} +EXPORT_SYMBOL_GPL(udma_mark_resource_ranges); + +int udma_setup_rx_flush(struct udma_dev *ud) +{ + struct udma_rx_flush *rx_flush =3D &ud->rx_flush; + struct cppi5_desc_hdr_t *tr_desc; + struct cppi5_tr_type1_t *tr_req; + struct cppi5_host_desc_t *desc; + struct device *dev =3D ud->dev; + struct udma_hwdesc *hwdesc; + size_t tr_size; + + /* Allocate 1K buffer for discarded data on RX channel teardown */ + rx_flush->buffer_size =3D SZ_1K; + rx_flush->buffer_vaddr =3D devm_kzalloc(dev, rx_flush->buffer_size, + GFP_KERNEL); + if (!rx_flush->buffer_vaddr) + return -ENOMEM; + + rx_flush->buffer_paddr =3D dma_map_single(dev, rx_flush->buffer_vaddr, + rx_flush->buffer_size, + DMA_TO_DEVICE); + if (dma_mapping_error(dev, rx_flush->buffer_paddr)) + return -ENOMEM; + + /* Set up descriptor to be used for TR mode */ + hwdesc =3D &rx_flush->hwdescs[0]; + tr_size =3D sizeof(struct cppi5_tr_type1_t); + hwdesc->cppi5_desc_size =3D cppi5_trdesc_calc_size(tr_size, 1); + hwdesc->cppi5_desc_size =3D ALIGN(hwdesc->cppi5_desc_size, + ud->desc_align); + + hwdesc->cppi5_desc_vaddr =3D devm_kzalloc(dev, hwdesc->cppi5_desc_size, + GFP_KERNEL); + if (!hwdesc->cppi5_desc_vaddr) + return -ENOMEM; + + hwdesc->cppi5_desc_paddr =3D dma_map_single(dev, hwdesc->cppi5_desc_vaddr, + hwdesc->cppi5_desc_size, + DMA_TO_DEVICE); + if (dma_mapping_error(dev, hwdesc->cppi5_desc_paddr)) + return -ENOMEM; + + /* Start of the TR req records */ + hwdesc->tr_req_base =3D hwdesc->cppi5_desc_vaddr + tr_size; + /* Start address of the TR response array */ + hwdesc->tr_resp_base =3D hwdesc->tr_req_base + tr_size; + + tr_desc =3D hwdesc->cppi5_desc_vaddr; + cppi5_trdesc_init(tr_desc, 1, tr_size, 0, 0); + cppi5_desc_set_pktids(tr_desc, 0, CPPI5_INFO1_DESC_FLOWID_DEFAULT); + cppi5_desc_set_retpolicy(tr_desc, 0, 0); + + tr_req =3D hwdesc->tr_req_base; + cppi5_tr_init(&tr_req->flags, CPPI5_TR_TYPE1, false, false, + CPPI5_TR_EVENT_SIZE_COMPLETION, 0); + cppi5_tr_csf_set(&tr_req->flags, CPPI5_TR_CSF_SUPR_EVT); + + tr_req->addr =3D rx_flush->buffer_paddr; + tr_req->icnt0 =3D rx_flush->buffer_size; + tr_req->icnt1 =3D 1; + + dma_sync_single_for_device(dev, hwdesc->cppi5_desc_paddr, + hwdesc->cppi5_desc_size, DMA_TO_DEVICE); + + /* Set up descriptor to be used for packet mode */ + hwdesc =3D &rx_flush->hwdescs[1]; + hwdesc->cppi5_desc_size =3D ALIGN(sizeof(struct cppi5_host_desc_t) + + CPPI5_INFO0_HDESC_EPIB_SIZE + + CPPI5_INFO0_HDESC_PSDATA_MAX_SIZE, + ud->desc_align); + + hwdesc->cppi5_desc_vaddr =3D devm_kzalloc(dev, hwdesc->cppi5_desc_size, + GFP_KERNEL); + if (!hwdesc->cppi5_desc_vaddr) + return -ENOMEM; + + hwdesc->cppi5_desc_paddr =3D dma_map_single(dev, hwdesc->cppi5_desc_vaddr, + hwdesc->cppi5_desc_size, + DMA_TO_DEVICE); + if (dma_mapping_error(dev, hwdesc->cppi5_desc_paddr)) + return -ENOMEM; + + desc =3D hwdesc->cppi5_desc_vaddr; + cppi5_hdesc_init(desc, 0, 0); + cppi5_desc_set_pktids(&desc->hdr, 0, CPPI5_INFO1_DESC_FLOWID_DEFAULT); + cppi5_desc_set_retpolicy(&desc->hdr, 0, 0); + + cppi5_hdesc_attach_buf(desc, + rx_flush->buffer_paddr, rx_flush->buffer_size, + rx_flush->buffer_paddr, rx_flush->buffer_size); + + dma_sync_single_for_device(dev, hwdesc->cppi5_desc_paddr, + hwdesc->cppi5_desc_size, DMA_TO_DEVICE); + return 0; +} +EXPORT_SYMBOL_GPL(udma_setup_rx_flush); + +#ifdef CONFIG_DEBUG_FS +void udma_dbg_summary_show_chan(struct seq_file *s, + struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + struct udma_chan_config *ucc =3D &uc->config; + + seq_printf(s, " %-13s| %s", dma_chan_name(chan), + chan->dbg_client_name ?: "in-use"); + if (ucc->tr_trigger_type) + seq_puts(s, " (triggered, "); + else + seq_printf(s, " (%s, ", + dmaengine_get_direction_text(uc->config.dir)); + + switch (uc->config.dir) { + case DMA_MEM_TO_MEM: + if (uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { + seq_printf(s, "bchan%d)\n", uc->bchan->id); + return; + } + + seq_printf(s, "chan%d pair [0x%04x -> 0x%04x], ", uc->tchan->id, + ucc->src_thread, ucc->dst_thread); + break; + case DMA_DEV_TO_MEM: + seq_printf(s, "rchan%d [0x%04x -> 0x%04x], ", uc->rchan->id, + ucc->src_thread, ucc->dst_thread); + if (uc->ud->match_data->type =3D=3D DMA_TYPE_PKTDMA) + seq_printf(s, "rflow%d, ", uc->rflow->id); + break; + case DMA_MEM_TO_DEV: + seq_printf(s, "tchan%d [0x%04x -> 0x%04x], ", uc->tchan->id, + ucc->src_thread, ucc->dst_thread); + if (uc->ud->match_data->type =3D=3D DMA_TYPE_PKTDMA) + seq_printf(s, "tflow%d, ", uc->tchan->tflow_id); + break; + default: + seq_puts(s, ")\n"); + return; + } + + if (ucc->ep_type =3D=3D PSIL_EP_NATIVE) { + seq_puts(s, "PSI-L Native"); + if (ucc->metadata_size) { + seq_printf(s, "[%s", ucc->needs_epib ? " EPIB" : ""); + if (ucc->psd_size) + seq_printf(s, " PSDsize:%u", ucc->psd_size); + seq_puts(s, " ]"); + } + } else { + seq_puts(s, "PDMA"); + if (ucc->enable_acc32 || ucc->enable_burst) + seq_printf(s, "[%s%s ]", + ucc->enable_acc32 ? " ACC32" : "", + ucc->enable_burst ? " BURST" : ""); + } + + seq_printf(s, ", %s)\n", ucc->pkt_mode ? "Packet mode" : "TR mode"); +} + +void udma_dbg_summary_show(struct seq_file *s, + struct dma_device *dma_dev) +{ + struct dma_chan *chan; + + list_for_each_entry(chan, &dma_dev->channels, device_node) { + if (chan->client_count) + udma_dbg_summary_show_chan(s, chan); + } +} +EXPORT_SYMBOL_GPL(udma_dbg_summary_show); +#endif /* CONFIG_DEBUG_FS */ + +enum dmaengine_alignment udma_get_copy_align(struct udma_dev *ud) +{ + const struct udma_match_data *match_data =3D ud->match_data; + u8 tpl; + + if (!match_data->enable_memcpy_support) + return DMAENGINE_ALIGN_8_BYTES; + + /* Get the highest TPL level the device supports for memcpy */ + if (ud->bchan_cnt) + tpl =3D udma_get_chan_tpl_index(&ud->bchan_tpl, 0); + else if (ud->tchan_cnt) + tpl =3D udma_get_chan_tpl_index(&ud->tchan_tpl, 0); + else + return DMAENGINE_ALIGN_8_BYTES; + + switch (match_data->burst_size[tpl]) { + case TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_256_BYTES: + return DMAENGINE_ALIGN_256_BYTES; + case TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_128_BYTES: + return DMAENGINE_ALIGN_128_BYTES; + case TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_64_BYTES: + fallthrough; + default: + return DMAENGINE_ALIGN_64_BYTES; + } +} +EXPORT_SYMBOL_GPL(udma_get_copy_align); + 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 195ff948548c3..89c887bc86a34 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -61,92 +61,6 @@ int navss_psil_unpair(struct udma_dev *ud, u32 src_threa= d, src_thread, dst_thread); } =20 -static void k3_configure_chan_coherency(struct dma_chan *chan, u32 asel) -{ - struct device *chan_dev =3D &chan->dev->device; - - if (asel =3D=3D 0) { - /* No special handling for the channel */ - chan->dev->chan_dma_dev =3D false; - - dev_clear_dma_coherent(chan_dev); - chan_dev->dma_parms =3D NULL; - } else if (asel =3D=3D 14 || asel =3D=3D 15) { - chan->dev->chan_dma_dev =3D true; - - dev_set_dma_coherent(chan_dev); - dma_coerce_mask_and_coherent(chan_dev, DMA_BIT_MASK(48)); - chan_dev->dma_parms =3D chan_dev->parent->dma_parms; - } else { - dev_warn(chan->device->dev, "Invalid ASEL value: %u\n", asel); - - dev_clear_dma_coherent(chan_dev); - chan_dev->dma_parms =3D NULL; - } -} - -static u8 udma_get_chan_tpl_index(struct udma_tpl *tpl_map, int chan_id) -{ - int i; - - for (i =3D 0; i < tpl_map->levels; i++) { - if (chan_id >=3D tpl_map->start_idx[i]) - return i; - } - - return 0; -} - -static void udma_reset_uchan(struct udma_chan *uc) -{ - memset(&uc->config, 0, sizeof(uc->config)); - uc->config.remote_thread_id =3D -1; - uc->config.mapped_channel_id =3D -1; - uc->config.default_flow_id =3D -1; - uc->state =3D UDMA_CHAN_IS_IDLE; -} - -static void udma_dump_chan_stdata(struct udma_chan *uc) -{ - struct device *dev =3D uc->ud->dev; - u32 offset; - int i; - - if (uc->config.dir =3D=3D DMA_MEM_TO_DEV || uc->config.dir =3D=3D DMA_MEM= _TO_MEM) { - dev_dbg(dev, "TCHAN State data:\n"); - for (i =3D 0; i < 32; i++) { - offset =3D UDMA_CHAN_RT_STDATA_REG + i * 4; - dev_dbg(dev, "TRT_STDATA[%02d]: 0x%08x\n", i, - udma_tchanrt_read(uc, offset)); - } - } - - if (uc->config.dir =3D=3D DMA_DEV_TO_MEM || uc->config.dir =3D=3D DMA_MEM= _TO_MEM) { - dev_dbg(dev, "RCHAN State data:\n"); - for (i =3D 0; i < 32; i++) { - offset =3D UDMA_CHAN_RT_STDATA_REG + i * 4; - dev_dbg(dev, "RRT_STDATA[%02d]: 0x%08x\n", i, - udma_rchanrt_read(uc, offset)); - } - } -} - -static bool udma_is_chan_running(struct udma_chan *uc) -{ - u32 trt_ctl =3D 0; - u32 rrt_ctl =3D 0; - - if (uc->tchan) - trt_ctl =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_CTL_REG); - if (uc->rchan) - rrt_ctl =3D udma_rchanrt_read(uc, UDMA_CHAN_RT_CTL_REG); - - if (trt_ctl & UDMA_CHAN_RT_CTL_EN || rrt_ctl & UDMA_CHAN_RT_CTL_EN) - return true; - - return false; -} - static bool udma_is_chan_paused(struct udma_chan *uc) { u32 val, pause_mask; @@ -275,40 +189,6 @@ static int udma_reset_chan(struct udma_chan *uc, bool = hard) return 0; } =20 -static void udma_start_desc(struct udma_chan *uc) -{ - struct udma_chan_config *ucc =3D &uc->config; - - if (uc->ud->match_data->type =3D=3D DMA_TYPE_UDMA && ucc->pkt_mode && - (uc->cyclic || ucc->dir =3D=3D DMA_DEV_TO_MEM)) { - int i; - - /* - * UDMA only: Push all descriptors to ring for packet mode - * cyclic or RX - * PKTDMA supports pre-linked descriptor and cyclic is not - * supported - */ - for (i =3D 0; i < uc->desc->sglen; i++) - udma_push_to_ring(uc, i); - } else { - udma_push_to_ring(uc, 0); - } -} - -static bool udma_chan_needs_reconfiguration(struct udma_chan *uc) -{ - /* Only PDMAs have staticTR */ - if (uc->config.ep_type =3D=3D PSIL_EP_NATIVE) - return false; - - /* Check if the staticTR configuration has changed for TX */ - if (memcmp(&uc->static_tr, &uc->desc->static_tr, sizeof(uc->static_tr))) - return true; - - return false; -} - static int udma_start(struct udma_chan *uc) { struct virt_dma_desc *vd =3D vchan_next_desc(&uc->vc); @@ -453,86 +333,6 @@ static int udma_stop(struct udma_chan *uc) return 0; } =20 -static void udma_cyclic_packet_elapsed(struct udma_chan *uc) -{ - struct udma_desc *d =3D uc->desc; - struct cppi5_host_desc_t *h_desc; - - h_desc =3D d->hwdesc[d->desc_idx].cppi5_desc_vaddr; - cppi5_hdesc_reset_to_original(h_desc); - udma_push_to_ring(uc, d->desc_idx); - d->desc_idx =3D (d->desc_idx + 1) % d->sglen; -} - -static void udma_check_tx_completion(struct work_struct *work) -{ - struct udma_chan *uc =3D container_of(work, typeof(*uc), - tx_drain.work.work); - bool desc_done =3D true; - u32 residue_diff; - ktime_t time_diff; - unsigned long delay; - unsigned long flags; - - while (1) { - spin_lock_irqsave(&uc->vc.lock, flags); - - if (uc->desc) { - /* Get previous residue and time stamp */ - residue_diff =3D uc->tx_drain.residue; - time_diff =3D uc->tx_drain.tstamp; - /* - * Get current residue and time stamp or see if - * transfer is complete - */ - desc_done =3D udma_is_desc_really_done(uc, uc->desc); - } - - if (!desc_done) { - /* - * Find the time delta and residue delta w.r.t - * previous poll - */ - time_diff =3D ktime_sub(uc->tx_drain.tstamp, - time_diff) + 1; - residue_diff -=3D uc->tx_drain.residue; - if (residue_diff) { - /* - * Try to guess when we should check - * next time by calculating rate at - * which data is being drained at the - * peer device - */ - delay =3D (time_diff / residue_diff) * - uc->tx_drain.residue; - } else { - /* No progress, check again in 1 second */ - schedule_delayed_work(&uc->tx_drain.work, HZ); - break; - } - - spin_unlock_irqrestore(&uc->vc.lock, flags); - - usleep_range(ktime_to_us(delay), - ktime_to_us(delay) + 10); - continue; - } - - if (uc->desc) { - struct udma_desc *d =3D uc->desc; - - uc->ud->decrement_byte_counters(uc, d->residue); - uc->ud->start(uc); - vchan_cookie_complete(&d->vd); - break; - } - - break; - } - - spin_unlock_irqrestore(&uc->vc.lock, flags); -} - static irqreturn_t udma_ring_irq_handler(int irq, void *data) { struct udma_chan *uc =3D data; @@ -2097,38 +1897,6 @@ static int pktdma_alloc_chan_resources(struct dma_ch= an *chan) return ret; } =20 -static int udma_slave_config(struct dma_chan *chan, - struct dma_slave_config *cfg) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - - memcpy(&uc->cfg, cfg, sizeof(uc->cfg)); - - return 0; -} - -static void udma_issue_pending(struct dma_chan *chan) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - unsigned long flags; - - spin_lock_irqsave(&uc->vc.lock, flags); - - /* If we have something pending and no active descriptor, then */ - if (vchan_issue_pending(&uc->vc) && !uc->desc) { - /* - * start a descriptor if the channel is NOT [marked as - * terminating _and_ it is still running (teardown has not - * completed yet)]. - */ - if (!(uc->state =3D=3D UDMA_CHAN_IS_TERMINATING && - udma_is_chan_running(uc))) - uc->ud->start(uc); - } - - spin_unlock_irqrestore(&uc->vc.lock, flags); -} - static enum dma_status udma_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *txstate) @@ -2256,98 +2024,6 @@ static int udma_resume(struct dma_chan *chan) return 0; } =20 -static int udma_terminate_all(struct dma_chan *chan) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - unsigned long flags; - LIST_HEAD(head); - - spin_lock_irqsave(&uc->vc.lock, flags); - - if (udma_is_chan_running(uc)) - uc->ud->stop(uc); - - if (uc->desc) { - uc->terminated_desc =3D uc->desc; - uc->desc =3D NULL; - uc->terminated_desc->terminated =3D true; - cancel_delayed_work(&uc->tx_drain.work); - } - - uc->paused =3D false; - - vchan_get_all_descriptors(&uc->vc, &head); - spin_unlock_irqrestore(&uc->vc.lock, flags); - vchan_dma_desc_free_list(&uc->vc, &head); - - return 0; -} - -static void udma_synchronize(struct dma_chan *chan) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - unsigned long timeout =3D msecs_to_jiffies(1000); - - vchan_synchronize(&uc->vc); - - if (uc->state =3D=3D UDMA_CHAN_IS_TERMINATING) { - timeout =3D wait_for_completion_timeout(&uc->teardown_completed, - timeout); - if (!timeout) { - dev_warn(uc->ud->dev, "chan%d teardown timeout!\n", - uc->id); - udma_dump_chan_stdata(uc); - uc->ud->reset_chan(uc, true); - } - } - - uc->ud->reset_chan(uc, false); - if (udma_is_chan_running(uc)) - dev_warn(uc->ud->dev, "chan%d refused to stop!\n", uc->id); - - cancel_delayed_work_sync(&uc->tx_drain.work); - udma_reset_rings(uc); -} - -/* - * This tasklet handles the completion of a DMA descriptor by - * calling its callback and freeing it. - */ -static void udma_vchan_complete(struct tasklet_struct *t) -{ - struct virt_dma_chan *vc =3D from_tasklet(vc, t, task); - struct virt_dma_desc *vd, *_vd; - struct dmaengine_desc_callback cb; - LIST_HEAD(head); - - spin_lock_irq(&vc->lock); - list_splice_tail_init(&vc->desc_completed, &head); - vd =3D vc->cyclic; - if (vd) { - vc->cyclic =3D NULL; - dmaengine_desc_get_callback(&vd->tx, &cb); - } else { - memset(&cb, 0, sizeof(cb)); - } - spin_unlock_irq(&vc->lock); - - udma_desc_pre_callback(vc, vd, NULL); - dmaengine_desc_callback_invoke(&cb, NULL); - - list_for_each_entry_safe(vd, _vd, &head, node) { - struct dmaengine_result result; - - dmaengine_desc_get_callback(&vd->tx, &cb); - - list_del(&vd->node); - - udma_desc_pre_callback(vc, vd, &result); - dmaengine_desc_callback_invoke(&cb, &result); - - vchan_vdesc_fini(vd); - } -} - static void udma_free_chan_resources(struct dma_chan *chan) { struct udma_chan *uc =3D to_udma_chan(chan); @@ -2822,17 +2498,6 @@ static int udma_get_mmrs(struct platform_device *pde= v, struct udma_dev *ud) return 0; } =20 -static void udma_mark_resource_ranges(struct udma_dev *ud, unsigned long *= map, - struct ti_sci_resource_desc *rm_desc, - char *name) -{ - bitmap_clear(map, rm_desc->start, rm_desc->num); - bitmap_clear(map, rm_desc->start_sec, rm_desc->num_sec); - dev_dbg(ud->dev, "ti_sci resource range for %s: %d:%d | %d:%d\n", name, - rm_desc->start, rm_desc->num, rm_desc->start_sec, - rm_desc->num_sec); -} - static const char * const range_names[] =3D { [RM_RANGE_BCHAN] =3D "ti,sci-rm-range-bchan", [RM_RANGE_TCHAN] =3D "ti,sci-rm-range-tchan", @@ -3463,202 +3128,6 @@ static int setup_resources(struct udma_dev *ud) return ch_count; } =20 -static int udma_setup_rx_flush(struct udma_dev *ud) -{ - struct udma_rx_flush *rx_flush =3D &ud->rx_flush; - struct cppi5_desc_hdr_t *tr_desc; - struct cppi5_tr_type1_t *tr_req; - struct cppi5_host_desc_t *desc; - struct device *dev =3D ud->dev; - struct udma_hwdesc *hwdesc; - size_t tr_size; - - /* Allocate 1K buffer for discarded data on RX channel teardown */ - rx_flush->buffer_size =3D SZ_1K; - rx_flush->buffer_vaddr =3D devm_kzalloc(dev, rx_flush->buffer_size, - GFP_KERNEL); - if (!rx_flush->buffer_vaddr) - return -ENOMEM; - - rx_flush->buffer_paddr =3D dma_map_single(dev, rx_flush->buffer_vaddr, - rx_flush->buffer_size, - DMA_TO_DEVICE); - if (dma_mapping_error(dev, rx_flush->buffer_paddr)) - return -ENOMEM; - - /* Set up descriptor to be used for TR mode */ - hwdesc =3D &rx_flush->hwdescs[0]; - tr_size =3D sizeof(struct cppi5_tr_type1_t); - hwdesc->cppi5_desc_size =3D cppi5_trdesc_calc_size(tr_size, 1); - hwdesc->cppi5_desc_size =3D ALIGN(hwdesc->cppi5_desc_size, - ud->desc_align); - - hwdesc->cppi5_desc_vaddr =3D devm_kzalloc(dev, hwdesc->cppi5_desc_size, - GFP_KERNEL); - if (!hwdesc->cppi5_desc_vaddr) - return -ENOMEM; - - hwdesc->cppi5_desc_paddr =3D dma_map_single(dev, hwdesc->cppi5_desc_vaddr, - hwdesc->cppi5_desc_size, - DMA_TO_DEVICE); - if (dma_mapping_error(dev, hwdesc->cppi5_desc_paddr)) - return -ENOMEM; - - /* Start of the TR req records */ - hwdesc->tr_req_base =3D hwdesc->cppi5_desc_vaddr + tr_size; - /* Start address of the TR response array */ - hwdesc->tr_resp_base =3D hwdesc->tr_req_base + tr_size; - - tr_desc =3D hwdesc->cppi5_desc_vaddr; - cppi5_trdesc_init(tr_desc, 1, tr_size, 0, 0); - cppi5_desc_set_pktids(tr_desc, 0, CPPI5_INFO1_DESC_FLOWID_DEFAULT); - cppi5_desc_set_retpolicy(tr_desc, 0, 0); - - tr_req =3D hwdesc->tr_req_base; - cppi5_tr_init(&tr_req->flags, CPPI5_TR_TYPE1, false, false, - CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req->flags, CPPI5_TR_CSF_SUPR_EVT); - - tr_req->addr =3D rx_flush->buffer_paddr; - tr_req->icnt0 =3D rx_flush->buffer_size; - tr_req->icnt1 =3D 1; - - dma_sync_single_for_device(dev, hwdesc->cppi5_desc_paddr, - hwdesc->cppi5_desc_size, DMA_TO_DEVICE); - - /* Set up descriptor to be used for packet mode */ - hwdesc =3D &rx_flush->hwdescs[1]; - hwdesc->cppi5_desc_size =3D ALIGN(sizeof(struct cppi5_host_desc_t) + - CPPI5_INFO0_HDESC_EPIB_SIZE + - CPPI5_INFO0_HDESC_PSDATA_MAX_SIZE, - ud->desc_align); - - hwdesc->cppi5_desc_vaddr =3D devm_kzalloc(dev, hwdesc->cppi5_desc_size, - GFP_KERNEL); - if (!hwdesc->cppi5_desc_vaddr) - return -ENOMEM; - - hwdesc->cppi5_desc_paddr =3D dma_map_single(dev, hwdesc->cppi5_desc_vaddr, - hwdesc->cppi5_desc_size, - DMA_TO_DEVICE); - if (dma_mapping_error(dev, hwdesc->cppi5_desc_paddr)) - return -ENOMEM; - - desc =3D hwdesc->cppi5_desc_vaddr; - cppi5_hdesc_init(desc, 0, 0); - cppi5_desc_set_pktids(&desc->hdr, 0, CPPI5_INFO1_DESC_FLOWID_DEFAULT); - cppi5_desc_set_retpolicy(&desc->hdr, 0, 0); - - cppi5_hdesc_attach_buf(desc, - rx_flush->buffer_paddr, rx_flush->buffer_size, - rx_flush->buffer_paddr, rx_flush->buffer_size); - - dma_sync_single_for_device(dev, hwdesc->cppi5_desc_paddr, - hwdesc->cppi5_desc_size, DMA_TO_DEVICE); - return 0; -} - -#ifdef CONFIG_DEBUG_FS -static void udma_dbg_summary_show_chan(struct seq_file *s, - struct dma_chan *chan) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - struct udma_chan_config *ucc =3D &uc->config; - - seq_printf(s, " %-13s| %s", dma_chan_name(chan), - chan->dbg_client_name ?: "in-use"); - if (ucc->tr_trigger_type) - seq_puts(s, " (triggered, "); - else - seq_printf(s, " (%s, ", - dmaengine_get_direction_text(uc->config.dir)); - - switch (uc->config.dir) { - case DMA_MEM_TO_MEM: - if (uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { - seq_printf(s, "bchan%d)\n", uc->bchan->id); - return; - } - - seq_printf(s, "chan%d pair [0x%04x -> 0x%04x], ", uc->tchan->id, - ucc->src_thread, ucc->dst_thread); - break; - case DMA_DEV_TO_MEM: - seq_printf(s, "rchan%d [0x%04x -> 0x%04x], ", uc->rchan->id, - ucc->src_thread, ucc->dst_thread); - if (uc->ud->match_data->type =3D=3D DMA_TYPE_PKTDMA) - seq_printf(s, "rflow%d, ", uc->rflow->id); - break; - case DMA_MEM_TO_DEV: - seq_printf(s, "tchan%d [0x%04x -> 0x%04x], ", uc->tchan->id, - ucc->src_thread, ucc->dst_thread); - if (uc->ud->match_data->type =3D=3D DMA_TYPE_PKTDMA) - seq_printf(s, "tflow%d, ", uc->tchan->tflow_id); - break; - default: - seq_printf(s, ")\n"); - return; - } - - if (ucc->ep_type =3D=3D PSIL_EP_NATIVE) { - seq_printf(s, "PSI-L Native"); - if (ucc->metadata_size) { - seq_printf(s, "[%s", ucc->needs_epib ? " EPIB" : ""); - if (ucc->psd_size) - seq_printf(s, " PSDsize:%u", ucc->psd_size); - seq_printf(s, " ]"); - } - } else { - seq_printf(s, "PDMA"); - if (ucc->enable_acc32 || ucc->enable_burst) - seq_printf(s, "[%s%s ]", - ucc->enable_acc32 ? " ACC32" : "", - ucc->enable_burst ? " BURST" : ""); - } - - seq_printf(s, ", %s)\n", ucc->pkt_mode ? "Packet mode" : "TR mode"); -} - -static void udma_dbg_summary_show(struct seq_file *s, - struct dma_device *dma_dev) -{ - struct dma_chan *chan; - - list_for_each_entry(chan, &dma_dev->channels, device_node) { - if (chan->client_count) - udma_dbg_summary_show_chan(s, chan); - } -} -#endif /* CONFIG_DEBUG_FS */ - -static enum dmaengine_alignment udma_get_copy_align(struct udma_dev *ud) -{ - const struct udma_match_data *match_data =3D ud->match_data; - u8 tpl; - - if (!match_data->enable_memcpy_support) - return DMAENGINE_ALIGN_8_BYTES; - - /* Get the highest TPL level the device supports for memcpy */ - if (ud->bchan_cnt) - tpl =3D udma_get_chan_tpl_index(&ud->bchan_tpl, 0); - else if (ud->tchan_cnt) - tpl =3D udma_get_chan_tpl_index(&ud->tchan_tpl, 0); - else - return DMAENGINE_ALIGN_8_BYTES; - - switch (match_data->burst_size[tpl]) { - case TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_256_BYTES: - return DMAENGINE_ALIGN_256_BYTES; - case TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_128_BYTES: - return DMAENGINE_ALIGN_128_BYTES; - case TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_64_BYTES: - fallthrough; - default: - return DMAENGINE_ALIGN_64_BYTES; - } -} - static int udma_probe(struct platform_device *pdev) { struct device_node *navss_node =3D pdev->dev.parent->of_node; diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 16de0b218d8ad..4878d13d84ed0 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -629,6 +629,34 @@ void udma_reset_rings(struct udma_chan *uc); =20 int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); +void udma_start_desc(struct udma_chan *uc); +u8 udma_get_chan_tpl_index(struct udma_tpl *tpl_map, int chan_id); +void k3_configure_chan_coherency(struct dma_chan *chan, u32 asel); +void udma_reset_uchan(struct udma_chan *uc); +void udma_dump_chan_stdata(struct udma_chan *uc); +bool udma_is_chan_running(struct udma_chan *uc); + +bool udma_chan_needs_reconfiguration(struct udma_chan *uc); +void udma_cyclic_packet_elapsed(struct udma_chan *uc); +void udma_check_tx_completion(struct work_struct *work); +int udma_slave_config(struct dma_chan *chan, + struct dma_slave_config *cfg); +void udma_issue_pending(struct dma_chan *chan); +int udma_terminate_all(struct dma_chan *chan); +void udma_synchronize(struct dma_chan *chan); +void udma_vchan_complete(struct tasklet_struct *t); +void udma_mark_resource_ranges(struct udma_dev *ud, unsigned long *map, + struct ti_sci_resource_desc *rm_desc, + char *name); +int udma_setup_rx_flush(struct udma_dev *ud); +enum dmaengine_alignment udma_get_copy_align(struct udma_dev *ud); + +#ifdef CONFIG_DEBUG_FS +void udma_dbg_summary_show_chan(struct seq_file *s, + struct dma_chan *chan); +void udma_dbg_summary_show(struct seq_file *s, + struct dma_device *dma_dev); +#endif /* CONFIG_DEBUG_FS */ =20 /* 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_thr= ead); --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 AF7CD4314BA; Fri, 24 Jul 2026 10:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888554; cv=fail; b=Ys+2azBW/NEdLPVoaOZDFMApRjzd4NAhT02V8kDtCq9MBEzJfqd33RMIwd1WoYYMmn/5G2yCWn7Swmgs4B+FBimB22ez/PdoKAunK0uriVfe3EyqQ9HtOh2C96SN5azPVj2AEcoARowk4E+SM0W/N4MZ3eYNSsupc+iS+2uiL5I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888554; c=relaxed/simple; bh=w6xyZI8go91jWeBC5t5GFMFd1VRtnxQRjvIYLx3mlgI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L9srmf7uD+PKm8xzmsqwJMI8s0tKXt4r5s4gv7N3U0t6KhH621tQPR5hJy6z+LlzAi7qpCCLhwr58OMFNY0ImMcr7miFjfulNEkc+L/V7nZVp0Ar9IDdenWZPdG9+/rKkq3daqRjMegufvlUQ5LR3KQfZ8FOj//p3/PZq+FT2CY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=dRrnfQoG; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=k8GAoK+U; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="dRrnfQoG"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="k8GAoK+U" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFjFM785785; Fri, 24 Jul 2026 05:22:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=3ldUeE4iBKzmF8Tbb0OhdK0QI7tIiWjIm4qgipt7M /8=; b=dRrnfQoGgwDk/IVhjRLrHCMrGSdPQ0RgSviXxNncQq8D29Ypqul4xKncn 3wGfGohBlJ1+2GUzRk8nxBRnuNCZhGD6fzM7EmaFQlNSi596vFUb3q/THs61Acp0 khHFWkBkYfzAs6yzbnVmgeH5pCiZTUCMPundU9IorF28+LgPXUdxsYdX81cB6Fgm 9b2IF3QcKoiBujfUgu+Fy7qoStVbs1py6ioW1ytbnRuVpV73RAgVqmAqDNKhyw4o NK97vDslVI5VLtnj2jdD1m2PiVsCDPnN7FDs33aY3PKRosHCS82+I1K+NaZe5Pv7 2q+t19E61j2lNRPz8dzzyGXC+0s/w== Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azon11010027.outbound.protection.outlook.com [52.101.46.27]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fm5p304m2-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:21 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m+Qysa0a3xt/SPTGw4WTjnNpM2OJTLaZfdK4eCRqR6T6ZMsBs1Ow7V3489OjPrmOdB0YltBN5KxkVa7vttSGE3S8yyHEHEDR+eAY87dD40ylusxYV7xH3bdrzFaBPc83VG1D2btO72Mq4E1J2v/U9SMRR7r4a/KXkQKuGIOPP4i5e3JkA6xzCkSSQu3K4elTGCpvZyoAgOs3BnMWfAZziy6pICmwWVfNXggxzx7cRpHu7mGIMNgXDW94FWHpMeuDXUTFB7fMJH8w2+U0aj+EJ++PABdSjFksdu0MhYEXOW5wyhoZPmJ2sQotACPzLfDs3HRyfraI+C5NIBiEfFYmfw== 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=3ldUeE4iBKzmF8Tbb0OhdK0QI7tIiWjIm4qgipt7M/8=; b=JE7wbY6yZN6Hyq/M3amSAIKzbdDIEgoYVgnYMTE4s9gq+grVut1j15KYy5czocTQUHIbjdJg64DBIIpBnfa8rCKfsxGqED6BBiTzNKBw3rgPPoxDiviYDKoFlCLavaeQwtv5Y+1qpWS8pf4KfYyHWF6NjdceDgYzffAKDP4wEJLf/GvCHik1Z+Ys294z84hCnsf3SLseoeeWIudLdPgrQkHzXDQ4P3Uu+AMS4w/S2DxrWEB/wbBWvaKZWcHoNPCRrcHQVy7zRnSDK4MT9s0S/XwepM+rPHKnROo56HyrZwgX52VjFOB0mjCv6NQKlSsYZzkjV+CM/OGa1PubI76S3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3ldUeE4iBKzmF8Tbb0OhdK0QI7tIiWjIm4qgipt7M/8=; b=k8GAoK+Ule4c2LA+fjnxhGpo4EjcUDQX4Zf1hL/6Z+UmNtHEPLKq8uN6SYzW1FYNWxrWBMzI6w8xDZKEBpBGpQZeuff3y+S+pqTT1YGwdNvkAilHDuP8+GI/OPLQ/xbmRCDiyP9US+pysQl10Tk27WLq/FmL7t59/2VQ8Vsn4C4= Received: from CH0PR03CA0111.namprd03.prod.outlook.com (2603:10b6:610:cd::26) by LV0PR10MB997590.namprd10.prod.outlook.com (2603:10b6:408:344::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Fri, 24 Jul 2026 10:22:16 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:cd:cafe::6d) by CH0PR03CA0111.outlook.office365.com (2603:10b6:610:cd::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.12 via Frontend Transport; Fri, 24 Jul 2026 10:22:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:16 +0000 Received: from DLEE205.ent.ti.com (157.170.170.85) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:14 -0500 Received: from DLEE214.ent.ti.com (157.170.170.117) by DLEE205.ent.ti.com (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:13 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:14 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFO3017088; Fri, 24 Jul 2026 05:22:09 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 09/19] dmaengine: ti: k3-udma: move resource management functions to k3-udma-common.c Date: Fri, 24 Jul 2026 15:50:42 +0530 Message-ID: <20260724102115.2854-10-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|LV0PR10MB997590:EE_ X-MS-Office365-Filtering-Correlation-Id: c1e40bd1-9b2d-4f21-5e73-08dee96d6f78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|23010399003|36860700016|921020|6133799003|18002099003|22082099003|56012099006|3023799007|10067099003; X-Microsoft-Antispam-Message-Info: bG67+D6nkX56ACgbQPCo1b0sIAbfWy0TIdqW5ZYYpnPLx23hxm5dcMopu7AawtqPzmX7OjoKlKzlvHQNhzwDC/P0Gzw/ebus7G+hKu3Tnw5BVSktrkujdF/0KUPZ0eDLdih46rHlg9ZxNsoFOTJH2jwuRsZlfSEnv7XcA29Z3Vtzx5pYnA55BRjKw6r7uZ5ZM6CcEenLFGpChkQWbP0bJQT2ErDC0goPZ2HR8RcY6M51GUaqkqOn7s53Z+hfjZ/uGUj2ssvSVmhLLpvgj1E8eVornYHP1J5X2zLEba6Y7/M7CKkuHOYoSWoD4OcvioIDQoE6G24E2Et8OeffBJunysXYvbYUDtdcaNpiRgsLwIVZRiuLfbtxHjqfNQzDt+mQBPlllPow+9MzqsmEdW7y4eirQqPEDycK4iJhHYJFYaNoSL6ZqWFXYxEr1s7V/lBq11zc78Sj+7z5C2LN2beQQwZhXm6WWko68p0hiGBRpS0lOo96SIqD/0Eetr61817yAhnYhNMKUQfQX3Cv6Z2WZaM30O23F1Y+5IQoXfDFCA7pVeI9TToMHLb8ka0E8dWQEujuAiLgD8W3TPOjL4FWuj5fUOyzyTwKUGfc8CaTkhw5tetbFVjx4rU98d2gvH/Bl/dnujWW1ZSlUqqbWEpv4n1ruP9EQB/gs++PcbWQ/OpHyrDiMZcaRL+jxa/Xtaekq60FtbuSjQDn4i8xt8qbubOhSZixI8PdAy3qZ2Qtsj58xhozJ1jNCX79Fuy9r7SQ X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(23010399003)(36860700016)(921020)(6133799003)(18002099003)(22082099003)(56012099006)(3023799007)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uWbEauqna+ubz6yIVpLqJRPbJTZWtJjHlYL1/NtagvrNWgl3dDT6XdusxxDJYeRkKwKA3vlH5LPO5xUQ08Y8B5kevS0OtdFq228r7WpI5+ONFDl5XHQF4rTFAtnQyz6lO3u8qTIlwSDdShDudmVfwY0TQDdycS88tjMaBv6Rg3Y0CRtzY+tmlStGVzhgbLKgIkwrHOWcnZLqxD/6I0PbQKrNWjZhSUyH6a4kE/jrqbd+6dPQHjBq7HYNhARZ9yYQTdqQxQe/vj4lBro20qp4hDRr3mbN+f791+SdfVEHCy94ZEzpP4JoVUBnqgjm3pfsiJ2TehR2cd8F0bqFOySod/lLgHbsi0h3mhv9o0g8y/k4fbV3p+pWs9Ht/QSKE/JMBj333E6Os1Fd5SCLXYUN1mj9Bmysf4vAU8H/ZlL1Fd77GKMhVY0L/ZUFBp/ceWl6 X-Exchange-RoutingPolicyChecked: miEV9sHbfiGDXeLzpowPDdZVBY7IMubIzn2GFxDi1OnQqfmePq8ayuy6Udi4BunhJnlmZKQRcovqrgTKLBXVEoCALeM4duxSYwergeBwEreNLZ/5V0PWaSkZBLoK1sAuRNpX0bzWdrSXh1sPQtm5GnPELy7itVZwlRYmZpRTTjLAw43mDrBAhpMLKA1+EhSYtK80zmnKr5WvoBvVUCNZKMPzG27iO+af6+x7tgrEG5HJjDwN53DYFERHkGu5WrFckStr0JflxGY1O61XZdyzi4rO/uO9pti+bW1KceYHjjNiSSmdKWrP4I5YUnTtjqaZbp2ZZp46yGm3rsxfgcubeA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:16.3112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1e40bd1-9b2d-4f21-5e73-08dee96d6f78 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV0PR10MB997590 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX5J+NXj0hE8JY hMV67ut/AIkIaFKJuQwf1dD9o+kKElCLKmCnTHr/QG1+UugEm+HHGuH7hmiJ5DWLszNStBJl7BV pFeXw5PfgjRocBgMbjMGMr/sV8+SsBCZeIdutOckEy1etlyIRSVUbXlfxyWIX81j/EEJtu74t5l lvdNHk7Kwl/90FCBRo1ezVm6fq9aITEoAH2kOM0wURMsubib7YXrx/nYD3wwixY8TKpDj4KTneC OSlVl3S5O9ZABXp7YTKpCih4yeX3fFv60VqY034+m8pLkgaLtbvGeqrCZDQYJRThs/rKSWS6WZb Yu1/aFgArOzzdHP3owt/wFJpvCtvWX9JoFuAAJku6CVxDM8V5SjUBAtyIIZ5RJeoBTy/WDr2j02 uxLXkzI7Dg1k7eA6JpwdGrGHvtsvZyxI0eZnQwWLvO06DaF8O+diFiX5aVduyE28TEwSZNNWhdK i3VqX2igGHs6phx69SA== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX5wEKhS7aDp/U qAjLJRtB+KxGlhnVPyaIEKehJ7zV3HDAHMDlieGLG+42cW03x9dhzmg/w477nMRm9Gd6KQJhtLG MMlYpoALwV3e/RyHs2hx/gVPV1AZgmA= X-Proofpoint-GUID: GbJ3KRobmzxnoyU-HsA9tVdpbknvGDQO X-Proofpoint-ORIG-GUID: GbJ3KRobmzxnoyU-HsA9tVdpbknvGDQO X-Authority-Analysis: v=2.4 cv=C8PZDwP+ c=1 sm=1 tr=0 ts=6a633cdd cx=c_pps a=g+XQapjYtrKCWQI10hurPg==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=AMbNDxq4J1R_ZtRBPm4A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" 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 --- drivers/dma/ti/k3-udma-common.c | 442 ++++++++++++++++++++++++++++++++ drivers/dma/ti/k3-udma.c | 423 ------------------------------ drivers/dma/ti/k3-udma.h | 21 ++ 3 files changed, 463 insertions(+), 423 deletions(-) diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index 01aea77c25715..472903e7d1a9f 100644 --- a/drivers/dma/ti/k3-udma-common.c +++ b/drivers/dma/ti/k3-udma-common.c @@ -1891,5 +1891,447 @@ enum dmaengine_alignment udma_get_copy_align(struct= udma_dev *ud) } EXPORT_SYMBOL_GPL(udma_get_copy_align); =20 +/** + * __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 reques= ted + * only using explicit flow id number. if @from is set to -1 it will try t= o find + * first free range. if @from is positive value it will force allocation o= nly + * 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 =3D from; + if (tmp_from < 0) + tmp_from =3D 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 =3D bitmap_find_next_zero_area(tmp, + ud->rflow_cnt, + tmp_from, cnt, 0); + if (start >=3D ud->rflow_cnt) + return -ENOMEM; + + if (from >=3D 0 && start !=3D 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 >=3D 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 >=3D 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 >=3D ud->res##_tpl.levels) \ + tpl =3D ud->res##_tpl.levels - 1; \ + \ + start =3D ud->res##_tpl.start_idx[tpl]; \ + \ + id =3D find_next_zero_bit(ud->res##_map, ud->res##_cnt, \ + start); \ + if (id =3D=3D 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 =3D 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 =3D __udma_reserve_tchan(ud, uc->config.channel_tpl, + uc->config.mapped_channel_id); + if (IS_ERR(uc->tchan)) { + ret =3D PTR_ERR(uc->tchan); + uc->tchan =3D NULL; + return ret; + } + + if (ud->tflow_cnt) { + int tflow_id; + + /* Only PKTDMA have support for tx flows */ + if (uc->config.default_flow_id >=3D 0) + tflow_id =3D uc->config.default_flow_id; + else + tflow_id =3D 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 =3D NULL; + return -ENOENT; + } + + uc->tchan->tflow_id =3D tflow_id; + set_bit(tflow_id, ud->tflow_map); + } else { + uc->tchan->tflow_id =3D -1; + } + + return 0; +} +EXPORT_SYMBOL_GPL(udma_get_tchan); + +int udma_get_rchan(struct udma_chan *uc) +{ + struct udma_dev *ud =3D 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 =3D __udma_reserve_rchan(ud, uc->config.channel_tpl, + uc->config.mapped_channel_id); + if (IS_ERR(uc->rchan)) { + ret =3D PTR_ERR(uc->rchan); + uc->rchan =3D NULL; + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(udma_get_rchan); + +int udma_get_chan_pair(struct udma_chan *uc) +{ + struct udma_dev *ud =3D uc->ud; + int chan_id, end; + + if ((uc->tchan && uc->rchan) && uc->tchan->id =3D=3D 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 =3D 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 =3D 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 =3D=3D end) + return -ENOENT; + + set_bit(chan_id, ud->tchan_map); + set_bit(chan_id, ud->rchan_map); + uc->tchan =3D &ud->tchans[chan_id]; + uc->rchan =3D &ud->rchans[chan_id]; + + /* UDMA does not use tx flows */ + uc->tchan->tflow_id =3D -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 =3D 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 =3D __udma_get_rflow(ud, flow_id); + if (IS_ERR(uc->rflow)) { + ret =3D PTR_ERR(uc->rflow); + uc->rflow =3D NULL; + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(udma_get_rflow); + +void udma_put_rchan(struct udma_chan *uc) +{ + struct udma_dev *ud =3D 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 =3D NULL; + } +} +EXPORT_SYMBOL_GPL(udma_put_rchan); + +void udma_put_tchan(struct udma_chan *uc) +{ + struct udma_dev *ud =3D 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 >=3D 0) + clear_bit(uc->tchan->tflow_id, ud->tflow_map); + + uc->tchan =3D NULL; + } +} +EXPORT_SYMBOL_GPL(udma_put_tchan); + +void udma_put_rflow(struct udma_chan *uc) +{ + struct udma_dev *ud =3D 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 =3D 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 =3D NULL; + uc->tchan->tc_ring =3D 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 =3D uc->rflow; + + k3_ringacc_ring_free(rflow->fd_ring); + k3_ringacc_ring_free(rflow->r_ring); + rflow->fd_ring =3D NULL; + rflow->r_ring =3D 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 =3D to_udma_chan(chan); + struct udma_dev *ud =3D 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 =3D 0; + } + if (uc->irq_num_udma > 0) { + free_irq(uc->irq_num_udma, uc); + + uc->irq_num_udma =3D 0; + } + + /* Release PSI-L pairing */ + if (uc->psil_paired && ud->psil_unpair) { + ud->psil_unpair(ud, uc->config.src_thread, + uc->config.dst_thread); + uc->psil_paired =3D 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 =3D false; + } +} +EXPORT_SYMBOL_GPL(udma_free_chan_resources); + +void bcdma_put_bchan(struct udma_chan *uc) +{ + struct udma_dev *ud =3D 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 =3D NULL; + uc->tchan =3D 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 =3D NULL; + uc->bchan->t_ring =3D 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 89c887bc86a34..753acf1e13fa2 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, voi= d *data) return IRQ_HANDLED; } =20 -/** - * __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 reques= ted - * only using explicit flow id number. if @from is set to -1 it will try t= o find - * first free range. if @from is positive value it will force allocation o= nly - * 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 =3D from; - if (tmp_from < 0) - tmp_from =3D 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 =3D bitmap_find_next_zero_area(tmp, - ud->rflow_cnt, - tmp_from, cnt, 0); - if (start >=3D ud->rflow_cnt) - return -ENOMEM; - - if (from >=3D 0 && start !=3D 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 c= nt) -{ - 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 >=3D 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 >=3D 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 >=3D ud->res##_tpl.levels) \ - tpl =3D ud->res##_tpl.levels - 1; \ - \ - start =3D ud->res##_tpl.start_idx[tpl]; \ - \ - id =3D find_next_zero_bit(ud->res##_map, ud->res##_cnt, \ - start); \ - if (id =3D=3D 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 =3D uc->ud; @@ -585,223 +456,6 @@ static int bcdma_get_bchan(struct udma_chan *uc) return 0; } =20 -static int udma_get_tchan(struct udma_chan *uc) -{ - struct udma_dev *ud =3D 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 =3D __udma_reserve_tchan(ud, uc->config.channel_tpl, - uc->config.mapped_channel_id); - if (IS_ERR(uc->tchan)) { - ret =3D PTR_ERR(uc->tchan); - uc->tchan =3D NULL; - return ret; - } - - if (ud->tflow_cnt) { - int tflow_id; - - /* Only PKTDMA have support for tx flows */ - if (uc->config.default_flow_id >=3D 0) - tflow_id =3D uc->config.default_flow_id; - else - tflow_id =3D 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 =3D NULL; - return -ENOENT; - } - - uc->tchan->tflow_id =3D tflow_id; - set_bit(tflow_id, ud->tflow_map); - } else { - uc->tchan->tflow_id =3D -1; - } - - return 0; -} - -static int udma_get_rchan(struct udma_chan *uc) -{ - struct udma_dev *ud =3D 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 =3D __udma_reserve_rchan(ud, uc->config.channel_tpl, - uc->config.mapped_channel_id); - if (IS_ERR(uc->rchan)) { - ret =3D PTR_ERR(uc->rchan); - uc->rchan =3D NULL; - return ret; - } - - return 0; -} - -static int udma_get_chan_pair(struct udma_chan *uc) -{ - struct udma_dev *ud =3D uc->ud; - int chan_id, end; - - if ((uc->tchan && uc->rchan) && uc->tchan->id =3D=3D 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 =3D 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 =3D 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 =3D=3D end) - return -ENOENT; - - set_bit(chan_id, ud->tchan_map); - set_bit(chan_id, ud->rchan_map); - uc->tchan =3D &ud->tchans[chan_id]; - uc->rchan =3D &ud->rchans[chan_id]; - - /* UDMA does not use tx flows */ - uc->tchan->tflow_id =3D -1; - - return 0; -} - -static int udma_get_rflow(struct udma_chan *uc, int flow_id) -{ - struct udma_dev *ud =3D 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 =3D __udma_get_rflow(ud, flow_id); - if (IS_ERR(uc->rflow)) { - ret =3D PTR_ERR(uc->rflow); - uc->rflow =3D NULL; - return ret; - } - - return 0; -} - -static void bcdma_put_bchan(struct udma_chan *uc) -{ - struct udma_dev *ud =3D 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 =3D NULL; - uc->tchan =3D NULL; - } -} - -static void udma_put_rchan(struct udma_chan *uc) -{ - struct udma_dev *ud =3D 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 =3D NULL; - } -} - -static void udma_put_tchan(struct udma_chan *uc) -{ - struct udma_dev *ud =3D 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 >=3D 0) - clear_bit(uc->tchan->tflow_id, ud->tflow_map); - - uc->tchan =3D NULL; - } -} - -static void udma_put_rflow(struct udma_chan *uc) -{ - struct udma_dev *ud =3D 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 =3D 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 =3D NULL; - uc->bchan->t_ring =3D 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_cha= n *uc) return ret; } =20 -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 =3D NULL; - uc->tchan->tc_ring =3D 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 *u= c) return ret; } =20 -static void udma_free_rx_resources(struct udma_chan *uc) -{ - if (!uc->rchan) - return; - - if (uc->rflow) { - struct udma_rflow *rflow =3D uc->rflow; - - k3_ringacc_ring_free(rflow->fd_ring); - k3_ringacc_ring_free(rflow->r_ring); - rflow->fd_ring =3D NULL; - rflow->r_ring =3D NULL; - - udma_put_rflow(uc); - } - - udma_put_rchan(uc); -} - static int udma_alloc_rx_resources(struct udma_chan *uc) { struct udma_dev *ud =3D uc->ud; @@ -2024,51 +1646,6 @@ static int udma_resume(struct dma_chan *chan) return 0; } =20 -static void udma_free_chan_resources(struct dma_chan *chan) -{ - struct udma_chan *uc =3D to_udma_chan(chan); - struct udma_dev *ud =3D 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 =3D 0; - } - if (uc->irq_num_udma > 0) { - free_irq(uc->irq_num_udma, uc); - - uc->irq_num_udma =3D 0; - } - - /* Release PSI-L pairing */ - if (uc->psil_paired) { - navss_psil_unpair(ud, uc->config.src_thread, - uc->config.dst_thread); - uc->psil_paired =3D 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 =3D 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 4878d13d84ed0..329df7eb156b2 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -658,6 +658,27 @@ void udma_dbg_summary_show(struct seq_file *s, struct dma_device *dma_dev); #endif /* CONFIG_DEBUG_FS */ =20 +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_thr= ead); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 48B14429CE6; Fri, 24 Jul 2026 10:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888561; cv=fail; b=TCqw7lUvkQU2PR/Pjsbt0yb43qcMNmAJ+pHXJEvv3O86O/sFFPrvnNJMEwpzv1z10WG/12m0CgI/UnGo+BTEaMZ4xdvZ72Qczh/eWbfCC9EqU24tUaxLcxK/LUxpGJ1Ec7x7ZRvaW7bIOKXTJa4KjHD9Z8jqYwJOuI4/5NBEJ3w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888561; c=relaxed/simple; bh=/ASIj2OAf33MvmBmekiXhqCoEdwiaHO04J7XA5KNDiY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d9XOS/XlOBrJ7OsstgnbUTYyCkrt6cqa9uOigqogtRT8FNwpG9ONo8xubLyqL7AcgmDQk/U/XOXBfaRZ9quCgrXD2nTx+5uCsfAmSNTngKFCBHrz0PaxQFeD0gMOTzhdVzZ8ZdUg5mG450uzbFWebb9B/MXkLPucV7i2ovGJYxI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=Pleteh+w; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=xPrs1uKJ; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="Pleteh+w"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="xPrs1uKJ" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFZ0D1093922; Fri, 24 Jul 2026 05:22:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=U7nwZjgL9kBHQ0H2OEYNZCM1RxqjOHGIdFHTGse9k 7A=; b=Pleteh+w+tFnNhewJQ1gFLKRmynt5LWg4bwKvu/L6hXOqpsOK9n07szdc 6XBok2qyJ4Hf7z0OBkYOSWc1krCTrxj/uHaKsGfj92Ekb5Z+yClzTMfLtj4rh1Wg 0vLUriJYOS33rMxwaF/LmD4/w+0bbDvGwhlOeED0QTfAWTjXbUMcJoU3Uh3GYEG9 NvkwT0O38ZP2PMuyFaZtlWLYX5UkrKTM6CJDmGdHLL0/xmW98lNlCAPTEQJntITM SXxyFfZ0YjpcqhZbV6WozyYE+VhQBrm4xlBtGzC7MhPZyu9vRXPqd9gzXikxDpOW E8sH9UqP4reM5gBJoATXIQrIg2wqA== Received: from bn8pr05cu002.outbound.protection.outlook.com (mail-eastus2azon11011052.outbound.protection.outlook.com [52.101.57.52]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkyp7j3y6-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:26 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wkwYWh93l5eJ9d8cHSDUoE0wc72hrL/dSJWoLjUOOOgif37kRdAV5fiFZBugU9nPsg1wlcx0KKOf98jM/nHo9y4Zk2V6ugoENMxa15Nlo/L0bg2K6zbRhUd2bR3hxoSp/lHwv2iN70XyJ3AQP+6Q+20b7zc2LexkyxFr/qJoW7S9OMc+Chkz9YCNPcTyppmsGLOdjNvuWQtUIku8QzfTTrcAv0SGZj9l78g+bP5nZKINCBtw10k1vbahxVL4lq3AO9oBTfWafmpWgGjdONYDJjAgJKl9jXceE+t+nJk4o/rlYT6SMJHKnrEk2it3glDMtohNavf8QEhzoUiU49In8Q== 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=U7nwZjgL9kBHQ0H2OEYNZCM1RxqjOHGIdFHTGse9k7A=; b=KbZ+WzgMVvgNO8yVsilx+l81tFIhGky+hppK4R4bdzprY+mKFWdgsg9HamSH40wU/UyFpZUxVRbsdB7A+qsbXhACQl/V3xEw3CwfPdYjl3GnnfeK+Ox9OU0Z01SM9HKn6UiaYBYdjwpoPbO1NKFJpEo48Jkn2tS5INEG7WH2OYMooBSaqVDTEMoMAeJTlxhydF/MnS7EvG6KGWMq72f5e9SvZlWOIE6XghOubuA/Ra7voTuhnT6ChiIvRPbRFaY/HK5XFu8IZQdDAOHScPhbAq1PJT4PXNqa0EljUUSPfCNk989yoGzdoIc7AeZtgf/WeWsyRPhG27vaf7uL574lRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U7nwZjgL9kBHQ0H2OEYNZCM1RxqjOHGIdFHTGse9k7A=; b=xPrs1uKJrL96PSlMxvkXuPcREq66NNtAmLYRlHPS3rscoJgCDSyJ536WFRdg/RUZ7qJIvWfFgEqcAWmARWKcmdX1EPSeBjMzvz/D3maF9FjK100h8DIkI7gD9YSCxNzHCcI/3Qc9eRt4RQE+O3fi9d41O2Ej/l12z7+UvJUOZu8= Received: from BL1PR13CA0131.namprd13.prod.outlook.com (2603:10b6:208:2bb::16) by SJ5PPF7A7588508.namprd10.prod.outlook.com (2603:10b6:a0f:fc02::7aa) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Fri, 24 Jul 2026 10:22:21 +0000 Received: from BL02EPF00021F6C.namprd02.prod.outlook.com (2603:10b6:208:2bb:cafe::3b) by BL1PR13CA0131.outlook.office365.com (2603:10b6:208:2bb::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by BL02EPF00021F6C.mail.protection.outlook.com (10.167.249.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:19 +0000 Received: from DFLE215.ent.ti.com (10.64.6.73) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:19 -0500 Received: from DFLE215.ent.ti.com (10.64.6.73) by DFLE215.ent.ti.com (10.64.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:19 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE215.ent.ti.com (10.64.6.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:19 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFP3017088; Fri, 24 Jul 2026 05:22:14 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 10/19] dmaengine: ti: k3-udma: refactor resource setup functions Date: Fri, 24 Jul 2026 15:50:43 +0530 Message-ID: <20260724102115.2854-11-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00021F6C:EE_|SJ5PPF7A7588508:EE_ X-MS-Office365-Filtering-Correlation-Id: a6f933bc-102a-484d-147c-08dee96d7190 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|7416014|376014|82310400026|1800799024|36860700016|921020|6133799003|56012099006|10067099003|22082099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: ol5l2C2fZe/8vbZtA+7HdMzVJMiwrigaoI7whc8RPo1cwuAgIKKzyOe/5oohMtLd1S+c955+tVyJkdGgkPnTK0p3dLHHUvL4R6RI3tPX329YqPIxmxOT4gODrC+kQjNDtav64akyZGZd1wJQQr53q9kjKi7c1QhuS9D2E+JDvbzg+ObjywwFOh8gwG+6+PRVoIMn0lpTbPgTODVroPlQDn2dqn4Xrq4YoALf3efVU4qUbqdiv1xK89RwucKOWq+s8L7UQ7lnwjGW2t/SxsKspaj9joLUxy9xjlQfnbntPmrk4/R+YlguO7DdkGc+uTeuAn2sBjl+GY4un0hRCgIktrjTv6ZXiaRl/dEH02E6upWKkAZ9lKd/DIqumBt3k8sfBWWs0lYwNkwskDOV978v5O7SW98u+vHAIOGrEYZtHVyM/hL7g/ZPOlDOfA+VcUVEakkNyGRqszhi4JtIt9Ny0BLejvLDI/oAJdF/zRg33nmEWGyNm24c4gKQVfouTEYrDUwUIshidmUqxYOhA8lfPRABm58exoYLCpHtKcwX+HA6Ow/6eF5GGm8ZF8RG27nKzUmrRp4Ze2xpz0zH6oz05Ep44TYsDapzaLydCCaN4mOD7vtX9iVfMn5/hPrDDudhYd2lzJQSi1BcWZUIT1pMIptE60C8f7SBceVx0DfCxKFy44E/gk3vsKZftJqgRtJ4PFkWCWPYEwvJpSq6fRol0wvXvGWdmYOE3GPNG/R+ZQTRKZB18tGtJBiVDNbrYGDC X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(23010399003)(7416014)(376014)(82310400026)(1800799024)(36860700016)(921020)(6133799003)(56012099006)(10067099003)(22082099003)(18002099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZcdNSIR/Y7G/M+ZgtcA2CSNCUUWYU62tJWsm9Nw8cdSc9lXjYeAFKNmdUegGzFWZ0FYF610aXFlR0aT98Sg1FZpTdCzNJzy7TyPEBr239AA50ttcR7UtAdWdZlwo7TwZ1GgxJfgym4kLf384oU3EKgmXF3UrqtZq611YUzmJGCx0KQYgGp6lLQP5rtZe+6vD6h/sh+F0bmPSYL2I8RV2pE5KAmP5IEbuZ1W6HyjNmHLOFlEYotZqp6C0TbjYnRaxw5JIfSlzSdzdgd4QGKI5NIahsJqAhWc46TtjGYFc5ysj7JxmhiDFYzdUkI6hQdnJNwokzwQNzmgBYCuxEJB/09nVepl16gfmGCFbkx0DQV6eZ4lI1jPIKwzHV4YMguNq3TifwvOW3X4Jdfp5hkKUZR8+sxNoy8itHsJtqaGuW+9p4Ce4dKpe/3woGFdkO9pM X-Exchange-RoutingPolicyChecked: qpsybfDKk6mKdhT2w4RXpxJiZE+fLo3ATNTh/A9Rh5HNCVWxZsKQzDvyvht4hpFouGt3S4GcEs/A0/LK44Tl7piYtQUm2Vs5ZY9EXFX+jCeSlvyAUBefDo/hTTKD19/liN+3UdX9xjfMweeUpBrCT4BazbHHX/uETFn3LXLA0tmRV3Jf7R7Nfxvr18ZfJBg8dMFsBB/8i7Vt0MZCr8Xd0HKwNecPSnRubZcurpLRXsKGYqo/9cFgqTBwX5ZjepnyjDfaSqMgFi8ANGR0W2Yxk1wrey+Quhp1E2KkgZEubTH1n9YGxdIK04HtwpXXS6zII4gPqAzb+39QxqxTOw7vBg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:19.7949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a6f933bc-102a-484d-147c-08dee96d7190 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00021F6C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ5PPF7A7588508 X-Authority-Analysis: v=2.4 cv=M4p97Sws c=1 sm=1 tr=0 ts=6a633ce2 cx=c_pps a=TarwAQ2eZTQc/qcP07j9+g==:117 a=tJyPKKxUohctrY4NYmUjkA==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=I_B2hWj7ayHADsQg9NcA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX3+U+C86LhFIQ GCj4FgdvMbG0D8paFrIb+Aanzvvpf9G+HovNQKZAm1OyM4gprJD6mZGedGgLgHwy4XhMXOKbdoh /4cPHUxwkLRxD2kvqggwy9i6IX/MrDQ= X-Proofpoint-ORIG-GUID: 6S048gIZHw2dpm53QrgmyUaIlqb0jfDq X-Proofpoint-GUID: 6S048gIZHw2dpm53QrgmyUaIlqb0jfDq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX8h5/RTkE8BKU 2OiL6//d6BndmJt366TIs4vYCStzUYMXLIMr+LSIAASFlp0EHHgpDFh+O8GDhWg+z0xiW0gQDO6 LTI15ZVHdlRt7Y1ColyiRE30nXuNjjQ3ARW8ZgxLz0XAAQOBt4YEljPcSw5DT63eWQ4dKhR0wQs 8RNQPY1fSiHQsw1qJ2MEaeLDrBYKU80RM6SAPW2flvmFdiT90EbdDTGjdCbQXlrsRU69hXuNVYh frhX2TqljmOVvW6I2b/2HxX3kcnHNDeJDDsrP8NlMUl2K3tl9/8vtEaNFLqJ95Cc9XBMWFFyXgN vPHDW6x10BsNImswVysfuC62wA8Msdtnrx26axSoOzkwmp05UyM6mwrwXvHVVIN31uKy7VmIxTk J0BeV3JWOebBD5TxRZGWmong9fCSwTYZQXN1SiDMoLIV7R1iE/06PLC3DzYBYMyt44/XD5wyUrL U9UkF4Ciodze+pHCyVg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" 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. This refactor improves code reuse and maintainability across multiple variants. No functional changes intended. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma-common.c | 204 ++++++++++++++++++++++++++++++++ drivers/dma/ti/k3-udma.c | 182 +--------------------------- drivers/dma/ti/k3-udma.h | 8 ++ 3 files changed, 218 insertions(+), 176 deletions(-) diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index 472903e7d1a9f..8b2a3be3fa932 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 =20 #include "k3-udma.h" @@ -2333,5 +2335,207 @@ void bcdma_free_bchan_resources(struct udma_chan *u= c) } EXPORT_SYMBOL_GPL(bcdma_free_bchan_resources); =20 +int bcdma_setup_resources(struct udma_dev *ud) +{ + int ret; + struct device *dev =3D ud->dev; + u32 cap; + + /* Set up the throughput level start indexes */ + cap =3D udma_read(ud->mmrs[MMR_GCFG], 0x2c); + if (BCDMA_CAP3_UBCHAN_CNT(cap)) { + ud->bchan_tpl.levels =3D 3; + ud->bchan_tpl.start_idx[1] =3D BCDMA_CAP3_UBCHAN_CNT(cap); + ud->bchan_tpl.start_idx[0] =3D BCDMA_CAP3_HBCHAN_CNT(cap); + } else if (BCDMA_CAP3_HBCHAN_CNT(cap)) { + ud->bchan_tpl.levels =3D 2; + ud->bchan_tpl.start_idx[0] =3D BCDMA_CAP3_HBCHAN_CNT(cap); + } else { + ud->bchan_tpl.levels =3D 1; + } + + cap =3D udma_read(ud->mmrs[MMR_GCFG], 0x30); + if (BCDMA_CAP4_URCHAN_CNT(cap)) { + ud->rchan_tpl.levels =3D 3; + ud->rchan_tpl.start_idx[1] =3D BCDMA_CAP4_URCHAN_CNT(cap); + ud->rchan_tpl.start_idx[0] =3D BCDMA_CAP4_HRCHAN_CNT(cap); + } else if (BCDMA_CAP4_HRCHAN_CNT(cap)) { + ud->rchan_tpl.levels =3D 2; + ud->rchan_tpl.start_idx[0] =3D BCDMA_CAP4_HRCHAN_CNT(cap); + } else { + ud->rchan_tpl.levels =3D 1; + } + + if (BCDMA_CAP4_UTCHAN_CNT(cap)) { + ud->tchan_tpl.levels =3D 3; + ud->tchan_tpl.start_idx[1] =3D BCDMA_CAP4_UTCHAN_CNT(cap); + ud->tchan_tpl.start_idx[0] =3D BCDMA_CAP4_HTCHAN_CNT(cap); + } else if (BCDMA_CAP4_HTCHAN_CNT(cap)) { + ud->tchan_tpl.levels =3D 2; + ud->tchan_tpl.start_idx[0] =3D BCDMA_CAP4_HTCHAN_CNT(cap); + } else { + ud->tchan_tpl.levels =3D 1; + } + + ud->bchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->bchan_cnt), + sizeof(unsigned long), GFP_KERNEL); + ud->bchans =3D devm_kcalloc(dev, ud->bchan_cnt, sizeof(*ud->bchans), + GFP_KERNEL); + ud->tchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), + sizeof(unsigned long), GFP_KERNEL); + ud->tchans =3D devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), + GFP_KERNEL); + ud->rchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), + sizeof(unsigned long), GFP_KERNEL); + ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), + GFP_KERNEL); + /* BCDMA do not really have flows, but the driver expect it */ + ud->rflow_in_use =3D devm_kcalloc(dev, BITS_TO_LONGS(ud->rchan_cnt), + sizeof(unsigned long), + GFP_KERNEL); + ud->rflows =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rflows), + GFP_KERNEL); + + 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) { + ret =3D ud->bcdma_setup_sci_resources(ud); + if (ret) + return ret; + } + + return 0; +} + +int pktdma_setup_resources(struct udma_dev *ud) +{ + int ret; + struct device *dev =3D ud->dev; + u32 cap3; + + /* Set up the throughput level start indexes */ + cap3 =3D udma_read(ud->mmrs[MMR_GCFG], 0x2c); + if (UDMA_CAP3_UCHAN_CNT(cap3)) { + ud->tchan_tpl.levels =3D 3; + ud->tchan_tpl.start_idx[1] =3D UDMA_CAP3_UCHAN_CNT(cap3); + ud->tchan_tpl.start_idx[0] =3D UDMA_CAP3_HCHAN_CNT(cap3); + } else if (UDMA_CAP3_HCHAN_CNT(cap3)) { + ud->tchan_tpl.levels =3D 2; + ud->tchan_tpl.start_idx[0] =3D UDMA_CAP3_HCHAN_CNT(cap3); + } else { + ud->tchan_tpl.levels =3D 1; + } + + ud->rchan_tpl.levels =3D ud->tchan_tpl.levels; + ud->rchan_tpl.start_idx[0] =3D ud->tchan_tpl.start_idx[0]; + ud->rchan_tpl.start_idx[1] =3D ud->tchan_tpl.start_idx[1]; + + ud->tchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), + sizeof(unsigned long), GFP_KERNEL); + ud->tchans =3D devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), + GFP_KERNEL); + ud->rchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), + sizeof(unsigned long), GFP_KERNEL); + ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), + GFP_KERNEL); + ud->rflow_in_use =3D devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt), + sizeof(unsigned long), + GFP_KERNEL); + ud->rflows =3D devm_kcalloc(dev, ud->rflow_cnt, sizeof(*ud->rflows), + GFP_KERNEL); + ud->tflow_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tflow_cnt), + sizeof(unsigned long), 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) { + ret =3D ud->pktdma_setup_sci_resources(ud); + if (ret) + return ret; + } + + return 0; +} + +int setup_resources(struct udma_dev *ud) +{ + struct device *dev =3D ud->dev; + int ch_count, ret; + + switch (ud->match_data->type) { + case DMA_TYPE_UDMA: + ret =3D ud->udma_setup_resources(ud); + break; + case DMA_TYPE_BCDMA: + ret =3D bcdma_setup_resources(ud); + break; + case DMA_TYPE_PKTDMA: + ret =3D pktdma_setup_resources(ud); + break; + default: + return -EINVAL; + } + + if (ret) + return ret; + + ch_count =3D ud->bchan_cnt + ud->tchan_cnt + ud->rchan_cnt; + if (ud->bchan_cnt) + ch_count -=3D bitmap_weight(ud->bchan_map, ud->bchan_cnt); + ch_count -=3D bitmap_weight(ud->tchan_map, ud->tchan_cnt); + ch_count -=3D bitmap_weight(ud->rchan_map, ud->rchan_cnt); + if (!ch_count) + return -ENODEV; + + ud->channels =3D devm_kcalloc(dev, ch_count, sizeof(*ud->channels), + GFP_KERNEL); + 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(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 753acf1e13fa2..d9d6cbda46b2c 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[] =3D { [RM_RANGE_TFLOW] =3D "ti,sci-rm-range-tflow", }; =20 -static int udma_setup_resources(struct udma_dev *ud) +int udma_setup_resources(struct udma_dev *ud) { int ret, i, j; struct device *dev =3D ud->dev; @@ -2245,74 +2245,13 @@ static int udma_setup_resources(struct udma_dev *ud) return 0; } =20 -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 =3D ud->dev; struct ti_sci_resource *rm_res, irq_res; struct udma_tisci_rm *tisci_rm =3D &ud->tisci_rm; const struct udma_oes_offsets *oes =3D &ud->soc_data->oes; - u32 cap; - - /* Set up the throughput level start indexes */ - cap =3D udma_read(ud->mmrs[MMR_GCFG], 0x2c); - if (BCDMA_CAP3_UBCHAN_CNT(cap)) { - ud->bchan_tpl.levels =3D 3; - ud->bchan_tpl.start_idx[1] =3D BCDMA_CAP3_UBCHAN_CNT(cap); - ud->bchan_tpl.start_idx[0] =3D BCDMA_CAP3_HBCHAN_CNT(cap); - } else if (BCDMA_CAP3_HBCHAN_CNT(cap)) { - ud->bchan_tpl.levels =3D 2; - ud->bchan_tpl.start_idx[0] =3D BCDMA_CAP3_HBCHAN_CNT(cap); - } else { - ud->bchan_tpl.levels =3D 1; - } - - cap =3D udma_read(ud->mmrs[MMR_GCFG], 0x30); - if (BCDMA_CAP4_URCHAN_CNT(cap)) { - ud->rchan_tpl.levels =3D 3; - ud->rchan_tpl.start_idx[1] =3D BCDMA_CAP4_URCHAN_CNT(cap); - ud->rchan_tpl.start_idx[0] =3D BCDMA_CAP4_HRCHAN_CNT(cap); - } else if (BCDMA_CAP4_HRCHAN_CNT(cap)) { - ud->rchan_tpl.levels =3D 2; - ud->rchan_tpl.start_idx[0] =3D BCDMA_CAP4_HRCHAN_CNT(cap); - } else { - ud->rchan_tpl.levels =3D 1; - } - - if (BCDMA_CAP4_UTCHAN_CNT(cap)) { - ud->tchan_tpl.levels =3D 3; - ud->tchan_tpl.start_idx[1] =3D BCDMA_CAP4_UTCHAN_CNT(cap); - ud->tchan_tpl.start_idx[0] =3D BCDMA_CAP4_HTCHAN_CNT(cap); - } else if (BCDMA_CAP4_HTCHAN_CNT(cap)) { - ud->tchan_tpl.levels =3D 2; - ud->tchan_tpl.start_idx[0] =3D BCDMA_CAP4_HTCHAN_CNT(cap); - } else { - ud->tchan_tpl.levels =3D 1; - } - - ud->bchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->bchan_cnt), - sizeof(unsigned long), GFP_KERNEL); - ud->bchans =3D devm_kcalloc(dev, ud->bchan_cnt, sizeof(*ud->bchans), - GFP_KERNEL); - ud->tchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), - sizeof(unsigned long), GFP_KERNEL); - ud->tchans =3D devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), - GFP_KERNEL); - ud->rchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), - sizeof(unsigned long), GFP_KERNEL); - ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), - GFP_KERNEL); - /* BCDMA do not really have flows, but the driver expect it */ - ud->rflow_in_use =3D devm_kcalloc(dev, BITS_TO_LONGS(ud->rchan_cnt), - sizeof(unsigned long), - GFP_KERNEL); - ud->rflows =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rflows), - GFP_KERNEL); - - if (!ud->bchan_map || !ud->tchan_map || !ud->rchan_map || - !ud->rflow_in_use || !ud->bchans || !ud->tchans || !ud->rchans || - !ud->rflows) - return -ENOMEM; =20 /* Get resource ranges from tisci */ for (i =3D 0; i < RM_RANGE_LAST; i++) { @@ -2476,51 +2415,13 @@ static int bcdma_setup_resources(struct udma_dev *u= d) return 0; } =20 -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 =3D ud->dev; struct ti_sci_resource *rm_res, irq_res; struct udma_tisci_rm *tisci_rm =3D &ud->tisci_rm; const struct udma_oes_offsets *oes =3D &ud->soc_data->oes; - u32 cap3; - - /* Set up the throughput level start indexes */ - cap3 =3D udma_read(ud->mmrs[MMR_GCFG], 0x2c); - if (UDMA_CAP3_UCHAN_CNT(cap3)) { - ud->tchan_tpl.levels =3D 3; - ud->tchan_tpl.start_idx[1] =3D UDMA_CAP3_UCHAN_CNT(cap3); - ud->tchan_tpl.start_idx[0] =3D UDMA_CAP3_HCHAN_CNT(cap3); - } else if (UDMA_CAP3_HCHAN_CNT(cap3)) { - ud->tchan_tpl.levels =3D 2; - ud->tchan_tpl.start_idx[0] =3D UDMA_CAP3_HCHAN_CNT(cap3); - } else { - ud->tchan_tpl.levels =3D 1; - } - - ud->rchan_tpl.levels =3D ud->tchan_tpl.levels; - ud->rchan_tpl.start_idx[0] =3D ud->tchan_tpl.start_idx[0]; - ud->rchan_tpl.start_idx[1] =3D ud->tchan_tpl.start_idx[1]; - - ud->tchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), - sizeof(unsigned long), GFP_KERNEL); - ud->tchans =3D devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), - GFP_KERNEL); - ud->rchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), - sizeof(unsigned long), GFP_KERNEL); - ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), - GFP_KERNEL); - ud->rflow_in_use =3D devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt), - sizeof(unsigned long), - GFP_KERNEL); - ud->rflows =3D devm_kcalloc(dev, ud->rflow_cnt, sizeof(*ud->rflows), - GFP_KERNEL); - ud->tflow_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tflow_cnt), - sizeof(unsigned long), GFP_KERNEL); - - if (!ud->tchan_map || !ud->rchan_map || !ud->tflow_map || !ud->tchans || - !ud->rchans || !ud->rflows || !ud->rflow_in_use) - return -ENOMEM; =20 /* Get resource ranges from tisci */ for (i =3D 0; i < RM_RANGE_LAST; i++) { @@ -2631,80 +2532,6 @@ static int pktdma_setup_resources(struct udma_dev *u= d) return 0; } =20 -static int setup_resources(struct udma_dev *ud) -{ - struct device *dev =3D ud->dev; - int ch_count, ret; - - switch (ud->match_data->type) { - case DMA_TYPE_UDMA: - ret =3D udma_setup_resources(ud); - break; - case DMA_TYPE_BCDMA: - ret =3D bcdma_setup_resources(ud); - break; - case DMA_TYPE_PKTDMA: - ret =3D pktdma_setup_resources(ud); - break; - default: - return -EINVAL; - } - - if (ret) - return ret; - - ch_count =3D ud->bchan_cnt + ud->tchan_cnt + ud->rchan_cnt; - if (ud->bchan_cnt) - ch_count -=3D bitmap_weight(ud->bchan_map, ud->bchan_cnt); - ch_count -=3D bitmap_weight(ud->tchan_map, ud->tchan_cnt); - ch_count -=3D bitmap_weight(ud->rchan_map, ud->rchan_cnt); - if (!ch_count) - return -ENODEV; - - ud->channels =3D devm_kcalloc(dev, ch_count, sizeof(*ud->channels), - GFP_KERNEL); - 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 =3D pdev->dev.parent->of_node; @@ -2747,6 +2574,9 @@ static int udma_probe(struct platform_device *pdev) ud->decrement_byte_counters =3D udma_decrement_byte_counters; ud->psil_pair =3D navss_psil_pair; ud->psil_unpair =3D navss_psil_unpair; + ud->udma_setup_resources =3D udma_setup_resources; + ud->bcdma_setup_sci_resources =3D bcdma_setup_sci_resources; + ud->pktdma_setup_sci_resources =3D pktdma_setup_sci_resources; =20 ret =3D udma_get_mmrs(pdev, ud); if (ret) diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 329df7eb156b2..5e222ce366faf 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -357,6 +357,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); }; =20 struct udma_desc { @@ -679,6 +682,11 @@ struct udma_bchan *__udma_reserve_bchan(struct udma_de= v *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); =20 +int udma_setup_resources(struct udma_dev *ud); +int bcdma_setup_resources(struct udma_dev *ud); +int pktdma_setup_resources(struct udma_dev *ud); +int 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_thr= ead); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 AA838423E91; Fri, 24 Jul 2026 10:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888568; cv=fail; b=GAKw0cjIXFst3KYimEFDem/gfJiLtGvfxK65CvtUGlKoNn96hAldb0xv+/dEIiLPt6j8xQOujg6lSTjmyujOPWAyWfWJYnjWQ2VTgU8W4KoezRtOMFWw0Vp4EgmwIuolH0euTdLDftya3JJ6IXzdzG/wPpArF0Dnov5FMMkbD5I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888568; c=relaxed/simple; bh=ZcLThQ2hYQw4KY9I9h8PaHbn9C3vLljLhMlhD7XbqcI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gc9fKIV4XN7K2TwkX3IDx1mAzMux0aNtMF2C8lHPaGkP74Cu3tiVJFVePcQjh5l+uGDt+oA9slfqpv4HQ6qdZ82IgUzdzaePSHKgLghjAUzacRy/qJFcRbG3LrX65nnT4J7p19ciCdTM9KYz6rrt+N9fJfbKXX4c4vtaWFtbb+w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=NWVQUIwQ; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=AZq/sx91; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="NWVQUIwQ"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="AZq/sx91" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFTTu1093779; Fri, 24 Jul 2026 05:22:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=WwDxHefWibjKCJVfzeekGDFElgQz1afsxNB+GV07g Is=; b=NWVQUIwQb4hRQ6WEY4k1Igxc3m64679fOfoYoIqnrch4djRvrOhf3sT9L FoGnrJLsswSBQ2t4qjqvHI0OxnebbFObHxRRKhIkgDnLyxXqtohduzjdLAqVa8kf AycSIkPw+5inXD775sFstQ+AwW/eO0ej1rnz7/VKW+OPe3z24uovEJkdtr1AIlNM jcyNz+3dDvSI9ARlMVIS1GM2dAPmpP8QG0h9QWMqq53zAL6X8XmA+QjcWVS8A+4h 5G8MzR3CRxiqoypnN5H61uXLosBdAYy40WhOodvVL4TWEj/UPAyELtOKXRda1ai9 yYIqb7z2gPFTIdAWeOpI6GbxwvOIg== Received: from dm1pr04cu001.outbound.protection.outlook.com (mail-centralusazon11010016.outbound.protection.outlook.com [52.101.61.16]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkyp7j3yc-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:31 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UUJcv7XtYIBD4kahIRp5xUl46R4yEuEl/eun7XzMnXshAMTE8QGLakyDMVixEpvNCcpVnGCGZrTNOBPVBm3woAlDVb8v+rYAs/KqGF6eJRUC16TH2ohP0DvPsAhW9KZ7KS9M1qDn4AqqV/sEGuUzPdqGmzcjIG0CgGVDdJVlb3uIf+tV9oJDyx/jV4AtrE8z/r+RsRydd3ETKHihkL3y2HYHZz1N+Mw9MAd1k8GnwByoeuSaOs6WhYi9nEDBgxblA/IBteKBh/Kl7si/tt8wYzFg0VIZx0+bbi+sB/BWW4wn6bFGi0nvjsBPs40qT9Q9e8cnxpR7ZdEX4pZq/Qx7Aw== 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=WwDxHefWibjKCJVfzeekGDFElgQz1afsxNB+GV07gIs=; b=jyJ8W396fgaTjos7UEkstk0sS0gZJN6yGNfTyBvYNhZwIWytEFzqWjsY/DS1AR+6K82+IZBwp+im+zBBbs/bIZGpvkcmOl1ODCij3CwLMc5L3BO6Xe8AjM+RjbsPcy7sma3aMhOm+BEgOXzyjbMaUPQf+MuLgq9scP9YV2F+3DzUZHbSHcf+6lwQPKtgMhJaCqtE/BXDXHK6C665N+zPjhVxbXEjGQWyCSJ3hyT7HjO66oH0D1AJsXwaLRLHiznfnndISBXEhABr/KCOFqBkm2o4WCyqh57sIgVaMR0a38T6MXzbM8GUbTBZDtfNoY0eq55s5E2ZC97Iwn3QJRHxbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WwDxHefWibjKCJVfzeekGDFElgQz1afsxNB+GV07gIs=; b=AZq/sx91izDZZRUjyUKOwx7DZ7QPs6iduOO3brBr8DW82dAT89EE2EaRobA0weprK+Lw3Lln0K88BVN7h1ymu22FZUdxmigBa9G5OQE7wJeswcM8FoKldEtvtGUZmXlKoufhqyIAseaUa25nQE1wnJ+C+dyckfQu9FsGIKi4uSA= Received: from CH0PR03CA0383.namprd03.prod.outlook.com (2603:10b6:610:119::18) by DS7PR10MB5903.namprd10.prod.outlook.com (2603:10b6:8:85::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:22:26 +0000 Received: from CH2PEPF0000013D.namprd02.prod.outlook.com (2603:10b6:610:119:cafe::3a) by CH0PR03CA0383.outlook.office365.com (2603:10b6:610:119::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:22:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH2PEPF0000013D.mail.protection.outlook.com (10.167.244.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:26 +0000 Received: from DLEE203.ent.ti.com (157.170.170.78) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:24 -0500 Received: from DLEE204.ent.ti.com (157.170.170.84) by DLEE203.ent.ti.com (157.170.170.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:24 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE204.ent.ti.com (157.170.170.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:24 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFQ3017088; Fri, 24 Jul 2026 05:22:19 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 11/19] dmaengine: ti: k3-udma: move inclusion of k3-udma-private.c to k3-udma-common.c Date: Fri, 24 Jul 2026 15:50:44 +0530 Message-ID: <20260724102115.2854-12-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000013D:EE_|DS7PR10MB5903:EE_ X-MS-Office365-Filtering-Correlation-Id: 0335a6c8-292b-4ff4-db4a-08dee96d7595 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700016|7416014|376014|23010399003|3023799007|56012099006|10067099003|921020|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: MdoFF8veaCOwM8rAaz/C/r1zFOXQxI4PlmMr3aLLv0CqRiVXly9MJxqbFPIIHTZzPAYi9dN13PYHq26S5TyPNu0xCil7XuH5mbri2jLNUePIPFQCXFG7+azcT4EvtO5Pzghn/P9SF88Vzh6QPJA1wiAHQitVXspl8VhNKBkvpi7Fpbl19hZMXAz0xzNjW1vPvuIYte3QJsNF074JgXZPQRGQIBn2FpGrd23zI6+005/GdintQMDF/l918F7Zs1Tnyb63BN3Jgs6h4rT2BrclrXm+AbfJ9XHkD2LKQitQVAhltKl3+7NpCWSZ3XCBTUTJ0Urz/MHtaUuclqXNFA2/C28OmOJ+rsTWf+bMI2O/7jg0uH6uDrtl5kZi3cujOVuutsTMk16ufJKB9ZpUI/MkWRr8PuhL+S2SkwAMUbEuYQaFLarIer7SDoN9/VS7KaRrS5Eb4b1Wvg+iE6tPA9XndWcmUvuzz3u1CZfToeBIlaeKtIgSM6XdRLz0yBk8/cjuU00SpnTFPw9K8kQ8m7q0vZyTnYS4PcRJB+u1k43Pn+sDt3yTyZKP85wdofZkdXY1v/xiA4/6MMVjybLx0ZAFL8vAKqw0qyBD+re/DsSyC8kWHCPZ/fYh1OK3YJARBnYafdjG7pxeSIhLDPeRI+sxeNRq/8a3x/gmVM2iuhTDIeyE3ZryVJq6nU8S8DQzwmLqayimunpNQvOM18FV8U18Mvs/R1/Ea0dGBJ9++y9oh7BqJ5lnZwUspPZCPilX2clX X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700016)(7416014)(376014)(23010399003)(3023799007)(56012099006)(10067099003)(921020)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: usk34CQJpEdVmdnetgxQWGHIJEWIDf+SY6kMidej7DPxLoS/Nakhs1+1gqOWNhgUcN3iN9bup55gAEPjl69YaWpilDiZWGgf8YuWbzxP/matx6xgy6NcuFYeWwckWn+HBHbrTyl7tJtWf92TjT9IklpOs5hBgtfo3t01c4pKqoyFeJgEglkh1aAvVeqtWURLGPBmVCaE+FhALunEmwp+se+HDJbzZQW5TFg8YApI/hAtO1mk8iDrGXTshGQJmBp6UcZgVPMPQTy4Hb+f0Iw31rn5nS3+sJOoYNzlXZL1xs17kmH1MJkXDJIq9rlfjBuYkPUcJcv+4Pmba5NXrNsMdPtxPyJjWjqUO67fz8zzcCZSU3jPFpkvprOMqVX2gTa9x3S8q6Me8EKGWWh/FWIU+DkVDIVvluMcA+kqtyfvdhAdJyCHRzIdOBFYzv1w+ufV X-Exchange-RoutingPolicyChecked: St8bTsph9WFeRyvGtoqwSJgYQoPMOqPB6gRL0acfKmhBTo8+t/gmOzigz/KM7SuX0kKTUKJ6DX/gIMmlCe6EmC8Sg8mDh3QajrhhFZOMI63yu3Jf5b60KicKSa4k51jBX0oZjGa2EXn2bQBFxr8ZDrZ92DH/+KoLUeggGvFfWhhvc81DY0bLx+f5XhRRKQn42gSg6u0DTJWjkevwL4RmiB0GLlaDBMu7PPyalzXWbN8bZTGivUSdX/AQ52iCVkozRfRe0akgH+s8R61ffB/4rw1MigmWIye33oFnu25ztCuhefMFy0GnmqVx+BA4VBJ0DT89ZB3kel68pHc1DmzxwQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:26.5609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0335a6c8-292b-4ff4-db4a-08dee96d7595 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000013D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5903 X-Authority-Analysis: v=2.4 cv=M4p97Sws c=1 sm=1 tr=0 ts=6a633ce8 cx=c_pps a=ItoRIIcZIWT0tNr6APkIeA==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=tBjUjbL6H5YkyfA7LM4A:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfXyQ29A7SYi8/T r9Mx8yIlrHNDmzXuPiPXV9wYNDmP+vz0E8bwArKV5azUnwZzt82vrOOteoYrVj+hiIUNnsKNHRv eNAo0mJ/5FIUVkR49kLDCHwZ5dZyOS4= X-Proofpoint-ORIG-GUID: lSddF28NzF_3F4yFCWjPl5nvlWKiSErc X-Proofpoint-GUID: lSddF28NzF_3F4yFCWjPl5nvlWKiSErc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX28uzInGB1smw z3lQevLCFtXil1PlkAjxdyCGuXo12Q6Yzfv+JOpPX2fokvtsTH0ySBmm5f6UcUMI8r3uejVXRSk U3XTIpMqgMQ96mNH4y6gZxaoJt1eX6t4s6sqf33bC4V57dYs35obaAHUJ/O2K/SvVldJZ/pdkiI EWRp3Mnu9424NR5znpmTmPDG36iJ9ALj0eRebN1NjQd7AzXpSPX/qiJJFBhFBnvD6JgK+sovjOI 0klp07500n9AbDvnRpjh9LFgHQZT8NXpuyJtQ6sUqc9glK9mn65RILz+2GL/PwCpEmDPJF0j4C/ RS9znF5Lfu6gpHFr/VXYNdpbojrZjpyu5/vk+egFVnMOs3TaN/HpI/fXW9iqUDityhv1yjd0Cpu e7q89qXNtYHai+f9Kj2rqhz/+d6GNR58VWbnBJyeDqc1ofVCUyJ1d+VZd3tMyskS83jLvxpfwF1 96CmvCzrAWOY7njdOBw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Relocate the #include directive for k3-udma-private.c to k3-udma-common.c so that the code can be shared between other UDMA variants (like k3-udma-v2). This change improves modularity and prepares for variant-specific implementations. No functional changes intended. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma-common.c | 3 +++ drivers/dma/ti/k3-udma.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index 8b2a3be3fa932..7ae2c70eb5414 100644 --- a/drivers/dma/ti/k3-udma-common.c +++ b/drivers/dma/ti/k3-udma-common.c @@ -2539,3 +2539,6 @@ EXPORT_SYMBOL_GPL(setup_resources); =20 MODULE_DESCRIPTION("Texas Instruments K3 UDMA Common Library"); MODULE_LICENSE("GPL v2"); + +/* Private interfaces to UDMA */ +#include "k3-udma-private.c" diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index d9d6cbda46b2c..58cbb399bc3b2 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -2857,5 +2857,3 @@ module_platform_driver(udma_driver); MODULE_DESCRIPTION("Texas Instruments UDMA support"); MODULE_LICENSE("GPL v2"); =20 -/* Private interfaces to UDMA */ -#include "k3-udma-private.c" --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 13BA8433033; Fri, 24 Jul 2026 10:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888577; cv=fail; b=AeCS2uxJByZQS8KzRn3yVbL8jw7NEFA00il4Iv0C+/sOOhJV2BwQ2NXoslP3o0MvjV8fgWJPirg0HKt3VnnTPn9Dqg2QykA5OLOzcbbPzNUbEr3FnT9nbeIglwyRZtgo439L8qqzOdkwYKnDZkZgxRxVKH9kdnvbGgk5MdnTxt4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888577; c=relaxed/simple; bh=Wpg5b1X6+6C8Xs431x3az2z7BpJosCaJNxp0J+cLmFc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g6E7tBxb2teqtkZ8/wqxaWsAFNM0RBmAfZh5MBWbkz+ZBS/IEbPVYodsPVAGkdRdlDhbe6bOvE9o+AwAl3hy29SALCj+GAN2+TdtFyf8dZJhz/2dyyDuedEDVo4ZOTOwX3mGtm+FWpqHFEMYsfIfnKdc8mqPLN80PSHQc7eCxCU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=jEX5jJrx; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=i112Jl8r; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="jEX5jJrx"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="i112Jl8r" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAF9OP2796761; Fri, 24 Jul 2026 05:22:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=GDgvrlI2YqRkvzqhjxzdPC6mOKbamuxBF2VmUYeEP WI=; b=jEX5jJrxoIuvbVTgXu+oyTET+WS01AbtdOEeeh2h1vy/mT9Z2j/ASufV8 f9Xo1ShoQ5+epCwLe1cfj2j5+0wM4JlZSQy9R0MXPaQc4azSsqmcxIAN44KmFACH U5bdGszQmn7kDdVZL1tZvj3cDzTvlOS7lY8s1HLbdjEmV384cG+3QWMffkBWQHRJ K36rBTrKYhjXesJEHa/5vlDHJU4VoAFYeCePn8KNlJG1ewcEeNAkzOFbzb/TCt5j qyWPcbX1mcQ42kRgXCIgJpNbBBBWdL3QiieDYvdRKyZmaCKhQIpDXGjwAfO9eyXt o745szY83i4kcOfAJAlj/C/WlZ4Xg== Received: from ph7pr06cu001.outbound.protection.outlook.com (mail-westus3azon11010062.outbound.protection.outlook.com [52.101.201.62]) by m0384305.ppops.net (PPS) with ESMTPS id 4fm3v38pw1-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:39 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yOsHQRSomU9YuwL1zk+ySIyZN41nSugc8pwx0r5VODUDKR2jxEiu7myyrj7W6WLB8c+LQKyUvfzsDr0wlWaaJ1/XqxTaU5DdUYjeBR7CgIoh0RCxKeHNQMW/vBhpUqtZyQBw6RLKbHDq/REdbxDFELkv2GLHwKzM1+ZZN1MbyPn3+5zx0AVMzlYYanr/CgIdBvhkje+mBUBp0yKOVCutVMHHYYKOHpuuWcLHEv5mmhdlcjiWYzF0ksua6AI90BopFVBpOrVTmNHEnSgzrHJrt+6WWxfZYSBYX5YFNaiGrgXyZKORywEmamY4Lvsoy6vMj1nBT+doMowKjwO4KGcpyg== 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=GDgvrlI2YqRkvzqhjxzdPC6mOKbamuxBF2VmUYeEPWI=; b=R3s8SkEe+Wx1Y8EyLylATVOz/xutuG/JfBPbQyLe0NdR0aj3KN+wba3ySrZxLs0Folb9DhUDPP0cvXwg3FUG0yZyvKCcTphnjw0+Qk7MMFGIelhsjjFeWaIcwpzOVw6Y/z7DyUBLCw7NY1jbTM/9/6kvby30eYqZTJ2Is2mPxm80W7mWncIjx2wx53OivaS65sbgjgh+cc4AJ4LZkw5gd9FxK17jbUulk2HPA6COlRTZWBEH0hpBmLFy1Yh8iB8zB17P2afStb/S4OMEI4/U7MJ0hc+9f4MGHwplRFl8x0WJzoXkCZK+7WMd8R4lhtTFU2ZOPuv9Z57dUsM9X28AzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GDgvrlI2YqRkvzqhjxzdPC6mOKbamuxBF2VmUYeEPWI=; b=i112Jl8rRS9cA0LU0ZBy3Qnf+QXrjtiRILuTpCSL5j+kOL/nIFNvRRneT2hqa6ja4fhNnMgVw0I5ADKOGajosqpwxYEfgDK7OSaBItTZ5B+mlp+GyN6E6CCPjFiF8QEdaYGeDYPfD9oadXow4oLLPlh6AY5WIA6Q7jQLev2PR0I= Received: from SJ0PR05CA0168.namprd05.prod.outlook.com (2603:10b6:a03:339::23) by DSVPR10MB997870.namprd10.prod.outlook.com (2603:10b6:8:45d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Fri, 24 Jul 2026 10:22:35 +0000 Received: from MWH0EPF000C6195.namprd02.prod.outlook.com (2603:10b6:a03:339:cafe::99) by SJ0PR05CA0168.outlook.office365.com (2603:10b6:a03:339::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.4 via Frontend Transport; Fri, 24 Jul 2026 10:22:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by MWH0EPF000C6195.mail.protection.outlook.com (10.167.249.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:33 +0000 Received: from DFLE211.ent.ti.com (10.64.6.69) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:29 -0500 Received: from DFLE210.ent.ti.com (10.64.6.68) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:29 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:29 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFR3017088; Fri, 24 Jul 2026 05:22:24 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 12/19] drivers: soc: ti: k3-ringacc: handle absence of tisci Date: Fri, 24 Jul 2026 15:50:45 +0530 Message-ID: <20260724102115.2854-13-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6195:EE_|DSVPR10MB997870:EE_ X-MS-Office365-Filtering-Correlation-Id: cbbcc40e-98d2-4742-b3ab-08dee96d79c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|7416014|376014|1800799024|23010399003|56012099006|10067099003|6133799003|22082099003|18002099003|921020; X-Microsoft-Antispam-Message-Info: LKRxDmIxRrrH4nOQ4K5cDWNITxSkyczDYjUY4S3Ab4ppbnFkpQYZufwjT8yDRWg2cgDq+/UZo1kCwkxQLH1wrK6L/NzR228D0TP8txDrtKgGFwpigTXqWKq1F57hCiP+iy9VTejMyrFnNLr0ibkoe/DitWaqWzXMXbIuPWi4Vpwl6F3obinUZetVyJNs6296CT3v4eXFxXZE91j7d1A2CzEADYFaaec7VRxzoaISVABrJa6N2WPrTBNfRKpBrhHrNOB9PslNALnk1CPLFUrgzeJG3v++caadYif+6nqptqCN5R02OrSoheszgXMpEhJb8cQHtu8NX1/sHId7Y4WZchCIcEnVm/GJBGgSWyvwKcyFjAOg2YNNv1ByEyPYtvfXIMy6KnHR9Ia1wVvjGQUFPqAkfO1XQCToBxmYFberKRfPVSnNHlqHMcuRgBVwKuy+Ww1P+kD0wKXs0kg5jhRXiCFgo/gKyWK7f4fLYXcLYcG9JhgLpCoC3oYy8+5qLsHdAXnuH57I4ytDJV0+S3HxxwLXeMkIZ+yIrRrq8lS7cTIuv3cK5KoJX8SF1Z8F/Mxrt1bAoMvDlGq+79iB6rXwh8CsVNayTEwY0ojTQ4BdiyhW5qVr2UKYobTceU/5DSX2nvVKntB/RyobMi9SEOpAwaxKkKU3YlM/0agYB2FTERVODisIDWN+bo4faDuZkVxNDw1sK9HrR+15Ol8esLzxmODhujXhB8U6EERIMG75mVrItARSp0jZGyiYn2nN3fec X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(7416014)(376014)(1800799024)(23010399003)(56012099006)(10067099003)(6133799003)(22082099003)(18002099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NudVjVTM1gov8r3kkOr0wL4ZFw9ghSwcDfpvSlWYVjvzenlorCtvS/67ydzX/9Lz8GChNlCLsF1ImW+yCtby6EuP6Y8WkkPODERII0RowS63aaQnvWKp2HDEXsKtORJw78/ZKuT18iPrpSrDbY29y2RsRoRVUYcEaktyo5jIRzv2s0FCf0nEjTtpTMbGGexMTVoGByFUQ1Lh6/YCL6gXuYculTDu/lSJQsiUoT35+TeoRoBBnDvmVbFLZHSd19y1O/fzgzUeD0aU98n0Ie9Q2BlQooqF2lt959zMa6Sr/6gJASCFfPXABN+INWGZl0VKJT73Wc4pgwxm8v0KxTZzftZLbP6qSKpjiZvajanb8w4Sk7ZmAYwA9oKggB91QhKm1cU6wHLptHMPCz8noqT/4qkNEkgAAnGSz2ShNVASubAIHRje2XsHkaNkc+20WGGH X-Exchange-RoutingPolicyChecked: cWw+SE3Te3wmj5tPna0Uj+YIpe8bCROmEqwjaBwAazPin5CrPz2Ga/5SvmQA1ZH/uxuE+xCxhzeWT/5dhkxKHSfMivSHKPrnNcIrtluwkU8vOuq1r1hJQaMepovuwmPkPb7KFyuHIgQcygQffAuffnbJGjbDrJSLfTjv7IOm8mmvMKwCHeOQesMDclr8udA7q9fz8rEl5qXk8Owb13EU5nRoT6dYd2OqyVdDOEKdaX+iotHiVG63xEUCAdwEnod+no69kCwmpNiiF1ZQlWymS08i6Or6/BpCZhvnbjP8ynEsoHpmlg/JKc6Nzg7IRBbf/rbVolXBZSiWpEnjDiDcbQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:33.5480 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbbcc40e-98d2-4742-b3ab-08dee96d79c3 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6195.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DSVPR10MB997870 X-Proofpoint-GUID: s4k2U-yivzx1LkVx4N8BX8HMGRx-zLSw X-Proofpoint-ORIG-GUID: s4k2U-yivzx1LkVx4N8BX8HMGRx-zLSw X-Authority-Analysis: v=2.4 cv=dLWWXuZb c=1 sm=1 tr=0 ts=6a633cef cx=c_pps a=V+mzYH1ZSfwt9Wwm8MCB5w==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=JJJAxwKGgbaLG8uOhDEA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX83aulAvGWdzV /gspAsZkT9HTwAGo0cVUxSy6jMf7IVme+5FenpBhlEHIyclE8HErr4cUTiDKz3x0lmPuEsWHHpK F03DcSabkkMgKydtACM/u4A7Jz10XmxkzRc7DHlz8Xx9ecxALCc0VtLz2rDgBz8/ju+PPJF4cMB CPZwL/cXEFSFPEFwoy37VOcYfzhq/mAhB6876ORp1aRyDWFAHDw+T84APxZ/w5Gk8ng1HlNZ5zb GF08pAx0Nkn4WFJdocgTnSsauafnVYtxe3fw6fPWUHDYLN5ilMeYzYreTfuj/DTbLNuPH1EjY0v B0sU5BFHa2zxZxZBrR6FOHG3Drc8WA+SYuU7tmGBbkteLGUGTYnVa4BLLtNk+2dRw1TAjh+CIcW n41zBQEs1DmWLFNuGnEOwr1Ze3IswhLVgfKQxL39TFTTfILMp40Q3ZJe8Gg/xXMGi1VVCJDsEIx igWDUgtIz4jdkssSqCQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX513n2ziGQiV/ 7VXDvBpJxSuWb+C553BX7RP51uB9ZWVHFXIMQXAHNzocpysKz8yzMGYdzJOMaVwye9mAg1rAEQ8 eqM7dvr/arT17fKjU6iTSCDAEG9gv+M= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Handle absence of tisci with direct register writes. This will support platforms that do not have tisci firmware like AM62L. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/soc/ti/k3-ringacc.c | 188 ++++++++++++++++++++++++++---- include/linux/soc/ti/k3-ringacc.h | 17 +++ 2 files changed, 181 insertions(+), 24 deletions(-) diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c index 5966db4327b13..e81d19a9ed324 100644 --- a/drivers/soc/ti/k3-ringacc.c +++ b/drivers/soc/ti/k3-ringacc.c @@ -46,6 +46,53 @@ struct k3_ring_rt_regs { u32 hwindx; }; =20 +#define K3_RINGACC_RT_CFG_REGS_OFS 0x40 +#define K3_DMARING_CFG_ADDR_HI_MASK GENMASK(3, 0) +#define K3_DMARING_CFG_ASEL_SHIFT 16 +#define K3_DMARING_CFG_SIZE_MASK GENMASK(15, 0) + +/** + * struct k3_ring_cfg_regs - The RA Configuration Registers region + * + * @ba_lo: Ring Base Address Low Register + * @ba_hi: Ring Base Address High Register + * @size: Ring Size Register + */ +struct k3_ring_cfg_regs { + u32 ba_lo; + u32 ba_hi; + u32 size; +}; + +#define K3_RINGACC_RT_INT_REGS_OFS 0x140 +#define K3_RINGACC_RT_INT_ENABLE_SET_COMPLETE BIT(0) +#define K3_RINGACC_RT_INT_ENABLE_SET_TR BIT(2) + +/** + * struct k3_ring_intr_regs { + * + * @enable_set: Ring Interrupt Enable Register + * @resv_1: Reserved + * @clr: Ring Interrupt Clear Register + * @resv_2: Reserved + * @status_set: Ring Interrupt Status Set Register + * @resv_3: Reserved + * @status: Ring Interrupt Status Register + * @resv_4: Reserved + * @status_masked: Ring Interrupt Status Masked Register + */ +struct k3_ring_intr_regs { + u32 enable_set; + u32 resv_1; + u32 clr; + u32 resv_2; + u32 status_set; + u32 resv_3; + u32 status; + u32 resv_4; + u32 status_masked; +}; + #define K3_RINGACC_RT_REGS_STEP 0x1000 #define K3_DMARING_RT_REGS_STEP 0x2000 #define K3_DMARING_RT_REGS_REVERSE_OFS 0x1000 @@ -139,6 +186,8 @@ struct k3_ring_state { * struct k3_ring - RA Ring descriptor * * @rt: Ring control/status registers + * @cfg: Ring config registers + * @intr: Ring interrupt registers * @fifos: Ring queues registers * @proxy: Ring Proxy Datapath registers * @ring_mem_dma: Ring buffer dma address @@ -158,6 +207,8 @@ struct k3_ring_state { */ struct k3_ring { struct k3_ring_rt_regs __iomem *rt; + struct k3_ring_cfg_regs __iomem *cfg; + struct k3_ring_intr_regs __iomem *intr; struct k3_ring_fifo_regs __iomem *fifos; struct k3_ringacc_proxy_target_regs __iomem *proxy; dma_addr_t ring_mem_dma; @@ -467,15 +518,31 @@ static void k3_ringacc_ring_reset_sci(struct k3_ring = *ring) struct k3_ringacc *ringacc =3D ring->parent; int ret; =20 - ring_cfg.nav_id =3D ringacc->tisci_dev_id; - ring_cfg.index =3D ring->ring_id; - ring_cfg.valid_params =3D TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID; - ring_cfg.count =3D ring->size; + if (!ringacc->tisci) { + u32 reg; =20 - ret =3D ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); - if (ret) - dev_err(ringacc->dev, "TISCI reset ring fail (%d) ring_idx %d\n", - ret, ring->ring_id); + if (!ring->cfg) + return; + + reg =3D readl(&ring->cfg->size); + reg &=3D ~K3_DMARING_CFG_SIZE_MASK; + writel(reg, &ring->cfg->size); + + /* Ensure the register clear operation completes before writing new valu= e */ + wmb(); + reg |=3D ring->size; + writel(reg, &ring->cfg->size); + } else { + ring_cfg.nav_id =3D ringacc->tisci_dev_id; + ring_cfg.index =3D ring->ring_id; + ring_cfg.valid_params =3D TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID; + ring_cfg.count =3D ring->size; + + ret =3D ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); + if (ret) + dev_err(ringacc->dev, "TISCI reset ring fail (%d) ring_idx %d\n", + ret, ring->ring_id); + } } =20 void k3_ringacc_ring_reset(struct k3_ring *ring) @@ -501,10 +568,25 @@ static void k3_ringacc_ring_reconfig_qmode_sci(struct= k3_ring *ring, ring_cfg.valid_params =3D TI_SCI_MSG_VALUE_RM_RING_MODE_VALID; ring_cfg.mode =3D mode; =20 - ret =3D ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); - if (ret) - dev_err(ringacc->dev, "TISCI reconf qmode fail (%d) ring_idx %d\n", - ret, ring->ring_id); + if (!ringacc->tisci) { + u32 reg; + + writel(ring_cfg.addr_lo, &ring->cfg->ba_lo); + writel((ring_cfg.addr_hi & K3_DMARING_CFG_ADDR_HI_MASK) + + (ring_cfg.asel << K3_DMARING_CFG_ASEL_SHIFT), + &ring->cfg->ba_hi); + + reg =3D readl(&ring->cfg->size); + reg &=3D ~K3_DMARING_CFG_SIZE_MASK; + reg |=3D ring_cfg.count & K3_DMARING_CFG_SIZE_MASK; + + writel(reg, &ring->cfg->size); + } else { + ret =3D ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); + if (ret) + dev_err(ringacc->dev, "TISCI reconf qmode fail (%d) ring_idx %d\n", + ret, ring->ring_id); + } } =20 void k3_ringacc_ring_reset_dma(struct k3_ring *ring, u32 occ) @@ -576,10 +658,25 @@ static void k3_ringacc_ring_free_sci(struct k3_ring *= ring) ring_cfg.index =3D ring->ring_id; ring_cfg.valid_params =3D TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER; =20 - ret =3D ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); - if (ret) - dev_err(ringacc->dev, "TISCI ring free fail (%d) ring_idx %d\n", - ret, ring->ring_id); + if (!ringacc->tisci) { + u32 reg; + + writel(ring_cfg.addr_lo, &ring->cfg->ba_lo); + writel((ring_cfg.addr_hi & K3_DMARING_CFG_ADDR_HI_MASK) + + (ring_cfg.asel << K3_DMARING_CFG_ASEL_SHIFT), + &ring->cfg->ba_hi); + + reg =3D readl(&ring->cfg->size); + reg &=3D ~K3_DMARING_CFG_SIZE_MASK; + reg |=3D ring_cfg.count & K3_DMARING_CFG_SIZE_MASK; + + writel(reg, &ring->cfg->size); + } else { + ret =3D ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); + if (ret) + dev_err(ringacc->dev, "TISCI ring free fail (%d) ring_idx %d\n", + ret, ring->ring_id); + } } =20 int k3_ringacc_ring_free(struct k3_ring *ring) @@ -670,15 +767,30 @@ int k3_ringacc_get_ring_irq_num(struct k3_ring *ring) } EXPORT_SYMBOL_GPL(k3_ringacc_get_ring_irq_num); =20 +u32 k3_ringacc_ring_get_irq_status(struct k3_ring *ring) +{ + struct k3_ringacc *ringacc =3D ring->parent; + struct k3_ring *ring2 =3D &ringacc->rings[ring->ring_id]; + + return readl(&ring2->intr->status); +} +EXPORT_SYMBOL_GPL(k3_ringacc_ring_get_irq_status); + +void k3_ringacc_ring_clear_irq(struct k3_ring *ring) +{ + struct k3_ringacc *ringacc =3D ring->parent; + struct k3_ring *ring2 =3D &ringacc->rings[ring->ring_id]; + + writel(0xFF, &ring2->intr->status); +} +EXPORT_SYMBOL_GPL(k3_ringacc_ring_clear_irq); + static int k3_ringacc_ring_cfg_sci(struct k3_ring *ring) { struct ti_sci_msg_rm_ring_cfg ring_cfg =3D { 0 }; struct k3_ringacc *ringacc =3D ring->parent; int ret; =20 - if (!ringacc->tisci) - return -EINVAL; - ring_cfg.nav_id =3D ringacc->tisci_dev_id; ring_cfg.index =3D ring->ring_id; ring_cfg.valid_params =3D TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER; @@ -689,6 +801,24 @@ static int k3_ringacc_ring_cfg_sci(struct k3_ring *rin= g) ring_cfg.size =3D ring->elm_size; ring_cfg.asel =3D ring->asel; =20 + if (!ringacc->tisci) { + u32 reg; + + writel(ring_cfg.addr_lo, &ring->cfg->ba_lo); + writel((ring_cfg.addr_hi & K3_DMARING_CFG_ADDR_HI_MASK) + + (ring_cfg.asel << K3_DMARING_CFG_ASEL_SHIFT), + &ring->cfg->ba_hi); + + reg =3D readl(&ring->cfg->size); + reg &=3D ~K3_DMARING_CFG_SIZE_MASK; + reg |=3D ring_cfg.count & K3_DMARING_CFG_SIZE_MASK; + + writel(reg, &ring->cfg->size); + writel(K3_RINGACC_RT_INT_ENABLE_SET_COMPLETE | K3_RINGACC_RT_INT_ENABLE_= SET_TR, + &ring->intr->enable_set); + return 0; + } + ret =3D ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); if (ret) dev_err(ringacc->dev, "TISCI config ring fail (%d) ring_idx %d\n", @@ -1347,8 +1477,11 @@ static int k3_ringacc_probe_dt(struct k3_ringacc *ri= ngacc) return PTR_ERR(ringacc->rm_gp_range); } =20 - return ti_sci_inta_msi_domain_alloc_irqs(ringacc->dev, - ringacc->rm_gp_range); + if (IS_ENABLED(CONFIG_TI_K3_UDMA)) + return ti_sci_inta_msi_domain_alloc_irqs(ringacc->dev, + ringacc->rm_gp_range); + else + return 0; } =20 static const struct k3_ringacc_soc_data k3_ringacc_soc_data_sr1 =3D { @@ -1481,9 +1614,12 @@ struct k3_ringacc *k3_ringacc_dmarings_init(struct p= latform_device *pdev, =20 mutex_init(&ringacc->req_lock); =20 - base_rt =3D devm_platform_ioremap_resource_byname(pdev, "ringrt"); - if (IS_ERR(base_rt)) - return ERR_CAST(base_rt); + base_rt =3D data->base_rt; + if (!base_rt) { + base_rt =3D devm_platform_ioremap_resource_byname(pdev, "ringrt"); + if (IS_ERR(base_rt)) + return ERR_CAST(base_rt); + } =20 ringacc->rings =3D devm_kzalloc(dev, sizeof(*ringacc->rings) * @@ -1499,6 +1635,10 @@ struct k3_ringacc *k3_ringacc_dmarings_init(struct p= latform_device *pdev, struct k3_ring *ring =3D &ringacc->rings[i]; =20 ring->rt =3D base_rt + K3_DMARING_RT_REGS_STEP * i; + ring->cfg =3D base_rt + K3_RINGACC_RT_CFG_REGS_OFS + + K3_DMARING_RT_REGS_STEP * i; + ring->intr =3D base_rt + K3_RINGACC_RT_INT_REGS_OFS + + K3_DMARING_RT_REGS_STEP * i; ring->parent =3D ringacc; ring->ring_id =3D i; ring->proxy_id =3D K3_RINGACC_PROXY_NOT_USED; diff --git a/include/linux/soc/ti/k3-ringacc.h b/include/linux/soc/ti/k3-ri= ngacc.h index 39b022b925986..9f2d141c988bd 100644 --- a/include/linux/soc/ti/k3-ringacc.h +++ b/include/linux/soc/ti/k3-ringacc.h @@ -158,6 +158,22 @@ u32 k3_ringacc_get_ring_id(struct k3_ring *ring); */ int k3_ringacc_get_ring_irq_num(struct k3_ring *ring); =20 +/** + * k3_ringacc_ring_get_irq_status - Get the irq status for the ring + * @ring: pointer on ring + * + * Returns the interrupt status + */ +u32 k3_ringacc_ring_get_irq_status(struct k3_ring *ring); + +/** + * k3_ringacc_ring_clear_irq - Clear all interrupts + * @ring: pointer on ring + * + * Clears all the interrupts on the ring + */ +void k3_ringacc_ring_clear_irq(struct k3_ring *ring); + /** * k3_ringacc_ring_cfg - ring configure * @ring: pointer on ring @@ -262,6 +278,7 @@ struct k3_ringacc_init_data { const struct ti_sci_handle *tisci; u32 tisci_dev_id; u32 num_rings; + void __iomem *base_rt; }; =20 struct k3_ringacc *k3_ringacc_dmarings_init(struct platform_device *pdev, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 AB8A9424D5A; Fri, 24 Jul 2026 10:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888597; cv=fail; b=DB0TIZBHSatO0eScxAhE4ZZvrILFk8VvfEdn/KjwPLcRnWu9v+CXRHa4yv2ZqMajCDAPVSjHr2oyXcOW6r6iuUPLeU7ocxDPFkP4dmMZtjXFds97/xT2rZsUHeVQnppv8X4Q+S14PPzDv+57p6juWG7P8K43F240YmUX6K+UUjA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888597; c=relaxed/simple; bh=WJontK+Bl2iHifrWgjwlNaLl6bdOw30tbco2EvGrv/M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SOGWKOgtziozp/h92RWzGNsdsN/lA8ufOfv9LwuDDjDXo6G+zpnTvmYlCHGWDRL5iyx9UPzoOcWDJ1hOrYmpOqcwVeyWM2rYp83vIn9IdMz6RP26OW2hFTkOCYiJznEWzAAm5xeP2ud4WqU69GCpd4olGbPt2LWacjj91onHHeY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=d5S9TTzk; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=FGZ4wqnQ; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="d5S9TTzk"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="FGZ4wqnQ" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFXAO1093822; Fri, 24 Jul 2026 05:22:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=F6oI5zrWNdRH+dqAwMgP5Nt5I3TeT9+rgBgkxDJXC Mo=; b=d5S9TTzkRFD+FYo1c14XipfPR7UF/uRKXbcF7IaA+l5NwY4VmwYCqtvwq CviMSs7D9cQM9wxR6zYk4Z1T8K97DJmSghAKkRgsgxNEvMTCkA+QDPphNN6ydc9S WJYwzEOUqfhijdJJIW9aFN8W3naf3DnE0wx/RpwDms63kz+VmK2pJGbfJyXJDXop lefQ5pNu/RlKzJxVv+IHa2uNll+hDxG2/Zj/vqZsXJiL7eUaXQ/Unf/zmYLKY510 4D0tV5IC7A0oba9e8Dd6hCl/unFdHC8WHgYXHAubOPJcWjBLC28QK8a7ZgjM11fr FQHKnlL+8p44aZ3nC2YlH+Uub6LZg== Received: from ch1pr05cu001.outbound.protection.outlook.com (mail-northcentralusazon11010052.outbound.protection.outlook.com [52.101.193.52]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkyp7j40m-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:50 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MX5BQWj210eivS2qZ53Mw4cVWJx6XwRumjJu4JG1urusoWS7/5/VjeZ656bnyxhDbXtmclS0mzQxMZnBsuMjbB+ymwsZGJEuod4rewk4d/gjqx8G+GIJUreR76CHtLXEZCYSVOJtq+GIsXQCFQtUdMDPU5G79SRlB4sc8s3vSSz92xvmVIpR5om+bFKmuTUdUHyAj/tUnrulDkkNxjXl4nyHxRAUXaG6e3eS8OEOPg84lPhuHCB18sb/WP/g7FU+bgEY5J7nDlntFnbYKAUXF0CscCggLzo7TzmLgFYV7wU+MwuJdv2kW5TQJ+n+Tcd1LJQGJAhyxtcKpyJ2WJTVNg== 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=F6oI5zrWNdRH+dqAwMgP5Nt5I3TeT9+rgBgkxDJXCMo=; b=jgeAUb02+IBhpCX7ImMeI1uHvr0ts3Iai0X+9ooOZQAUrPLUIV7flr1QVSb1YXe0wpEmYd0H3fDvynTSyPadxPfbFfbJLegkTJ1yVxo5NfCEuUEK1UNTv+CGso/4mG+5oFmyvfpvGXmtetiBhfFe3huO0FaNqVUX29eigTDMeJGq6osNOreSkZG0WBr9u+X161UOg8ML5m1lMolJRSqfICD8ZvRFdROYA3wb/+iSCMM0vmPBMUMbqtZg07keDZXMFM+Nna/DON8AfDiePE25gD/8lKElWV1Phy0bNh15Z+GCBJaPSj1ZRUhpVFW3MFpsOxXQ5pqRo0e6nJ0RJ5uRqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F6oI5zrWNdRH+dqAwMgP5Nt5I3TeT9+rgBgkxDJXCMo=; b=FGZ4wqnQlXnHt0oBlRFo6PGRfKw24yH0BT62x36kJEM4MWX0snF5c/LRx6qaXP1F5unVBLX3KMp9ZT8M+YLJpJimtOSXxqAieIJIh9ZhAh7ZRyHukqUnSzBkEERxvZeTmh/7qGjHI4KEJFZJXBySSI4i4s6qT7zvnf89HbUXfNU= Received: from SJ0PR05CA0174.namprd05.prod.outlook.com (2603:10b6:a03:339::29) by MW4PR10MB6654.namprd10.prod.outlook.com (2603:10b6:303:22f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:22:46 +0000 Received: from MWH0EPF000C6195.namprd02.prod.outlook.com (2603:10b6:a03:339:cafe::46) by SJ0PR05CA0174.outlook.office365.com (2603:10b6:a03:339::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by MWH0EPF000C6195.mail.protection.outlook.com (10.167.249.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:44 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:35 -0500 Received: from DFLE201.ent.ti.com (10.64.6.59) by DFLE207.ent.ti.com (10.64.6.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:35 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:35 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFS3017088; Fri, 24 Jul 2026 05:22:29 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 13/19] dt-bindings: dma: ti: Add K3 BCDMA V2 Date: Fri, 24 Jul 2026 15:50:46 +0530 Message-ID: <20260724102115.2854-14-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6195:EE_|MW4PR10MB6654:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d1dbee9-e494-434d-d488-08dee96d801e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|23010399003|7416014|376014|36860700016|56012099006|10067099003|6133799003|3023799007|22082099003|18002099003|13003099007|921020; X-Microsoft-Antispam-Message-Info: /ZMAWRMJvhqT+Cb3Nmx1KPjhJ5+go/VeAFoeu9yeLmhpT5+NtIDaIKo3bqJXJa1YrdsJT+m2atxTH+cjQV+Db2IMnSfujpVCumWQeCTGKC8YHswLq79CoWE9wc8B2zCdjxBGCbr88TvG5vI2C1VpnIgFyuR4k2YYwCRVgJ4mPfJUlxf0Nxl1v0ssbVBTua7eIP68091y6Wei1rKvNFIy6hsg506dzsHiu/kONM8Z4l51bz4WEfZdcosh+hrtoBqkP1RTRNwIyEiG5CAcWBcjRy5l5dMG7VHNg1UI9xBdp0B6VH+/ENJO0KI02402y4J69fIR1CzOGSqw6z9GJHqcq1BXoWgARAVtCBe28JpcIdJcZ3QP+1Z8xBJgzvJ7VD9Be59WV5DfRw5hvV/jaTpxZoFtlM0tVBfy60uqiIyNZjp3nYlQs+nDwDGa0RwFyUcqtmMsnIENUsFJmzRhl5cqV2ed9B+mkQlHGcTPwV7OLLsnwocyc67NZHfWUK2+dJ6EVZ4BDjSNoIxfq0cxbD0Co9AvsltNDjb9svL0PY4Sz0lKYZl8J1+fAdt8866h1DwV7rGn3QXkRCuONKodYpwT5tjwRfzhxMmBPpYafiQZsuYDmfinAhUZ+8i1lY1pzfG5Evi/QNv4QJKTg/fL9UwUTnToP9PciG5PYSckQ6avt9tK9BS+juxdl2A58BS3QDad X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(23010399003)(7416014)(376014)(36860700016)(56012099006)(10067099003)(6133799003)(3023799007)(22082099003)(18002099003)(13003099007)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YAGB886YThdmGyit+Qo4GU8bdiRHYW8vfBqcnSRq7Nf9TrrNillep77FOTJ36CzTlpHjZvSzZsF/JG/EzoiV9qquwsrw9GML+W8p8cprHfQlCYWAeAkLk35cu7hxSpaUeZ6s8H/81JN3GButyKH0+syGi5RByebPyeQdZ82VsEyXa6paazfWn1UjjFG/P+koOmXYR86AXnGp118rrtL0BPU7zUUL5krwH4MGRN36YukCjP7OpQDGuhdd8OEIj6Ao/2npZKX3gW/Ye1JzQgQV0UaHbVBw48ZIyUE0FwWT3IhyzHR6D26KRHGbYp8IIQBt1M9F2brwsU3psc8y2WPTYuJjBR3YmN63sgLDdMj3Xy/Cz+F3Ozn01drA75AG0djWuAh9wiOCc4LuNSLBZvwJ+2xz3tvsk6aIcbdd2pcLUdqY2BoUYLbNfhlkcm9AeseN X-Exchange-RoutingPolicyChecked: bF7EmSuqtO+h/5sOK5lVTtOVz5zy68jzK1HBRy4g9VwQb+dZX47LABwJ0aoESIQFMelvbFd8BmA1Zu93aV7u5+/57c9SI969oQF7wQpy174Dpyu5NTLbTg8qYatt+6WckKSXIi2G+rFcUH2+U0ddmMnvW5mCthnjqyBp5WogQjkIEb+GFf5d9dDmUcDmcbkcaTE11OBxo1WcyeGD7WtSLU7D5JANKoE23lvir4EfUwKDPFw+miyL3XwM9Fz3rCRvVvRIds1hNM4xPgEJ4OF3QLZ9ZaIGYir7Tk+qdJgHUuAWNAw4bSMK7NyUgd4P7Nl6XSKdFj5lLnazesIqcOT5gg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:44.2100 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d1dbee9-e494-434d-d488-08dee96d801e X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6195.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6654 X-Authority-Analysis: v=2.4 cv=M4p97Sws c=1 sm=1 tr=0 ts=6a633cfa cx=c_pps a=N8fQrVaeAljVkTo8kKJ49A==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=gEfo2CItAAAA:8 a=sozttTNsAAAA:8 a=hcTNyZL6kbs_FXLRU4UA:9 a=sptkURWiP4Gy88Gu7hUp:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX4pa7aho7bsMG oAt8yAVLdukpsoL86OQPGNmQK1LOCulbz6QennXUATzlB/kYYwHhOt5xk/YFWioAjRiYwv425Mp GPn64xuYSH98+t4loB2rrcDbYEpYG/E= X-Proofpoint-ORIG-GUID: y76i2jtoKnIka8C-osD_fIZOQFuGBjHw X-Proofpoint-GUID: y76i2jtoKnIka8C-osD_fIZOQFuGBjHw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX1QIICrhQBZug dIzV7f7P6+ef9N/YrUhJOvmJoqv0BtmWqLTVLzz8BuA3nsAZgtvIVo7vI2gF0HopXsLG4BbVr8Z Rgk2EkhTwnHKEnz9uM1QdAcZLhahC4wAY6Mnc2+7kBh15+OCSCg7/FQjjzQddzQkDmuTtmiX8lg 8DewUzCL4wTiBEMSf8IEzaT+cTJxTB2kv8hEcT/cot/6xGhfJfAwG7ja3RnR+kUk0BR3T1ZGwAN nLQF24iBJSCxoOWZfkjSpp/lk1Rxbaru4z4/mWhD5VAJPN4lR0UXb+kJrB/TUHzR6uvXNeoolBA FA4fGQ6HKT46f0ZO3iqX1hmmB84T9XqmPg3N+phcWOTWu1mBY++XwFPXB2jPv3MqNOjTwoJAJ7y 1p4ODaiFSzJBELELZ/robf62nZZ0aQUnnz6KBEy2Iqft5IYXA2F2PaUjR8Ds9vRVKis4cbqcvKJ jZIB/TnooaKohwF1quQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" New binding document for Texas Instruments K3 Block Copy DMA (BCDMA) V2. BCDMA V2 is introduced as part of AM62L. Signed-off-by: Sai Sree Kartheek Adivi --- .../bindings/dma/ti/ti,am62l-dmss-bcdma.yaml | 212 ++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-= bcdma.yaml diff --git a/Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-bcdma.y= aml b/Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-bcdma.yaml new file mode 100644 index 0000000000000..4e676d30e6bef --- /dev/null +++ b/Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-bcdma.yaml @@ -0,0 +1,212 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2026 Texas Instruments Incorporated +# Author: Sai Sree Kartheek Adivi +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/ti/ti,am62l-dmss-bcdma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments K3 DMSS BCDMA V2 + +maintainers: + - Sai Sree Kartheek Adivi + +description: + The BCDMA V2 is intended to perform similar functions as the TR + mode channels of K3 UDMA-P. + BCDMA V2 includes block copy channels and Split channels. + + Block copy channels mainly used for memory to memory transfers, but with + optional triggers a block copy channel can service peripherals by access= ing + directly to memory mapped registers or area. + + Split channels can be used to service PSI-L based peripherals. + The peripherals can be PSI-L native or legacy, non PSI-L native peripher= als + with PDMAs. PDMA is tasked to act as a bridge between the PSI-L fabric a= nd the + legacy peripheral. + +allOf: + - $ref: /schemas/dma/dma-controller.yaml# + +properties: + compatible: + const: ti,am62l-dmss-bcdma + + reg: + items: + - description: BCDMA Control & Status Registers region + - description: Block Copy Channel Realtime Registers region + - description: Channel Realtime Registers region + - description: Ring Realtime Registers region + + reg-names: + items: + - const: gcfg + - const: bchanrt + - const: chanrt + - const: ringrt + + "#dma-cells": + const: 4 + description: | + cell 1: Trigger type for the channel + 0 - disable / no trigger + 1 - internal channel event + 2 - external signal + 3 - timer manager event + + cell 2: parameter for the trigger: + if cell 1 is 0 (disable / no trigger): + Unused, ignored + if cell 1 is 1 (internal channel event): + channel number whose TR event should trigger the current channel. + if cell 1 is 2 or 3 (external signal or timer manager event): + index of global interfaces that come into the DMA. + + Please refer to the device documentation for global interface in= dexes. + + cell 3: Channel ID for the peripheral + This is the mapped_channel_id assigned to the peripheral in the PS= I-L + endpoint map. For XYMF peripherals (SPI, CRC32) each chip-select/F= IFO + has a distinct channel ID; use the channel ID for the specific + direction and chip-select being requested. Use 0 for triggered + block-copy channels (cell 1 !=3D 0). + + Please refer to the device documentation for the channel map. + + cell 4: ASEL value for the channel + + interrupts: + minItems: 75 + maxItems: 75 + description: + Interrupts for DMA channels. + + interrupt-names: + minItems: 75 + maxItems: 75 + items: + pattern: "^chan([0-9]|1[0-3]|1[6-9]|2[0-9]|3[0-9]|4[0-7]|4[89]|5[0-3= ]|6[4-8]|8[01]|12[89]|13[0-9]|14[0-3])$" + description: + The name of the interrupt corresponding to the DMA channel. + +required: + - compatible + - reg + - reg-names + - "#dma-cells" + - interrupts + - interrupt-names + +unevaluatedProperties: false + +examples: + - | + #include + #include + + dma-controller@485c4000 { + compatible =3D "ti,am62l-dmss-bcdma"; + reg =3D <0x485c4000 0x4000>, + <0x48880000 0x10000>, + <0x48800000 0x80000>, + <0x47000000 0x200000>; + reg-names =3D "gcfg", "bchanrt", "chanrt", "ringrt"; + + #dma-cells =3D <4>; + + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D "chan0", "chan1", "chan2", "chan3", "chan4", + "chan5", "chan6", "chan7", "chan8", "chan9", + "chan10", "chan11", "chan12", "chan13", + "chan16", "chan17", "chan18", "chan19", + "chan20", "chan21", "chan22", "chan23", + "chan24", "chan25", "chan26", "chan27", + "chan28", "chan29", "chan30", "chan31", + "chan32", "chan33", "chan34", "chan35", + "chan36", "chan37", "chan38", "chan39", + "chan40", "chan41", "chan42", "chan43", + "chan44", "chan45", "chan46", "chan47", + "chan48", "chan49", "chan50", "chan51", + "chan52", "chan53", "chan64", "chan65", + "chan66", "chan80", "chan81", "chan67", + "chan68", "chan128", "chan129", "chan130", + "chan131", "chan132", "chan133", "chan134", + "chan135", "chan136", "chan137", "chan138", + "chan139", "chan140", "chan141", "chan142", + "chan143"; + }; --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 1D773421230; Fri, 24 Jul 2026 10:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888587; cv=fail; b=Gw7jdUX4qp+xsUQYxAoDJZA13/ngJZPK+DcM1nyx6MBLW1Pt3Hppfd6+j/dERLlVbUhTltAruiYf4bUm2DHp5TuMxTcmDAqrF2kaennAon64jLFisZaXQ6q/MFYO2pDhWs1ucSQ9TXjJ2yopzdh6tWRU3kEZ6tUdcGdW7/4S2pI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888587; c=relaxed/simple; bh=Vai8vedctXv59NdXoI1kAZRUddHT3EvmOTlnmUUgfJo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OsN1zAGXgRjZn4EuvMFUdQx4m1ZOZc7ZdR1KKB346nle3x5QvcOUmMjNi5QlZTcntytLuXK0RWB8HwYDDSU7iqRMUz4zwsTfbaictZVmaAjnwvLGaDAW7UR8B76gbPbljAOQb7nU6WQZY4NmOJMJ/mp3SZw+IVRPKyZwxU+LJjY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=aF6hRsac; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=J6cGm+9T; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="aF6hRsac"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="J6cGm+9T" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFTU01093779; Fri, 24 Jul 2026 05:22:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=rn2ToUShEZ3AkNds0FY/x49iRDmxuNyHoDDmmbF+S Zw=; b=aF6hRsac88GMDmWC0HbkgTaoIg1F5sosfBgDMA9qEAgzHPUHOiX3dTA/M BXoH/xmvhin0hkWMWmH8vNadkn7FDmFqrvvA9Mt1WHQUnC2qNF1AD7F+fm1rBsmI se4HnPWVj44g5xtERMVPkizKVo2umIIW1wcn9HclcC79SYzbLLEp+Eaj+S26ePO0 b6u03aOpY4k43qT5CZtru7WTZPnwdcPW1Ik7llL/7eDD9I8zR84LcZ4skh2jFYUt FGpwYlKqvRaY4dVAT/1KFERpiWA+GxH0x54sCg48qXuad5WTF0IGONL2aS1vBPXr u9nPnLwfgLvQNNClzUeCIaASAxdMw== Received: from ph0pr06cu001.outbound.protection.outlook.com (mail-westus3azon11011045.outbound.protection.outlook.com [40.107.208.45]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkyp7j40c-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:45 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MMMH6vO8kB8LSsnG9fxM9fLEdDCRqSurPPMf184LXJSChQHbXpuL14NZLaU8om2LROsQlL9eKRhAZzyFSZcaeOzIyAjp61R4E71/QR/LWWlZRW5sg8DiZlxt1OGtFz4fLtDwLiq+/XVTdLl7z0MddUqTjKNP9MDgonUVYtG+9C9yIImUF2LxL1R7GX9n7+4n3n/XupnLecG51erSERL9wH8U1r+JOZHqLW7xCKNCaFgqtAfuhxBL1cSayY8w7BgGRCYkiP88RIGzxrcBsGJt4RSDX49HG+APGYxFjHZEUPrcA8dioFzra/BONU320XFP8K1PVgD8DwPeAubXxrhhRg== 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=rn2ToUShEZ3AkNds0FY/x49iRDmxuNyHoDDmmbF+SZw=; b=NrquO+MWTEdloL6kFfM/Rm91DJ2vCx5Kn0T2NU+EdpjExtAj9BeDN6QS52DU8bD3mGGhJeJwGuUNc180gdWB53ZMr0kLsO/nNQ+207j/dSmT+JmKvpYjQMWSF7g7BKOPNbeRLuzLRyX7GYGZe3NtjFomneplPE/p0XE9AxJj9l9/50gch5XasuFvhqXwKbHbTpSDQS1IFrOYz8MNHNc1vbceytrHKCrCWybZu01IdODzjM7Gljj+dDtBOP/8ZXd/Lf+3IA/OnXikGwEcgBpRr+AKAxhvEhGUKzFZEsbuA72NBQq4qewCdq1AVV9nGeq6WJ4y7cPu6t2vrq3P9fDbyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rn2ToUShEZ3AkNds0FY/x49iRDmxuNyHoDDmmbF+SZw=; b=J6cGm+9T47QC4jylTJ3jznPr0vgYiq2gIy56h+VYGHwO4uxSWyYmAXo5i2Jpud7q/KGqc3T8ElpCOZo82yG75IXY3DZrPjcfN2oasZ4v0fQq4M+tDp9UNKYpNIQzgr2JljH+/hy30PlhVPrGIGNlE71qTMRNoVNXaniA1ULcMJA= Received: from CH0PR03CA0192.namprd03.prod.outlook.com (2603:10b6:610:e4::17) by CH0PR10MB4986.namprd10.prod.outlook.com (2603:10b6:610:c7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Fri, 24 Jul 2026 10:22:41 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:e4:cafe::30) by CH0PR03CA0192.outlook.office365.com (2603:10b6:610:e4::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:22:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:40 +0000 Received: from DLEE202.ent.ti.com (157.170.170.77) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:40 -0500 Received: from DLEE205.ent.ti.com (157.170.170.85) by DLEE202.ent.ti.com (157.170.170.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:40 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE205.ent.ti.com (157.170.170.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:40 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFT3017088; Fri, 24 Jul 2026 05:22:35 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 14/19] dt-bindings: dma: ti: Add K3 PKTDMA V2 Date: Fri, 24 Jul 2026 15:50:47 +0530 Message-ID: <20260724102115.2854-15-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000140:EE_|CH0PR10MB4986:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f2ebabe-f303-4454-2ee2-08dee96d7e16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|23010399003|82310400026|36860700016|1800799024|13003099007|921020|6133799003|56012099006|10067099003|18002099003|22082099003|3023799007; X-Microsoft-Antispam-Message-Info: XJLmFZ9Xn3IFYG4iRhodt4xVpLJLebEh5w4YcDmQexHjImL7+izX8tpX6eu4UO2869DLp9ehqIO/sowARf3rTDmvqfh5+lnfW7q0vaHIW5WsSN6CYD8mQo7ivn0ijLwJXkzuGr+xHxstGRgDIRPMW7vNdaAdnfSChP4A2NueAGG2WNmukYMDNQjdtfPL5gR7P7a/SvZXA9bDb92XDkSdIcjizzsJWK+L9yaYWxRqT2XlUeUzUK/CXQ1jIDqh0kB+x2p9J9ngL9xJ5LeauhGdzBhpZDDefnsj4HgnFAdphPpx68DsBD+UszqkKLt+Z/DVFMKh/9zSoIYiZ9GY6UTxEdnMmCmM6y0dbHcwb1qLsOFDENJ6MBhOQUZA7+8hcG/tPssrCEKykJJ8Nc5T7gc1S4mMYBUzVW4ZK0/HsO9IVC8QiT2/c7I79Mi4Y7QSyXgsD+VdEJvT54at1yFIekJhmvtpOr/686U4MoXy0dGyqh24yQxgbCfd3xr5tNZuG7yWjLYntMlzCmzhR0h2KnkZrtl40bW56jYGWx6IYRJOZKjeq0hNj1gXVrlTIMKCvROnrMnoAVZwP9lQ1tim8TucSAFMDi5O0glM79YezD+MX4O6d0J14JxYbCinghF8DssVwV7J8BKm+ijuVJYDtwyd6/9mt4H1YFsjlNvAchXzFnA5hEEfP0GwSuMTpAWlG0aXHJMtcqh036VC5AgvROYMDg== X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(23010399003)(82310400026)(36860700016)(1800799024)(13003099007)(921020)(6133799003)(56012099006)(10067099003)(18002099003)(22082099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wfVt5N/xWJHFTSdxbxgDjUfWmVVRqtFR+y07dlvtrpk05+adPXQqyf0EhORxEiwThoqoYMPjC9MaH31UzQMGkhOzO9aK5/6Rdgm29LhsLUkQF5wiMy+G8DlYGJskkbErr689X2Cpg0uWzoazkPIIVFnJBFe4usrRChW3ngGE8aKZUvdz4TC7yKpjQAsWdSqTmXffPgD2mrHC04ThA91QUSr0VpXNa/5XtSSpOIZjXPGzxVnbxARJNWRkUEn+qpcpZ8AwLNv3RhihDt+83mZbMpeH9xcwAlBmNeKH/+0ry5DIDeX+JYz1cm4duQhnt0nSkQSNFjau98kaB7HC1qLlBIf0xQgViEIA6Ou3pj5m299JpgQhsWfhzQJ1rBGCE9hFYPxEd+MxjrDqWFs//G73Qwljdx1NviIidZ7DSIfD+VvnGtOvpScC4QIGkbACpSD1 X-Exchange-RoutingPolicyChecked: ncSSNZMtgZzMz3JSZRJQiIEed6A4kXHH/i6Dk4+x/0a2AT4HwMGcmFhXUTaH1KW4ckGxm3eG+ZzOXz1FkZg6Do3rgCFOOQ2SBt5/6pLS40MxnzicSKOki4QRezqxvXchanAwyJbnQDqXBIC8l5v2KPs0DNZxFEFGgA5kIWlqFkw19ix7waaARZqCRWrwY/fmD52NYUGutfhkF5B3htHbL/eYlBiyqSQgpNtZQwRyvM+vY8doRf6Cq8L8jrSv+XwsoCSHZmtZQKG+CpLpublyxOw5lbkVofRo+sjMVGce81VfSZtwkYHUxxzW+zFEroyx3Qcp1hc7gYTRCQGRLO8qmQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:40.8270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f2ebabe-f303-4454-2ee2-08dee96d7e16 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4986 X-Authority-Analysis: v=2.4 cv=M4p97Sws c=1 sm=1 tr=0 ts=6a633cf5 cx=c_pps a=s6FLI2cSFE2dV00WXjZlDQ==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=gEfo2CItAAAA:8 a=sozttTNsAAAA:8 a=tgGeiVbHXLEZap8J-VEA:9 a=sptkURWiP4Gy88Gu7hUp:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX+7JzOVUhg/Jv x/O7mTOd/QwwcSNSM0WFwtw4TKBZ8qtxdd0d+Bp5M/8MSviAb5xT12DfsyspgtiyGGjyPwfaHGY giSy+ma9xQnbNwe+KZWhs4Rqm4Xb5nI= X-Proofpoint-ORIG-GUID: o-_hOmQhH8jUmXJsmXurtLTe6JNE6ShC X-Proofpoint-GUID: o-_hOmQhH8jUmXJsmXurtLTe6JNE6ShC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX6b/WWXwOlLXt QU4z9Ol1TpmdhTURxtHTo754CPR+N6KbrvE8PkvuQBqAZP4HxR/5pmvDvi1jaf7wYYNPI0x9ymJ 8rAMkSeQcm+NHPlfWsdUTiY67Zgrfm1cHgmQLIqxrHqG8/z7y53LxE18NJZwi49223qK2FaHl0L XV1QsUaVyHlZsE/wRFMtcONbIDkrmRQJswumnI6xG7a/XX0wrGndMUNdtIboJOlO9ujjkwLkcSR gKpJbkq3/ENGwLhagkJNNzR9QCg71R8hP152O+OPO1IEhcLQ5o4mFc70em700OJ9KZ+jMD+ZZAq 6WjGLdQbQlNyVPdQ2VKH0+67HLBQqtavWyeFy7kPnZnYtlW+3DsDweEoAqip/+Y/SgYlJXFk9zc nwFd+T4mmSa9p28Q9EPMBKqWtYLqQHw2c+mJAyDxkO61YjFqgF4IGWCN1F5nYzFWWZ/3wsjnVOz 0/HuGPOyjtp5Afk+Cgg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" New binding document for Texas Instruments K3 Packet DMA (PKTDMA) V2. PKTDMA V2 is introduced as part of AM62L. Signed-off-by: Sai Sree Kartheek Adivi --- .../bindings/dma/ti/ti,am62l-dmss-pktdma.yaml | 191 ++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-= pktdma.yaml diff --git a/Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-pktdma.= yaml b/Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-pktdma.yaml new file mode 100644 index 0000000000000..7173041708369 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/ti/ti,am62l-dmss-pktdma.yaml @@ -0,0 +1,191 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2026 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/ti/ti,am62l-dmss-pktdma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments K3 DMSS PKTDMA V2 + +maintainers: + - Sai Sree Kartheek Adivi + +description: + The PKTDMA V2 is intended to perform similar functions as the packet mode + channels of K3 UDMA-P. PKTDMA V2 only includes Split channels to service + PSI-L based peripherals. + + The peripherals can be PSI-L native or legacy, non PSI-L native peripher= als + with PDMAs. PDMA is tasked to act as a bridge between the PSI-L fabric a= nd the + legacy peripheral. + +allOf: + - $ref: /schemas/dma/dma-controller.yaml# + +properties: + compatible: + const: ti,am62l-dmss-pktdma + + reg: + items: + - description: Packet DMA Control & Status + - description: Channel Realtime + - description: Ring Realtime + + reg-names: + items: + - const: gcfg + - const: chanrt + - const: ringrt + + "#dma-cells": + const: 2 + description: | + cell 1: Flow ID for the peripheral + This is the hardware flow index assigned to the peripheral. TX flo= ws + use even indices and RX flows use odd indices in an interleaved + manner. For XYMF peripherals (SPI, CRC32) each chip-select/FIFO has + a distinct flow ID; use the flow ID for the specific direction and + chip-select being requested. + + Please refer to the device documentation for the flow map. + + cell 2: ASEL value for the channel + + interrupts: + minItems: 78 + maxItems: 78 + description: + Interrupts for DMA channels. + + interrupt-names: + minItems: 78 + maxItems: 78 + items: + pattern: "^(t|r)flow([0-9]|1[0-3]|1[6-9]|2[0-9]|3[0-9]|4[0-7]|6[4-9]= |7[0-9]|9[6-9]|10[0-9]|11[01])$" + description: + The name of the interrupt corresponding to the DMA flow. + TX flows use the "tflow" prefix, RX flows use the "rflow" prefix. + +required: + - compatible + - reg + - reg-names + - "#dma-cells" + - interrupts + - interrupt-names + +unevaluatedProperties: false + +examples: + - | + #include + #include + + dma-controller@485c0000 { + compatible =3D "ti,am62l-dmss-pktdma"; + reg =3D <0x485c0000 0x4000>, + <0x48900000 0x80000>, + <0x47200000 0x100000>; + reg-names =3D "gcfg", "chanrt", "ringrt"; + + #dma-cells =3D <2>; + + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D "rflow0", "tflow1", "rflow2", "tflow3", "rflow= 4", + "tflow5", "rflow6", "tflow7", "rflow8", "tflow9", + "rflow10", "tflow11", "rflow12", "tflow13", + "rflow16", "tflow17", "rflow18", "tflow19", + "rflow20", "tflow21", "rflow22", "tflow23", + "rflow24", "tflow25", "rflow26", "tflow27", + "rflow28", "tflow29", "rflow30", "tflow31", + "rflow32", "tflow33", "rflow34", "tflow35", + "rflow36", "tflow37", "rflow38", "tflow39", + "rflow40", "tflow41", "rflow42", "tflow43", + "rflow44", "tflow45", "rflow46", "tflow47", + "tflow64", "tflow65", "tflow66", "tflow67", + "tflow68", "tflow69", "tflow70", "tflow71", + "tflow72", "tflow73", "tflow74", "tflow75", + "tflow76", "tflow77", "tflow78", "tflow79", + "rflow96", "rflow97", "rflow98", "rflow99", + "rflow100", "rflow101", "rflow102", "rflow103", + "rflow104", "rflow105", "rflow106", "rflow107", + "rflow108", "rflow109", "rflow110", "rflow111"; + }; --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 7AF2B426416; Fri, 24 Jul 2026 10:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888590; cv=fail; b=M1iuemMnSlmfLJ6w5w1rMwJiwvTM1hIAWEwB4cnXa6y4f3IJocy1How2R1UKX0b3jgX+zvfgLmoDMGnHc9pXhKZkO+0ELuGPNMvT80pw2JIleGHyRtbYkCaPHyJIgGwN9xnqzkVhNaOnWqTJ5pBqIkAqE3Kidhoaxvx9hVRgdCA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888590; c=relaxed/simple; bh=itB6MkycUtMADRSZCIKkEkECzV5nURYe1QutKWaXjgY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IS4YzerqXV23YmrEknVGrG6PaOjlc4W3boHJhLB4MAYbzl0972dlkBpg/7jL1aH+BY+RzKIcMSB4yVGshR2KY919hJ6LuLc1faURjnpiFfV1AmCDEo5Ky0FHLEyhO9rDT1jkbuwRWul5gM9Vwv+vH5g+SsojPA8ywZoZprvfKQA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=dInbBnhR; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ipvxAEHi; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="dInbBnhR"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ipvxAEHi" Received: from pps.filterd (m0374956.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFcnj785578; Fri, 24 Jul 2026 05:22:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=RafoSg/rRS0ocxqA8msW6b042DQTCrc9ZzCU7RQU4 E4=; b=dInbBnhRU0YHY1z8B0zXwUi5dLJu2BZOpWCIFAMs3uclPciKMYpMRmZ7b xixjflw+qSfq3oJJjCPQzSYdQUe09iAhdv/lhUIe2H5BswdEDEAPl7EnPhgSYXfh cAftu+5/Dc5BY0hjUVhsZrGieulK6CuT/oAD0Dtv2Ty4e8/Ach/gTE9tIMAmk/v9 35QFjWJ+bHzc06/nQImZFPIx+SQhWqs1wGgiw6O/T5df7ExYzInWwbKanvILGgW2 kAZ/zjwjI7o6uD3S3v6k81U3e9EnVhJucI+HJPshte/nhRIwDLTyUdYswaCYxtP3 UNeVtkHzbRjTJfDE7ATmvk5j/bV9Q== Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazon11013053.outbound.protection.outlook.com [40.93.196.53]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fm5p304ns-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:53 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fg1B7DliHfjkfNvlBKuR+yWC2ys7cGl1XyS7yp7Zuc1St5mf7MGI/A8bgQouQP5IgM2Ql1QfZHdzJq+8UjUiLYNlsAHNp4yuODBRLehrsTgsyNroj2m1g2rt7+evNsP4rUQ74vCq7KO794bQx/J+BsMbrLHE/jbO5KxxdJ++noGQ9CxxnegCevzVC03H5OUCI6946/dR+TTA7VyhwxKcGNjpZKFGI7zUiJC9YgTF8zlFQqt9GvlXYLyQlms1XTd6GJUSjOmLxL4tRMZCeSFSlfEE0CqO0i1Y9lp6n5x1mUwZzSejN9bVvxkwvfY55V7Eig3o0rFQZ3GKNDMWqSmZ1w== 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=RafoSg/rRS0ocxqA8msW6b042DQTCrc9ZzCU7RQU4E4=; b=KJbzkKN0WZl/WaY65Y85IDRpOouFGDopEABRTngDX2CZqv9M8+iRjnd9xddQvu6fLCodr6eSn/FdqK9MBDkKrgCxsnFv9EGzIoOolMyRJ9dEwJZB7y+xVh1mJ5eT8+2Hu261LjmwlyMDNk6t1IUf5qIo8Owo84T09HEkNbeiyVRRa+cGoBysv+2I++nOEaRPZUMlnQnbnkBlIKuFqVb5e1lgntetczxBCCJE9oLayA4osUya70PMAnPpP/6etJbM1pRgwyAq6SUXQHSfmq4WuPSros3OMDpcmtvdCEIm+JBvA0FnLY2Jg6W8Of3IN2rKrXb3hJdxTQfdXsssBn/Pkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RafoSg/rRS0ocxqA8msW6b042DQTCrc9ZzCU7RQU4E4=; b=ipvxAEHiVcoO5OPtrGJWpYnwtAUXgHEpkexFaGnCUS37LONNBbNkEvHdadmT8lTNavBdD3NWagOHkUBc8U8p7iXnR7vGrCfYhE0Zal++UthbB0Fzq64M6CXGruG590EbCdiT+JUmhoH3pbltnOiDTnr+7Gek3LzeIRG8R8WgEWs= Received: from SJ0PR05CA0175.namprd05.prod.outlook.com (2603:10b6:a03:339::30) by LV3PR10MB8131.namprd10.prod.outlook.com (2603:10b6:408:27f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:22:48 +0000 Received: from MWH0EPF000C6195.namprd02.prod.outlook.com (2603:10b6:a03:339:cafe::65) by SJ0PR05CA0175.outlook.office365.com (2603:10b6:a03:339::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Fri, 24 Jul 2026 10:22:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by MWH0EPF000C6195.mail.protection.outlook.com (10.167.249.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:46 +0000 Received: from DFLE210.ent.ti.com (10.64.6.68) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:45 -0500 Received: from DFLE206.ent.ti.com (10.64.6.64) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:45 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:45 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFU3017088; Fri, 24 Jul 2026 05:22:40 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 15/19] dmaengine: ti: k3-psil-am62l: Add AM62Lx PSIL and PDMA data Date: Fri, 24 Jul 2026 15:50:48 +0530 Message-ID: <20260724102115.2854-16-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6195:EE_|LV3PR10MB8131:EE_ X-MS-Office365-Filtering-Correlation-Id: 57e2f886-1de6-46d1-0705-08dee96d8185 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700016|23010399003|1800799024|3023799007|13003099007|56012099006|18002099003|22082099003|921020|10067099003; X-Microsoft-Antispam-Message-Info: 2ctnBaq3nF72dDJ42chekD0ZllQoj98vZO1fw47I2bW43KKPt9j2gunkvwaxcWy3KsQplTifFV8o7KR8LuTpjWesjGTmDKberYZ5wO5GblGKE9QagFp2r9wxHbY10D2ZW4n+v6v29XD1j2GF8f4+FKmntrLv1ruUmwHnh/RMBUGMrkeQOq61Jx7B6otGQ7NO+rZspumO28W20pJ+RNf3N8dUYf6wqG1qJryrz3i0aH5ncBF4YoKn+Bbslj++L//v4LygcL8Tn7u8ntsuNcMBmDR+8jUyQadfk4V5I4/49cywbqS3Qr0baXvXI9JCd+UQ2n2UsV9CSGV1m6YuDdd4MOsHGDw3rBKov5SFOp6RqaewGJlOuBGh8iZ1K2flXZzU0SLpY6KPuwug4PUPQV+K3VrEJkdaJ3Ewd+MmThmpGe2EcyGbMnpqmZlyDv29z7VVltipviI+rlxK5Ev8Bhl10/Pvd4QrXM4VZ+uyoAo2/2xbyycct0Po4aQlkcqo3rcIsSjnLeu5I2pAuCI8fZtZNPn6WVTqKMBVFMMvRcPj5sRps4eOyX9TPDiV0sYm9Zk47x0YWXxiFC5GuTB7kObcnJXUqY88wTWuzrCL2dsHhBbP/nvS+L4bK2M2djJjUkyYfTCyHXIgjtbcr0yjhop774mpxX5guhUTMc8hDQDklbS/TUTL+7yKkMaOwq1q/ogH X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700016)(23010399003)(1800799024)(3023799007)(13003099007)(56012099006)(18002099003)(22082099003)(921020)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OkMhC8347EV3dKSynmTdR7J1lLKyRPkhA6NHLtooTUMwHtc+1xPCIj9GAE00T7fFvgvqpE+8AvK/eNqdsTMzWrMOvTLOcR0TZMomZVTZryxUqRhcs4OV+Lwn/KHn0vIiiI0ds5hLgAmWSIQ7kXy1xjvyhU9sG6FKQ5mlMbfEAVwUyW+vdKo1ZD0OTirJPgoVp5/sUTKpSJ8sZCVdmbMfDFIAhuRpyryR8j2ZvXPvu/4utEKdyZ1BMfMMwkWRVPK20CkkZmr6Lbzb4lE03pjgpjKmhN16vWsLbdUXlzmQ/jxfFR4Ul2UlE3UyAtqaEvnzaV9b8JcQ0gPA7aLtKOzRg2Gb5LwnWBcVFhGM4gHTBbwgU4sQ2GkU2kiDd31DEEBKMts8A/xyRBS7Yu+veAaojOmBJcyd0UM4wFSEwW/m4+M+SeMkXf5IoDxH+C0q/uXH X-Exchange-RoutingPolicyChecked: VdhNvD2lH5E17gNeQTvwJ8zdVnhONekwzwXKW6X4YzeNUQFhkUl+2pLY8SGS4I+sxMeqU1aPmI3+iAgAoOgKWtzRDAwcGq0bduSgsMGMJCTL8AMHII7YOLcV7u3esWO0Vy1sSU7BkNlGQ+gFOpyMmAu7RTFiJID0iIEq/hQc5oE5mGwlZ5RSb4yMPyUhinspkp5pU7H8zoXDiX6gVvBJxRH/z+Gf7kTj/AgaMMSGzZMTy/3417WqoAxFhtghbb0yv0xMEOzePku9bF9FseWLhgblczh2clFbmS1THHODAkKDC5zxn5xRkGZOu48EuaeavYSb8TkZYrX2HRLFu9n9GQ== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:46.5528 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57e2f886-1de6-46d1-0705-08dee96d8185 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6195.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8131 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX+Xg71UzYSTcj ijAPKpdUHbm8ooDyePVyClgrOA7CSW6YLYKASY+oFKCBZ8/rFrbb4tMU/OvrScD+TGI9IuoMWOe DsKhPT+oiBkYpS4Cke88ht4SV7/3QMRWpNj809/bYEUjA1QuXy0slhqdAl55iIak4+EC4u+F2s2 mluBCHGvbCskcKIkmhSFlwTM4DuYDKp3w3FvEi7DJS4xgN2TWGNb+A7H1sAYIGkitmuvggIE/yT OXqcA/1ODA2FBwp+5LoJHrubBRshW7bQkrHbUZIir/0uic9GUhVZIhxdVMpkIImp7wBjHU7Lm5V tj6A5jkgxG2QmqZhdgIO/hvbqu/+t/hShPg1J7art02Wdk2fwGyxZfyoml3dGiE+EVXFQ5Q5bVm 9FOGtv6wPHSyZCS8XWB/e7LzG4V5eTcbFm7PGTW9hBbexEarF+BIvNG1cgb1dowQWOOI9iJ6phJ Nd9cBAGbjzisT9z58mA== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfXw3G7kG1BU/9j nEMsKVux42lYEkKmkvuOMcBlOCozxzEbzwhV5u77yHS52dHa8r7RsVwLehoQOLtKm+zq2ttqxHn Fdko2m8JDRmLDkSKzVUSvkVG2QqmjNs= X-Proofpoint-GUID: 5r_t8SQnR_grftmVne5gvRo9wejK0S1_ X-Proofpoint-ORIG-GUID: 5r_t8SQnR_grftmVne5gvRo9wejK0S1_ X-Authority-Analysis: v=2.4 cv=C8PZDwP+ c=1 sm=1 tr=0 ts=6a633cfd cx=c_pps a=5zjvB78PlnLPEzvzEo0MXg==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=jwouBfj2j3NM8CExmVVE:22 a=sozttTNsAAAA:8 a=SxTibnW5tSAW0Is98DsA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Add PSIL and PDMA data for AM62Lx SoC. Introduce new PSIL_EP_PDMA_XYMF type for channels that have multiple selectable fifos. Also add a new fifo_id field to psil_endpoint_config to specify the selectable fifo_id. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/Makefile | 3 +- drivers/dma/ti/k3-psil-am62l.c | 169 +++++++++++++++++++++++++++++++++ drivers/dma/ti/k3-psil-priv.h | 5 + drivers/dma/ti/k3-psil.c | 71 +++++++++++++- include/linux/dma/k3-psil.h | 3 + 5 files changed, 247 insertions(+), 4 deletions(-) create mode 100644 drivers/dma/ti/k3-psil-am62l.c diff --git a/drivers/dma/ti/Makefile b/drivers/dma/ti/Makefile index 3b91c02e55eaf..41bfba944dc6c 100644 --- a/drivers/dma/ti/Makefile +++ b/drivers/dma/ti/Makefile @@ -14,6 +14,7 @@ k3-psil-lib-objs :=3D k3-psil.o \ k3-psil-am62.o \ k3-psil-am62a.o \ k3-psil-j784s4.o \ - k3-psil-am62p.o + k3-psil-am62p.o \ + k3-psil-am62l.o obj-$(CONFIG_TI_K3_PSIL) +=3D k3-psil-lib.o obj-$(CONFIG_TI_DMA_CROSSBAR) +=3D dma-crossbar.o diff --git a/drivers/dma/ti/k3-psil-am62l.c b/drivers/dma/ti/k3-psil-am62l.c new file mode 100644 index 0000000000000..ee77fae3787a4 --- /dev/null +++ b/drivers/dma/ti/k3-psil-am62l.c @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024-2025 Texas Instruments Incorporated - https://www.t= i.com + */ + +#include + +#include "k3-psil-priv.h" + +#define PSIL_PDMA_XY_TR(x, ch) \ + { \ + .thread_id =3D x, \ + .ep_config =3D { \ + .ep_type =3D PSIL_EP_PDMA_XY, \ + .mapped_channel_id =3D ch, \ + .default_flow_id =3D -1, \ + }, \ + } + +#define PSIL_PDMA_XYMF_TR(x, ch, fifo) \ + { \ + .thread_id =3D x, \ + .ep_config =3D { \ + .ep_type =3D PSIL_EP_PDMA_XYMF, \ + .mapped_channel_id =3D ch, \ + .default_flow_id =3D -1, \ + .fifo_id =3D fifo, \ + }, \ + } + +#define PSIL_PDMA_XY_PKT(x, ch) \ + { \ + .thread_id =3D x, \ + .ep_config =3D { \ + .ep_type =3D PSIL_EP_PDMA_XY, \ + .mapped_channel_id =3D ch, \ + .pkt_mode =3D 1, \ + .default_flow_id =3D -1 \ + }, \ + } + +#define PSIL_ETHERNET(x, ch, flow_base, flow_cnt) \ + { \ + .thread_id =3D x, \ + .ep_config =3D { \ + .ep_type =3D PSIL_EP_NATIVE, \ + .pkt_mode =3D 1, \ + .needs_epib =3D 1, \ + .psd_size =3D 16, \ + .mapped_channel_id =3D ch, \ + .flow_start =3D flow_base, \ + .flow_num =3D flow_cnt, \ + .default_flow_id =3D flow_base, \ + }, \ + } + +#define PSIL_PDMA_MCASP(x, ch) \ + { \ + .thread_id =3D x, \ + .ep_config =3D { \ + .ep_type =3D PSIL_EP_PDMA_XY, \ + .pdma_acc32 =3D 1, \ + .pdma_burst =3D 1, \ + .mapped_channel_id =3D ch, \ + .default_flow_id =3D -1 \ + }, \ + } + +/* PSI-L source thread IDs, used for RX (DMA_DEV_TO_MEM) */ +static struct psil_ep am62l_src_ep_map[] =3D { + /* PDMA_MAIN1 - UART0-6 */ + PSIL_PDMA_XY_PKT(0x4400, 0), + PSIL_PDMA_XY_PKT(0x4401, 2), + PSIL_PDMA_XY_PKT(0x4402, 4), + PSIL_PDMA_XY_PKT(0x4403, 6), + PSIL_PDMA_XY_PKT(0x4404, 8), + PSIL_PDMA_XY_PKT(0x4405, 10), + PSIL_PDMA_XY_PKT(0x4406, 12), + /* PDMA_MAIN0 - SPI0 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0x4300, 16, 0), + PSIL_PDMA_XYMF_TR(0x4300, 18, 1), + PSIL_PDMA_XYMF_TR(0x4300, 20, 2), + PSIL_PDMA_XYMF_TR(0x4300, 22, 3), + /* PDMA_MAIN0 - SPI1 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0x4301, 24, 0), + PSIL_PDMA_XYMF_TR(0x4301, 26, 1), + PSIL_PDMA_XYMF_TR(0x4301, 28, 2), + PSIL_PDMA_XYMF_TR(0x4301, 30, 3), + /* PDMA_MAIN0 - SPI2 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0x4302, 32, 0), + PSIL_PDMA_XYMF_TR(0x4302, 34, 1), + PSIL_PDMA_XYMF_TR(0x4302, 36, 2), + PSIL_PDMA_XYMF_TR(0x4302, 38, 3), + /* PDMA_MAIN0 - SPI3 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0x4303, 40, 0), + PSIL_PDMA_XYMF_TR(0x4303, 42, 1), + PSIL_PDMA_XYMF_TR(0x4303, 44, 2), + PSIL_PDMA_XYMF_TR(0x4303, 46, 3), + /* PDMA_MAIN2 - MCASP0-2 */ + PSIL_PDMA_MCASP(0x4500, 48), + PSIL_PDMA_MCASP(0x4501, 50), + PSIL_PDMA_MCASP(0x4502, 52), + /* PDMA_MAIN0 - AES */ + PSIL_PDMA_XY_TR(0x4700, 65), + /* PDMA_MAIN0 - ADC */ + PSIL_PDMA_XY_TR(0x4503, 80), + PSIL_PDMA_XY_TR(0x4504, 81), + PSIL_ETHERNET(0x4600, 96, 96, 16), +}; + +/* PSI-L destination thread IDs, used for TX (DMA_MEM_TO_DEV) */ +static struct psil_ep am62l_dst_ep_map[] =3D { + /* PDMA_MAIN1 - UART0-6 */ + PSIL_PDMA_XY_PKT(0xC400, 1), + PSIL_PDMA_XY_PKT(0xC401, 3), + PSIL_PDMA_XY_PKT(0xC402, 5), + PSIL_PDMA_XY_PKT(0xC403, 7), + PSIL_PDMA_XY_PKT(0xC404, 9), + PSIL_PDMA_XY_PKT(0xC405, 11), + PSIL_PDMA_XY_PKT(0xC406, 13), + /* PDMA_MAIN0 - SPI0 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0xC300, 17, 0), + PSIL_PDMA_XYMF_TR(0xC300, 19, 1), + PSIL_PDMA_XYMF_TR(0xC300, 21, 2), + PSIL_PDMA_XYMF_TR(0xC300, 23, 3), + /* PDMA_MAIN0 - SPI1 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0xC301, 25, 0), + PSIL_PDMA_XYMF_TR(0xC301, 27, 1), + PSIL_PDMA_XYMF_TR(0xC301, 29, 2), + PSIL_PDMA_XYMF_TR(0xC301, 31, 3), + /* PDMA_MAIN0 - SPI2 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0xC302, 33, 0), + PSIL_PDMA_XYMF_TR(0xC302, 35, 1), + PSIL_PDMA_XYMF_TR(0xC302, 37, 2), + PSIL_PDMA_XYMF_TR(0xC302, 39, 3), + /* PDMA_MAIN0 - SPI3 - CH0-3 */ + PSIL_PDMA_XYMF_TR(0xC303, 41, 0), + PSIL_PDMA_XYMF_TR(0xC303, 43, 1), + PSIL_PDMA_XYMF_TR(0xC303, 45, 2), + PSIL_PDMA_XYMF_TR(0xC303, 47, 3), + /* PDMA_MAIN2 - MCASP0-2 */ + PSIL_PDMA_MCASP(0xC500, 49), + PSIL_PDMA_MCASP(0xC501, 51), + PSIL_PDMA_MCASP(0xC502, 53), + /* PDMA_MAIN0 - SHA */ + PSIL_PDMA_XY_TR(0xC700, 64), + /* PDMA_MAIN0 - AES */ + PSIL_PDMA_XY_TR(0xC701, 66), + /* PDMA_MAIN0 - CRC32 - CH0-1 */ + PSIL_PDMA_XYMF_TR(0xC702, 67, 0), + PSIL_PDMA_XYMF_TR(0xC702, 68, 1), + /* CPSW3G */ + PSIL_ETHERNET(0xc600, 64, 64, 2), + PSIL_ETHERNET(0xc601, 66, 66, 2), + PSIL_ETHERNET(0xc602, 68, 68, 2), + PSIL_ETHERNET(0xc603, 70, 70, 2), + PSIL_ETHERNET(0xc604, 72, 72, 2), + PSIL_ETHERNET(0xc605, 74, 74, 2), + PSIL_ETHERNET(0xc606, 76, 76, 2), + PSIL_ETHERNET(0xc607, 78, 78, 2), +}; + +struct psil_ep_map am62l_ep_map =3D { + .name =3D "am62l", + .src =3D am62l_src_ep_map, + .src_count =3D ARRAY_SIZE(am62l_src_ep_map), + .dst =3D am62l_dst_ep_map, + .dst_count =3D ARRAY_SIZE(am62l_dst_ep_map), +}; diff --git a/drivers/dma/ti/k3-psil-priv.h b/drivers/dma/ti/k3-psil-priv.h index a577be97e3447..970afd46a79e6 100644 --- a/drivers/dma/ti/k3-psil-priv.h +++ b/drivers/dma/ti/k3-psil-priv.h @@ -35,6 +35,10 @@ struct psil_ep_map { }; =20 struct psil_endpoint_config *psil_get_ep_config(u32 thread_id); +struct psil_endpoint_config *psil_get_ep_config_by_id(u32 channel_id, + bool is_pktdma, + u32 *thread_id, + bool *dev_to_mem); =20 /* SoC PSI-L endpoint maps */ extern struct psil_ep_map am654_ep_map; @@ -46,5 +50,6 @@ extern struct psil_ep_map am62_ep_map; extern struct psil_ep_map am62a_ep_map; extern struct psil_ep_map j784s4_ep_map; extern struct psil_ep_map am62p_ep_map; +extern struct psil_ep_map am62l_ep_map; =20 #endif /* K3_PSIL_PRIV_H_ */ diff --git a/drivers/dma/ti/k3-psil.c b/drivers/dma/ti/k3-psil.c index c4b6f0df46861..ed9c92d5a7b2b 100644 --- a/drivers/dma/ti/k3-psil.c +++ b/drivers/dma/ti/k3-psil.c @@ -28,6 +28,7 @@ static const struct soc_device_attribute k3_soc_devices[]= =3D { { .family =3D "J784S4", .data =3D &j784s4_ep_map }, { .family =3D "AM62PX", .data =3D &am62p_ep_map }, { .family =3D "J722S", .data =3D &am62p_ep_map }, + { .family =3D "AM62LX", .data =3D &am62l_ep_map }, { /* sentinel */ } }; =20 @@ -71,6 +72,57 @@ struct psil_endpoint_config *psil_get_ep_config(u32 thre= ad_id) } EXPORT_SYMBOL_GPL(psil_get_ep_config); =20 +struct psil_endpoint_config *psil_get_ep_config_by_id(u32 channel_id, + bool is_pktdma, + u32 *thread_id, + bool *dev_to_mem) +{ + int i; + + mutex_lock(&ep_map_mutex); + if (!soc_ep_map) { + const struct soc_device_attribute *soc; + + soc =3D soc_device_match(k3_soc_devices); + if (soc) + soc_ep_map =3D soc->data; + } + + if (soc_ep_map->src) { + for (i =3D 0; i < soc_ep_map->src_count; i++) { + struct psil_ep *ep =3D &soc_ep_map->src[i]; + + if (ep->ep_config.mapped_channel_id !=3D (s16)channel_id) + continue; + if ((bool)ep->ep_config.pkt_mode !=3D is_pktdma) + continue; + *thread_id =3D ep->thread_id; + *dev_to_mem =3D true; + mutex_unlock(&ep_map_mutex); + return &ep->ep_config; + } + } + + if (soc_ep_map->dst) { + for (i =3D 0; i < soc_ep_map->dst_count; i++) { + struct psil_ep *ep =3D &soc_ep_map->dst[i]; + + if (ep->ep_config.mapped_channel_id !=3D (s16)channel_id) + continue; + if ((bool)ep->ep_config.pkt_mode !=3D is_pktdma) + continue; + *thread_id =3D ep->thread_id; + *dev_to_mem =3D false; + mutex_unlock(&ep_map_mutex); + return &ep->ep_config; + } + } + + mutex_unlock(&ep_map_mutex); + return ERR_PTR(-ENOENT); +} +EXPORT_SYMBOL_GPL(psil_get_ep_config_by_id); + int psil_set_new_ep_config(struct device *dev, const char *name, struct psil_endpoint_config *ep_config) { @@ -90,9 +142,22 @@ int psil_set_new_ep_config(struct device *dev, const ch= ar *name, index, &dma_spec)) return -ENOENT; =20 - thread_id =3D dma_spec.args[0]; - - dst_ep_config =3D psil_get_ep_config(thread_id); + if (of_device_is_compatible(dev->of_node, "ti,am62l-dmss-pktdma")) { + bool dev_to_mem; + + dst_ep_config =3D psil_get_ep_config_by_id(dma_spec.args[0], + true, + &thread_id, &dev_to_mem); + } else if (of_device_is_compatible(dev->of_node, "ti,am62l-dmss-bcdma")) { + bool dev_to_mem; + + dst_ep_config =3D psil_get_ep_config_by_id(dma_spec.args[0], + false, + &thread_id, &dev_to_mem); + } else { + thread_id =3D dma_spec.args[0]; + dst_ep_config =3D psil_get_ep_config(thread_id); + } if (IS_ERR(dst_ep_config)) { pr_err("PSIL: thread ID 0x%04x not defined in map\n", thread_id); diff --git a/include/linux/dma/k3-psil.h b/include/linux/dma/k3-psil.h index 5f106d852f1cf..36e347311f8b2 100644 --- a/include/linux/dma/k3-psil.h +++ b/include/linux/dma/k3-psil.h @@ -35,6 +35,7 @@ enum udma_tp_level { enum psil_endpoint_type { PSIL_EP_NATIVE =3D 0, PSIL_EP_PDMA_XY, + PSIL_EP_PDMA_XYMF, PSIL_EP_PDMA_MCAN, PSIL_EP_PDMA_AASRC, }; @@ -78,6 +79,8 @@ struct psil_endpoint_config { u16 flow_start; u16 flow_num; s16 default_flow_id; + /* XYMF FIFO index (0-3 for CS0-CS3), Only for PSIL_EP_PDMA_XYMF */ + u8 fifo_id; }; =20 int psil_set_new_ep_config(struct device *dev, const char *name, --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 60F8D420E98; Fri, 24 Jul 2026 10:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888610; cv=fail; b=opniupB8gW5L67Dgbu1zZvfkCTQ4UYs2xOjNbeqGxnec9lNBpeU9vLUMufhUvjNyN/FK+HJJXIq3VrNwZCtTyuMsPRMPAR5jcf+xr7Z0WbmNVN90xlloxLcUzG+GgThNtOtKcMzDVZoBhzO1f3XcNjByeLLbTO+MPsifMDWzpx8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888610; c=relaxed/simple; bh=hhmDPV43QZUoOT/pjAqwUwpjVcN9ft7qLiMC6N4c7Ps=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Zz0oWff6qAY7RKC/Jcsdro3nhSkmRmJ55dNc2FVZMEW1URNBfAif4gegFMNf6siX5wpOIOoMi9Bz3j/oqiv4vdwtVi2fi2pVLY++B7cgAMQl2zGiGYI5HV7Zab+Ml64Nr6TFnkC4t1638VOX0lQ3TH/JpsrlGGG2TY8jkpAoT8E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=Dt7qtINP; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=PtyQaFAY; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="Dt7qtINP"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="PtyQaFAY" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAFC4e2796788; Fri, 24 Jul 2026 05:22:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=xhgGf5UXWUorDYGasOngYTxXTZweHzgikhGpIwuVL GE=; b=Dt7qtINPA7O+uf0w4GRLYnivQ94AVEY/3tmMUkmB3ZWmRdEG73kiK04hO dfneKZi5/IHQtB5d0Oo2jzT9r8iB9GFT9pZxa1eZ/lSXTdmN3tFKV/bceURIieC4 XqZZbLg3pAN+zwXVeJ/V4CmBeMLwg2j0oEqipj52fy2cA5t2RPAvsOkKlqtYiuxf rqFmy6QjdGdjgzZhZRS3CFxYs2oxprzeKuJd2YGrzy+vmHVas50j17CoDJ6vlUTv /mU1MGxEu96xJxGN2d+pkCWj1szvY7XqnPRj/wyBaBSCjIXidgfO3RwMsRWNxGlj BpBE7QOISGoFNJ4sdb4eZehC48Q8g== Received: from sj2pr03cu001.outbound.protection.outlook.com (mail-westusazon11012002.outbound.protection.outlook.com [52.101.43.2]) by m0384305.ppops.net (PPS) with ESMTPS id 4fm3v38px4-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:22:58 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xGRV62F6E0lhVPGVHH4K+Bo9JHopKIU5e7H6VCVxhseHlsdvqo+F6gNZnVZDrPuPu5iZ2V0AAmuiVqubLz6EfWftmYoDKM6adIBTptQ7AkIS8RtATZRxIGCvTpsZSbNU9nFIGMvQP2QDQ/8F0dpSX/qgj7Foj3B3ZlD5BuTxlHo4uCeHLiM9OqBpy1BcA3q2xwIOBDB8Ow4uSiwtMdE+mNVUy++gH++74ldj1Hi1lXr0whN/oe+ridw5HvOrGSFc1jNWJ6OHMq6q3g/fw3Jm1ZFVD7LI3KH19V3LYH07/g5lVElPLoOurpX1aXqtCgj7HF1dGFrGL/1SGhXcKT2YIQ== 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=xhgGf5UXWUorDYGasOngYTxXTZweHzgikhGpIwuVLGE=; b=U2f7AivhEJjED/wNhqkjSYjBdUidxSIf65RrqUeXSn9AO9ClNMYvyXOeCu83L+Yrx9qvX9fsL6OrHSgpu9F/ncZw6x9Fb9H3mpL/zM+iAahP2ZlHpTzE2H+4lRqqWyHeZtuB2pDw574RgDykORzswfB8PpMsbMALPEsQDgK/oO43wXT9hpMIao0R2ezeOPwKJaVR67Ed2Lde8WEjoqv1KaE9gQ+s3XWUjkdQ+p/v25w2NjkJgteVqCFADfPP2apn6UBcjs5z4wdjw4jkAAfgwWQ3DD/N0nxeOB3gaJsdDN7aMF09XZcLwu8W06xv4dNAyZqylid0RPqiZ1o/KeWFJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xhgGf5UXWUorDYGasOngYTxXTZweHzgikhGpIwuVLGE=; b=PtyQaFAYVWgqyVhHeWCj+XD1OIeVxCNpwgSUKL1T7phAHS+5iIreA2jVKvjx8rSzWycV5IAj2T+cpqtjEH+qXBCkKRV5ySpcTdZmO7PSyBNjALz7YkPHDYRmoXGrzoWpLCw/Ym2cjkZxLoPS+z88QBm//ozL/pu0qf7c8BvErlo= Received: from MW4PR03CA0033.namprd03.prod.outlook.com (2603:10b6:303:8e::8) by IA0PR10MB6724.namprd10.prod.outlook.com (2603:10b6:208:43e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:22:54 +0000 Received: from MWH0EPF000C6191.namprd02.prod.outlook.com (2603:10b6:303:8e:cafe::8d) by MW4PR03CA0033.outlook.office365.com (2603:10b6:303:8e::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.12 via Frontend Transport; Fri, 24 Jul 2026 10:22:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by MWH0EPF000C6191.mail.protection.outlook.com (10.167.249.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:52 +0000 Received: from DFLE206.ent.ti.com (10.64.6.64) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:50 -0500 Received: from DFLE207.ent.ti.com (10.64.6.65) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:50 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE207.ent.ti.com (10.64.6.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:50 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFV3017088; Fri, 24 Jul 2026 05:22:45 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 16/19] dmaengine: ti: k3-udma-v2: New driver for K3 BCDMA_V2 Date: Fri, 24 Jul 2026 15:50:49 +0530 Message-ID: <20260724102115.2854-17-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6191:EE_|IA0PR10MB6724:EE_ X-MS-Office365-Filtering-Correlation-Id: cfd6f3f9-43fa-4c4b-6bf9-08dee96d84f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|23010399003|376014|7416014|82310400026|3023799007|10067099003|56012099006|6133799003|13003099007|921020|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: 0c9tWkS/moAYjhB/M0sQ6lggk15l1RqvUM5fYTnsy2x9gett2VE/1dYjIOEnAhqc6ybtLBsm9loMpLo4/3Suacr26RN4iTZB1x3j9O4Hn1bnwgSMtCAOCscKIYWWHx1Z5pKThts9bmBxytI/AWhnB4DVGFZxxA0469T/htGUP2qx2BUMmFR5MnTaIu+u+3FYg4/FwzIBzeLeKaErs450S7o/dJshUs6hA/aA/sdvo/1X5bjrPdGjnNY0ehGPVNZnVGaEEP6Hyvv6q6opJnpnnj00txVqZq1JUMSiJtf5AdAvmYrpc7crYA1QeOS5yVb1BZNW5q7355Fhgl7yZ3hBlonmbdc3eQbeg2MeSaM2lqzkUi3s8lbr8f9yJ0ATKjRCW9qlL4I23UrbX+lIJickX8Y+UTYUK1IcoHO3gdrz0Ff1Dk492dx0H+iErb2Kcr/H6wxwKKji5DBa163BKFCaFLPkVXkfJLAu7vKzowkPnUZT77E+M8yqS1C2OjnHm5y0thqMGdC5OjbrsVbqgxwFvHUjOTLCEmnXBhA6qrkm5DvUORGZczA3uzMecJp2411GbcgV5eYHDRKdNTyQcWCxgNxKlzekgX62lZ9HAnCH8gPduGN1kE1OXSM2RJUrMlrjz71wxenJhBG7m7TCTIw0ObFe9WVjOB8OoZIaf7Z27Vsrh2piTkK9EarX4cQSEZAEdajSrM/hxjtJDIanTBFvUw== X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(23010399003)(376014)(7416014)(82310400026)(3023799007)(10067099003)(56012099006)(6133799003)(13003099007)(921020)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k+pj84Ds5am/s5Gei+XWQYc4hz4gcF6BkGA4hgGiEFVt34s0VoabvR7dot5xLp6kDgX71S66s3nwaTFNYzmOF9qsJ2mEar5d0/t8eqti17S2gr77DUB8xg6qF90tzf0YH0yHPeASrizlavaHZQG5D1APP2w2xrVBe1r1qQnNWQvXP1bGZI4ARD+057Wav/d/WrfwRT975klGtegod8rjl+QIzMm+nWp6O/DFfZniJ5fbogVZduQroBJ/ypvONyOFHpIWQDB/Wg6nA4UDfCcVF7b7gOwmTUsa32Osc3nIkqgIp/XiZsmtdyhPToMDtMYtss0i38KU515psckLPrKq4EArc38AhzfSkKvRQGcwmWQywNehmOGEhijywgmRLOYBd4YzCvrPEBjauWzfkhdU2foOPKfonQ/2metN2cFJqBwu7g4pyLQ4Yfafr6+B97gz X-Exchange-RoutingPolicyChecked: CKp9vRIfpGFxdNKBtquWnqWchMy30hlIfPMSBEVdxFpHveBHhxw5s4nehqiCyhaAGuYNjq7Lxt7U+osE1f5P4IGg7aS/dR32+rXWYxYOg3QVk8embXOW3C1hrcb/rkMxir2SHDf8wA+2zsHjUQaPjvMbJR9OztQc4eHsN2IYbtFxgQApxPMihYgkS5PFx6JZZjkNCuki5V41Q1wgIGYMjHkkfEoRr0oyYEihIH3jkc7CYNdxH2dH7h1jN1SmDRRRVeyKGgDXvGZiI4Ox0YpRu6T7UWqDQk6kyFUESGog+DZkZncfA9vS6G4Mjv+tkF/3RM0dl+rInOAUXmXIhP9WtA== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:52.3156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfd6f3f9-43fa-4c4b-6bf9-08dee96d84f4 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C6191.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6724 X-Proofpoint-GUID: OlBChVd29gzTu7VmbyINrNyQ-9TphqSs X-Proofpoint-ORIG-GUID: OlBChVd29gzTu7VmbyINrNyQ-9TphqSs X-Authority-Analysis: v=2.4 cv=dLWWXuZb c=1 sm=1 tr=0 ts=6a633d02 cx=c_pps a=E0F994Awt23I4DNeuEdoUA==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=gedxhmekW7z0cqXWnrIA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfXzGBHtgkeZulJ o3iETfoL/LGmI32AmL8sEgQJ6uSFsXSX+0wg5ThOs0QS60jnYxfRHkntIFvwm02GvawSuX6oLZ4 SxZlbU16Zsd3n+50z4H/iwCkRiZoiDH5tNpt2emt+zDwmgmpQ20N+mXQoqGoy6PSxFiPoN99Vm4 d7dU5RuTGDteNW9nz5NHp4aq+663tA/xZTbnzUz9O5RgswEAOiuoKm8YXUekz/1iQKtUlaK0lTq re5tcgyeK1b7ouIZpeAMfhJUAMQUIs8Y6o612eFvKKN/dSfW9ES2Fel3bqcnD+cvgupB1+7uf8U VTHvx6U5AY9cNpY86vd0xvXogKznI2kwBi9NtnYFb/adIHNGUczzvKSyzHSBqX2BL2pBokAovRI BWixmsUQRq+84EmhNTweoDTgia8qITgVwzL0WrqcMF4v6e2ec7uGR2D8SBcj8CrhRfMlbtq5lWM dcQLWSbUeQeEFEU17oA== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX63SpjKBEuGWA wpbwWfsRXCMzWnwqVL+eMLI23ObAAUmDi9SmdaGKVtKriFPYrLD/8jC64YNDPQrtPZlW8/b1quQ iVfTUoI3syU2fTT9dMniA1EY9i2pneQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Add support for BCDMA_V2. The BCDMA_V2 is different than the existing BCDMA supported by the k3-udma driver. The changes in BCDMA_V2 are: - Autopair: There is no longer a need for PSIL pair and AUTOPAIR bit needs to set in the RT_CTL register. - Static channel mapping: Each channel is mapped to a single peripheral. - Direct IRQs: There is no INT-A and interrupt lines from DMA are directly connected to GIC. - Remote side configuration handled by DMA. So no need to write to PEER registers to START / STOP / PAUSE / TEARDOWN. - Unified Channel Space: Tx and Rx channels share a single register space. Each channel index is specifically fixed in hardware as either Tx or Rx in an interleaved manner. Also, since a version member is introduced in the match_data, Add version v1 in match_data of SoCs using v1 DMA. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/Kconfig | 14 +- drivers/dma/ti/Makefile | 1 + drivers/dma/ti/k3-udma-common.c | 93 ++- drivers/dma/ti/k3-udma-v2.c | 1302 +++++++++++++++++++++++++++++ drivers/dma/ti/k3-udma.c | 9 + drivers/dma/ti/k3-udma.h | 123 +-- include/linux/soc/ti/k3-ringacc.h | 3 + 7 files changed, 1468 insertions(+), 77 deletions(-) create mode 100644 drivers/dma/ti/k3-udma-v2.c diff --git a/drivers/dma/ti/Kconfig b/drivers/dma/ti/Kconfig index 712e456015459..40713bd1e8e9b 100644 --- a/drivers/dma/ti/Kconfig +++ b/drivers/dma/ti/Kconfig @@ -49,6 +49,18 @@ config TI_K3_UDMA Enable support for the TI UDMA (Unified DMA) controller. This DMA engine is used in AM65x and j721e. =20 +config TI_K3_UDMA_V2 + tristate "Texas Instruments K3 UDMA v2 support" + depends on ARCH_K3 + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + select TI_K3_UDMA_COMMON + select TI_K3_RINGACC + select TI_K3_PSIL + help + Enable support for the TI UDMA (Unified DMA) v2 controller. This + DMA engine is used in AM62L. + config TI_K3_UDMA_COMMON tristate default n @@ -63,7 +75,7 @@ config TI_K3_UDMA_GLUE_LAYER =20 config TI_K3_PSIL tristate - default TI_K3_UDMA + default TI_K3_UDMA || TI_K3_UDMA_V2 =20 config TI_DMA_CROSSBAR bool diff --git a/drivers/dma/ti/Makefile b/drivers/dma/ti/Makefile index 41bfba944dc6c..296aa3421e71b 100644 --- a/drivers/dma/ti/Makefile +++ b/drivers/dma/ti/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_TI_CPPI41) +=3D cppi41.o obj-$(CONFIG_TI_EDMA) +=3D edma.o obj-$(CONFIG_DMA_OMAP) +=3D omap-dma.o obj-$(CONFIG_TI_K3_UDMA) +=3D k3-udma.o +obj-$(CONFIG_TI_K3_UDMA_V2) +=3D k3-udma-v2.o obj-$(CONFIG_TI_K3_UDMA_COMMON) +=3D k3-udma-common.o obj-$(CONFIG_TI_K3_UDMA_GLUE_LAYER) +=3D k3-udma-glue.o k3-psil-lib-objs :=3D k3-psil.o \ diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index 7ae2c70eb5414..10a42fff128aa 100644 --- a/drivers/dma/ti/k3-udma-common.c +++ b/drivers/dma/ti/k3-udma-common.c @@ -171,8 +171,13 @@ bool udma_is_desc_really_done(struct udma_chan *uc, st= ruct udma_desc *d) uc->config.dir !=3D DMA_MEM_TO_DEV || !(uc->config.tx_flags & DMA_PRE= P_INTERRUPT)) return true; =20 - peer_bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_PEER_BCNT_REG); - bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); + if (uc->ud->match_data->version =3D=3D K3_UDMA_V1) { + peer_bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_PEER_BCNT_REG); + bcnt =3D udma_tchanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); + } else { + peer_bcnt =3D udma_chanrt_read(uc, UDMA_CHAN_RT_PERIPH_BCNT_REG); + bcnt =3D udma_chanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); + } =20 /* Transfer is incomplete, store current residue and time stamp */ if (peer_bcnt < bcnt) { @@ -319,6 +324,7 @@ udma_prep_slave_sg_tr(struct udma_chan *uc, struct scat= terlist *sgl, size_t tr_size; int num_tr =3D 0; int tr_idx =3D 0; + u32 extra_flags =3D 0; u64 asel; =20 /* estimate the number of TRs we will need */ @@ -342,6 +348,11 @@ udma_prep_slave_sg_tr(struct udma_chan *uc, struct sca= tterlist *sgl, else asel =3D (u64)uc->config.asel << K3_ADDRESS_ASEL_SHIFT; =20 + if (uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA && + uc->ud->match_data->version =3D=3D K3_UDMA_V2 && + dir =3D=3D DMA_MEM_TO_DEV) + extra_flags =3D CPPI5_TR_CSF_EOP; + tr_req =3D d->hwdesc[0].tr_req_base; for_each_sg(sgl, sgent, sglen, i) { dma_addr_t sg_addr =3D sg_dma_address(sgent); @@ -358,7 +369,7 @@ udma_prep_slave_sg_tr(struct udma_chan *uc, struct scat= terlist *sgl, =20 cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, false, false, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); - cppi5_tr_csf_set(&tr_req[tr_idx].flags, CPPI5_TR_CSF_SUPR_EVT); + cppi5_tr_csf_set(&tr_req[tr_idx].flags, CPPI5_TR_CSF_SUPR_EVT | extra_fl= ags); =20 sg_addr |=3D asel; tr_req[tr_idx].addr =3D sg_addr; @@ -372,7 +383,7 @@ udma_prep_slave_sg_tr(struct udma_chan *uc, struct scat= terlist *sgl, false, false, CPPI5_TR_EVENT_SIZE_COMPLETION, 0); cppi5_tr_csf_set(&tr_req[tr_idx].flags, - CPPI5_TR_CSF_SUPR_EVT); + CPPI5_TR_CSF_SUPR_EVT | extra_flags); =20 tr_req[tr_idx].addr =3D sg_addr + tr0_cnt1 * tr0_cnt0; tr_req[tr_idx].icnt0 =3D tr1_cnt0; @@ -593,7 +604,7 @@ int udma_configure_statictr(struct udma_chan *uc, struc= t udma_desc *d, enum dma_slave_buswidth dev_width, u16 elcnt) { - if (uc->config.ep_type !=3D PSIL_EP_PDMA_XY) + if (uc->config.ep_type !=3D PSIL_EP_PDMA_XY && uc->config.ep_type !=3D PS= IL_EP_PDMA_XYMF) return 0; =20 /* Bus width translates to the element size (ES) */ @@ -951,7 +962,8 @@ udma_prep_dma_cyclic_tr(struct udma_chan *uc, dma_addr_= t buf_addr, * As we are in cyclic mode, we do not know which period might be the * last one, so set the flag for each period. */ - if (uc->config.ep_type =3D=3D PSIL_EP_PDMA_XY && + if ((uc->config.ep_type =3D=3D PSIL_EP_PDMA_XY || + uc->config.ep_type =3D=3D PSIL_EP_PDMA_XYMF) && uc->ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { period_csf =3D CPPI5_TR_CSF_EOP; } @@ -2052,6 +2064,8 @@ int udma_get_tchan(struct udma_chan *uc) uc->tchan =3D NULL; return ret; } + if (ud->match_data->version =3D=3D K3_UDMA_V2) + uc->chan =3D uc->tchan; =20 if (ud->tflow_cnt) { int tflow_id; @@ -2102,6 +2116,8 @@ int udma_get_rchan(struct udma_chan *uc) uc->rchan =3D NULL; return ret; } + if (ud->match_data->version =3D=3D K3_UDMA_V2) + uc->chan =3D uc->rchan; =20 return 0; } @@ -2377,18 +2393,22 @@ int bcdma_setup_resources(struct udma_dev *ud) ud->tchan_tpl.levels =3D 1; } =20 - ud->bchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->bchan_cnt), - sizeof(unsigned long), GFP_KERNEL); + ud->bchan_map =3D devm_bitmap_zalloc(dev, ud->bchan_cnt, GFP_KERNEL); ud->bchans =3D devm_kcalloc(dev, ud->bchan_cnt, sizeof(*ud->bchans), GFP_KERNEL); - ud->tchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), - sizeof(unsigned long), GFP_KERNEL); + ud->tchan_map =3D devm_bitmap_zalloc(dev, ud->tchan_cnt, GFP_KERNEL); ud->tchans =3D devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), GFP_KERNEL); - ud->rchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), - sizeof(unsigned long), GFP_KERNEL); - ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), - GFP_KERNEL); + if (ud->match_data->version =3D=3D K3_UDMA_V1) { + ud->rchan_map =3D devm_bitmap_zalloc(dev, ud->rchan_cnt, GFP_KERNEL); + ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), + GFP_KERNEL); + } else { + ud->rchan_map =3D ud->tchan_map; + ud->rchans =3D ud->tchans; + ud->chan_map =3D ud->tchan_map; + ud->chans =3D ud->tchans; + } /* BCDMA do not really have flows, but the driver expect it */ ud->rflow_in_use =3D devm_kcalloc(dev, BITS_TO_LONGS(ud->rchan_cnt), sizeof(unsigned long), @@ -2484,11 +2504,18 @@ int setup_resources(struct udma_dev *ud) if (ret) return ret; =20 - ch_count =3D ud->bchan_cnt + ud->tchan_cnt + ud->rchan_cnt; - if (ud->bchan_cnt) - ch_count -=3D bitmap_weight(ud->bchan_map, ud->bchan_cnt); - ch_count -=3D bitmap_weight(ud->tchan_map, ud->tchan_cnt); - ch_count -=3D bitmap_weight(ud->rchan_map, ud->rchan_cnt); + if (ud->match_data->version =3D=3D K3_UDMA_V1) { + ch_count =3D ud->bchan_cnt + ud->tchan_cnt + ud->rchan_cnt; + if (ud->bchan_cnt) + ch_count -=3D bitmap_weight(ud->bchan_map, ud->bchan_cnt); + ch_count -=3D bitmap_weight(ud->tchan_map, ud->tchan_cnt); + ch_count -=3D bitmap_weight(ud->rchan_map, ud->rchan_cnt); + } else { + ch_count =3D ud->bchan_cnt + ud->tchan_cnt; + if (ud->bchan_cnt) + ch_count -=3D bitmap_weight(ud->bchan_map, ud->bchan_cnt); + ch_count -=3D bitmap_weight(ud->tchan_map, ud->tchan_cnt); + } if (!ch_count) return -ENODEV; =20 @@ -2510,15 +2537,25 @@ int setup_resources(struct udma_dev *ud) 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)); + if (ud->match_data->version =3D=3D K3_UDMA_V1) { + 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)); + } else { + dev_info(dev, + "Channels: %d (bchan: %u, chan: %u)\n", + ch_count, + ud->bchan_cnt - bitmap_weight(ud->bchan_map, + ud->bchan_cnt), + ud->chan_cnt - bitmap_weight(ud->chan_map, + ud->chan_cnt)); + } break; case DMA_TYPE_PKTDMA: dev_info(dev, diff --git a/drivers/dma/ti/k3-udma-v2.c b/drivers/dma/ti/k3-udma-v2.c new file mode 100644 index 0000000000000..e7989b0b34cac --- /dev/null +++ b/drivers/dma/ti/k3-udma-v2.c @@ -0,0 +1,1302 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Derived from K3 UDMA driver (k3-udma.c) + * Copyright (C) 2024-2025 Texas Instruments Incorporated - http://www.ti= .com + * Author: Peter Ujfalusi + * Author: Sai Sree Kartheek Adivi + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../virt-dma.h" +#include "k3-udma.h" +#include "k3-psil-priv.h" + +static const char * const v2_mmr_names[] =3D { + [V2_MMR_GCFG] =3D "gcfg", + [V2_MMR_BCHANRT] =3D "bchanrt", + [V2_MMR_CHANRT] =3D "chanrt", +}; + +static int udma_v2_check_chan_autopair_completion(struct udma_chan *uc) +{ + u32 val; + + val =3D udma_chanrt_read(uc, UDMA_CHAN_RT_CTL_REG); + if (val & UDMA_CHAN_RT_CTL_PAIR_TIMEOUT) + return -ETIMEDOUT; + else if (val & UDMA_CHAN_RT_CTL_PAIR_COMPLETE) + return 1; + + /* timeout didn't occur and also pairing didn't happen yet. */ + return 0; +} + +static bool udma_v2_is_chan_paused(struct udma_chan *uc) +{ + u32 val, pause_mask; + + if (uc->config.dir =3D=3D DMA_MEM_TO_MEM) { + val =3D udma_chanrt_read(uc, UDMA_CHAN_RT_CTL_REG); + pause_mask =3D UDMA_CHAN_RT_CTL_PAUSE; + } else { + val =3D udma_chanrt_read(uc, UDMA_CHAN_RT_PDMA_STATE_REG); + pause_mask =3D UDMA_CHAN_RT_PDMA_STATE_PAUSE; + } + + if (val & pause_mask) + return true; + + return false; +} + +static void udma_v2_decrement_byte_counters(struct udma_chan *uc, u32 val) +{ + udma_chanrt_write(uc, UDMA_CHAN_RT_BCNT_REG, val); + udma_chanrt_write(uc, UDMA_CHAN_RT_SBCNT_REG, val); + if (uc->config.ep_type !=3D PSIL_EP_NATIVE) + udma_chanrt_write(uc, UDMA_CHAN_RT_PERIPH_BCNT_REG, val); +} + +static void udma_v2_reset_counters(struct udma_chan *uc) +{ + u32 val; + + val =3D udma_chanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); + udma_chanrt_write(uc, UDMA_CHAN_RT_BCNT_REG, val); + + val =3D udma_chanrt_read(uc, UDMA_CHAN_RT_SBCNT_REG); + udma_chanrt_write(uc, UDMA_CHAN_RT_SBCNT_REG, val); + + val =3D udma_chanrt_read(uc, UDMA_CHAN_RT_PCNT_REG); + udma_chanrt_write(uc, UDMA_CHAN_RT_PCNT_REG, val); + + if (!uc->bchan) { + val =3D udma_chanrt_read(uc, UDMA_CHAN_RT_PERIPH_BCNT_REG); + udma_chanrt_write(uc, UDMA_CHAN_RT_PERIPH_BCNT_REG, val); + } +} + +static int udma_v2_reset_chan(struct udma_chan *uc, bool hard) +{ + udma_chanrt_write(uc, UDMA_CHAN_RT_CTL_REG, 0); + + /* Reset all counters */ + udma_v2_reset_counters(uc); + + /* Hard reset: re-initialize the channel to reset */ + if (hard) { + struct udma_chan_config ucc_backup; + int ret; + + memcpy(&ucc_backup, &uc->config, sizeof(uc->config)); + uc->ud->ddev.device_free_chan_resources(&uc->vc.chan); + + /* restore the channel configuration */ + memcpy(&uc->config, &ucc_backup, sizeof(uc->config)); + ret =3D uc->ud->ddev.device_alloc_chan_resources(&uc->vc.chan); + if (ret) + return ret; + + /* + * Setting forced teardown after forced reset helps recovering + * the rchan. + */ + if (uc->config.dir =3D=3D DMA_DEV_TO_MEM) + udma_chanrt_update_bits(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN | UDMA_CHAN_RT_CTL_TDOWN | + UDMA_CHAN_RT_CTL_FTDOWN, + UDMA_CHAN_RT_CTL_EN | UDMA_CHAN_RT_CTL_TDOWN | + UDMA_CHAN_RT_CTL_FTDOWN); + } + uc->state =3D UDMA_CHAN_IS_IDLE; + + return 0; +} + +static int udma_v2_start(struct udma_chan *uc) +{ + struct virt_dma_desc *vd =3D vchan_next_desc(&uc->vc); + struct udma_dev *ud =3D uc->ud; + int status; + + if (!vd) { + uc->desc =3D NULL; + return -ENOENT; + } + + list_del(&vd->node); + + uc->desc =3D to_udma_desc(&vd->tx); + + /* Channel is already running and does not need reconfiguration */ + if (udma_is_chan_running(uc) && !udma_chan_needs_reconfiguration(uc)) { + udma_start_desc(uc); + goto out; + } + + /* Make sure that we clear the teardown bit, if it is set */ + ud->reset_chan(uc, false); + + /* Push descriptors before we start the channel */ + udma_start_desc(uc); + + switch (uc->config.dir) { + case DMA_DEV_TO_MEM: + /* Config remote TR */ + if (uc->config.ep_type =3D=3D PSIL_EP_PDMA_XY || + uc->config.ep_type =3D=3D PSIL_EP_PDMA_XYMF) { + u32 val =3D PDMA_STATIC_TR_Y(uc->desc->static_tr.elcnt) | + PDMA_STATIC_TR_X(uc->desc->static_tr.elsize); + const struct udma_match_data *match_data =3D + uc->ud->match_data; + + if (uc->config.enable_acc32) + val |=3D PDMA_STATIC_TR_XY_ACC32; + if (uc->config.enable_burst) + val |=3D PDMA_STATIC_TR_XY_BURST; + + udma_chanrt_write(uc, + UDMA_CHAN_RT_STATIC_TR_XY_REG, + val); + + udma_chanrt_write(uc, + UDMA_CHAN_RT_STATIC_TR_Z_REG, + PDMA_STATIC_TR_Z(uc->desc->static_tr.bstcnt, + match_data->statictr_z_mask)); + + /* save the current staticTR configuration */ + memcpy(&uc->static_tr, &uc->desc->static_tr, + sizeof(uc->static_tr)); + } + + if (uc->config.ep_type =3D=3D PSIL_EP_PDMA_XYMF) + udma_chanrt_write(uc, UDMA_CHAN_RT_FIFO_SEL_REG, uc->config.fifo_id); + + udma_chanrt_write(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN | UDMA_CHAN_RT_CTL_AUTOPAIR); + + /* Poll for autopair completion */ + read_poll_timeout_atomic(udma_v2_check_chan_autopair_completion, + status, status !=3D 0, 100, 500, false, uc); + + if (status <=3D 0) + return -ETIMEDOUT; + + break; + case DMA_MEM_TO_DEV: + /* Config remote TR */ + if (uc->config.ep_type =3D=3D PSIL_EP_PDMA_XY || + uc->config.ep_type =3D=3D PSIL_EP_PDMA_XYMF) { + u32 val =3D PDMA_STATIC_TR_Y(uc->desc->static_tr.elcnt) | + PDMA_STATIC_TR_X(uc->desc->static_tr.elsize); + + if (uc->config.enable_acc32) + val |=3D PDMA_STATIC_TR_XY_ACC32; + if (uc->config.enable_burst) + val |=3D PDMA_STATIC_TR_XY_BURST; + + udma_chanrt_write(uc, + UDMA_CHAN_RT_STATIC_TR_XY_REG, + val); + + /* save the current staticTR configuration */ + memcpy(&uc->static_tr, &uc->desc->static_tr, + sizeof(uc->static_tr)); + } + + if (uc->config.ep_type =3D=3D PSIL_EP_PDMA_XYMF) + udma_chanrt_write(uc, UDMA_CHAN_RT_FIFO_SEL_REG, uc->config.fifo_id); + + udma_chanrt_write(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN | UDMA_CHAN_RT_CTL_AUTOPAIR); + + /* Poll for autopair completion */ + read_poll_timeout_atomic(udma_v2_check_chan_autopair_completion, + status, status !=3D 0, 100, 500, false, uc); + + if (status <=3D 0) + return -ETIMEDOUT; + + break; + case DMA_MEM_TO_MEM: + udma_bchanrt_write(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN); + udma_bchanrt_write(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN); + + break; + default: + return -EINVAL; + } + + uc->state =3D UDMA_CHAN_IS_ACTIVE; +out: + + return 0; +} + +static int udma_v2_stop(struct udma_chan *uc) +{ + uc->state =3D UDMA_CHAN_IS_TERMINATING; + reinit_completion(&uc->teardown_completed); + + if (uc->config.dir =3D=3D DMA_DEV_TO_MEM) { + if (!uc->cyclic && !uc->desc) + udma_push_to_ring(uc, -1); + } + + udma_chanrt_write(uc, UDMA_CHAN_RT_PEER_REG(8), UDMA_CHAN_RT_PEER_REG8_FL= USH); + udma_chanrt_update_bits(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN | UDMA_CHAN_RT_CTL_TDOWN, + UDMA_CHAN_RT_CTL_EN | UDMA_CHAN_RT_CTL_TDOWN); + + return 0; +} + +static irqreturn_t udma_v2_udma_irq_handler(int irq, void *data) +{ + struct udma_chan *uc =3D data; + struct udma_dev *ud =3D uc->ud; + struct udma_desc *d; + + switch (uc->config.dir) { + case DMA_DEV_TO_MEM: + k3_ringacc_ring_clear_irq(uc->rflow->r_ring); + break; + case DMA_MEM_TO_DEV: + case DMA_MEM_TO_MEM: + k3_ringacc_ring_clear_irq(uc->tchan->tc_ring); + break; + default: + return -ENOENT; + } + + spin_lock(&uc->vc.lock); + d =3D uc->desc; + if (d) { + d->tr_idx =3D (d->tr_idx + 1) % d->sglen; + + if (uc->cyclic) { + vchan_cyclic_callback(&d->vd); + } else { + /* TODO: figure out the real amount of data */ + ud->decrement_byte_counters(uc, d->residue); + ud->start(uc); + vchan_cookie_complete(&d->vd); + } + } + + spin_unlock(&uc->vc.lock); + + return IRQ_HANDLED; +} + +static irqreturn_t udma_v2_ring_irq_handler(int irq, void *data) +{ + struct udma_chan *uc =3D data; + struct udma_dev *ud =3D uc->ud; + struct udma_desc *d; + dma_addr_t paddr =3D 0; + u32 intr_status, reg; + + switch (uc->config.dir) { + case DMA_DEV_TO_MEM: + intr_status =3D k3_ringacc_ring_get_irq_status(uc->rflow->r_ring); + break; + case DMA_MEM_TO_DEV: + case DMA_MEM_TO_MEM: + intr_status =3D k3_ringacc_ring_get_irq_status(uc->tchan->tc_ring); + break; + default: + return IRQ_NONE; + } + + if (!intr_status) + return IRQ_NONE; /* Not this channel's interrupt */ + + reg =3D udma_chanrt_read(uc, UDMA_CHAN_RT_CTL_REG); + + if (intr_status & K3_RINGACC_RT_INT_STATUS_TR) { + /* check teardown status */ + if ((reg & UDMA_CHAN_RT_CTL_TDOWN) && !(reg & UDMA_CHAN_RT_CTL_EN)) + complete_all(&uc->teardown_completed); + return udma_v2_udma_irq_handler(irq, data); + } + + if (udma_pop_from_ring(uc, &paddr) || !paddr) + return IRQ_NONE; + + spin_lock(&uc->vc.lock); + + /* Teardown completion message */ + if (cppi5_desc_is_tdcm(paddr)) { + complete_all(&uc->teardown_completed); + + if (uc->terminated_desc) { + udma_desc_free(&uc->terminated_desc->vd); + uc->terminated_desc =3D NULL; + } + + if (!uc->desc) + ud->start(uc); + + goto out; + } + + d =3D udma_udma_desc_from_paddr(uc, paddr); + + if (d) { + dma_addr_t desc_paddr =3D udma_curr_cppi5_desc_paddr(d, + d->desc_idx); + if (desc_paddr !=3D paddr) { + dev_err(uc->ud->dev, "not matching descriptors!\n"); + goto out; + } + + if (d =3D=3D uc->desc) { + /* active descriptor */ + if (uc->cyclic) { + udma_cyclic_packet_elapsed(uc); + vchan_cyclic_callback(&d->vd); + } else { + if (udma_is_desc_really_done(uc, d)) { + ud->decrement_byte_counters(uc, d->residue); + ud->start(uc); + vchan_cookie_complete(&d->vd); + } else { + schedule_delayed_work(&uc->tx_drain.work, + 0); + } + } + } else { + /* + * terminated descriptor, mark the descriptor as + * completed to update the channel's cookie marker + */ + dma_cookie_complete(&d->vd.tx); + } + } +out: + spin_unlock(&uc->vc.lock); + + return IRQ_HANDLED; +} + +static int bcdma_v2_get_bchan(struct udma_chan *uc) +{ + struct udma_dev *ud =3D uc->ud; + enum udma_tp_level tpl; + int ret; + + if (uc->bchan) { + dev_dbg(ud->dev, "chan%d: already have bchan%d allocated\n", + uc->id, uc->bchan->id); + return 0; + } + + /* + * Use normal channels for peripherals, and highest TPL channel for + * mem2mem + */ + if (uc->config.tr_trigger_type) + tpl =3D 0; + else + tpl =3D ud->bchan_tpl.levels - 1; + + uc->bchan =3D __udma_reserve_bchan(ud, tpl, uc->id); + if (IS_ERR(uc->bchan)) { + ret =3D PTR_ERR(uc->bchan); + uc->bchan =3D NULL; + return ret; + } + uc->chan =3D uc->bchan; + uc->tchan =3D uc->bchan; + + return 0; +} + +static int bcdma_v2_alloc_bchan_resources(struct udma_chan *uc) +{ + struct k3_ring_cfg ring_cfg; + struct udma_dev *ud =3D uc->ud; + int ret; + + ret =3D bcdma_v2_get_bchan(uc); + if (ret) + return ret; + + ret =3D k3_ringacc_request_rings_pair(ud->ringacc, ud->match_data->chan_c= nt + uc->id, -1, + &uc->bchan->t_ring, + &uc->bchan->tc_ring); + if (ret) { + ret =3D -EBUSY; + goto err_ring; + } + + memset(&ring_cfg, 0, sizeof(ring_cfg)); + ring_cfg.size =3D K3_UDMA_DEFAULT_RING_SIZE; + ring_cfg.elm_size =3D K3_RINGACC_RING_ELSIZE_8; + ring_cfg.mode =3D K3_RINGACC_RING_MODE_RING; + + k3_configure_chan_coherency(&uc->vc.chan, ud->asel); + ring_cfg.asel =3D ud->asel; + ring_cfg.dma_dev =3D dmaengine_get_dma_device(&uc->vc.chan); + + ret =3D k3_ringacc_ring_cfg(uc->bchan->t_ring, &ring_cfg); + if (ret) + goto err_ringcfg; + + return 0; + +err_ringcfg: + k3_ringacc_ring_free(uc->bchan->tc_ring); + uc->bchan->tc_ring =3D NULL; + k3_ringacc_ring_free(uc->bchan->t_ring); + uc->bchan->t_ring =3D NULL; + k3_configure_chan_coherency(&uc->vc.chan, 0); +err_ring: + bcdma_put_bchan(uc); + + return ret; +} + +static int udma_v2_alloc_tx_resources(struct udma_chan *uc) +{ + struct k3_ring_cfg ring_cfg; + struct udma_dev *ud =3D uc->ud; + struct udma_tchan *tchan; + int ring_idx, ret; + + ret =3D udma_get_tchan(uc); + if (ret) + return ret; + + tchan =3D uc->tchan; + if (tchan->tflow_id >=3D 0) + ring_idx =3D tchan->tflow_id; + else + ring_idx =3D tchan->id; + + ret =3D k3_ringacc_request_rings_pair(ud->ringacc, ring_idx, -1, + &tchan->t_ring, + &tchan->tc_ring); + if (ret) { + ret =3D -EBUSY; + goto err_ring; + } + + memset(&ring_cfg, 0, sizeof(ring_cfg)); + ring_cfg.size =3D K3_UDMA_DEFAULT_RING_SIZE; + ring_cfg.elm_size =3D K3_RINGACC_RING_ELSIZE_8; + ring_cfg.mode =3D K3_RINGACC_RING_MODE_RING; + + k3_configure_chan_coherency(&uc->vc.chan, uc->config.asel); + ring_cfg.asel =3D uc->config.asel; + ring_cfg.dma_dev =3D dmaengine_get_dma_device(&uc->vc.chan); + + ret =3D k3_ringacc_ring_cfg(tchan->t_ring, &ring_cfg); + ret |=3D k3_ringacc_ring_cfg(tchan->tc_ring, &ring_cfg); + + if (ret) + goto err_ringcfg; + + return 0; + +err_ringcfg: + k3_ringacc_ring_free(uc->tchan->tc_ring); + uc->tchan->tc_ring =3D NULL; + k3_ringacc_ring_free(uc->tchan->t_ring); + uc->tchan->t_ring =3D NULL; +err_ring: + udma_put_tchan(uc); + + return ret; +} + +static int udma_v2_alloc_rx_resources(struct udma_chan *uc) +{ + struct udma_dev *ud =3D uc->ud; + struct k3_ring_cfg ring_cfg; + struct udma_rflow *rflow; + int fd_ring_id; + int ret; + + ret =3D udma_get_rchan(uc); + if (ret) + return ret; + + /* For MEM_TO_MEM we don't need rflow or rings */ + if (uc->config.dir =3D=3D DMA_MEM_TO_MEM) + return 0; + + if (uc->config.default_flow_id >=3D 0) + ret =3D udma_get_rflow(uc, uc->config.default_flow_id); + else + ret =3D udma_get_rflow(uc, uc->rchan->id); + + if (ret) { + ret =3D -EBUSY; + goto err_rflow; + } + + rflow =3D uc->rflow; + if (ud->tflow_cnt) + fd_ring_id =3D ud->tflow_cnt + rflow->id; + else + fd_ring_id =3D uc->rchan->id; + ret =3D k3_ringacc_request_rings_pair(ud->ringacc, fd_ring_id, -1, + &rflow->fd_ring, &rflow->r_ring); + if (ret) { + ret =3D -EBUSY; + goto err_ring; + } + + memset(&ring_cfg, 0, sizeof(ring_cfg)); + + ring_cfg.elm_size =3D K3_RINGACC_RING_ELSIZE_8; + ring_cfg.size =3D K3_UDMA_DEFAULT_RING_SIZE; + ring_cfg.mode =3D K3_RINGACC_RING_MODE_RING; + + k3_configure_chan_coherency(&uc->vc.chan, uc->config.asel); + ring_cfg.asel =3D uc->config.asel; + ring_cfg.dma_dev =3D dmaengine_get_dma_device(&uc->vc.chan); + + ret =3D k3_ringacc_ring_cfg(rflow->fd_ring, &ring_cfg); + + ring_cfg.size =3D K3_UDMA_DEFAULT_RING_SIZE; + ret |=3D k3_ringacc_ring_cfg(rflow->r_ring, &ring_cfg); + + if (ret) + goto err_ringcfg; + + return 0; + +err_ringcfg: + k3_ringacc_ring_free(rflow->r_ring); + rflow->r_ring =3D NULL; + k3_ringacc_ring_free(rflow->fd_ring); + rflow->fd_ring =3D NULL; +err_ring: + udma_put_rflow(uc); +err_rflow: + udma_put_rchan(uc); + + return ret; +} + +static int bcdma_v2_alloc_chan_resources(struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + struct udma_dev *ud =3D to_udma_dev(chan->device); + struct platform_device *pdev =3D to_platform_device(ud->dev); + char irq_name[10]; + u32 irq_ring_idx; + int ret; + + /* Only TR mode is supported */ + uc->config.pkt_mode =3D false; + + /* + * Make sure that the completion is in a known state: + * No teardown, the channel is idle + */ + reinit_completion(&uc->teardown_completed); + complete_all(&uc->teardown_completed); + uc->state =3D UDMA_CHAN_IS_IDLE; + + switch (uc->config.dir) { + case DMA_MEM_TO_MEM: + /* Non synchronized - mem to mem type of transfer */ + dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-MEM\n", __func__, + uc->id); + + ret =3D bcdma_v2_alloc_bchan_resources(uc); + if (ret) + return ret; + + irq_ring_idx =3D ud->match_data->chan_cnt + uc->id; + break; + case DMA_MEM_TO_DEV: + /* Slave transfer synchronized - mem to dev (TX) transfer */ + dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-DEV\n", __func__, + uc->id); + + ret =3D udma_v2_alloc_tx_resources(uc); + if (ret) { + uc->config.remote_thread_id =3D -1; + return ret; + } + + uc->config.src_thread =3D ud->psil_base + uc->tchan->id; + uc->config.dst_thread =3D uc->config.remote_thread_id; + uc->config.dst_thread |=3D K3_PSIL_DST_THREAD_ID_OFFSET; + + irq_ring_idx =3D uc->tchan->id; + + break; + case DMA_DEV_TO_MEM: + /* Slave transfer synchronized - dev to mem (RX) transfer */ + dev_dbg(uc->ud->dev, "%s: chan%d as DEV-to-MEM\n", __func__, + uc->id); + + ret =3D udma_v2_alloc_rx_resources(uc); + if (ret) { + uc->config.remote_thread_id =3D -1; + return ret; + } + + uc->config.src_thread =3D uc->config.remote_thread_id; + uc->config.dst_thread =3D (ud->psil_base + uc->rchan->id) | + K3_PSIL_DST_THREAD_ID_OFFSET; + + irq_ring_idx =3D uc->rchan->id; + + break; + default: + /* Can not happen */ + dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n", + __func__, uc->id, uc->config.dir); + return -EINVAL; + } + + /* check if the channel configuration was successful */ + if (ret) + goto err_res_free; + + if (udma_is_chan_running(uc)) { + dev_warn(ud->dev, "chan%d: is running!\n", uc->id); + ud->reset_chan(uc, false); + if (udma_is_chan_running(uc)) { + dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); + ret =3D -EBUSY; + goto err_res_free; + } + } + + uc->dma_dev =3D dmaengine_get_dma_device(chan); + if (uc->config.dir =3D=3D DMA_MEM_TO_MEM && !uc->config.tr_trigger_type)= { + uc->config.hdesc_size =3D + cppi5_trdesc_calc_size(sizeof(struct cppi5_tr_type15_t), 2); + + uc->hdesc_pool =3D dma_pool_create(uc->name, ud->ddev.dev, + uc->config.hdesc_size, + ud->desc_align, + 0); + if (!uc->hdesc_pool) { + dev_err(ud->ddev.dev, + "Descriptor pool allocation failed\n"); + uc->use_dma_pool =3D false; + ret =3D -ENOMEM; + goto err_res_free; + } + + uc->use_dma_pool =3D true; + } else if (uc->config.dir !=3D DMA_MEM_TO_MEM) { + uc->psil_paired =3D true; + } + + snprintf(irq_name, sizeof(irq_name), "chan%u", irq_ring_idx); + uc->irq_num_ring =3D platform_get_irq_byname(pdev, irq_name); + if (uc->irq_num_ring < 0) { + ret =3D uc->irq_num_ring; + goto err_res_free; + } + + ret =3D request_irq(uc->irq_num_ring, udma_v2_ring_irq_handler, + IRQF_SHARED | IRQF_TRIGGER_HIGH, uc->name, uc); + if (ret) { + dev_err(ud->dev, "chan%d: ring irq request failed\n", uc->id); + goto err_irq_free; + } + + udma_reset_rings(uc); + + INIT_DELAYED_WORK_ONSTACK(&uc->tx_drain.work, + udma_check_tx_completion); + return 0; + +err_irq_free: + uc->irq_num_ring =3D 0; + uc->irq_num_udma =3D 0; +err_res_free: + 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 =3D false; + } + + return ret; +} + +static enum dma_status udma_v2_tx_status(struct dma_chan *chan, + dma_cookie_t cookie, + struct dma_tx_state *txstate) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + enum dma_status ret; + unsigned long flags; + + spin_lock_irqsave(&uc->vc.lock, flags); + + ret =3D dma_cookie_status(chan, cookie, txstate); + + if (!udma_is_chan_running(uc)) + ret =3D DMA_COMPLETE; + + if (ret =3D=3D DMA_IN_PROGRESS && udma_v2_is_chan_paused(uc)) + ret =3D DMA_PAUSED; + + if (ret =3D=3D DMA_COMPLETE || !txstate) + goto out; + + if (uc->desc && uc->desc->vd.tx.cookie =3D=3D cookie) { + u32 peer_bcnt =3D 0; + u32 bcnt =3D 0; + u32 residue =3D uc->desc->residue; + u32 delay =3D 0; + + if (uc->desc->dir =3D=3D DMA_MEM_TO_DEV) { + bcnt =3D udma_chanrt_read(uc, UDMA_CHAN_RT_SBCNT_REG); + + if (uc->config.ep_type !=3D PSIL_EP_NATIVE) { + peer_bcnt =3D udma_chanrt_read(uc, 0x810); + + if (bcnt > peer_bcnt) + delay =3D bcnt - peer_bcnt; + } + } else if (uc->desc->dir =3D=3D DMA_DEV_TO_MEM) { + bcnt =3D udma_chanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); + + if (uc->config.ep_type !=3D PSIL_EP_NATIVE) { + peer_bcnt =3D udma_chanrt_read(uc, 0x810); + + if (peer_bcnt > bcnt) + delay =3D peer_bcnt - bcnt; + } + } else { + bcnt =3D udma_chanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); + } + + if (bcnt && !(bcnt % uc->desc->residue)) + residue =3D 0; + else + residue -=3D bcnt % uc->desc->residue; + + if (!residue && (uc->config.dir =3D=3D DMA_DEV_TO_MEM || !delay)) { + ret =3D DMA_COMPLETE; + delay =3D 0; + } + + dma_set_residue(txstate, residue); + dma_set_in_flight_bytes(txstate, delay); + + } else { + ret =3D DMA_COMPLETE; + } + +out: + spin_unlock_irqrestore(&uc->vc.lock, flags); + return ret; +} + +static int udma_v2_pause(struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + + /* pause the channel */ + udma_chanrt_update_bits(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_PAUSE, UDMA_CHAN_RT_CTL_PAUSE); + + return 0; +} + +static int udma_v2_resume(struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + + /* resume the channel */ + udma_chanrt_update_bits(uc, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_PAUSE, 0); + + return 0; +} + +static struct platform_driver bcdma_v2_driver; + +static bool udma_v2_dma_filter_fn(struct dma_chan *chan, void *param) +{ + struct udma_v2_filter_param *filter_param; + struct psil_endpoint_config *ep_config; + struct udma_chan_config *ucc; + struct udma_chan *uc; + struct udma_dev *ud; + + if (chan->device->dev->driver !=3D &bcdma_v2_driver.driver) + return false; + + uc =3D to_udma_chan(chan); + ucc =3D &uc->config; + ud =3D uc->ud; + filter_param =3D param; + + if (filter_param->asel > 15) { + dev_err(ud->dev, "Invalid channel asel: %u\n", + filter_param->asel); + return false; + } + + ucc->asel =3D filter_param->asel; + ucc->tr_trigger_type =3D filter_param->tr_trigger_type; + + if (ucc->tr_trigger_type) { + ucc->dir =3D DMA_MEM_TO_MEM; + goto triggered_bchan; + } else { + u32 thread_id; + bool dev_to_mem; + + ep_config =3D psil_get_ep_config_by_id(filter_param->channel_id, + (ud->match_data->type =3D=3D DMA_TYPE_PKTDMA), + &thread_id, &dev_to_mem); + if (IS_ERR(ep_config)) { + dev_err(ud->dev, "No config for channel %u\n", + filter_param->channel_id); + ucc->atype =3D 0; + ucc->asel =3D 0; + return false; + } + ucc->remote_thread_id =3D thread_id; + ucc->dir =3D dev_to_mem ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV; + } + if (IS_ERR(ep_config)) { + dev_err(ud->dev, "No configuration for psi-l thread 0x%04x\n", + ucc->remote_thread_id); + ucc->dir =3D DMA_MEM_TO_MEM; + ucc->remote_thread_id =3D -1; + ucc->atype =3D 0; + ucc->asel =3D 0; + return false; + } + + ucc->pkt_mode =3D ep_config->pkt_mode; + ucc->channel_tpl =3D ep_config->channel_tpl; + ucc->notdpkt =3D ep_config->notdpkt; + ucc->ep_type =3D ep_config->ep_type; + ucc->fifo_id =3D ep_config->fifo_id; + + if (ud->match_data->version =3D=3D K3_UDMA_V2 && + ep_config->mapped_channel_id >=3D 0) { + ucc->mapped_channel_id =3D ep_config->mapped_channel_id; + ucc->default_flow_id =3D ep_config->default_flow_id; + } else { + ucc->mapped_channel_id =3D -1; + ucc->default_flow_id =3D -1; + } + + ucc->needs_epib =3D ep_config->needs_epib; + ucc->psd_size =3D ep_config->psd_size; + ucc->metadata_size =3D + (ucc->needs_epib ? CPPI5_INFO0_HDESC_EPIB_SIZE : 0) + + ucc->psd_size; + + if (ucc->ep_type !=3D PSIL_EP_NATIVE) { + const struct udma_match_data *match_data =3D ud->match_data; + + if ((match_data->flags & UDMA_FLAG_PDMA_ACC32) && ep_config->pdma_acc32) + ucc->enable_acc32 =3D true; + else + ucc->enable_acc32 =3D false; + + if ((match_data->flags & UDMA_FLAG_PDMA_BURST) && ep_config->pdma_burst) + ucc->enable_burst =3D true; + else + ucc->enable_burst =3D false; + } + if (ucc->pkt_mode) + ucc->hdesc_size =3D ALIGN(sizeof(struct cppi5_host_desc_t) + + ucc->metadata_size, ud->desc_align); + + dev_dbg(ud->dev, "chan%d: Remote thread: 0x%04x (%s)\n", uc->id, + ucc->remote_thread_id, dmaengine_get_direction_text(ucc->dir)); + + return true; + +triggered_bchan: + dev_dbg(ud->dev, "chan%d: triggered channel (type: %u)\n", uc->id, + ucc->tr_trigger_type); + + return true; +} + +static struct dma_chan *udma_v2_of_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct udma_dev *ud =3D ofdma->of_dma_data; + dma_cap_mask_t mask =3D ud->ddev.cap_mask; + struct udma_v2_filter_param filter_param; + struct dma_chan *chan; + + if (ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { + if (dma_spec->args_count !=3D 4) + return NULL; + + filter_param.tr_trigger_type =3D dma_spec->args[0]; + filter_param.trigger_param =3D dma_spec->args[1]; + filter_param.channel_id =3D dma_spec->args[2]; + filter_param.asel =3D dma_spec->args[3]; + } else { + if (dma_spec->args_count !=3D 1 && dma_spec->args_count !=3D 2) + return NULL; + + filter_param.channel_id =3D dma_spec->args[0]; + filter_param.tr_trigger_type =3D 0; + if (dma_spec->args_count =3D=3D 2) + filter_param.asel =3D dma_spec->args[1]; + else + filter_param.asel =3D 0; + } + + chan =3D __dma_request_channel(&mask, udma_v2_dma_filter_fn, &filter_para= m, + ofdma->of_node); + if (!chan) { + dev_err(ud->dev, "get channel fail in %s.\n", __func__); + return ERR_PTR(-EINVAL); + } + + return chan; +} + +static struct udma_match_data bcdma_v2_am62l_data =3D { + .type =3D DMA_TYPE_BCDMA, + .version =3D K3_UDMA_V2, + .psil_base =3D 0x2000, /* for tchan and rchan, not applicable to bchan */ + .enable_memcpy_support =3D true, /* Supported via bchan */ + .flags =3D UDMA_FLAGS_J7_CLASS, + .statictr_z_mask =3D GENMASK(23, 0), + .burst_size =3D { + TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_64_BYTES, /* Normal Channels */ + 0, /* No H Channels */ + 0, /* No UH Channels */ + }, + .bchan_cnt =3D 16, + .chan_cnt =3D 128, + .tchan_cnt =3D 128, + .rchan_cnt =3D 128, +}; + +static const struct of_device_id udma_of_match[] =3D { + { + .compatible =3D "ti,am62l-dmss-bcdma", + .data =3D &bcdma_v2_am62l_data, + }, + { /* Sentinel */ }, +}; + +static const struct soc_device_attribute k3_soc_devices[] =3D { + { .family =3D "AM62LX", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, udma_of_match); + +static int udma_v2_get_mmrs(struct platform_device *pdev, struct udma_dev = *ud) +{ + int i; + + ud->mmrs[V2_MMR_GCFG] =3D devm_platform_ioremap_resource_byname(pdev, + v2_mmr_names[V2_MMR_GCFG]); + if (IS_ERR(ud->mmrs[V2_MMR_GCFG])) + return PTR_ERR(ud->mmrs[V2_MMR_GCFG]); + + ud->bchan_cnt =3D ud->match_data->bchan_cnt; + /* There are no tchan and rchan in BCDMA_V2. + * Duplicate chan as tchan and rchan to keep the common code + * in k3-udma-common.c functional for BCDMA_V2. + */ + ud->chan_cnt =3D ud->match_data->chan_cnt; + ud->tchan_cnt =3D ud->match_data->chan_cnt; + ud->rchan_cnt =3D ud->match_data->chan_cnt; + ud->rflow_cnt =3D ud->chan_cnt; + + for (i =3D 1; i < V2_MMR_LAST; i++) { + if (i =3D=3D V2_MMR_BCHANRT && ud->bchan_cnt =3D=3D 0) + continue; + if (i =3D=3D V2_MMR_CHANRT && ud->chan_cnt =3D=3D 0) + continue; + + ud->mmrs[i] =3D devm_platform_ioremap_resource_byname(pdev, v2_mmr_names= [i]); + if (IS_ERR(ud->mmrs[i])) + return PTR_ERR(ud->mmrs[i]); + } + + return 0; +} + +static int udma_v2_probe(struct platform_device *pdev) +{ + const struct soc_device_attribute *soc; + struct device *dev =3D &pdev->dev; + const struct of_device_id *match; + struct udma_dev *ud; + int ch_count, i, ret; + + ret =3D dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(48)); + if (ret) + dev_err(dev, "failed to set dma mask stuff\n"); + + ud =3D devm_kzalloc(dev, sizeof(*ud), GFP_KERNEL); + if (!ud) + return -ENOMEM; + + match =3D of_match_node(udma_of_match, dev->of_node); + if (!match) { + dev_err(dev, "No compatible match found\n"); + return -ENODEV; + } + ud->match_data =3D match->data; + + ud->soc_data =3D ud->match_data->soc_data; + if (!ud->soc_data) { + soc =3D soc_device_match(k3_soc_devices); + if (!soc) { + dev_err(dev, "No compatible SoC found\n"); + return -ENODEV; + } + ud->soc_data =3D soc->data; + } + // Setup function pointers + ud->start =3D udma_v2_start; + ud->stop =3D udma_v2_stop; + ud->reset_chan =3D udma_v2_reset_chan; + ud->decrement_byte_counters =3D udma_v2_decrement_byte_counters; + ud->bcdma_setup_sci_resources =3D NULL; + + ret =3D udma_v2_get_mmrs(pdev, ud); + if (ret) + return ret; + + struct k3_ringacc_init_data ring_init_data =3D {0}; + + ring_init_data.num_rings =3D ud->bchan_cnt + ud->chan_cnt; + + ud->ringacc =3D k3_ringacc_dmarings_init(pdev, &ring_init_data); + + if (IS_ERR(ud->ringacc)) + return PTR_ERR(ud->ringacc); + + dma_cap_set(DMA_SLAVE, ud->ddev.cap_mask); + + dma_cap_set(DMA_CYCLIC, ud->ddev.cap_mask); + ud->ddev.device_prep_dma_cyclic =3D udma_prep_dma_cyclic; + + ud->ddev.device_config =3D udma_slave_config; + ud->ddev.device_prep_slave_sg =3D udma_prep_slave_sg; + ud->ddev.device_issue_pending =3D udma_issue_pending; + ud->ddev.device_tx_status =3D udma_v2_tx_status; + ud->ddev.device_pause =3D udma_v2_pause; + ud->ddev.device_resume =3D udma_v2_resume; + ud->ddev.device_terminate_all =3D udma_terminate_all; + ud->ddev.device_synchronize =3D udma_synchronize; +#ifdef CONFIG_DEBUG_FS + ud->ddev.dbg_summary_show =3D udma_dbg_summary_show; +#endif + + ud->ddev.device_alloc_chan_resources =3D + bcdma_v2_alloc_chan_resources; + + ud->ddev.device_free_chan_resources =3D udma_free_chan_resources; + + ud->ddev.src_addr_widths =3D TI_UDMAC_BUSWIDTHS; + ud->ddev.dst_addr_widths =3D TI_UDMAC_BUSWIDTHS; + ud->ddev.directions =3D BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); + ud->ddev.residue_granularity =3D DMA_RESIDUE_GRANULARITY_BURST; + ud->ddev.desc_metadata_modes =3D DESC_METADATA_CLIENT | + DESC_METADATA_ENGINE; + if (ud->match_data->enable_memcpy_support && + !(ud->match_data->type =3D=3D DMA_TYPE_BCDMA && ud->bchan_cnt =3D=3D = 0)) { + dma_cap_set(DMA_MEMCPY, ud->ddev.cap_mask); + ud->ddev.device_prep_dma_memcpy =3D udma_prep_dma_memcpy; + ud->ddev.directions |=3D BIT(DMA_MEM_TO_MEM); + } + + ud->ddev.dev =3D dev; + ud->dev =3D dev; + ud->psil_base =3D ud->match_data->psil_base; + + INIT_LIST_HEAD(&ud->ddev.channels); + INIT_LIST_HEAD(&ud->desc_to_purge); + + ch_count =3D setup_resources(ud); + if (ch_count <=3D 0) + return ch_count; + + spin_lock_init(&ud->lock); + INIT_WORK(&ud->purge_work, udma_purge_desc_work); + + ud->desc_align =3D 64; + if (ud->desc_align < dma_get_cache_alignment()) + ud->desc_align =3D dma_get_cache_alignment(); + + ret =3D udma_setup_rx_flush(ud); + if (ret) + return ret; + + for (i =3D 0; i < ud->bchan_cnt; i++) { + struct udma_bchan *bchan =3D &ud->bchans[i]; + + bchan->id =3D i; + bchan->reg_rt =3D ud->mmrs[V2_MMR_BCHANRT] + i * 0x1000; + } + + for (i =3D 0; i < ud->tchan_cnt; i++) { + struct udma_tchan *tchan =3D &ud->tchans[i]; + + tchan->id =3D i; + tchan->reg_rt =3D ud->mmrs[V2_MMR_CHANRT] + i * 0x1000; + } + + for (i =3D 0; i < ud->rchan_cnt; i++) { + struct udma_rchan *rchan =3D &ud->rchans[i]; + + rchan->id =3D i; + rchan->reg_rt =3D ud->mmrs[V2_MMR_CHANRT] + i * 0x1000; + } + + for (i =3D 0; i < ud->rflow_cnt; i++) { + struct udma_rflow *rflow =3D &ud->rflows[i]; + + rflow->id =3D i; + rflow->reg_rt =3D ud->rflow_rt + i * 0x2000; + } + + for (i =3D 0; i < ch_count; i++) { + struct udma_chan *uc =3D &ud->channels[i]; + + uc->ud =3D ud; + uc->vc.desc_free =3D udma_desc_free; + uc->id =3D i; + uc->bchan =3D NULL; + uc->tchan =3D NULL; + uc->rchan =3D NULL; + uc->config.remote_thread_id =3D -1; + uc->config.mapped_channel_id =3D -1; + uc->config.default_flow_id =3D -1; + uc->config.dir =3D DMA_MEM_TO_MEM; + uc->name =3D devm_kasprintf(dev, GFP_KERNEL, "%s chan%d", + dev_name(dev), i); + + vchan_init(&uc->vc, &ud->ddev); + /* Use custom vchan completion handling */ + tasklet_setup(&uc->vc.task, udma_vchan_complete); + init_completion(&uc->teardown_completed); + INIT_DELAYED_WORK(&uc->tx_drain.work, udma_check_tx_completion); + } + + /* Configure the copy_align to the maximum burst size the device supports= */ + ud->ddev.copy_align =3D udma_get_copy_align(ud); + + ret =3D dma_async_device_register(&ud->ddev); + if (ret) { + dev_err(dev, "failed to register slave DMA engine: %d\n", ret); + return ret; + } + + platform_set_drvdata(pdev, ud); + + ret =3D of_dma_controller_register(dev->of_node, udma_v2_of_xlate, ud); + if (ret) { + dev_err(dev, "failed to register of_dma controller\n"); + dma_async_device_unregister(&ud->ddev); + } + + return ret; +} + +static int __maybe_unused udma_v2_pm_suspend(struct device *dev) +{ + struct udma_dev *ud =3D dev_get_drvdata(dev); + struct dma_device *dma_dev =3D &ud->ddev; + struct dma_chan *chan; + struct udma_chan *uc; + + list_for_each_entry(chan, &dma_dev->channels, device_node) { + if (chan->client_count) { + uc =3D to_udma_chan(chan); + /* backup the channel configuration */ + memcpy(&uc->backup_config, &uc->config, + sizeof(struct udma_chan_config)); + dev_dbg(dev, "Suspending channel %s\n", + dma_chan_name(chan)); + ud->ddev.device_free_chan_resources(chan); + } + } + + return 0; +} + +static int __maybe_unused udma_v2_pm_resume(struct device *dev) +{ + struct udma_dev *ud =3D dev_get_drvdata(dev); + struct dma_device *dma_dev =3D &ud->ddev; + struct dma_chan *chan; + struct udma_chan *uc; + int ret; + + list_for_each_entry(chan, &dma_dev->channels, device_node) { + if (chan->client_count) { + uc =3D to_udma_chan(chan); + /* restore the channel configuration */ + memcpy(&uc->config, &uc->backup_config, + sizeof(struct udma_chan_config)); + dev_dbg(dev, "Resuming channel %s\n", + dma_chan_name(chan)); + ret =3D ud->ddev.device_alloc_chan_resources(chan); + if (ret) + return ret; + } + } + + return 0; +} + +static const struct dev_pm_ops udma_pm_ops =3D { + SET_LATE_SYSTEM_SLEEP_PM_OPS(udma_v2_pm_suspend, udma_v2_pm_resume) +}; + +static struct platform_driver bcdma_v2_driver =3D { + .driver =3D { + .name =3D "ti-udma-v2", + .of_match_table =3D udma_of_match, + .suppress_bind_attrs =3D true, + .pm =3D &udma_pm_ops, + }, + .probe =3D udma_v2_probe, +}; + +module_platform_driver(bcdma_v2_driver); +MODULE_DESCRIPTION("Texas Instruments K3 UDMA v2 support"); +MODULE_LICENSE("GPL"); diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 58cbb399bc3b2..bbf4163f407b5 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -1810,6 +1810,7 @@ static struct dma_chan *udma_of_xlate(struct of_phand= le_args *dma_spec, =20 static struct udma_match_data am654_main_data =3D { .type =3D DMA_TYPE_UDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x1000, .enable_memcpy_support =3D true, .statictr_z_mask =3D GENMASK(11, 0), @@ -1822,6 +1823,7 @@ static struct udma_match_data am654_main_data =3D { =20 static struct udma_match_data am654_mcu_data =3D { .type =3D DMA_TYPE_UDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x6000, .enable_memcpy_support =3D false, .statictr_z_mask =3D GENMASK(11, 0), @@ -1834,6 +1836,7 @@ static struct udma_match_data am654_mcu_data =3D { =20 static struct udma_match_data j721e_main_data =3D { .type =3D DMA_TYPE_UDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x1000, .enable_memcpy_support =3D true, .flags =3D UDMA_FLAGS_J7_CLASS, @@ -1847,6 +1850,7 @@ static struct udma_match_data j721e_main_data =3D { =20 static struct udma_match_data j721e_mcu_data =3D { .type =3D DMA_TYPE_UDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x6000, .enable_memcpy_support =3D false, /* MEM_TO_MEM is slow via MCU UDMA */ .flags =3D UDMA_FLAGS_J7_CLASS, @@ -1876,6 +1880,7 @@ static struct udma_soc_data j721s2_bcdma_csi_soc_data= =3D { =20 static struct udma_match_data am62a_bcdma_csirx_data =3D { .type =3D DMA_TYPE_BCDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x3100, .enable_memcpy_support =3D false, .burst_size =3D { @@ -1888,6 +1893,7 @@ static struct udma_match_data am62a_bcdma_csirx_data = =3D { =20 static struct udma_match_data am64_bcdma_data =3D { .type =3D DMA_TYPE_BCDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x2000, /* for tchan and rchan, not applicable to bchan */ .enable_memcpy_support =3D true, /* Supported via bchan */ .flags =3D UDMA_FLAGS_J7_CLASS, @@ -1901,6 +1907,7 @@ static struct udma_match_data am64_bcdma_data =3D { =20 static struct udma_match_data am64_pktdma_data =3D { .type =3D DMA_TYPE_PKTDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x1000, .enable_memcpy_support =3D false, /* PKTDMA does not support MEM_TO_MEM */ .flags =3D UDMA_FLAGS_J7_CLASS, @@ -1914,6 +1921,7 @@ static struct udma_match_data am64_pktdma_data =3D { =20 static struct udma_match_data j721s2_bcdma_csi_data =3D { .type =3D DMA_TYPE_BCDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x2000, .enable_memcpy_support =3D false, .burst_size =3D { @@ -1926,6 +1934,7 @@ static struct udma_match_data j721s2_bcdma_csi_data = =3D { =20 static struct udma_match_data j722s_bcdma_csi_data =3D { .type =3D DMA_TYPE_BCDMA, + .version =3D K3_UDMA_V1, .psil_base =3D 0x3100, .enable_memcpy_support =3D false, .burst_size =3D { diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 5e222ce366faf..680d776f7ae8c 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -32,6 +32,12 @@ #define UDMA_CHAN_RT_SWTRIG_REG 0x8 #define UDMA_CHAN_RT_STDATA_REG 0x80 =20 +#define UDMA_CHAN_RT_STATIC_TR_XY_REG 0x800 +#define UDMA_CHAN_RT_STATIC_TR_Z_REG 0x804 +#define UDMA_CHAN_RT_PERIPH_BCNT_REG 0x810 +#define UDMA_CHAN_RT_FIFO_SEL_REG 0x824 +#define UDMA_CHAN_RT_PDMA_STATE_REG 0x80c + #define UDMA_CHAN_RT_PEER_REG(i) (0x200 + ((i) * 0x4)) #define UDMA_CHAN_RT_PEER_STATIC_TR_XY_REG \ UDMA_CHAN_RT_PEER_REG(0) /* PSI-L: 0x400 */ @@ -71,8 +77,16 @@ #define UDMA_CHAN_RT_CTL_TDOWN BIT(30) #define UDMA_CHAN_RT_CTL_PAUSE BIT(29) #define UDMA_CHAN_RT_CTL_FTDOWN BIT(28) +#define UDMA_CHAN_RT_CTL_AUTOPAIR BIT(23) +#define UDMA_CHAN_RT_CTL_PAIR_TIMEOUT BIT(17) +#define UDMA_CHAN_RT_CTL_PAIR_COMPLETE BIT(16) #define UDMA_CHAN_RT_CTL_ERROR BIT(0) =20 +/* UDMA_CHAN_RT_PDMA_STATE_REG */ +#define UDMA_CHAN_RT_PDMA_STATE_IN_EVT BIT(31) +#define UDMA_CHAN_RT_PDMA_STATE_TDOWN BIT(30) +#define UDMA_CHAN_RT_PDMA_STATE_PAUSE BIT(29) + /* UDMA_CHAN_RT_PEER_RT_EN_REG */ #define UDMA_PEER_RT_EN_ENABLE BIT(31) #define UDMA_PEER_RT_EN_TEARDOWN BIT(30) @@ -103,6 +117,9 @@ */ #define PDMA_STATIC_TR_Z(x, mask) ((x) & (mask)) =20 +/* UDMA_CHAN_RT_PEER_REG(8) */ +#define UDMA_CHAN_RT_PEER_REG8_FLUSH 0x09000000 + /* Address Space Select */ #define K3_ADDRESS_ASEL_SHIFT 48 =20 @@ -208,6 +225,11 @@ enum k3_dma_type { DMA_TYPE_PKTDMA, }; =20 +enum k3_dma_version { + K3_UDMA_V1 =3D 0, + K3_UDMA_V2, +}; + enum udma_mmr { MMR_GCFG =3D 0, MMR_BCHANRT, @@ -216,6 +238,13 @@ enum udma_mmr { MMR_LAST, }; =20 +enum udma_v2_mmr { + V2_MMR_GCFG =3D 0, + V2_MMR_BCHANRT, + V2_MMR_CHANRT, + V2_MMR_LAST, +}; + struct udma_filter_param { int remote_thread_id; u32 atype; @@ -223,6 +252,13 @@ struct udma_filter_param { u32 tr_trigger_type; }; =20 +struct udma_v2_filter_param { + u32 tr_trigger_type; + u32 trigger_param; + u32 channel_id; + u32 asel; +}; + struct udma_tchan { void __iomem *reg_rt; =20 @@ -234,17 +270,13 @@ struct udma_tchan { }; =20 #define udma_bchan udma_tchan +#define udma_rchan udma_tchan =20 struct udma_rflow { int id; struct k3_ring *fd_ring; /* Free Descriptor ring */ struct k3_ring *r_ring; /* Receive ring */ -}; - -struct udma_rchan { void __iomem *reg_rt; - - int id; }; =20 struct udma_oes_offsets { @@ -266,12 +298,19 @@ struct udma_oes_offsets { =20 struct udma_match_data { enum k3_dma_type type; + enum k3_dma_version version; u32 psil_base; bool enable_memcpy_support; u32 flags; u32 statictr_z_mask; u8 burst_size[3]; struct udma_soc_data *soc_data; + u32 bchan_cnt; + u32 chan_cnt; + u32 tchan_cnt; + u32 rchan_cnt; + u32 tflow_cnt; + u32 rflow_cnt; }; =20 struct udma_soc_data { @@ -306,6 +345,7 @@ struct udma_dev { struct dma_device ddev; struct device *dev; void __iomem *mmrs[MMR_LAST]; + void __iomem *rflow_rt; const struct udma_match_data *match_data; const struct udma_soc_data *soc_data; =20 @@ -326,12 +366,14 @@ struct udma_dev { struct udma_rx_flush rx_flush; =20 int bchan_cnt; + int chan_cnt; int tchan_cnt; int echan_cnt; int rchan_cnt; int rflow_cnt; int tflow_cnt; unsigned long *bchan_map; + unsigned long *chan_map; unsigned long *tchan_map; unsigned long *rchan_map; unsigned long *rflow_gp_map; @@ -340,6 +382,7 @@ struct udma_dev { unsigned long *tflow_map; =20 struct udma_bchan *bchans; + struct udma_tchan *chans; struct udma_tchan *tchans; struct udma_rchan *rchans; struct udma_rflow *rflows; @@ -411,6 +454,7 @@ struct udma_chan_config { bool enable_acc32; bool enable_burst; enum udma_tp_level channel_tpl; /* Channel Throughput Level */ + u8 fifo_id; /* XYMF FIFO index */ =20 u32 tr_trigger_type; unsigned long tx_flags; @@ -434,6 +478,7 @@ struct udma_chan { char *name; =20 struct udma_bchan *bchan; + struct udma_tchan *chan; struct udma_tchan *tchan; struct udma_rchan *rchan; struct udma_rflow *rflow; @@ -503,51 +548,33 @@ static inline void udma_update_bits(void __iomem *bas= e, int reg, writel(tmp, base + reg); } =20 -/* TCHANRT */ -static inline u32 udma_tchanrt_read(struct udma_chan *uc, int reg) -{ - if (!uc->tchan) - return 0; - return udma_read(uc->tchan->reg_rt, reg); -} - -static inline void udma_tchanrt_write(struct udma_chan *uc, int reg, u32 v= al) -{ - if (!uc->tchan) - return; - udma_write(uc->tchan->reg_rt, reg, val); +#define _UDMA_REG_ACCESS(channel) \ +static inline u32 udma_##channel##rt_read(struct udma_chan *uc, int reg) \ +{ \ + if (!uc->channel) \ + return 0; \ + return udma_read(uc->channel->reg_rt, reg); \ +} \ +\ +static inline void udma_##channel##rt_write(struct udma_chan *uc, int reg,= u32 val) \ +{ \ + if (!uc->channel) \ + return; \ + udma_write(uc->channel->reg_rt, reg, val); \ +} \ +\ +static inline void udma_##channel##rt_update_bits(struct udma_chan *uc, in= t reg, \ + u32 mask, u32 val) \ +{ \ + if (!uc->channel) \ + return; \ + udma_update_bits(uc->channel->reg_rt, reg, mask, val); \ } =20 -static inline void udma_tchanrt_update_bits(struct udma_chan *uc, int reg, - u32 mask, u32 val) -{ - if (!uc->tchan) - return; - udma_update_bits(uc->tchan->reg_rt, reg, mask, val); -} - -/* RCHANRT */ -static inline u32 udma_rchanrt_read(struct udma_chan *uc, int reg) -{ - if (!uc->rchan) - return 0; - return udma_read(uc->rchan->reg_rt, reg); -} - -static inline void udma_rchanrt_write(struct udma_chan *uc, int reg, u32 v= al) -{ - if (!uc->rchan) - return; - udma_write(uc->rchan->reg_rt, reg, val); -} - -static inline void udma_rchanrt_update_bits(struct udma_chan *uc, int reg, - u32 mask, u32 val) -{ - if (!uc->rchan) - return; - udma_update_bits(uc->rchan->reg_rt, reg, mask, val); -} +_UDMA_REG_ACCESS(chan); +_UDMA_REG_ACCESS(bchan); +_UDMA_REG_ACCESS(tchan); +_UDMA_REG_ACCESS(rchan); =20 static inline dma_addr_t udma_curr_cppi5_desc_paddr(struct udma_desc *d, int idx) diff --git a/include/linux/soc/ti/k3-ringacc.h b/include/linux/soc/ti/k3-ri= ngacc.h index 9f2d141c988bd..1ac01b97dd923 100644 --- a/include/linux/soc/ti/k3-ringacc.h +++ b/include/linux/soc/ti/k3-ringacc.h @@ -10,6 +10,9 @@ =20 #include =20 +#define K3_RINGACC_RT_INT_STATUS_COMPLETE BIT(0) +#define K3_RINGACC_RT_INT_STATUS_TR BIT(2) + struct device_node; =20 /** --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 EA5C541D65D; Fri, 24 Jul 2026 10:23:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888607; cv=fail; b=Zc2xGeD/pqLe4rHDMIuLIfZPO62atvoRLhOCceB4LpG8K1+bLegCB+jm0o8QBopT5lignMtrjGlcJKI5iDKaLQP8NSsj6nrASwZ3k1VKxwLgcRF1r/nvxaTFrqDhmP9y/f62NFsnDnSZLvQtXGnMt2sfEiopYi8sZtck6/a/CFs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888607; c=relaxed/simple; bh=UdzNBMuE64PSapCQLmvMR5dK7I0CESelKeukkQ8ipm4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lWOVPTbrwapGebttoJa3XRSnx+PDb/sUYdSorf1QJMOhPJaff28ioQ+o4ON1GiFARIT544cyFheO9mEyD8hDA7quw7TfA04o7ww1p356VzefBEiXAuTH5b0E7ILiXcZ/f+mis9SCedqgO8xueoOyivx2I4z2H4TCBOzU3M832M8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=KnMCBMGU; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=G/w4L914; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="KnMCBMGU"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="G/w4L914" Received: from pps.filterd (m0380145.ppops.net [127.0.0.1]) by m0380145.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAF3Q3821212; Fri, 24 Jul 2026 05:23:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=mmVTWlnyzo+ApeBnFdQhkC7FsPHnp6KdcChlknerY Nc=; b=KnMCBMGUKVCZWojzWDZiSALLFkSB865LKhhMCfCrbpLePelLITrxFOrP8 L64mTX9LwjnBbmAHfXigNeeuzpOANFnfK1OAgAFc1m2gnbjecjYN8Nfh7pH/yCa/ 5+FK1CWuZze6pCLdCx6NuiSGHCgzLaAqhnC+BT1v1vr5uweBWfvg5pRBW/1Tlmgi mUeAhnKkqSCs5CydHlruro7VNuG+rc8yCs70KIyjdAGK8SpfIOwFRmvI+7aGLdhT WmZ+Oiercf4CT7itOhQ7BuW4pm1LM7seHgaCD/J1WIPQ47nwnrCy94p6X3OkvTtH +8IJdAGBDJ4shrfXl7nTq/cKZsBOw== Received: from ch5pr02cu005.outbound.protection.outlook.com (mail-northcentralusazon11012058.outbound.protection.outlook.com [40.107.200.58]) by m0380145.ppops.net (PPS) with ESMTPS id 4fm4vw0d6x-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:23:01 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uvlmfmHv4w2H94X14ODYLJpTq9RacuXp56w7nX1wxGYJbEy6rHTqC/q2cCKu7DlIdp200kg8dNO1T9GjMcbtoPsrwu5J7QiAMQC5wn9zV4kUk4swH3EESOeMTaMTKHavQRDrloADajJreUk9FJOhkBH5gIrSVUhCNvxempmTSI6RS7+poWp8s+9LXmVSKgC2+gbRP9ySeBXzDrRQTli44/Mb36t3sWkFlDAUmKXv5EdduiTfedwtC9mQZqVQRCnOL+DV4V+YfpYdAVQTm0pGYH0umrIjZ05zBLPhaHTZQ1t5r8aJvpuWzDTZg+NG7cCsA27G9crMvQOz+67Pfm4e5w== 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=mmVTWlnyzo+ApeBnFdQhkC7FsPHnp6KdcChlknerYNc=; b=XFMIZrfRMNQBc4L/8gKV7A8igccj7ZKXOi/uFb4dW1H8tFEhnFVfwHbRrqyD/TkklObUt3CoqJ/TDdetuQuAoVQX5U3L90dQ56/yMloVr7A8b++qKlp7VUX4tZrmU1yNjCceoS8db8Jm/qPBSAFnUrAF/TTXpChxF1YlX0Qtqgxqh4K1+pP6l1uUTbanLFwcCxsdCr1F1AneF8FIEIMnGxoEDsuns0hqSFkBODX7zCyhmwgD8vcvdLPJzAY/ZiojBQEP+CWCvqmLihvybxWgsXXjzl4Y6KlYBLzfbsjF8L0KqYm+SelFVZitgqjBj/b7VAdvdIgpP3gdYRexAqer/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mmVTWlnyzo+ApeBnFdQhkC7FsPHnp6KdcChlknerYNc=; b=G/w4L9140uWNeF5/vkdkMA8tbwEjT6EN206/ENKBlZ18zyiNnANWZ3guonOUGXv/mcwQDcCTqkxilVdsydFTvdbljlU4faPVq1T/pqpJvFzApgu5XZxSqzo1Gn6qp3GRYO4t74R4Okcx8OPLDkseCpaMOwI8x6wV6gRX5An5A7s= Received: from CH2PR18CA0032.namprd18.prod.outlook.com (2603:10b6:610:55::12) by SA6PR10MB8206.namprd10.prod.outlook.com (2603:10b6:806:441::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Fri, 24 Jul 2026 10:22:56 +0000 Received: from CH2PEPF00000142.namprd02.prod.outlook.com (2603:10b6:610:55:cafe::ad) by CH2PR18CA0032.outlook.office365.com (2603:10b6:610:55::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:22:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CH2PEPF00000142.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:22:56 +0000 Received: from DLEE208.ent.ti.com (157.170.170.97) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:55 -0500 Received: from DLEE207.ent.ti.com (157.170.170.95) by DLEE208.ent.ti.com (157.170.170.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:22:55 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE207.ent.ti.com (157.170.170.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:22:55 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFW3017088; Fri, 24 Jul 2026 05:22:51 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 17/19] dmaengine: ti: k3-udma-v2: Add support for PKTDMA V2 Date: Fri, 24 Jul 2026 15:50:50 +0530 Message-ID: <20260724102115.2854-18-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000142:EE_|SA6PR10MB8206:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a3c319a-475d-415f-faaf-08dee96d8752 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|7416014|82310400026|36860700016|1800799024|921020|6133799003|56012099006|10067099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: OqLlMAwdHGWVMJ3AMkQoFPCXglOXT3+3Fo/PUZqF+9h5nn9vLoK1gtWQOSjuaAqOKVli17ZhkHc9kFlbDDb/FXNdJvmYwiMv6wO75nuj4w1GjUJEF2yoW/fVFXBkx4kPmZx+xG6cRX/zm29DX2GIEcIcDl1fLd+qBmayn7jQXlCA1LVEt3PWgFOuOwwsJ14q7OPFUyPc2xXwOSjPbyxOMqpcUnBa6jJlnJnM/76AfMknB0LN+0oX0NSGNjjcvXBo4IEmndFIRt4ASfiqBuHc9MgWKkk/OCb+EIcb6+JiK8b7wcW1CLQVT1jisEnKfgmk2MIaSTz2a6PkbFhw2X44a+tq6ElKNsEaRqFij4FuS6MkyiV9MTqF4O29/ZEu/2d9CV085AnKil+r0OwJlBrKTKlCLmVY9DJhFrceYxtlOCjHEj7GRyxZtW7DXSKJJtJCPV3BWAkJdvo766cvLofI452JSpKMEypTN4eploy+TlFR1JCXg8aNq09dOOp3RLUT4yPsc8D0r1VFJ+ftBNBsN2pNjWemNSOcKd0tPrFhwh4PhUkfS4AYby8M3tGEnx22CYmMbJ/RqAyHh+1FprzQb45A3kas42Syavjnl1CVqTve/1hd7n9P6mky/Rf6Pdo0gx8JCpk/H+hDD6LHjZRgxFxwuvOk+upd8IGC/OSnaeoPV0J2stwcusO2nPJnjCrJ8eq+hJDvqM71YnoDDWU57yxYEOAoYSQHr6dM/ZHgUpcVUc6tAOkrU+SYx0S9DGrO X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(23010399003)(7416014)(82310400026)(36860700016)(1800799024)(921020)(6133799003)(56012099006)(10067099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ggzqXIiNYWOd0YcSTsmad6s975nocyeoZ3fIkLGrXwE5NYuDW8GHdRh7MBOmU112dUhAZiiJFKoiuAuHfawyHsZW2F4+bRfSCMgVmuwgz4BKggFsrvGzZrl5tMPOiPqEQZu34bloPOd/fjCuFlT6/auWLapbB6sNaTKRigrgRm1Fl+HZMwk+QHL9dt9AnJ5xAPLCOpAVZFdhUA7B0vc1Lmk0DknWdINdY92Q98g45EE5fx73hX7BY2C4T9wSRggth3G1qTZz2kEmcNvY4hIw+HH/tIQVvuOvWs//nYDVpxs8MaPL9O2DOnbRUvrqk+7HP4BfqB8EvC8UT88UYRl2wwSvXDlbffqaMjnkZFpzeAw42V0M0LlqNzqEN/5HBNqP1r7nBT8I1FFV3bLMhbxaIqzJ1MmkVMfNT+RyxH+ZFtaJFJEoD70tlviBLN+fLpA3 X-Exchange-RoutingPolicyChecked: HY7zlceGZKaTK3tpZ/7Xw1oltKzyA+mP3v/Kjl+GaNuaC13kScFY09AmDeC3fr8G/EM8SXg60UcTdGMXrD2YVUz1FD8mcy3nRKMlbzMwLysW3hxQS82/JMdDNe3VvsaFMDDC2w5r3FPWVzrtRwx8sEdYqrNoHULQc/JBCJ8pQcjGFPSiqeF4CAfqaoyQUgOgtq0xZbcrk7i2mQfKUICx1fmy7oNvkD9T1zTydnvKfAzDgB+EP/8hpqHpnH9M7MEhbXWZlYuEb3TmrXIXOwPO2m85hN6qgRH5oO5Lhkx/TmApllaAGpJz0KGemxBpVBDwUIuG4nmTfMYteNuk5ctmNg== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:22:56.3093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a3c319a-475d-415f-faaf-08dee96d8752 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000142.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA6PR10MB8206 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX5U2EACEWEeH+ ++Ct96ECk4GZTA7Y0uG2m5Yv/mxahW8myr+iFnQxABb70SQm5h/KASsa6QSCVesbqVYpEqB17s6 V1GHzz/wGp6DmajGo9yvT3mqs6WDBMK+8/Xupx3BiQUmrp3A+gCfRPXBQCvUuVGsje1zxesxvfW nsfZc6F52V4HNYrioO3bU+7DizTepbKXL9ZN2l7tcb+jLqhAvjjNUaQBxgx9MFXYKoSGk6CPIWG d2MZezvYDZM2MFGQlYoaK0tyqjCyRlcyfYrO9SNVBSK84A379clnA9Hago5LlKCYFrkk0fQ9e0g nUxvTCKMgm+0nPlZlB1q9cp7lhuIVBlMdVa3TF9zcmSGy0mgtVOggkMiif9d4gOXArnB9ykOqCX QWIoPuWrCrxECEBiZXKCV+oa6qlYziSPeARcOldaaT/Ean8TvZ5l0YJtQj0RkUJfpL6ZjKaApAR 8JbsISfcuAdvQYPHtCQ== X-Proofpoint-GUID: TNHJA3ySjq1Tw6_cYspkrBRKB5YegWVd X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX8DAyDi7U7YY/ QfpTzeGAEG0pTOmJE3t3FfYwRnonjf73YtS2cK3jyFDJafGSilF4owL1u8iaXqfqSsrJq9CCDBU UfJ3Fmylbr3xS5YM/2zSBnGhAyuHfB0= X-Proofpoint-ORIG-GUID: TNHJA3ySjq1Tw6_cYspkrBRKB5YegWVd X-Authority-Analysis: v=2.4 cv=feadDUQF c=1 sm=1 tr=0 ts=6a633d05 cx=c_pps a=UC1wTn8whqDYkpYF2DSMwg==:117 a=WotqVVQAdb04rnGuttW3Kw==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=gO1vWkAQAl3rybz1DQOp:22 a=sozttTNsAAAA:8 a=kuJ5fwJTF0DCxNmv2DYA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 adultscore=0 impostorscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" The PKTDMA V2 is different than the existing PKTDMA supported by the k3-udma driver. The changes in PKTDMA V2 are: - Autopair: There is no longer a need for PSIL pair and AUTOPAIR bit needs to set in the RT_CTL register. - Static channel mapping: Each channel is mapped to a single peripheral. - Direct IRQs: There is no INT-A and interrupt lines from DMA are directly connected to GIC. - Remote side configuration handled by DMA. So no need to write to PEER registers to START / STOP / PAUSE / TEARDOWN. - Unified Channel Space: Tx and Rx channels share a single register space. Each channel index is specifically fixed in hardware as either Tx or Rx in an interleaved manner. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma-common.c | 42 +++--- drivers/dma/ti/k3-udma-glue.c | 23 ++++ drivers/dma/ti/k3-udma-private.c | 12 +- drivers/dma/ti/k3-udma-v2.c | 221 +++++++++++++++++++++++++++++-- drivers/dma/ti/k3-udma.h | 3 + 5 files changed, 269 insertions(+), 32 deletions(-) diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index 10a42fff128aa..d7c148ad694f9 100644 --- a/drivers/dma/ti/k3-udma-common.c +++ b/drivers/dma/ti/k3-udma-common.c @@ -2453,21 +2453,25 @@ int pktdma_setup_resources(struct udma_dev *ud) ud->rchan_tpl.start_idx[0] =3D ud->tchan_tpl.start_idx[0]; ud->rchan_tpl.start_idx[1] =3D ud->tchan_tpl.start_idx[1]; =20 - ud->tchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), - sizeof(unsigned long), GFP_KERNEL); + ud->tchan_map =3D devm_bitmap_zalloc(dev, ud->tchan_cnt, GFP_KERNEL); ud->tchans =3D devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), GFP_KERNEL); - ud->rchan_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), - sizeof(unsigned long), GFP_KERNEL); - ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), - GFP_KERNEL); + if (ud->match_data->version =3D=3D K3_UDMA_V1) { + ud->rchan_map =3D devm_bitmap_zalloc(dev, ud->rchan_cnt, GFP_KERNEL); + ud->rchans =3D devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), + GFP_KERNEL); + } else { + ud->rchan_map =3D ud->tchan_map; + ud->rchans =3D ud->tchans; + ud->chan_map =3D ud->tchan_map; + ud->chans =3D ud->tchans; + } ud->rflow_in_use =3D devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt), sizeof(unsigned long), GFP_KERNEL); ud->rflows =3D devm_kcalloc(dev, ud->rflow_cnt, sizeof(*ud->rflows), GFP_KERNEL); - ud->tflow_map =3D devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tflow_cnt), - sizeof(unsigned long), GFP_KERNEL); + ud->tflow_map =3D devm_bitmap_zalloc(dev, ud->tflow_cnt, GFP_KERNEL); =20 if (!ud->tchan_map || !ud->rchan_map || !ud->tflow_map || !ud->tchans || !ud->rchans || !ud->rflows || !ud->rflow_in_use) @@ -2558,13 +2562,21 @@ int setup_resources(struct udma_dev *ud) } 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)); + if (ud->match_data->version =3D=3D K3_UDMA_V1) { + 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)); + } else { + dev_info(dev, + "Channels: %d (tchan + rchan: %u)\n", + ch_count, + ud->chan_cnt - bitmap_weight(ud->chan_map, + ud->chan_cnt)); + } break; default: break; diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index 686dc140293eb..bec4deb480e60 100644 --- a/drivers/dma/ti/k3-udma-glue.c +++ b/drivers/dma/ti/k3-udma-glue.c @@ -166,6 +166,29 @@ static int of_k3_udma_glue_parse_chn(struct device_nod= e *chn_np, goto out_put_spec; =20 thread_id =3D dma_spec.args[0]; + + /* + * V2 PKTDMA DT specifiers encode the hardware flow/channel ID in + * args[0] rather than the PSI-L thread ID used by V1. Resolve the + * PSI-L thread ID before the common path checks the direction bit. + */ + if (common->udmax->match_data->version =3D=3D K3_UDMA_V2 && + xudma_is_pktdma(common->udmax)) { + struct psil_endpoint_config *ep_cfg; + u32 psil_thread_id; + bool dev_to_mem; + + ep_cfg =3D psil_get_ep_config_by_id(thread_id, DMA_TYPE_PKTDMA, + &psil_thread_id, &dev_to_mem); + if (IS_ERR(ep_cfg)) { + dev_err(common->dev, + "No PSI-L config for flow %u\n", thread_id); + ret =3D PTR_ERR(ep_cfg); + goto out_put_spec; + } + thread_id =3D psil_thread_id; + } + if (dma_spec.args_count =3D=3D 2) { if (dma_spec.args[1] > 2 && !xudma_is_pktdma(common->udmax)) { dev_err(common->dev, "Invalid channel atype: %u\n", diff --git a/drivers/dma/ti/k3-udma-private.c b/drivers/dma/ti/k3-udma-priv= ate.c index 44c097fff5ee6..41299d3c3d91a 100644 --- a/drivers/dma/ti/k3-udma-private.c +++ b/drivers/dma/ti/k3-udma-private.c @@ -174,16 +174,20 @@ EXPORT_SYMBOL(xudma_is_pktdma); =20 int xudma_pktdma_tflow_get_irq(struct udma_dev *ud, int udma_tflow_id) { - const struct udma_oes_offsets *oes =3D &ud->soc_data->oes; + struct platform_device *pdev =3D to_platform_device(ud->dev); + char irq_name[10]; =20 - return msi_get_virq(ud->dev, udma_tflow_id + oes->pktdma_tchan_flow); + snprintf(irq_name, sizeof(irq_name), "tflow%u", udma_tflow_id); + return platform_get_irq_byname(pdev, irq_name); } EXPORT_SYMBOL(xudma_pktdma_tflow_get_irq); =20 int xudma_pktdma_rflow_get_irq(struct udma_dev *ud, int udma_rflow_id) { - const struct udma_oes_offsets *oes =3D &ud->soc_data->oes; + struct platform_device *pdev =3D to_platform_device(ud->dev); + char irq_name[10]; =20 - return msi_get_virq(ud->dev, udma_rflow_id + oes->pktdma_rchan_flow); + snprintf(irq_name, sizeof(irq_name), "rflow%u", udma_rflow_id); + return platform_get_irq_byname(pdev, irq_name); } EXPORT_SYMBOL(xudma_pktdma_rflow_get_irq); diff --git a/drivers/dma/ti/k3-udma-v2.c b/drivers/dma/ti/k3-udma-v2.c index e7989b0b34cac..879042bff79a6 100644 --- a/drivers/dma/ti/k3-udma-v2.c +++ b/drivers/dma/ti/k3-udma-v2.c @@ -753,6 +753,145 @@ static int bcdma_v2_alloc_chan_resources(struct dma_c= han *chan) return ret; } =20 +static int pktdma_v2_alloc_chan_resources(struct dma_chan *chan) +{ + struct udma_chan *uc =3D to_udma_chan(chan); + struct udma_dev *ud =3D to_udma_dev(chan->device); + struct platform_device *pdev =3D to_platform_device(ud->dev); + char irq_name[10]; + u32 irq_ring_idx; + int ret; + + /* + * Make sure that the completion is in a known state: + * No teardown, the channel is idle + */ + reinit_completion(&uc->teardown_completed); + complete_all(&uc->teardown_completed); + uc->state =3D UDMA_CHAN_IS_IDLE; + + switch (uc->config.dir) { + case DMA_MEM_TO_DEV: + /* Slave transfer synchronized - mem to dev (TX) transfer */ + dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-DEV\n", __func__, + uc->id); + + ret =3D udma_v2_alloc_tx_resources(uc); + if (ret) { + uc->config.remote_thread_id =3D -1; + return ret; + } + + uc->config.src_thread =3D ud->psil_base + uc->tchan->id; + uc->config.dst_thread =3D uc->config.remote_thread_id; + uc->config.dst_thread |=3D K3_PSIL_DST_THREAD_ID_OFFSET; + + irq_ring_idx =3D uc->config.mapped_channel_id; + break; + case DMA_DEV_TO_MEM: + /* Slave transfer synchronized - dev to mem (RX) transfer */ + dev_dbg(uc->ud->dev, "%s: chan%d as DEV-to-MEM\n", __func__, + uc->id); + + ret =3D udma_v2_alloc_rx_resources(uc); + if (ret) { + uc->config.remote_thread_id =3D -1; + return ret; + } + + uc->config.src_thread =3D uc->config.remote_thread_id; + uc->config.dst_thread =3D (ud->psil_base + uc->rchan->id) | + K3_PSIL_DST_THREAD_ID_OFFSET; + + irq_ring_idx =3D uc->config.mapped_channel_id; + udma_write(uc->rflow->reg_rt, UDMA_RX_FLOWRT_RFA, BIT(28)); + break; + default: + /* Can not happen */ + dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n", + __func__, uc->id, uc->config.dir); + return -EINVAL; + } + + /* check if the channel configuration was successful */ + if (ret) + goto err_res_free; + + if (udma_is_chan_running(uc)) { + dev_warn(ud->dev, "chan%d: is running!\n", uc->id); + ud->reset_chan(uc, false); + if (udma_is_chan_running(uc)) { + dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); + ret =3D -EBUSY; + goto err_res_free; + } + } + + uc->dma_dev =3D dmaengine_get_dma_device(chan); + uc->hdesc_pool =3D dma_pool_create(uc->name, uc->dma_dev, + uc->config.hdesc_size, ud->desc_align, + 0); + if (!uc->hdesc_pool) { + dev_err(ud->ddev.dev, + "Descriptor pool allocation failed\n"); + uc->use_dma_pool =3D false; + ret =3D -ENOMEM; + goto err_res_free; + } + + uc->use_dma_pool =3D true; + + uc->psil_paired =3D true; + + if (uc->config.dir =3D=3D DMA_MEM_TO_DEV) + snprintf(irq_name, sizeof(irq_name), "tflow%u", irq_ring_idx); + else + snprintf(irq_name, sizeof(irq_name), "rflow%u", irq_ring_idx); + uc->irq_num_ring =3D platform_get_irq_byname(pdev, irq_name); + if (uc->irq_num_ring < 0) + return uc->irq_num_ring; + + ret =3D request_irq(uc->irq_num_ring, udma_v2_ring_irq_handler, + IRQF_SHARED | IRQF_TRIGGER_HIGH, uc->name, uc); + + if (ret) { + dev_err(ud->dev, "chan%d: ring irq request failed\n", uc->id); + goto err_irq_free; + } + + uc->irq_num_udma =3D 0; + + udma_reset_rings(uc); + + INIT_DELAYED_WORK_ONSTACK(&uc->tx_drain.work, + udma_check_tx_completion); + + if (uc->tchan) + dev_dbg(ud->dev, + "chan%d: tchan%d, tflow%d, Remote thread: 0x%04x\n", + uc->id, uc->tchan->id, uc->tchan->tflow_id, + uc->config.remote_thread_id); + else if (uc->rchan) + dev_dbg(ud->dev, + "chan%d: rchan%d, rflow%d, Remote thread: 0x%04x\n", + uc->id, uc->rchan->id, uc->rflow->id, + uc->config.remote_thread_id); + return 0; + +err_irq_free: + uc->irq_num_ring =3D 0; +err_res_free: + udma_free_tx_resources(uc); + udma_free_rx_resources(uc); + + udma_reset_uchan(uc); + + dma_pool_destroy(uc->hdesc_pool); + uc->use_dma_pool =3D false; + + return ret; +} + static enum dma_status udma_v2_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *txstate) @@ -847,6 +986,7 @@ static int udma_v2_resume(struct dma_chan *chan) } =20 static struct platform_driver bcdma_v2_driver; +static struct platform_driver pktdma_v2_driver; =20 static bool udma_v2_dma_filter_fn(struct dma_chan *chan, void *param) { @@ -856,7 +996,8 @@ static bool udma_v2_dma_filter_fn(struct dma_chan *chan= , void *param) struct udma_chan *uc; struct udma_dev *ud; =20 - if (chan->device->dev->driver !=3D &bcdma_v2_driver.driver) + if (chan->device->dev->driver !=3D &bcdma_v2_driver.driver && + chan->device->dev->driver !=3D &pktdma_v2_driver.driver) return false; =20 uc =3D to_udma_chan(chan); @@ -1009,11 +1150,34 @@ static struct udma_match_data bcdma_v2_am62l_data = =3D { .rchan_cnt =3D 128, }; =20 +static struct udma_match_data pktdma_v2_am62l_data =3D { + .type =3D DMA_TYPE_PKTDMA, + .version =3D K3_UDMA_V2, + .psil_base =3D 0x1000, + .enable_memcpy_support =3D false, /* PKTDMA does not support MEM_TO_MEM */ + .flags =3D UDMA_FLAGS_J7_CLASS, + .statictr_z_mask =3D GENMASK(23, 0), + .burst_size =3D { + TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_64_BYTES, /* Normal Channels */ + 0, /* No H Channels */ + 0, /* No UH Channels */ + }, + .tchan_cnt =3D 97, + .rchan_cnt =3D 97, + .chan_cnt =3D 97, + .tflow_cnt =3D 112, + .rflow_cnt =3D 112, +}; + static const struct of_device_id udma_of_match[] =3D { { .compatible =3D "ti,am62l-dmss-bcdma", .data =3D &bcdma_v2_am62l_data, }, + { + .compatible =3D "ti,am62l-dmss-pktdma", + .data =3D &pktdma_v2_am62l_data, + }, { /* Sentinel */ }, }; =20 @@ -1032,15 +1196,23 @@ static int udma_v2_get_mmrs(struct platform_device = *pdev, struct udma_dev *ud) if (IS_ERR(ud->mmrs[V2_MMR_GCFG])) return PTR_ERR(ud->mmrs[V2_MMR_GCFG]); =20 - ud->bchan_cnt =3D ud->match_data->bchan_cnt; - /* There are no tchan and rchan in BCDMA_V2. + /* There are no tchan and rchan in BCDMA_V2 and PKTDMA_V2. * Duplicate chan as tchan and rchan to keep the common code - * in k3-udma-common.c functional for BCDMA_V2. + * in k3-udma-common.c functional. */ - ud->chan_cnt =3D ud->match_data->chan_cnt; - ud->tchan_cnt =3D ud->match_data->chan_cnt; - ud->rchan_cnt =3D ud->match_data->chan_cnt; - ud->rflow_cnt =3D ud->chan_cnt; + if (ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { + ud->bchan_cnt =3D ud->match_data->bchan_cnt; + ud->chan_cnt =3D ud->match_data->chan_cnt; + ud->tchan_cnt =3D ud->match_data->chan_cnt; + ud->rchan_cnt =3D ud->match_data->chan_cnt; + ud->rflow_cnt =3D ud->chan_cnt; + } else if (ud->match_data->type =3D=3D DMA_TYPE_PKTDMA) { + ud->chan_cnt =3D ud->match_data->chan_cnt; + ud->tchan_cnt =3D ud->match_data->tchan_cnt; + ud->rchan_cnt =3D ud->match_data->rchan_cnt; + ud->tflow_cnt =3D ud->match_data->tflow_cnt; + ud->rflow_cnt =3D ud->match_data->rflow_cnt; + } =20 for (i =3D 1; i < V2_MMR_LAST; i++) { if (i =3D=3D V2_MMR_BCHANRT && ud->bchan_cnt =3D=3D 0) @@ -1094,6 +1266,7 @@ static int udma_v2_probe(struct platform_device *pdev) ud->reset_chan =3D udma_v2_reset_chan; ud->decrement_byte_counters =3D udma_v2_decrement_byte_counters; ud->bcdma_setup_sci_resources =3D NULL; + ud->pktdma_setup_sci_resources =3D NULL; =20 ret =3D udma_v2_get_mmrs(pdev, ud); if (ret) @@ -1101,7 +1274,17 @@ static int udma_v2_probe(struct platform_device *pde= v) =20 struct k3_ringacc_init_data ring_init_data =3D {0}; =20 - ring_init_data.num_rings =3D ud->bchan_cnt + ud->chan_cnt; + if (ud->match_data->type =3D=3D DMA_TYPE_BCDMA) { + ring_init_data.num_rings =3D ud->bchan_cnt + ud->chan_cnt; + } else if (ud->match_data->type =3D=3D DMA_TYPE_PKTDMA) { + ring_init_data.num_rings =3D ud->rflow_cnt; + + ud->rflow_rt =3D devm_platform_ioremap_resource_byname(pdev, "ringrt"); + if (IS_ERR(ud->rflow_rt)) + return PTR_ERR(ud->rflow_rt); + + ring_init_data.base_rt =3D ud->rflow_rt; + } =20 ud->ringacc =3D k3_ringacc_dmarings_init(pdev, &ring_init_data); =20 @@ -1110,8 +1293,10 @@ static int udma_v2_probe(struct platform_device *pde= v) =20 dma_cap_set(DMA_SLAVE, ud->ddev.cap_mask); =20 - dma_cap_set(DMA_CYCLIC, ud->ddev.cap_mask); - ud->ddev.device_prep_dma_cyclic =3D udma_prep_dma_cyclic; + if (ud->match_data->type !=3D DMA_TYPE_PKTDMA) { + dma_cap_set(DMA_CYCLIC, ud->ddev.cap_mask); + ud->ddev.device_prep_dma_cyclic =3D udma_prep_dma_cyclic; + } =20 ud->ddev.device_config =3D udma_slave_config; ud->ddev.device_prep_slave_sg =3D udma_prep_slave_sg; @@ -1125,8 +1310,18 @@ static int udma_v2_probe(struct platform_device *pde= v) ud->ddev.dbg_summary_show =3D udma_dbg_summary_show; #endif =20 - ud->ddev.device_alloc_chan_resources =3D - bcdma_v2_alloc_chan_resources; + switch (ud->match_data->type) { + case DMA_TYPE_BCDMA: + ud->ddev.device_alloc_chan_resources =3D + bcdma_v2_alloc_chan_resources; + break; + case DMA_TYPE_PKTDMA: + ud->ddev.device_alloc_chan_resources =3D + pktdma_v2_alloc_chan_resources; + break; + default: + return -EINVAL; + } =20 ud->ddev.device_free_chan_resources =3D udma_free_chan_resources; =20 diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 680d776f7ae8c..fc8f0cfe7a36e 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -27,8 +27,11 @@ #define UDMA_RX_FLOW_ID_FW_OES_REG 0x80 #define UDMA_RX_FLOW_ID_FW_STATUS_REG 0x88 =20 +#define UDMA_RX_FLOWRT_RFA 0x8 + /* BCHANRT/TCHANRT/RCHANRT registers */ #define UDMA_CHAN_RT_CTL_REG 0x0 +#define UDMA_CHAN_RT_CFG_REG 0x4 #define UDMA_CHAN_RT_SWTRIG_REG 0x8 #define UDMA_CHAN_RT_STDATA_REG 0x80 =20 --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0b-0002e601.pphosted.com (mx0b-0002e601.pphosted.com [148.163.154.28]) (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 3CF28435AB2; Fri, 24 Jul 2026 10:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.154.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888614; cv=fail; b=mWYX/hpwIIKANwQW01LTY2oh57XNAiaL1x6yTympTFWeYcrZ+L5QYpo/fIHNuz41I6bo12MHlfcbRPtXvA80KZjhHr5j2m6aAAhKXVyEpaFc61GIxzweIQf9eqBT55PWK/TTy5O15ktTh3CopjH23Fw4DRvE0BT9FTHjP5kicF0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888614; c=relaxed/simple; bh=MSNn7R6C5gCK15HH45MU/Qp0BlT84nl3jZ/dgMO4vEY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SziJIAft3NJh1OFBw8tjASq9kqlQNlGpwQi3qJtFEO4kWWhGX43o53uhcOunAVZmctxX1ENrkcJxaFh1E5//BYCcW8PlVtkc12dTYUTRKGl7B5YU4FLMTQiWwMR/wiy8ajAWaJ6/VU2xWdfTg27BPbM90EL6KP0jH6vIaMbPAb4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=AtipSuT7; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=G8ag9gKd; arc=fail smtp.client-ip=148.163.154.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="AtipSuT7"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="G8ag9gKd" Received: from pps.filterd (m0374955.ppops.net [127.0.0.1]) by mx0b-0002e601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66OAFZ0I1093922; Fri, 24 Jul 2026 05:23:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=C5O5/KQzcRH4emdLqgh+uLZUHRwbAskPo1Mjg/eqe 5U=; b=AtipSuT7m2OIUq3wKtRHTQgAYUcsmtEtjHHHKWrFu8J+Thy53EauFtgVd zRDJd7HyTdi1gFrRQdvmAN0XP++I9Qc605smhZ+ySG35Oi2LcsvoT7KnhexVvY20 QNzUtY7S6NlI4Hjv7HS6ZR3QgQSoSEQD2JtoISgiGiSrwX+3tmQq7gpHqVEDGSDG 18SxCA+x/H7vvECOjcJo2lSMo+PTIM08XIAkQOJx5Ap3Nw/1ZothCGg2VVe6/Iwc G4uOg/epkydnlKBYdVcIkrmBqn6GdmpckEmvytjn+oNSEhFoVGQsiWmO1W7sTWbM jtQt4YqnnMO7IyCRbBOV0as89njBA== Received: from ch5pr02cu005.outbound.protection.outlook.com (mail-northcentralusazon11012010.outbound.protection.outlook.com [40.107.200.10]) by mx0b-0002e601.pphosted.com (PPS) with ESMTPS id 4fkyp7j41m-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:23:09 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jT+EE+KjYHPzT9vrcd5MBrgCo/pzVRw2241SlBwTa3+ojpSQcDnlC+YDWt651ZsYA5F1YOE5pkGVCo4Fo0/aOQPJPIz//dMzs1O09UMl5qda1aqcjDUya2To4VF8xCBE9E+OuzanKsVwD3NHslt+3MxRfdDZDchyWw8A6SOchh3/CskHRfXgPuBUykveswzUMoKInCRQ+sdtbHGFZkIBaECF1+fc5UOa8YsH7uFxfhRXLkqQMYJnppTPNP/i0VLJtb2BWAg4uSJfLJMbYzACqV3Ufmw+rGv8G9j/1UEDlvVgdnBsx5CzoEd8dnbzYcJGtJcXexZiAi9Zf+Gn+uZqig== 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=C5O5/KQzcRH4emdLqgh+uLZUHRwbAskPo1Mjg/eqe5U=; b=mGT10mLy0zMKfXtc34NTsaHSlx5PZ9ogDD4txMKAfHvu14aI/GqX+9RjYfXc+JfZGe8EtU4phhxLT7ZX8eoYLxZjiQDm4vD1qETpclezUurZRFgoMNwsp1eAkPSbvAagDrtAY7t5xojPTQQ112UjBJQ3UMwh/IxEly+rzF0ZkPq4ZfIvlGZv3Za4JD7RZjLx7TVkVaI1dsPVAPziZD9ahxCY10PL8ot6g4cH30hSRCH9D1CWLjjuoufIgHga4aKpmFPKDaIDDw83BgtZrkWt7EQTdFMbiYYBqZrvE2+XaB255PT0q47ygif1ElEuEbFIbI5Rb9X7xca5ue7cjjNC0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C5O5/KQzcRH4emdLqgh+uLZUHRwbAskPo1Mjg/eqe5U=; b=G8ag9gKdfVM2sIlXCm6TNY+xKQL1JQm2K4fB2QP/NnsTEJGvlN6kLdqqD1D19ULV2m+nBo+UOfRoKz+32OlNBrfBzsT8ym0LA3OXw2mD0QzZuZ64Kl/gACIlsPDNPRxFG0QDPqn3OKUpFG7mI+B53ajozk9XLgRZGn5sndWyPPY= Received: from SJ0PR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:33f::21) by IA0PR10MB6890.namprd10.prod.outlook.com (2603:10b6:208:432::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:23:02 +0000 Received: from SJ1PEPF00002313.namprd03.prod.outlook.com (2603:10b6:a03:33f:cafe::90) by SJ0PR05CA0046.outlook.office365.com (2603:10b6:a03:33f::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:23:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ1PEPF00002313.mail.protection.outlook.com (10.167.242.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:23:01 +0000 Received: from DLEE215.ent.ti.com (157.170.170.118) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:23:01 -0500 Received: from DLEE212.ent.ti.com (157.170.170.114) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:23:01 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE212.ent.ti.com (157.170.170.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:23:00 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFX3017088; Fri, 24 Jul 2026 05:22:56 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 18/19] dmaengine: ti: k3-udma-v2: Update glue layer to support PKTDMA V2 Date: Fri, 24 Jul 2026 15:50:51 +0530 Message-ID: <20260724102115.2854-19-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002313:EE_|IA0PR10MB6890:EE_ X-MS-Office365-Filtering-Correlation-Id: 434e9a78-6f7e-4de5-d41e-08dee96d8a77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|1800799024|376014|7416014|13003099007|921020|6133799003|10067099003|56012099006|22082099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: 0R3qex1fdqYLbrtXwqLRlp+QgHteNyuTNiohBmZVjgL42KZhTRsSFAJxg544qHvnnnZTNFstOIY4BS/pKe/SPkbHIMVdDWsvhHK8s46aexRJWwtqMNEHDM2dPWryPmNur4Q2qKapfU6Eqz8fRMwKNaUeBoikmuMlR0XZC7+1EI3AL90N8WtdTq4z/UQJGGqDRK9F/Ogv02c6gqMl6CuKPacoboJMBTtREftghE90abi8fp15o3L3J7571WbrDLHeHc2/p1TkUKDe2Xu2nPS5wXnazu7eg37tSKnfkHvm8fO4eCFJkdfRCua5S7mvUzJdZhEH9zRNOAoOwx3bossC3b1QJMyo1EpzoeHgV30BouzOmd851GX7NFGZEmKZXS0Vs+piBEoYYi/w1hKc7/glJKdeORChlMtW7KL530814FB8W3qdXKXKOo0KocJWedwbpyo1WK2j6HJWo9/ApOdgyB5F3qQNq549qy0Pq4SYHhrpMjCBqqyEFipbnrSOqnEDql2lnliFuxArFx69kudYqpqaOXqzJmGPD7c7cjOvDBOAeBGw2Lrnn1Zq4OD45LGHrFVdOqO9bvG6hl7s4fTdY0DJ1mwpVDbRn3qKrYZ0Ih0vWkt0LSPaz6IeBhfAS6mjQGX7Sao8HFygorp3+xXW/ddRdtI4RGV6S+uKBm/rD4G4PuFDzEUVcZd6pAcz/ymM795JDvM1jCuoV+tUUlBiQg== X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(36860700016)(1800799024)(376014)(7416014)(13003099007)(921020)(6133799003)(10067099003)(56012099006)(22082099003)(18002099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3WNQSbDcqvztUqEOdqYGErdMO+q7DHR7uBKUKUV52JYq0X+c4Vsfrx6whjnzhf/NknrhL43WoSVAmYJfe9FHhD8/nMKWe08haQyHSjxSbntecOQ5kKhVVD/n7YFCWzd6UYzlDcDlyxypDnVmjXxcjHy7EX9EsS1pyBomRkdwcpAt6lisyIFNZM4ta0F7zZAQuU/abMw9XIQpUWtvu6c/K+B4YMz2/DHp2AVzF8UNEZg2kirPwZBC8x3yJK7ULje2Vs9ggvpdMqsG0foCYZ5FZQR3ZWLFDeB44au1g22IEZlKh4gNGFXFqdM/Tziod0JMaJnY4URWf3SwXOYEQoPkxvf69pML/XSrqjkH5yJav3VgUUn/sDiN2nUhwwV+o4rEg2+mxIasTAXnl7yI0/wXXTbt2KdoAJgrVSmq/f2//82exT3fOUmE6jTlC/6L2cm1 X-Exchange-RoutingPolicyChecked: U3r35ZMmz3c2M6qaDOlTnlKNuwLDehK9mk9TS5oXDKKQYtmndSZUdOI4LwoU7jAPDp/VDhtVtU7edJYqF66hbkz+cDc+lrc8pc01VFQe8IBx0yW58Kj3cGDV5x0Ni59PvIj92vocV8G2rDkS5b05gWPuGLrO9qFgYe2UEYKE5OD4Pua+2hv5C1B4r7C+wlCqzbZhcrHfkS5AmkA/hMNAD3aKaAOAX6yk5YJww73uug8Z5h6Me2kNpanu3e/IzeSJthUl7x5a9ggXgOgyTBQ4ylrRzJiSUmlABYLJqkU433eFNXB7X7Yik6naTfAvDQj74O8aO9W6wWUQ+qPEWjBd6g== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:23:01.5538 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 434e9a78-6f7e-4de5-d41e-08dee96d8a77 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002313.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6890 X-Authority-Analysis: v=2.4 cv=M4p97Sws c=1 sm=1 tr=0 ts=6a633d0d cx=c_pps a=I0dIGTHPrmtoUi9UVMbYOA==:117 a=f+v6EHfkeJbVwR46tk4DMg==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=s63m1ICgrNkA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=fPAWb5peG099m5CrUpKH:22 a=sozttTNsAAAA:8 a=OJxNCoZY2EU3D4kC5y4A:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX0Kn8sD1tL6U2 sS2+0wQh609/BPnT3KUoFhGd/FhGUkDkD6LloEF0W7mzmaEr7EbTe4d2su9Y3Qw/o7X6bKk15kR x5+ljTW8zdvoLYe50J8scyf0b5VQ+48= X-Proofpoint-ORIG-GUID: 0pWL4Yx5jhR5AcS1wvTHDYeNhAWiWMTa X-Proofpoint-GUID: 0pWL4Yx5jhR5AcS1wvTHDYeNhAWiWMTa X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfXyZMwT25MXSDB 7p4YuG46Ge1WjmbQwIfDcfJf4z/FxpMD8C4DOmi/LkTXKHqzVl1cc9+q5t9SMgYKohaaUoqQwcO d8jFIW7TS02PLjnTogHL/gxo1mS9g8QFeMmH3Vy7ftjaAMUsVnI0/o3fYKVXMa+j1TgqjsQY8Jr GJg2A85PMBOXzcEkVwcaVoCHG8uv1/WAmnibgQFufe8AQJ2mzqf1ooTODGAOy7FnsXS3CtHa/HX +pTRTbFzb7NEziAr+PDWVIVww3oWAlL3NByPpA80ZsAxVQLMtkKUzZJYkYGl5HcVrQNcGp8nRwy DSPfeZml2qArW4mzN8TOc4kYrLjJppE0Cq4mkNTMeoo0PnLj3IRn2Mkl/L4NBAFiWWf6OnpzUkc zIvkKejMV+z77s43J8u+EUqODrWZTKLfrn9I3hlU5pvtC9RDol/18tdoZLeOoFMlerJDffw7cw2 sVTpEF3310R9agb/Rlw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" Update glue layer to support PKTDMA V2 for non DMAengine users. The updates include - Handling absence of TISCI - Direct IRQs - Autopair: Lack of PSIL pair. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/Kconfig | 2 +- drivers/dma/ti/k3-udma-glue.c | 92 ++++++++++++++++++++++---------- drivers/dma/ti/k3-udma-private.c | 15 ++++++ drivers/dma/ti/k3-udma.h | 10 ++++ 4 files changed, 90 insertions(+), 29 deletions(-) diff --git a/drivers/dma/ti/Kconfig b/drivers/dma/ti/Kconfig index 40713bd1e8e9b..ada2ea8aca4b0 100644 --- a/drivers/dma/ti/Kconfig +++ b/drivers/dma/ti/Kconfig @@ -68,7 +68,7 @@ config TI_K3_UDMA_COMMON config TI_K3_UDMA_GLUE_LAYER tristate "Texas Instruments UDMA Glue layer for non DMAengine users" depends on ARCH_K3 || COMPILE_TEST - depends on TI_K3_UDMA + depends on TI_K3_UDMA || TI_K3_UDMA_V2 help Say y here to support the K3 NAVSS DMA glue interface If unsure, say N. diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index bec4deb480e60..07952c4efee2d 100644 --- a/drivers/dma/ti/k3-udma-glue.c +++ b/drivers/dma/ti/k3-udma-glue.c @@ -267,6 +267,9 @@ static int k3_udma_glue_cfg_tx_chn(struct k3_udma_glue_= tx_channel *tx_chn) const struct udma_tisci_rm *tisci_rm =3D tx_chn->common.tisci_rm; struct ti_sci_msg_rm_udmap_tx_ch_cfg req; =20 + if (!tisci_rm->tisci) + return 0; + memset(&req, 0, sizeof(req)); =20 req.valid_params =3D TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID | @@ -525,21 +528,26 @@ int k3_udma_glue_enable_tx_chn(struct k3_udma_glue_tx= _channel *tx_chn) { int ret; =20 - ret =3D xudma_navss_psil_pair(tx_chn->common.udmax, - tx_chn->common.src_thread, - tx_chn->common.dst_thread); - if (ret) { - dev_err(tx_chn->common.dev, "PSI-L request err %d\n", ret); - return ret; - } + if (tx_chn->common.udmax->match_data->version =3D=3D K3_UDMA_V1) { + ret =3D xudma_navss_psil_pair(tx_chn->common.udmax, + tx_chn->common.src_thread, + tx_chn->common.dst_thread); + if (ret) { + dev_err(tx_chn->common.dev, "PSI-L request err %d\n", ret); + return ret; + } =20 - tx_chn->psil_paired =3D true; + tx_chn->psil_paired =3D true; =20 - xudma_tchanrt_write(tx_chn->udma_tchanx, UDMA_CHAN_RT_PEER_RT_EN_REG, - UDMA_PEER_RT_EN_ENABLE); + xudma_tchanrt_write(tx_chn->udma_tchanx, UDMA_CHAN_RT_PEER_RT_EN_REG, + UDMA_PEER_RT_EN_ENABLE); =20 - xudma_tchanrt_write(tx_chn->udma_tchanx, UDMA_CHAN_RT_CTL_REG, - UDMA_CHAN_RT_CTL_EN); + xudma_tchanrt_write(tx_chn->udma_tchanx, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN); + } else { + xudma_tchanrt_write(tx_chn->udma_tchanx, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_AUTOPAIR | UDMA_CHAN_RT_CTL_EN); + } =20 k3_udma_glue_dump_tx_rt_chn(tx_chn, "txchn en"); return 0; @@ -705,7 +713,6 @@ static int k3_udma_glue_cfg_rx_chn(struct k3_udma_glue_= rx_channel *rx_chn) TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID | TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID; =20 - req.nav_id =3D tisci_rm->tisci_dev_id; req.index =3D rx_chn->udma_rchan_id; req.rx_fetch_size =3D rx_chn->common.hdesc_size >> 2; /* @@ -725,11 +732,18 @@ static int k3_udma_glue_cfg_rx_chn(struct k3_udma_glu= e_rx_channel *rx_chn) req.rx_chan_type =3D TI_SCI_RM_UDMAP_CHAN_TYPE_PKT_PBRR; req.rx_atype =3D rx_chn->common.atype_asel; =20 + if (!tisci_rm->tisci) { + // TODO: look at the chan settings + xudma_rchanrt_write(rx_chn->udma_rchanx, UDMA_CHAN_RT_CFG_REG, + UDMA_CHAN_CFG_FILT_EINFO | UDMA_CHAN_CFG_FILT_PSWORDS); + return 0; + } + + req.nav_id =3D tisci_rm->tisci_dev_id; ret =3D tisci_rm->tisci_udmap_ops->rx_ch_cfg(tisci_rm->tisci, &req); if (ret) dev_err(rx_chn->common.dev, "rchan%d cfg failed %d\n", - rx_chn->udma_rchan_id, ret); - + rx_chn->udma_rchan_id, ret); return ret; } =20 @@ -778,8 +792,11 @@ static int k3_udma_glue_cfg_rx_flow(struct k3_udma_glu= e_rx_channel *rx_chn, } =20 if (xudma_is_pktdma(rx_chn->common.udmax)) { - rx_ringfdq_id =3D flow->udma_rflow_id + + if (tisci_rm->tisci) + rx_ringfdq_id =3D flow->udma_rflow_id + xudma_get_rflow_ring_offset(rx_chn->common.udmax); + else + rx_ringfdq_id =3D flow->udma_rflow_id; rx_ring_id =3D 0; } else { rx_ring_id =3D flow_cfg->ring_rxq_id; @@ -826,6 +843,14 @@ static int k3_udma_glue_cfg_rx_flow(struct k3_udma_glu= e_rx_channel *rx_chn, rx_ringfdq_id =3D k3_ringacc_get_ring_id(flow->ringrxfdq); } =20 + if (!tisci_rm->tisci) { + xudma_rflowrt_write(flow->udma_rflow, UDMA_RX_FLOWRT_RFA, + UDMA_FLOWRT_RFA_RX_EINFO_PRESENT | + UDMA_FLOWRT_RFA_RX_PSINFO_PRESENT); + rx_chn->flows_ready++; + return 0; + } + memset(&req, 0, sizeof(req)); =20 req.valid_params =3D @@ -1330,6 +1355,9 @@ int k3_udma_glue_rx_flow_enable(struct k3_udma_glue_r= x_channel *rx_chn, if (!rx_chn->remote) return -EINVAL; =20 + if (!tisci_rm->tisci) + return 0; + rx_ring_id =3D k3_ringacc_get_ring_id(flow->ringrx); rx_ringfdq_id =3D k3_ringacc_get_ring_id(flow->ringrxfdq); =20 @@ -1371,6 +1399,9 @@ int k3_udma_glue_rx_flow_disable(struct k3_udma_glue_= rx_channel *rx_chn, if (!rx_chn->remote) return -EINVAL; =20 + if (!tisci_rm->tisci) + return 0; + memset(&req, 0, sizeof(req)); req.valid_params =3D TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_QNUM_VALID | @@ -1406,21 +1437,26 @@ int k3_udma_glue_enable_rx_chn(struct k3_udma_glue_= rx_channel *rx_chn) if (rx_chn->flows_ready < rx_chn->flow_num) return -EINVAL; =20 - ret =3D xudma_navss_psil_pair(rx_chn->common.udmax, - rx_chn->common.src_thread, - rx_chn->common.dst_thread); - if (ret) { - dev_err(rx_chn->common.dev, "PSI-L request err %d\n", ret); - return ret; - } + if (rx_chn->common.udmax->match_data->version =3D=3D K3_UDMA_V1) { + ret =3D xudma_navss_psil_pair(rx_chn->common.udmax, + rx_chn->common.src_thread, + rx_chn->common.dst_thread); + if (ret) { + dev_err(rx_chn->common.dev, "PSI-L request err %d\n", ret); + return ret; + } =20 - rx_chn->psil_paired =3D true; + rx_chn->psil_paired =3D true; =20 - xudma_rchanrt_write(rx_chn->udma_rchanx, UDMA_CHAN_RT_CTL_REG, - UDMA_CHAN_RT_CTL_EN); + xudma_rchanrt_write(rx_chn->udma_rchanx, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_EN); =20 - xudma_rchanrt_write(rx_chn->udma_rchanx, UDMA_CHAN_RT_PEER_RT_EN_REG, - UDMA_PEER_RT_EN_ENABLE); + xudma_rchanrt_write(rx_chn->udma_rchanx, UDMA_CHAN_RT_PEER_RT_EN_REG, + UDMA_PEER_RT_EN_ENABLE); + } else { + xudma_rchanrt_write(rx_chn->udma_rchanx, UDMA_CHAN_RT_CTL_REG, + UDMA_CHAN_RT_CTL_AUTOPAIR | UDMA_CHAN_RT_CTL_EN); + } =20 k3_udma_glue_dump_rx_rt_chn(rx_chn, "rxrt en"); return 0; diff --git a/drivers/dma/ti/k3-udma-private.c b/drivers/dma/ti/k3-udma-priv= ate.c index 41299d3c3d91a..1eac4dcd5d880 100644 --- a/drivers/dma/ti/k3-udma-private.c +++ b/drivers/dma/ti/k3-udma-private.c @@ -3,6 +3,10 @@ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com * Author: Peter Ujfalusi */ +#include +#include +#include +#include #include #include =20 @@ -165,6 +169,7 @@ void xudma_##res##rt_write(struct udma_##res *p, int re= g, u32 val) \ EXPORT_SYMBOL(xudma_##res##rt_write) XUDMA_RT_IO_FUNCTIONS(tchan); XUDMA_RT_IO_FUNCTIONS(rchan); +XUDMA_RT_IO_FUNCTIONS(rflow); =20 int xudma_is_pktdma(struct udma_dev *ud) { @@ -174,6 +179,11 @@ EXPORT_SYMBOL(xudma_is_pktdma); =20 int xudma_pktdma_tflow_get_irq(struct udma_dev *ud, int udma_tflow_id) { + if (ud->match_data->version =3D=3D K3_UDMA_V1) { + const struct udma_oes_offsets *oes =3D &ud->soc_data->oes; + + return msi_get_virq(ud->dev, udma_tflow_id + oes->pktdma_tchan_flow); + } struct platform_device *pdev =3D to_platform_device(ud->dev); char irq_name[10]; =20 @@ -184,6 +194,11 @@ EXPORT_SYMBOL(xudma_pktdma_tflow_get_irq); =20 int xudma_pktdma_rflow_get_irq(struct udma_dev *ud, int udma_rflow_id) { + if (ud->match_data->version =3D=3D K3_UDMA_V1) { + const struct udma_oes_offsets *oes =3D &ud->soc_data->oes; + + return msi_get_virq(ud->dev, udma_rflow_id + oes->pktdma_rchan_flow); + } struct platform_device *pdev =3D to_platform_device(ud->dev); char irq_name[10]; =20 diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index fc8f0cfe7a36e..a2952183cd8e7 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -85,6 +85,14 @@ #define UDMA_CHAN_RT_CTL_PAIR_COMPLETE BIT(16) #define UDMA_CHAN_RT_CTL_ERROR BIT(0) =20 +/* UDMA_CHAN_CFG_REG */ +#define UDMA_CHAN_CFG_FILT_EINFO BIT(30) +#define UDMA_CHAN_CFG_FILT_PSWORDS BIT(29) + +/* UDMA_RX_FLOWRT_RFA */ +#define UDMA_FLOWRT_RFA_RX_EINFO_PRESENT BIT(30) +#define UDMA_FLOWRT_RFA_RX_PSINFO_PRESENT BIT(29) + /* UDMA_CHAN_RT_PDMA_STATE_REG */ #define UDMA_CHAN_RT_PDMA_STATE_IN_EVT BIT(31) #define UDMA_CHAN_RT_PDMA_STATE_TDOWN BIT(30) @@ -749,6 +757,8 @@ u32 xudma_rchanrt_read(struct udma_rchan *rchan, int re= g); void xudma_rchanrt_write(struct udma_rchan *rchan, int reg, u32 val); bool xudma_rflow_is_gp(struct udma_dev *ud, int id); int xudma_get_rflow_ring_offset(struct udma_dev *ud); +u32 xudma_rflowrt_read(struct udma_rflow *rflow, int reg); +void xudma_rflowrt_write(struct udma_rflow *rflow, int reg, u32 val); =20 int xudma_is_pktdma(struct udma_dev *ud); =20 --=20 2.54.0 From nobody Fri Jul 24 21:53:02 2026 Received: from mx0a-0002e601.pphosted.com (mx0a-0002e601.pphosted.com [148.163.150.75]) (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 E3445436344; Fri, 24 Jul 2026 10:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.150.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888623; cv=fail; b=LP6Ls7z32RdPuNN/Vt6CzhhPGne3r0XhOFBVE6n0bj0OxPPG5I70E8BPAwmeNRwUDbPmW5vRucaR3UrmXA26GUebIHNWOdFBQhyRPlQqMyruVhRuMoQvEPzeGD1gq5ePVrsGG0XA0SxRnpo047jvouoEnKCpmNGYDESQKMXbW7A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888623; c=relaxed/simple; bh=CiO6ry1YOOKsrffI8TGO5d9U0qf1KsG35D6VwptBlFQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ronAZ7w1qVTpOth6Ggzu12yGLmsy0HTuhQ/nJ4K07XZ2irjrAtozlDzlQalN1OQqcZkFtcjuUQz8eKhZKHLR1sYngZg2PaLmW7JtZsOs75KqgmJQNNtZJdng8ltNv7vVtCjFPY+IUG0039Vn+vfcnl2ubR/k5Wgv8rXCrv0Yzfg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b=PfLLP+BU; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=px0OPFs2; arc=fail smtp.client-ip=148.163.150.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ti.com header.i=@ti.com header.b="PfLLP+BU"; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="px0OPFs2" Received: from pps.filterd (m0384305.ppops.net [127.0.0.1]) by m0384305.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 66OAFC4h2796788; Fri, 24 Jul 2026 05:23:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint-05-2026; bh=GXGdgG58ROBEJqgorcVLSNLilXa2FQL79ZhqkIfPh xU=; b=PfLLP+BUSIRrXA4Joe1/iHn2wCmyMf8kWvjsh7SVTCksHP0QE4dzUjxhk Y3cYV2NOEtxRJ06G5OG83ZdroiEnkeJZIzrc8nj9NPT+L9u2Jl9AqnMVNh4q0e+l SBPZjSsv9UsNuWuFDFn6/NsHAvHhBoVYI/9rwTzt/QyLIBBL/UTiWOIZrkJy8tus l9Bf9epWeoCHOH5u/tIOxZkKOzB06x4c81klpSNuWi8HVp534xuVAp8ZLy3kDUmD bfaaYd4RKhMF1Y7/+sZgth53qW9hgfOs/kU5Egz0h9ljV4+P4htK/102rtAzCOu2 z+NbbERKnwGOzK9NcaSjghBUSdTjw== Received: from ph0pr06cu001.outbound.protection.outlook.com (mail-westus3azon11011037.outbound.protection.outlook.com [40.107.208.37]) by m0384305.ppops.net (PPS) with ESMTPS id 4fm3v38pyg-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Jul 2026 05:23:19 -0500 (CDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OqatNUMp/QD1wNoEriWdIKkEvBjKX6v8hdo8JZl5OhKgMyBXhdYrD8wZEpzODHbaAhBMyhNP7299r+jo757+h+FFCJJ19NjVMr0Xjx7V94rQWbPoSw+dGWukpxbnORvmUZuaJhj/ubl3bV9P+EGjNJnTQR5pxqBJTlTOEzvqiiPbx4Boes08IC3iZAaiOPBlAerzqN+p/fnMsJNK0m+HMHIqXWzz3XrE3DfU5F8Ued1zQTkaewy4VPP5eE3gGDoZWA/Vx5X1CfERCVDgnr8Rq/A1Wa6M0ppOz026ldGvxM+5v0x60J55/xlrI4XzyMXxgG/1+d+6kgr/Is0rveegfQ== 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=GXGdgG58ROBEJqgorcVLSNLilXa2FQL79ZhqkIfPhxU=; b=ObHD+e4TDV8s/dKw9g9jgRx2QdS2sUaOTB6yGavKdcUO3oDwM1TuzJdwm+g/ckG2k/iVD8uDBHD+ICPrI82t7RR9+iMf9pdCi4pHhnAMD2PZ/5+lJlOaIqhNWMfbuDcAHQtsH5uIw5UFPNhmvSh8RpDQpHRqZpGLP+JXrIutJv+d6W9InE1qWozoiR8pF4oWSRVVPf2CIyXWUPpeWsy5ypUoT8VrVMjOBkp8ZhEHFNUH9SvAuCF0S7/BqviZ9teBdTf1Z1oW3hfelrgHOsmRHK97zeuwexeV5oqrUN3OsdgZRyXAsoTU5wouKRyky6zwYXoUWGuM1jPIia6SPKGJxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=nxp.com smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GXGdgG58ROBEJqgorcVLSNLilXa2FQL79ZhqkIfPhxU=; b=px0OPFs27qrMjA+++nsFKzBNkGE3fxRqT6TVa4lv0jAJBy6xo8OkkVMUtF6oMrcQQkZRErVgF+Xjc7d+TpO3HPkbNUdbKToXKPSzjhi+dckdULKkA+x+OvWcgJJYq14cZXVsqhediSd5jS21Cg3xk2TwqbC/HtSyhaZeMCwd9Hw= Received: from MW4PR04CA0105.namprd04.prod.outlook.com (2603:10b6:303:83::20) by DS0PR10MB7341.namprd10.prod.outlook.com (2603:10b6:8:f8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.11; Fri, 24 Jul 2026 10:23:15 +0000 Received: from MWH0EPF000C618E.namprd02.prod.outlook.com (2603:10b6:303:83:cafe::7e) by MW4PR04CA0105.outlook.office365.com (2603:10b6:303:83::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.11 via Frontend Transport; Fri, 24 Jul 2026 10:23:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by MWH0EPF000C618E.mail.protection.outlook.com (10.167.249.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.5 via Frontend Transport; Fri, 24 Jul 2026 10:23:14 +0000 Received: from DFLE205.ent.ti.com (10.64.6.63) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:23:06 -0500 Received: from DFLE202.ent.ti.com (10.64.6.60) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 24 Jul 2026 05:23:06 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE202.ent.ti.com (10.64.6.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Fri, 24 Jul 2026 05:23:06 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [10.24.51.254]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 66OALMFY3017088; Fri, 24 Jul 2026 05:23:01 -0500 From: Sai Sree Kartheek Adivi To: , , , , , , , , , , , , , CC: , Subject: [PATCH v7 19/19] dmaengine: ti: k3-udma: Validate resource ID and fix logging in reservation Date: Fri, 24 Jul 2026 15:50:52 +0530 Message-ID: <20260724102115.2854-20-s-adivi@ti.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260724102115.2854-1-s-adivi@ti.com> References: <20260724102115.2854-1-s-adivi@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C618E:EE_|DS0PR10MB7341:EE_ X-MS-Office365-Filtering-Correlation-Id: d71907f6-c44e-4734-abaf-08dee96d91e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700016|82310400026|23010399003|1800799024|56012099006|18002099003|22082099003|10067099003|921020; X-Microsoft-Antispam-Message-Info: 5mghoabT5Gm1Ukfqgs6IVXp2JwQk5WcdIsyIGjTeQALtOmns4moGqOya+NNQSS+pTE7TI3dQ7WPHiuKNl5xEQUvMpZnF4ilVpVZQDibkrM1oUMQn09F7ZQI6TWSG1c+u5h+0ql5jDpjLzaJbKaR1d32b9/0iy+OMmfnoah6bCG6lJP2F0YGcnK+59ITKa1l1nZd5/m/MYLNxF7NZM+4yRTXFIe5y4Y0pe3SvSwnNtkGGRNPmirrj6GDHN/HRzN5q6Pk9v150ciankIBF4KUpqsVExwGDotuum7zkD1JKRrNXhdkSMrI5yWn1VQBDS6MPEAiXQWsoom8zSktOYo0lJYoctSyZOB1Yu6pm2bUKEztomaQhpXssj+JT60+jEQ7iuJ3LxRTrIC2IrSviOn5UP/V1fq/NO6ceQjfIaLC/A+toE1ih01RE68G4v8XlotJd9TaJOiWM9M5HR7b+Jn2WmY9xsxQaCJLM26C8fGee++hlkFKa24ZjZet+N56p4gLTiEcQVZeVDENB3rKUPaEkh6+4yUxWYaH53tnuBwq8Eef512tsuABV4XnNQShlujaPdJBbLPy8hrnT4xXij/u8QjTeE7jG3M5WUPJvyfE301hPJcfbB43hiuY8UelTZhllDJ7AjGP2W/KtaWzRaO/6sdi9HKMrmVVn/EmUvKkBPEFfBtr2Sb0oMX/CzMSPDoPTeiOoCEWUAy0FQYvdOnBRfPE7rDejP3rBDKxJ8PVTb76rwKVcxxI5p0k4eHylBdHt X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700016)(82310400026)(23010399003)(1800799024)(56012099006)(18002099003)(22082099003)(10067099003)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nAvJlMa9UrOSDTIB4zNyS9u8EoZ8MnHtZhdh2VDydddoNbye/A9iigUVfsV9codsH9LZXPiDqkr6Zxr8ISJCuR1BOHsV8aek7061+6Or77uKUbZgXTFLSvpeTtEEBZf37s/6K79dSzyr5hyuJsELSzAXd5kA4rCyfAd59OsDEIbviufrMG/JuWDP4FCZC91Vz8tOPZzfbINaZVw4e2aVVZOobvffFf/mzyfYRHCp8dx6ASTejGfslumHHTsLT0970SZRGYh9tHIM9dVbQfslsguzcBo3G6QJOX4nbkZZiYau2iPoITtUAmF5/YccczTQGmhLnMcBPZrGX2U6xe60D7ZrPkYg3VTxzH/yR+9Fje32BML8jzwco4cfBKCWJjacmnDVAuzbFDIIKX3rXu56IhaNZoSFU4tS5Dt+Uv/L2Sw+Yc4YTLsI+LQxNdoxL51Q X-Exchange-RoutingPolicyChecked: H5mhCexc1KiiN8ZXTPT/kKxUhcCBdZvWVMZlOMxO4bqq3rI/xRPDQpv7ULDj8iDWDBxhUCcWMiVxS7BEc30z8tQViR/YGWHUiGsTbVQm3CwiXzLivXeErw2yePBQdKgQ4Y8Ls5Cqt/620gWPD0fZXqLlKMMpcoZBJmorU2qHqp4ZDF/aAboCezZ+977hhVXO/lzcmrg7JZkwt1bjosEfNbIH8AVLjDoUvi5gXRIaFbyAFquQAMjwsUMp/ylpwnRPoCDoz+zzcXhcGwKfKSsOCmIN/8vP2IC0mWIraL2oXVoEA9lwYx60hgFKvwIS7CXD4Yy1S3GTPK0R4s6TXP7A6g== X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2026 10:23:14.0239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d71907f6-c44e-4734-abaf-08dee96d91e3 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000C618E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7341 X-Proofpoint-GUID: oDpF9f67rtiIcZOCI1sCxOK4W92YUkyT X-Proofpoint-ORIG-GUID: oDpF9f67rtiIcZOCI1sCxOK4W92YUkyT X-Authority-Analysis: v=2.4 cv=dLWWXuZb c=1 sm=1 tr=0 ts=6a633d17 cx=c_pps a=9z8yexD6E2gW5LInT/Y/IQ==:117 a=iwqwCZQqcuTv3JOpYdM7/Q==:17 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=RAioF0-LDSMA:10 a=V5UXEbMT0ywA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Z8NIEmU8O1QQgoT56wFK:22 a=taLDd7a_hP9WKsMzeGRc:22 a=sozttTNsAAAA:8 a=awo6gdX1Wv1SqJAOH5YA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfXxURmZCO7pMEd 5/IOMkHOkuqsVShfFNvVjqB0aM12GOhO/ANwVQCYgZKcdIzMH4lj+z3glBuAl5b7X7epMk0gCu3 +eX+YCWH8MQRi1UcdrTZaTiRjVvI/mxZr9F+TRfbfOL59bmdw/cKVyBH/0FqtS2iOyD4fGQ/+/T e9QrGW1Kbjush1QTcEUu94QaW/iPhUbMKaBMmM90yHt/jI30zfqAMXc3+RPDHQX5V5K6Vce/PvH 4EZs4uzGaXNJvwyQwQ/Nu1xCNJFg00dIPS7kHCp226KhnW/Po2v6nHFcyorXYmwl2TOiO/ytTlC P/cwEuqxr+xziobfGoDIW0gTp6MQlGHNOJDDp2cct7ro5wuF9QLb8vVDTnTCMXN5UjO5SCCXfxn E6YGr/QN92QC980xNzdIUGQAanKIL21KkQRz/Uvoym6yS9WJNdPw2QjsWdcWs/iTIhPVKL/SALv h5X1zz/RP7SanZfYZ5w== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI0MDA5NCBTYWx0ZWRfX30CC5xElnDwS 4VQBv648y3T6ev/+fxpR9khiyqULf14CpdsL4JchudUhAk6O5y44tE6DQtwz4RGmsGNgM9/ds1a nxBcn1AUhzM6ifPbMVf9BEDwNrpSudk= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-24_02,2026-07-22_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607240094 Content-Type: text/plain; charset="utf-8" The `__udma_reserve_##res` macro currently lacks a bounds check for the provided `id`. If a caller passes an ID exceeding the resource count (`ud->res##_cnt`), `test_bit()` performs an out-of-bounds memory access on the bitmap. Additionally, the macro returns `-ENOENT` when a resource is already in use, which is semantically incorrect. The logging logic is also broken, printing the literal "res##" instead of the resource name. Update the macro to: 1. Validate `id` against `ud->res##_cnt` and return `-EINVAL` if out of bounds. 2. Return `-EBUSY` instead of `-ENOENT` when a resource is already reserved, correctly reflecting the resource state. 3. Use the stringification operator `#res` to correctly print the resource name (e.g., "tchan") in error messages. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma-common.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dma/ti/k3-udma-common.c b/drivers/dma/ti/k3-udma-commo= n.c index d7c148ad694f9..dec4c2ed24e04 100644 --- a/drivers/dma/ti/k3-udma-common.c +++ b/drivers/dma/ti/k3-udma-common.c @@ -2011,9 +2011,14 @@ struct udma_##res *__udma_reserve_##res(struct udma_= dev *ud, \ int id) \ { \ if (id >=3D 0) { \ + if (id >=3D ud->res##_cnt) { \ + dev_err(ud->dev, \ + #res " id %d is out of bounds.\n", id); \ + return ERR_PTR(-EINVAL); \ + } \ if (test_bit(id, ud->res##_map)) { \ - dev_err(ud->dev, "res##%d is in use\n", id); \ - return ERR_PTR(-ENOENT); \ + dev_err(ud->dev, #res "%d is in use\n", id); \ + return ERR_PTR(-EBUSY); \ } \ } else { \ int start; \ --=20 2.54.0