7 Replies Latest reply on Apr 23, 2019 2:59 AM by abhinavg_21

    Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.

    ViKu_2048416

      Hi,

      Can anyone explain about the situations on which CyU3PDmaChannelGetBuffer fails with timeout error. One situation I guess is that if host side application fails to clear the buffers in time, it leads to CyU3PDmaChannelGetBuffer failure with timeout error. My doubt is that, Is there any other situations which leads to this error. Please help me to know about the other situations if any.

       

      Thanks in advance,

      Vignesh Kumar R.

        • 1. Re: Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.
          abhinavg_21

          Hi Vignesh,

           

          There are two cases in which CyU3PDmaChannelGetBuffer fails with timeout error:

          1. When all the DMA buffers are committed to consumer side but consumer is not consuming it. In that case producer side has no buffer left to fill and hence timeout error happens due to lack of buffers.

          2. When free buffers are available but producer is not filling it fast enough to make it available to  CyU3PDmaChannelGetBuffer API. in that case timeout error happens due to slow producer.

           

          Thanks & Regards

          Abhinav

          • 2. Re: Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.
            ViKu_2048416

            Hi Abinav,

             

            Thanks for your response, first case is very clear to me. But in second case I am not, because CY_U3P_DMA_CB_PROD_EVENT event only happens after producer fills the buffer, if that is the case we should not get timeout error for CyU3PDmaChannelGetBuffer in CyCx3UvcAppDmaCallback. Is my understanding is correct in this case? Please correct me if I am wrong.

             

            Regards,

            Vignesh Kumar R.

            • 3. Re: Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.
              abhinavg_21

              Hi Vignesh,

               

              Yes you are absolutely right. With each CY_U3P_DMA_CB_PROD_EVENT event, if you are calling CyU3PDmaChannelGetBuffer only once then it should not timeout, but if you are calling this API more than once then it may timeout due to the above mentioned reason.

               

               

              Thanks & Regrads

              Abhinav Garg

               

               

              • 4. Re: Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.
                ViKu_2048416

                Hi Abhinav,

                 

                Thanks for the clarification, but in our case the behavior is strange, we are calling CyU3PDmaChannelGetBuffer only one time  in CyU3PUvcAppDmaCallback once the producer event occurred but even after this CyU3PDmaChannelGetBuffer fails with timeout error what might be the reason for this kind of failure. The code flow will be like below,

                 

                CyU3PUvcAppDmaCallback()

                {

                 

                if(event = CY_U3P_DMA_CB_PROD_EVENT)

                {

                status = CyU3PDmaChannelGetBuffer(parameters);

                }

                 

                }

                 

                Thanks and Regards,

                Vignesh Kumar R.

                • 5. Re: Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.
                  abhinavg_21

                  Hi Vignesh,

                   

                  I suspect that the following API in the implementation of CyU3PDmaChannelGetBuffer() is failing.

                  status = CyU3PEventGet (&(handle->flags), (CY_U3P_DMA_CB_PROD_EVENT |

                                          CY_U3P_DMA_CB_ABORTED | CY_U3P_DMA_CB_ERROR), CYU3P_EVENT_OR,

                                      &flags, waitOption);

                              if (status != CY_U3P_SUCCESS)

                              {

                                  return CY_U3P_ERROR_TIMEOUT;

                              }

                   

                  Try to increase the value of last parameter of CyU3PDmaChannelGetBuffer() API, which will decide the timeout for this API. See if there is any change.

                  Also second step is to check the "flags" status which is present in the DMA channel "handle" and check if "CY_U3P_DMA_CB_PROD_EVENT" is signaled or not.

                   

                  Thanks & Regards
                  Abhinav Garg

                  • 6. Re: Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.
                    ViKu_2048416

                    Hi Abhinav,

                     

                    Thanks for your response, we create the DMA channel with the following parameters,

                     

                    /* Create a DMA Manual OUT channel for streaming data */

                    /* Video streaming Channel is not active till a stream request is received */

                    dmaCfg.size                 = CX3_UVC_STREAM_BUF_SIZE;

                    dmaCfg.count                = CX3_UVC_STREAM_BUF_COUNT;

                    dmaCfg.validSckCount        = 2;

                     

                     

                    dmaCfg.prodSckId[0]         = CX3_PRODUCER_PPORT_SOCKET_0;

                    dmaCfg.prodSckId[1]         = CX3_PRODUCER_PPORT_SOCKET_1;

                     

                     

                    dmaCfg.consSckId[0]         = CX3_EP_VIDEO_CONS_SOCKET;

                    dmaCfg.dmaMode              = CY_U3P_DMA_MODE_BYTE;

                    dmaCfg.notification         = CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_CONS_EVENT;

                    dmaCfg.cb                   = CyCx3UvcAppDmaCallback;

                    dmaCfg.prodHeader           = CX3_UVC_PROD_HEADER;

                    dmaCfg.prodFooter           = CX3_UVC_PROD_FOOTER;

                    dmaCfg.consHeader           = 0;

                    dmaCfg.prodAvailCount       = 0;

                     

                     

                    status = CyU3PDmaMultiChannelCreate (&glChHandleUVCStream,

                    CY_U3P_DMA_TYPE_MANUAL_MANY_TO_ONE , &dmaCfg);

                    if (status != CY_U3P_SUCCESS)

                    {

                    CyU3PDebugPrint (4, "\n\r AppInit:DmaMultiChannelCreate Err = 0x%x", status);

                    }

                     

                    With reference to the above parameters, CyCx3UvcAppDmaCallback will be called one and only if CY_U3P_DMA_CB_PROD_EVENT or CY_U3P_DMA_CB_CONS_EVENT occurs. So it is sure that the get buffer API called only after producer event occurred.

                     

                    I have a doubt in increasing the timeout, we are calling the get buffer API only after a buffer got filled. So it should be passed with CYU3P_NO_WAIT option itself. Please comment on my observations.

                     

                    Regards,

                    Vignesh Kumar R.

                    • 7. Re: Reasons for CyU3PDmaChannelGetBuffer failure with timeout error in FX3/CX3.
                      abhinavg_21

                      Hi Vignesh,

                       

                      Yes you are right there is no need for adding timeout. Please check your firmware, how many times you are calling CyU3PDmaChannelGetBuffer()  API in one producer event call. Please mention which firmware example you are using as a base?

                       

                      Thanks & Regards

                      Abhinav Garg