CSI capture and USERPTR memory via posix_memalign


I have implemented a new v4l2 sensor driver and all is working fine except when using USERPTR mode with buffers allocated using posix_memalign(buffer, getpagesize(), buffer_size).

The problem I’m seeing appears to be a caching issue. The first N buffers are captured fine (N is the number of buffers sent in via VIDIOC_REQBUFS). After these N buffers are captured (they are recycled by just calling VIDIOC_QBUF with the previous index), the new captures start to have “lines” of 64 bytes of data that appear to be corruption (actually data from previous acquisition).

If I use MMAP or USERPTR (with PINNED memory) there is no such corruption.

Any help would be appreciated.

hello phabsch,

we’re going to investigate this.
may i know why you need USERPTR mode to allocate the buffers?

Thanks for the reply.

The final implementation will be using USERPTR with PIN memory, and can default back to MMAP if need be. USERPTR with posix_memalign() is not a requirement, but understanding the reason for the errors I’m seeing would be great.

Let me know if you need any more information.