misrac fix 2 for 4.2.0 (PRSDK-3354)
authorSuraj Das <s-das@ti.com>
Mon, 11 Dec 2017 19:30:55 +0000 (14:30 -0500)
committerSuraj Das <s-das@ti.com>
Mon, 11 Dec 2017 19:38:28 +0000 (14:38 -0500)
packages/ti/sdo/edma3/drv/src/edma3_drv_adv.c
packages/ti/sdo/edma3/drv/src/edma3_drv_basic.c
packages/ti/sdo/edma3/rm/src/edma3resmgr.c

index f8f380887907271e68e6a1b1573b8921d2d0367d..55edc54e4a76056e1441d56fde0b5d34c1a5a139 100755 (executable)
@@ -213,7 +213,9 @@ EDMA3_DRV_Result EDMA3_DRV_linkChannel (EDMA3_DRV_Handle hEdma,
 #endif
     }
 
-       if (EDMA3_DRV_SOK == result)
+    if (EDMA3_DRV_SOK == result)
+    {
+        if((lCh1 < EDMA3_MAX_LOGICAL_CH) && (lCh2 < EDMA3_MAX_LOGICAL_CH))
         {
         paRAM1Id = edma3DrvChBoundRes[edma3Id][lCh1].paRAMId;
         paRAM2Id = edma3DrvChBoundRes[edma3Id][lCh2].paRAMId;
@@ -227,7 +229,12 @@ EDMA3_DRV_Result EDMA3_DRV_linkChannel (EDMA3_DRV_Handle hEdma,
             {
             result = EDMA3_DRV_E_INVALID_PARAM;
             }
-               }
+        }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
     if (result == EDMA3_DRV_SOK)
         {
@@ -327,27 +334,34 @@ EDMA3_DRV_Result EDMA3_DRV_unlinkChannel (EDMA3_DRV_Handle hEdma, uint32_t lCh)
 #endif
     }
 
-       if (EDMA3_DRV_SOK == result)
+    if (EDMA3_DRV_SOK == result)
+    {
+        if(lCh < EDMA3_MAX_LOGICAL_CH)
         {
-        paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
-        if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
+            paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
+            if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
             {
-            result = EDMA3_DRV_E_INVALID_PARAM;
+                result = EDMA3_DRV_E_INVALID_PARAM;
             }
-               else
-               {
-               /* Get the Link-bcntReload PaRAM set entry */
-               linkBcntReld = (uint32_t)(*((&globalRegs->PARAMENTRY [paRAMId].OPT)
-                                                       + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD));
+            else
+            {
+                /* Get the Link-bcntReload PaRAM set entry */
+                linkBcntReld = (uint32_t)(*((&globalRegs->PARAMENTRY [paRAMId].OPT)
+                                                    + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD));
 
-               /* Remove any linking */
-               linkBcntReld |= 0xFFFFU;
+                /* Remove any linking */
+                linkBcntReld |= 0xFFFFU;
 
-               /* Store it back */
-               *((&globalRegs->PARAMENTRY[paRAMId].OPT)
-                           + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD) = linkBcntReld;
-               }
-               }
+                /* Store it back */
+                *((&globalRegs->PARAMENTRY[paRAMId].OPT)
+                            + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD) = linkBcntReld;
+            }
+        }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
 #ifdef EDMA3_INSTRUMENTATION_ENABLED
     EDMA3_LOG_EVENT(&DVTEvent_Log,"EDMA3",
@@ -790,14 +804,21 @@ EDMA3_DRV_Result EDMA3_DRV_getPaRAM (EDMA3_DRV_Handle hEdma,
         }
 #endif
     }
-       if (EDMA3_DRV_SOK == result)
+    if (EDMA3_DRV_SOK == result)
+    {
+        if(lCh < EDMA3_MAX_LOGICAL_CH)
         {
-        paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
-        if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
+            paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
+            if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
             {
-            result = EDMA3_DRV_E_INVALID_PARAM;
+                result = EDMA3_DRV_E_INVALID_PARAM;
             }
-               }
+        }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
     if (result == EDMA3_DRV_SOK)
         {
@@ -874,18 +895,25 @@ EDMA3_DRV_Result EDMA3_DRV_setPaRAMEntry (EDMA3_DRV_Handle hEdma,
 #endif
     }
     if (EDMA3_DRV_SOK == result)
+    {
+        if(lCh < EDMA3_MAX_LOGICAL_CH)
         {
-        paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
-        if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
+            paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
+            if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
             {
             result = EDMA3_DRV_E_INVALID_PARAM;
             }
-        else
+            else
             {
             *((&globalRegs->PARAMENTRY[paRAMId].OPT) +
                                        (uint32_t)paRAMEntry) = newPaRAMEntryVal;
             }
-               }
+       }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
 #ifdef EDMA3_INSTRUMENTATION_ENABLED
     EDMA3_LOG_EVENT(&DVTEvent_Log,"EDMA3",
index 5d5123003921073bda05cb56264f14f00922acbd..2a6ab6e155c0a32f2f4645c8272e49596810e663 100755 (executable)
@@ -727,89 +727,92 @@ EDMA3_DRV_Result EDMA3_DRV_freeChannel (EDMA3_DRV_Handle hEdma,
 
 
     if (EDMA3_DRV_SOK == result)
+    {
+        if(channelId < EDMA3_MAX_LOGICAL_CH)
         {
-        if (chType == EDMA3_DRV_CHANNEL_TYPE_LINK)
-            {
-            /* LINK Channel */
-            resObj.type = EDMA3_RM_RES_PARAM_SET;
+            if (chType == EDMA3_DRV_CHANNEL_TYPE_LINK)
+                {
+                /* LINK Channel */
+                resObj.type = EDMA3_RM_RES_PARAM_SET;
 
-            /* Get the PaRAM id from the book-keeping info. */
-            resObj.resId = (uint32_t)(edma3DrvChBoundRes[edma3Id][channelId].paRAMId);
+                /* Get the PaRAM id from the book-keeping info. */
+                resObj.resId = (uint32_t)(edma3DrvChBoundRes[edma3Id][channelId].paRAMId);
 
-            result = EDMA3_RM_freeResource(drvInst->resMgrInstance,
-                                        (EDMA3_RM_ResDesc *)&resObj);
+                result = EDMA3_RM_freeResource(drvInst->resMgrInstance,
+                                            (EDMA3_RM_ResDesc *)&resObj);
 
-            if (EDMA3_DRV_SOK == result)
-                {
-                edma3DrvChBoundRes[edma3Id][channelId].paRAMId = -1;
-                }
-            }
-        else
-            {
-            /* DMA/QDMA Channel */
-            paRAMId = edma3DrvChBoundRes[edma3Id][channelId].paRAMId;
-            tcc = edma3DrvChBoundRes[edma3Id][channelId].tcc;
-
-            /* Check the paRAMId and tcc values first */
-            if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
-                {
-                result = EDMA3_DRV_E_INVALID_PARAM;
+                if (EDMA3_DRV_SOK == result)
+                    {
+                    edma3DrvChBoundRes[edma3Id][channelId].paRAMId = -1;
+                    }
                 }
-
-            if (tcc >= drvObject->gblCfgParams.numTccs)
+            else
                 {
-                result = EDMA3_DRV_E_INVALID_PARAM;
-                }
+                /* DMA/QDMA Channel */
+                paRAMId = edma3DrvChBoundRes[edma3Id][channelId].paRAMId;
+                tcc = edma3DrvChBoundRes[edma3Id][channelId].tcc;
 
-            if (EDMA3_DRV_SOK == result)
-                {
-                /* Disable the transfer and remove various mappings. */
-                result = edma3RemoveMapping(hEdma, channelId);
-                }
+                /* Check the paRAMId and tcc values first */
+                if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
+                    {
+                    result = EDMA3_DRV_E_INVALID_PARAM;
+                    }
 
-            if (EDMA3_DRV_SOK == result)
-                {
-                /* Now Free the PARAM set and TCC */
-                resObj.type = EDMA3_RM_RES_PARAM_SET;
-                resObj.resId = (uint32_t)paRAMId;
-                result = EDMA3_RM_freeResource(drvInst->resMgrInstance, (EDMA3_RM_ResDesc *)&resObj);
+                if (tcc >= drvObject->gblCfgParams.numTccs)
+                    {
+                    result = EDMA3_DRV_E_INVALID_PARAM;
+                    }
 
                 if (EDMA3_DRV_SOK == result)
                     {
-                    /* PaRAM Set Freed */
-                    edma3DrvChBoundRes[edma3Id][channelId].paRAMId = -1;
-
-                    /* Free the TCC */
-                    resObj.type = EDMA3_RM_RES_TCC;
-                    resObj.resId = tcc;
-                    result = EDMA3_RM_freeResource(drvInst->resMgrInstance,
-                                                (EDMA3_RM_ResDesc *)&resObj);
+                    /* Disable the transfer and remove various mappings. */
+                    result = edma3RemoveMapping(hEdma, channelId);
                     }
 
                 if (EDMA3_DRV_SOK == result)
                     {
-                    /* TCC Freed. */
-                    edma3DrvChBoundRes[edma3Id][channelId].tcc = EDMA3_MAX_TCC;
+                    /* Now Free the PARAM set and TCC */
+                    resObj.type = EDMA3_RM_RES_PARAM_SET;
+                    resObj.resId = (uint32_t)paRAMId;
+                    result = EDMA3_RM_freeResource(drvInst->resMgrInstance, (EDMA3_RM_ResDesc *)&resObj);
 
-                    /* Now free the DMA/QDMA Channel in the end. */
-                    if (chType == EDMA3_DRV_CHANNEL_TYPE_QDMA)
+                    if (EDMA3_DRV_SOK == result)
                         {
-                        resObj.type = EDMA3_RM_RES_QDMA_CHANNEL;
-                        resObj.resId = (channelId - edma3_qdma_ch_min_val[edma3Id]);
+                        /* PaRAM Set Freed */
+                        edma3DrvChBoundRes[edma3Id][channelId].paRAMId = -1;
+
+                        /* Free the TCC */
+                        resObj.type = EDMA3_RM_RES_TCC;
+                        resObj.resId = tcc;
                         result = EDMA3_RM_freeResource(drvInst->resMgrInstance,
                                                     (EDMA3_RM_ResDesc *)&resObj);
                         }
-                    else
+
+                    if (EDMA3_DRV_SOK == result)
                         {
-                        resObj.type = EDMA3_RM_RES_DMA_CHANNEL;
-                        resObj.resId = channelId;
-                        result = EDMA3_RM_freeResource(drvInst->resMgrInstance,
-                                                    (EDMA3_RM_ResDesc *)&resObj);
+                        /* TCC Freed. */
+                        edma3DrvChBoundRes[edma3Id][channelId].tcc = EDMA3_MAX_TCC;
+
+                        /* Now free the DMA/QDMA Channel in the end. */
+                        if (chType == EDMA3_DRV_CHANNEL_TYPE_QDMA)
+                            {
+                            resObj.type = EDMA3_RM_RES_QDMA_CHANNEL;
+                            resObj.resId = (channelId - edma3_qdma_ch_min_val[edma3Id]);
+                            result = EDMA3_RM_freeResource(drvInst->resMgrInstance,
+                                                        (EDMA3_RM_ResDesc *)&resObj);
+                            }
+                        else
+                            {
+                            resObj.type = EDMA3_RM_RES_DMA_CHANNEL;
+                            resObj.resId = channelId;
+                            result = EDMA3_RM_freeResource(drvInst->resMgrInstance,
+                                                        (EDMA3_RM_ResDesc *)&resObj);
+                            }
                         }
                     }
                 }
-            }
         }
+    }
 
 #ifdef EDMA3_INSTRUMENTATION_ENABLED
     EDMA3_LOG_EVENT(&DVTEvent_Log,"EDMA3",
@@ -2337,23 +2340,30 @@ static EDMA3_DRV_Result edma3RemoveMapping (EDMA3_DRV_Handle hEdma,
         edma3OsProtectEntry(edma3Id, (int32_t)EDMA3_OS_PROTECT_INTERRUPT, &intState);
 
         if (channelId <= edma3_dma_ch_max_val [edma3Id])
+        {
+            if((channelId >> 3U) < 8)
             {
-            /* DMA channel */
+                /* DMA channel */
 #ifndef EDMA3_PROGRAM_QUEUE_NUM_REGISTER_INIT_TIME
-            /* Remove the channel to Event Queue mapping */
-            globalRegs->DMAQNUM[channelId >> 3U] &=
-                            EDMA3_DRV_DMAQNUM_CLR_MASK(channelId);
+                /* Remove the channel to Event Queue mapping */
+                globalRegs->DMAQNUM[channelId >> 3U] &=
+                                EDMA3_DRV_DMAQNUM_CLR_MASK(channelId);
 #endif
-            /**
-             * If DMA channel to PaRAM Set mapping exists,
-             * remove it too.
-             */
-            if (TRUE == drvObject->gblCfgParams.dmaChPaRAMMapExists)
-                {
-                globalRegs->DCHMAP[channelId] &=
-                                        EDMA3_RM_DCH_PARAM_CLR_MASK;
-                }
+                /**
+                 * If DMA channel to PaRAM Set mapping exists,
+                 * remove it too.
+                 */
+                if (TRUE == drvObject->gblCfgParams.dmaChPaRAMMapExists)
+                    {
+                    globalRegs->DCHMAP[channelId] &=
+                                            EDMA3_RM_DCH_PARAM_CLR_MASK;
+                    }
             }
+            else
+            {
+                result = EDMA3_DRV_E_INVALID_PARAM;
+            }
+        }
         else
             {
             /* QDMA channel */
index 98dc8cb18195fc5b8cd0cf0c8e5a1628a2becb70..78c0cdce2e4f6014d2cf5e7b71a65ce597eacdf8 100755 (executable)
@@ -1728,7 +1728,7 @@ EDMA3_RM_Result EDMA3_RM_freeResource(EDMA3_RM_Handle hEdmaResMgr,
                     {
                     case EDMA3_RM_RES_DMA_CHANNEL :
                         {
-                        if (resId < rmObj->gblCfgParams.numDmaChannels)
+                        if ((resId < rmObj->gblCfgParams.numDmaChannels) && ((resId/32U) < 2))
                             {
                             if (((rmInstance->initParam.rmInstInitConfig->ownDmaChannels [resId/32U]) & (resIdSet))!=FALSE)
                                 {