Hi,all:
I read the source code with regarding to PCIE transmitting data via DMA in the Lightning_PCIE_0.8 by Advandtech. I noted that in the routine pcie_drv_dma_mem_alloc the application firstly call dma_alloc_coherent to alloc dma physical addr and dma virtual addr in the driver like below:
dma_buffer_info->buf_info[i].virtAddr = (uint8_t *)dma_alloc_coherent(
&ti667x_pci_dev[dev_id]->dev,
dma_buffer_info->buffer_size,
(dma_addr_t *)&dma_buffer_info->buf_info[i].pcieAddr,
GFP_KERNEL);
Then applicaiont call mmap to remap dma physical addr into dma virtual addr like below:
buf_desc[i].virtAddr = mmap(0,
size_of_buffer,
PROT_READ | PROT_WRITE,
MAP_SHARED,
pcie_drv_inst[dsp_id].dev_desc,
buf_desc[i].pcieAddr);
Why ? Why we need call mmap after dma_alloc_coherent ? As I understand, after I call the dma_alloc_coherent,I have already used dma virtual addr. I can copy to or from that dma virtual address in the user space in my application. When I read and write the dma virtual addr That means I read and write the dma physical address. The content of dma physical address and dma virtual address should be the same.
So, there’s no need to call mmap after dma_alloc_coherent. I think in the dma_alloc_coherent application has remap between dma virtual address and dma physical address. If call mmap again, Doen’t belong to repeat work ? How about your opinion ? thanks!