From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795520747; b=1dN0LhCAP5u1eWyaNvGbY2wwcLRWb0VT/KhEL6qRRrQUHyeDmaz2XUU3nv8PyoziuRqL LWiDfAQ7ZaKl2RmcwTbCmWOe+SZYjqXgnaCpP3rvz/5QEKMC83/9GuX44f41rInoeAS35 fiWJ+ZMiB1b/H9hA97ICzFuxpwO/4UFw7J6katl+yg1pyavG6i2h8WmbLHlsUtwTcz80S E4vA+9BJ3nK8bALR7Y/rR/A8YRLUfdhvFEBrMV/lpTLxLbzkkP6Rrsa5tJUlgNsyI4blp uBI9qwVk+n/o5R0/p3svrU4xhLsh9CxkgeWIwlHGihah4BYl1F50ygvV6rMbH9mGa0w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795520747; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=Ots3WAFDPR2PYg+mjIwzB9jpyCmnpV1ZAB8Z4JBu2L8=; b=1gZiCk9RLyTgBVIHx9NgMSIHlWr9NeVE9QUy2bmAhkEav/m4F8n9GRV7lWNHbHAlVzw4 ch/LzU6pJ2MKyIvMAWyal4lDZF58awBME12Iiozl7013koWT/6ALEKgfTbUPyNVIG6qpx xXPH+5uvsIcv91YhpIhWllHP1gHmgWqeJbbGcMg4xMj+7APCxzhL+rD5XCjshM4yMA2XI oLcy+W9P7yxXaG+5jz7XiCAPeZFWJ9eMdesi8i5bMIpF/G6qwlKdZPtKCNXPjLYMWhZKB KM5l5g8UZu0rEmtCYh4UAHPg306AjaM3Q3itjkAI0HYlqKzLoEzKCRYIHccAuc/CRBA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e0zksxXp; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74936606A689; Tue, 24 Nov 2026 11:45:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e0zksxXp Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795520747; b=Oold0Sxq7Ud0IZHMV8lZNaNBmmHS310TqdDuf/8Tkoc/M6tbe6xVZsf/fWfDShyFmvI6 CHCGeFgVkyq6GRMKzffq7nn6zhryxxHgcbUDarno9rRH8My1x44p5UhpkKmmlB8a/lwkq FKPurIRC32sXN9sbgmAdXLCYcmY+sFedyYqXOZpspWS/REe/akn6ydGMz1GQ6SdpA6YiK 3MWlOJacxWgofVhrGRxre7O2NaEa7xOe2D9lBYW1olLwyo0Mahv+w/Xw05idoENtgOqgh kF2UvLTmDniKf6fd4VvZJX9h/A9xg1za7Kp3x49C7zzqdma9egQMZgcv1KlN5mglh2A== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795520747; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=Ots3WAFDPR2PYg+mjIwzB9jpyCmnpV1ZAB8Z4JBu2L8=; b=OB58gbjWJ9BG5IPm0NYxXTFdYR858AaUcu+yE/MEYYlbIKL6apk3FwGBuTieRKP+ul87 c5LIl73myk9X4IrsrwKc6sly4Y9xVMpni1kXhnurrvJdiwDgeCKxTTWs4bLYd7bXwOKEm jXcQf94E4Y6LaDcPfumGFA7te51KoyiaMlA8rhA7N8gET85Ggy3xu6V1ILrIdoX9K5LWe QS87VhOqiBaLpPNgTEsqbNAz2TxqUjNDy3aYF0EoiyzPk9ELnqkxVWl2BiINDUT2zPPfu OxB4TETqjLxRj9d4gclObvvBUKC9Ic0fQ+O4K4FEVVjgFcG/3ht8Nopx58Gz9LI2QLQ== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 952221F000D3; Tue, 24 Nov 2026 11:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795520747; bh=Ots3WAFDPR2PYg+mjIwzB9jpyCmnpV1ZAB8Z4JBu2L8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=e0zksxXpJOPwkjxsQEorcZAvvbK6FBu2ER4NCfS9GNjqHRlTjAWvK9JbMkqNfBFbx n3xAvAG1x3TeSqn59TAzm3bI/PONmnlWhy+FjAH0JVl8O8oHrnVcV2/2PYBBAi+gye /1yMw31QDeaBQWuD+kfg5Dm0OQbOtJqC3UKfJkGu+uEOSQmuxcRP2Fgxltm06bmEnq bte2dZ9CNgYuKoIDAusNPImFpV1Esf2p/Up0dUbMGoMju+0QgDCIyAEN5lduTAnA06 jSYXexQZ903NEqcf3/xMyRLJxSeDmPvbD9cGdGuiViKdHsnzoR31Sl5PdIR6pE1uPG 409ZNhohOWQ1w== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 99A8F4CA03; Tue, 24 Nov 2026 11:45:27 +0000 (UTC) From: Sai Sree Kartheek Adivi via B4 Relay Date: Tue, 24 Nov 2026 17:15:09 +0530 Subject: [PATCH v13 07/20] dmaengine: ti: k3-udma: Add variant-specific function pointers to udma_dev X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261124-dma-upstream-v13-v13-7-bd4251fdc6d4@ti.com> References: <20261124-dma-upstream-v13-v13-0-bd4251fdc6d4@ti.com> In-Reply-To: <20261124-dma-upstream-v13-v13-0-bd4251fdc6d4@ti.com> To: Vignesh Raghavendra , Vinod Koul , Frank Li , Peter Ujfalusi , Nishanth Menon , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, sebin.francis@ti.com, Sai Sree Kartheek Adivi , Frank Li X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795520723; l=10558; i=s-adivi@ti.com; s=20261124; h=from:subject:message-id; bh=4M8T7KkPXsvWkJD69g3DX42CQArerjghpVbY6qtdGd4=; b=RAFS4XmRc0vojszchHsL5bVx5o7VZTz9ERaO3bRssmW9kwE3KMDrCUhpv/7auXxMlpVav3eSn Bju7zI3uCrVDiAAAmQ9/ucCZ6SOC9pwcu1fSnFFe9fg6zvqhFJbyCRq X-Developer-Key: i=s-adivi@ti.com; a=ed25519; pk=EtOwVxmXDuYMgw3DqFtPDBpf8ZvbO89w1fJm4w5yPI8= X-Endpoint-Received: by B4 Relay for s-adivi@ti.com/20261124 with auth_id=1627 X-Original-From: Sai Sree Kartheek Adivi Reply-To: s-adivi@ti.com Content-Transfer-Encoding: 7bit From: Sai Sree Kartheek Adivi Introduce function pointers in the udma_dev structure to allow variant-specific implementations for certain operations. This prepares the driver for supporting multiple K3 UDMA variants, such as UDMA v2, with minimal code duplication. No functional changes intended in this commit. Reviewed-by: Frank Li Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma-private.c | 10 ++++-- drivers/dma/ti/k3-udma.c | 66 ++++++++++++++++++++++------------------ drivers/dma/ti/k3-udma.h | 12 ++++++++ 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/drivers/dma/ti/k3-udma-private.c b/drivers/dma/ti/k3-udma-private.c index 624360423ef17..44c097fff5ee6 100644 --- a/drivers/dma/ti/k3-udma-private.c +++ b/drivers/dma/ti/k3-udma-private.c @@ -8,13 +8,19 @@ int xudma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) { - return navss_psil_pair(ud, src_thread, dst_thread); + if (ud->psil_pair) + return ud->psil_pair(ud, src_thread, dst_thread); + + return 0; } EXPORT_SYMBOL(xudma_navss_psil_pair); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) { - return navss_psil_unpair(ud, src_thread, dst_thread); + if (ud->psil_unpair) + return ud->psil_unpair(ud, src_thread, dst_thread); + + return 0; } EXPORT_SYMBOL(xudma_navss_psil_unpair); diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 2fba734616272..fbcf976d7a668 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -40,7 +40,7 @@ static const char * const mmr_names[] = { [MMR_TCHANRT] = "tchanrt", }; -static int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) +int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) { struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; @@ -50,8 +50,8 @@ static int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) src_thread, dst_thread); } -static int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, - u32 dst_thread) +int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, + u32 dst_thread) { struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; @@ -329,7 +329,7 @@ static int udma_start(struct udma_chan *uc) } /* Make sure that we clear the teardown bit, if it is set */ - udma_reset_chan(uc, false); + uc->ud->reset_chan(uc, false); /* Push descriptors before we start the channel */ udma_start_desc(uc); @@ -521,8 +521,8 @@ static void udma_check_tx_completion(struct work_struct *work) if (uc->desc) { struct udma_desc *d = uc->desc; - udma_decrement_byte_counters(uc, d->residue); - udma_start(uc); + uc->ud->decrement_byte_counters(uc, d->residue); + uc->ud->start(uc); vchan_cookie_complete(&d->vd); break; } @@ -554,7 +554,7 @@ static irqreturn_t udma_ring_irq_handler(int irq, void *data) } if (!uc->desc) - udma_start(uc); + uc->ud->start(uc); goto out; } @@ -576,8 +576,8 @@ static irqreturn_t udma_ring_irq_handler(int irq, void *data) vchan_cyclic_callback(&d->vd); } else { if (udma_is_desc_really_done(uc, d)) { - udma_decrement_byte_counters(uc, d->residue); - udma_start(uc); + uc->ud->decrement_byte_counters(uc, d->residue); + uc->ud->start(uc); vchan_cookie_complete(&d->vd); } else { schedule_delayed_work(&uc->tx_drain.work, @@ -612,8 +612,8 @@ static irqreturn_t udma_udma_irq_handler(int irq, void *data) vchan_cyclic_callback(&d->vd); } else { /* TODO: figure out the real amount of data */ - udma_decrement_byte_counters(uc, d->residue); - udma_start(uc); + uc->ud->decrement_byte_counters(uc, d->residue); + uc->ud->start(uc); vchan_cookie_complete(&d->vd); } } @@ -1654,7 +1654,7 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) if (udma_is_chan_running(uc)) { dev_warn(ud->dev, "chan%d: is running!\n", uc->id); - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) { dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); ret = -EBUSY; @@ -1663,7 +1663,7 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) } /* PSI-L pairing */ - ret = navss_psil_pair(ud, uc->config.src_thread, uc->config.dst_thread); + ret = ud->psil_pair(ud, uc->config.src_thread, uc->config.dst_thread); if (ret) { dev_err(ud->dev, "PSI-L pairing failed: 0x%04x -> 0x%04x\n", uc->config.src_thread, uc->config.dst_thread); @@ -1718,7 +1718,7 @@ static int udma_alloc_chan_resources(struct dma_chan *chan) uc->irq_num_ring = 0; uc->irq_num_udma = 0; err_psi_free: - navss_psil_unpair(ud, uc->config.src_thread, uc->config.dst_thread); + ud->psil_unpair(ud, uc->config.src_thread, uc->config.dst_thread); uc->psil_paired = false; err_res_free: udma_free_tx_resources(uc); @@ -1821,7 +1821,7 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan) if (udma_is_chan_running(uc)) { dev_warn(ud->dev, "chan%d: is running!\n", uc->id); - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) { dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); ret = -EBUSY; @@ -1849,8 +1849,8 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan) uc->use_dma_pool = true; } else if (uc->config.dir != DMA_MEM_TO_MEM) { /* PSI-L pairing */ - ret = navss_psil_pair(ud, uc->config.src_thread, - uc->config.dst_thread); + ret = ud->psil_pair(ud, uc->config.src_thread, + uc->config.dst_thread); if (ret) { dev_err(ud->dev, "PSI-L pairing failed: 0x%04x -> 0x%04x\n", @@ -1910,8 +1910,8 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan) uc->irq_num_udma = 0; err_psi_free: if (uc->psil_paired) - navss_psil_unpair(ud, uc->config.src_thread, - uc->config.dst_thread); + ud->psil_unpair(ud, uc->config.src_thread, + uc->config.dst_thread); uc->psil_paired = false; err_res_free: bcdma_free_bchan_resources(uc); @@ -2014,7 +2014,7 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan) if (udma_is_chan_running(uc)) { dev_warn(ud->dev, "chan%d: is running!\n", uc->id); - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) { dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); ret = -EBUSY; @@ -2037,7 +2037,7 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan) uc->use_dma_pool = true; /* PSI-L pairing */ - ret = navss_psil_pair(ud, uc->config.src_thread, uc->config.dst_thread); + ret = ud->psil_pair(ud, uc->config.src_thread, uc->config.dst_thread); if (ret) { dev_err(ud->dev, "PSI-L pairing failed: 0x%04x -> 0x%04x\n", uc->config.src_thread, uc->config.dst_thread); @@ -2083,7 +2083,7 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan) err_irq_free: uc->irq_num_ring = 0; err_psi_free: - navss_psil_unpair(ud, uc->config.src_thread, uc->config.dst_thread); + ud->psil_unpair(ud, uc->config.src_thread, uc->config.dst_thread); uc->psil_paired = false; err_res_free: udma_free_tx_resources(uc); @@ -2123,7 +2123,7 @@ static void udma_issue_pending(struct dma_chan *chan) */ if (!(uc->state == UDMA_CHAN_IS_TERMINATING && udma_is_chan_running(uc))) - udma_start(uc); + uc->ud->start(uc); } spin_unlock_irqrestore(&uc->vc.lock, flags); @@ -2265,7 +2265,7 @@ static int udma_terminate_all(struct dma_chan *chan) spin_lock_irqsave(&uc->vc.lock, flags); if (udma_is_chan_running(uc)) - udma_stop(uc); + uc->ud->stop(uc); if (uc->desc) { uc->terminated_desc = uc->desc; @@ -2297,11 +2297,11 @@ static void udma_synchronize(struct dma_chan *chan) dev_warn(uc->ud->dev, "chan%d teardown timeout!\n", uc->id); udma_dump_chan_stdata(uc); - udma_reset_chan(uc, true); + uc->ud->reset_chan(uc, true); } } - udma_reset_chan(uc, false); + uc->ud->reset_chan(uc, false); if (udma_is_chan_running(uc)) dev_warn(uc->ud->dev, "chan%d refused to stop!\n", uc->id); @@ -2355,7 +2355,7 @@ static void udma_free_chan_resources(struct dma_chan *chan) udma_terminate_all(chan); if (uc->terminated_desc) { - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); udma_reset_rings(uc); } @@ -2374,8 +2374,8 @@ static void udma_free_chan_resources(struct dma_chan *chan) /* Release PSI-L pairing */ if (uc->psil_paired) { - navss_psil_unpair(ud, uc->config.src_thread, - uc->config.dst_thread); + ud->psil_unpair(ud, uc->config.src_thread, + uc->config.dst_thread); uc->psil_paired = false; } @@ -3677,6 +3677,14 @@ static int udma_probe(struct platform_device *pdev) ud->soc_data = soc->data; } + // Setup function pointers + ud->start = udma_start; + ud->stop = udma_stop; + ud->reset_chan = udma_reset_chan; + ud->decrement_byte_counters = udma_decrement_byte_counters; + ud->psil_pair = navss_psil_pair; + ud->psil_unpair = navss_psil_unpair; + ret = udma_get_mmrs(pdev, ud); if (ret) return ret; diff --git a/drivers/dma/ti/k3-udma.h b/drivers/dma/ti/k3-udma.h index 1777f0e1f085e..59170714f53cc 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -349,6 +349,15 @@ struct udma_dev { u32 psil_base; u32 atype; u32 asel; + + int (*start)(struct udma_chan *uc); + int (*stop)(struct udma_chan *uc); + int (*reset_chan)(struct udma_chan *uc, bool hard); + void (*decrement_byte_counters)(struct udma_chan *uc, u32 val); + int (*psil_pair)(struct udma_dev *ud, u32 src_thread, + u32 dst_thread); + int (*psil_unpair)(struct udma_dev *ud, u32 src_thread, + u32 dst_thread); }; struct udma_desc { @@ -586,6 +595,9 @@ int udma_push_to_ring(struct udma_chan *uc, int idx); int udma_pop_from_ring(struct udma_chan *uc, dma_addr_t *addr); void udma_reset_rings(struct udma_chan *uc); +int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); +int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); + /* Direct access to UDMA low lever resources for the glue layer */ int xudma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread); int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, -- 2.55.0