In my driver, I have a certain number of physically contiguous DMA buffers (e.g. 4 MB each) for receiving data from the device. They are processed by hardware using the SG list. Since the received data will be subjected to intensive processing, I do not want to disable the cache, and I will use dma_sync_single_for_cpu after each buffer is filled with DMA.
To simplify data processing, I want these buffers to appear as one huge, continuous circular buffer in user space. In the case of a single buffer, I just use remap_pfn_range or dma_mmap_coherent . However, I cannot use these functions several times to match sequential buffers.
Of course, I can implement the crash operation in vm_operations to find the pfn of the corresponding page in the right buffer and paste it into vma using vm_insert_pfn .
The acquisition will be very fast, so I cannot process the display when real data arrives. But this can be easily solved. So that the entire display is ready before the start of data collection, I can simply read the entire mmapped buffer in my application before the start of the collection, so that all pages are already inserted when the first data arrives.
An error-based trio should work, but maybe there is something more elegant? Only one function that can be called several times to gradually build the entire display?
An additional difficulty is that the solution must be applicable (with minimal adjustments) to the kernels, starting from 2.6.32 to the latest.
PS. . , - mmapped- ( ), COW?