linux - ping pong DMA in kernel -


i using soc dma data programmable logic side (pl) processor side (ps). overall scheme allocate 2 separate dma buffers , ping-pong data these buffers user-space application can access data without collisions. have done using single dma transactions in loop (in kthread) each transaction either on first or second buffer. able notify poll() method of either first or second buffer.

now investigate scatter-gather and/or cyclic dma.

struct scatterlist      sg[2] struct dma_async_tx_descriptor *chan_desc; struct dma_slave_config config;  sg_init_table(sg, array_size(sg));  addr_0 = (unsigned int *)dma_alloc_coherent(null, dma_size, &handle_0, gfp_kernel); addr_1 = (unsigned int *)dma_alloc_coherent(null, dma_size, &handle_1, gfp_kernel);  sg_dma_address(&sg[0]) = handle_0; sg_dma_len(&sg[0]) = dma_size; sg_dma_address(&sg[1]) = handle_1; sg_dma_len(&sg[1]) = dma_size;  memset(&config, 0, sizeof(config)); config.direction = dma_dev_to_mem; config.dst_addr_width = dma_slave_buswidth_4_bytes; config.src_maxburst = dma_max_burst_size / dma_slave_buswidth_4_bytes; dmaengine_slave_config(dma_dev->chan, &config); chan_desc = dmaengine_prep_slave_sg(dma_dev->chan, &sg[0], 2, dma_dev_to_mem, dma_ctrl_ack | dma_prep_interrupt);  chan_desc->callback = sync_callback; chan_desc->callback_param = dma_dev->cmp; init_completion(dma_dev->cmp);  dmaengine_submit(chan_desc); dma_async_issue_pending(dma_dev->chan);  dma_free_coherent(null, dma_size, addr_0, handle_0); dma_free_coherent(null, dma_size, addr_1, handle_1); 

this works fine single run through scatterlist , calls call_back @ sync_callback. thought chain scatterlist in loop won't callback.

is there way have callback each descriptor in scatterlist? wondered if use dmaengine_prep_slave_cyclic (calls callback after every transaction) looks me single buffer when reviewing dmaengine.h. looking @ dma engine api guide looks there option dmaengine_prep_interleaved_dma using dma_interleaved_template sounds interesting hard find info about.

in end want signal user space in manner buffer ready.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -