Hi,
I am trying to use the functions to sync the memory buffer so the FPGA can handle the data, but I am getting a segmentation fault when calling the dma_sync_single_for_device function, so I wonder if I am using the wrong parameters,
what is the dma_addr_t dma_handle parameter? is it the physical address? or the virtual address after the mem allocation? I read that the dma_addr_t is not the same as the physical address, or am I missing something before calling the functions, something like doing a dma map before?
switch(cmd){
case MY_SYNC_DEVICE:
//device now owns buffer to read
dma_sync_single_for_device(&d->pdev->dev,
d->my_buf.buf_phys_addr, d->myfx_buf.buf_len,
DMA_TO_DEVICE);
break;
case MY_SYNC_CPU:
//cpu now owns buffer to read
dma_sync_single_for_cpu(&d->pdev->dev, d->my_buf.buf_phys_addr, d->my_buf.buf_len,
DMA_FROM_DEVICE);
break;
default:
dev_err(&d->pdev->dev, "Improper ioctl command %d.\n", cmd);
return -1;
}
--- Quote Start ---
Hmm... I've always allocated all the memory available to the linux system so the kernel has access to all of it. That way, I can allocate as much or as little buffer space in the driver as needed. I'm not sure how to keep memory off-limits to the kernel but still accessible to drivers, is it possible? Sorry, not sure.
--- Quote End ---
What I did was to boot the kernel with the argument mem=896M, so the kernel can only see that memory, then in the kernel module I request access to missing memory by using the request_mem_region function, then from the user app I call the mmap to actual remap the physical region from the kernel to the user app space by using the remap_pfn_range function, so if I call the dma_sync_single_for_device function with the physical start address of that region I get the segmentation fault.
Any advice on how to handle the reserved memory from the booting process, or the reason on getting the segmentation fault?
Thanks.