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.

Syslink failure Assertion

I'm suddenly getting a failure assertion from HeapMemMP_create():

Assertion at Line no: 385 in /swcoe/sdk/cm/netra/arago-tmp/work/dm816x-evm-none-
linux-gnueabi/ti-syslink-02_00_00_68-r3i/syslink_02_00_00_68_beta1/ti/syslink/ut
ils/hlos/knl/Linux/../../../../../../ti/syslink/ipc/hlos/knl/Linux/HeapMemMPDrv.
c: (cargs.args.create.handle != NULL) : failed

Here is the code:

/*
Setup a heap for messages
Inputs:
theInfo        :      Pointer to the message info set by the DSP
*/
HeapMemMP_Handle initializeMessageheap(App_Info *theInfo)
{
  Int32               status  = 0;
  UInt16              procId;
  SizeT               heapSize = 0;
  HeapMemMP_Params    heapMemParams;
  HeapMemMP_Handle    heapMH = NULL;
  IHeap_Handle        srHeap = NULL;
  Ptr                 ptr = NULL;
 
  procId = MultiProc_getId ("DSP");

  /* Create Heap and register it with MessageQ */
  Osal_printf("Creating the heap\n");
  HeapMemMP_Params_init (&heapMemParams);

  heapMemParams.sharedAddr = NULL;
  heapSize = HeapMemMP_sharedMemReq (&heapMemParams)
    + 2*(theInfo->numQueues * sizeof(MSG2));
  //get a handle to the shared heap in region 0
  srHeap = SharedRegion_getHeap (REGIONID0);
  if (srHeap == NULL) {

    Osal_printf ("SharedRegion_getHeap failed for %d processor\n", procId);
    return(NULL);
  }

  ptr = Memory_alloc (srHeap,
                      heapSize,
                      0,
                      NULL);
  if (ptr == NULL) {

    Osal_printf ("Memory_alloc failed for %d processor\n", procId);
    return(NULL);
  }
  //messages use region 0
  heapMemParams.name           = theInfo->heapName;
  heapMemParams.regionId       = REGIONID0;
  heapMemParams.sharedAddr     = ptr;
  heapMemParams.sharedBufSize  = heapSize;

  heapMH = HeapMemMP_create (&heapMemParams);
  if (heapMH == NULL) {

    Osal_printf ("HeapMemMP_create failed for %d processor\n", procId);
    return(NULL);
  }
 
  /* Register this heap */
  Osal_printf ("Registering heapId %d with MessageQ for procId: %d\n",
                     theInfo->heapId,
                     procId);
  MessageQ_registerHeap (&heapMH, theInfo->heapId);
 
  return(heapMH);
}

HeapMemMP_create is returning NULL.  REGIONID0=0, theInfo->heapid=0, and the heap size is 2088 bytes, there is more than enough space in shared region 0.

Any idea what is wrong?

Lee Holeva

 

  • Lee Holeva said:

      ptr = Memory_alloc (srHeap,
                          heapSize,
                          0,
                          NULL);
      ...
      //messages use region 0
      heapMemParams.name           = theInfo->heapName;
      heapMemParams.regionId       = REGIONID0;
      heapMemParams.sharedAddr     = ptr;
      heapMemParams.sharedBufSize  = heapSize;

    My guess is that the sharedAddr is not aligned to the SharedRegion's cache line size.  It needs to be so aligned, and you're passing 0 for the Memory_alloc() alignment.  Note the following code in HeapMemMP.c:
                            else if (  ((UInt32) params->sharedAddr
                                     % SharedRegion_getCacheLineSize (obj->regionId)
                                     != 0)) {
                                status = HeapMemMP_E_FAIL;
                                /*! @retval HeapMemMP_E_FAIL params->sharedAddr does
                                            not meet cache alignment constraints */
                                GT_setFailureReason (curTrace,
                                             GT_4CLASS,
                                             "_ListMP_create",
                                             status,
                                             "params->sharedAddr does not"
                                             " meet cache alignment constraints!");

    However, I believe your code can be simplified.  In fact, when sharedAddr is non-NULL regionId is a "don't care" and will be assigned for the created instance by HeapMemMP_create().  Note this code that exists just above the code listed above:
                        if (params->sharedAddr == NULL) {
                            /* Creating using a shared region ID */
                            /* It is allowed to have NULL name for an anonymous, not
                             * to be opened by name, heap.
                             */
                            obj->attrs = NULL; /* Will be alloced in postInit */
                            obj->regionId = params->regionId;
                        }
                        else {
                            /* Creating using sharedAddr */
                            obj->regionId = SharedRegion_getId (params->sharedAddr);

    Your code allocates the memory block to be used by the HeapMemMP instance from Shared Region 0, but you can instead have HeapMemMP do the allocation from that region 0 for you, by setting regionId to 0 and passing sharedAddr as NULL.  Note this comment from ti/ipc/HeapMemMP.h:
        Ptr sharedAddr;
        /*!< Physical address of the shared memory
         *
         *  This value can be left as 'null' unless it is required to place the
         *  heap at a specific location in shared memory.  If sharedAddr is null,
         *  then shared memory for a new instance will be allocated from the
         *  heap belonging to the region identified by
         *  #HeapMemMP_Params::regionId.
         */

    Regards,

    - Rob

  • Robert Tivy said:
    However, I believe your code can be simplified. 

    You're correct, a simiplication is possible.  I changed the code to:

    /*
    Setup a heap for messages
    Inputs:
    theInfo        :      Pointer to the message info set by the DSP
    */
    HeapMemMP_Handle initializeMessageheap(App_Info *theInfo)
    {
      Int32               status  = 0;
      UInt16              procId;
      SizeT               heapSize = 0;
      HeapMemMP_Params    heapMemParams;
      HeapMemMP_Handle    heapHandle;
     
      procId = MultiProc_getId ("DSP");

      /* Create Heap and register it with MessageQ */
      Osal_printf("Creating the heap\n");

      HeapMemMP_Params_init (&heapMemParams);
      heapMemParams.sharedAddr = NULL;
      heapSize = MESSAGEHEAPSIZE;

      heapMemParams.name          = theInfo->heapName;
      heapMemParams.regionId      = REGIONID0;
      heapMemParams.sharedBufSize = heapSize;
      heapHandle = HeapMemMP_create (&heapMemParams);
      if (heapHandle == NULL) {

        Osal_printf ("HeapMemMP_create failed for %d processor\n",
                                     procId);
        return(NULL);
      }

      /* Register this heap */
      Osal_printf ("Registering heapId %d with MessageQ for procId: %d\n",
                         theInfo->heapId,
                         procId);
      //MessageQ_registerHeap (&heapMH, theInfo->heapId);
      status = MessageQ_registerHeap (heapHandle, theInfo->heapId);
      if (status != MessageQ_S_SUCCESS){

        Osal_printf("Error: heap registration failure for heapId %d\n", theInfo->heapId);
        return(NULL);
      }

      return(heapHandle);
    }

    I set MESSAGEHEAPSIZE = 4096 and the failure assertion went away.

    Lee Holeva