diff options
Diffstat (limited to 'drivers/gpu/pvr/devicemem.c')
-rw-r--r-- | drivers/gpu/pvr/devicemem.c | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/drivers/gpu/pvr/devicemem.c b/drivers/gpu/pvr/devicemem.c index cd22faa..8874d61 100644 --- a/drivers/gpu/pvr/devicemem.c +++ b/drivers/gpu/pvr/devicemem.c @@ -516,7 +516,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, return PVRSRV_ERROR_OUT_OF_MEMORY; } - psKernelSyncInfo->ui32RefCount = 0; + eError = OSAtomicAlloc(&psKernelSyncInfo->pvRefCount); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVAllocSyncInfoKM: Failed to allocate atomic")); + OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_SYNC_INFO), psKernelSyncInfo, IMG_NULL); + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + pBMContext = (BM_CONTEXT*)hDevMemContext; @@ -541,6 +548,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, { PVR_DPF((PVR_DBG_ERROR,"PVRSRVAllocSyncInfoKM: Failed to alloc memory")); + OSAtomicFree(psKernelSyncInfo->pvRefCount); OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_SYNC_INFO), psKernelSyncInfo, IMG_NULL); return PVRSRV_ERROR_OUT_OF_MEMORY; @@ -558,6 +566,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, psSyncData->ui32ReadOps2Complete = 0; psSyncData->ui32LastOpDumpVal = 0; psSyncData->ui32LastReadOpDumpVal = 0; + psSyncData->ui64LastWrite = 0; #if defined(PDUMP) PDUMPCOMMENT("Allocating kernel sync object"); @@ -577,34 +586,34 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, psKernelSyncInfo->psSyncDataMemInfoKM->psKernelSyncInfo = IMG_NULL; + OSAtomicInc(psKernelSyncInfo->pvRefCount); + *ppsKernelSyncInfo = psKernelSyncInfo; return PVRSRV_OK; } - IMG_EXPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +IMG_VOID PVRSRVAcquireSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) { - PVRSRV_ERROR eError; + OSAtomicInc(psKernelSyncInfo->pvRefCount); +} - if (psKernelSyncInfo->ui32RefCount != 0) +IMG_EXPORT +IMG_VOID IMG_CALLCONV PVRSRVReleaseSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +{ + if (OSAtomicDecAndTest(psKernelSyncInfo->pvRefCount)) { - PVR_DPF((PVR_DBG_ERROR, "oops: sync info ref count not zero at destruction")); + FreeDeviceMem(psKernelSyncInfo->psSyncDataMemInfoKM); + + + psKernelSyncInfo->psSyncDataMemInfoKM = IMG_NULL; + psKernelSyncInfo->psSyncData = IMG_NULL; + OSAtomicFree(psKernelSyncInfo->pvRefCount); + (IMG_VOID)OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_SYNC_INFO), psKernelSyncInfo, IMG_NULL); - return PVRSRV_ERROR_OUT_OF_MEMORY; } - - eError = FreeDeviceMem(psKernelSyncInfo->psSyncDataMemInfoKM); - - - psKernelSyncInfo->psSyncDataMemInfoKM = IMG_NULL; - psKernelSyncInfo->psSyncData = IMG_NULL; - (IMG_VOID)OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_SYNC_INFO), psKernelSyncInfo, IMG_NULL); - - - return eError; } static IMG_VOID freeWrapped(PVRSRV_KERNEL_MEM_INFO *psMemInfo) @@ -661,7 +670,7 @@ PVRSRV_ERROR _PollUntilAtLeast(volatile IMG_UINT32* pui32WatchedValue, if(psSysData->psGlobalEventObject) { eError = OSEventObjectOpenKM(psSysData->psGlobalEventObject, &hOSEventKM); - if (eError |= PVRSRV_OK) + if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "_PollUntilAtLeast: OSEventObjectOpen failed")); @@ -791,15 +800,11 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, case PVRSRV_MEMTYPE_WRAPPED: freeWrapped(psMemInfo); case PVRSRV_MEMTYPE_DEVICE: + case PVRSRV_MEMTYPE_DEVICECLASS: if (psMemInfo->psKernelSyncInfo) { PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo); - if (psMemInfo->psKernelSyncInfo->ui32RefCount == 0) - { - eError = PVRSRVFreeSyncInfoKM(psMemInfo->psKernelSyncInfo); - } } - case PVRSRV_MEMTYPE_DEVICECLASS: break; default: PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: Unknown memType")); @@ -921,8 +926,6 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, { goto free_mainalloc; } - - PVRSRVKernelSyncInfoIncRef(psMemInfo->psKernelSyncInfo, psMemInfo); } @@ -957,6 +960,10 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, return (PVRSRV_OK); free_mainalloc: + if (psMemInfo->psKernelSyncInfo) + { + PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo); + } FreeDeviceMem(psMemInfo); return eError; @@ -1204,8 +1211,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, goto ErrorExitPhase4; } - PVRSRVKernelSyncInfoIncRef(psMemInfo->psKernelSyncInfo, psMemInfo); - PVRSRVKernelMemInfoIncRef(psMemInfo); @@ -1290,15 +1295,6 @@ static PVRSRV_ERROR UnmapDeviceMemoryCallBack(IMG_PVOID pvParam, if( psMapData->psMemInfo->psKernelSyncInfo ) { PVRSRVKernelSyncInfoDecRef(psMapData->psMemInfo->psKernelSyncInfo, psMapData->psMemInfo); - if (psMapData->psMemInfo->psKernelSyncInfo->ui32RefCount == 0) - { - eError = PVRSRVFreeSyncInfoKM(psMapData->psMemInfo->psKernelSyncInfo); - if(eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR,"UnmapDeviceMemoryCallBack: Failed to free sync info")); - return eError; - } - } } eError = FreeDeviceMem(psMapData->psMemInfo); @@ -1723,6 +1719,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * psMemInfo->uAllocSize = uByteSize; psMemInfo->psKernelSyncInfo = psDeviceClassBuffer->psKernelSyncInfo; + PVR_ASSERT(psMemInfo->psKernelSyncInfo != IMG_NULL); + if (psMemInfo->psKernelSyncInfo) + { + PVRSRVKernelSyncInfoIncRef(psMemInfo->psKernelSyncInfo, psMemInfo); + } + psMemInfo->pvSysBackupBuffer = IMG_NULL; @@ -1766,8 +1768,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * #if defined(SUPPORT_PDUMP_MULTI_PROCESS) - PDUMPCOMMENT("Dump display surface"); - PDUMPMEM(IMG_NULL, psMemInfo, ui32Offset, psMemInfo->uAllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); + if(psMemInfo->pvLinAddrKM) + { + + PDUMPCOMMENT("Dump display surface"); + PDUMPMEM(IMG_NULL, psMemInfo, ui32Offset, psMemInfo->uAllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); + } #endif return PVRSRV_OK; @@ -1775,6 +1781,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * ErrorExitPhase3: if(psMemInfo) { + if (psMemInfo->psKernelSyncInfo) + { + PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo); + } + FreeDeviceMem(psMemInfo); |