Skip to contentSkip to conversation

DSPBRIDGE: centralized services initialization

PATCH Superseded Omar Ramirez Luna 1 participant 7 messages Jan 23, 2010 – Jan 26, 2010

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover DSPBRIDGE: centralized services initialization

It is more logic to initialize services related modules inside services layer, even if we are planning to remove it.

This set should be applied after Andy's List patches.

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        |   14 +-----
 drivers/dsp/bridge/rmgr/rmm.c          |   17 +-----
 drivers/dsp/bridge/services/mem.c      |   36 ++----------
 drivers/dsp/bridge/services/services.c |   92 +++++++++++++-------------------
 7 files changed, 53 insertions(+), 146 deletions(-)
#1 lore raw

PATCH 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
index 962cac6..2afe222 100644
@@ -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
#2 lore raw

PATCH 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 |   92 +++++++++++++-------------------
 1 files changed, 37 insertions(+), 55 deletions(-)
drivers/dsp/bridge/services/services.c +37 -55
index c3e11b4..efcb0a1 100644
@@ -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,21 @@ 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();
-	}
+	/* Uninitialize all SERVICES modules here */
+	NTFY_Exit();
+	SYNC_Exit();
+	CLK_Exit();
+	REG_Exit();
+	DBG_Exit();
+	CFG_Exit();
+	MEM_Exit();
 
-	DBC_Ensure(cRefs >= 0);
+	GT_exit();
 }
 
 /*
@@ -86,61 +79,50 @@ 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
#3 lore raw

PATCH 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
index 5a5684c..1197829 100644
@@ -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
index 5422d21..80ca4d4 100644
@@ -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
index 3d50952..cb244f4 100644
@@ -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
index cdd987a..5c484bc 100644
@@ -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
index 4d01917..cee646a 100644
@@ -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
#4 lore raw

PATCH 4/5 DSPBRIDGE: Remove multiple initializations of REG module

REG module should be only initialized by services layer.

---
 drivers/dsp/bridge/rmgr/dbdcd.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/dsp/bridge/rmgr/dbdcd.c +1 -7
index cb244f4..d90aa83 100644
@@ -350,7 +350,6 @@ void DCD_Exit(void)
 
 	cRefs--;
 	if (cRefs == 0) {
-		REG_Exit();
 		COD_Exit();
 	}
 
@@ -833,18 +832,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
#5 lore raw

PATCH RESEND 4/5 DSPBRIDGE: Remove multiple initializations of REG module

From cab08d7241af701397f6e78723d8e2125c3f2306 Mon Sep 17 00:00:00 2001
From: Omar Ramirez Luna <[email protected]>
Date: Thu, 21 Jan 2010 20:34:20 -0600
Subject: [PATCH 08/15] 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
index cb244f4..caa57f1 100644
@@ -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
#6 lore raw

PATCH 5/5 DSPBRIDGE: Remove multiple initializations of NTFY module

In reply to Omar Ramirez Luna

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
index 2afe222..b92386a 100644
@@ -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