|
目标是将fpga 挂在的ddr ram中的数据搬移到arm的应用层缓冲区中
参考各位前辈的资料写了1个多通道dma的驱动,现在用的是coherent buffer,没有用dma链,只是根据应用层传的参数按照coherent buffer size分批搬运。现在的速度(双通道,由fpga ram到arm的应用层缓冲)是170MB/s。如果读取arm端预留内存速度大约是450MB/s。比较芯片手册和坊间传说的XGB/s差距很大。
不知道各位大神有没有做过相关的测试,没用dma链是否比较影响速度,求解答。多谢
void dma_callback_func(void *arg)
{
complete((struct completion *)arg);
}
static int timeout = 1000;
int dma_xmit(struct s_dma *p_s_dma)
{
int i = p_s_dma->opt;
// alloc a desc,and set dst_addr,src_addr,data_size.
if((i>=0)&&(i<=NUM_CHANNEL-1))
s_dc[i].tx = s_dc[i].dma_dev->device_prep_dma_memcpy(s_dc[i].chan, s_dc[i].buffer_d_addr, (dma_addr_t)(p_s_dma->p_src), p_s_dma->nxmit, s_dc[i].flags);
else
printk("p_s_dma->opt error\n");
if(!(s_dc[i].tx))
{
printk("Failed to prepare DMA memcpy\n");
return -EFAULT;
}
s_dc[i].tx->callback = dma_callback_func; // 设置回调函数
s_dc[i].tx->callback_param = (void *)&(s_dc[i].dma_complete);
s_dc[i].cookie = dmaengine_submit(s_dc[i].tx); // 上传dma描述符
// static inline dma_cookie_t dmaengine_submit(struct dma_async_tx_descriptor *desc)
// return desc->tx_submit(desc);
// (struct dma_pl330_desc *)desc->txd.tx_submit = pl330_tx_submit;
if(dma_submit_error(s_dc[i].cookie))
{
printk("Failed to do DMA tx_submit\n");
return -EFAULT;
}
dma_async_issue_pending(s_dc[i].chan); // 开始dma传输
// chan->device->device_issue_pending(chan);
if(!wait_for_completion_timeout(&(s_dc[i].dma_complete), msecs_to_jiffies(timeout)))
{
printk("Timeout waiting for TX DMA!\n");
dmaengine_terminate_all(s_dc[i].chan);
return -ETIMEDOUT;
}
return 0;
}
|
|