Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1088565rdb; Wed, 24 Jan 2024 04:43:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSXvtE3glm6bNpeQzpKw5c2J7dXDNglisMKUOShNB8hxQuJyZm8+1Jr14JPkrmn4mrbi1S X-Received: by 2002:a05:6359:4c1f:b0:175:fc44:2654 with SMTP id kj31-20020a0563594c1f00b00175fc442654mr5869391rwc.15.1706100236432; Wed, 24 Jan 2024 04:43:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706100236; cv=pass; d=google.com; s=arc-20160816; b=GB0ddNHcOwwE1WYDHf59WpF8BuH8lhu2VPOZ5nxiVNNTxpTvNmAUM2tHv5ZGbOjopH 52E+Sy9vGpRJfNUNDJYrQhjr3OR/NTSRmvREnletnF+EXuSJgHyGJJMM1IDHBs5eQE8N Ik7Fzq6/0xLWcE/cjcOtgNOUK1ZEy7bPmqcyNAvFUZc3vjfe9b5Jt5qXJVhWHlAgpxP9 K4DeWQxFYcORLv5rGK/ZEg3Lme+X8AMaBuF6IxlTP/qmt2jwBByMBYWQf/gFBOR3KPRm QS/EEkgMJTsYENO6Hk8pVgu3P/cOW9m1mGwesbv3V8wx11mZqsqJqrzHR5b9zILHpN6x 5O0Q== ARC-Message-Signature: i=2; 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=S+mt0+BtY4IjeyFnmSwt09wDqqdPebMtT0dYwPR1Pzk=; fh=kWHopdWuWktDcnjSO11R7sPQi0EWg865jqRuCsOPYXE=; b=L/IftuC5x183Fu71dIJa9JdyOXk/hg2Afud/8h7BPT9F3V+GeFHULxg+iJdmEAu1EZ xkjxWnO08L93i0JZT/Ck2V9j8kh57YaE3h5ZyOaqsB8WmPod3NTtKI3wDHweJphoZOEH 0am9LQ3vUISwdiC6IsAeK1Pg5ctue5QZgDgk3jKHRaugVKU+2kj8FcIDLkSZ6KFDVwa6 cBcio3jyAW3hZMI/j1HjX/gIAxF7oMVgI70cEHgN75lcSBjzLg9QOsOmhwq75iJs433+ E047u49kUzsopByaB8Vxu6djAuC2Eu02lu7q4oHuJSBBq5BHmx6wD5Jmq0N7yMcQKXgc Qefg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wZQAH2aw; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-37007-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w37-20020a631625000000b005be1ee5dfc7si11461331pgl.9.2024.01.24.04.43.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 04:43:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37007-linux.lists.archive=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=wZQAH2aw; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-37007-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37007-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F211A286D20 for ; Wed, 24 Jan 2024 12:43:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 278C577F14; Wed, 24 Jan 2024 12:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="wZQAH2aw" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 B1D246A002; Wed, 24 Jan 2024 12:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706100214; cv=none; b=JSnURmyobYNuu1fkNT/0yKKsOy0+yAGCfHCbLG/zdC167r905WncIrLBcm2gKfbV2YACeH+LYAViUl4KWfStc061lqLM3R/UD9UB5BMSe4L0T4Wm3GSxObqMmo0vyutBhVmnE8TmNZAOFZE7z4pVDWE42WUtgsivCzVjfhI+v7A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706100214; c=relaxed/simple; bh=sWbShL7ww7PYScK7QTBF1rzM2n3vss+3BTm2PIiCgfE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TOLbRtpcxEh6FbaaqIuahNN3ctyn1m545mMYRqX0r3GfdgVIPSAEiWLKLn9igg0ZOnTHOPffwOqFD0nXa5VYENrk9XbId1Usa7AJlx+b2KmPhAge0CusVL8+spAgs9fcJrXjMLOEciZGQ0hPTaKFEy/jIfCG0pOdI0r+5vDHjgg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=wZQAH2aw; arc=none smtp.client-ip=198.47.23.249 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 lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40OChPeV010386; Wed, 24 Jan 2024 06:43:25 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706100205; bh=S+mt0+BtY4IjeyFnmSwt09wDqqdPebMtT0dYwPR1Pzk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=wZQAH2awQ4ByiVzcKipKGxeyLnS6fBd++w8Zqk7484wDr4tqADLl0k0qSlEXXdayj p2KP6GasGwz2znrpojvdkS3T0tD7IzYLbQVWqE+eRjELCU5jHSjK7tWVQSZeB8X5O0 p1oayYWCgjnnM+QI4/T4U0Z0sM+N2IocntDbDaHE= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40OChPug019713 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Jan 2024 06:43:25 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) 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; Wed, 24 Jan 2024 06:43:25 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE109.ent.ti.com (10.64.6.30) 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; Wed, 24 Jan 2024 06:43:25 -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 40OChJPe014062; Wed, 24 Jan 2024 06:43:23 -0600 From: Siddharth Vadapalli To: , CC: , , , , , Subject: [PATCH v4 1/4] dmaengine: ti: k3-udma-glue: Add function to parse channel by ID Date: Wed, 24 Jan 2024 18:13:16 +0530 Message-ID: <20240124124319.820002-2-s-vadapalli@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240124124319.820002-1-s-vadapalli@ti.com> References: <20240124124319.820002-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 Acked-by: Peter Ujfalusi --- 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