Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4560907rdb; Tue, 12 Dec 2023 03:12:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHY3T9vIYkJbYJzXlF5bvTpU/j9XZf4+9RaeSIJhkSZx7rJ243MAwoVq/7ybBVNYahzjQSX X-Received: by 2002:a05:6e02:2166:b0:35d:a8bd:c788 with SMTP id s6-20020a056e02216600b0035da8bdc788mr9123892ilv.21.1702379544620; Tue, 12 Dec 2023 03:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702379544; cv=none; d=google.com; s=arc-20160816; b=XRnY6vDT1KvK/bpnJFoJ5Vz7SYh/CJ6P1uTIysDhuDOdhO2R73dEQzRpGQCXga9Pan vBuGtGxSVgnxaU7vaqlPdEKf43xovPaz7wOM7b2XErrRwVfTdkloAZVFrEbYCEsF7BnS whaMbHZ/02p9t7G0HAKQtwhHeQJI0hGO2c/VooY4I5cqqlUKDCgu0JOH7xdGXUoMTNW1 CPIo+2CjUXNNa1nsGFQYRwuXG3VsfRLGPogc7M8/whnWuJSbTai15Gz2I/BDky4bkZ20 glWLERP7K5K56Yhbn2fJqb0AJuzyZJPoUuj9FCBnDfdaTbZTpL4QDJF3raSp84vNLEq0 Sy8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NDYSOhMhZmqY81VdzmRhbg1HQImEb7c2DNjpVOKaW7U=; fh=kWHopdWuWktDcnjSO11R7sPQi0EWg865jqRuCsOPYXE=; b=pR4xMzRf9ascRQU0mG1c5VIUKnHlivKLETYAW+Gy9aksm1m2XFOqs8MnIDFlOog7BY vKb21n0zDE58O6vHNQKBCNSovP5w1xTu/AIpkvGvTTnzIl5sVyylNQT90x7+7NF/5DBv qrBjlj1uM0ur9zuyY3EdeF9yffs96AIIVAOFoM0QrwRP+qxQQRUOuXZr0f43qABjYfgN aP/zSNrWPS2YSdHmL2vOfIHeUugipvti5+9sOdAcP+SXE7Tl4+xhL8C6LVFnsjakPzuY BAY6lJ0KkuwcFZwZ9iDcwUQZkGO9upHOsQ7hlhWVnsYYIjnMGqMVlu4VsB6n16RyWBd/ lFDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xEBCUIAa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id i34-20020a635422000000b005c658bf30a8si7479329pgb.302.2023.12.12.03.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 03:12:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xEBCUIAa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id F0F05807A5BE; Tue, 12 Dec 2023 03:12:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235173AbjLLLMD (ORCPT + 99 others); Tue, 12 Dec 2023 06:12:03 -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: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 03:12:22 -0800 (PST) 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 *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) { -- 2.34.1