Skip to content

Commit 50318b5

Browse files
pcercueinunojsa
authored andcommitted
dmaengine: dma-axi-dmac: Implement device_prep_peripheral_dma_vec
Add implementation of the .device_prep_peripheral_dma_vec() callback. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Co-developed-by: Nuno Sa <nuno.sa@analog.com> Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240620122726.41232-3-paul@crapouillou.net Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 444cd62 commit 50318b5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

drivers/dma/dma-axi-dmac.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,45 @@ static struct axi_dmac_sg *axi_dmac_fill_linear_sg(struct axi_dmac_chan *chan,
628628
return sg;
629629
}
630630

631+
static struct dma_async_tx_descriptor *
632+
axi_dmac_prep_peripheral_dma_vec(struct dma_chan *c, const struct dma_vec *vecs,
633+
size_t nb, enum dma_transfer_direction direction,
634+
unsigned long flags)
635+
{
636+
struct axi_dmac_chan *chan = to_axi_dmac_chan(c);
637+
struct axi_dmac_desc *desc;
638+
unsigned int num_sgs = 0;
639+
struct axi_dmac_sg *dsg;
640+
size_t i;
641+
642+
if (direction != chan->direction)
643+
return NULL;
644+
645+
for (i = 0; i < nb; i++)
646+
num_sgs += DIV_ROUND_UP(vecs[i].len, chan->max_length);
647+
648+
desc = axi_dmac_alloc_desc(chan, num_sgs);
649+
if (!desc)
650+
return NULL;
651+
652+
dsg = desc->sg;
653+
654+
for (i = 0; i < nb; i++) {
655+
if (!axi_dmac_check_addr(chan, vecs[i].addr) ||
656+
!axi_dmac_check_len(chan, vecs[i].len)) {
657+
kfree(desc);
658+
return NULL;
659+
}
660+
661+
dsg = axi_dmac_fill_linear_sg(chan, direction, vecs[i].addr, 1,
662+
vecs[i].len, dsg);
663+
}
664+
665+
desc->cyclic = false;
666+
667+
return vchan_tx_prep(&chan->vchan, &desc->vdesc, flags);
668+
}
669+
631670
static struct dma_async_tx_descriptor *axi_dmac_prep_slave_sg(
632671
struct dma_chan *c, struct scatterlist *sgl,
633672
unsigned int sg_len, enum dma_transfer_direction direction,
@@ -1082,6 +1121,7 @@ static int axi_dmac_probe(struct platform_device *pdev)
10821121
dma_dev->device_issue_pending = axi_dmac_issue_pending;
10831122
dma_dev->device_prep_slave_sg = axi_dmac_prep_slave_sg;
10841123
dma_dev->device_config = axi_dmac_device_config;
1124+
dma_dev->device_prep_peripheral_dma_vec = axi_dmac_prep_peripheral_dma_vec;
10851125
dma_dev->device_prep_dma_cyclic = axi_dmac_prep_dma_cyclic;
10861126
dma_dev->device_prep_interleaved_dma = axi_dmac_prep_interleaved;
10871127
dma_dev->device_terminate_all = axi_dmac_terminate_all;

0 commit comments

Comments
 (0)