From: Mahesh Radhakrishnan Date: Thu, 8 Feb 2018 18:56:58 +0000 (-0600) Subject: Merge pull request #20 in PROCESSOR-SDK/edma3_lld from misrac_fix_PRSDK-3354 to master X-Git-Tag: DEV_EDMA3_LLD_02_12_05_30C~4 X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Fedma3_lld.git;a=commitdiff_plain;h=7c22a41159efedf13ad9ff448db554658f4877ee;hp=3ceeb1d9df8cc7b7fc0f8612c0633dc22bc83a25 Merge pull request #20 in PROCESSOR-SDK/edma3_lld from misrac_fix_PRSDK-3354 to master * commit '81e2f425f6bf02b1bf477955a818b76f8a303969': misrac fix 2 for 4.2.0 (PRSDK-3354) misrac fix for 4.2.0 (PRSDK-3354) --- diff --git a/packages/ti/sdo/edma3/drv/src/edma3_drv_adv.c b/packages/ti/sdo/edma3/drv/src/edma3_drv_adv.c index f8f3808..55edc54 100755 --- a/packages/ti/sdo/edma3/drv/src/edma3_drv_adv.c +++ b/packages/ti/sdo/edma3/drv/src/edma3_drv_adv.c @@ -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", diff --git a/packages/ti/sdo/edma3/drv/src/edma3_drv_basic.c b/packages/ti/sdo/edma3/drv/src/edma3_drv_basic.c index 5d51230..2a6ab6e 100755 --- a/packages/ti/sdo/edma3/drv/src/edma3_drv_basic.c +++ b/packages/ti/sdo/edma3/drv/src/edma3_drv_basic.c @@ -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 */ diff --git a/packages/ti/sdo/edma3/rm/src/edma3resmgr.c b/packages/ti/sdo/edma3/rm/src/edma3resmgr.c index fed46eb..78c0cdc 100755 --- a/packages/ti/sdo/edma3/rm/src/edma3resmgr.c +++ b/packages/ti/sdo/edma3/rm/src/edma3resmgr.c @@ -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) { @@ -2986,28 +2986,31 @@ EDMA3_RM_Result EDMA3_RM_mapEdmaChannel (EDMA3_RM_Handle hEdmaResMgr, /* DMA channel and PaRAM Set should be previously allocated. */ if (result == EDMA3_RM_SOK) { - if (((rmInstance->initParam.rmInstInitConfig->ownDmaChannels[channelId/32U]) - & - (~(rmInstance->avlblDmaChannels[channelId/32U])) - & - ((uint32_t)1U << (channelId%32U))) != FALSE) + if(((channelId/32U) < 2) && ((paRAMId/32U) < 16)) { - /* DMA channel allocated, check for the PaRAM Set */ - if (((rmInstance->initParam.rmInstInitConfig->ownPaRAMSets[paRAMId/32U]) - & - (~(rmInstance->avlblPaRAMSets[paRAMId/32U])) - & - ((uint32_t)1U << (paRAMId%32U))) == FALSE) + if (((rmInstance->initParam.rmInstInitConfig->ownDmaChannels[channelId/32U]) + & + (~(rmInstance->avlblDmaChannels[channelId/32U])) + & + ((uint32_t)1U << (channelId%32U))) != FALSE) { - /* PaRAM Set NOT allocated, return error */ + /* DMA channel allocated, check for the PaRAM Set */ + if (((rmInstance->initParam.rmInstInitConfig->ownPaRAMSets[paRAMId/32U]) + & + (~(rmInstance->avlblPaRAMSets[paRAMId/32U])) + & + ((uint32_t)1U << (paRAMId%32U))) == FALSE) + { + /* PaRAM Set NOT allocated, return error */ + result = EDMA3_RM_E_RES_NOT_ALLOCATED; + } + } + else + { + /* DMA channel NOT allocated, return error */ result = EDMA3_RM_E_RES_NOT_ALLOCATED; } } - else - { - /* DMA channel NOT allocated, return error */ - result = EDMA3_RM_E_RES_NOT_ALLOCATED; - } } @@ -3115,28 +3118,31 @@ EDMA3_RM_Result EDMA3_RM_mapQdmaChannel (EDMA3_RM_Handle hEdmaResMgr, /* QDMA channel and PaRAM Set should be previously allocated. */ if (result == EDMA3_RM_SOK) { - if (((rmInstance->initParam.rmInstInitConfig->ownQdmaChannels[channelId/32U]) - & - (~(rmInstance->avlblQdmaChannels[channelId/32U])) - & - ((uint32_t)1U << (channelId%32U))) != FALSE) + if(((channelId/32U) < 1) && ((paRAMId/32U) < 16)) { - /* QDMA channel allocated, check for the PaRAM Set */ - if (((rmInstance->initParam.rmInstInitConfig->ownPaRAMSets[paRAMId/32U]) - & - (~(rmInstance->avlblPaRAMSets[paRAMId/32U])) - & - ((uint32_t)1U << (paRAMId%32U))) == FALSE) + if (((rmInstance->initParam.rmInstInitConfig->ownQdmaChannels[channelId/32U]) + & + (~(rmInstance->avlblQdmaChannels[channelId/32U])) + & + ((uint32_t)1U << (channelId%32U))) != FALSE) { - /* PaRAM Set NOT allocated, return error */ + /* QDMA channel allocated, check for the PaRAM Set */ + if (((rmInstance->initParam.rmInstInitConfig->ownPaRAMSets[paRAMId/32U]) + & + (~(rmInstance->avlblPaRAMSets[paRAMId/32U])) + & + ((uint32_t)1U << (paRAMId%32U))) == FALSE) + { + /* PaRAM Set NOT allocated, return error */ + result = EDMA3_RM_E_RES_NOT_ALLOCATED; + } + } + else + { + /* QDMA channel NOT allocated, return error */ result = EDMA3_RM_E_RES_NOT_ALLOCATED; } } - else - { - /* QDMA channel NOT allocated, return error */ - result = EDMA3_RM_E_RES_NOT_ALLOCATED; - } } if (result == EDMA3_RM_SOK) @@ -3585,7 +3591,7 @@ EDMA3_RM_Result EDMA3_RM_allocContiguousResource(EDMA3_RM_Handle hEdmaResMgr, resIdSet = (1U << (resAllocIdx%32U)); /* Check whether it is owned or not */ - if (((rmInstance->initParam.rmInstInitConfig->ownDmaChannels[resAllocIdx/32U])&(resIdSet)) != FALSE) + if (((resAllocIdx/32U) < 2) && (((rmInstance->initParam.rmInstInitConfig->ownDmaChannels[resAllocIdx/32U])&(resIdSet)) != FALSE)) { /* Now check if specified resource is available presently*/ if (((rmInstance->avlblDmaChannels[resAllocIdx/32U])&(resIdSet)) != FALSE) @@ -3707,7 +3713,7 @@ EDMA3_RM_Result EDMA3_RM_allocContiguousResource(EDMA3_RM_Handle hEdmaResMgr, resIdSet = (1U << (resAllocIdx%32U)); /* Check whether it is owned or not */ - if (((rmInstance->initParam.rmInstInitConfig->ownTccs[resAllocIdx/32U])&(resIdSet))!=FALSE) + if (((resAllocIdx/32U) < 2) && (((rmInstance->initParam.rmInstInitConfig->ownTccs[resAllocIdx/32U])&(resIdSet))!=FALSE)) { /* Now check if specified resource is available presently*/ if (((rmInstance->avlblTccs[resAllocIdx/32U])&(resIdSet))!=FALSE) @@ -3774,7 +3780,7 @@ EDMA3_RM_Result EDMA3_RM_allocContiguousResource(EDMA3_RM_Handle hEdmaResMgr, if (((rmInstance->initParam.rmInstInitConfig->ownPaRAMSets[resAllocIdx/32U])&(resIdSet))!=FALSE) { /* Now check if specified resource is available presently*/ - if (((rmInstance->avlblPaRAMSets[resAllocIdx/32U])&(resIdSet))!=FALSE) + if (((resAllocIdx/32U) < 16) && (((rmInstance->avlblPaRAMSets[resAllocIdx/32U])&(resIdSet))!=FALSE)) { /* * Mark the specified resource as "Not Available"