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.

dma_alloc_coherent problem dm355

Hello all,

My problem has been that I am getting dma_alloc_coherent errors once I try to encode images above 720p resolution (using DM355, dvsdk 3.10, with latest gst-ti release).

I have tried upping mem=x in my kernel bootargs by many precious MB's (even tried using 128 and outputting raw images) but still no luck.

I can easily use videotestsrc to encode 5mp images (2592*1944) but whenever I go above 720p with v4l2src I get the dma_alloc_coherent failed errors (followed by gst's 'failed to mmap: Cannot allocate memory', and then into the segmentation fault)

Has anyone got an idea for a solution?

 

Thanks,

Ernie

  • Ernie,

    v4l2src only works with driver allocated buffer and looks like by default Linux driver reserves memory for D1 buffer and because of that you are able to do D1 mmap without any issues. With this you have two options

    1) Update Linux capture driver to reserve 720P capture buffer. FYI,  latest linux-davinci-staging tree has patch  which can be used to reserve big buffers and have been used on DM365 platform to reserve 720P buffers. May be you can try applying the same patch on your kernel to get this support.

    http://arago-project.org/git/people/?p=sneha/linux-davinci-staging.git;a=commit;h=9247a3aa8a7373a72933ba93263f93ec0c47c6b9

    http://arago-project.org/git/people/?p=sneha/linux-davinci-staging.git;a=commit;h=1003221bc1f8165a25501d43a366ad254063e8a7

    http://arago-project.org/git/people/?p=sneha/linux-davinci-staging.git;a=commit;h=8c51960de35465adb68e212eafdff8ac359b3ee4

    http://arago-project.org/git/people/?p=sneha/linux-davinci-staging.git;a=commit;h=0ee58bcdf4f26357e25b0fc8bd5b136afab1ad60

    http://arago-project.org/git/people/?p=sneha/linux-davinci-staging.git;a=commit;h=1ac38af033f8a394ce8bcbc173c075d3e5d8c489

    Once you have applied the appropriate patches then make sure you reserve the memory by setting the right bootargs. After this v4l2src  should be able to capture 720P buffer without any issues.

    2) Or update v4l2src to work with application allocated buffer (aka USER_PTR).

    You can choose any of the above method to get 720P data from v4l2.  Both of these options have pros and cons.

    Thanks

    Brijesh

  • Hi Brijesh,

    Thanks for your input.

    I am sorry I might have not been clear enough. I have already applied these patches and am able to capture 720p with no problem. The problem begins when I go above that resolution ( in attempt to capture jpegs and such). I tried playing around with the defined sizes and also the bootargs but I am still getting the "vpfe capture: dma_alloc_coherent size xxxx failed"  error (xxxx being the imagesize I am trying to capture) I have tried increasing device_bufsize min_bufsize and setting the bufsize parameter through bootargs but still no luck.

    I am thinking that maybe cont_bufsize and cont_offset might be able to help... Can you give me any info about these to parameters? Are these buffers allocated from the kernel memory pool(mem=*)? Or do these act similar to cmem in that I have to lower the kernel pool to give these more space?

    I tried setting the desired cont_bufsize param with 0 offset but still no luck.

    Any Ideas?

    Thanks again,

    Ernie

     

  • Hello Ernie,

    See below on how memory was layed out on DM365 DVSDK 4.0 default DVSDK setting and as you can see the 6MB is reserved for the capture - which translates to a maximum of 720P buffer. Note that bufSize need to be 1M aligned . While calculating your new resolution requirment make sure bufSize is set probably otherwise system will not able to allocate the request size and may fail with dma_alloc_coherent error message. And this memory gets reserved outsize mem=XX area. And make sure your cmem start address is not overlaping with this video memoy area.

    Hope the picture will give you a bit more clear visibilty:

    Hope this helps.

    Thanks

    Brijesh

  • Hi Brijesh Singh

    i am also facing the same problem while capturing video after 720p resolution. It is showing the following error

     


    davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124
    vpfe-capture vpfe-capture: IPIPE Chained
    vpfe-capture vpfe-capture: Resizer present
    Leopard: switch to HD imager-MT9P031 video input
    vpfe-capture vpfe-capture: dma_alloc_coherent size 3112960 failed
    Segmentation fault

    How to solve this issue. Is there any modification is required in kernel to get the required memory. I have one more question in ur lost post u mention 48mb for kernel and 6mb each for display and capture respectively for that we gave mem=(48+6+6)MB or mem=48MB and start cmem after (48+6+6)MB.

     

     

    Thanks in advance,

    venugopal.


  • Hi again,

     

    First of all thanks that for that info Brijesh it cleared things up for me, and I have been able to get rid of the dma error!

    Now my problem is really strange, I can run these 2 gstreamer pipelineselins:

    1) v4l2src > raw output to file (using a weird resolution because of dm355 ipipe continuous mode limits)

    gst-launch -v v4l2src num-buffers=1 always-copy=false ! 'video/x-raw-yuv,height=1536,width=1344' ! filesink location=2mp_sample_yuv.raw

     

    2) videotestsrc > TIImgenc1 element > output file

    gst-launch -v v4l2src num-buffers=1 always-copy=false ! TIImgenc1 iColorSpace=UYVY oColorSpace=YUV420P qValue=97 ! 'video/x-raw-yuv,height=1536,width=1344' ! filesink location=2mp_sample_yuv.raw

    but when I try to do v4l2src > TIImgenc1 element > outputfile there seems to be no data running in the pipeline because gstreamer hangs after "setting pipeline to playing... newclock:  GstSystemClock"

    any Ideas?

     

    Thanks a bunch for your help so far!

    Ernie

  • venu said:

    Hi Brijesh Singh

    i am also facing the same problem while capturing video after 720p resolution. It is showing the following error

     


    davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124
    vpfe-capture vpfe-capture: IPIPE Chained
    vpfe-capture vpfe-capture: Resizer present
    Leopard: switch to HD imager-MT9P031 video input
    vpfe-capture vpfe-capture: dma_alloc_coherent size 3112960 failed
    Segmentation fault

    How to solve this issue. Is there any modification is required in kernel to get the required memory. I have one more question in ur lost post u mention 48mb for kernel and 6mb each for display and capture respectively for that we gave mem=(48+6+6)MB or mem=48MB and start cmem after (48+6+6)MB.

     

     

    Thanks in advance,

    venugopal.


     

     

    Hi venu,

     

    the correct way is mem=48MB and start cmem after (48+6+6)MB, at least that's what worked for me!

     

    good luck,

    Ernie

  • Ernie,

    I've not tried image enc/dec elements, but do you know if v4l2src is output NV12 or UYVY and make sure that v4l2 is output the exact same color format expected by image enc element.

    Thanks

    Brijesh

  • Hi Brijesh,

     

    Again I am sorry for not being clear enough. I have been able to encode images with lower resolution (up to 720p). When I first tried to increase the resolution I got the dma_alloc errors discussed earlier in this thread. When those were solved I encountered this problem.

    I checked the driver for the sensor and I there isn't a difference in the color format for different resolution (raw bayer, converted to UYVY by the ipipe which is running in continuous mode)

    Thanks,

    Ernie

  • Ernie,

    Okay, can you check the encoder element source to see if there is no hardcoding to limit the resolution. I believe there will be a switch statment to configure codec paramsMaxHeight and paramsMaxWidth. If the maxheight and width is less than what you are giving from v4l2 then its possible that element is still waiting for more or less data.

    Thanks

    Brijesh

  • Hi Brijesh,

    I looked through the code and there doesn't seem to be any hardcoded values to these variables.

    Also, as I mentioned before I am able to run the encoder element with video input from videotestsrc at this resolution (say 1280x1024) just not when the input is coming from v4l2src. I have been able to dump the raw image from v4l2src at this resolution to a file though.

    Combining between these two has given me problems.

    Thanks again for your help,

    Ernie

     

    EDIT: this ended up being something with the ipipe

  • Hello Everyone,

    Sorry to bring this old issue up again, but for some reason I ran into it again.

    Trying to capture images at 5MP (2592x1944) has once again given me the dma_alloc_coherent failed error, but this time I have not been able to solve it by increasing the buffers allocated by vpfe_capture at boot.

    my cont_bufsize is set to 32079872, which is aligned to 1mb and should be more than enough to fit 3 buffers of 2592x1944x2.

    When trying to capture I manage to mmap 1 buffer (mmap offset:0, length 10077696) , but the second one fails (MMAP offset: 10080256, length : 10077696).

    Does anyone have any idea?

     

    Thanks,

    Ernie

  • Hi,

    Bumping this up... Does anyone have any clues?

    Thanks,

    Ernie

  • Hello,

    Giving this another bump.

    I was also looking around and found something about a DMA_CONSISTENT_SIZE and reading somewhere this is capped out at 14 MB for davinci platforms.. is this true?

    Is there any workaround to this limit? (or any other workaround to capture a 5 megapixel image using gstreamer's v4l2src)

    Thanks,

    Ernie

  • Hi,

    I Got how much memory we have to reserved for CMEM and kernel. I have been using LeopardDM368 running With DVSDK4.02. 

    My problem is I am not getting where is the file to allocate memory for CMEM.

    Can you plese provide path to allocate memory for CMEM? or Please suggest me procedure to reserve memory for  CMEM. 

    If I run any Gstreamer pipeline I am facing ERROR like

    dma_alloc_coherent size 532480 failed

     


    Fallowing are the bootarguments which I used

    mmc rescan 0
    setenv bootargs 'console=ttyS0,115200n8  root=/dev/mmcblk0p2 rw ip=off mem=60M  davinci_enc_mngr.ch0_output=COMPOSITE davinci_enc_mngr.ch0_mode=NTSC  vpfe_capture.cont_bufoffset=6291456 vpfe_capture.cont_bufsize=6291456 video=davincifb:vid0=off:vid1=off:osd1=off dm365_imp.oper_mode=0 davinci_capture.device_type=1 rootwait'
    fatload mmc 0 80700000 uImage
    bootm 80700000

  • Dasari,

    I don't understand your question. Are you trying to increase the CMEM memory block? Maybe the following link will help.

    http://processors.wiki.ti.com/index.php/Changing_the_DVEVM_memory_map

    This thread is over three years old. Please start a new thread with your question.

    ~Ramsey