AnsweredAssumed Answered

imx6ull v4l2 slow memcpy for captured memory

Question asked by Andrej Kostrov on Aug 27, 2018
Latest reply on Aug 30, 2018 by Yuri Muhin



I'm using EVK with imx6ull with connected mt9j003 sensor. I developed the driver for support mt9j003 and it works together with mx6s_capture driver. used linux kernel is linux-imx-4.9.88. I have to update the kernel because of bugs in Ethernet driver.


Now I can capture the images and save it as file or transfer it over USB to host PC. But I found that my framerate is too low(about 2 FPS but expected 4 FPS). Then I measured the times necessary for every operation. I captured the on the mt9j003 generated test pattern in full resolution 10Mpix. The capturing is as expected was with about 4 FPS possible and the bottleneck was the memcpy. For 10 Mbyte it needs over 250 ms! To access the video buffers I used the mmap way.

Reading of many threads in internet confirm my suspicion the over mmap allocated memory are not cached and the access to that memory is very slow. I didn't found any solution for that problem but proposed workaround to use UESRPTR method. I test this way but it does not work as expected. First I got the errno -22 on VIDIOC_QBUF call. After I replaced the malloc to memalign like:
//        buffers[n_buffers].start = malloc(buffer_size);
        buffers[n_buffers].start = memalign(page_size,buffer_size);
I got  another error -14 bad address and a message "contiguous mapping is too small 4096/10444800". Probably the user allocated memory is fragmented in physical memory and DMA can't work with this type of memory.


Now I don't know what can I do to get the fast memcpy of captured frame fast. Because the 250 ms for 10 Mbyte is 40 Mbyte/sec. The 8051 may be is faster then imx6...