Skip to contentSkip to conversation

dma: ti: k3-udma: Use ring_idx to pair k3 nav rings

PATCH Superseded MD Danish Anwar 4 participants 4 messages Jan 30, 2024 – Feb 7, 2024

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 dma: ti: k3-udma: Use ring_idx to pair k3 nav rings

Use ring_idx to pair rings. ring_idx will be same as tx flow_id for all non-negative flow_ids. For negative flow_ids, ring_idx will be tchan->id added with bchan_cnt.

---
Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.

v3: https://lore.kernel.org/all/[email protected]/

 drivers/dma/ti/k3-udma.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/dma/ti/k3-udma.c +9 -2
index 8a62d63dfe..eea9ec9659 100644
@@ -876,13 +876,20 @@ static int udma_alloc_tx_resources(struct udma_chan *uc)
 {
 	struct k3_nav_ring_cfg ring_cfg;
 	struct udma_dev *ud = uc->ud;
-	int ret;
+	struct udma_tchan *tchan;
+	int ring_idx, ret;
 
 	ret = udma_get_tchan(uc);
 	if (ret)
 		return ret;
 
-	ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, uc->tchan->id, -1,
+	tchan = uc->tchan;
+	if (tchan->tflow_id >= 0)
+		ring_idx = tchan->tflow_id;
+	else
+		ring_idx = ud->bchan_cnt + tchan->id;
+
+	ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, ring_idx, -1,
 						&uc->tchan->t_ring,
 						&uc->tchan->tc_ring);
 	if (ret) {
Signature · 1 line
2.34.1
Reviewed-by on v4 1/1
#1 lore raw
Quoted 32 lines · MD Danish Anwar

Use ring_idx to pair rings. ring_idx will be same as tx flow_id for all non-negative flow_ids. For negative flow_ids, ring_idx will be tchan->id added with bchan_cnt.

---
Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.

v3: https://lore.kernel.org/all/[email protected]/

 drivers/dma/ti/k3-udma.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/dma/ti/k3-udma.c +2 -2
index 8a62d63dfe..eea9ec9659 100644
@@ -876,13 +876,20 @@ static int udma_alloc_tx_resources(struct udma_chan *uc)
 {
 	struct k3_nav_ring_cfg ring_cfg;
 	struct udma_dev *ud = uc->ud;
-	int ret;
+	struct udma_tchan *tchan;
+	int ring_idx, ret;
 
 	ret = udma_get_tchan(uc);
 	if (ret)
 		return ret;
 
-	ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, uc->tchan->id, -1,

drivers/dma/ti/k3-udma.c static int udma_alloc_tx_resources(struct udma_chan *uc) · line 895

Quoted 10 lines
drivers/dma/ti/k3-udma.c +7 -0
+	tchan = uc->tchan;
+	if (tchan->tflow_id >= 0)
+		ring_idx = tchan->tflow_id;
+	else
+		ring_idx = ud->bchan_cnt + tchan->id;
+
+	ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, ring_idx, -1,
 						&uc->tchan->t_ring,
 						&uc->tchan->tc_ring);
 	if (ret) {

I see this change present in upstream linux kernel as well.
You could consider providing the link to kernel if such changes are already merged there.

#2 lore raw
Quoted 34 lines · Ravi Gunasekaran
Quoted 31 lines · MD Danish Anwar

Use ring_idx to pair rings. ring_idx will be same as tx flow_id for all non-negative flow_ids. For negative flow_ids, ring_idx will be tchan->id added with bchan_cnt.

---
Changes from v3 to v4:
*) No functional change. Splitted the patch out of the series as suggested
by Nishant.

v3: https://lore.kernel.org/all/[email protected]/

 drivers/dma/ti/k3-udma.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/dma/ti/k3-udma.c +2 -1
index 8a62d63dfe..eea9ec9659 100644
@@ -876,13 +876,20 @@ static int udma_alloc_tx_resources(struct udma_chan *uc)
 {
 	struct k3_nav_ring_cfg ring_cfg;
 	struct udma_dev *ud = uc->ud;
-	int ret;
+	struct udma_tchan *tchan;
+	int ring_idx, ret;
 
 	ret = udma_get_tchan(uc);
 	if (ret)
 		return ret;
 
Quoted 15 lines

drivers/dma/ti/k3-udma.c static int udma_alloc_tx_resources(struct udma_chan *uc) · line 895

Quoted 11 lines
drivers/dma/ti/k3-udma.c +7 -1
-	ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, uc->tchan->id, -1,
+	tchan = uc->tchan;
+	if (tchan->tflow_id >= 0)
+		ring_idx = tchan->tflow_id;
+	else
+		ring_idx = ud->bchan_cnt + tchan->id;
+
+	ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, ring_idx, -1,
 						&uc->tchan->t_ring,
 						&uc->tchan->tc_ring);
 	if (ret) {

I see this change present in upstream linux kernel as well.
You could consider providing the link to kernel if such changes are already merged there.

Sure Ravi,

Link to upstream kernel code for the same [1]. Upstream Commit: d2abc982333c02f9e1ff1c6b3782174f5b7662d7

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/dma/ti/k3-udma.c?h=v6.8-rc2#n1686

Quoted 2 lines
Signature · 2 lines
Thanks and Regards,
Md Danish Anwar
#3 lore raw
In reply to MD Danish Anwar
Quoted 7 lines · MD Danish Anwar

Use ring_idx to pair rings. ring_idx will be same as tx flow_id for all non-negative flow_ids. For negative flow_ids, ring_idx will be tchan->id added with bchan_cnt.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom