U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: Tom Rini <trini@konsulko.com>
Cc: <u-boot@lists.denx.de>, Vignesh Raghavendra <vigneshr@ti.com>,
	Praneeth Bajjuri <praneeth@ti.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: [PATCH] dma: ti: k3-udma: Fix rflow reservation for PKTDMA
Date: Thu, 23 Dec 2021 19:27:30 +0530	[thread overview]
Message-ID: <20211223135730.1285175-1-vigneshr@ti.com> (raw)

Driver has a bug in that it uses rflow_in_use bitmap when setting up free rflow range
from TISCI but use rflow_map for reservation in __udma_reserve_rflow()

Fix this by dropping rflow_in_use bitmap array and use rflow_map for
PKTDMA. BCDMA does not need rflow_in_use either.

This fixes CPSW3g not able to get DMA channels at R5 SPL on AM64x

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/dma/ti/k3-udma.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 411edef3a7..86603d43f1 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -165,7 +165,6 @@ struct udma_dev {
 	unsigned long *rchan_map;
 	unsigned long *rflow_map;
 	unsigned long *rflow_map_reserved;
-	unsigned long *rflow_in_use;
 	unsigned long *tflow_map;
 
 	struct udma_bchan *bchans;
@@ -1448,15 +1447,11 @@ static int bcdma_setup_resources(struct udma_dev *ud)
 					   sizeof(unsigned long), GFP_KERNEL);
 	ud->rchans = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans),
 				  GFP_KERNEL);
-	/* BCDMA do not really have flows, but the driver expect it */
-	ud->rflow_in_use = devm_kcalloc(dev, BITS_TO_LONGS(ud->rchan_cnt),
-					sizeof(unsigned long),
-					GFP_KERNEL);
 	ud->rflows = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rflows),
 				  GFP_KERNEL);
 
 	if (!ud->bchan_map || !ud->tchan_map || !ud->rchan_map ||
-	    !ud->rflow_in_use || !ud->bchans || !ud->tchans || !ud->rchans ||
+	    !ud->bchans || !ud->tchans || !ud->rchans ||
 	    !ud->rflows)
 		return -ENOMEM;
 
@@ -1535,16 +1530,16 @@ static int pktdma_setup_resources(struct udma_dev *ud)
 					   sizeof(unsigned long), GFP_KERNEL);
 	ud->rchans = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans),
 				  GFP_KERNEL);
-	ud->rflow_in_use = devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt),
-					sizeof(unsigned long),
-					GFP_KERNEL);
+	ud->rflow_map = devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt),
+				     sizeof(unsigned long),
+				     GFP_KERNEL);
 	ud->rflows = devm_kcalloc(dev, ud->rflow_cnt, sizeof(*ud->rflows),
 				  GFP_KERNEL);
 	ud->tflow_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tflow_cnt),
 					   sizeof(unsigned long), GFP_KERNEL);
 
 	if (!ud->tchan_map || !ud->rchan_map || !ud->tflow_map || !ud->tchans ||
-	    !ud->rchans || !ud->rflows || !ud->rflow_in_use)
+	    !ud->rchans || !ud->rflows || !ud->rflow_map)
 		return -ENOMEM;
 
 	/* Get resource ranges from tisci */
@@ -1592,12 +1587,12 @@ static int pktdma_setup_resources(struct udma_dev *ud)
 	rm_res = tisci_rm->rm_ranges[RM_RANGE_RFLOW];
 	if (IS_ERR(rm_res)) {
 		/* all rflows are assigned exclusively to Linux */
-		bitmap_zero(ud->rflow_in_use, ud->rflow_cnt);
+		bitmap_zero(ud->rflow_map, ud->rflow_cnt);
 	} else {
-		bitmap_fill(ud->rflow_in_use, ud->rflow_cnt);
+		bitmap_fill(ud->rflow_map, ud->rflow_cnt);
 		for (i = 0; i < rm_res->sets; i++) {
 			rm_desc = &rm_res->desc[i];
-			bitmap_clear(ud->rflow_in_use, rm_desc->start,
+			bitmap_clear(ud->rflow_map, rm_desc->start,
 				     rm_desc->num);
 			dev_dbg(dev, "ti-sci-res: rflow: %d:%d\n",
 				rm_desc->start, rm_desc->num);
-- 
2.34.1


             reply	other threads:[~2021-12-23 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 13:57 Vignesh Raghavendra [this message]
2022-01-17 18:36 ` [PATCH] dma: ti: k3-udma: Fix rflow reservation for PKTDMA Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211223135730.1285175-1-vigneshr@ti.com \
    --to=vigneshr@ti.com \
    --cc=grygorii.strashko@ti.com \
    --cc=praneeth@ti.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox