[PATCH v2 0/5]
v2 cover [PATCH v2 0/5]
It is more logic to initialize services related modules inside services layer, even if we are planning to remove it.
v2:
- Fixed crefs build issue (patch 2) if enabling debug
Omar Ramirez Luna (5):
DSPBRIDGE: Avoid multiple calls to SERVICES_[Init|Exit]
DSPBRIDGE: remove crefs for SERVICES[Init|Exit]
DSPBRIDGE: Remove multiple initializations of MEM module
DSPBRIDGE: Remove multiple initializations of REG module
DSPBRIDGE: Remove multiple initializations of NTFY module
drivers/dsp/bridge/gen/gs.c | 8 +-- drivers/dsp/bridge/pmgr/dbll.c | 15 +---- drivers/dsp/bridge/pmgr/wcd.c | 17 +----- drivers/dsp/bridge/rmgr/dbdcd.c | 15 +----- drivers/dsp/bridge/rmgr/rmm.c | 17 +----- drivers/dsp/bridge/services/mem.c | 36 ++---------- drivers/dsp/bridge/services/services.c | 100 ++++++++++++-------------------- 7 files changed, 53 insertions(+), 155 deletions(-)
PATCH v2 1/5 DSPBRIDGE: Avoid multiple calls to SERVICES_[Init|Exit]
Avoid calling multiple times to SERVICES_[Init|Exit] functions, these should be called once at probe and exit respectively.
--- drivers/dsp/bridge/pmgr/wcd.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/dsp/bridge/pmgr/wcd.c +2 -8
@@ -302,7 +302,6 @@ void WCD_Exit(void)MGR_Exit ();RMM_exit ();DRV_Exit (); -SERVICES_Exit (); }DBC_Ensure (WCD_cRefs >=0 ); }
@@ -315,12 +314,10 @@ void WCD_Exit(void)bool WCD_Init (void ) {bool fInit = true; -bool fDRV, fDEV, fCOD, fSERVICES, fCHNL, fMSG, fIO; +bool fDRV, fDEV, fCOD, fCHNL, fMSG, fIO;bool fMGR, fPROC, fNODE, fDISP, fNTFY, fSTRM, fRMM;if (WCD_cRefs ==0 ) { -/* initialize all SERVICES modules */ - fSERVICES =SERVICES_Init ();/* initialize debugging module */ DBC_Assert (!WCD_debugMask.flags);GT_create (&WCD_debugMask,"CD" );/* CD for class driver */
@@ -338,13 +335,10 @@ bool WCD_Init(void) fIO =IO_Init (); fDEV =DEV_Init (); fCOD =COD_Init (); - fInit = fSERVICES && fDRV && fDEV && fCHNL && fCOD && + fInit = fDRV && fDEV && fCHNL && fCOD && fMSG && fIO; fInit = fInit && fMGR && fPROC && fRMM;if (!fInit) { -if (fSERVICES) -SERVICES_Exit (); -if (fDRV)DRV_Exit ();
Signature · 1 line
1.6.2.4
PATCH v2 2/5 DSPBRIDGE: remove crefs for SERVICES[Init|Exit]
No point in having a module counter if these are called only once.
--- drivers/dsp/bridge/services/services.c | 100 ++++++++++++-------------------- 1 files changed, 37 insertions(+), 63 deletions(-)
drivers/dsp/bridge/services/services.c +37 -63
@@ -43,8 +43,6 @@static struct GT_Mask SERVICES_debugMask = {NULL ,NULL };/* GT trace var. */ #endif -static u32 cRefs;/* SERVICES module reference count */ -/* * ======== SERVICES_Exit ======== * Purpose:
@@ -53,26 +51,16 @@ static u32 cRefs; /* SERVICES module reference count */*/ void SERVICES_Exit (void ) { -DBC_Require (cRefs >0 ); - -GT_1trace (SERVICES_debugMask,GT_5CLASS ,"SERVICES_Exit: cRefs 0x%x\n" , - cRefs); - - cRefs--; -if (cRefs ==0 ) { -/* Uninitialize all SERVICES modules here */ -NTFY_Exit (); -SYNC_Exit (); -CLK_Exit (); -REG_Exit (); -DBG_Exit (); -CFG_Exit (); -MEM_Exit (); - -GT_exit (); - } - -DBC_Ensure (cRefs >=0 ); +/* Uninitialize all SERVICES modules here */ +NTFY_Exit (); +SYNC_Exit (); +CLK_Exit (); +REG_Exit (); +DBG_Exit (); +CFG_Exit (); +MEM_Exit (); + +GT_exit (); }/*
@@ -86,61 +74,47 @@ bool SERVICES_Init(void)bool fCFG, fDBG, fMEM;bool fREG, fSYNC, fCLK, fNTFY; -DBC_Require (cRefs >=0 ); - -if (cRefs ==0 ) { +GT_init (); +GT_create (&SERVICES_debugMask,"OS" );/* OS for OSal */ -GT_init (); -GT_create (&SERVICES_debugMask,"OS" );/* OS for OSal */ - -GT_0trace (SERVICES_debugMask,GT_ENTER , +GT_0trace (SERVICES_debugMask,GT_ENTER ,"SERVICES_Init: entered\n" ); -/* Perform required initialization of SERVICES modules. */ - fMEM =MEM_Init (); - fREG =REG_Init (); - fCFG =CFG_Init (); - fDBG =DBG_Init (); - fSYNC =SYNC_Init (); - fCLK =CLK_Init (); - fNTFY =NTFY_Init (); +/* Perform required initialization of SERVICES modules. */ + fMEM =MEM_Init (); + fREG =REG_Init (); + fCFG =CFG_Init (); + fDBG =DBG_Init (); + fSYNC =SYNC_Init (); + fCLK =CLK_Init (); + fNTFY =NTFY_Init (); - fInit = fCFG && fDBG && - fMEM && fREG && fSYNC && fCLK; + fInit = fCFG && fDBG && fMEM && fREG && fSYNC && fCLK; -if (!fInit) { -if (fNTFY) -NTFY_Exit (); +if (!fInit) { +if (fNTFY) +NTFY_Exit (); -if (fSYNC) -SYNC_Exit (); +if (fSYNC) +SYNC_Exit (); -if (fCLK) -CLK_Exit (); +if (fCLK) +CLK_Exit (); -if (fREG) -REG_Exit (); +if (fREG) +REG_Exit (); -if (fDBG) -DBG_Exit (); +if (fDBG) +DBG_Exit (); -if (fCFG) -CFG_Exit (); +if (fCFG) +CFG_Exit (); -if (fMEM) -MEM_Exit (); +if (fMEM) +MEM_Exit (); - } } -if (fInit) - cRefs++; - -GT_1trace (SERVICES_debugMask,GT_5CLASS ,"SERVICES_Init: cRefs 0x%x\n" , - cRefs); - -DBC_Ensure ((fInit && (cRefs >0 )) || (!fInit && (cRefs >=0 ))); -return fInit; }
Signature · 1 line
1.6.2.4
PATCH v2 3/5 DSPBRIDGE: Remove multiple initializations of MEM module
MEM module should be only initialized by services layer, removed reference counter for it.
--- drivers/dsp/bridge/gen/gs.c | 8 ++------ drivers/dsp/bridge/pmgr/dbll.c | 15 ++------------- drivers/dsp/bridge/rmgr/dbdcd.c | 8 +------- drivers/dsp/bridge/rmgr/rmm.c | 17 ++--------------- drivers/dsp/bridge/services/mem.c | 36 ++++++------------------------------ 5 files changed, 13 insertions(+), 71 deletions(-)
drivers/dsp/bridge/gen/gs.c +2 -6
@@ -52,7 +52,7 @@ void *GS_alloc(u32 size)*/ void GS_exit (void ) { -MEM_Exit (); +/* Do nothing */ }/*
@@ -85,9 +85,5 @@ void GS_frees(void *ptr, u32 size)*/ void GS_init (void ) { -static bool curInit; - -if (curInit == false) { - curInit =MEM_Init ();/* which can't fail currently. */ - } +/* Do nothing */ }
drivers/dsp/bridge/pmgr/dbll.c +2 -13
@@ -317,7 +317,6 @@ void DBLL_exit(void) cRefs);if (cRefs ==0 ) { -MEM_Exit ();GH_exit ();#if GT_TRACE DBLL_debugMask.flags =NULL ;
@@ -468,30 +467,20 @@ DSP_STATUS DBLL_getSect(struct DBLL_LibraryObj *lib, char *name, u32 *pAddr,*/ bool DBLL_init (void ) { -bool retVal = true; -DBC_Require (cRefs >=0 );if (cRefs ==0 ) {DBC_Assert (!DBLL_debugMask.flags);GT_create (&DBLL_debugMask,"DL" );/* "DL" for dbDL */ GH_init (); - retVal =MEM_Init (); -if (!retVal) -MEM_Exit (); - } -if (retVal) - cRefs++; - + cRefs++;GT_1trace (DBLL_debugMask,GT_5CLASS ,"DBLL_init(), ref count: 0x%x\n" , cRefs); -DBC_Ensure ((retVal && (cRefs >0 )) || (!retVal && (cRefs >=0 ))); - -return retVal; +return true; }/*
drivers/dsp/bridge/rmgr/dbdcd.c +1 -7
@@ -352,7 +352,6 @@ void DCD_Exit(void)if (cRefs ==0 ) {REG_Exit ();COD_Exit (); -MEM_Exit (); }DBC_Ensure (cRefs >=0 );
@@ -822,7 +821,6 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER *hDcdMgr,*/ bool DCD_Init (void ) { -bool fInitMEM;bool fInitREG;bool fInitCOD;bool fInit = true;
@@ -834,17 +832,13 @@ bool DCD_Init(void)if (cRefs ==0 ) {/* Initialize required modules. */ - fInitMEM =MEM_Init (); fInitCOD =COD_Init (); fInitREG =REG_Init (); -if (!fInitMEM || !fInitCOD || !fInitREG) { +if (!fInitCOD || !fInitREG) { fInit = false;GT_0trace (curTrace,GT_6CLASS ,"DCD_Init failed\n" );/* Exit initialized modules. */ -if (fInitMEM) -MEM_Exit (); -if (fInitCOD)COD_Exit ();
drivers/dsp/bridge/rmgr/rmm.c +2 -15
@@ -335,9 +335,6 @@ void RMM_exit(void)GT_1trace (RMM_debugMask,GT_5CLASS ,"RMM_exit() ref count: 0x%x\n" , cRefs); -if (cRefs ==0 ) -MEM_Exit (); -DBC_Ensure (cRefs >=0 ); }
@@ -396,31 +393,21 @@ bool RMM_free(struct RMM_TargetObj *target, u32 segid, u32 addr, u32 size,*/ bool RMM_init (void ) { -bool retVal = true; -DBC_Require (cRefs >=0 );if (cRefs ==0 ) {DBC_Assert (!RMM_debugMask.flags);GT_create (&RMM_debugMask,"RM" );/* "RM" for RMm */ - retVal =MEM_Init (); - -if (!retVal) -MEM_Exit (); - } -if (retVal) - cRefs++; + cRefs++;GT_1trace (RMM_debugMask,GT_5CLASS ,"RMM_init(), ref count: 0x%x\n" , cRefs); -DBC_Ensure ((retVal && (cRefs >0 )) || (!retVal && (cRefs >=0 ))); - -return retVal; +return true; }/*
drivers/dsp/bridge/services/mem.c +6 -30
@@ -45,8 +45,6 @@static struct GT_Mask MEM_debugMask = {NULL ,NULL };/* GT trace variable */ #endif -static u32 cRefs;/* module reference count */ -static bool extPhysMemPoolEnabled;struct extPhysMemPool {
@@ -307,8 +305,6 @@ void *MEM_AllocPhysMem(u32 cBytes, u32 ulAlign, OUT u32 *pPhysicalAddress)void *pVaMem =NULL ;dma_addr_t paMem; -DBC_Require (cRefs >0 ); -GT_2trace (MEM_debugMask,GT_ENTER ,"MEM_AllocPhysMem: cBytes 0x%x\tulAlign" "0x%x\n" , cBytes, ulAlign);
@@ -414,17 +410,9 @@ void *MEM_Calloc(u32 cBytes, enum MEM_POOLATTRS type)*/ void MEM_Exit (void ) { -DBC_Require (cRefs >0 ); - -GT_1trace (MEM_debugMask,GT_5CLASS ,"MEM_Exit: cRefs 0x%x\n" , cRefs); - - cRefs--;#ifdef MEM_CHECK -if (cRefs ==0 ) -MEM_Check (); - +MEM_Check ();#endif -DBC_Ensure (cRefs >=0 ); }/*
@@ -434,7 +422,7 @@ void MEM_Exit(void)*/ void MEM_FlushCache (void *pMemBuf,u32 cBytes,s32 FlushType) { -if (cRefs <=0 || !pMemBuf) +if (!pMemBuf)return ;switch (FlushType) {
@@ -546,7 +534,6 @@ void MEM_Free(IN void *pMemBuf)void MEM_FreePhysMem (void *pVirtualAddress,u32 pPhysicalAddress,u32 cBytes) { -DBC_Require (cRefs >0 );DBC_Require (pVirtualAddress !=NULL ); GT_1trace(MEM_debugMask, GT_ENTER, "MEM_FreePhysMem: pVirtualAddress "
@@ -564,24 +551,13 @@ void MEM_FreePhysMem(void *pVirtualAddress, u32 pPhysicalAddress,*/ bool MEM_Init (void ) { -DBC_Require (cRefs >=0 ); - -if (cRefs ==0 ) { -GT_create (&MEM_debugMask,"MM" );/* MM for MeM module */ +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); + mMan.lst.head.next = &mMan.lst.head; + mMan.lst.head.prev = &mMan.lst.head; +spin_lock_init (&mMan.lock);#endif - } - - cRefs++; - -GT_1trace (MEM_debugMask,GT_5CLASS ,"MEM_Init: cRefs 0x%x\n" , cRefs); - -DBC_Ensure (cRefs >0 ); -return true; }
Signature · 1 line
1.6.2.4
PATCH v2 4/5 DSPBRIDGE: Remove multiple initializations of REG module
REG module should be only initialized by services layer.
--- drivers/dsp/bridge/rmgr/dbdcd.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
drivers/dsp/bridge/rmgr/dbdcd.c +1 -8
@@ -350,7 +350,6 @@ void DCD_Exit(void) cRefs--;if (cRefs ==0 ) { -REG_Exit ();COD_Exit (); }
@@ -821,7 +820,6 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER *hDcdMgr,*/ bool DCD_Init (void ) { -bool fInitREG;bool fInitCOD;bool fInit = true;
@@ -833,18 +831,13 @@ bool DCD_Init(void)if (cRefs ==0 ) {/* Initialize required modules. */ fInitCOD =COD_Init (); - fInitREG =REG_Init (); -if (!fInitCOD || !fInitREG) { +if (!fInitCOD) { fInit = false;GT_0trace (curTrace,GT_6CLASS ,"DCD_Init failed\n" );/* Exit initialized modules. */ if (fInitCOD)COD_Exit (); - -if (fInitREG) -REG_Exit (); - } }
Signature · 1 line
1.6.2.4
PATCH v2 5/5 DSPBRIDGE: Remove multiple initializations of NTFY module
NTFY module should be only initialized by services layer.
--- drivers/dsp/bridge/pmgr/wcd.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/dsp/bridge/pmgr/wcd.c +1 -6
@@ -295,7 +295,6 @@ void WCD_Exit(void)MSG_Exit ();IO_Exit ();STRM_Exit (); -NTFY_Exit ();DISP_Exit ();NODE_Exit ();PROC_Exit ();
@@ -315,7 +314,7 @@ bool WCD_Init(void) {bool fInit = true;bool fDRV, fDEV, fCOD, fCHNL, fMSG, fIO; -bool fMGR, fPROC, fNODE, fDISP, fNTFY, fSTRM, fRMM; +bool fMGR, fPROC, fNODE, fDISP, fSTRM, fRMM;if (WCD_cRefs ==0 ) {/* initialize debugging module */
@@ -327,7 +326,6 @@ bool WCD_Init(void) fPROC =PROC_Init (); fNODE =NODE_Init (); fDISP =DISP_Init (); - fNTFY =NTFY_Init (); fSTRM =STRM_Init (); fRMM =RMM_init (); fCHNL =CHNL_Init ();
@@ -357,9 +355,6 @@ bool WCD_Init(void)if (fDISP)DISP_Exit (); -if (fNTFY) -NTFY_Exit (); -if (fCHNL)CHNL_Exit ();
Signature · 1 line
1.6.2.4
RE: [PATCH v2 4/5] DSPBRIDGE: Remove multiple initializations of REG module
In reply to Omar Ramirez LunaHi,
Quoted 48 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Ramirez Luna, Omar
Sent: Tuesday, January 26, 2010 6:57 PM
To: linux-omap
Cc: Ameya Palande; Hiroshi Doyu; Felipe Contreras; Menon, Nishanth; Ramirez Luna, Omar
Subject: [PATCH v2 4/5] DSPBRIDGE: Remove multiple initializations of REG moduleREG module should be only initialized by services layer.
Signed-off-by Omar Ramirez Luna <[email protected]>---
drivers/dsp/bridge/rmgr/dbdcd.c| 9 +--------1 files changed, 1 insertions(+), 8 deletions(-)drivers/dsp/bridge/rmgr/dbdcd.c +1
-4@@ -350,7 +350,6 @@ void DCD_Exit(void) cRefs--;if (cRefs ==0 ) { -REG_Exit ();COD_Exit (); }@@ -821,7 +820,6 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER*hDcdMgr, */ bool DCD_Init (void ) { -bool fInitREG;bool fInitCOD;bool fInit = true;@@ -833,18 +831,13 @@ bool DCD_Init(void)if (cRefs ==0 ) {/* Initialize required modules. */ fInitCOD =COD_Init (); - fInitREG =REG_Init (); -if (!fInitCOD || !fInitREG) { +if (!fInitCOD) { fInit = false;
drivers/dsp/bridge/rmgr/dbdcd.c bool DCD_Init(void) · line 842
Quoted 10 lines
drivers/dsp/bridge/rmgr/dbdcd.c +0
-4GT_0trace (curTrace,GT_6CLASS ,"DCD_Init failed\n" );/* Exit initialized modules. */ if (fInitCOD)COD_Exit (); - -if (fInitREG) -REG_Exit (); - } }
Now DCD_Init() is only initializing COD module maybe you can remove DCD_Init and just call COD_Init(), if it is not good for consistency you can replace the function for something like this:
bool DCD_Init(void)
{
return COD_Init();
}All the other stuff are not needed.
Regards,
Fernando.
Quoted 8 lines
drivers/dsp/bridge/rmgr/dbdcd.c +0
-1--1.6.2.4
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 4/5] DSPBRIDGE: Remove multiple initializations of REG module
Quoted 65 lines · Fernando
Hi,
Quoted 48 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Ramirez Luna, Omar
Sent: Tuesday, January 26, 2010 6:57 PM
To: linux-omap
Cc: Ameya Palande; Hiroshi Doyu; Felipe Contreras; Menon, Nishanth; Ramirez Luna, Omar
Subject: [PATCH v2 4/5] DSPBRIDGE: Remove multiple initializations of REG moduleREG module should be only initialized by services layer.
Signed-off-by Omar Ramirez Luna<[email protected]>---
drivers/dsp/bridge/rmgr/dbdcd.c| 9 +--------1 files changed, 1 insertions(+), 8 deletions(-)drivers/dsp/bridge/rmgr/dbdcd.c +1
-4@@ -350,7 +350,6 @@ void DCD_Exit(void) cRefs--;if (cRefs ==0 ) { -REG_Exit ();COD_Exit (); }@@ -821,7 +820,6 @@ DSP_STATUS DCD_GetLibraryName(IN struct DCD_MANAGER*hDcdMgr, */ bool DCD_Init (void ) { -bool fInitREG;bool fInitCOD;bool fInit = true;@@ -833,18 +831,13 @@ bool DCD_Init(void)if (cRefs ==0 ) {/* Initialize required modules. */ fInitCOD =COD_Init (); - fInitREG =REG_Init (); -if (!fInitCOD || !fInitREG) { +if (!fInitCOD) { fInit = false;drivers/dsp/bridge/rmgr/dbdcd.c bool DCD_Init(void) · line 842
Quoted 10 lines
drivers/dsp/bridge/rmgr/dbdcd.c +0
-4GT_0trace (curTrace,GT_6CLASS ,"DCD_Init failed\n" );/* Exit initialized modules. */ if (fInitCOD)COD_Exit (); - -if (fInitREG) -REG_Exit (); - } }Now
DCD_Init()is only initializing COD module maybe you can removeDCD_Initand just callCOD_Init(), if it is not good for consistency you can replace the function for something like this:
Quoted 7 lines
bool
DCD_Init(void){ return COD_Init(); }All the other stuff are not needed.
Agree, but this should be a separate patch as this series only touch services layer init functions.
- omar
Omar Ramirez Luna
AppliedRe: [PATCH v2 0/5] DSPBRIDGE: centralized services initialization
In reply to Omar Ramirez LunaQuoted 13 lines · Omar
It is more logic to initialize services related modules inside services layer, even if we are planning to remove it.
v2:
- Fixed crefs build issue (patch 2) if enabling debugOmar Ramirez Luna (5):
DSPBRIDGE: Avoid multiple calls to SERVICES_[Init|Exit]
DSPBRIDGE: remove crefs for SERVICES[Init|Exit]
DSPBRIDGE: Remove multiple initializations of MEM module
DSPBRIDGE: Remove multiple initializations of REG module
DSPBRIDGE: Remove multiple initializations of NTFY module
Quoted 9 lines
drivers/dsp/bridge/gen/gs.c | 8 +-- drivers/dsp/bridge/pmgr/dbll.c | 15 +---- drivers/dsp/bridge/pmgr/wcd.c | 17 +----- drivers/dsp/bridge/rmgr/dbdcd.c | 15 +----- drivers/dsp/bridge/rmgr/rmm.c | 17 +----- drivers/dsp/bridge/services/mem.c | 36 ++---------- drivers/dsp/bridge/services/services.c | 100 ++++++++++++-------------------- 7 files changed, 53 insertions(+), 155 deletions(-)
Pushed to dspbridge.
- omar