Skip to content

Commit 4927b1a

Browse files
Peter UjfalusiSantoshShilimkar
authored andcommitted
dmaengine: ti: k3-udma: Switch to k3_ringacc_request_rings_pair
We only request ring pairs via K3 DMA driver, switch to use the new k3_ringacc_request_rings_pair() to simplify the code. Signed-off-by: Peter Ujfalusi <[email protected]> Signed-off-by: Grygorii Strashko <[email protected]> Acked-by: Vinod Koul <[email protected]> Signed-off-by: Santosh Shilimkar <[email protected]>
1 parent 40a2a7c commit 4927b1a

File tree

2 files changed

+24
-52
lines changed

2 files changed

+24
-52
lines changed

drivers/dma/ti/k3-udma-glue.c

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,12 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx_chn(struct device *dev,
271271
atomic_set(&tx_chn->free_pkts, cfg->txcq_cfg.size);
272272

273273
/* request and cfg rings */
274-
tx_chn->ringtx = k3_ringacc_request_ring(tx_chn->common.ringacc,
275-
tx_chn->udma_tchan_id, 0);
276-
if (!tx_chn->ringtx) {
277-
ret = -ENODEV;
278-
dev_err(dev, "Failed to get TX ring %u\n",
279-
tx_chn->udma_tchan_id);
280-
goto err;
281-
}
282-
283-
tx_chn->ringtxcq = k3_ringacc_request_ring(tx_chn->common.ringacc,
284-
-1, 0);
285-
if (!tx_chn->ringtxcq) {
286-
ret = -ENODEV;
287-
dev_err(dev, "Failed to get TXCQ ring\n");
274+
ret = k3_ringacc_request_rings_pair(tx_chn->common.ringacc,
275+
tx_chn->udma_tchan_id, -1,
276+
&tx_chn->ringtx,
277+
&tx_chn->ringtxcq);
278+
if (ret) {
279+
dev_err(dev, "Failed to get TX/TXCQ rings %d\n", ret);
288280
goto err;
289281
}
290282

@@ -587,22 +579,16 @@ static int k3_udma_glue_cfg_rx_flow(struct k3_udma_glue_rx_channel *rx_chn,
587579
}
588580

589581
/* request and cfg rings */
590-
flow->ringrx = k3_ringacc_request_ring(rx_chn->common.ringacc,
591-
flow_cfg->ring_rxq_id, 0);
592-
if (!flow->ringrx) {
593-
ret = -ENODEV;
594-
dev_err(dev, "Failed to get RX ring\n");
582+
ret = k3_ringacc_request_rings_pair(rx_chn->common.ringacc,
583+
flow_cfg->ring_rxq_id,
584+
flow_cfg->ring_rxfdq0_id,
585+
&flow->ringrxfdq,
586+
&flow->ringrx);
587+
if (ret) {
588+
dev_err(dev, "Failed to get RX/RXFDQ rings %d\n", ret);
595589
goto err_rflow_put;
596590
}
597591

598-
flow->ringrxfdq = k3_ringacc_request_ring(rx_chn->common.ringacc,
599-
flow_cfg->ring_rxfdq0_id, 0);
600-
if (!flow->ringrxfdq) {
601-
ret = -ENODEV;
602-
dev_err(dev, "Failed to get RXFDQ ring\n");
603-
goto err_ringrx_free;
604-
}
605-
606592
ret = k3_ringacc_ring_cfg(flow->ringrx, &flow_cfg->rx_cfg);
607593
if (ret) {
608594
dev_err(dev, "Failed to cfg ringrx %d\n", ret);
@@ -673,8 +659,6 @@ static int k3_udma_glue_cfg_rx_flow(struct k3_udma_glue_rx_channel *rx_chn,
673659

674660
err_ringrxfdq_free:
675661
k3_ringacc_ring_free(flow->ringrxfdq);
676-
677-
err_ringrx_free:
678662
k3_ringacc_ring_free(flow->ringrx);
679663

680664
err_rflow_put:

drivers/dma/ti/k3-udma.c

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,17 +1418,12 @@ static int udma_alloc_tx_resources(struct udma_chan *uc)
14181418
if (ret)
14191419
return ret;
14201420

1421-
uc->tchan->t_ring = k3_ringacc_request_ring(ud->ringacc,
1422-
uc->tchan->id, 0);
1423-
if (!uc->tchan->t_ring) {
1424-
ret = -EBUSY;
1425-
goto err_tx_ring;
1426-
}
1427-
1428-
uc->tchan->tc_ring = k3_ringacc_request_ring(ud->ringacc, -1, 0);
1429-
if (!uc->tchan->tc_ring) {
1421+
ret = k3_ringacc_request_rings_pair(ud->ringacc, uc->tchan->id, -1,
1422+
&uc->tchan->t_ring,
1423+
&uc->tchan->tc_ring);
1424+
if (ret) {
14301425
ret = -EBUSY;
1431-
goto err_txc_ring;
1426+
goto err_ring;
14321427
}
14331428

14341429
memset(&ring_cfg, 0, sizeof(ring_cfg));
@@ -1447,10 +1442,9 @@ static int udma_alloc_tx_resources(struct udma_chan *uc)
14471442
err_ringcfg:
14481443
k3_ringacc_ring_free(uc->tchan->tc_ring);
14491444
uc->tchan->tc_ring = NULL;
1450-
err_txc_ring:
14511445
k3_ringacc_ring_free(uc->tchan->t_ring);
14521446
uc->tchan->t_ring = NULL;
1453-
err_tx_ring:
1447+
err_ring:
14541448
udma_put_tchan(uc);
14551449

14561450
return ret;
@@ -1499,16 +1493,11 @@ static int udma_alloc_rx_resources(struct udma_chan *uc)
14991493

15001494
rflow = uc->rflow;
15011495
fd_ring_id = ud->tchan_cnt + ud->echan_cnt + uc->rchan->id;
1502-
rflow->fd_ring = k3_ringacc_request_ring(ud->ringacc, fd_ring_id, 0);
1503-
if (!rflow->fd_ring) {
1504-
ret = -EBUSY;
1505-
goto err_rx_ring;
1506-
}
1507-
1508-
rflow->r_ring = k3_ringacc_request_ring(ud->ringacc, -1, 0);
1509-
if (!rflow->r_ring) {
1496+
ret = k3_ringacc_request_rings_pair(ud->ringacc, fd_ring_id, -1,
1497+
&rflow->fd_ring, &rflow->r_ring);
1498+
if (ret) {
15101499
ret = -EBUSY;
1511-
goto err_rxc_ring;
1500+
goto err_ring;
15121501
}
15131502

15141503
memset(&ring_cfg, 0, sizeof(ring_cfg));
@@ -1533,10 +1522,9 @@ static int udma_alloc_rx_resources(struct udma_chan *uc)
15331522
err_ringcfg:
15341523
k3_ringacc_ring_free(rflow->r_ring);
15351524
rflow->r_ring = NULL;
1536-
err_rxc_ring:
15371525
k3_ringacc_ring_free(rflow->fd_ring);
15381526
rflow->fd_ring = NULL;
1539-
err_rx_ring:
1527+
err_ring:
15401528
udma_put_rflow(uc);
15411529
err_rflow:
15421530
udma_put_rchan(uc);

0 commit comments

Comments
 (0)