<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: imx6ull v4l2 slow memcpy for captured memory in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826536#M127086</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; the following may be helpful: &lt;A href="https://community.nxp.com/message/536900"&gt;https://community.nxp.com/message/536900&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yuri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 Aug 2018 04:36:15 GMT</pubDate>
    <dc:creator>Yuri</dc:creator>
    <dc:date>2018-08-31T04:36:15Z</dc:date>
    <item>
      <title>imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826529#M127079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;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:&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffers[n_buffers].start = malloc(buffer_size);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffers[n_buffers].start = memalign(page_size,buffer_size);&lt;BR /&gt;I got&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2018 08:45:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826529#M127079</guid>
      <dc:creator>firex</dc:creator>
      <dc:date>2018-08-27T08:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826530#M127080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrej&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one can look at memcpy improvements suggestions on&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/340705"&gt;imx6 running slow&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or try sdma memory copy example&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://source.codeaurora.org/external/imx/imx-test/tree/module_test/mxc_sdma_memcopy_test.c?h=imx_4.9.88_2.0.0_ga" title="https://source.codeaurora.org/external/imx/imx-test/tree/module_test/mxc_sdma_memcopy_test.c?h=imx_4.9.88_2.0.0_ga"&gt;mxc_sdma_memcopy_test.c\module_test - imx-test - i.MX Driver Test Application Software&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2018 08:42:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826530#M127080</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2018-08-28T08:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826531#M127081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Igor,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for your answer. the first link may be helpful, but i have a little other problem. my system runs on expected speed. and copy on malloc memroy runs up to 10 times faster then on mmap memory allocated in /dev/video0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;about the second link. this is a some module that tests the m2m transfer. the example driver on write init 4 wbufs and starts dma transfer from wbufs to rbufs. On read the data will be compared. I don't see how it can help me to copy in video4linux captured frames to other user allocated memory with the same performance as copy from user allocated memory to user allocated memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;may be I don't described my problem good enough? sorry for bad English.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards &lt;BR /&gt;Andrej.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2018 09:32:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826531#M127081</guid>
      <dc:creator>firex</dc:creator>
      <dc:date>2018-08-28T09:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826532#M127082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrej&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as your task is specifc for memcpy improvements may be recommended to use&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.nxp.com/support/support/nxp-professional-services:PROFESSIONAL-SERVICE" title="https://www.nxp.com/support/support/nxp-professional-services:PROFESSIONAL-SERVICE"&gt;NXP Professional Services|NXP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2018 01:22:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826532#M127082</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2018-08-29T01:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826533#M127083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Igor,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for the answer. i don't know what is specific in my question. I want only get the captured image from v4l device make some operations with the image and send it over USB to PC. Send to PC works es expected. Image capturing too, but only the copy the captured v4l frame to the user memory runs 10 times slower as user memory to user memory.&lt;BR /&gt;I try to explain on the othe way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void *buf1,*buf2; // i have two buffers&lt;BR /&gt;const size_t size = 10*1024*1024; // both buffers are 10 Mb&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;case1:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;buf1 = malloc(size);
buf2 = malloc(size);
memcpy(buf1, buf2, size); &lt;STRONG&gt;// this operation is approx 20 ms &lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;case2:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;buf1 = malloc(size);
xioctl(fd, VIDIOC_QUERYBUF, &amp;amp;v4l_buf_struct); // this step is necessary for v4l2 to allocate buffer
buf2 = mmap(NULL,size,PROT_READ | PROT_WRITE,MAP_SHARED,fd,v4l_buf_struct.m.offset); // get memory allocated in v4l2
memcpy(buf1,buf2,size); &lt;STRONG&gt;// this operation needs 250 ms!!!&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrej&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2018 07:19:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826533#M127083</guid>
      <dc:creator>firex</dc:creator>
      <dc:date>2018-08-29T07:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826534#M127084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrej&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;specific are requirements for your task (in particular memcpy implementation),&lt;/P&gt;&lt;P&gt;NXP provides software which does not meet them. Performance requirements, as they&lt;/P&gt;&lt;P&gt;are board specific, are usually supported through NXP Professional Services.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2018 01:15:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826534#M127084</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2018-08-30T01:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826535#M127085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Igor,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for the fast answer. I can confirm, that is a memcpy operation that making a problems, but only with memory allocated by mx6s_capture module. :-) I guess this module is from freescale/nxp. So I tried to ask by NXP :-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The module mx6s_capture provides the v4l2 interface. This module returns the memory that have bad performance to copy it to userspace. I can try to implement for-loop that copies the memory in loop over incremented pointers but I guess the result will be the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the task to copy the captured image to userspace nothing special. ;-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrej.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2018 08:03:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826535#M127085</guid>
      <dc:creator>firex</dc:creator>
      <dc:date>2018-08-30T08:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826536#M127086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; the following may be helpful: &lt;A href="https://community.nxp.com/message/536900"&gt;https://community.nxp.com/message/536900&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Yuri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2018 04:36:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/826536#M127086</guid>
      <dc:creator>Yuri</dc:creator>
      <dc:date>2018-08-31T04:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: imx6ull v4l2 slow memcpy for captured memory</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/1524873#M195359</link>
      <description>Dear firex：&lt;BR /&gt;Have you soloved this problem？</description>
      <pubDate>Tue, 20 Sep 2022 08:52:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx6ull-v4l2-slow-memcpy-for-captured-memory/m-p/1524873#M195359</guid>
      <dc:creator>Jack9</dc:creator>
      <dc:date>2022-09-20T08:52:28Z</dc:date>
    </item>
  </channel>
</rss>

