--- Quote Start ---
Just one more question, you said that you are using the ioctl calls to sync the buffer when the FPGA is going to handle the data, but according to the driver the buffer is not being cached, am I wrong on that?
I see in the driver code the call to pgprot_noncached and in the user application the MAP_SHARED flag when mapping the buffer.
--- Quote End ---
This driver?
https://github.com/jpendlum/user-peripheral-kmod/blob/master/user_peripheral.c It looks to me like they only do pgprot_noncached for the control registers MMAP_REGS. The buffers MMAP_BUFFS are default which would be cached. If the ACP port is used, everything is fine. But if not, dma_sync_single calls would be needed.
--- Quote Start ---
I noticed that in your code (d->my_buf[arg]) you are using an array of buffers, is that correct? then how are you managing the map requests from multiple map calls?
--- Quote End ---
I'm following the scheme used by the above driver which treats a page offset like a flag, maybe a little kludgy. The driver uses
# define MMAP_REGS 0x1# define MMAP_BUFFS 0x2
And the application does (
https://github.com/jpendlum/zynq-fir-filter-example/blob/master/zynq_fir_filter_example.c)
*control_regs = (unsigned int*)mmap(NULL, *control_length, PROT_READ|PROT_WRITE, MAP_SHARED, *fd, 0x1000); //corresponds to MMAP_REGS
if (control_regs == MAP_FAILED)
{
perror("Error mapping control_regs");
close(*fd);
return(-1);
}
*buff = (unsigned int*)mmap(NULL, *buffer_length, PROT_READ|PROT_WRITE, MAP_SHARED, *fd, 0x2000); //corresponds to MMAP_BUFFS
if (buff == MAP_FAILED)
{
perror("Error mapping buff");
close(*fd);
return(-1);
}
--- Quote Start ---
Also, I have a requested the linux system to only take 850M of my DDR3 SRAM (1G total), so I need in the kernel driver to allocate the last 150M of mem to be used as the buffer, how can I allocate that memory so I can then remap this area later to the user application? And still have the physical address reference there to be used by the FPGA transactions.
--- Quote End ---
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.
Best,