Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp78373rdb; Sun, 17 Dec 2023 22:27:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxxTA95bQMmvasM58jwc5r6ExSqMiYnoye7XYwA9d2mpiFCG9F01bgilxE1nsVXqQ8ZT5e X-Received: by 2002:a05:620a:1219:b0:77f:60df:4373 with SMTP id u25-20020a05620a121900b0077f60df4373mr18818786qkj.4.1702880832067; Sun, 17 Dec 2023 22:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702880832; cv=none; d=google.com; s=arc-20160816; b=FVM0edTZto2D6PhZh6n6M0qfuA/QJ9pKYLoKVJl8lMxYsedr3raOIE1pXROH4Z37Hn lc+pTPRhiM+Ip92kpvcJ7XW6ZcrlsNcAWVc8lIj6zLWSRnGZimKxvmPbCHPQrWJZEeeR tp8rpY4JlNOMj12piSYuHZSjIBLtUW+l6TGtvDJ6x3fojzMUjP5641dugtTIKEFKD1vL W/frr7tKp4evCgooFzCcmd+B57hHl/qh4OFtKW2bYWVmbPJcGQ0SaAW3u+vc4yk+1A5f jgT41n8A8VCn6JO/ymfQ5vp8PYpL0Jgrdhr074kk/QzVx0Iva2jb5+hqj8snp0Z4m8Uw FaSA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3038-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c1-20020a37e101000000b0077f33376a64si22324381qkm.530.2023.12.17.22.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 22:27:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3038-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3038-linux.lists.archive=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 BFF241C211D3 for ; Mon, 18 Dec 2023 06:27:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15C956FDD; Mon, 18 Dec 2023 06:26:58 +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 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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) { -- 2.34.1