aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/pvr/refcount.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/pvr/refcount.c')
-rw-r--r--drivers/gpu/pvr/refcount.c111
1 files changed, 99 insertions, 12 deletions
diff --git a/drivers/gpu/pvr/refcount.c b/drivers/gpu/pvr/refcount.c
index 8b00972..5bc9b4a 100644
--- a/drivers/gpu/pvr/refcount.c
+++ b/drivers/gpu/pvr/refcount.c
@@ -1,7 +1,27 @@
-/*************************************************************************/ /*!
-@Title Services reference count debugging
-@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
-@License Strictly Confidential.
+/**********************************************************************
+ *
+ * Copyright (C) Imagination Technologies Ltd. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful but, except
+ * as otherwise stated in writing, without any warranty; without even the
+ * implied warranty of merchantability or fitness for a particular purpose.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ *
+ * Contact Information:
+ * Imagination Technologies Ltd. <gpl-support@imgtec.com>
+ * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
+ *
*/ /**************************************************************************/
#if defined(PVRSRV_REFCOUNT_DEBUG)
@@ -26,10 +46,11 @@ static DEFINE_MUTEX(gsCCBLock);
#define PVRSRV_REFCOUNT_CCB_DEBUG_MEMINFO (1U << 1)
#define PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF (1U << 2)
#define PVRSRV_REFCOUNT_CCB_DEBUG_BM_BUF2 (1U << 3)
+#define PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC (1U << 4)
#if defined(__linux__)
-#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP (1U << 4)
-#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 (1U << 5)
+#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP (1U << 16)
+#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 (1U << 17)
#else
#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP 0
#define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 0
@@ -95,6 +116,8 @@ void PVRSRVKernelSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
{
+ IMG_UINT32 ui32RefValue = OSAtomicRead(psKernelSyncInfo->pvRefCount);
+
if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO))
goto skip;
@@ -111,8 +134,8 @@ void PVRSRVKernelSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
psKernelMemInfo,
NULL,
(psKernelMemInfo) ? psKernelMemInfo->sMemBlk.hOSMemHandle : NULL,
- psKernelSyncInfo->ui32RefCount,
- psKernelSyncInfo->ui32RefCount + 1,
+ ui32RefValue,
+ ui32RefValue + 1,
(psKernelMemInfo) ? psKernelMemInfo->uAllocSize : 0);
gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
@@ -120,7 +143,7 @@ void PVRSRVKernelSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
PVRSRV_UNLOCK_CCB();
skip:
- psKernelSyncInfo->ui32RefCount++;
+ PVRSRVAcquireSyncInfoKM(psKernelSyncInfo);
}
IMG_INTERNAL
@@ -128,6 +151,8 @@ void PVRSRVKernelSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
{
+ IMG_UINT32 ui32RefValue = OSAtomicRead(psKernelSyncInfo->pvRefCount);
+
if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO))
goto skip;
@@ -144,8 +169,8 @@ void PVRSRVKernelSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
psKernelMemInfo,
(psKernelMemInfo) ? psKernelMemInfo->sMemBlk.hOSMemHandle : NULL,
NULL,
- psKernelSyncInfo->ui32RefCount,
- psKernelSyncInfo->ui32RefCount - 1,
+ ui32RefValue,
+ ui32RefValue - 1,
(psKernelMemInfo) ? psKernelMemInfo->uAllocSize : 0);
gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
@@ -153,7 +178,7 @@ void PVRSRVKernelSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
PVRSRV_UNLOCK_CCB();
skip:
- psKernelSyncInfo->ui32RefCount--;
+ PVRSRVReleaseSyncInfoKM(psKernelSyncInfo);
}
IMG_INTERNAL
@@ -344,6 +369,68 @@ skip:
pBuf->ui32ExportCount--;
}
+IMG_INTERNAL
+void PVRSRVBMXProcIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index)
+{
+ if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC))
+ goto skip;
+
+ PVRSRV_LOCK_CCB();
+
+ gsRefCountCCB[giOffset].pszFile = pszFile;
+ gsRefCountCCB[giOffset].iLine = iLine;
+ gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
+ snprintf(gsRefCountCCB[giOffset].pcMesg,
+ PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
+ PVRSRV_REFCOUNT_CCB_FMT_STRING,
+ "BM_XPROC",
+ NULL,
+ NULL,
+ gXProcWorkaroundShareData[ui32Index].hOSMemHandle,
+ (IMG_VOID *) ui32Index,
+ gXProcWorkaroundShareData[ui32Index].ui32RefCount,
+ gXProcWorkaroundShareData[ui32Index].ui32RefCount + 1,
+ gXProcWorkaroundShareData[ui32Index].ui32Size);
+ gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
+ giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
+
+ PVRSRV_UNLOCK_CCB();
+
+skip:
+ gXProcWorkaroundShareData[ui32Index].ui32RefCount++;
+}
+
+IMG_INTERNAL
+void PVRSRVBMXProcDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index)
+{
+ if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_BM_XPROC))
+ goto skip;
+
+ PVRSRV_LOCK_CCB();
+
+ gsRefCountCCB[giOffset].pszFile = pszFile;
+ gsRefCountCCB[giOffset].iLine = iLine;
+ gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM();
+ snprintf(gsRefCountCCB[giOffset].pcMesg,
+ PVRSRV_REFCOUNT_CCB_MESG_MAX - 1,
+ PVRSRV_REFCOUNT_CCB_FMT_STRING,
+ "BM_XPROC",
+ NULL,
+ NULL,
+ gXProcWorkaroundShareData[ui32Index].hOSMemHandle,
+ (IMG_VOID *) ui32Index,
+ gXProcWorkaroundShareData[ui32Index].ui32RefCount,
+ gXProcWorkaroundShareData[ui32Index].ui32RefCount - 1,
+ gXProcWorkaroundShareData[ui32Index].ui32Size);
+ gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0;
+ giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX;
+
+ PVRSRV_UNLOCK_CCB();
+
+skip:
+ gXProcWorkaroundShareData[ui32Index].ui32RefCount--;
+}
+
#if defined(__linux__)
/* mmap refcounting is Linux specific */