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.

CMEM errer

Hi everybody,

We are using dvsdk_2_00_00_22 and davinc(dm6446) evm. We faced to CMEM error. The following is error logs.

************************ Start logs ************************

2:mpeg4enc
3:mp- <odu_osd_open>
eg4dec
[DEC] bufSize2 622080
[Loader] read size 1244160
[Loader] readBuf size 3088320
CMEMK Error: get_phys: Unable to find phys addr for 0x8403d843
[DEC] Not first CMEMK Error: get_phys: get_user_pages() failed: -14

field
[DEC] hInCMEMK Error: GETPHYS: Failed to convert virtual 0x8403d843 to physical.
Buf2(903848)hDstBuf2(628792)
CMEM Error: getPhys: Failed to get physical address of 0x8403d843
+ <odu_osd_release>
_ <odu_osd_release>

************************ End logs ************************

And the following is CE_DEBUG=3 logs. 

************************ Start logs ************************

[Loader] read size 1244160
[Loader] readBuf size 3088320
@3,957,415us: [+2 T:0x424da490 S:0x424d9c14] ti.sdo.dmai - [Loader] Creating Loader for /opt/dm6446/test.mpeg4 with buffer size 3088320, window size 1244160, alignment -1
@3,962,021us: [+0 T:0x424da490 S:0x424d9bd4] OM - Memory_alloc> Enter(0x2f1fc0)
@3,962,261us: [+0 T:0x424da490 S:0x424d9b8c] OM - Memory_contigAlloc> Enter(size=3088320, align=-1, cached=FALSE, heap=FALSE)
@3,962,830us: [+4 T:0x424da490 S:0x424d9b8c] OM - Memory_contigAlloc> CMEM_alloc(3088320) = 0x43ff9000.
@3,963,081us: [+4 T:0x424da490 S:0x424d9b8c] OM - Memory_contigAlloc> CMEM_getPhys(0x43ff9000) = 0x87922000.
@3,963,276us: [+1 T:0x424da490 S:0x424d9b44] OM - Memory__addContigBuf> Enter(virtAddr=0x43ff9000, size=3088320, physAddr=0x87922000)
@3,963,459us: [+1 T:0x424da490 S:0x424d9b44] OM - Memory__addContigBuf> creating new contigBuf object
@3,963,622us: [+0 T:0x424da490 S:0x424d9b2c] OM - Memory_alloc> Enter(0x10)
@3,963,797us: [+0 T:0x424da490 S:0x424d9b2c] OM - Memory_alloc> return (0x134d48)
@3,963,961us: [+1 T:0x424da490 S:0x424d9b44] OM - Memory__addContigBuf> returning: cb->phys=0x87922000, cb->size=3088320, cb->virt=0x43ff9000
@3,964,132us: [+0 T:0x424da490 S:0x424d9b8c] OM - Memory_contigAlloc> return (0x43ff9000)
@3,964,292us: [+0 T:0x424da490 S:0x424d9bd4] OM - Memory_alloc> return (0x43ff9000)
@3,964,527us: [+0 T:0x424da490 S:0x424d9bb4] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x43ff9000, size=4)
@3,964,712us: [+1 T:0x424da490 S:0x424d9bb4] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x43ff9000, size=4)
@3,965,008us: [+1 T:0x424da490 S:0x424d9bb4] OM - Memory__getPhysicalAddress> found in cb(Sc=0x43ff9000, Ec=0x442eafc0, Ss=0x43ff9000, Es=0x43ff9004, PSc=0x87922000)
@3,965,245us: [+1 T:0x424da490 S:0x424d9bb4] OM - Memory__getPhysicalAddress> returning physAddr=0x87922000
@3,965,425us: [+0 T:0x424da490 S:0x424d9bb4] OM - Memory_getBufferPhysicalAddress> return (0x87922000)
@3,965,598us: [+2 T:0x424da490 S:0x424d9bec] ti.sdo.dmai - [Buffer] Alloc Buffer of size 3088320 at 0x43ff9000 (0x87922000 phys)
@3,965,802us: [+0 T:0x424da490 S:0x424d9bfc] ti.sdo.ce.osal.Sem - Sem_create> count: 0
@3,965,982us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_alloc> Enter(0x14)
@3,966,167us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_alloc> return (0x134da0)
@3,966,342us: [+0 T:0x424da490 S:0x424d9bfc] ti.sdo.ce.osal.Sem - Leaving Sem_create> sem[0x134da0]
@3,966,517us: [+0 T:0x424da490 S:0x424d9bfc] ti.sdo.ce.osal.Sem - Sem_create> count: 1
@3,966,682us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_alloc> Enter(0x14)
@3,966,860us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_alloc> return (0x134db8)
@3,967,034us: [+0 T:0x424da490 S:0x424d9bfc] ti.sdo.ce.osal.Sem - Leaving Sem_create> sem[0x134db8]
@3,967,210us: [+0 T:0x424da490 S:0x424d9bfc] ti.sdo.ce.osal.Sem - Sem_create> count: 0
@3,967,377us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_alloc> Enter(0x14)
@3,967,560us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_alloc> return (0x134dd0)
@3,967,732us: [+0 T:0x424da490 S:0x424d9bfc] ti.sdo.ce.osal.Sem - Leaving Sem_create> sem[0x134dd0]
@3,989,313us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x43ff9000, size=4)
@3,989,571us: [+1 T:0x424da490 S:0x424d9be4] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x43ff9000, size=4)
@3,989,763us: [+1 T:0x424da490 S:0x424d9be4] OM - Memory__getPhysicalAddress> found in cb(Sc=0x43ff9000, Ec=0x442eafc0, Ss=0x43ff9000, Es=0x43ff9004, PSc=0x87922000)
@3,989,950us: [+1 T:0x424da490 S:0x424d9be4] OM - Memory__getPhysicalAddress> returning physAddr=0x87922000
@3,990,121us: [+0 T:0x424da490 S:0x424d9be4] OM - Memory_getBufferPhysicalAddress> return (0x87922000)
@3,990,292us: [+2 T:0x424da490 S:0x424d9c1c] ti.sdo.dmai - [Buffer] Set user pointer 0x43ff9000 (physical 0x87922000)
@3,990,476us: [+0 T:0x424da490 S:0x424d9c1c] ti.sdo.ce.osal.Sem - Entered Sem_post> sem[0x134da0]
@3,990,671us: [+0 T:0x424da490 S:0x424d9c2c] ti.sdo.ce.osal.Sem - Leaving Sem_post> sem[0x134da0]
[DEC] Not first field
@3,990,950us: [+0 T:0x424da490 S:0x424d92ac] ti.sdo.ce.video2.VIDDEC2 - VIDDEC2_process> Enter (handle=0x85210, inBufs=0x424d93fc, outBufs=0x424d93f0, inArgs=0x424d9c60, outArgs=0x424d94c0)
@3,991,311us: [+5 T:0x424da490 S:0x424d9234] CV - VISA_allocMsg> Allocating message for messageId=0x0003aab0
@3,991,575us: [+0 T:0x424da490 S:0x424d9204] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x43ff9000, size=1244160)
@3,991,781us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x43ff9000, size=1244160)
@3,991,967us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> found in cb(Sc=0x43ff9000, Ec=0x442eafc0, Ss=0x43ff9000, Es=0x44128c00, PSc=0x87922000)
@3,992,156us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> returning physAddr=0x87922000
@3,992,323us: [+0 T:0x424da490 S:0x424d9204] OM - Memory_getBufferPhysicalAddress> return (0x87922000)
@3,992,501us: [+0 T:0x424da490 S:0x424d9204] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x43e63000, size=414720)
@3,992,677us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x43e63000, size=414720)
@3,992,856us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> found in cb(Sc=0x43e63000, Ec=0x43efae00, Ss=0x43e63000, Es=0x43ec8400, PSc=0x875f6000)
@3,993,041us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> returning physAddr=0x875f6000
@3,993,289us: [+0 T:0x424da490 S:0x424d9204] OM - Memory_getBufferPhysicalAddress> return (0x875f6000)
@3,993,481us: [+0 T:0x424da490 S:0x424d9204] OM - Memory_getBufferPhysicalAddress> Enter(virtAddr=0x7f, size=1076320212)
@3,993,667us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> Enter(virtAddr=0x7f, size=1076320212)
@3,993,848us: [+1 T:0x424da490 S:0x424d9204] OM - Memory__getPhysicalAddress> returning physAddr=0x0
@4,011,191us: [+1 T:0x424da490 S:0x424d9204] OM - Memory_getBufferPhysicalAddress> CMEM_getPhys(0x7f) = 0x0.
@4,032,664us: [+0 T:0x424da490 S:0x424d9204] OM - Memory_getBufferPhysicalAddress> return (0x0)
@4,032,904us: [+5 T:0x424da490 S:0x424d921c] CV - VISA_freeMsg(0x85210, 0x42cedc80): Freeing message with messageId=0x0003aab0
@4,033,120us: [+0 T:0x424da490 S:0x424d92ac] ti.sdo.ce.video2.VIDDEC2 - VIDDEC2_process> Exit (handle=0x85210, retVal=0xffffffff)
@4,033,320us: [+2 T:0x424da490 S:0x424d92fc] ti.sdo.dmai - [Vdec2] VIDDEC2_process() ret -1 inId 0 inUse 1264160 consumed 1076320212
@4,033,516us: [+2 T:0x424da490 S:0x424d92fc] ti.sdo.dmai - [Vdec2] VIDDEC2_process() non-fatal error 0x40226a10
@4,045,902us: [+0 T:0x424da490 S:0x424d8e94] OG - Global_exit> enter

************************ End logs ************************

And the following is source codes

************************ Start code ************************

Void *videoThrFxn(Void *arg)
{
    VideoEnv               *envp                = (VideoEnv *) arg;
    Void                   *status              = THREAD_SUCCESS;
    VIDENC1_Params          defaultParams       = Venc1_Params_DEFAULT;
    VIDENC1_DynamicParams   defaultDynParams    = Venc1_DynamicParams_DEFAULT;
    BufferGfx_Attrs         gfxAttrs            = BufferGfx_Attrs_DEFAULT;
    Venc1_Handle            hVe1                = NULL;
    Engine_Handle           hEngine             = NULL;
    BufTab_Handle           hBufTab             = NULL;
    Int                     frameCnt            = 0;
    Buffer_Handle           hCapBuf, hDstBuf;
    VIDENC1_Params         *params;
    VIDENC1_DynamicParams  *dynParams;
#ifdef PLAYBACK
    BufferGfx_Attrs     gfxAttrs2  = BufferGfx_Attrs_DEFAULT;
    Loader_Attrs     lAttrs  = Loader_Attrs_DEFAULT;
    BufTab_Handle     hBufTab2  = NULL;
    VIDDEC2_Params     defaultParams2 = Vdec2_Params_DEFAULT;
    VIDDEC2_DynamicParams   defaultDynParams2 = Vdec2_DynamicParams_DEFAULT;
    Vdec2_Handle     hVd2  = NULL;
    Loader_Handle     hLoader  = NULL;
    Buffer_Handle     hDstBuf2, hInBuf2, hDispBuf2;
    VIDDEC2_Params    *params2;
    VIDDEC2_DynamicParams  *dynParams2;
    Int32      bufSize2;
    Int       ret;
#endif
    Int                     fifoRet;
    Int                     bufIdx;

    // printf("+<V>\n");

    ui93.changedFlag = FALSE;

    /* Open the codec engine */
    hEngine = Engine_open(envp->engineName, NULL, NULL);

    if (hEngine == NULL) {
        ERR("Failed to open codec engine %s\n", envp->engineName);
        cleanup(THREAD_FAILURE);
    }

    /* Use supplied params if any, otherwise use defaults */
    params = envp->params ? envp->params : &defaultParams;
    dynParams = envp->dynParams ? envp->dynParams : &defaultDynParams;

    /* Set up codec parameters */
    params->maxWidth          = envp->imageWidth;
    params->maxHeight         = envp->imageHeight;
    params->inputChromaFormat = XDM_YUV_422ILE;

    /* Set up codec parameters depending on bit rate */
    if (envp->videoBitRate < 0) {
        /* Variable bit rate */
        params->rateControlPreset = IVIDEO_NONE;

        /*
         * If variable bit rate use a bogus bit rate value (> 0)
         * since it will be ignored.
         */
        params->maxBitRate        = 2000000;
    }
    else {
        /* Constant bit rate */
        params->rateControlPreset = IVIDEO_LOW_DELAY;
        params->maxBitRate        = envp->videoBitRate;
    }

    dynParams->targetBitRate = params->maxBitRate;
    dynParams->inputWidth    = params->maxWidth;
    dynParams->inputHeight   = params->maxHeight;

    /* Create the video encoder */
    hVe1 = Venc1_create(hEngine, envp->videoEncoder, params, dynParams);

    if (hVe1 == NULL) {
        ERR("Failed to create video encoder: %s\n", envp->videoEncoder);
        cleanup(THREAD_FAILURE);
    }

    /* Store the output buffer size in the environment */
    envp->outBufSize = Venc1_getOutBufSize(hVe1);

    // printf("V1\n");

    /* Signal that the codec is created and output buffer size available */
    Rendezvous_meet(envp->hRendezvousWriter);

    // printf("V2\n");

    gfxAttrs.colorSpace = ColorSpace_UYVY;
    gfxAttrs.dim.width = envp->imageWidth;
    gfxAttrs.dim.height = envp->imageHeight;
    gfxAttrs.dim.lineLength = BufferGfx_calcLineLength(gfxAttrs.dim.width,
                                                       gfxAttrs.colorSpace);

    /*
     * Ask the codec how much input data it needs and create a table of
     * buffers with this size.
     */
    hBufTab = BufTab_create(NUM_VIDEO_BUFS, Venc1_getInBufSize(hVe1),
                            BufferGfx_getBufferAttrs(&gfxAttrs));

    if (hBufTab == NULL) {
        ERR("Failed to allocate contiguous buffers\n");
        cleanup(THREAD_FAILURE);
    }

    /* Send buffers to the capture thread to be ready for main loop */
    for (bufIdx = 0; bufIdx < NUM_VIDEO_BUFS; bufIdx++) {
        if (Fifo_put(envp->hCaptureInFifo,
                     BufTab_getBuf(hBufTab, bufIdx)) < 0) {
            ERR("Failed to send buffer to display thread\n");
            cleanup(THREAD_FAILURE);
        }
    }

    // printf("V3\n");

#ifdef PLAYBACK
    /* Use supplied params if any, otherwise use defaults */
    params2 = envp->params2 ? envp->params2 : &defaultParams2;
    dynParams2 = envp->dynParams2 ? envp->dynParams2 : &defaultDynParams2;

    // Create the video decoder
    hVd2 = Vdec2_create(hEngine, envp->videoDecoder, params2, dynParams2);

    if (hVd2 == NULL) {
 ERR("[DEC] Failed to create video decoder: %s\n", envp->videoDecoder);
 cleanup(THREAD_FAILURE);
    }

    // Which output buffer size does the codec required?
    bufSize2 = Vdec2_getOutBufSize(hVd2);
    printf("[DEC] bufSize2 %d\n", bufSize2);

    gfxAttrs2.bAttrs.useMask = CODEC_FREE | DISPLAY_FREE;
    gfxAttrs2.colorSpace = ColorSpace_UYVY;
    gfxAttrs2.dim.width = envp->imageWidth;
    gfxAttrs2.dim.height = envp->imageHeight;
    gfxAttrs2.dim.lineLength = BufferGfx_calcLineLength(gfxAttrs.dim.width,
                                                       gfxAttrs.colorSpace);

    // Create a table of buffers for decoded data
    hBufTab2 = BufTab_create(DISPLAY_PIPE_SIZE, bufSize2,
    BufferGfx_getBufferAttrs(&gfxAttrs2));

    if (hBufTab2 == NULL) {
 ERR("[DEC] Failed to create BufTab for display pipe\n");
 cleanup(THREAD_FAILURE);
    }

    // The codec is going to use this BufTab for output buffers
    Vdec2_setBufTab(hVd2, hBufTab2);

    // Ask the codec how much input data it needs
    lAttrs.readSize = Vdec2_getInBufSize(hVd2);
    printf("[Loader] read size %d\n", lAttrs.readSize);

    // Let the loader thread read 300000 bytes extra
    lAttrs.readAhead = 300000;

    // Make the total ring buffer larger
    lAttrs.readBufSize = (lAttrs.readSize + lAttrs.readAhead) * 2;
    printf("[Loader] readBuf size %d\n", lAttrs.readBufSize);

    // Use asynchronous mode since we have a separate loader therad
    lAttrs.async = TRUE;

    // Create the file loader for reading encoded data
    envp->videoFile = "/opt/dm6446/test.mpeg4";
    hLoader = Loader_create(envp->videoFile, &lAttrs);

    if (hLoader == NULL) {
 ERR("[Loader] Failed to create loader for file\n");
 cleanup(THREAD_FAILURE);
    }

    envp->hLoader = hLoader;

prime:
    ret = Dmai_EOK;

    // Prime the file loader
    if (Loader_prime(hLoader, &hInBuf2) < 0) {
 ERR("[DEC] Failed to prime loader for file\n");
 cleanup(THREAD_FAILURE);
    }

    // Prime the display(capture) thread with video buffers
    for (bufIdx = 0; bufIdx < DISPLAY_PIPE_SIZE; bufIdx++) {

 if (ret != Dmai_EFIRSTFIELD) {
     printf("[DEC] Not first field\n");
     // Get free buffer from the BufTab
     hDstBuf2 = BufTab_getFreeBuf(hBufTab2);
     if (hDstBuf2 == NULL) {
  ERR("[DEC] Failed to get free buffer from display pipe BufTab\n");
  cleanup(THREAD_FAILURE);
     }
 }

 // Make sure the whole buffer is used for output
 BufferGfx_resetDimensions(hDstBuf2);

 printf("[DEC] hInBuf2(%d)hDstBuf2(%d)\n", hInBuf2, hDstBuf2);

 // Decode the video buffer
 ret = Vdec2_process(hVd2, hInBuf2, hDstBuf2);                                  <----------- error point

 if (ret < 0) {
     ERR("[DEC] Failed to decode video buffer\n");
     cleanup(THREAD_FAILURE);
 }


    }
#endif

************************ End code ************************

 

 

We don't konw why. Is Our code wrong? Would you give me some information about this issue?

 

Thank you and best regards,

Inchlul.