Part Number:AM5726
Tool/software: Linux
My linux kernel version:
Linux am57xx-evm 4.1.18-rt17 #1 SMP PREEMPT RT Thu Jun 29 11:43:34 DST 2017 armv7l GNU/Linux
My Problem:
time out when do dma from bf800000(DDR)to 24000000(pci 0000:01:00.0: BAR 0: assigned [mem 0x24000000-0x27ffffff])length 256 Bytes
My Code:
static int tx_dma_transfer(struct dma_chan *chan, dma_addr_t dma_dst, dma_addr_t dma_src, size_t len)
{
int rc = -ENODEV;
dma_cookie_t cookie;
struct completion cmp;
enum dma_status status;
enum dma_ctrl_flags flags = 0;
struct dma_slave_config cfg;
struct dma_async_tx_descriptor *tx = NULL;
unsigned long tmo = msecs_to_jiffies(3000);
if(!chan)
goto done;
memset(&cfg, 0, sizeof(cfg));
cfg.direction = DMA_MEM_TO_DEV;
cfg.src_addr = dma_src;
cfg.dst_addr = dma_dst;
cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
cfg.src_maxburst = 16;
cfg.dst_maxburst = 16;
rc = dmaengine_slave_config(chan, &cfg);
if (rc < 0)
goto done;
flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
tx = dmaengine_prep_slave_single(chan, dma_src, len, DMA_MEM_TO_DEV, flags);
if (!tx) {
printk(KERN_ERR "%s: Failed to prepare DMA transfer\n",
__FUNCTION__);
goto done;
}
init_completion(&cmp);
tx->callback = dma_callback;
tx->callback_param = &cmp;
cookie = dmaengine_submit(tx);
if (dma_submit_error(cookie)) {
printk(KERN_ERR "%s: Failed to start DMA transfer\n",
__FUNCTION__);
rc = -ENOMEM;
goto done;
}
dma_async_issue_pending(chan);
tmo = wait_for_completion_timeout(&cmp, tmo);
status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
if (tmo <= 0) {
dmaengine_terminate_all(chan);
printk(KERN_ERR "%s: Transfer timed out\n", __FUNCTION__);
rc = -ETIMEDOUT;
}
if (status != DMA_COMPLETE) {
printk(KERN_ERR "%s: Transfer failed: status is %s\n",
__FUNCTION__,
status == DMA_ERROR ? "error" : "in progress");
dmaengine_terminate_all(chan);
rc = -EIO;
}
done:
return rc;
}debug info after called:
[ 59.429200] edma test from bf800000 to 24000000 len 256
[ 59.434377] edma 43300000.edma: first transfer starting on channel 4
[ 59.440942] edma 43300000.edma: ER0 00000000
[ 59.445232] edma 43300000.edma: EER0 00000010
[ 62.448966] edma 43300000.edma: EER0 00000000
[ 62.453343] tx_dma_transfer: Transfer timed out
[ 62.457892] tx_dma_transfer: Transfer failed: status is in progress
with EDMA