From patchwork Mon Dec 18 06:26:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Vadapalli X-Patchwork-Id: 180149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1060025dyi; Sun, 17 Dec 2023 22:27:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsAlgjs4Hk8ShVwDmkvhPsdDwwgXWHu5c3hqzYubj+MyV5/J+WlR6nZXAWO23rtpCqsJC1 X-Received: by 2002:a9d:664b:0:b0:6d9:a184:d8e8 with SMTP id q11-20020a9d664b000000b006d9a184d8e8mr14750246otm.60.1702880849539; Sun, 17 Dec 2023 22:27:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702880849; cv=none; d=google.com; s=arc-20160816; b=mV5/FuKdbfRgTQUCfx6+TeXJRaTUy11Cky2iPNIp80NYUyZ9Cm2rVWhafZCxpVFp8u hTAiDljBGYQB0OCcRgcXXgPMv6c8epNiQ0+du6sEowySq86vA2OR+oWNRlewAZ38OwrI fsbPxFBAxUaHEpRV1aHzLcVBvS8stlBxxwZvUO8JcXPaBsPl4HPt5CJQMsFzicM9CWYs YcIvbLe0wPQ5lnUqHYft432OLwsB7AJfFept6Ty0IZqwnZsfT8BQ7NMEYxr9xsL3O/Cc sxIsdzv+a/HYo8GYKSsjqw/PeBAcPmR+yS5NM/wMCYCw3RwGNvNk+L99Yemx31NdzIGt fGdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=m9jjy1qyyaNCh2U8cWve6iIhYhOqjY1jfz82P/MAGFQ=; fh=kWHopdWuWktDcnjSO11R7sPQi0EWg865jqRuCsOPYXE=; b=YdZsgnE4RPzhkIPO2MnyPlDqClq6ZOP9CMqhpP+E02bI8Qi5mHp+2egSzMWN7LLKNG /DgGkMJSUKwXE8KnRKjdcts+pQ9971RgEoqaC2gYGMaGPhhMo2KX+QKy2KbUrkN4quU7 BwxqETScio+k/ImXZS/bb3fRxCueCoQJTxi2OvxsWc+L1MWC9V6RjNS8N99zL3/ybVhu wxb1CskZiWigRVqwvNzMkxhzSWeyCh+OHInav0FGRZo6fr1H9bn8p9P5YI9/u711DsLG a7eSO93tA8LbDGO66tQ/WVBnxZBHri7l951usohdToOVOGoITqIj7V1q8sQbEu9WJ4qh 4O5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Dy7r5cle; spf=pass (google.com: domain of linux-kernel+bounces-3038-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3038-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id by22-20020a056a02059600b005cda46a7c9esi737416pgb.331.2023.12.17.22.27.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 22:27:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3038-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Dy7r5cle; spf=pass (google.com: domain of linux-kernel+bounces-3038-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3038-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DA94F2825F0 for ; Mon, 18 Dec 2023 06:27:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0975779F7; Mon, 18 Dec 2023 06:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Dy7r5cle" X-Original-To: linux-kernel@vger.kernel.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 45E126FA3; Mon, 18 Dec 2023 06:26:55 +0000 (UTC) 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 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BI6QkCi121872; Mon, 18 Dec 2023 00:26:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702880806; bh=m9jjy1qyyaNCh2U8cWve6iIhYhOqjY1jfz82P/MAGFQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Dy7r5clekN5VahVzi8FtWIOeOh4r7xNlGGYVvga0dyXs0ZK48dZtVDnuDSAkQrxLu 84xnx7so1dWCurA2fZbNhuGnMV+BaitDhcIRg5Rq28qCQZBasZco2o48dBgG0COgWD mUKxUmSnXv5eB9PMRJN3AC6MNm0zfQS/5m9mSWTQ= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BI6QkkT101897 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Dec 2023 00:26:46 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 18 Dec 2023 00:26:46 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) 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 via Frontend Transport; Mon, 18 Dec 2023 00:26:46 -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 3BI6QebG063306; Mon, 18 Dec 2023 00:26:44 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v3 1/4] dmaengine: ti: k3-udma-glue: Add function to parse channel by ID Date: Mon, 18 Dec 2023 11:56:37 +0530 Message-ID: <20231218062640.2338453-2-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218062640.2338453-1-s-vadapalli@ti.com> References: <20231218062640.2338453-1-s-vadapalli@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785599989820489782 X-GMAIL-MSGID: 1785599989820489782 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 v2: - None. 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 *udmax_np, return 0; } +static int of_k3_udma_glue_parse_chn_common(struct k3_udma_glue_common *common, 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 = 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 = common->ep_config->needs_epib; + common->psdata_size = common->ep_config->psd_size; + + if (tx_chn) + common->dst_thread = thread_id; + else + common->src_thread = 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_node *chn_np, common->atype_asel = dma_spec.args[1]; } - if (tx_chn && !(thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) { - ret = -EINVAL; - goto out_put_spec; - } - - if (!tx_chn && (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) { - ret = -EINVAL; - goto out_put_spec; - } - - /* get psil endpoint config */ - common->ep_config = 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 = PTR_ERR(common->ep_config); - goto out_put_spec; - } - - common->epib = common->ep_config->needs_epib; - common->psdata_size = common->ep_config->psd_size; - - if (tx_chn) - common->dst_thread = thread_id; - else - common->src_thread = thread_id; + ret = of_k3_udma_glue_parse_chn_common(common, thread_id, tx_chn); 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_udma_glue_common *common, + bool tx_chn, u32 thread_id) +{ + int ret = 0; + + if (unlikely(!udmax_np)) + return -EINVAL; + + ret = of_k3_udma_glue_parse(udmax_np, common); + if (ret) + goto out_put_spec; + + ret = of_k3_udma_glue_parse_chn_common(common, thread_id, tx_chn); + +out_put_spec: + of_node_put(udmax_np); + return ret; +} static void k3_udma_glue_dump_tx_chn(struct k3_udma_glue_tx_channel *tx_chn) { From patchwork Mon Dec 18 06:26:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Vadapalli X-Patchwork-Id: 180153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1060287dyi; Sun, 17 Dec 2023 22:28:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiM+fpA8sqVY/iYLIEbDJCgCs3rWauwOt3rwoECKzUsBxvsv1PgxtYHz81ONwLWjPhOpEF X-Received: by 2002:a50:8757:0:b0:553:3537:ffb6 with SMTP id 23-20020a508757000000b005533537ffb6mr860551edv.75.1702880907165; Sun, 17 Dec 2023 22:28:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702880907; cv=none; d=google.com; s=arc-20160816; b=w5oTD9Sxxze6/W/xW3uBY3+TKwkKVk0lCrBfvoAagAPKXSP6NQ+8NJG1RS6g8OMpSF oqbtkXR4USV+fzvacFUlqXNaIZluwAq3jIl+wuRKDNHucjksdbbsyxVPgJC2vah569Lr u9VvGJrUMl2ivodlLM897xjJcUCs0B2Vp/GC436EaK3sYMBD7KvKkvLN+t1L4TcVImmv f6RhLnyvVPPEd2EIjjMC5YnIl8tt1CGRgK0Wzpqkc8DUzoJa5GU8UoVJsX4G2/6SmUzc 1MGs6a01yI+uWxLGOscW0QCpnXGYeH1tcrLIddpBp4OrKoc7ClIw3o+uyhDz99Id3zUw hM/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dyqviI7GwGtSeJl4sxgKTXGo8yaA63h9KE0oUhFvIVs=; fh=kWHopdWuWktDcnjSO11R7sPQi0EWg865jqRuCsOPYXE=; b=oSVniOlVOWsh03meF07Zrwk2yZ4xfqv3euurKpx6y9Wx4B7c+DiVauLRgPo2jwxy7D GHTuWVB4UeE9Wn+wO+vgYue61lNSmB0XTUvR5pzCXCD9c5P0m/J6SndbUFCfCCSp7OgV foLuOEMp/cRehTpAZt/jMd2NpH53WqEqwcazIA1P9UnrlZnluR7HFS4NSxNNo75UqP3r VsQMfwOlJjHHdpGHRMsYxQXkCqD95F4AcPSSGNekPWS7gpdRa3i6Fj7IJ9cMXDu74JAq 4lTU4FtY1T708QeINZpCOcjgBnHbzOiRsqpcgOg55LAd5/l5GePj/i0t2Aa0TKGAVWNq RwrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KzaBeBN4; spf=pass (google.com: domain of linux-kernel+bounces-3042-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3042-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eh19-20020a0564020f9300b005530123e1d6si1933052edb.75.2023.12.17.22.28.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 22:28:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3042-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KzaBeBN4; spf=pass (google.com: domain of linux-kernel+bounces-3042-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3042-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C03191F22B6D for ; Mon, 18 Dec 2023 06:28:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23296101E8; Mon, 18 Dec 2023 06:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="KzaBeBN4" X-Original-To: linux-kernel@vger.kernel.org Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 0C5B8F9C1; Mon, 18 Dec 2023 06:27:08 +0000 (UTC) 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 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BI6Qn5n041875; Mon, 18 Dec 2023 00:26:49 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702880809; bh=dyqviI7GwGtSeJl4sxgKTXGo8yaA63h9KE0oUhFvIVs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=KzaBeBN4jwW2FS3I7GL/H4soC/b8UPfbfKufhYOngpRmKngtTHJm9EUjj90mzlh8u 0neTPnbow/N59NVSnij1q5ZDMd18URUMVvLAprgsvJiR+l0EN8lSYEdlwc1jDv++Mu 8lqfP0JlUYQuwWjfc8HrYoxRHENguIt4LTscPGz4= 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 3BI6QnWA044355 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Dec 2023 00:26:49 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) 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; Mon, 18 Dec 2023 00:26:48 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE108.ent.ti.com (157.170.170.38) 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; Mon, 18 Dec 2023 00:26:49 -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 3BI6QebH063306; Mon, 18 Dec 2023 00:26:46 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v3 2/4] dmaengine: ti: k3-udma-glue: Update name for remote RX channel device Date: Mon, 18 Dec 2023 11:56:38 +0530 Message-ID: <20231218062640.2338453-3-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218062640.2338453-1-s-vadapalli@ti.com> References: <20231218062640.2338453-1-s-vadapalli@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785600049985350104 X-GMAIL-MSGID: 1785600049985350104 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 --- Changes since v2: - None. Changes since v1: - None. 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, rx_chn->common.chan_dev.class = &k3_udma_glue_devclass; rx_chn->common.chan_dev.parent = 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 = device_register(&rx_chn->common.chan_dev); if (ret) { dev_err(dev, "Channel Device registration failed %d\n", ret); From patchwork Mon Dec 18 06:26:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Vadapalli X-Patchwork-Id: 180150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1060091dyi; Sun, 17 Dec 2023 22:27:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRqy8HZMoYh9bigb0RghepnbaiEkjchjnNKwxQAc0GOk2deQZKAg5yaftffuzF4yeugMqY X-Received: by 2002:a17:902:d4d0:b0:1cf:b413:8baa with SMTP id o16-20020a170902d4d000b001cfb4138baamr22335157plg.25.1702880865855; Sun, 17 Dec 2023 22:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702880865; cv=none; d=google.com; s=arc-20160816; b=dhV3f0tQlOhpBs7SCQ5azYXSYZyC563j0jui7WbJO9arE6+M2dMAs/ejpJTRKe34su XZ/AGt++JoP4I6g/YLvS+DLb472jWlF5EqJcGYxbfWvEc1D7z8WlwaJijzP6YN3qw5Rg smT3jLH4oivTk1wsgMLqB5WEqnj1snUaUIF7pdJgMT0lw1sHhqchrNkaBVZXwzB3FFja qYqu0C4UmNtH7lvCi2paM44pyYjJGpKnEClpwteGDGjMjzNJ0kgA30UYAd8apyVmMUeg nAmoFtsMB22lSAMYDsZOJeQKu3fYhS9YSYtUH/e8Qx9r32PoReWVKtVr9NzHK1vMmc6z NJDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xX67062yd24mxHA9UldMnhvbksslocwl/qQK5mCsL90=; fh=kWHopdWuWktDcnjSO11R7sPQi0EWg865jqRuCsOPYXE=; b=tfNtBQbxAmpDr2czFqwOLz8JFdVF43Uiqd6ZjJKEbBMOzImftDKLS4iOfQJVtvyHbf JVYLt1MJK1vN1wUngwKkP11MtELnOEAnYJKpfMpZ5M+N/CZZ0j5PZJcQHGaO6yIAmG1E 2UC+EMf+YB+fbR5QdqPG2aT2TjX6hq170LRVUIRqqCvlmb+i0dfXIUIi2GeGlnhlCuyD h6OrKj2GmmcMKPZzkCz9yAPzFCOVk4WTA3k0hS8vI+byLO4tSesb31j5Ev+feW4NHxla bSmIPkNH3Cp0Z+7PgqKMgbmLib21IeVMoFBjBw/eJWdJlaFTD8NgtZld8nif2nPXtldU uC/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EQ0q1FQb; spf=pass (google.com: domain of linux-kernel+bounces-3039-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3039-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w188-20020a6362c5000000b005cd8a601b2esi2647244pgb.469.2023.12.17.22.27.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 22:27:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3039-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EQ0q1FQb; spf=pass (google.com: domain of linux-kernel+bounces-3039-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3039-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 92EC82825BC for ; Mon, 18 Dec 2023 06:27:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83462D2EB; Mon, 18 Dec 2023 06:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="EQ0q1FQb" X-Original-To: linux-kernel@vger.kernel.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 48B637464; Mon, 18 Dec 2023 06:26:58 +0000 (UTC) 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 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BI6QpG0121895; Mon, 18 Dec 2023 00:26:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702880811; bh=xX67062yd24mxHA9UldMnhvbksslocwl/qQK5mCsL90=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EQ0q1FQby2dGxL3FeLkzcQRZBAhcuoEXrBWENFEvYO5rstwMSV6eg+TziASuvnExH l5JvDMG5Vscp6bo9c+WVuoLmkapGa6dNQmuZDyBOUUmuu94QzCdml5+FECWZxj0GG7 IHLM8kK9lj41MKNDEeUum/QKj87w5WgSmpNqJ4Rw= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BI6QptJ066524 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Dec 2023 00:26:51 -0600 Received: from DFLE104.ent.ti.com (10.64.6.25) 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; Mon, 18 Dec 2023 00:26:51 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE104.ent.ti.com (10.64.6.25) 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; Mon, 18 Dec 2023 00:26:51 -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 3BI6QebI063306; Mon, 18 Dec 2023 00:26:49 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v3 3/4] dmaengine: ti: k3-udma-glue: Add function to request TX chan for thread ID Date: Mon, 18 Dec 2023 11:56:39 +0530 Message-ID: <20231218062640.2338453-4-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218062640.2338453-1-s-vadapalli@ti.com> References: <20231218062640.2338453-1-s-vadapalli@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785600006753110587 X-GMAIL-MSGID: 1785600006753110587 The existing function k3_udma_glue_request_tx_chn() supports requesting a TX DMA channel by its name. Add a new function to request TX DMA channel for a given thread ID, named k3_udma_glue_request_tx_chn_for_thread_id(). Also, 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 thread ID corresponding to the TX DMA channel by RPMsg for example. Since the new function k3_udma_glue_request_tx_chn_for_thread_id() reuses most of the code in k3_udma_glue_request_tx_chn(), create a new function for the common code, named k3_udma_glue_request_tx_chn_common(). Signed-off-by: Siddharth Vadapalli --- Changes since v2: - Renamed function "k3_udma_glue_request_tx_chn_by_id()" to "k3_udma_glue_request_tx_chn_for_thread_id()". - Updated commit message to reflect function renaming. Changes since v1: - Updated commit message indicating the use-case for which the patch is being added. drivers/dma/ti/k3-udma-glue.c | 102 +++++++++++++++++++++++-------- include/linux/dma/k3-udma-glue.h | 5 ++ 2 files changed, 81 insertions(+), 26 deletions(-) diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index eff1ae3d3efe..a475bbea35ee 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_glue_tx_channel *tx_chn) return tisci_rm->tisci_udmap_ops->tx_ch_cfg(tisci_rm->tisci, &req); } -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; - tx_chn = devm_kzalloc(dev, sizeof(*tx_chn), GFP_KERNEL); - if (!tx_chn) - return ERR_PTR(-ENOMEM); - - tx_chn->common.dev = dev; - tx_chn->common.swdata_size = cfg->swdata_size; - tx_chn->tx_pause_on_err = cfg->tx_pause_on_err; - tx_chn->tx_filt_einfo = cfg->tx_filt_einfo; - tx_chn->tx_filt_pswords = cfg->tx_filt_pswords; - tx_chn->tx_supr_tdpkt = cfg->tx_supr_tdpkt; - - /* parse of udmap channel */ - ret = of_k3_udma_glue_parse_chn(dev->of_node, name, - &tx_chn->common, true); - if (ret) - goto err; - tx_chn->common.hdesc_size = 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 = 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 = xudma_tchan_get_id(tx_chn->udma_tchanx); @@ -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 = NULL; - goto err; + return ret; } 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; } /* 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 = 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; } ret = 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; } /* 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 = k3_udma_glue_cfg_tx_chn(tx_chn); if (ret) { dev_err(dev, "Failed to cfg tchan %d\n", ret); - goto err; + return ret; } k3_udma_glue_dump_tx_chn(tx_chn); + 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 = devm_kzalloc(dev, sizeof(*tx_chn), GFP_KERNEL); + if (!tx_chn) + return ERR_PTR(-ENOMEM); + + tx_chn->common.dev = dev; + tx_chn->common.swdata_size = cfg->swdata_size; + tx_chn->tx_pause_on_err = cfg->tx_pause_on_err; + tx_chn->tx_filt_einfo = cfg->tx_filt_einfo; + tx_chn->tx_filt_pswords = cfg->tx_filt_pswords; + tx_chn->tx_supr_tdpkt = cfg->tx_supr_tdpkt; + + /* parse of udmap channel */ + ret = of_k3_udma_glue_parse_chn(dev->of_node, name, + &tx_chn->common, true); + if (ret) + goto err; + + ret = k3_udma_glue_request_tx_chn_common(dev, tx_chn, cfg); + if (ret) + goto err; + return tx_chn; err: @@ -395,6 +410,41 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx_chn(struct device *dev, } EXPORT_SYMBOL_GPL(k3_udma_glue_request_tx_chn); +struct k3_udma_glue_tx_channel * +k3_udma_glue_request_tx_chn_for_thread_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 = devm_kzalloc(dev, sizeof(*tx_chn), GFP_KERNEL); + if (!tx_chn) + return ERR_PTR(-ENOMEM); + + tx_chn->common.dev = dev; + tx_chn->common.swdata_size = cfg->swdata_size; + tx_chn->tx_pause_on_err = cfg->tx_pause_on_err; + tx_chn->tx_filt_einfo = cfg->tx_filt_einfo; + tx_chn->tx_filt_pswords = cfg->tx_filt_pswords; + tx_chn->tx_supr_tdpkt = cfg->tx_supr_tdpkt; + + ret = of_k3_udma_glue_parse_chn_by_id(udmax_np, &tx_chn->common, true, thread_id); + if (ret) + goto err; + + ret = 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_for_thread_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-glue.h index e443be4d3b4b..c81386ceb1c1 100644 --- a/include/linux/dma/k3-udma-glue.h +++ b/include/linux/dma/k3-udma-glue.h @@ -26,6 +26,11 @@ 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); +struct k3_udma_glue_tx_channel * +k3_udma_glue_request_tx_chn_for_thread_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, From patchwork Mon Dec 18 06:26:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Vadapalli X-Patchwork-Id: 180151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1060176dyi; Sun, 17 Dec 2023 22:28:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcpkMWbT2Pn4dOpMAoWw3neNf1ro4KnZpg2KPPg+R2Bybm8R/qiQM1gvyPVPUbzcdPczWz X-Received: by 2002:a81:5cc2:0:b0:5d7:1941:3577 with SMTP id q185-20020a815cc2000000b005d719413577mr9802089ywb.94.1702880880559; Sun, 17 Dec 2023 22:28:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702880880; cv=none; d=google.com; s=arc-20160816; b=IjKfnxoMXCUlfxS2KRV0D2/jKlNpnuNgDtlq0otq9+JW4TvGNw8Z4eQnSgbS0o+3qA nRAP/d+6bQGl77zlB0SUb0Niy0jbz4GOaRbBAe33FYtDI6b29vJbxoN0vdbPaO/l9+1q hISQo/ByiRSg+VJycWWC/4BwAAPPKpiOMu07DfmxUj6LhpMk2/+pGfzwYxaLLzUyHYyB KtW1RVazBx3wH5U2PWdZ+FPXQMp17uMq6dbjgmEgvdnOOr9n7iumiSkp99IG8kYJ/AeW dc7mFlPJ1yeguRAzy8sBcliq3yiqUJluKVGD9kr9Xetu5Cr9TS9h6XeOQnP7pFbM5m7C 6JUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hvyAogCDuF0aiWDT6fef8PtsOTs666fOdyAhOsf1BYY=; fh=kWHopdWuWktDcnjSO11R7sPQi0EWg865jqRuCsOPYXE=; b=wFSRARd3ftByuw6QXlaJd0Gc3Ysg9KjkYGRrbFfCtMCVlCXJt7dQPjkkMrSOhZGpz5 DDd/SPvnHiKXYBcVZakEgErEFRBkE6kLSDk1Zs9CKxdzKcJ9LpORlJwpNM4P/drhqnae FM6CIdQUOsQcPX6T8iGZsxDSlZowGe5gOrrL+RZiIr2nvUq7dw/aiqAnhZP7YluSHzXc lZnswY6biLX+Ev3umDqCqcuxZxfAkfGv7gaOBh/opaEuR9hHLUVDuUHnb8Au89Su23UT IAzO6UP1jOGiLXSXVOzFdsbaFhClI2NOHzpjQXR3W2huA3TvXVCDdjSxq48JkcfYozcL UZRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wQwNOS9r; spf=pass (google.com: domain of linux-kernel+bounces-3040-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3040-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q8-20020a0c9a48000000b0067f475845dbsi1161078qvd.2.2023.12.17.22.28.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 22:28:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3040-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wQwNOS9r; spf=pass (google.com: domain of linux-kernel+bounces-3040-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3040-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4BC251C2138C for ; Mon, 18 Dec 2023 06:28:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A691479F1; Mon, 18 Dec 2023 06:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="wQwNOS9r" X-Original-To: linux-kernel@vger.kernel.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 637608470; Mon, 18 Dec 2023 06:27:00 +0000 (UTC) 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 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BI6Qs8n121907; Mon, 18 Dec 2023 00:26:54 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1702880814; bh=hvyAogCDuF0aiWDT6fef8PtsOTs666fOdyAhOsf1BYY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wQwNOS9rLCkPxthqp/9ZBvb7/EzEQlm/jFSxPyKIuyg/Tw81BOe57zfyHmJO8GjSz +W+EYiOwI1vab0ts+3cHCr1v5sbv3mEB5SxvAK5rTN4w0gE6MCVcb6AaFJiM+Japxr kMS0NvHMUnuVnC0+lwtFlT+/comas20lJPsl22zo= 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 3BI6Qs3h009127 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Dec 2023 00:26:54 -0600 Received: from DFLE113.ent.ti.com (10.64.6.34) 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; Mon, 18 Dec 2023 00:26:54 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE113.ent.ti.com (10.64.6.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; Mon, 18 Dec 2023 00:26:54 -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 3BI6QebJ063306; Mon, 18 Dec 2023 00:26:51 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v3 4/4] dmaengine: ti: k3-udma-glue: Add function to request RX chan for thread ID Date: Mon, 18 Dec 2023 11:56:40 +0530 Message-ID: <20231218062640.2338453-5-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218062640.2338453-1-s-vadapalli@ti.com> References: <20231218062640.2338453-1-s-vadapalli@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785600021785186729 X-GMAIL-MSGID: 1785600021785186729 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 DMA channel for a given thread ID in the form of a new function named k3_udma_glue_request_remote_rx_chn_for_thread_id(). Also, 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 thread ID corresponding to the RX DMA channel by RPMsg for example. Since the new function k3_udma_glue_request_remote_rx_chn_for_thread_id() reuses most of the code in k3_udma_glue_request_remote_rx_chn(), create a new function named k3_udma_glue_request_remote_rx_chn_common() for the common code. Signed-off-by: Siddharth Vadapalli --- Changes since v2: - Renamed function "k3_udma_glue_request_remote_rx_chn_by_id()" to "k3_udma_glue_request_remote_rx_chn_for_thread_id()". - Updated commit message to reflect function renaming. Changes since v1: - Updated commit message indicating the use-case for which the patch is being added. drivers/dma/ti/k3-udma-glue.c | 137 ++++++++++++++++++++++--------- include/linux/dma/k3-udma-glue.h | 5 ++ 2 files changed, 103 insertions(+), 39 deletions(-) diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c index a475bbea35ee..c9b93055dc9d 100644 --- a/drivers/dma/ti/k3-udma-glue.c +++ b/drivers/dma/ti/k3-udma-glue.c @@ -1073,52 +1073,21 @@ k3_udma_glue_request_rx_chn_priv(struct device *dev, const char *name, return ERR_PTR(ret); } -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; - if (cfg->flow_id_num <= 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 = devm_kzalloc(dev, sizeof(*rx_chn), GFP_KERNEL); - if (!rx_chn) - return ERR_PTR(-ENOMEM); - - rx_chn->common.dev = dev; - rx_chn->common.swdata_size = cfg->swdata_size; - rx_chn->remote = true; - rx_chn->udma_rchan_id = -1; - rx_chn->flow_num = cfg->flow_id_num; - rx_chn->flow_id_base = cfg->flow_id_base; - rx_chn->psil_paired = false; - - /* parse of udmap channel */ - ret = of_k3_udma_glue_parse_chn(dev->of_node, name, - &rx_chn->common, false); - if (ret) - goto err; - rx_chn->common.hdesc_size = cppi5_hdesc_calc_size(rx_chn->common.epib, rx_chn->common.psdata_size, rx_chn->common.swdata_size); rx_chn->flows = devm_kcalloc(dev, rx_chn->flow_num, sizeof(*rx_chn->flows), GFP_KERNEL); - if (!rx_chn->flows) { - ret = -ENOMEM; - goto err; - } + if (!rx_chn->flows) + return -ENOMEM; rx_chn->common.chan_dev.class = &k3_udma_glue_devclass; rx_chn->common.chan_dev.parent = xudma_get_device(rx_chn->common.udmax); @@ -1129,7 +1098,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 = NULL; - goto err; + return ret; } if (xudma_is_pktdma(rx_chn->common.udmax)) { @@ -1141,19 +1110,109 @@ k3_udma_glue_request_remote_rx_chn(struct device *dev, const char *name, ret = k3_udma_glue_allocate_rx_flows(rx_chn, cfg); if (ret) - goto err; + return ret; for (i = 0; i < rx_chn->flow_num; i++) rx_chn->flows[i].udma_rflow_id = rx_chn->flow_id_base + i; k3_udma_glue_dump_rx_chn(rx_chn); + 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 <= 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 = devm_kzalloc(dev, sizeof(*rx_chn), GFP_KERNEL); + if (!rx_chn) + return ERR_PTR(-ENOMEM); + + rx_chn->common.dev = dev; + rx_chn->common.swdata_size = cfg->swdata_size; + rx_chn->remote = true; + rx_chn->udma_rchan_id = -1; + rx_chn->flow_num = cfg->flow_id_num; + rx_chn->flow_id_base = cfg->flow_id_base; + rx_chn->psil_paired = false; + + /* parse of udmap channel */ + ret = of_k3_udma_glue_parse_chn(dev->of_node, name, + &rx_chn->common, false); + if (ret) + goto err; + + ret = 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_for_thread_id(struct device *dev, + struct k3_udma_glue_rx_channel_cfg *cfg, + struct device_node *udmax_np, u32 thread_id) +{ + struct k3_udma_glue_rx_channel *rx_chn; + int ret; + + if (cfg->flow_id_num <= 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 = devm_kzalloc(dev, sizeof(*rx_chn), GFP_KERNEL); + if (!rx_chn) + return ERR_PTR(-ENOMEM); + + rx_chn->common.dev = dev; + rx_chn->common.swdata_size = cfg->swdata_size; + rx_chn->remote = true; + rx_chn->udma_rchan_id = -1; + rx_chn->flow_num = cfg->flow_id_num; + rx_chn->flow_id_base = cfg->flow_id_base; + rx_chn->psil_paired = false; + + ret = of_k3_udma_glue_parse_chn_by_id(udmax_np, &rx_chn->common, false, thread_id); + if (ret) + goto err; + + ret = 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); } +EXPORT_SYMBOL_GPL(k3_udma_glue_request_remote_rx_chn_for_thread_id); 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-glue.h index c81386ceb1c1..1e491c5dcac2 100644 --- a/include/linux/dma/k3-udma-glue.h +++ b/include/linux/dma/k3-udma-glue.h @@ -114,6 +114,11 @@ struct k3_udma_glue_rx_channel *k3_udma_glue_request_rx_chn( const char *name, struct k3_udma_glue_rx_channel_cfg *cfg); +struct k3_udma_glue_rx_channel * +k3_udma_glue_request_remote_rx_chn_for_thread_id(struct device *dev, + struct k3_udma_glue_rx_channel_cfg *cfg, + struct device_node *udmax_np, 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);