Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Paul Cercueil and committed by
Vinod Koul
74609e56 5878853f

+40
+40
drivers/dma/dma-axi-dmac.c
··· 620 620 return sg; 621 621 } 622 622 623 + static struct dma_async_tx_descriptor * 624 + axi_dmac_prep_peripheral_dma_vec(struct dma_chan *c, const struct dma_vec *vecs, 625 + size_t nb, enum dma_transfer_direction direction, 626 + unsigned long flags) 627 + { 628 + struct axi_dmac_chan *chan = to_axi_dmac_chan(c); 629 + struct axi_dmac_desc *desc; 630 + unsigned int num_sgs = 0; 631 + struct axi_dmac_sg *dsg; 632 + size_t i; 633 + 634 + if (direction != chan->direction) 635 + return NULL; 636 + 637 + for (i = 0; i < nb; i++) 638 + num_sgs += DIV_ROUND_UP(vecs[i].len, chan->max_length); 639 + 640 + desc = axi_dmac_alloc_desc(chan, num_sgs); 641 + if (!desc) 642 + return NULL; 643 + 644 + dsg = desc->sg; 645 + 646 + for (i = 0; i < nb; i++) { 647 + if (!axi_dmac_check_addr(chan, vecs[i].addr) || 648 + !axi_dmac_check_len(chan, vecs[i].len)) { 649 + kfree(desc); 650 + return NULL; 651 + } 652 + 653 + dsg = axi_dmac_fill_linear_sg(chan, direction, vecs[i].addr, 1, 654 + vecs[i].len, dsg); 655 + } 656 + 657 + desc->cyclic = false; 658 + 659 + return vchan_tx_prep(&chan->vchan, &desc->vdesc, flags); 660 + } 661 + 623 662 static struct dma_async_tx_descriptor *axi_dmac_prep_slave_sg( 624 663 struct dma_chan *c, struct scatterlist *sgl, 625 664 unsigned int sg_len, enum dma_transfer_direction direction, ··· 1100 1061 dma_dev->device_tx_status = dma_cookie_status; 1101 1062 dma_dev->device_issue_pending = axi_dmac_issue_pending; 1102 1063 dma_dev->device_prep_slave_sg = axi_dmac_prep_slave_sg; 1064 + dma_dev->device_prep_peripheral_dma_vec = axi_dmac_prep_peripheral_dma_vec; 1103 1065 dma_dev->device_prep_dma_cyclic = axi_dmac_prep_dma_cyclic; 1104 1066 dma_dev->device_prep_interleaved_dma = axi_dmac_prep_interleaved; 1105 1067 dma_dev->device_terminate_all = axi_dmac_terminate_all;