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

dmaengine: bcm2835: add dma_memcopy support to bcm2835-dma

Also added check for an error condition in bcm2835_dma_create_cb_chain
that showed up during development of this patch.

Tested using dmatest for all enabled channels.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Martin Sperl and committed by
Vinod Koul
d9f094a0 388cc7a2

+35 -1
+35 -1
drivers/dma/bcm2835-dma.c
··· 310 310 struct bcm2835_cb_entry *cb_entry; 311 311 struct bcm2835_dma_cb *control_block; 312 312 313 + if (!frames) 314 + return NULL; 315 + 313 316 /* allocate and setup the descriptor. */ 314 317 d = kzalloc(sizeof(*d) + frames * sizeof(struct bcm2835_cb_entry), 315 318 gfp); ··· 600 597 spin_unlock_irqrestore(&c->vc.lock, flags); 601 598 } 602 599 600 + struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( 601 + struct dma_chan *chan, dma_addr_t dst, dma_addr_t src, 602 + size_t len, unsigned long flags) 603 + { 604 + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); 605 + struct bcm2835_desc *d; 606 + u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC; 607 + u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP; 608 + size_t max_len = bcm2835_dma_max_frame_length(c); 609 + size_t frames; 610 + 611 + /* if src, dst or len is not given return with an error */ 612 + if (!src || !dst || !len) 613 + return NULL; 614 + 615 + /* calculate number of frames */ 616 + frames = bcm2835_dma_frames_for_length(len, max_len); 617 + 618 + /* allocate the CB chain - this also fills in the pointers */ 619 + d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false, 620 + info, extra, frames, 621 + src, dst, len, 0, GFP_KERNEL); 622 + if (!d) 623 + return NULL; 624 + 625 + return vchan_tx_prep(&c->vc, &d->vd, flags); 626 + } 627 + 603 628 static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( 604 629 struct dma_chan *chan, 605 630 struct scatterlist *sgl, unsigned int sg_len, ··· 911 880 dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask); 912 881 dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask); 913 882 dma_cap_set(DMA_SLAVE, od->ddev.cap_mask); 883 + dma_cap_set(DMA_MEMCPY, od->ddev.cap_mask); 914 884 od->ddev.device_alloc_chan_resources = bcm2835_dma_alloc_chan_resources; 915 885 od->ddev.device_free_chan_resources = bcm2835_dma_free_chan_resources; 916 886 od->ddev.device_tx_status = bcm2835_dma_tx_status; 917 887 od->ddev.device_issue_pending = bcm2835_dma_issue_pending; 918 888 od->ddev.device_prep_dma_cyclic = bcm2835_dma_prep_dma_cyclic; 919 889 od->ddev.device_prep_slave_sg = bcm2835_dma_prep_slave_sg; 890 + od->ddev.device_prep_dma_memcpy = bcm2835_dma_prep_dma_memcpy; 920 891 od->ddev.device_config = bcm2835_dma_slave_config; 921 892 od->ddev.device_terminate_all = bcm2835_dma_terminate_all; 922 893 od->ddev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); 923 894 od->ddev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); 924 - od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); 895 + od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV) | 896 + BIT(DMA_MEM_TO_MEM); 925 897 od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; 926 898 od->ddev.dev = &pdev->dev; 927 899 INIT_LIST_HEAD(&od->ddev.channels);