DSPBRIDGE: MEM Module cleanup series
Subsystems (2)
cover DSPBRIDGE: MEM Module cleanup series
This series contains patches which remove following things from the MEM module:
1. MEM_CHECK memory leak debugging mechanism
2. MEM_Free() function
3. MEM_VFree() function
Ameya Palande (3):
DSPBRIDGE: Get rid of MEM_CHECK mechanism
DSPBRIDGE: Get rid of MEM_Free()
DSPBRIDGE: Get rid of MEM_VFree()
arch/arm/plat-omap/include/dspbridge/mem.h | 36 +---- drivers/dsp/bridge/gen/gs.c | 4 +- drivers/dsp/bridge/pmgr/cmm.c | 12 +- drivers/dsp/bridge/pmgr/cod.c | 4 +- drivers/dsp/bridge/pmgr/dbll.c | 15 +- drivers/dsp/bridge/pmgr/dev.c | 11 +- drivers/dsp/bridge/pmgr/dmm.c | 3 +- drivers/dsp/bridge/pmgr/wcd.c | 46 ++--- drivers/dsp/bridge/rmgr/dbdcd.c | 13 +- drivers/dsp/bridge/rmgr/disp.c | 3 +- drivers/dsp/bridge/rmgr/drv.c | 32 ++-- drivers/dsp/bridge/rmgr/drv_interface.c | 2 +- drivers/dsp/bridge/rmgr/nldr.c | 52 ++---- drivers/dsp/bridge/rmgr/node.c | 77 +++------ drivers/dsp/bridge/rmgr/proc.c | 11 +- drivers/dsp/bridge/rmgr/rmm.c | 18 +- drivers/dsp/bridge/rmgr/strm.c | 3 +- drivers/dsp/bridge/services/mem.c | 246 +--------------------------- drivers/dsp/bridge/services/ntfy.c | 7 +- drivers/dsp/bridge/services/regsup.c | 10 +- drivers/dsp/bridge/services/sync.c | 3 +- drivers/dsp/bridge/wmd/chnl_sm.c | 11 +- drivers/dsp/bridge/wmd/io_sm.c | 12 +- drivers/dsp/bridge/wmd/msg_sm.c | 8 +- drivers/dsp/bridge/wmd/tiomap3430.c | 17 +-- drivers/dsp/bridge/wmd/ue_deh.c | 2 +- 26 files changed, 159 insertions(+), 499 deletions(-)
PATCH 1/3 DSPBRIDGE: Get rid of MEM_CHECK mechanism
kmemleak offeres the same functionality as custom MEM_CHECK mechanism, so get rid of MEM_CHECK.
--- drivers/dsp/bridge/services/mem.c | 212 +------------------------------------ 1 files changed, 2 insertions(+), 210 deletions(-)
drivers/dsp/bridge/services/mem.c +2 -210
@@ -34,11 +34,6 @@/* ----------------------------------- Defines */ #define MEM_512MB 0x1fffffff -#define memInfoSign 0x464E494D/* "MINF" (in reverse). */ - -#ifdef CONFIG_BRIDGE_DEBUG -#define MEM_CHECK /* Use to detect source of memory leaks */ -#endif /* ----------------------------------- Globals */ #if GT_TRACE
@@ -56,85 +51,6 @@ struct extPhysMemPool {static struct extPhysMemPool extMemPool; -/* Information about each element allocated on heap */ -struct memInfo { -struct list_head link;/* Must be first */ -size_t size; -void *caller; -u32 dwSignature;/* Should be last */ -}; - -#ifdef MEM_CHECK - -/* -* This structure holds a linked list to all memory elements allocated on -* heap by DSP/BIOS Bridge. This is used to report memory leaks and free -* such elements while removing the DSP/BIOS Bridge driver -*/ -struct memMan { -struct LST_LIST lst; -spinlock_t lock; -}; - -static struct memMan mMan; - -/* -* These functions are similar to LST_PutTail and LST_RemoveElem and are -* duplicated here to make MEM independent of LST -*/ -static inline void MLST_PutTail (struct LST_LIST *pList,struct list_head *pElem) -{ - pElem->prev = pList->head.prev; - pElem->next = &pList->head; - pList->head.prev = pElem; - pElem->prev->next = pElem; -} - -static inline void MLST_RemoveElem (struct LST_LIST *pList, -struct list_head *pCurElem) -{ - pCurElem->prev->next = pCurElem->next; - pCurElem->next->prev = pCurElem->prev; - pCurElem->next =NULL ; - pCurElem->prev =NULL ; -} - -static void MEM_Check (void ) -{ -struct memInfo *pMem; -struct list_head *last = &mMan.lst.head; -struct list_head *curr = last->next; - -if (!LST_IsEmpty (&mMan.lst)) { -GT_0trace (MEM_debugMask,GT_7CLASS ,"*** MEMORY LEAK ***\n" ); -GT_0trace (MEM_debugMask,GT_7CLASS , -"Addr Size Caller\n" ); -while (curr != last) { - pMem = (struct memInfo *)curr; - curr = curr->next; -if ((u32 )pMem >PAGE_OFFSET && -MEM_IsValidHandle (pMem, memInfoSign)) { -GT_3trace (MEM_debugMask,GT_7CLASS , -"%lx %d\t [<%p>]\n" , - (u32 ) pMem +sizeof (struct memInfo ), - pMem->size, pMem->caller); -MLST_RemoveElem (&mMan.lst, - (struct list_head *)pMem); -kfree (pMem); - }else { -GT_1trace (MEM_debugMask,GT_7CLASS , -"Invalid allocation or " -"Buffer underflow at %x\n" , - (u32 )pMem +sizeof (struct memInfo )); -break ; - } - } - } -DBC_Ensure (LST_IsEmpty (&mMan.lst)); -} - -#endif -void MEM_ExtPhysPoolInit (u32 poolPhysBase,u32 poolSize) {u32 poolVirtBase;
@@ -233,7 +149,7 @@ static void *MEM_ExtPhysMemAlloc(u32 bytes, u32 align, OUT u32 *pPhysAddr)*/ void *MEM_Alloc (u32 cBytes,enum MEM_POOLATTRS type) { -struct memInfo *pMem =NULL ; +void *pMem =NULL ;GT_2trace (MEM_debugMask,GT_ENTER ,"MEM_Alloc: cBytes 0x%x\ttype 0x%x\n" , cBytes, type);
@@ -242,46 +158,11 @@ void *MEM_Alloc(u32 cBytes, enum MEM_POOLATTRS type)case MEM_NONPAGED :/* If non-paged memory required, see note at top of file. */ case MEM_PAGED : -#ifndef MEM_CHECK pMem =kmalloc (cBytes, (in_atomic ()) ?GFP_ATOMIC :GFP_KERNEL ); -#else - pMem =kmalloc (cBytes +sizeof (struct memInfo ), - (in_atomic ()) ?GFP_ATOMIC :GFP_KERNEL ); -if (pMem) { - pMem->size = cBytes; - pMem->caller =__builtin_return_address (0 ); - pMem->dwSignature = memInfoSign; - -spin_lock (&mMan.lock); -MLST_PutTail (&mMan.lst, - (struct list_head *)pMem); -spin_unlock (&mMan.lock); - - pMem = (void *)((u32 )pMem + -sizeof (struct memInfo )); - } -#endif break ;case MEM_LARGEVIRTMEM : -#ifndef MEM_CHECK pMem =vmalloc (cBytes); -#else - pMem =vmalloc (cBytes +sizeof (struct memInfo )); -if (pMem) { - pMem->size = cBytes; - pMem->caller =__builtin_return_address (0 ); - pMem->dwSignature = memInfoSign; - -spin_lock (&mMan.lock); -MLST_PutTail (&mMan.lst, - (struct list_head *)pMem); -spin_unlock (&mMan.lock); - - pMem = (void *)((u32 )pMem + -sizeof (struct memInfo )); - } -#endif break ;default :
@@ -335,7 +216,7 @@ void *MEM_AllocPhysMem(u32 cBytes, u32 ulAlign, OUT u32 *pPhysicalAddress)*/ void *MEM_Calloc (u32 cBytes,enum MEM_POOLATTRS type) { -struct memInfo *pMem =NULL ; +void *pMem =NULL ; GT_2trace(MEM_debugMask, GT_ENTER, "MEM_Calloc: cBytes 0x%x\ttype 0x%x\n",
@@ -346,51 +227,16 @@ void *MEM_Calloc(u32 cBytes, enum MEM_POOLATTRS type)case MEM_NONPAGED :/* If non-paged memory required, see note at top of file. */ case MEM_PAGED : -#ifndef MEM_CHECK pMem =kmalloc (cBytes, (in_atomic ()) ?GFP_ATOMIC :GFP_KERNEL );if (pMem)memset (pMem,0 , cBytes); -#else - pMem =kmalloc (cBytes +sizeof (struct memInfo ), - (in_atomic ()) ?GFP_ATOMIC :GFP_KERNEL ); -if (pMem) { -memset ((void *)((u32 )pMem + -sizeof (struct memInfo )),0 , cBytes); - pMem->size = cBytes; - pMem->caller =__builtin_return_address (0 ); - pMem->dwSignature = memInfoSign; -spin_lock (&mMan.lock); -MLST_PutTail (&mMan.lst, - (struct list_head *)pMem); -spin_unlock (&mMan.lock); - pMem = (void *)((u32 )pMem + -sizeof (struct memInfo )); - } -#endif break ;case MEM_LARGEVIRTMEM : -#ifndef MEM_CHECK pMem =vmalloc (cBytes);if (pMem)memset (pMem,0 , cBytes); -#else - pMem =vmalloc (cBytes +sizeof (struct memInfo )); -if (pMem) { -memset ((void *)((u32 )pMem + -sizeof (struct memInfo )),0 , cBytes); - pMem->size = cBytes; - pMem->caller =__builtin_return_address (0 ); - pMem->dwSignature = memInfoSign; -spin_lock (&mMan.lock); -MLST_PutTail (&mMan.lst, - (struct list_head *)pMem); -spin_unlock (&mMan.lock); - pMem = (void *)((u32 )pMem + -sizeof (struct memInfo )); - } -#endif break ;default : GT_1trace(MEM_debugMask, GT_6CLASS,
@@ -410,9 +256,6 @@ void *MEM_Calloc(u32 cBytes, enum MEM_POOLATTRS type)*/ void MEM_Exit (void ) { -#ifdef MEM_CHECK -MEM_Check (); -#endif }/*
@@ -455,35 +298,13 @@ void MEM_FlushCache(void *pMemBuf, u32 cBytes, s32 FlushType)*/ void MEM_VFree(IN void *pMemBuf) { -#ifdef MEM_CHECK -struct memInfo *pMem = (void *)((u32 )pMemBuf -sizeof (struct memInfo )); -#endif -DBC_Require (pMemBuf !=NULL );GT_1trace (MEM_debugMask,GT_ENTER ,"MEM_VFree: pMemBufs 0x%x\n" , pMemBuf);if (pMemBuf) { -#ifndef MEM_CHECK vfree (pMemBuf); -#else -if (pMem) { -if (pMem->dwSignature == memInfoSign) { -spin_lock (&mMan.lock); -MLST_RemoveElem (&mMan.lst, - (struct list_head *)pMem); -spin_unlock (&mMan.lock); - pMem->dwSignature =0 ; -vfree (pMem); - }else { -GT_1trace (MEM_debugMask,GT_7CLASS , -"Invalid allocation or " -"Buffer underflow at %x\n" , - (u32 ) pMem +sizeof (struct memInfo )); - } - } -#endif } }
@@ -494,35 +315,13 @@ void MEM_VFree(IN void *pMemBuf)*/ void MEM_Free(IN void *pMemBuf) { -#ifdef MEM_CHECK -struct memInfo *pMem = (void *)((u32 )pMemBuf -sizeof (struct memInfo )); -#endif -DBC_Require (pMemBuf !=NULL );GT_1trace (MEM_debugMask,GT_ENTER ,"MEM_Free: pMemBufs 0x%x\n" , pMemBuf);if (pMemBuf) { -#ifndef MEM_CHECK kfree (pMemBuf); -#else -if (pMem) { -if (pMem->dwSignature == memInfoSign) { -spin_lock (&mMan.lock); -MLST_RemoveElem (&mMan.lst, - (struct list_head *)pMem); -spin_unlock (&mMan.lock); - pMem->dwSignature =0 ; -kfree (pMem); - }else { -GT_1trace (MEM_debugMask,GT_7CLASS , -"Invalid allocation or " -"Buffer underflow at %x\n" , - (u32 ) pMem +sizeof (struct memInfo )); - } - } -#endif } }
@@ -552,12 +351,5 @@ void MEM_FreePhysMem(void *pVirtualAddress, u32 pPhysicalAddress,bool MEM_Init (void ) {GT_create (&MEM_debugMask,"MM" );/* MM for MeM module */ - -#ifdef MEM_CHECK - mMan.lst.head.next = &mMan.lst.head; - mMan.lst.head.prev = &mMan.lst.head; -spin_lock_init (&mMan.lock); -#endif -return true; }
Signature · 1 line
1.6.3.3
PATCH 2/3 DSPBRIDGE: Get rid of MEM_Free()
In reply to Ameya Palandekfree() is NULL and ZERO pointer safe so MEM_Free() doesn't provide any significant advantage. By getting rid of MEM_Free() and the NULL pointer check associated with it, we can save on:
1. One level of indirection which translates to a function call cost.
2. NULL pointer checking cost.
--- arch/arm/plat-omap/include/dspbridge/mem.h | 19 +------ drivers/dsp/bridge/gen/gs.c | 4 +- drivers/dsp/bridge/pmgr/cmm.c | 12 ++-- drivers/dsp/bridge/pmgr/cod.c | 4 +- drivers/dsp/bridge/pmgr/dbll.c | 15 +++--- drivers/dsp/bridge/pmgr/dev.c | 11 ++--- drivers/dsp/bridge/pmgr/wcd.c | 46 +++++++---------- drivers/dsp/bridge/rmgr/dbdcd.c | 13 ++--- drivers/dsp/bridge/rmgr/disp.c | 3 +- drivers/dsp/bridge/rmgr/drv.c | 32 ++++++------ drivers/dsp/bridge/rmgr/drv_interface.c | 2 +- drivers/dsp/bridge/rmgr/nldr.c | 52 +++++++------------ drivers/dsp/bridge/rmgr/node.c | 77 ++++++++++------------------ drivers/dsp/bridge/rmgr/proc.c | 11 ++-- drivers/dsp/bridge/rmgr/rmm.c | 18 +++--- drivers/dsp/bridge/rmgr/strm.c | 3 +- drivers/dsp/bridge/services/mem.c | 17 ------ drivers/dsp/bridge/services/ntfy.c | 7 +-- drivers/dsp/bridge/services/regsup.c | 10 ++-- drivers/dsp/bridge/services/sync.c | 3 +- drivers/dsp/bridge/wmd/chnl_sm.c | 11 ++-- drivers/dsp/bridge/wmd/io_sm.c | 12 ++--- drivers/dsp/bridge/wmd/msg_sm.c | 8 ++-- drivers/dsp/bridge/wmd/tiomap3430.c | 17 ++---- drivers/dsp/bridge/wmd/ue_deh.c | 2 +- 25 files changed, 156 insertions(+), 253 deletions(-)
arch/arm/plat-omap/include/dspbridge/mem.h +2 -17
@@ -140,21 +140,6 @@extern void MEM_FlushCache (void *pMemBuf,u32 cBytes,s32 FlushType);/* -* ======== MEM_Free ======== -* Purpose: -* Free the given block of system memory. -* Parameters: -* pMemBuf: Pointer to memory allocated by MEM_Calloc/Alloc(). -* Returns: -* Requires: -* MEM initialized. -* pMemBuf is a valid memory address returned by MEM_Calloc/Alloc(). -* Ensures: -* pMemBuf is no longer a valid pointer to memory. -*/ - extern void MEM_Free(IN void *pMemBuf); - -/* * ======== MEM_VFree ======== * Purpose: * Free the given block of system memory in virtual space.
@@ -200,14 +185,14 @@* pObj: Pointer to the object to free. * Returns: * Requires: -* Same requirements as MEM_Free(). +* Same requirements as kfree(). * Ensures: * A subsequent call to MEM_IsValidHandle() will fail for this object. */ #define MEM_FreeObject (pObj) \ { \ pObj->dwSignature = 0x00; \ - MEM_Free(pObj); \ + kfree(pObj); \ }/*
drivers/dsp/bridge/gen/gs.c +2 -2
@@ -62,7 +62,7 @@ void GS_exit(void)*/ void GS_free (void *ptr) { -MEM_Free (ptr); +kfree (ptr);/* ack! no size info */ /* cumsize -= size; */ }
@@ -74,7 +74,7 @@ void GS_free(void *ptr)*/ void GS_frees (void *ptr,u32 size) { -MEM_Free (ptr); +kfree (ptr); cumsize -= size; }
drivers/dsp/bridge/pmgr/cmm.c +6 -6
@@ -369,10 +369,10 @@ DSP_STATUS CMM_Destroy(struct CMM_OBJECT *hCmmMgr, bool bForce)while (!LST_IsEmpty (pCmmMgr->pNodeFreeListHead)) { pNode = (struct CMM_MNODE *)LST_GetHead (pCmmMgr-> pNodeFreeListHead); -MEM_Free (pNode); +kfree (pNode); }/* delete NodeFreeList list */ -MEM_Free (pCmmMgr->pNodeFreeListHead); +kfree (pCmmMgr->pNodeFreeListHead); }SYNC_LeaveCS (pCmmMgr->hCmmLock);if (DSP_SUCCEEDED (status)) {
@@ -765,11 +765,11 @@ static void UnRegisterGPPSMSeg(struct CMM_ALLOCATOR *pSMA) (struct list_head *)pCurNode);LST_RemoveElem (pSMA->pFreeListHead, (struct list_head *)pCurNode); -MEM_Free ((void *) pCurNode); +kfree ((void *) pCurNode);/* next node. */ pCurNode = pNextNode; } -MEM_Free (pSMA->pFreeListHead);/* delete freelist */ +kfree (pSMA->pFreeListHead);/* delete freelist */ /* free nodes on InUse list */ pCurNode = (struct CMM_MNODE *)LST_First (pSMA->pInUseListHead);while (pCurNode) {
@@ -778,11 +778,11 @@ static void UnRegisterGPPSMSeg(struct CMM_ALLOCATOR *pSMA) (struct list_head *)pCurNode);LST_RemoveElem (pSMA->pInUseListHead, (struct list_head *)pCurNode); -MEM_Free ((void *) pCurNode); +kfree ((void *) pCurNode);/* next node. */ pCurNode = pNextNode; } -MEM_Free (pSMA->pInUseListHead);/* delete InUse list */ +kfree (pSMA->pInUseListHead);/* delete InUse list */ }if ((void *) pSMA->dwVmBase !=NULL )MEM_UnmapLinearAddress ((void *) pSMA->dwVmBase);
drivers/dsp/bridge/pmgr/cod.c +2 -2
@@ -210,7 +210,7 @@ void COD_Close(struct COD_LIBRARYOBJ *lib) hMgr = lib->hCodMgr; hMgr->fxns.closeFxn (lib->dbllLib); -MEM_Free (lib); +kfree (lib); }/*
@@ -315,7 +315,7 @@ void COD_Delete(struct COD_MANAGER *hMgr) hMgr->fxns.exitFxn (); } hMgr->ulMagic = ~MAGIC ; -MEM_Free (hMgr); +kfree (hMgr); }/*
drivers/dsp/bridge/pmgr/dbll.c +7 -8
@@ -235,8 +235,7 @@ void DBLL_close(struct DBLL_LibraryObj *zlLib)/* Free DOF resources */ dofClose (zlLib); -if (zlLib->fileName) -MEM_Free (zlLib->fileName); +kfree (zlLib->fileName);/* remove symbols from symbol table */ if (zlLib->symTab)
@@ -1009,7 +1008,7 @@ static void symDelete(void *value) {struct Symbol *sp = (struct Symbol *)value; -MEM_Free (sp->name); +kfree (sp->name); }/*
@@ -1178,7 +1177,7 @@ static struct dynload_symbol *addToSymbolTable(struct Dynamic_Loader_Sym *this, symPtr = (struct Symbol *)GH_insert (lib->symTab, (void *)name, (void *)&symbol);if (symPtr ==NULL ) -MEM_Free (symbol.name); +kfree (symbol.name); }if (symPtr !=NULL )
@@ -1234,7 +1233,7 @@ static void deallocate(struct Dynamic_Loader_Sym *this, void *memPtr) lib = pSymbol->lib;DBC_Require (MEM_IsValidHandle (lib,DBLL_LIBSIGNATURE )); -MEM_Free (memPtr); +kfree (memPtr); }/*
@@ -1336,11 +1335,11 @@ static int rmmAlloc(struct Dynamic_Loader_Allocate *this, req, segId); } } -MEM_Free (szSectName); +kfree (szSectName); szSectName =NULL ; -MEM_Free (szLastToken); +kfree (szLastToken); szLastToken =NULL ; -MEM_Free (szSecLastToken); +kfree (szSecLastToken); szSecLastToken =NULL ; func_cont:if (memType ==DBLL_CODE )
drivers/dsp/bridge/pmgr/dev.c +4 -7
@@ -295,8 +295,8 @@ DSP_STATUS DEV_CreateDevice(OUT struct DEV_OBJECT **phDevObject,"DEV_CreateDevice Succeeded \nDevObject " "0x%x\n", pDevObject); }else { -if (pDevObject && pDevObject->procList) -MEM_Free (pDevObject->procList); +if (pDevObject) +kfree (pDevObject->procList);if (pDevObject && pDevObject->hCodMgr)COD_Delete (pDevObject->hCodMgr);
@@ -451,11 +451,8 @@ DSP_STATUS DEV_DestroyDevice(struct DEV_OBJECT *hDevObject) }else status =DSP_EFAIL ;if (DSP_SUCCEEDED (status)) { -if (pDevObject->procList) { -MEM_Free (pDevObject->procList); - pDevObject->procList =NULL ; - } - +kfree (pDevObject->procList); + pDevObject->procList =NULL ;/* Remove this DEV_Object from the global list: */ DRV_RemoveDevObject (pDevObject->hDrvObject, pDevObject);/* Free The library * LDR_FreeModule
drivers/dsp/bridge/pmgr/wcd.c +18 -28
143 lines not on this page · raw message
drivers/dsp/bridge/rmgr/dbdcd.c +5 -8
@@ -563,13 +563,12 @@ DSP_STATUS DCD_GetObjectDef(IN struct DCD_MANAGER *hDcdMgr, }/* Free the previously allocated dynamic buffer. */ -MEM_Free (pszCoffBuf); +kfree (pszCoffBuf); func_end:if (lib)COD_Close (lib); -if (szUuid) -MEM_Free (szUuid); +kfree (szUuid);return status; }
@@ -690,7 +689,7 @@ DSP_STATUS DCD_GetObjects(IN struct DCD_MANAGER *hDcdMgr, IN char *pszCoffPath, }/* Free the previously allocated dynamic buffer. */ -MEM_Free (pszCoffBuf); +kfree (pszCoffBuf); func_cont:if (lib)COD_Close (lib);
@@ -1514,11 +1513,9 @@ func_cont:COD_Close (lib);/* Free previously allocated dynamic buffers. */ -if (pszFileName) -MEM_Free (pszFileName); +kfree (pszFileName); -if (pszCoffBuf) -MEM_Free (pszCoffBuf); +kfree (pszCoffBuf);return status; }
drivers/dsp/bridge/rmgr/disp.c +1 -2
@@ -726,8 +726,7 @@ static void DeleteDisp(struct DISP_OBJECT *hDisp) status); } } -if (hDisp->pBuf) -MEM_Free (hDisp->pBuf); +kfree (hDisp->pBuf);MEM_FreeObject (hDisp); }
drivers/dsp/bridge/rmgr/drv.c +16 -16
@@ -134,7 +134,7 @@ DSP_STATUS DRV_RemoveNodeResElement(HANDLE hNodeRes, HANDLE hPCtxt)return DSP_ENOTFOUND ; pTempNode->next = pNodeRes->next; } -MEM_Free (pNodeRes); +kfree (pNodeRes);return DSP_SOK ; }
@@ -236,7 +236,7 @@ DSP_STATUS DRV_RemoveDMMResElement(HANDLE hDMMRes, HANDLE hPCtxt)return DSP_ENOTFOUND ; pTempDMMRes->next = pDMMRes->next; } -MEM_Free (pDMMRes); +kfree (pDMMRes);return DSP_SOK ; }
@@ -302,7 +302,7 @@ DSP_STATUS DRV_RemoveAllDMMResElements(HANDLE hPCtxt)while (pTempDMMRes !=NULL ) { pTempDMMRes2 = pTempDMMRes; pTempDMMRes = pTempDMMRes->next; -MEM_Free (pTempDMMRes2); +kfree (pTempDMMRes2); } pCtxt->pDMMList =NULL ;return status;
@@ -363,7 +363,7 @@ DSP_STATUS DRV_RemoveAllNodeResElements(HANDLE hPCtxt)while (pTempNode !=NULL ) { pTempNode2 = pTempNode; pTempNode = pTempNode->next; -MEM_Free (pTempNode2); +kfree (pTempNode2); } pCtxt->pNodeList =NULL ;return status;
@@ -449,7 +449,7 @@ DSP_STATUS DRV_ProcRemoveSTRMResElement(HANDLE hSTRMRes, HANDLE hPCtxt) pTempSTRMRes->next = pSTRMRes->next; } -MEM_Free (pSTRMRes); +kfree (pSTRMRes);return DSP_SOK ; }
@@ -476,7 +476,7 @@ static DSP_STATUS DRV_ProcFreeSTRMRes(HANDLE hPCtxt) sizeof(u8 *)), MEM_NONPAGED); status =STRM_FreeBuffer (pSTRMRes->hStream, apBuffer, pSTRMRes->uNumBufs, pCtxt); -MEM_Free (apBuffer); +kfree (apBuffer); } status =STRM_Close (pSTRMRes->hStream, pCtxt);if (DSP_FAILED (status)) {
@@ -509,7 +509,7 @@ DSP_STATUS DRV_RemoveAllSTRMResElements(HANDLE hPCtxt)while (pTempSTRMRes !=NULL ) { pTempSTRMRes2 = pTempSTRMRes; pTempSTRMRes = pTempSTRMRes->next; -MEM_Free (pTempSTRMRes2); +kfree (pTempSTRMRes2); } pCtxt->pSTRMList =NULL ;return status;
@@ -606,7 +606,7 @@ DSP_STATUS DRV_Create(OUT struct DRV_OBJECT **phDRVObject) *phDRVObject = pDRVObject; }else {/* Free the DRV Object */ -MEM_Free (pDRVObject); +kfree (pDRVObject);GT_0trace (curTrace,GT_7CLASS ,"Failed to update the Registry with " "DRV Object " );
@@ -658,11 +658,11 @@ DSP_STATUS DRV_Destroy(struct DRV_OBJECT *hDRVObject)*/ if (pDRVObject->devList) {/* Could assert if the list is not empty */ -MEM_Free (pDRVObject->devList); +kfree (pDRVObject->devList); }if (pDRVObject->devNodeString) {/* Could assert if the list is not empty */ -MEM_Free (pDRVObject->devNodeString); +kfree (pDRVObject->devNodeString); }MEM_FreeObject (pDRVObject);/* Update the DRV Object in Registry to be 0 */
@@ -902,7 +902,7 @@ DSP_STATUS DRV_RemoveDevObject(struct DRV_OBJECT *hDRVObject, }/* Remove list if empty. */ if (LST_IsEmpty (pDRVObject->devList)) { -MEM_Free (pDRVObject->devList); +kfree (pDRVObject->devList); pDRVObject->devList =NULL ; } DBC_Ensure((pDRVObject->devList == NULL) ||
@@ -1018,12 +1018,12 @@ DSP_STATUS DRV_ReleaseResources(u32 dwContext, struct DRV_OBJECT *hDrvObject)/* Delete from the Driver object list */ LST_RemoveElem (pDRVObject->devNodeString, (struct list_head *)pszdevNode); -MEM_Free ((void *) pszdevNode); +kfree ((void *) pszdevNode);break ; }/* Delete the List if it is empty */ if (LST_IsEmpty (pDRVObject->devNodeString)) { -MEM_Free (pDRVObject->devNodeString); +kfree (pDRVObject->devNodeString); pDRVObject->devNodeString =NULL ; } }
@@ -1125,7 +1125,7 @@ static DSP_STATUS RequestBridgeResources(u32 dwContext, s32 bRequest) status =REG_SetValue (CURRENTCONFIG , (u8 *)pResources, (u32 )dwBuffSize);/* Set all the other entries to NULL */ -MEM_Free (pResources); +kfree (pResources); }else { status =DSP_EMEMORY ; }
@@ -1186,7 +1186,7 @@ static DSP_STATUS RequestBridgeResources(u32 dwContext, s32 bRequest)" Failed to set the registry " "value for CURRENTCONFIG\n"); } -MEM_Free (pResources); +kfree (pResources); }/* End Mem alloc */ return status;
@@ -1309,7 +1309,7 @@ static DSP_STATUS RequestBridgeResourcesDSP(u32 dwContext, s32 bRequest) " for CURRENTCONFIG\n"); } } -MEM_Free (pResources); +kfree (pResources); }/* End Mem alloc */ return status;
drivers/dsp/bridge/rmgr/drv_interface.c +1 -1
@@ -540,7 +540,7 @@ static int bridge_release(struct inode *ip, struct file *filp)flush_signals (current);DRV_RemoveAllResources (pr_ctxt);PROC_Detach (pr_ctxt); -MEM_Free (pr_ctxt); +kfree (pr_ctxt); filp->private_data =NULL ;
drivers/dsp/bridge/rmgr/nldr.c +19 -33
117 lines not on this page · raw message
drivers/dsp/bridge/rmgr/node.c +28 -49
158 lines not on this page · raw message
drivers/dsp/bridge/rmgr/proc.c +5 -6
@@ -503,10 +503,9 @@ DSP_STATUS PROC_Detach(struct PROCESS_CONTEXT *pr_ctxt)if (pProcObject->hNtfy)NTFY_Delete (pProcObject->hNtfy); -if (pProcObject->g_pszLastCoff) { -MEM_Free (pProcObject->g_pszLastCoff); - pProcObject->g_pszLastCoff =NULL ; - } +kfree (pProcObject->g_pszLastCoff); + pProcObject->g_pszLastCoff =NULL ; +/* Remove the Proc from the DEV List */ (void )DEV_RemoveProcObject (pProcObject->hDevObject, (u32 )pProcObject);
@@ -1071,7 +1070,7 @@ DSP_STATUS PROC_Load(DSP_HPROCESSOR hProcessor, IN CONST s32 iArgc,/* Regardless of auto unregister status, * free previously allocated * memory. */ -MEM_Free (pProcObject->g_pszLastCoff); +kfree (pProcObject->g_pszLastCoff); pProcObject->g_pszLastCoff =NULL ; } }
@@ -1233,7 +1232,7 @@ DSP_STATUS PROC_Load(DSP_HPROCESSOR hProcessor, IN CONST s32 iArgc, } }/* Restore the original argv[0] */ -MEM_Free (newEnvp); +kfree (newEnvp); aArgv[0 ] = pargv0;#ifdef CONFIG_BRIDGE_DEBUG if (DSP_SUCCEEDED (status)) {
drivers/dsp/bridge/rmgr/rmm.c +9 -9
@@ -296,15 +296,15 @@ void RMM_delete(struct RMM_TargetObj *target)GT_1trace (RMM_debugMask,GT_ENTER ,"RMM_delete(0x%lx)\n" , target);if (target->segTab !=NULL ) -MEM_Free (target->segTab); +kfree (target->segTab);if (target->ovlyList) {while ((pSect = (struct RMM_OvlySect *)LST_GetHead (target->ovlyList))) { -MEM_Free (pSect); +kfree (pSect); }DBC_Assert (LST_IsEmpty (target->ovlyList)); -MEM_Free (target->ovlyList); +kfree (target->ovlyList); }if (target->freeList !=NULL ) {
@@ -314,10 +314,10 @@ void RMM_delete(struct RMM_TargetObj *target)while (next) { hptr = next; next = hptr->next; -MEM_Free (hptr); +kfree (hptr); } } -MEM_Free (target->freeList); +kfree (target->freeList); }MEM_FreeObject (target);
@@ -375,7 +375,7 @@ bool RMM_free(struct RMM_TargetObj *target, u32 segid, u32 addr, u32 size,/* Remove from list */ LST_RemoveElem (target->ovlyList, (struct list_head *)sect); -MEM_Free (sect); +kfree (sect);break ; } sect = (struct RMM_OvlySect *)LST_Next(target->ovlyList,
@@ -494,7 +494,7 @@ static bool allocBlock(struct RMM_TargetObj *target, u32 segid, u32 size,if (hsize >= allocsize) {/* big enough */ if (hsize == allocsize && prevhead !=NULL ) { prevhead->next = next; -MEM_Free (head); +kfree (head); }else { head->size = hsize - allocsize; head->addr += allocsize;
@@ -563,7 +563,7 @@ static bool freeBlock(struct RMM_TargetObj *target, u32 segid, u32 addr, head->next = rhead->next; thead->size = size + thead->size; thead->addr = addr; -MEM_Free (rhead); +kfree (rhead); rhead = thead; }
@@ -571,7 +571,7 @@ static bool freeBlock(struct RMM_TargetObj *target, u32 segid, u32 addr,if ((head->addr + head->size) == rhead->addr) { head->next = rhead->next; head->size = head->size + rhead->size; -MEM_Free (rhead); +kfree (rhead); } }
drivers/dsp/bridge/rmgr/strm.c +1 -2
@@ -873,8 +873,7 @@ DSP_STATUS STRM_Select(IN struct STRM_OBJECT **aStrmTab, u32 nStrms, } } func_end: -if (hSyncEvents) -MEM_Free (hSyncEvents); +kfree (hSyncEvents);DBC_Ensure ((DSP_SUCCEEDED (status) && (*pMask !=0 || uTimeout ==0 )) || (DSP_FAILED (status) && *pMask ==0 ));
drivers/dsp/bridge/services/mem.c +0 -17
@@ -309,23 +309,6 @@ void MEM_VFree(IN void *pMemBuf) }/* -* ======== MEM_Free ======== -* Purpose: -* Free the given block of system memory. -*/ -void MEM_Free(IN void *pMemBuf) -{ -DBC_Require (pMemBuf !=NULL ); - -GT_1trace (MEM_debugMask,GT_ENTER ,"MEM_Free: pMemBufs 0x%x\n" , - pMemBuf); - -if (pMemBuf) { -kfree (pMemBuf); - } -} - -/* * ======== MEM_FreePhysMem ======== * Purpose: * Free the given block of physically contiguous memory.
drivers/dsp/bridge/services/ntfy.c +3 -4
@@ -133,7 +133,7 @@ void NTFY_Delete(struct NTFY_OBJECT *hNtfy)DeleteNotify (pNotify); }DBC_Assert (LST_IsEmpty (hNtfy->notifyList)); -MEM_Free (hNtfy->notifyList); +kfree (hNtfy->notifyList); }if (hNtfy->hSync) (void )SYNC_DeleteCS (hNtfy->hSync);
@@ -299,9 +299,8 @@ static void DeleteNotify(struct NOTIFICATION *pNotify)if (pNotify->hSync) (void )SYNC_CloseEvent (pNotify->hSync); -if (pNotify->pstrName) -MEM_Free (pNotify->pstrName); +kfree (pNotify->pstrName); -MEM_Free (pNotify); +kfree (pNotify); }
drivers/dsp/bridge/services/regsup.c +5 -5
@@ -72,8 +72,8 @@ void regsupExit(void)while (!LST_IsEmpty (pRegKey)) { rv = (struct RegValue *)LST_GetHead (pRegKey); -MEM_Free (rv->pData); -MEM_Free (rv); +kfree (rv->pData); +kfree (rv); } }
@@ -135,7 +135,7 @@ DSP_STATUS regsupSetValue(char *valName, void *pBuf, u32 dataSize)/* Make sure the new data size is the same. */ if (dataSize != rv->dataSize) {/* The caller needs a different data size! */ -MEM_Free (rv->pData); +kfree (rv->pData); rv->pData =MEM_Alloc (dataSize,MEM_NONPAGED );if (rv->pData ==NULL )break ;
@@ -238,8 +238,8 @@ DSP_STATUS regsupDeleteValue(IN CONST char *pstrValue)* key. */ LST_RemoveElem (pRegKey, (struct list_head *)rv); -MEM_Free (rv->pData); -MEM_Free (rv); +kfree (rv->pData); +kfree (rv);/* Set our status to good and exit... */ retVal =DSP_SOK ;
drivers/dsp/bridge/services/sync.c +1 -2
@@ -375,8 +375,7 @@ DSP_STATUS SYNC_WaitOnMultipleEvents(struct SYNC_OBJECT **hSyncEvents, "SYNC:Signaling Event NULL!!!(:-\n"); status =DSP_ETIMEOUT ; } -if (Wp) -MEM_Free (Wp); +kfree (Wp);return status; }
drivers/dsp/bridge/wmd/chnl_sm.c +5 -6
@@ -159,7 +159,7 @@ DSP_STATUS WMD_CHNL_AddIOReq(struct CHNL_OBJECT *hChnl, void *pHostBuf,"Error copying user buffer to " "kernel, %d bytes remaining.\n" , status); -MEM_Free (pHostSysBuf); +kfree (pHostSysBuf); pHostSysBuf =NULL ; status =DSP_EPOINTER ; goto func_end;
@@ -466,8 +466,7 @@ DSP_STATUS WMD_CHNL_Destroy(struct CHNL_MGR *hChnlMgr)SYNC_DeleteCS (pChnlMgr->hCSObj);/* Free channel manager object: */ -if (pChnlMgr->apChannel) -MEM_Free (pChnlMgr->apChannel); +kfree (pChnlMgr->apChannel);/* Set hChnlMgr to NULL in device object. */ DEV_SetChnlMgr (pChnlMgr->hDevObject,NULL );
@@ -711,7 +710,7 @@ DSP_STATUS WMD_CHNL_GetIOC(struct CHNL_OBJECT *hChnl, u32 dwTimeOut, status =DSP_EPOINTER ; } func_cont1: -MEM_Free (pHostSysBuf); +kfree (pHostSysBuf); } func_cont:/* Update User's IOC block: */
@@ -970,9 +969,9 @@ static void FreeChirpList(struct LST_LIST *pChirpList)DBC_Require (pChirpList !=NULL );while (!LST_IsEmpty (pChirpList)) -MEM_Free (LST_GetHead (pChirpList)); +kfree (LST_GetHead (pChirpList)); -MEM_Free (pChirpList); +kfree (pChirpList); }/*
drivers/dsp/bridge/wmd/io_sm.c +5 -7
@@ -323,8 +323,7 @@ DSP_STATUS WMD_IO_Destroy(struct IO_MGR *hIOMgr)DBG_Trace (GT_2CLASS ,"DPC_Destroy: SUCCESS\n" );#ifndef DSP_TRACEBUF_DISABLED -if (hIOMgr->pMsg) -MEM_Free (hIOMgr->pMsg); +kfree (hIOMgr->pMsg);#endif SYNC_DeleteCS (hIOMgr->hCSObj);/* Leak Fix. */ /* Free this IO manager object */
@@ -816,8 +815,7 @@ DSP_STATUS WMD_IO_OnLoaded(struct IO_MGR *hIOMgr) hIOMgr->ulTraceBufferCurrent = (ulGppVa + ulSeg1Size + ulPadSize) + (hIOMgr->ulTraceBufferCurrent - ulDspVa);/* Calculate the size of trace buffer */ -if (hIOMgr->pMsg) -MEM_Free (hIOMgr->pMsg); +kfree (hIOMgr->pMsg); hIOMgr->pMsg =MEM_Alloc (((hIOMgr->ulTraceBufferEnd - hIOMgr->ulTraceBufferBegin) * hIOMgr->uWordSize) +2 ,MEM_NONPAGED );
@@ -1994,7 +1992,7 @@ static DSP_STATUS PackTraceBuffer(char *lpBuf, u32 nBytes, u32 ulNumWords)strncpy (lpBufStart, lpTmpStart, nBytes);/* Make sure output is null terminated */ lpBufStart[nBytes -1 ] ='\0' ; -MEM_Free (lpTmpStart); +kfree (lpTmpStart); }return status;
@@ -2101,8 +2099,8 @@ DSP_STATUS PrintDspTraceBuffer(struct WMD_DEV_CONTEXT *hWmdContext)GT_1trace (dsp_trace_mask,GT_1CLASS ,"DSP Trace Buffer:\n%s\n" , pszBuf); } -MEM_Free (pszBuf); -MEM_Free (lpszBuf); +kfree (pszBuf); +kfree (lpszBuf); }else {GT_0trace (dsp_trace_mask,GT_2CLASS , "PrintDspTraceBuffer: Failed to "
drivers/dsp/bridge/wmd/msg_sm.c +4 -4
@@ -559,7 +559,7 @@ static void DeleteMsgMgr(struct MSG_MGR *hMsgMgr)if (hMsgMgr->queueList) {if (LST_IsEmpty (hMsgMgr->queueList)) { -MEM_Free (hMsgMgr->queueList); +kfree (hMsgMgr->queueList); hMsgMgr->queueList =NULL ; } }
@@ -606,7 +606,7 @@ static void DeleteMsgQueue(struct MSG_QUEUE *hMsgQueue, u32 uNumToDSP)if (!LST_IsEmpty (hMsgMgr->msgFreeList)) { pMsg = (struct MSG_FRAME *)LST_GetHead (hMsgMgr-> msgFreeList); -MEM_Free (pMsg); +kfree (pMsg); }else {/* Cannot free all of the message frames */ break ;
@@ -653,11 +653,11 @@ static void FreeMsgList(struct LST_LIST *msgList) goto func_end;while ((pMsg = (struct MSG_FRAME *)LST_GetHead (msgList)) !=NULL ) -MEM_Free (pMsg); +kfree (pMsg);DBC_Assert (LST_IsEmpty (msgList)); -MEM_Free (msgList); +kfree (msgList); func_end:return ; }
drivers/dsp/bridge/wmd/tiomap3430.c +6 -11
@@ -1142,8 +1142,7 @@ static DSP_STATUS WMD_DEV_Create(OUT struct WMD_DEV_CONTEXT **ppDevContext,if (pPtAttrs->hCSObj)SYNC_DeleteCS (pPtAttrs->hCSObj); -if (pPtAttrs->pgInfo) -MEM_Free (pPtAttrs->pgInfo); +kfree (pPtAttrs->pgInfo);if (pPtAttrs->L2TblAllocVa) { MEM_FreePhysMem((void *)pPtAttrs->L2TblAllocVa,
@@ -1156,11 +1155,9 @@ static DSP_STATUS WMD_DEV_Create(OUT struct WMD_DEV_CONTEXT **ppDevContext, pPtAttrs->L1TblAllocSz); } } -if (pPtAttrs) -MEM_Free (pPtAttrs); +kfree (pPtAttrs); -if (pDevContext) -MEM_Free (pDevContext); +kfree (pDevContext);DBG_Trace (DBG_LEVEL7 ,"WMD_DEV_Create Error Device not created\n" );
@@ -1257,8 +1254,7 @@ static DSP_STATUS WMD_DEV_Destroy(struct WMD_DEV_CONTEXT *hDevContext)if (pPtAttrs->hCSObj)SYNC_DeleteCS (pPtAttrs->hCSObj); -if (pPtAttrs->pgInfo) -MEM_Free (pPtAttrs->pgInfo); +kfree (pPtAttrs->pgInfo);if (pPtAttrs->L2TblAllocVa) { MEM_FreePhysMem((void *)pPtAttrs->L2TblAllocVa,
@@ -1270,12 +1266,11 @@ static DSP_STATUS WMD_DEV_Destroy(struct WMD_DEV_CONTEXT *hDevContext) pPtAttrs->L1TblAllocPa, pPtAttrs-> L1TblAllocSz); } -if (pPtAttrs) -MEM_Free (pPtAttrs); +kfree (pPtAttrs); }/* Free the driver's device context: */ -MEM_Free ((void *) hDevContext); +kfree ((void *) hDevContext);return status; }
drivers/dsp/bridge/wmd/ue_deh.c +1 -1
@@ -339,7 +339,7 @@ DSP_STATUS WMD_DEH_GetInfo(struct DEH_MGR *hDehMgr,void WMD_DEH_ReleaseDummyMem (void ) {if (dummyVaAddr) { -MEM_Free ((void *)dummyVaAddr); +kfree ((void *)dummyVaAddr); dummyVaAddr =0 ; } }
Signature · 1 line
1.6.3.3
PATCH 3/3 DSPBRIDGE: Get rid of MEM_VFree()
In reply to Ameya Palandevfree() is NULL safe so MEM_VFree() doesn't provide any significant advantage. By getting rid of MEM_VFree() and the NULL pointer check associated with it, we can save on:
1. One level of indirection which translates to a function call cost.
2. NULL pointer checking cost.
--- arch/arm/plat-omap/include/dspbridge/mem.h | 17 ----------------- drivers/dsp/bridge/pmgr/dmm.c | 3 +-- drivers/dsp/bridge/services/mem.c | 17 ----------------- 3 files changed, 1 insertions(+), 36 deletions(-)
arch/arm/plat-omap/include/dspbridge/mem.h +0 -17
@@ -140,23 +140,6 @@extern void MEM_FlushCache (void *pMemBuf,u32 cBytes,s32 FlushType);/* -* ======== MEM_VFree ======== -* Purpose: -* Free the given block of system memory in virtual space. -* Parameters: -* pMemBuf: Pointer to memory allocated by MEM_Calloc/Alloc() -* using vmalloc. -* Returns: -* Requires: -* MEM initialized. -* pMemBuf is a valid memory address returned by MEM_Calloc/Alloc() -* using vmalloc. -* Ensures: -* pMemBuf is no longer a valid pointer to memory. -*/ - extern void MEM_VFree(IN void *pMemBuf); - -/* * ======== MEM_FreePhysMem ======== * Purpose: * Free the given block of physically contiguous memory.
drivers/dsp/bridge/pmgr/dmm.c +1 -2
@@ -220,8 +220,7 @@ DSP_STATUS DMM_DeleteTables(struct DMM_OBJECT *hDmmMgr)/* Delete all DMM tables */ SYNC_EnterCS (pDmmObj->hDmmLock); -if (pVirtualMappingTable !=NULL ) -MEM_VFree (pVirtualMappingTable); +vfree (pVirtualMappingTable);SYNC_LeaveCS (pDmmObj->hDmmLock); }else
drivers/dsp/bridge/services/mem.c +0 -17
@@ -292,23 +292,6 @@ void MEM_FlushCache(void *pMemBuf, u32 cBytes, s32 FlushType) }/* -* ======== MEM_VFree ======== -* Purpose: -* Free the given block of system memory in virtual space. -*/ -void MEM_VFree(IN void *pMemBuf) -{ -DBC_Require (pMemBuf !=NULL ); - -GT_1trace (MEM_debugMask,GT_ENTER ,"MEM_VFree: pMemBufs 0x%x\n" , - pMemBuf); - -if (pMemBuf) { -vfree (pMemBuf); - } -} - -/* * ======== MEM_FreePhysMem ======== * Purpose: * Free the given block of physically contiguous memory.
Signature · 1 line
1.6.3.3