From nobody Sun Dec 28 04:59:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FC66C4332F for ; Tue, 12 Dec 2023 11:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346157AbjLLLMF (ORCPT ); Tue, 12 Dec 2023 06:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235037AbjLLLLl (ORCPT ); Tue, 12 Dec 2023 06:11:41 -0500 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FF31D68; Tue, 12 Dec 2023 03:11:07 -0800 (PST) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBAH9o107535; Tue, 12 Dec 2023 05:10:17 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702379417; bh=NDYSOhMhZmqY81VdzmRhbg1HQImEb7c2DNjpVOKaW7U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xEBCUIAaHEDcx2zOloWWCtjo/hb/oGgSdnAQb3/R4F2+6R+aON2EA5uLojXK85hS9 pZAWrsZNMRzPz40CnCpPt/s9INecwPfmduOBV3RQwQD2koEluS2VqamfLpT2BPXGaW YVIamLaqtbYKZVA8PKxGc8lX34jW+UpOV/Uu0/Yc= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BCBAHVL014629 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 12 Dec 2023 05:10:17 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 12 Dec 2023 05:10:17 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 12 Dec 2023 05:10:16 -0600 Received: from uda0492258.dhcp.ti.com (uda0492258.dhcp.ti.com [172.24.227.9]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBAB9w088764; Tue, 12 Dec 2023 05:10:14 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v2 1/4] dmaengine: ti: k3-udma-glue: Add function to parse channel by ID Date: Tue, 12 Dec 2023 16:40:08 +0530 Message-ID: <20231212111011.1401641-2-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212111011.1401641-1-s-vadapalli@ti.com> References: <20231212111011.1401641-1-s-vadapalli@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The existing helper function of_k3_udma_glue_parse() fetches the DMA Channel thread ID from the device-tree node. This makes it necessary to have a device-tree node with the Channel thread IDs populated. However, in the case where the thread ID is known by alternate methods (an example being that of Firmware running on remote core sharing details of the thread IDs), there is no equivalent function to implement the functionality of the existing of_k3_udma_glue_parse() function. In such cases, the driver utilizing the DMA APIs might not even have a device-tree node to begin with, since it could be probed with other methods (RPMsg-Bus for example). Add the of_k3_udma_glue_parse_chn_by_id() helper function which accepts the thread ID as an argument, thereby making it unnecessary to have a device-tree node for obtaining the thread ID. Since of_k3_udma_glue_parse() and of_k3_udma_glue_parse_chn_by_id() share a lot of code in common, create a new function to handle the common code which is named as of_k3_udma_glue_parse_chn_common(). Signed-off-by: Siddharth Vadapalli --- Changes since v1: - Updated commit message indicating that this patch is helpful for cases where the driver utilizing the DMA APIs might not be probed by a device-tree node. - Removed unnecessary return value check within "of_k3_udma_glue_parse_chn()" function since it will fall through to "out_put_spec" anyway. - Removed unnecessary return value check within "of_k3_udma_glue_parse_chn_by_id()" function since it will fall through to "out_put_spec" anyway. drivers/dma/ti/k3-udma-glue.c | 79 ++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index c278d5facf7d..d8781625034b 100644 --- a/drivers/dma/ti/k3-udma-glue.c +++ b/drivers/dma/ti/k3-udma-glue.c @@ -111,6 +111,35 @@ static int of_k3_udma_glue_parse(struct device_node *u= dmax_np, return 0; } =20 +static int of_k3_udma_glue_parse_chn_common(struct k3_udma_glue_common *co= mmon, u32 thread_id, + bool tx_chn) +{ + if (tx_chn && !(thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) + return -EINVAL; + + if (!tx_chn && (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) + return -EINVAL; + + /* get psil endpoint config */ + common->ep_config =3D psil_get_ep_config(thread_id); + if (IS_ERR(common->ep_config)) { + dev_err(common->dev, + "No configuration for psi-l thread 0x%04x\n", + thread_id); + return PTR_ERR(common->ep_config); + } + + common->epib =3D common->ep_config->needs_epib; + common->psdata_size =3D common->ep_config->psd_size; + + if (tx_chn) + common->dst_thread =3D thread_id; + else + common->src_thread =3D thread_id; + + return 0; +} + static int of_k3_udma_glue_parse_chn(struct device_node *chn_np, const char *name, struct k3_udma_glue_common *common, bool tx_chn) @@ -153,38 +182,32 @@ static int of_k3_udma_glue_parse_chn(struct device_no= de *chn_np, common->atype_asel =3D dma_spec.args[1]; } =20 - if (tx_chn && !(thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) { - ret =3D -EINVAL; - goto out_put_spec; - } - - if (!tx_chn && (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) { - ret =3D -EINVAL; - goto out_put_spec; - } - - /* get psil endpoint config */ - common->ep_config =3D psil_get_ep_config(thread_id); - if (IS_ERR(common->ep_config)) { - dev_err(common->dev, - "No configuration for psi-l thread 0x%04x\n", - thread_id); - ret =3D PTR_ERR(common->ep_config); - goto out_put_spec; - } - - common->epib =3D common->ep_config->needs_epib; - common->psdata_size =3D common->ep_config->psd_size; - - if (tx_chn) - common->dst_thread =3D thread_id; - else - common->src_thread =3D thread_id; + ret =3D of_k3_udma_glue_parse_chn_common(common, thread_id, tx_chn); =20 out_put_spec: of_node_put(dma_spec.np); return ret; -}; +} + +static int +of_k3_udma_glue_parse_chn_by_id(struct device_node *udmax_np, struct k3_ud= ma_glue_common *common, + bool tx_chn, u32 thread_id) +{ + int ret =3D 0; + + if (unlikely(!udmax_np)) + return -EINVAL; + + ret =3D of_k3_udma_glue_parse(udmax_np, common); + if (ret) + goto out_put_spec; + + ret =3D of_k3_udma_glue_parse_chn_common(common, thread_id, tx_chn); + +out_put_spec: + of_node_put(udmax_np); + return ret; +} =20 static void k3_udma_glue_dump_tx_chn(struct k3_udma_glue_tx_channel *tx_ch= n) { --=20 2.34.1 From nobody Sun Dec 28 04:59:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05009C4332F for ; Tue, 12 Dec 2023 11:12:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235156AbjLLLMB (ORCPT ); Tue, 12 Dec 2023 06:12:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbjLLLLk (ORCPT ); Tue, 12 Dec 2023 06:11:40 -0500 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69BC0D5B; Tue, 12 Dec 2023 03:11:06 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBAJ9U052432; Tue, 12 Dec 2023 05:10:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702379419; bh=rJFXrrgFOd1lUZkhXA6Tx5Vqg9CUHLXSKpgDsjyKI+I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=AQWNiUrejD8z82OePDbeJG/Htv3WIYLSvoUiidk8Hj46obJ5wqP5PM21s6kUuMld9 U4Y6AHz+lmq35qwhS1vn/xtZSwG0GJDZAn8LCRgLwh792rm6m2hfKCAxhOZ8IkvGRD uSfBtnetaQ7JO8akYtj/OkDuxmcHlfVqptzf0O4A= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BCBAJqn021165 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 12 Dec 2023 05:10:19 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 12 Dec 2023 05:10:19 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 12 Dec 2023 05:10:19 -0600 Received: from uda0492258.dhcp.ti.com (uda0492258.dhcp.ti.com [172.24.227.9]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBAB9x088764; Tue, 12 Dec 2023 05:10:17 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v2 2/4] dmaengine: ti: k3-udma-glue: Update name for remote RX channel device Date: Tue, 12 Dec 2023 16:40:09 +0530 Message-ID: <20231212111011.1401641-3-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212111011.1401641-1-s-vadapalli@ti.com> References: <20231212111011.1401641-1-s-vadapalli@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" A single RX Channel can have multiple flows. It is possible that a single device requests multiple flows on the same RX Channel. In such cases, the existing implementation of naming the device on the basis of the RX Channel can result in duplicate names. The existing implementation only uses the RX Channel source thread when naming, which implies duplicate names when different flows are being requested on the same RX Channel. In order to avoid duplicate names, include the RX flow as well in the name. Signed-off-by: Siddharth Vadapalli --- drivers/dma/ti/k3-udma-glue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index d8781625034b..eff1ae3d3efe 100644 --- a/drivers/dma/ti/k3-udma-glue.c +++ b/drivers/dma/ti/k3-udma-glue.c @@ -1072,8 +1072,8 @@ k3_udma_glue_request_remote_rx_chn(struct device *dev= , const char *name, =20 rx_chn->common.chan_dev.class =3D &k3_udma_glue_devclass; rx_chn->common.chan_dev.parent =3D xudma_get_device(rx_chn->common.udmax); - dev_set_name(&rx_chn->common.chan_dev, "rchan_remote-0x%04x", - rx_chn->common.src_thread); + dev_set_name(&rx_chn->common.chan_dev, "rchan_remote-0x%04x-0x%02x", + rx_chn->common.src_thread, rx_chn->flow_id_base); ret =3D device_register(&rx_chn->common.chan_dev); if (ret) { dev_err(dev, "Channel Device registration failed %d\n", ret); --=20 2.34.1 From nobody Sun Dec 28 04:59:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AB86C4332F for ; Tue, 12 Dec 2023 11:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232500AbjLLLLo (ORCPT ); Tue, 12 Dec 2023 06:11:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346185AbjLLLLY (ORCPT ); Tue, 12 Dec 2023 06:11:24 -0500 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B2DB26BA; Tue, 12 Dec 2023 03:10:41 -0800 (PST) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBAMko052438; Tue, 12 Dec 2023 05:10:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702379422; bh=7+jdojrvI/WT4WBoua2xkCIhykh2otOmQh/gKolYxxQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RsFiL61FcvnYtZw0dLfiJfPHyvJd0iaK1ZxaGaXcwR3B0PBBPx1cWBjC3FCvYdH/b +Qr/8KljboBpOhT5jZtnsM9MW3J17NL4kGkkK8OqtVYru96tCRkuE295s5z0gxLbDb TSvcNkjc3NCEj0iuDCG2H5wyqWvw9ssAIzJoFRjc= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BCBAM6P014659 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 12 Dec 2023 05:10:22 -0600 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 12 Dec 2023 05:10:22 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 12 Dec 2023 05:10:22 -0600 Received: from uda0492258.dhcp.ti.com (uda0492258.dhcp.ti.com [172.24.227.9]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBABA0088764; Tue, 12 Dec 2023 05:10:19 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v2 3/4] dmaengine: ti: k3-udma-glue: Add function to request TX channel by ID Date: Tue, 12 Dec 2023 16:40:10 +0530 Message-ID: <20231212111011.1401641-4-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212111011.1401641-1-s-vadapalli@ti.com> References: <20231212111011.1401641-1-s-vadapalli@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The existing function k3_udma_glue_request_tx_chn() supports requesting a TX DMA channel by its name. Add support to request TX channel by ID in the form of a new function k3_udma_glue_request_tx_chn_by_id() and export it for use by drivers which are probed by alternate methods (non device-tree) but still wish to make use of the existing DMA APIs. Such drivers could be informed about the TX channel to use by RPMsg for example. Since the implementation of k3_udma_glue_request_tx_chn_by_id() reuses most of the code in k3_udma_glue_request_tx_chn(), create a new function for the common code named as k3_udma_glue_request_tx_chn_common(). Signed-off-by: Siddharth Vadapalli --- Changes since v1: - Updated commit message indicating the use-case for which the patch is being added. drivers/dma/ti/k3-udma-glue.c | 101 +++++++++++++++++++++++-------- include/linux/dma/k3-udma-glue.h | 4 ++ 2 files changed, 79 insertions(+), 26 deletions(-) diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index eff1ae3d3efe..ea5119a5e8eb 100644 --- a/drivers/dma/ti/k3-udma-glue.c +++ b/drivers/dma/ti/k3-udma-glue.c @@ -274,29 +274,13 @@ static int k3_udma_glue_cfg_tx_chn(struct k3_udma_glu= e_tx_channel *tx_chn) return tisci_rm->tisci_udmap_ops->tx_ch_cfg(tisci_rm->tisci, &req); } =20 -struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx_chn(struct device = *dev, - const char *name, struct k3_udma_glue_tx_channel_cfg *cfg) +static int +k3_udma_glue_request_tx_chn_common(struct device *dev, + struct k3_udma_glue_tx_channel *tx_chn, + struct k3_udma_glue_tx_channel_cfg *cfg) { - struct k3_udma_glue_tx_channel *tx_chn; int ret; =20 - tx_chn =3D devm_kzalloc(dev, sizeof(*tx_chn), GFP_KERNEL); - if (!tx_chn) - return ERR_PTR(-ENOMEM); - - tx_chn->common.dev =3D dev; - tx_chn->common.swdata_size =3D cfg->swdata_size; - tx_chn->tx_pause_on_err =3D cfg->tx_pause_on_err; - tx_chn->tx_filt_einfo =3D cfg->tx_filt_einfo; - tx_chn->tx_filt_pswords =3D cfg->tx_filt_pswords; - tx_chn->tx_supr_tdpkt =3D cfg->tx_supr_tdpkt; - - /* parse of udmap channel */ - ret =3D of_k3_udma_glue_parse_chn(dev->of_node, name, - &tx_chn->common, true); - if (ret) - goto err; - tx_chn->common.hdesc_size =3D cppi5_hdesc_calc_size(tx_chn->common.epib, tx_chn->common.psdata_size, tx_chn->common.swdata_size); @@ -312,7 +296,7 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx= _chn(struct device *dev, if (IS_ERR(tx_chn->udma_tchanx)) { ret =3D PTR_ERR(tx_chn->udma_tchanx); dev_err(dev, "UDMAX tchanx get err %d\n", ret); - goto err; + return ret; } tx_chn->udma_tchan_id =3D xudma_tchan_get_id(tx_chn->udma_tchanx); =20 @@ -325,7 +309,7 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx= _chn(struct device *dev, dev_err(dev, "Channel Device registration failed %d\n", ret); put_device(&tx_chn->common.chan_dev); tx_chn->common.chan_dev.parent =3D NULL; - goto err; + return ret; } =20 if (xudma_is_pktdma(tx_chn->common.udmax)) { @@ -349,7 +333,7 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx= _chn(struct device *dev, &tx_chn->ringtxcq); if (ret) { dev_err(dev, "Failed to get TX/TXCQ rings %d\n", ret); - goto err; + return ret; } =20 /* Set the dma_dev for the rings to be configured */ @@ -365,13 +349,13 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_= tx_chn(struct device *dev, ret =3D k3_ringacc_ring_cfg(tx_chn->ringtx, &cfg->tx_cfg); if (ret) { dev_err(dev, "Failed to cfg ringtx %d\n", ret); - goto err; + return ret; } =20 ret =3D k3_ringacc_ring_cfg(tx_chn->ringtxcq, &cfg->txcq_cfg); if (ret) { dev_err(dev, "Failed to cfg ringtx %d\n", ret); - goto err; + return ret; } =20 /* request and cfg psi-l */ @@ -382,11 +366,42 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_= tx_chn(struct device *dev, ret =3D k3_udma_glue_cfg_tx_chn(tx_chn); if (ret) { dev_err(dev, "Failed to cfg tchan %d\n", ret); - goto err; + return ret; } =20 k3_udma_glue_dump_tx_chn(tx_chn); =20 + return 0; +} + +struct k3_udma_glue_tx_channel * +k3_udma_glue_request_tx_chn(struct device *dev, const char *name, + struct k3_udma_glue_tx_channel_cfg *cfg) +{ + struct k3_udma_glue_tx_channel *tx_chn; + int ret; + + tx_chn =3D devm_kzalloc(dev, sizeof(*tx_chn), GFP_KERNEL); + if (!tx_chn) + return ERR_PTR(-ENOMEM); + + tx_chn->common.dev =3D dev; + tx_chn->common.swdata_size =3D cfg->swdata_size; + tx_chn->tx_pause_on_err =3D cfg->tx_pause_on_err; + tx_chn->tx_filt_einfo =3D cfg->tx_filt_einfo; + tx_chn->tx_filt_pswords =3D cfg->tx_filt_pswords; + tx_chn->tx_supr_tdpkt =3D cfg->tx_supr_tdpkt; + + /* parse of udmap channel */ + ret =3D of_k3_udma_glue_parse_chn(dev->of_node, name, + &tx_chn->common, true); + if (ret) + goto err; + + ret =3D k3_udma_glue_request_tx_chn_common(dev, tx_chn, cfg); + if (ret) + goto err; + return tx_chn; =20 err: @@ -395,6 +410,40 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_t= x_chn(struct device *dev, } EXPORT_SYMBOL_GPL(k3_udma_glue_request_tx_chn); =20 +struct k3_udma_glue_tx_channel * +k3_udma_glue_request_tx_chn_by_id(struct device *dev, struct k3_udma_glue_= tx_channel_cfg *cfg, + struct device_node *udmax_np, u32 thread_id) +{ + struct k3_udma_glue_tx_channel *tx_chn; + int ret; + + tx_chn =3D devm_kzalloc(dev, sizeof(*tx_chn), GFP_KERNEL); + if (!tx_chn) + return ERR_PTR(-ENOMEM); + + tx_chn->common.dev =3D dev; + tx_chn->common.swdata_size =3D cfg->swdata_size; + tx_chn->tx_pause_on_err =3D cfg->tx_pause_on_err; + tx_chn->tx_filt_einfo =3D cfg->tx_filt_einfo; + tx_chn->tx_filt_pswords =3D cfg->tx_filt_pswords; + tx_chn->tx_supr_tdpkt =3D cfg->tx_supr_tdpkt; + + ret =3D of_k3_udma_glue_parse_chn_by_id(udmax_np, &tx_chn->common, true, = thread_id); + if (ret) + goto err; + + ret =3D k3_udma_glue_request_tx_chn_common(dev, tx_chn, cfg); + if (ret) + goto err; + + return tx_chn; + +err: + k3_udma_glue_release_tx_chn(tx_chn); + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(k3_udma_glue_request_tx_chn_by_id); + void k3_udma_glue_release_tx_chn(struct k3_udma_glue_tx_channel *tx_chn) { if (tx_chn->psil_paired) { diff --git a/include/linux/dma/k3-udma-glue.h b/include/linux/dma/k3-udma-g= lue.h index e443be4d3b4b..6205d84430ca 100644 --- a/include/linux/dma/k3-udma-glue.h +++ b/include/linux/dma/k3-udma-glue.h @@ -26,6 +26,10 @@ struct k3_udma_glue_tx_channel; struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx_chn(struct device = *dev, const char *name, struct k3_udma_glue_tx_channel_cfg *cfg); =20 +struct k3_udma_glue_tx_channel * +k3_udma_glue_request_tx_chn_by_id(struct device *dev, struct k3_udma_glue_= tx_channel_cfg *cfg, + struct device_node *udmax_np, u32 thread_id); + void k3_udma_glue_release_tx_chn(struct k3_udma_glue_tx_channel *tx_chn); int k3_udma_glue_push_tx_chn(struct k3_udma_glue_tx_channel *tx_chn, struct cppi5_host_desc_t *desc_tx, --=20 2.34.1 From nobody Sun Dec 28 04:59:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 501EAC4332F for ; Tue, 12 Dec 2023 11:12:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232344AbjLLLMS (ORCPT ); Tue, 12 Dec 2023 06:12:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235134AbjLLLLz (ORCPT ); Tue, 12 Dec 2023 06:11:55 -0500 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E861136; Tue, 12 Dec 2023 03:10:44 -0800 (PST) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBAO3k031728; Tue, 12 Dec 2023 05:10:24 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702379424; bh=PvkANg04A2utzuZAggw+6HPpsozwSzDkEwa7BpI7mhM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ym91uVEHlmGoLgfFRoymYYV8JwoBCkTjoSt/EI8c1RgQbl45K32fRnzC4Wt0RbzDY KKI0drNj4qBwG608Ifbcbsyu4NAiO7htNe7dbc4hncl7ZtRXu9GC36TivlHOAPNVG2 LAN2iXgLKFvn82rgj0y024NW87VUluaSf8xc9f54= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BCBAOHW043985 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 12 Dec 2023 05:10:24 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 12 Dec 2023 05:10:24 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 12 Dec 2023 05:10:24 -0600 Received: from uda0492258.dhcp.ti.com (uda0492258.dhcp.ti.com [172.24.227.9]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3BCBABA1088764; Tue, 12 Dec 2023 05:10:22 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v2 4/4] dmaengine: ti: k3-udma-glue: Add function to request RX channel by ID Date: Tue, 12 Dec 2023 16:40:11 +0530 Message-ID: <20231212111011.1401641-5-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212111011.1401641-1-s-vadapalli@ti.com> References: <20231212111011.1401641-1-s-vadapalli@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The existing function k3_udma_glue_request_remote_rx_chn() supports requesting an RX DMA channel and flow by the name of the RX DMA channel. Add support to request RX channel by ID in the form of a new function k3_udma_glue_request_remote_rx_chn_by_id() and export it for use by drivers which are probed by alternate methods (non device-tree) but still wish to make use of the existing DMA APIs. Such drivers could be informed about the RX channel to use by RPMsg for example. Since the implementation of k3_udma_glue_request_remote_rx_chn_by_id() reuses most of the code in k3_udma_glue_request_remote_rx_chn(), create a new function k3_udma_glue_request_remote_rx_chn_common() for the common code. Signed-off-by: Siddharth Vadapalli --- Changes since v1: - Updated commit message indicating the use-case for which the patch is being added. drivers/dma/ti/k3-udma-glue.c | 136 ++++++++++++++++++++++--------- include/linux/dma/k3-udma-glue.h | 4 + 2 files changed, 101 insertions(+), 39 deletions(-) diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index ea5119a5e8eb..996614b60675 100644 --- a/drivers/dma/ti/k3-udma-glue.c +++ b/drivers/dma/ti/k3-udma-glue.c @@ -1072,52 +1072,21 @@ k3_udma_glue_request_rx_chn_priv(struct device *dev= , const char *name, return ERR_PTR(ret); } =20 -static struct k3_udma_glue_rx_channel * -k3_udma_glue_request_remote_rx_chn(struct device *dev, const char *name, - struct k3_udma_glue_rx_channel_cfg *cfg) +static int +k3_udma_glue_request_remote_rx_chn_common(struct k3_udma_glue_rx_channel *= rx_chn, + struct k3_udma_glue_rx_channel_cfg *cfg, + struct device *dev) { - struct k3_udma_glue_rx_channel *rx_chn; int ret, i; =20 - if (cfg->flow_id_num <=3D 0 || - cfg->flow_id_use_rxchan_id || - cfg->def_flow_cfg || - cfg->flow_id_base < 0) - return ERR_PTR(-EINVAL); - - /* - * Remote RX channel is under control of Remote CPU core, so - * Linux can only request and manipulate by dedicated RX flows - */ - - rx_chn =3D devm_kzalloc(dev, sizeof(*rx_chn), GFP_KERNEL); - if (!rx_chn) - return ERR_PTR(-ENOMEM); - - rx_chn->common.dev =3D dev; - rx_chn->common.swdata_size =3D cfg->swdata_size; - rx_chn->remote =3D true; - rx_chn->udma_rchan_id =3D -1; - rx_chn->flow_num =3D cfg->flow_id_num; - rx_chn->flow_id_base =3D cfg->flow_id_base; - rx_chn->psil_paired =3D false; - - /* parse of udmap channel */ - ret =3D of_k3_udma_glue_parse_chn(dev->of_node, name, - &rx_chn->common, false); - if (ret) - goto err; - rx_chn->common.hdesc_size =3D cppi5_hdesc_calc_size(rx_chn->common.epib, rx_chn->common.psdata_size, rx_chn->common.swdata_size); =20 rx_chn->flows =3D devm_kcalloc(dev, rx_chn->flow_num, sizeof(*rx_chn->flows), GFP_KERNEL); - if (!rx_chn->flows) { - ret =3D -ENOMEM; - goto err; - } + if (!rx_chn->flows) + return -ENOMEM; =20 rx_chn->common.chan_dev.class =3D &k3_udma_glue_devclass; rx_chn->common.chan_dev.parent =3D xudma_get_device(rx_chn->common.udmax); @@ -1128,7 +1097,7 @@ k3_udma_glue_request_remote_rx_chn(struct device *dev= , const char *name, dev_err(dev, "Channel Device registration failed %d\n", ret); put_device(&rx_chn->common.chan_dev); rx_chn->common.chan_dev.parent =3D NULL; - goto err; + return ret; } =20 if (xudma_is_pktdma(rx_chn->common.udmax)) { @@ -1140,19 +1109,108 @@ k3_udma_glue_request_remote_rx_chn(struct device *= dev, const char *name, =20 ret =3D k3_udma_glue_allocate_rx_flows(rx_chn, cfg); if (ret) - goto err; + return ret; =20 for (i =3D 0; i < rx_chn->flow_num; i++) rx_chn->flows[i].udma_rflow_id =3D rx_chn->flow_id_base + i; =20 k3_udma_glue_dump_rx_chn(rx_chn); =20 + return 0; +} + +static struct k3_udma_glue_rx_channel * +k3_udma_glue_request_remote_rx_chn(struct device *dev, const char *name, + struct k3_udma_glue_rx_channel_cfg *cfg) +{ + struct k3_udma_glue_rx_channel *rx_chn; + int ret; + + if (cfg->flow_id_num <=3D 0 || + cfg->flow_id_use_rxchan_id || + cfg->def_flow_cfg || + cfg->flow_id_base < 0) + return ERR_PTR(-EINVAL); + + /* + * Remote RX channel is under control of Remote CPU core, so + * Linux can only request and manipulate by dedicated RX flows + */ + + rx_chn =3D devm_kzalloc(dev, sizeof(*rx_chn), GFP_KERNEL); + if (!rx_chn) + return ERR_PTR(-ENOMEM); + + rx_chn->common.dev =3D dev; + rx_chn->common.swdata_size =3D cfg->swdata_size; + rx_chn->remote =3D true; + rx_chn->udma_rchan_id =3D -1; + rx_chn->flow_num =3D cfg->flow_id_num; + rx_chn->flow_id_base =3D cfg->flow_id_base; + rx_chn->psil_paired =3D false; + + /* parse of udmap channel */ + ret =3D of_k3_udma_glue_parse_chn(dev->of_node, name, + &rx_chn->common, false); + if (ret) + goto err; + + ret =3D k3_udma_glue_request_remote_rx_chn_common(rx_chn, cfg, dev); + if (ret) + goto err; + + return rx_chn; + +err: + k3_udma_glue_release_rx_chn(rx_chn); + return ERR_PTR(ret); +} + +struct k3_udma_glue_rx_channel * +k3_udma_glue_request_remote_rx_chn_by_id(struct device *dev, struct device= _node *udmax_np, + struct k3_udma_glue_rx_channel_cfg *cfg, u32 thread_id) +{ + struct k3_udma_glue_rx_channel *rx_chn; + int ret; + + if (cfg->flow_id_num <=3D 0 || + cfg->flow_id_use_rxchan_id || + cfg->def_flow_cfg || + cfg->flow_id_base < 0) + return ERR_PTR(-EINVAL); + + /* + * Remote RX channel is under control of Remote CPU core, so + * Linux can only request and manipulate by dedicated RX flows + */ + + rx_chn =3D devm_kzalloc(dev, sizeof(*rx_chn), GFP_KERNEL); + if (!rx_chn) + return ERR_PTR(-ENOMEM); + + rx_chn->common.dev =3D dev; + rx_chn->common.swdata_size =3D cfg->swdata_size; + rx_chn->remote =3D true; + rx_chn->udma_rchan_id =3D -1; + rx_chn->flow_num =3D cfg->flow_id_num; + rx_chn->flow_id_base =3D cfg->flow_id_base; + rx_chn->psil_paired =3D false; + + ret =3D of_k3_udma_glue_parse_chn_by_id(udmax_np, &rx_chn->common, false,= thread_id); + if (ret) + goto err; + + ret =3D k3_udma_glue_request_remote_rx_chn_common(rx_chn, cfg, dev); + if (ret) + goto err; + return rx_chn; =20 err: k3_udma_glue_release_rx_chn(rx_chn); return ERR_PTR(ret); } +EXPORT_SYMBOL_GPL(k3_udma_glue_request_remote_rx_chn_by_id); =20 struct k3_udma_glue_rx_channel * k3_udma_glue_request_rx_chn(struct device *dev, const char *name, diff --git a/include/linux/dma/k3-udma-glue.h b/include/linux/dma/k3-udma-g= lue.h index 6205d84430ca..89dc59d7c5e2 100644 --- a/include/linux/dma/k3-udma-glue.h +++ b/include/linux/dma/k3-udma-glue.h @@ -113,6 +113,10 @@ struct k3_udma_glue_rx_channel *k3_udma_glue_request_r= x_chn( const char *name, struct k3_udma_glue_rx_channel_cfg *cfg); =20 +struct k3_udma_glue_rx_channel * +k3_udma_glue_request_remote_rx_chn_by_id(struct device *dev, struct device= _node *udmax_np, + struct k3_udma_glue_rx_channel_cfg *cfg, u32 thread_id); + void k3_udma_glue_release_rx_chn(struct k3_udma_glue_rx_channel *rx_chn); int k3_udma_glue_enable_rx_chn(struct k3_udma_glue_rx_channel *rx_chn); void k3_udma_glue_disable_rx_chn(struct k3_udma_glue_rx_channel *rx_chn); --=20 2.34.1