From nobody Sat Oct 11 04:13:38 2025 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (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 C1216220F51; Thu, 12 Jun 2025 07:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749712571; cv=none; b=bCMD467kk6IdaaF33Cc1bRc6zUlszlmhcOMeedAWn3TW9zNVpJrOevuUAMCeWnyCPBwrY2E+LMG+yuph92mTvmOxz/yoo1O7OaD8wvxCmHmvP/A1EJr6CTo2nQ2h1I99fRnscejlWaZpHzul18EOUnAAJfOxUuiD0dGK+DUs+Ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749712571; c=relaxed/simple; bh=2pj1dY9iSAN149up3mqoKD9fAkWXy4biuYqp4UpiTZk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qq6bIliOWT8+xODYD8mhtpc2vzMmql+5RhPk8hsDUemCFqeOxtBKqImu8bwi3PKfLFp5s25FDCSjHKJzi77DkuGGDMiHPNt5Ds73MCnDNcb9xGzn043OHxf5gJX+c8Y4tgAMgtaJL/LbOTdTkFpyFDac8YhVNN5qT2kYBZNQIKM= 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=odhmNtHX; arc=none smtp.client-ip=198.47.19.246 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="odhmNtHX" Received: from lelvem-sh01.itg.ti.com ([10.180.77.71]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTP id 55C7G4xg1615141; Thu, 12 Jun 2025 02:16:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1749712565; bh=KSy9Pw29srntZSrcNTrrXNXQGhv7S4aH3POd7ahYeys=; h=From:To:Subject:Date:In-Reply-To:References; b=odhmNtHX0WS5Avvxzv3uUOEwr47trm36lze6O4loGyh27sj9/FwWGb74YHpoFt/Fe EU2P4WSre4voM9YFg8ofBlA9w+ah0UUMjNDDo/9JkY0pKao+ox1TbKSvVZKLkBBKzd VSRXddzEjxZIr/rqvla5Qp3w4II9wv317ui4khdE= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelvem-sh01.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 55C7G4hG2380781 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Thu, 12 Jun 2025 02:16:04 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) 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.55; Thu, 12 Jun 2025 02:16:04 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55 via Frontend Transport; Thu, 12 Jun 2025 02:16:04 -0500 Received: from uda0498651.dhcp.ti.com (uda0498651.dhcp.ti.com [172.24.227.7]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 55C7FTKS1608959; Thu, 12 Jun 2025 02:15:59 -0500 From: Sai Sree Kartheek Adivi To: Peter Ujfalusi , Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Santosh Shilimkar , Sai Sree Kartheek Adivi , , , , , , , , , Subject: [PATCH v2 06/17] dmaengine: ti: k3-udma: Add variant-specific function pointers to udma_dev Date: Thu, 12 Jun 2025 12:45:10 +0530 Message-ID: <20250612071521.3116831-7-s-adivi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250612071521.3116831-1-s-adivi@ti.com> References: <20250612071521.3116831-1-s-adivi@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: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Sai Sree Kartheek Adivi --- drivers/dma/ti/k3-udma.c | 38 ++++++++++++++++++++++---------------- drivers/dma/ti/k3-udma.h | 5 +++++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index efbd16dc3f931..db342682edb23 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -329,7 +329,7 @@ static int udma_start(struct udma_chan *uc) } =20 /* Make sure that we clear the teardown bit, if it is set */ - udma_reset_chan(uc, false); + uc->ud->reset_chan(uc, false); =20 /* 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 =3D uc->desc; =20 - 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) } =20 if (!uc->desc) - udma_start(uc); + uc->ud->start(uc); =20 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) =20 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 =3D -EBUSY; @@ -1821,7 +1821,7 @@ static int bcdma_alloc_chan_resources(struct dma_chan= *chan) =20 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 =3D -EBUSY; @@ -2014,7 +2014,7 @@ static int pktdma_alloc_chan_resources(struct dma_cha= n *chan) =20 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 =3D -EBUSY; @@ -2123,7 +2123,7 @@ static void udma_issue_pending(struct dma_chan *chan) */ if (!(uc->state =3D=3D UDMA_CHAN_IS_TERMINATING && udma_is_chan_running(uc))) - udma_start(uc); + uc->ud->start(uc); } =20 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); =20 if (udma_is_chan_running(uc)) - udma_stop(uc); + uc->ud->stop(uc); =20 if (uc->desc) { uc->terminated_desc =3D 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); } } =20 - 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); =20 @@ -2355,7 +2355,7 @@ static void udma_free_chan_resources(struct dma_chan = *chan) =20 udma_terminate_all(chan); if (uc->terminated_desc) { - udma_reset_chan(uc, false); + ud->reset_chan(uc, false); udma_reset_rings(uc); } =20 @@ -3694,6 +3694,12 @@ static int udma_probe(struct platform_device *pdev) ud->soc_data =3D soc->data; } =20 + // Setup function pointers + ud->start =3D udma_start; + ud->stop =3D udma_stop; + ud->reset_chan =3D udma_reset_chan; + ud->decrement_byte_counters =3D udma_decrement_byte_counters; + ret =3D 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 edff919b8b347..67425ed1273aa 100644 --- a/drivers/dma/ti/k3-udma.h +++ b/drivers/dma/ti/k3-udma.h @@ -343,6 +343,11 @@ 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); }; =20 struct udma_desc { --=20 2.34.1