Skip to contentSkip to conversation

DSPBRIDGE: Reclaim all pending buffer on resource cleanup

PATCH Guzman Lugo, Fernando 2 participants 3 messages Feb 8, 2010 – Feb 16, 2010

lore
Share & tools
lore
#0 lore raw
Quoted 1 line

From 727c83cd8b7e4aca51b214412eaa1b95cde6e4ea Mon Sep 17 00:00:00 2001

From: Fernando Guzman Lugo <[email protected]>
Date: Tue, 2 Feb 2010 20:38:10 -0600
Subject: [PATCH] DSPBRIDGE: Reclaim all pending buffer on resource cleanup

Before in case of pending buffer while we try to close a stream, it was doing only one reclaim, in the case there were more pending buffer the second STRM_Close would also fail, now all the pending buffers are reclaim.

---
 drivers/dsp/bridge/rmgr/drv.c |   37 ++++++++++++++++---------------------
 1 files changed, 16 insertions(+), 21 deletions(-)
drivers/dsp/bridge/rmgr/drv.c +16 -21
index edd8e97..660f375 100644
@@ -458,40 +458,35 @@ static DSP_STATUS  DRV_ProcFreeSTRMRes(HANDLE hPCtxt)
 {
 	struct PROCESS_CONTEXT *pCtxt = (struct PROCESS_CONTEXT *)hPCtxt;
 	DSP_STATUS status = DSP_SOK;
-	DSP_STATUS status1 = DSP_SOK;
 	u8 **apBuffer = NULL;
-	struct STRM_RES_OBJECT *pSTRMList = NULL;
 	struct STRM_RES_OBJECT *pSTRMRes = NULL;
+	struct STRM_INFO strm_info;
+	struct DSP_STREAMINFO user;
 	u8 *pBufPtr;
 	u32 ulBytes;
 	u32 dwArg;
 	s32 ulBufSize;
 
-	pSTRMList = pCtxt->pSTRMList;
-	while (pSTRMList != NULL) {
-		pSTRMRes = pSTRMList;
-		pSTRMList = pSTRMList->next;
-		if (pSTRMRes->uNumBufs != 0) {
-			apBuffer = MEM_Alloc((pSTRMRes->uNumBufs *
-					    sizeof(u8 *)), MEM_NONPAGED);
+	pSTRMRes = pCtxt->pSTRMList;
+	while (pSTRMRes) {
+		if (pSTRMRes->uNumBufs) {
+			apBuffer = MEM_Alloc(pSTRMRes->uNumBufs *
+					    sizeof(u8 *), MEM_NONPAGED);
+			if (!apBuffer)
+				return DSP_EMEMORY;
 			status = STRM_FreeBuffer(pSTRMRes->hStream, apBuffer,
 						pSTRMRes->uNumBufs, pCtxt);
 			MEM_Free(apBuffer);
 		}
-		status = STRM_Close(pSTRMRes->hStream, pCtxt);
-		if (DSP_FAILED(status)) {
-			if (status == DSP_EPENDING) {
-				status = STRM_Reclaim(pSTRMRes->hStream,
-						     &pBufPtr, &ulBytes,
-						     (u32 *)&ulBufSize, &dwArg);
-				if (DSP_SUCCEEDED(status))
-					status = STRM_Close(pSTRMRes->hStream,
-							pCtxt);
+		strm_info.pUser = &user;
+		user.uNumberBufsInStream = 0;
+		STRM_GetInfo(pSTRMRes->hStream, &strm_info, sizeof(strm_info));
+		while (strm_info.pUser->uNumberBufsInStream--)
+			STRM_Reclaim(pSTRMRes->hStream, &pBufPtr, &ulBytes,
+					     (u32 *)&ulBufSize, &dwArg);
 
-			}
-		}
 	}
-	return status1;
+	return status;
 }
 
 /* Release all Stream resources and its context
Signature · 1 line
1.6.0.4
#1 lore raw

Hi,

Quoted 5 lines · Fernando

From 727c83cd8b7e4aca51b214412eaa1b95cde6e4ea Mon Sep 17 00:00:00 2001
From: Fernando Guzman Lugo<[email protected]>
Date: Tue, 2 Feb 2010 20:38:10 -0600
Subject: [PATCH] DSPBRIDGE: Reclaim all pending buffer on resource cleanup

Quoted 7 lines

Before in case of pending buffer while we try to close a stream, it was doing only one reclaim, in the case there were more pending buffer the second STRM_Close would also fail, now all the pending buffers are reclaim.

---

Shouldn't this be like?
Patch 1: Fix
Patch 2: code enhancement

that said, isn't this missing a STRM_Close? (look below)

Quoted 46 lines
  drivers/dsp/bridge/rmgr/drv.c |   37 ++++++++++++++++---------------------
  1 files changed, 16 insertions(+), 21 deletions(-)
drivers/dsp/bridge/rmgr/drv.c +9 -15
index edd8e97..660f375 100644
@@ -458,40 +458,35 @@ static DSP_STATUS  DRV_ProcFreeSTRMRes(HANDLE hPCtxt)
  {
  	struct PROCESS_CONTEXT *pCtxt = (struct PROCESS_CONTEXT *)hPCtxt;
  	DSP_STATUS status = DSP_SOK;
-	DSP_STATUS status1 = DSP_SOK;
  	u8 **apBuffer = NULL;
-	struct STRM_RES_OBJECT *pSTRMList = NULL;
  	struct STRM_RES_OBJECT *pSTRMRes = NULL;
+	struct STRM_INFO strm_info;
+	struct DSP_STREAMINFO user;
  	u8 *pBufPtr;
  	u32 ulBytes;
  	u32 dwArg;
  	s32 ulBufSize;
 
-	pSTRMList = pCtxt->pSTRMList;
-	while (pSTRMList != NULL) {
-		pSTRMRes = pSTRMList;
-		pSTRMList = pSTRMList->next;
-		if (pSTRMRes->uNumBufs != 0) {
-			apBuffer = MEM_Alloc((pSTRMRes->uNumBufs *
-					    sizeof(u8 *)), MEM_NONPAGED);
+	pSTRMRes = pCtxt->pSTRMList;
+	while (pSTRMRes) {
+		if (pSTRMRes->uNumBufs) {
+			apBuffer = MEM_Alloc(pSTRMRes->uNumBufs *
+					    sizeof(u8 *), MEM_NONPAGED);
+			if (!apBuffer)
+				return DSP_EMEMORY;
  			status = STRM_FreeBuffer(pSTRMRes->hStream, apBuffer,
  						pSTRMRes->uNumBufs, pCtxt);
  			MEM_Free(apBuffer);
  		}
-		status = STRM_Close(pSTRMRes->hStream, pCtxt);
-		if (DSP_FAILED(status)) {
-			if (status == DSP_EPENDING) {
-				status = STRM_Reclaim(pSTRMRes->hStream,
-						&pBufPtr,&ulBytes,
-						     (u32 *)&ulBufSize,&dwArg);

drivers/dsp/bridge/rmgr/drv.c static DSP_STATUS DRV_ProcFreeSTRMRes(HANDLE hPCtxt) · line 487

Quoted 10 lines
drivers/dsp/bridge/rmgr/drv.c +6 -3
-				if (DSP_SUCCEEDED(status))
-					status = STRM_Close(pSTRMRes->hStream,
-							pCtxt);
+		strm_info.pUser =&user;
+		user.uNumberBufsInStream = 0;
+		STRM_GetInfo(pSTRMRes->hStream,&strm_info, sizeof(strm_info));
+		while (strm_info.pUser->uNumberBufsInStream--)
+			STRM_Reclaim(pSTRMRes->hStream,&pBufPtr,&ulBytes,
+					     (u32 *)&ulBufSize,&dwArg);
 

Here.

drivers/dsp/bridge/rmgr/drv.c static DSP_STATUS DRV_ProcFreeSTRMRes(HANDLE hPCtxt) · line 492

Quoted 8 lines
drivers/dsp/bridge/rmgr/drv.c +1 -3
-			}
-		}
  	}
-	return status1;
+	return status;
  }
 
  /* Release all Stream resources and its context

- omar

#2 lore raw
Quoted 23 lines

-----Original Message-----
From: Ramirez Luna, Omar
Sent: Tuesday, February 16, 2010 12:13 PM
To: Guzman Lugo, Fernando
Cc: linux-omap; Hiroshi Doyu; Ameya Palande; Felipe Contreras
Subject: Re: DSPBRIDGE: Reclaim all pending buffer on resource cleanup

Hi,

Quoted 4 lines · Fernando

From 727c83cd8b7e4aca51b214412eaa1b95cde6e4ea Mon Sep 17 00:00:00 2001
From: Fernando Guzman Lugo<[email protected]>
Date: Tue, 2 Feb 2010 20:38:10 -0600
Subject: [PATCH] DSPBRIDGE: Reclaim all pending buffer on resource

cleanup

Quoted 6 lines

Before in case of pending buffer while we try to close a stream, it was doing only one reclaim, in the case there were more pending buffer the second STRM_Close would also fail, now all the pending buffers are reclaim.

Quoted 8 lines
Quoted 2 lines

---

Shouldn't this be like?
Patch 1: Fix
Patch 2: code enhancement

that said, isn't this missing a STRM_Close? (look below)

Yes, you re right, that is a mistake. I will send it again.

Regards,
Fernando.

Quoted 73 lines
Quoted 2 lines
  drivers/dsp/bridge/rmgr/drv.c |   37 ++++++++++++++++------------------

---

Review

Quoted 3 lines
  1 files changed, 16 insertions(+), 21 deletions(-)
(quoted diff) +0 -0

b/drivers/dsp/bridge/rmgr/drv.c

drivers/dsp/bridge/rmgr/drv.c static DSP_STATUS DRV_ProcFreeSTRMRes(HANDLE

Quoted 4 lines

index edd8e97..660f375 100644

drivers/dsp/bridge/rmgr/drv.c +0 -0
@@ -458,40 +458,35 @@ static DSP_STATUS  DRV_ProcFreeSTRMRes(HANDLE

hPCtxt)

Quoted 38 lines
drivers/dsp/bridge/rmgr/drv.c +9 -15
  {
  	struct PROCESS_CONTEXT *pCtxt = (struct PROCESS_CONTEXT *)hPCtxt;
  	DSP_STATUS status = DSP_SOK;
-	DSP_STATUS status1 = DSP_SOK;
  	u8 **apBuffer = NULL;
-	struct STRM_RES_OBJECT *pSTRMList = NULL;
  	struct STRM_RES_OBJECT *pSTRMRes = NULL;
+	struct STRM_INFO strm_info;
+	struct DSP_STREAMINFO user;
  	u8 *pBufPtr;
  	u32 ulBytes;
  	u32 dwArg;
  	s32 ulBufSize;
 
-	pSTRMList = pCtxt->pSTRMList;
-	while (pSTRMList != NULL) {
-		pSTRMRes = pSTRMList;
-		pSTRMList = pSTRMList->next;
-		if (pSTRMRes->uNumBufs != 0) {
-			apBuffer = MEM_Alloc((pSTRMRes->uNumBufs *
-					    sizeof(u8 *)), MEM_NONPAGED);
+	pSTRMRes = pCtxt->pSTRMList;
+	while (pSTRMRes) {
+		if (pSTRMRes->uNumBufs) {
+			apBuffer = MEM_Alloc(pSTRMRes->uNumBufs *
+					    sizeof(u8 *), MEM_NONPAGED);
+			if (!apBuffer)
+				return DSP_EMEMORY;
  			status = STRM_FreeBuffer(pSTRMRes->hStream, apBuffer,
  						pSTRMRes->uNumBufs, pCtxt);
  			MEM_Free(apBuffer);
  		}
-		status = STRM_Close(pSTRMRes->hStream, pCtxt);
-		if (DSP_FAILED(status)) {
-			if (status == DSP_EPENDING) {
-				status = STRM_Reclaim(pSTRMRes->hStream,
-						&pBufPtr,&ulBytes,
-						     (u32 *)&ulBufSize,&dwArg);

drivers/dsp/bridge/rmgr/drv.c static DSP_STATUS DRV_ProcFreeSTRMRes(HANDLE hPCtxt) · line 487

Quoted 10 lines
drivers/dsp/bridge/rmgr/drv.c +6 -3
-				if (DSP_SUCCEEDED(status))
-					status = STRM_Close(pSTRMRes->hStream,
-							pCtxt);
+		strm_info.pUser =&user;
+		user.uNumberBufsInStream = 0;
+		STRM_GetInfo(pSTRMRes->hStream,&strm_info, sizeof(strm_info));
+		while (strm_info.pUser->uNumberBufsInStream--)
+			STRM_Reclaim(pSTRMRes->hStream,&pBufPtr,&ulBytes,
+					     (u32 *)&ulBufSize,&dwArg);
 

Here.

drivers/dsp/bridge/rmgr/drv.c static DSP_STATUS DRV_ProcFreeSTRMRes(HANDLE hPCtxt) · line 492

Quoted 8 lines
drivers/dsp/bridge/rmgr/drv.c +1 -3
-			}
-		}
  	}
-	return status1;
+	return status;
  }
 
  /* Release all Stream resources and its context

- omar