This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: DMA memory allocation fails with dmabuf

Part Number: AM5728

Hi,

We are encoding Full HD data using ducatih264enc. We are providing 1920x1080@60,YUYV16bit data from fpga to AM5728 evk.
Since data format is YUYV, so we are using vpe plugin to convert data into NV12 before feeding to encoder.

pipeline flow is as below:

fpga    ----------->    vip  ----------->    vpe  ---------->  ducatih264enc  --------->   filesink
            YUYV                 YUYV                  NV12                                 mp4

We are using following command:

gst-launch-1.0 -e v4l2src device=/dev/video1 io-mode=4 ! \
'video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, framerate=(fraction)60/1' ! \
vpe num-input-buffers=8 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! queue ! ducatih264enc level=level-51 profile=high ! queue ! h264parse ! mp4mux ! filesink location=temp.mp4

The above pipeline works fine for few minutes. After that, the memory allocation fails as per following log

root@am57xx-evm:~# [ 2629.912733] vip 48990000.vip: dma_alloc_coherent of size 4149248 failed

** (gst-launch-1.0:1151): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed

** (gst-launch-1.0:1151): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed

** (gst-launch-1.0:1151): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed

** (gst-launch-1.0:1151): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.
Additional debug info:
../../../../gstreamer-1.8.3/libs/gst/base/gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason error (-5)
EOS on shutdown enabled -- waiting for EOS after Error
Waiting for EOS...
Got EOS from element "pipeline0".
EOS received - stopping pipeline...
Execution ended after 0:02:06.188277213
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
[ 2630.106452] *** fpga_s_stream ***
Setting pipeline to NULL ...
Freeing pipeline ...

I increased the cma size(cma=512M) from bootargs, the recording time increased but the error still persists. The following log shows
still 487MB cma memory available when the memory allocation failed
#cat /proc/meminfo
MemTotal: 1866148 kB
MemFree: 1167520 kB
MemAvailable: 1512168 kB
Buffers: 14272 kB
Cached: 369416 kB
SwapCached: 0 kB
Active: 93176 kB
Inactive: 343328 kB
Active(anon): 54540 kB
Inactive(anon): 44440 kB
Active(file): 38636 kB
Inactive(file): 298888 kB
Unevictable: 0 kB
Mlocked: 0 kB
HighTotal: 1307648 kB
HighFree: 779508 kB
LowTotal: 558500 kB
LowFree: 388012 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 8 kB
Writeback: 52 kB
AnonPages: 52812 kB
Mapped: 80644 kB
Shmem: 46168 kB
Slab: 40420 kB
SReclaimable: 26976 kB
SUnreclaim: 13444 kB
KernelStack: 1272 kB
PageTables: 1532 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 933072 kB
Committed_AS: 342940 kB
VmallocTotal: 245760 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 688128 kB
CmaFree: 487020 kB


This issue, I don't find when we use io-mode=5. Since we are getting YUYV data from fpga & duncatih264enc expects data in NV12 format, So we can't set the pad capabilty YUY2, we need to set the pad capability NV12. When we set the capability as NV12, the data is swapped(UYVY) at encoding.

gst-launch-1.0 -e v4l2src device=/dev/video1 io-mode=5 ! 'video/x-raw,format=(string)NV12, width=(int)1920, height=(int)1080, framerate=(fraction)60/1'! ducatih264enc level=level-51 profile=high ! queue ! h264parse ! mp4mux ! filesink location=temp1.mp4

We are using SDK version 04.00.00.04.

Please help us why it is failing for io-mode=4.

Thanks,

Praveen

  • The software team have been notified. They will respond here.
  • Hello,

    Please check this thread:
    e2e.ti.com/.../2292637

    Hope this helps.

    BR
    Margarita
  • Hi,

    I have checked the thread, issue is not resolved there.

    The problem persists there in the thread.

    Regards,
    Praveen
  • Hello,

    Did you apply the patch from the e2e thread in my previous post ?
    Do you observe the issue even with this patch?
    Could you try this pipeline:
    gst-launch-1.0 -v v4l2src device=/dev/video1 num-buffers=1800 io-mode=4 ! 'video/x-raw,format=(string)YUY2,width=1920,height=1080' ! queue ! vpe num-input-buffers=8 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! tee name=t ! queue ! ducatih264enc profile=high level=51 ! queue ! filesink location=test.264 t. ! queue ! kmssink

    BR
    Margarita
  • Hi,

    Thanks for the response. Because of leave here, took some time to reply.

    I have applied the patch. Issue is still there.

    Our requirement is to keep recording until the stop command has been received.  So we are not setting "num-buffers" in our case. The recording should be running for hours.

    I checked with the pipeline sent by you, following is the error log:

    /GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)YUY2\,\ width\=\(int\)1920\,\ he[ 743*

    ight\=\(int\)1080\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\ interlace-mode\=\(string\)progressive\,\ colorimetry\=\(string\)bt601\,\ "

    /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)YUY2\,\ width\=\(int\)1920\,\ h"

    /GstPipeline:pipeline0/GstVpe:vpe0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ height\=\(int\)"

    /GstPipeline:pipeline0/GstCapsFilter:capsfilter1.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ h"

    /GstPipeline:pipeline0/GstTee:t.GstTeePad:src_0: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ height\=\(int"

    /GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ height\=\("

    /GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ height\=\("

    /GstPipeline:pipeline0/GstTee:t.GstTeePad:src_1: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ height\=\(int"

    /GstPipeline:pipeline0/GstDucatiH264Enc:ducatih264enc0.GstPad:src: caps = "video/x-h264\,\ alignment\=\(string\)au\,\ stream-format\="

    /GstPipeline:pipeline0/GstDucatiH264Enc:ducatih264enc0.GstPad:src: caps = "video/x-h264\,\ alignment\=\(string\)au\,\ stream-format\="

    /GstPipeline[ 7434.581077] vip 48990000.vip: dma_alloc_coherent of size 4149248 failed

    :pipeline0/GstDucatiH264Enc:ducatih264enc0.GstPad:src: caps = "video/x-h264\,\ alignment\=\(string\)au\,\ stream-format\=\(string\)by"

    /GstPipeline:pipeline0/GstQueue:queue1.GstPad:sink: caps = "video/x-h264\,\ alignment\=\(string\)au\,\ stream-format\=\(string\)byte-"

    /GstPipeline:pipeline0/GstQueue:queue1.GstPad:sink: caps = "video/x-h264\,\ alignment\=\(string\)au\,\ stream-format\=\(string\)byte-"

    /GstPipeline:pipeline0/GstDucatiH264Enc:ducatih264enc0.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)19"

    /GstPipeline:pipeline0/GstVpe:vpe0.GstPad:src: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ height\=\(int\)"

    /GstPipeline:pipeline0/GstCapsFilter:capsfilter1.GstPad:sink: caps = "video/x-raw\,\ format\=\(string\)NV12\,\ width\=\(int\)1920\,\ "

    /GstPipeline:pipeline0/GstDucatiH264Enc:ducatih264enc0.GstPad:src: caps = "video/x-h264\,\ width\=\(int\)1920\,\ height\=\(int\)1080\"

    /GstPipeline:pipeline0/GstQueue:queue1.GstPad:sink: caps = "video/x-h264\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\ framerate\=\"

    /GstPipeline:pipeline0/GstQueue:queue1.GstPad:src: caps = "video/x-h264\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\ framerate\=\("

    /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = "video/x-h264\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\ framer"

    ** (gst-launch-1.0:1650): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed

    ** (gst-launch-1.0:1650): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed

    ** (gst-launch-1.0:1650): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed

    ** (gst-launch-1.0:1650): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed

    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.

    Additional debug info:

    ../../../../gstreamer-1.8.3/libs/gst/base/gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:

    streaming task paused, reason error (-5)

    Execution ended after 0:00:00.601266750

    Setting pipeline to PAUSED ...

    Setting pipeline to READY ...

    I have increased the cma memory to 512MB. The recording time increased (for 3 hours) but after that it failed. Without setting the cma(default value), the error occurs in an hour.

    We want to run it for hours without the memory allocation failure.  

    Regards,

    Praveen

  • Hello,

    If you replace vpe with videoconvert element do you observe the issue?

    BR
    Margarita
  • Hello,

    I see that you are using ducatih264enc also.
    There is a memory leak in it.
    You could check this thread:
    e2e.ti.com/.../2313451
      Page 2 you could find the patch and the .so file.

    BR
    Margarita

  • Hi,

    By replacing the VPE with videoconvert, the issue does not occurs. It is because in the case of videoconvert, CMA memory is not used.
    Using videoconvert, CPU usage is nearly 100%, and framerate is 7FPS.

    I took the .so file as suggested, but issue still persists.

    Regards,
    Praveen
  • Using the repacker module in VIP, i am able to rearrange the input data in UYVY format.
    So that I can remove the VPE plugin from the pipeline and I can use the io-mode=5; since there is no memory allocation problem in io-mode=5.

    Now I am able to get the expected data without using the VPE. But the Frame rate is comparatively low(43FPS), while with the VPE, I was getting 60FPS.

    Pipeline is as follows:
    gst-launch-1.0 -e v4l2src device=/dev/video1 io-mode=5 num-buffers=50 ! 'video/x-raw,format=(string)NV12, width=(int)1920, height=(int)1080, framerate=(fraction)60/1'! ducatih264enc level=level-51 profile=high ! queue ! h264parse ! mp4mux ! filesink location=temp.mp4

    Can we get the 60FPS without using the VPE?

    Regards,
    Praveen
  • Hi Praveen,

    Please wait for PLSDK 4.1 release.  The issue is taken care in that release. The release is coming soon.

    Regards,

    Manisha