Skip to contentSkip to conversation

DSPBRIDGE: Remove DMM physical addres table

PATCH In review Omar Ramirez Luna 2 participants 4 messages Jul 19, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 DSPBRIDGE: Remove DMM physical addres table

From: Hari Kanigeri <[email protected]>

Physical address is not needed anymore since Mapping migration to open source API, this patch removes the physical table entry.

---
 arch/arm/plat-omap/include/dspbridge/dmm.h |    1 -
 drivers/dsp/bridge/pmgr/dmm.c              |   35 ------------------
 drivers/dsp/bridge/wmd/tiomap3430.c        |   55 +++++++++++++++++-----------
 3 files changed, 34 insertions(+), 57 deletions(-)
arch/arm/plat-omap/include/dspbridge/dmm.h +0 -1
index ef37668..335edf8 100644
@@ -81,5 +81,4 @@
 
 	extern DSP_STATUS DMM_CreateTables(struct DMM_OBJECT *hDmmMgr,
 						u32 addr, u32 size);
-	extern u32 *DMM_GetPhysicalAddrTable(void);
 #endif				/* DMM_ */
drivers/dsp/bridge/pmgr/dmm.c +0 -35
index 803de93..f4fc6ec 100644
@@ -113,7 +113,6 @@ struct MapPage {
 static struct MapPage *pVirtualMappingTable;
 static u32  iFreeRegion;	/* The index of free region */
 static u32  iFreeSize;
-static u32  *pPhysicalAddrTable;	/* Physical address of MPU buffer */
 static u32  dynMemMapBeg;	/* The Beginning of dynamic memory mapping */
 static u32  TableSize;/* The size of virtual and physical pages tables */
 
@@ -151,28 +150,11 @@ DSP_STATUS DMM_CreateTables(struct DMM_OBJECT *hDmmMgr, u32 addr, u32 size)
 		if (pVirtualMappingTable == NULL)
 			status = DSP_EMEMORY;
 		else {
-			/* This table will be used
-			* to store the virtual to physical
-			* address translations
-			*/
-			pPhysicalAddrTable = (u32 *)MEM_Calloc
-				(TableSize*sizeof(u32), MEM_NONPAGED);
-			GT_1trace(DMM_debugMask, GT_4CLASS,
-			"DMM_CreateTables: Allocate"
-			"memory for pPhysicalAddrTable=%d entries\n",
-			TableSize);
-			if (pPhysicalAddrTable == NULL) {
-				status = DSP_EMEMORY;
-				GT_0trace(DMM_debugMask, GT_7CLASS,
-				    "DMM_CreateTables: Memory allocation for "
-				    "pPhysicalAddrTable failed\n");
-			} else {
 			/* On successful allocation,
 			* all entries are zero ('free') */
 			iFreeRegion = 0;
 			iFreeSize = TableSize*PG_SIZE_4K;
 			pVirtualMappingTable[0].RegionSize = TableSize;
-			}
 		}
 		SYNC_LeaveCS(pDmmObj->hDmmLock);
 	} else
@@ -275,9 +257,6 @@ DSP_STATUS DMM_DeleteTables(struct DMM_OBJECT *hDmmMgr)
 		if (pVirtualMappingTable != NULL)
 			MEM_Free(pVirtualMappingTable);
 
-		if (pPhysicalAddrTable != NULL)
-			MEM_Free(pPhysicalAddrTable);
-
 		SYNC_LeaveCS(pDmmObj->hDmmLock);
 	} else
 		status = DSP_EHANDLE;
@@ -361,7 +340,6 @@ bool DMM_Init(void)
 	DBC_Ensure((fRetval && (cRefs > 0)) || (!fRetval && (cRefs >= 0)));
 
 	pVirtualMappingTable = NULL ;
-	pPhysicalAddrTable = NULL ;
 	TableSize = 0;
 
 	return fRetval;
@@ -635,19 +613,6 @@ static struct MapPage *GetMappedRegion(u32 aAddr)
 	return currRegion;
 }
 
-/*
- *  ======== DMM_GetPhysicalAddrTable ========
- *  Purpose:
- *  Returns the physical table address
- */
-u32 *DMM_GetPhysicalAddrTable(void)
-{
-	GT_1trace(DMM_debugMask, GT_ENTER, "Entered "
-			"DMM_GetPhysicalAddrTable()- pPhysicalAddrTable 0x%x\n",
-			pPhysicalAddrTable);
-	return pPhysicalAddrTable;
-}
-
 #ifdef DSP_DMM_DEBUG
 u32 DMM_MemMapDump(struct DMM_OBJECT *hDmmMgr)
 {
drivers/dsp/bridge/wmd/tiomap3430.c +34 -21

85 lines not on this page · raw message

Signature · 1 line
1.6.2.4
#1 lore raw

PATCH 2/3 DSPBRIDGE: less code nesting for MemUnMap

less code nesting for MemUnMap

---
 drivers/dsp/bridge/wmd/tiomap3430.c |  271 +++++++++++++++++------------------
 1 files changed, 130 insertions(+), 141 deletions(-)
drivers/dsp/bridge/wmd/tiomap3430.c +130 -141
index 449de01..268de07 100644
@@ -1612,157 +1612,146 @@ static DSP_STATUS WMD_BRD_MemUnMap(struct WMD_DEV_CONTEXT *hDevContext,
 		pteAddrL1 = HW_MMU_PteAddrL1(L1BaseVa, vaCurr);
 		pteVal = *(u32 *)pteAddrL1;
 		pteSize = HW_MMU_PteSizeL1(pteVal);
-		if (pteSize == HW_MMU_COARSE_PAGE_SIZE) {
-			/*
-			 * Get the L2 PA from the L1 PTE, and find
-			 * corresponding L2 VA
-			 */
-			L2BasePa = HW_MMU_PteCoarseL1(pteVal);
-			L2BaseVa = L2BasePa - pt->L2BasePa + pt->L2BaseVa;
-			L2PageNum = (L2BasePa - pt->L2BasePa) /
-				    HW_MMU_COARSE_PAGE_SIZE;
-			/*
-			 * Find the L2 PTE address from which we will start
-			 * clearing, the number of PTEs to be cleared on this
-			 * page, and the size of VA space that needs to be
-			 * cleared on this L2 page
-			 */
-			pteAddrL2 = HW_MMU_PteAddrL2(L2BaseVa, vaCurr);
-			pteCount = pteAddrL2 & (HW_MMU_COARSE_PAGE_SIZE - 1);
-			pteCount = (HW_MMU_COARSE_PAGE_SIZE - pteCount) /
-				    sizeof(u32);
-			if (remBytes < (pteCount * PG_SIZE_4K))
-				pteCount = remBytes / PG_SIZE_4K;
-
-			remBytesL2 = pteCount * PG_SIZE_4K;
-			DBG_Trace(DBG_LEVEL1, "WMD_BRD_MemUnMap L2BasePa %x, "
-				  "L2BaseVa %x pteAddrL2 %x, remBytesL2 %x\n",
-				  L2BasePa, L2BaseVa, pteAddrL2, remBytesL2);
-			/*
-			 * Unmap the VA space on this L2 PT. A quicker way
-			 * would be to clear pteCount entries starting from
-			 * pteAddrL2. However, below code checks that we don't
-			 * clear invalid entries or less than 64KB for a 64KB
-			 * entry. Similar checking is done for L1 PTEs too
-			 * below
-			 */
-			while (remBytesL2 && (DSP_SUCCEEDED(status))) {
-				pteVal = *(u32 *)pteAddrL2;
-				pteSize = HW_MMU_PteSizeL2(pteVal);
-				/* vaCurr aligned to pteSize? */
-				if ((pteSize != 0) && (remBytesL2 >= pteSize) &&
-				   !(vaCurr & (pteSize - 1))) {
-					/* Collect Physical addresses from VA */
-					pAddr = (pteVal & ~(pteSize - 1));
-					if (pteSize == HW_PAGE_SIZE_64KB)
-						numof4KPages = 16;
-					else
-						numof4KPages = 1;
-					temp = 0;
-					while (temp++ < numof4KPages) {
-						if (!pfn_valid(__phys_to_pfn(
-								pAddr))) {
-							pAddr +=
-							    HW_PAGE_SIZE_4KB;
-							continue;
-						}
-						pg = phys_to_page(pAddr);
-						if (page_count(pg) < 1) {
-							pr_info("DSPBRIDGE:"
-							    "UNMAP function: "
-							    "COUNT 0 FOR PA "
-							    "0x%x, size = "
-							    "0x%x\n", pAddr,
-							    ulNumBytes);
-							bad_page_dump(pAddr,
-									pg);
-						}
-						SetPageDirty(pg);
-						page_cache_release(pg);
-						pAddr += HW_PAGE_SIZE_4KB;
-					}
-					if (HW_MMU_PteClear(pteAddrL2,
-						vaCurr, pteSize) == RET_OK) {
-						status = DSP_SOK;
-						remBytesL2 -= pteSize;
-						vaCurr += pteSize;
-						pteAddrL2 += (pteSize >> 12) *
-								sizeof(u32);
-					} else {
-						status = DSP_EFAIL;
-						goto EXIT_LOOP;
-					}
-				} else {
-					status = DSP_EFAIL;
-				}
-			}
-			SYNC_EnterCS(pt->hCSObj);
-			if (remBytesL2 == 0) {
-				pt->pgInfo[L2PageNum].numEntries -= pteCount;
-				if (pt->pgInfo[L2PageNum].numEntries == 0) {
-					/*
-					 * Clear the L1 PTE pointing to the
-					 * L2 PT
-					 */
-					if (RET_OK == HW_MMU_PteClear(L1BaseVa,
-					vaCurrOrig, HW_MMU_COARSE_PAGE_SIZE))
-						status = DSP_SOK;
-					else {
-						status = DSP_EFAIL;
-						SYNC_LeaveCS(pt->hCSObj);
-						goto EXIT_LOOP;
-					}
-				}
-				remBytes -= pteCount * PG_SIZE_4K;
-			} else {
+
+		if (pteSize != HW_MMU_COARSE_PAGE_SIZE)
+			goto skip_coarse_page;
+
+		/*
+		 * Get the L2 PA from the L1 PTE, and find
+		 * corresponding L2 VA
+		 */
+		L2BasePa = HW_MMU_PteCoarseL1(pteVal);
+		L2BaseVa = L2BasePa - pt->L2BasePa + pt->L2BaseVa;
+		L2PageNum = (L2BasePa - pt->L2BasePa) / HW_MMU_COARSE_PAGE_SIZE;
+		/*
+		 * Find the L2 PTE address from which we will start
+		 * clearing, the number of PTEs to be cleared on this
+		 * page, and the size of VA space that needs to be
+		 * cleared on this L2 page
+		 */
+		pteAddrL2 = HW_MMU_PteAddrL2(L2BaseVa, vaCurr);
+		pteCount = pteAddrL2 & (HW_MMU_COARSE_PAGE_SIZE - 1);
+		pteCount = (HW_MMU_COARSE_PAGE_SIZE - pteCount) / sizeof(u32);
+		if (remBytes < (pteCount * PG_SIZE_4K))
+			pteCount = remBytes / PG_SIZE_4K;
+		remBytesL2 = pteCount * PG_SIZE_4K;
+		DBG_Trace(DBG_LEVEL1, "WMD_BRD_MemUnMap L2BasePa %x, "
+			  "L2BaseVa %x pteAddrL2 %x, remBytesL2 %x\n",
+			  L2BasePa, L2BaseVa, pteAddrL2, remBytesL2);
+		/*
+		 * Unmap the VA space on this L2 PT. A quicker way
+		 * would be to clear pteCount entries starting from
+		 * pteAddrL2. However, below code checks that we don't
+		 * clear invalid entries or less than 64KB for a 64KB
+		 * entry. Similar checking is done for L1 PTEs too
+		 * below
+		 */
+		while (remBytesL2 && (DSP_SUCCEEDED(status))) {
+			pteVal = *(u32 *)pteAddrL2;
+			pteSize = HW_MMU_PteSizeL2(pteVal);
+			/* vaCurr aligned to pteSize? */
+			if (pteSize == 0 || remBytesL2 < pteSize ||
+						vaCurr & (pteSize - 1)) {
 				status = DSP_EFAIL;
+				break;
 			}
-			DBG_Trace(DBG_LEVEL1, "WMD_BRD_MemUnMap L2PageNum %x, "
-				  "numEntries %x, pteCount %x, status: 0x%x\n",
-				  L2PageNum, pt->pgInfo[L2PageNum].numEntries,
-				  pteCount, status);
-			SYNC_LeaveCS(pt->hCSObj);
-		} else
-			/* vaCurr aligned to pteSize? */
-			/* pteSize = 1 MB or 16 MB */
-			if ((pteSize != 0) && (remBytes >= pteSize) &&
-			   !(vaCurr & (pteSize - 1))) {
-				if (pteSize == HW_PAGE_SIZE_1MB)
-					numof4KPages = 256;
-				else
-					numof4KPages = 4096;
-				temp = 0;
-				/* Collect Physical addresses from VA */
-				pAddr = (pteVal & ~(pteSize - 1));
-				while (temp++ < numof4KPages) {
-					if (pfn_valid(__phys_to_pfn(pAddr))) {
-						pg = phys_to_page(pAddr);
-						if (page_count(pg) < 1) {
-							pr_info("DSPBRIDGE:"
-							    "UNMAP function: "
-							    "COUNT 0 FOR PA"
-							    " 0x%x, size = "
-							    "0x%x\n",
-							    pAddr, ulNumBytes);
-							bad_page_dump(pAddr,
-									pg);
-						}
-						SetPageDirty(pg);
-						page_cache_release(pg);
-					}
+
+			/* Collect Physical addresses from VA */
+			pAddr = (pteVal & ~(pteSize - 1));
+			if (pteSize == HW_PAGE_SIZE_64KB)
+				numof4KPages = 16;
+			else
+				numof4KPages = 1;
+			temp = 0;
+			while (temp++ < numof4KPages) {
+				if (!pfn_valid(__phys_to_pfn(pAddr))) {
 					pAddr += HW_PAGE_SIZE_4KB;
+					continue;
+				}
+				pg = phys_to_page(pAddr);
+				if (page_count(pg) < 1) {
+					pr_info("DSPBRIDGE: UNMAP function: "
+						"COUNT 0 FOR PA 0x%x, size = "
+						"0x%x\n", pAddr, ulNumBytes);
+					bad_page_dump(pAddr, pg);
 				}
-				if (HW_MMU_PteClear(L1BaseVa, vaCurr, pteSize)
-					       == RET_OK) {
+				SetPageDirty(pg);
+				page_cache_release(pg);
+				pAddr += HW_PAGE_SIZE_4KB;
+			}
+			if (HW_MMU_PteClear(pteAddrL2, vaCurr, pteSize)
+							 == RET_FAIL) {
+				status = DSP_EFAIL;
+				goto EXIT_LOOP;
+			}
+
+			status = DSP_SOK;
+			remBytesL2 -= pteSize;
+			vaCurr += pteSize;
+			pteAddrL2 += (pteSize >> 12) * sizeof(u32);
+		}
+		SYNC_EnterCS(pt->hCSObj);
+		if (remBytesL2 == 0) {
+			pt->pgInfo[L2PageNum].numEntries -= pteCount;
+			if (pt->pgInfo[L2PageNum].numEntries == 0) {
+				/*
+				 * Clear the L1 PTE pointing to the L2 PT
+				 */
+				if (HW_MMU_PteClear(L1BaseVa, vaCurrOrig,
+					    HW_MMU_COARSE_PAGE_SIZE) == RET_OK)
 					status = DSP_SOK;
-					remBytes -= pteSize;
-					vaCurr += pteSize;
-				} else {
+				else {
 					status = DSP_EFAIL;
+					SYNC_LeaveCS(pt->hCSObj);
 					goto EXIT_LOOP;
 				}
+			}
+			remBytes -= pteCount * PG_SIZE_4K;
+		} else
+			status = DSP_EFAIL;
+		DBG_Trace(DBG_LEVEL1, "WMD_BRD_MemUnMap L2PageNum %x, "
+			  "numEntries %x, pteCount %x, status: 0x%x\n",
+			  L2PageNum, pt->pgInfo[L2PageNum].numEntries,
+			  pteCount, status);
+		SYNC_LeaveCS(pt->hCSObj);
+		continue;
+skip_coarse_page:
+		/* vaCurr aligned to pteSize? */
+		/* pteSize = 1 MB or 16 MB */
+		if (pteSize == 0 || remBytes < pteSize ||
+						 vaCurr & (pteSize - 1)) {
+			status = DSP_EFAIL;
+			break;
+		}
+
+		if (pteSize == HW_PAGE_SIZE_1MB)
+			numof4KPages = 256;
+		else
+			numof4KPages = 4096;
+		temp = 0;
+		/* Collect Physical addresses from VA */
+		pAddr = (pteVal & ~(pteSize - 1));
+		while (temp++ < numof4KPages) {
+			if (pfn_valid(__phys_to_pfn(pAddr))) {
+				pg = phys_to_page(pAddr);
+				if (page_count(pg) < 1) {
+					pr_info("DSPBRIDGE: UNMAP function: "
+						"COUNT 0 FOR PA 0x%x, size = "
+						"0x%x\n", pAddr, ulNumBytes);
+					bad_page_dump(pAddr, pg);
+				}
+				SetPageDirty(pg);
+				page_cache_release(pg);
+			}
+			pAddr += HW_PAGE_SIZE_4KB;
+		}
+		if (HW_MMU_PteClear(L1BaseVa, vaCurr, pteSize) == RET_OK) {
+			status = DSP_SOK;
+			remBytes -= pteSize;
+			vaCurr += pteSize;
 		} else {
 			status = DSP_EFAIL;
+			goto EXIT_LOOP;
 		}
 	}
 	/*
Signature · 1 line
1.6.2.4
#2 lore raw

PATCH 3/3 DSPBRIDGE: NULL and safety checks

NULL and safety checks

---
 drivers/dsp/bridge/pmgr/dev.c      |   35 +++++--
 drivers/dsp/bridge/pmgr/msg.c      |    4 +-
 drivers/dsp/bridge/rmgr/node.c     |   33 +++++--
 drivers/dsp/bridge/rmgr/proc.c     |   10 ++-
 drivers/dsp/bridge/script.sh       |   10 ++
 drivers/dsp/bridge/services/list.c |   34 +++----
 drivers/dsp/bridge/services/mem.c  |    3 +-
 drivers/dsp/bridge/wmd/io_sm.c     |  188 ++++++++++++++++++++++++------------
 drivers/dsp/bridge/wmd/msg_sm.c    |   81 ++++++++++-----
 9 files changed, 268 insertions(+), 130 deletions(-)
 create mode 100644 drivers/dsp/bridge/script.sh
drivers/dsp/bridge/pmgr/dev.c +26 -9
index 5e4e30b..59eee7d 100644
@@ -496,11 +496,15 @@ DSP_STATUS DEV_DestroyDevice(struct DEV_OBJECT *hDevObject)
 	GT_1trace(debugMask, GT_ENTER, "Entered DEV_DestroyDevice, hDevObject: "
 		 "0x%x\n", hDevObject);
 	if (IsValidHandle(hDevObject)) {
-		if (pDevObject->hCodMgr)
+		if (pDevObject->hCodMgr) {
 			COD_Delete(pDevObject->hCodMgr);
+			pDevObject->hCodMgr = NULL;
+		}
 
-		if (pDevObject->hNodeMgr)
+		if (pDevObject->hNodeMgr) {
 			NODE_DeleteMgr(pDevObject->hNodeMgr);
+			pDevObject->hNodeMgr = NULL;
+		}
 
 		/* Free the io, channel, and message managers for this board: */
 		if (pDevObject->hIOMgr) {
@@ -511,28 +515,40 @@ DSP_STATUS DEV_DestroyDevice(struct DEV_OBJECT *hDevObject)
 			CHNL_Destroy(pDevObject->hChnlMgr);
 			pDevObject->hChnlMgr = NULL;
 		}
-		if (pDevObject->hMsgMgr)
+		if (pDevObject->hMsgMgr) {
 			MSG_Delete(pDevObject->hMsgMgr);
+			pDevObject->hMsgMgr = NULL;
+		}
 
 		if (pDevObject->hDehMgr) {
 			/* Uninitialize DEH module. */
 			(*pDevObject->intfFxns.pfnDehDestroy)
 			(pDevObject->hDehMgr);
+			pDevObject->hDehMgr = NULL;
 		}
-		if (pDevObject->hCmmMgr)
+		if (pDevObject->hCmmMgr) {
 			CMM_Destroy(pDevObject->hCmmMgr, true);
+			pDevObject->hCmmMgr = NULL;
+		}
 
-		if (pDevObject->hDmmMgr)
+		if (pDevObject->hDmmMgr) {
 			DMM_Destroy(pDevObject->hDmmMgr);
+			pDevObject->hDmmMgr = NULL;
+		}
 
 		/* Call the driver's WMD_DEV_Destroy() function: */
 		/* Require of DevDestroy */
-		DBC_Assert(pDevObject->hWmdContext != NULL);
-		status = (*pDevObject->intfFxns.pfnDevDestroy)
-			 (pDevObject->hWmdContext);
+		if (pDevObject->hWmdContext) {
+			status = (*pDevObject->intfFxns.pfnDevDestroy)
+				(pDevObject->hWmdContext);
+			pDevObject->hWmdContext = NULL;
+		} else
+			status = DSP_EFAIL;
 		if (DSP_SUCCEEDED(status)) {
-			if (pDevObject->procList)
+			if (pDevObject->procList) {
 				LST_Delete(pDevObject->procList);
+				pDevObject->procList = NULL;
+			}
 
 			/* Remove this DEV_Object from the global list: */
 			DRV_RemoveDevObject(pDevObject->hDrvObject, pDevObject);
@@ -540,6 +556,7 @@ DSP_STATUS DEV_DestroyDevice(struct DEV_OBJECT *hDevObject)
 			 * (pDevObject->hModule);*/
 			/* Free this dev object: */
 			MEM_FreeObject(pDevObject);
+			pDevObject = NULL;
 		}
 	} else {
 		GT_0trace(debugMask, GT_7CLASS, "DEV_Destroy: Invlaid handle");
drivers/dsp/bridge/pmgr/msg.c +3 -1
index be4acdb..d9e4fc6 100644
@@ -134,7 +134,9 @@ void MSG_Delete(struct MSG_MGR *hMsgMgr)
 	/* Let WMD message module destroy the MSG_MGR: */
 	(*pIntfFxns->pfnMsgDelete)(hMsgMgr);
 
-	DBC_Ensure(!MEM_IsValidHandle(pMsgMgr, MSGMGR_SIGNATURE));
+	if (MEM_IsValidHandle(pMsgMgr, MSGMGR_SIGNATURE))
+		GT_1trace(MSG_debugMask, GT_7CLASS, "MSG_Delete: Error hMsgMgr "
+					"Valid Handle: 0x%x\n", hMsgMgr);
 }
 
 /*
drivers/dsp/bridge/rmgr/node.c +24 -9
index 53a42bf..8ed9046 100644
@@ -1833,11 +1833,13 @@ DSP_STATUS NODE_DeleteMgr(struct NODE_MGR *hNodeMgr)
 	DSP_STATUS status = DSP_SOK;
 
 	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(hNodeMgr, NODEMGR_SIGNATURE));
 
 	GT_1trace(NODE_debugMask, GT_ENTER, "NODE_DeleteMgr: hNodeMgr: 0x%x\n",
 		 hNodeMgr);
-	DeleteNodeMgr(hNodeMgr);
+	if (MEM_IsValidHandle(hNodeMgr, NODEMGR_SIGNATURE))
+		DeleteNodeMgr(hNodeMgr);
+	else
+		status = DSP_EHANDLE;
 
 	return status;
 }
@@ -1855,7 +1857,6 @@ DSP_STATUS NODE_EnumNodes(struct NODE_MGR *hNodeMgr, IN DSP_HNODE *aNodeTab,
 	u32 i;
 	DSP_STATUS status = DSP_SOK;
 	DBC_Require(cRefs > 0);
-	DBC_Require(MEM_IsValidHandle(hNodeMgr, NODEMGR_SIGNATURE));
 	DBC_Require(aNodeTab != NULL || uNodeTabSize == 0);
 	DBC_Require(puNumNodes != NULL);
 	DBC_Require(puAllocated != NULL);
@@ -1863,6 +1864,10 @@ DSP_STATUS NODE_EnumNodes(struct NODE_MGR *hNodeMgr, IN DSP_HNODE *aNodeTab,
 		 "aNodeTab: %d\tuNodeTabSize: 0x%x\tpuNumNodes: 0x%x\t"
 		 "puAllocated\n", hNodeMgr, aNodeTab, uNodeTabSize, puNumNodes,
 		 puAllocated);
+	if (!MEM_IsValidHandle(hNodeMgr, NODEMGR_SIGNATURE)) {
+		status = DSP_EHANDLE;
+		goto func_end;
+	}
 	/* Enter critical section */
 	status = SYNC_EnterCS(hNodeMgr->hSync);
 	if (DSP_SUCCEEDED(status)) {
@@ -1887,6 +1892,7 @@ DSP_STATUS NODE_EnumNodes(struct NODE_MGR *hNodeMgr, IN DSP_HNODE *aNodeTab,
 	/* end of SYNC_EnterCS */
 	/* Exit critical section */
 	(void)SYNC_LeaveCS(hNodeMgr->hSync);
+func_end:
 	return status;
 }
 
@@ -2262,7 +2268,9 @@ bool NODE_Init(void)
  */
 void NODE_OnExit(struct NODE_OBJECT *hNode, s32 nStatus)
 {
-	DBC_Assert(MEM_IsValidHandle(hNode, NODE_SIGNATURE));
+	if (!MEM_IsValidHandle(hNode, NODE_SIGNATURE))
+		return;
+
 	/* Set node state to done */
 	NODE_SetState(hNode, NODE_DONE);
 	hNode->nExitStatus = nStatus;
@@ -2576,6 +2584,10 @@ DSP_STATUS NODE_Run(struct NODE_OBJECT *hNode)
 		goto func_end;
 
 	hNodeMgr = hNode->hNodeMgr;
+	if (!MEM_IsValidHandle(hNodeMgr, NODEMGR_SIGNATURE)) {
+		status = DSP_EHANDLE;
+		goto func_end;
+	}
 	pIntfFxns = hNodeMgr->pIntfFxns;
 	/* Enter critical section */
 	status = SYNC_EnterCS(hNodeMgr->hSync);
@@ -2825,10 +2837,11 @@ static void DeleteNode(struct NODE_OBJECT *hNode)
 			(struct PROC_OBJECT *)hNode->hProcessor;
 #endif
 	DSP_STATUS status;
-	DBC_Require(MEM_IsValidHandle(hNode, NODE_SIGNATURE));
+	if (!MEM_IsValidHandle(hNode, NODE_SIGNATURE))
+		goto func_end;
 	hNodeMgr = hNode->hNodeMgr;
-       if (!MEM_IsValidHandle(hNodeMgr, NODEMGR_SIGNATURE))
-               return;
+	if (!MEM_IsValidHandle(hNodeMgr, NODEMGR_SIGNATURE))
+		goto func_end;
 	hXlator = hNode->hXlator;
 	nodeType = NODE_GetType(hNode);
 	if (nodeType != NODE_DEVICE) {
@@ -2963,9 +2976,11 @@ static void DeleteNode(struct NODE_OBJECT *hNode)
 		hNodeMgr->nldrFxns.pfnFree(hNode->hNldrNode);
                hNode->hNldrNode = NULL;
        }
-
+	hNode->hNodeMgr = NULL;
 	MEM_FreeObject(hNode);
-       hNode = NULL;
+	hNode = NULL;
+func_end:
+	return;
 }
 
 /*
drivers/dsp/bridge/rmgr/proc.c +8 -2
index f6045bb..8cfbc46 100644
@@ -2032,15 +2032,21 @@ DSP_STATUS PROC_NotifyAllClients(DSP_HPROCESSOR hProc, u32 uEvents)
 	DSP_STATUS status = DSP_SOK;
 	struct PROC_OBJECT *pProcObject = (struct PROC_OBJECT *)hProc;
 
-	DBC_Require(MEM_IsValidHandle(pProcObject, PROC_SIGNATURE));
 	DBC_Require(IsValidProcEvent(uEvents));
 	DBC_Require(cRefs > 0);
 
+	if (!MEM_IsValidHandle(pProcObject, PROC_SIGNATURE)) {
+		status = DSP_EHANDLE;
+		GT_0trace(PROC_DebugMask, GT_7CLASS, "PROC_NotifyAllClients: "
+			 "InValid Processor Handle \n");
+		goto func_end;
+	}
+
 	DEV_NotifyClients(pProcObject->hDevObject, uEvents);
 
 	GT_0trace(PROC_DebugMask, GT_1CLASS,
 		 "PROC_NotifyAllClients :Signaled. \n");
-
+func_end:
 	return status;
 }
 
drivers/dsp/bridge/script.sh new file +10 -0
new file mode 100644
index 0000000..9ca4f87
@@ -0,0 +1,10 @@
+#!/bin/sh
+grep -rl "	" $1 |
+while read filename
+do
+(
+echo $filename
+sed "s/	/	/g;" $filename> $filename.xx
+mv $filename.xx $filename
+)
+done
drivers/dsp/bridge/services/list.c +14 -20
index 7fa3e76..7ac7772 100644
@@ -95,11 +95,10 @@ struct LST_LIST *LST_Create(void)
  */
 void LST_Delete(struct LST_LIST *pList)
 {
-	DBC_Require(pList != NULL);
-
 	GT_1trace(LST_debugMask, GT_ENTER, "LST_Delete: pList 0x%x\n", pList);
 
-	MEM_Free(pList);
+	if (pList != NULL)
+		MEM_Free(pList);
 }
 
 /*
@@ -122,11 +121,9 @@ struct LST_ELEM *LST_First(struct LST_LIST *pList)
 {
 	struct LST_ELEM *pElem = NULL;
 
-	DBC_Require(pList != NULL);
-
 	GT_1trace(LST_debugMask, GT_ENTER, "LST_First: pList 0x%x\n", pList);
 
-	if (!LST_IsEmpty(pList))
+	if (pList && !LST_IsEmpty(pList))
 		pElem = pList->head.next;
 
 	return pElem;
@@ -141,11 +138,9 @@ struct LST_ELEM *LST_GetHead(struct LST_LIST *pList)
 {
 	struct LST_ELEM *pElem;
 
-	DBC_Require(pList != NULL);
-
 	GT_1trace(LST_debugMask, GT_ENTER, "LST_GetHead: pList 0x%x\n", pList);
 
-	if (LST_IsEmpty(pList))
+	if (!pList || LST_IsEmpty(pList))
 		return NULL;
 
 	/* pElem is always valid because the list cannot be empty
@@ -197,14 +192,13 @@ void LST_InitElem(struct LST_ELEM *pElem)
 void LST_InsertBefore(struct LST_LIST *pList, struct LST_ELEM *pElem,
 		      struct LST_ELEM *pElemExisting)
 {
-	DBC_Require(pList != NULL);
-	DBC_Require(pElem != NULL);
-	DBC_Require(pElemExisting != NULL);
-
 	GT_3trace(LST_debugMask, GT_ENTER, "LST_InsertBefore: pList 0x%x, "
 		  "pElem 0x%x pElemExisting 0x%x\n", pList, pElem,
 		  pElemExisting);
 
+	if (!pList || !pElem || !pElemExisting)
+		return;
+
 	pElemExisting->prev->next = pElem;
 	pElem->prev = pElemExisting->prev;
 	pElem->next = pElemExisting;
@@ -221,8 +215,8 @@ struct LST_ELEM *LST_Next(struct LST_LIST *pList, struct LST_ELEM *pCurElem)
 {
 	struct LST_ELEM *pNextElem = NULL;
 
-	DBC_Require(pList != NULL);
-	DBC_Require(pCurElem != NULL);
+	if (!pList || !pCurElem)
+		return NULL;
 
 	GT_2trace(LST_debugMask, GT_ENTER,
 		  "LST_Next: pList 0x%x, pCurElem 0x%x\n",
@@ -243,13 +237,13 @@ struct LST_ELEM *LST_Next(struct LST_LIST *pList, struct LST_ELEM *pCurElem)
  */
 void LST_PutTail(struct LST_LIST *pList, struct LST_ELEM *pElem)
 {
-	DBC_Require(pList != NULL);
-	DBC_Require(pElem != NULL);
-
 	GT_2trace(LST_debugMask, GT_ENTER,
 		  "LST_PutTail: pList 0x%x, pElem 0x%x\n",
 		  pList, pElem);
 
+	if (!pList || !pElem)
+		return;
+
 	pElem->prev = pList->head.prev;
 	pElem->next = &pList->head;
 	pList->head.prev = pElem;
@@ -266,8 +260,8 @@ void LST_PutTail(struct LST_LIST *pList, struct LST_ELEM *pElem)
  */
 void LST_RemoveElem(struct LST_LIST *pList, struct LST_ELEM *pCurElem)
 {
-	DBC_Require(pList != NULL);
-	DBC_Require(pCurElem != NULL);
+	if (!pList || !pCurElem)
+		return;
 
 	GT_2trace(LST_debugMask, GT_ENTER,
 		  "LST_RemoveElem: pList 0x%x, pCurElem "
drivers/dsp/bridge/services/mem.c +2 -1
index 47ec09b..a3f86f7 100644
@@ -480,7 +480,8 @@ void MEM_Exit(void)
  */
 void MEM_FlushCache(void *pMemBuf, u32 cBytes, s32 FlushType)
 {
-	DBC_Require(cRefs > 0);
+	if (cRefs <= 0 || !pMemBuf)
+		return;
 
 	switch (FlushType) {
 	/* invalidate only */
drivers/dsp/bridge/wmd/io_sm.c +127 -61

441 lines not on this page · raw message

drivers/dsp/bridge/wmd/msg_sm.c +54 -27

169 lines not on this page · raw message

Signature · 1 line
1.6.2.4