diff options
Diffstat (limited to 'drivers')
140 files changed, 12095 insertions, 3240 deletions
diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index 76e553c..e24fd8b 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -23,26 +23,21 @@ ccflags-y += \ -DSUPPORT_SGX_HWPERF \ -DSYS_USING_INTERRUPTS \ -DPVR_SECURE_HANDLES \ - -DSERVICES4 \ - -DSUPPORT_SGX_EVENT_OBJECT \ -DTRANSFER_QUEUE \ -DSUPPORT_SGX \ - -DSUPPORT_SRVINIT \ -DSUPPORT_HW_RECOVERY \ - -DPVR_SECURE_FD_EXPORT \ - -DSUPPORT_SGX_EVENT_OBJECT \ -DLDM_PLATFORM \ - -DPVR2D_ALT_2DHW \ -DPVR_LINUX_USING_WORKQUEUES \ -DPVR_LINUX_MISR_USING_PRIVATE_WORKQUEUE \ -DPVR_LINUX_TIMERS_USING_WORKQUEUES \ -DSYS_CUSTOM_POWERLOCK_WRAP \ -DSUPPORT_MEMINFO_IDS \ -DSYS_SGX_ACTIVE_POWER_LATENCY_MS=100 \ - -DPVR_BUILD_DATE="" \ -DPVRSRV_MODNAME="\"pvrsrvkm\"" \ -Idrivers/gpu/pvr/sgx \ - -DPVRSRV_RESET_ON_HWTIMEOUT + -DPVRSRV_RESET_ON_HWTIMEOUT \ + -DSUPPORT_GET_DC_BUFFERS_SYS_PHYADDRS \ + -DPVR_LDM_DRIVER_REGISTRATION_NAME="\"pvrsrvkm\"" ccflags-$(CONFIG_PVR_BUILD_RELEASE) += \ -DPVR_BUILD_TYPE="\"release\"" -DRELEASE @@ -69,7 +64,7 @@ ccflags-$(CONFIG_PVR_USSE_EDM_STATUS_DEBUG) += -DPVRSRV_USSE_EDM_STATUS_DEBUG ccflags-$(CONFIG_PVR_DUMP_MK_TRACE) += -DPVRSRV_DUMP_MK_TRACE ccflags-$(CONFIG_PVR_PDUMP) += \ - -DPDUMP -DSUPPORT_DBGDRV_EVENT_OBJECTS -DSUPPORT_PDUMP_MULTI_PROCESS + -DPDUMP -DSUPPORT_PDUMP_MULTI_PROCESS pvrsrvkm-y := \ osfunc.o \ @@ -129,7 +124,7 @@ s3c_lcd-y := \ s3c_lcd/s3c_displayclass.o \ s3c_lcd/s3c_lcd.o -obj-$(CONFIG_PVR_PDUMP) += dbgdrv +obj-$(CONFIG_PVR_PDUMP) += dbgdrv/ obj-$(CONFIG_PVR_SGX) += pvrsrvkm.o diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 55e5647..44f8e05 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -76,7 +76,7 @@ PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY g_BridgeDispatchTable[BRIDGE_DISPATCH_TABLE_E PVRSRV_BRIDGE_GLOBAL_STATS g_BridgeGlobalStats; #endif -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) static IMG_BOOL abSharedDeviceMemHeap[PVRSRV_MAX_CLIENT_HEAPS]; static IMG_BOOL *pbSharedDeviceMemHeap = abSharedDeviceMemHeap; #else @@ -169,6 +169,9 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, IMG_HANDLE hDevMemContextInt; IMG_UINT32 i; IMG_BOOL bCreated; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM asHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_CREATE_DEVMEMCONTEXT); @@ -190,7 +193,11 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, psPerProc, &hDevMemContextInt, &psCreateDevMemContextOUT->ui32ClientHeapCount, +#if defined (SUPPORT_SID_INTERFACE) + &asHeapInfo[0], +#else &psCreateDevMemContextOUT->sHeapInfo[0], +#endif &bCreated, pbSharedDeviceMemHeap); @@ -223,35 +230,61 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, for(i = 0; i < psCreateDevMemContextOUT->ui32ClientHeapCount; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeapExt; +#else IMG_HANDLE hDevMemHeapExt; +#endif -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) if(abSharedDeviceMemHeap[i]) #endif { +#if defined (SUPPORT_SID_INTERFACE) + PVRSRVAllocHandleNR(psPerProc->psHandleBase, + &hDevMemHeapExt, + asHeapInfo[i].hDevMemHeap, + PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, + PVRSRV_HANDLE_ALLOC_FLAG_SHARED); +#else PVRSRVAllocHandleNR(psPerProc->psHandleBase, &hDevMemHeapExt, - psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap, - PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, - PVRSRV_HANDLE_ALLOC_FLAG_SHARED); + psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap, + PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, + PVRSRV_HANDLE_ALLOC_FLAG_SHARED); +#endif } -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) else { if(bCreated) { +#if defined (SUPPORT_SID_INTERFACE) + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &hDevMemHeapExt, + asHeapInfo[i].hDevMemHeap, + PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psCreateDevMemContextOUT->hDevMemContext); +#else PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &hDevMemHeapExt, psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap, PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, PVRSRV_HANDLE_ALLOC_FLAG_NONE, psCreateDevMemContextOUT->hDevMemContext); +#endif } else { psCreateDevMemContextOUT->eError = - PVRSRVFindHandle(psPerProc->psHandleBase, &hDevMemHeapExt, + PVRSRVFindHandle(psPerProc->psHandleBase, + &hDevMemHeapExt, +#if defined (SUPPORT_SID_INTERFACE) + asHeapInfo[i].hDevMemHeap, +#else psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap, +#endif PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP); if(psCreateDevMemContextOUT->eError != PVRSRV_OK) { @@ -261,6 +294,13 @@ PVRSRVCreateDeviceMemContextBW(IMG_UINT32 ui32BridgeID, } #endif psCreateDevMemContextOUT->sHeapInfo[i].hDevMemHeap = hDevMemHeapExt; +#if defined (SUPPORT_SID_INTERFACE) + psCreateDevMemContextOUT->sHeapInfo[i].ui32HeapID = asHeapInfo[i].ui32HeapID; + psCreateDevMemContextOUT->sHeapInfo[i].sDevVAddrBase = asHeapInfo[i].sDevVAddrBase; + psCreateDevMemContextOUT->sHeapInfo[i].ui32HeapByteSize = asHeapInfo[i].ui32HeapByteSize; + psCreateDevMemContextOUT->sHeapInfo[i].ui32Attribs = asHeapInfo[i].ui32Attribs; + psCreateDevMemContextOUT->sHeapInfo[i].ui32XTileStride = asHeapInfo[i].ui32XTileStride; +#endif } COMMIT_HANDLE_BATCH_OR_ERROR(psCreateDevMemContextOUT->eError, psPerProc) @@ -329,6 +369,9 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, IMG_HANDLE hDevCookieInt; IMG_HANDLE hDevMemContextInt; IMG_UINT32 i; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM asHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_GET_DEVMEM_HEAPINFO); @@ -358,7 +401,11 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, PVRSRVGetDeviceMemHeapInfoKM(hDevCookieInt, hDevMemContextInt, &psGetDevMemHeapInfoOUT->ui32ClientHeapCount, +#if defined (SUPPORT_SID_INTERFACE) + &asHeapInfo[0], +#else &psGetDevMemHeapInfoOUT->sHeapInfo[0], +#endif pbSharedDeviceMemHeap); if(psGetDevMemHeapInfoOUT->eError != PVRSRV_OK) @@ -368,25 +415,42 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, for(i = 0; i < psGetDevMemHeapInfoOUT->ui32ClientHeapCount; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeapExt; +#else IMG_HANDLE hDevMemHeapExt; +#endif -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) if(abSharedDeviceMemHeap[i]) #endif { +#if defined (SUPPORT_SID_INTERFACE) + PVRSRVAllocHandleNR(psPerProc->psHandleBase, + &hDevMemHeapExt, + asHeapInfo[i].hDevMemHeap, + PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, + PVRSRV_HANDLE_ALLOC_FLAG_SHARED); +#else PVRSRVAllocHandleNR(psPerProc->psHandleBase, &hDevMemHeapExt, psGetDevMemHeapInfoOUT->sHeapInfo[i].hDevMemHeap, PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); +#endif } -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) else { psGetDevMemHeapInfoOUT->eError = - PVRSRVFindHandle(psPerProc->psHandleBase, &hDevMemHeapExt, + PVRSRVFindHandle(psPerProc->psHandleBase, + &hDevMemHeapExt, +#if defined (SUPPORT_SID_INTERFACE) + asHeapInfo[i].hDevMemHeap, +#else psGetDevMemHeapInfoOUT->sHeapInfo[i].hDevMemHeap, +#endif PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP); if(psGetDevMemHeapInfoOUT->eError != PVRSRV_OK) { @@ -395,6 +459,13 @@ PVRSRVGetDeviceMemHeapInfoBW(IMG_UINT32 ui32BridgeID, } #endif psGetDevMemHeapInfoOUT->sHeapInfo[i].hDevMemHeap = hDevMemHeapExt; +#if defined (SUPPORT_SID_INTERFACE) + psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32HeapID = asHeapInfo[i].ui32HeapID; + psGetDevMemHeapInfoOUT->sHeapInfo[i].sDevVAddrBase = asHeapInfo[i].sDevVAddrBase; + psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32HeapByteSize = asHeapInfo[i].ui32HeapByteSize; + psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32Attribs = asHeapInfo[i].ui32Attribs; + psGetDevMemHeapInfoOUT->sHeapInfo[i].ui32XTileStride = asHeapInfo[i].ui32XTileStride; +#endif } COMMIT_HANDLE_BATCH_OR_ERROR(psGetDevMemHeapInfoOUT->eError, psPerProc) @@ -419,6 +490,8 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, PVRSRV_KERNEL_MEM_INFO *psMemInfo; IMG_HANDLE hDevCookieInt; IMG_HANDLE hDevMemHeapInt; + IMG_UINT32 ui32ShareIndex; + IMG_BOOL bUseShareMemWorkaround; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_ALLOC_DEVICEMEM); @@ -444,6 +517,36 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, return 0; } + + + bUseShareMemWorkaround = ((psAllocDeviceMemIN->ui32Attribs & PVRSRV_MEM_XPROC) != 0) ? IMG_TRUE : IMG_FALSE; + ui32ShareIndex = 7654321; + + if (bUseShareMemWorkaround) + { + + + + psAllocDeviceMemOUT->eError = + BM_XProcWorkaroundFindNewBufferAndSetShareIndex(&ui32ShareIndex); + if(psAllocDeviceMemOUT->eError != PVRSRV_OK) + { + return 0; + } + } + + + if(psAllocDeviceMemIN->pvPrivData) + { + if(!OSAccessOK(PVR_VERIFY_READ, + psAllocDeviceMemIN->pvPrivData, + psAllocDeviceMemIN->ui32PrivDataLength)) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVAllocDeviceMemBW: Access check failed for pvPrivData")); + return -EFAULT; + } + } + psAllocDeviceMemOUT->eError = PVRSRVAllocDeviceMemKM(hDevCookieInt, psPerProc, @@ -451,14 +554,33 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, psAllocDeviceMemIN->ui32Attribs, psAllocDeviceMemIN->ui32Size, psAllocDeviceMemIN->ui32Alignment, + psAllocDeviceMemIN->pvPrivData, + psAllocDeviceMemIN->ui32PrivDataLength, &psMemInfo, "" ); + if (bUseShareMemWorkaround) + { + PVR_ASSERT(ui32ShareIndex != 7654321); + BM_XProcWorkaroundUnsetShareIndex(ui32ShareIndex); + } + if(psAllocDeviceMemOUT->eError != PVRSRV_OK) { return 0; } + psMemInfo->sShareMemWorkaround.bInUse = bUseShareMemWorkaround; + if (bUseShareMemWorkaround) + { + PVR_ASSERT(ui32ShareIndex != 7654321); + psMemInfo->sShareMemWorkaround.ui32ShareIndex = ui32ShareIndex; + psMemInfo->sShareMemWorkaround.hDevCookieInt = hDevCookieInt; + psMemInfo->sShareMemWorkaround.ui32OrigReqAttribs = psAllocDeviceMemIN->ui32Attribs; + psMemInfo->sShareMemWorkaround.ui32OrigReqSize = (IMG_UINT32)psAllocDeviceMemIN->ui32Size; + psMemInfo->sShareMemWorkaround.ui32OrigReqAlignment = (IMG_UINT32)psAllocDeviceMemIN->ui32Alignment; + } + OSMemSet(&psAllocDeviceMemOUT->sClientMemInfo, 0, sizeof(psAllocDeviceMemOUT->sClientMemInfo)); @@ -473,8 +595,12 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, #endif psAllocDeviceMemOUT->sClientMemInfo.sDevVAddr = psMemInfo->sDevVAddr; psAllocDeviceMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags; - psAllocDeviceMemOUT->sClientMemInfo.ui32AllocSize = psMemInfo->ui32AllocSize; + psAllocDeviceMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize; +#if defined (SUPPORT_SID_INTERFACE) + +#else psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle; +#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo, @@ -482,6 +608,24 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, PVRSRV_HANDLE_TYPE_MEM_INFO, PVRSRV_HANDLE_ALLOC_FLAG_NONE); +#if defined (SUPPORT_SID_INTERFACE) + PVR_ASSERT(psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo != 0); + + if (psMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo, + psMemInfo->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_MEM_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo); + } + else + { + psAllocDeviceMemOUT->sClientMemInfo.hMappingInfo = 0; + } +#endif + if(psAllocDeviceMemIN->ui32Attribs & PVRSRV_MEM_NO_SYNCOBJ) { @@ -494,15 +638,35 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, { +#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) psAllocDeviceMemOUT->sClientSyncInfo.psSyncData = psMemInfo->psKernelSyncInfo->psSyncData; psAllocDeviceMemOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr = psMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr; psAllocDeviceMemOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr = psMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr; + psAllocDeviceMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = + psMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; +#if defined (SUPPORT_SID_INTERFACE) + if (psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psAllocDeviceMemOUT->sClientSyncInfo.hMappingInfo, + psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_SYNC_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psAllocDeviceMemOUT->sClientMemInfo.hKernelMemInfo); + } + else + { + psAllocDeviceMemOUT->sClientSyncInfo.hMappingInfo = 0; + } +#else psAllocDeviceMemOUT->sClientSyncInfo.hMappingInfo = psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; +#endif +#endif PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &psAllocDeviceMemOUT->sClientSyncInfo.hKernelSyncInfo, @@ -513,7 +677,6 @@ PVRSRVAllocDeviceMemBW(IMG_UINT32 ui32BridgeID, psAllocDeviceMemOUT->sClientMemInfo.psClientSyncInfo = &psAllocDeviceMemOUT->sClientSyncInfo; - } COMMIT_HANDLE_BATCH_OR_ERROR(psAllocDeviceMemOUT->eError, psPerProc) @@ -532,7 +695,6 @@ PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, IMG_HANDLE hDevCookieInt; IMG_VOID *pvKernelMemInfo; - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_FREE_DEVICEMEM); psRetOUT->eError = @@ -546,8 +708,13 @@ PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, } psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &pvKernelMemInfo, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &pvKernelMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psFreeDeviceMemIN->hKernelMemInfo, +#else psFreeDeviceMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -564,7 +731,11 @@ PVRSRVFreeDeviceMemBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + psFreeDeviceMemIN->hKernelMemInfo, +#else psFreeDeviceMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); return 0; @@ -578,13 +749,20 @@ PVRSRVExportDeviceMemBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hDevCookieInt; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo = IMG_NULL; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; +#endif - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_EXPORT_DEVICEMEM); + PVR_ASSERT(ui32BridgeID == PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_EXPORT_DEVICEMEM) || + ui32BridgeID == PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2)); + PVR_UNREFERENCED_PARAMETER(ui32BridgeID); psExportDeviceMemOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDevCookieInt, psExportDeviceMemIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); @@ -596,8 +774,13 @@ PVRSRVExportDeviceMemBW(IMG_UINT32 ui32BridgeID, psExportDeviceMemOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_PVOID *)&psKernelMemInfo, + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_PVOID *)&psKernelMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psExportDeviceMemIN->hKernelMemInfo, +#else psExportDeviceMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psExportDeviceMemOUT->eError != PVRSRV_OK) @@ -648,7 +831,9 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRV_KERNEL_MEM_INFO *psDstKernelMemInfo = IMG_NULL; IMG_HANDLE hDstDevMemHeap = IMG_NULL; - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_MAP_DEV_MEMORY); + PVR_ASSERT(ui32BridgeID == PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_MAP_DEV_MEMORY) || + ui32BridgeID == PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_MAP_DEV_MEMORY_2)); + PVR_UNREFERENCED_PARAMETER(ui32BridgeID); NEW_HANDLE_BATCH_OR_ERROR(psMapDevMemOUT->eError, psPerProc, 2) @@ -673,15 +858,68 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, } - psMapDevMemOUT->eError = PVRSRVMapDeviceMemoryKM(psPerProc, - psSrcKernelMemInfo, - hDstDevMemHeap, - &psDstKernelMemInfo); - if(psMapDevMemOUT->eError != PVRSRV_OK) + if (psSrcKernelMemInfo->sShareMemWorkaround.bInUse) { - return 0; + PVR_DPF((PVR_DBG_MESSAGE, "using the mem wrap workaround.")); + + + + + + + + + + psMapDevMemOUT->eError = BM_XProcWorkaroundSetShareIndex(psSrcKernelMemInfo->sShareMemWorkaround.ui32ShareIndex); + if(psMapDevMemOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVMapDeviceMemoryBW(): failed to recycle shared buffer")); + return 0; + } + + psMapDevMemOUT->eError = + PVRSRVAllocDeviceMemKM(psSrcKernelMemInfo->sShareMemWorkaround.hDevCookieInt, + psPerProc, + hDstDevMemHeap, + psSrcKernelMemInfo->sShareMemWorkaround.ui32OrigReqAttribs | PVRSRV_MEM_NO_SYNCOBJ, + psSrcKernelMemInfo->sShareMemWorkaround.ui32OrigReqSize, + psSrcKernelMemInfo->sShareMemWorkaround.ui32OrigReqAlignment, + IMG_NULL, + 0, + &psDstKernelMemInfo, + "" ); + + + BM_XProcWorkaroundUnsetShareIndex(psSrcKernelMemInfo->sShareMemWorkaround.ui32ShareIndex); + if(psMapDevMemOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVMapDeviceMemoryBW: Failed to create allocation for cross-process memory map")); + return 0; + } + + if(psSrcKernelMemInfo->psKernelSyncInfo) + { + psSrcKernelMemInfo->psKernelSyncInfo->ui32RefCount++; + } + + psDstKernelMemInfo->psKernelSyncInfo = psSrcKernelMemInfo->psKernelSyncInfo; + } + else + { + + psMapDevMemOUT->eError = PVRSRVMapDeviceMemoryKM(psPerProc, + psSrcKernelMemInfo, + hDstDevMemHeap, + &psDstKernelMemInfo); + if(psMapDevMemOUT->eError != PVRSRV_OK) + { + return 0; + } } + + psDstKernelMemInfo->sShareMemWorkaround = psSrcKernelMemInfo->sShareMemWorkaround; + OSMemSet(&psMapDevMemOUT->sDstClientMemInfo, 0, sizeof(psMapDevMemOUT->sDstClientMemInfo)); @@ -695,8 +933,12 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevMemOUT->sDstClientMemInfo.pvLinAddr = 0; psMapDevMemOUT->sDstClientMemInfo.sDevVAddr = psDstKernelMemInfo->sDevVAddr; psMapDevMemOUT->sDstClientMemInfo.ui32Flags = psDstKernelMemInfo->ui32Flags; - psMapDevMemOUT->sDstClientMemInfo.ui32AllocSize = psDstKernelMemInfo->ui32AllocSize; + psMapDevMemOUT->sDstClientMemInfo.uAllocSize = psDstKernelMemInfo->uAllocSize; +#if defined (SUPPORT_SID_INTERFACE) + +#else psMapDevMemOUT->sDstClientMemInfo.hMappingInfo = psDstKernelMemInfo->sMemBlk.hOSMemHandle; +#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, @@ -706,18 +948,56 @@ PVRSRVMapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRV_HANDLE_ALLOC_FLAG_NONE); psMapDevMemOUT->sDstClientSyncInfo.hKernelSyncInfo = IMG_NULL; +#if defined (SUPPORT_SID_INTERFACE) + + if (psDstKernelMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psMapDevMemOUT->sDstClientMemInfo.hMappingInfo, + psDstKernelMemInfo->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_MEM_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psMapDevMemOUT->sDstClientMemInfo.hKernelMemInfo); + } + else + { + psMapDevMemOUT->sDstClientMemInfo.hMappingInfo = 0; + } +#endif + if(psDstKernelMemInfo->psKernelSyncInfo) { +#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) psMapDevMemOUT->sDstClientSyncInfo.psSyncData = psDstKernelMemInfo->psKernelSyncInfo->psSyncData; psMapDevMemOUT->sDstClientSyncInfo.sWriteOpsCompleteDevVAddr = psDstKernelMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr; psMapDevMemOUT->sDstClientSyncInfo.sReadOpsCompleteDevVAddr = psDstKernelMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr; + psMapDevMemOUT->sDstClientSyncInfo.sReadOps2CompleteDevVAddr = + psDstKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; +#if defined (SUPPORT_SID_INTERFACE) + + if (psDstKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psMapDevMemOUT->sDstClientSyncInfo.hMappingInfo, + psDstKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_MEM_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psMapDevMemOUT->sDstClientMemInfo.hKernelMemInfo); + } + else + { + psMapDevMemOUT->sDstClientSyncInfo.hMappingInfo = 0; + } +#else psMapDevMemOUT->sDstClientSyncInfo.hMappingInfo = psDstKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; +#endif +#endif psMapDevMemOUT->sDstClientMemInfo.psClientSyncInfo = &psMapDevMemOUT->sDstClientSyncInfo; @@ -747,21 +1027,41 @@ PVRSRVUnmapDeviceMemoryBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID**)&psKernelMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psUnmapDevMemIN->hKernelMemInfo, +#else psUnmapDevMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { return 0; } - psRetOUT->eError = PVRSRVUnmapDeviceMemoryKM(psKernelMemInfo); - if(psRetOUT->eError != PVRSRV_OK) + if (psKernelMemInfo->sShareMemWorkaround.bInUse) { - return 0; + psRetOUT->eError = PVRSRVFreeDeviceMemKM(psKernelMemInfo->sShareMemWorkaround.hDevCookieInt, psKernelMemInfo); + if(psRetOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVUnmapDeviceMemoryBW: internal error, should expect FreeDeviceMem to fail")); + return 0; + } + } + else + { + psRetOUT->eError = PVRSRVUnmapDeviceMemoryKM(psKernelMemInfo); + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } } psRetOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + psUnmapDevMemIN->hKernelMemInfo, +#else psUnmapDevMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); return 0; @@ -787,7 +1087,8 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevClassMemOUT->eError = - PVRSRVLookupHandleAnyType(psPerProc->psHandleBase, &hDeviceClassBufferInt, + PVRSRVLookupHandleAnyType(psPerProc->psHandleBase, + &hDeviceClassBufferInt, &eHandleType, psMapDevClassMemIN->hDeviceClassBuffer); @@ -798,7 +1099,8 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevClassMemOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevMemContextInt, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDevMemContextInt, psMapDevClassMemIN->hDevMemContext, PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); @@ -810,7 +1112,7 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, switch(eHandleType) { -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) case PVRSRV_HANDLE_TYPE_DISP_BUFFER: case PVRSRV_HANDLE_TYPE_BUF_BUFFER: #else @@ -846,8 +1148,24 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psMapDevClassMemOUT->sClientMemInfo.pvLinAddr = 0; psMapDevClassMemOUT->sClientMemInfo.sDevVAddr = psMemInfo->sDevVAddr; psMapDevClassMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags; - psMapDevClassMemOUT->sClientMemInfo.ui32AllocSize = psMemInfo->ui32AllocSize; + psMapDevClassMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize; +#if defined (SUPPORT_SID_INTERFACE) + if (psMemInfo->sMemBlk.hOSMemHandle != 0) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psMapDevClassMemOUT->sClientMemInfo.hMappingInfo, + psMemInfo->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_MEM_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psMapDevClassMemIN->hDeviceClassBuffer); + } + else + { + psMapDevClassMemOUT->sClientMemInfo.hMappingInfo = 0; + } +#else psMapDevClassMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle; +#endif PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &psMapDevClassMemOUT->sClientMemInfo.hKernelMemInfo, @@ -861,15 +1179,35 @@ PVRSRVMapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, if(psMemInfo->psKernelSyncInfo) { +#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) psMapDevClassMemOUT->sClientSyncInfo.psSyncData = psMemInfo->psKernelSyncInfo->psSyncData; psMapDevClassMemOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr = psMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr; psMapDevClassMemOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr = psMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr; + psMapDevClassMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = + psMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; +#if defined (SUPPORT_SID_INTERFACE) + if (psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != 0) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psMapDevClassMemOUT->sClientSyncInfo.hMappingInfo, + psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_SYNC_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_MULTI, + psMapDevClassMemOUT->sClientMemInfo.hKernelMemInfo); + } + else + { + psMapDevClassMemOUT->sClientSyncInfo.hMappingInfo = 0; + } +#else psMapDevClassMemOUT->sClientSyncInfo.hMappingInfo = psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; +#endif +#endif psMapDevClassMemOUT->sClientMemInfo.psClientSyncInfo = &psMapDevClassMemOUT->sClientSyncInfo; @@ -898,7 +1236,11 @@ PVRSRVUnmapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvKernelMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psUnmapDevClassMemIN->hKernelMemInfo, +#else psUnmapDevClassMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -914,7 +1256,11 @@ PVRSRVUnmapDeviceClassMemoryBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + psUnmapDevClassMemIN->hKernelMemInfo, +#else psUnmapDevClassMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); return 0; @@ -939,7 +1285,7 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRV_KERNEL_MEM_INFO *psMemInfo; IMG_SYS_PHYADDR *psSysPAddr = IMG_NULL; IMG_UINT32 ui32PageTableSize = 0; - + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_WRAP_EXT_MEMORY); NEW_HANDLE_BATCH_OR_ERROR(psWrapExtMemOUT->eError, psPerProc, 2) @@ -987,7 +1333,7 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, return -EFAULT; } } - + psWrapExtMemOUT->eError = PVRSRVWrapExtMemoryKM(hDevCookieInt, psPerProc, @@ -1007,7 +1353,7 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, (IMG_VOID *)psSysPAddr, 0); } - + if(psWrapExtMemOUT->eError != PVRSRV_OK) { return 0; @@ -1020,8 +1366,11 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, psWrapExtMemOUT->sClientMemInfo.pvLinAddr = 0; psWrapExtMemOUT->sClientMemInfo.sDevVAddr = psMemInfo->sDevVAddr; psWrapExtMemOUT->sClientMemInfo.ui32Flags = psMemInfo->ui32Flags; - psWrapExtMemOUT->sClientMemInfo.ui32AllocSize = psMemInfo->ui32AllocSize; + psWrapExtMemOUT->sClientMemInfo.uAllocSize = psMemInfo->uAllocSize; +#if defined (SUPPORT_SID_INTERFACE) +#else psWrapExtMemOUT->sClientMemInfo.hMappingInfo = psMemInfo->sMemBlk.hOSMemHandle; +#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psWrapExtMemOUT->sClientMemInfo.hKernelMemInfo, @@ -1029,16 +1378,54 @@ PVRSRVWrapExtMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRV_HANDLE_TYPE_MEM_INFO, PVRSRV_HANDLE_ALLOC_FLAG_NONE); +#if defined (SUPPORT_SID_INTERFACE) + if (psMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psWrapExtMemOUT->sClientMemInfo.hMappingInfo, + psMemInfo->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_MEM_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psWrapExtMemOUT->sClientMemInfo.hKernelMemInfo); + } + else + { + psWrapExtMemOUT->sClientMemInfo.hMappingInfo = 0; + } +#endif + + +#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) psWrapExtMemOUT->sClientSyncInfo.psSyncData = psMemInfo->psKernelSyncInfo->psSyncData; psWrapExtMemOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr = psMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr; psWrapExtMemOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr = psMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr; + psWrapExtMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = + psMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; +#if defined (SUPPORT_SID_INTERFACE) + + if (psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psWrapExtMemOUT->sClientSyncInfo.hMappingInfo, + psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_MEM_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE, + psWrapExtMemOUT->sClientMemInfo.hKernelMemInfo); + } + else + { + psWrapExtMemOUT->sClientSyncInfo.hMappingInfo = 0; + } +#else psWrapExtMemOUT->sClientSyncInfo.hMappingInfo = psMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; +#endif +#endif psWrapExtMemOUT->sClientMemInfo.psClientSyncInfo = &psWrapExtMemOUT->sClientSyncInfo; @@ -1125,12 +1512,12 @@ PVRMMapOSMemHandleToMMapDataBW(IMG_UINT32 ui32BridgeID, &psMMapDataOUT->ui32ByteOffset, &psMMapDataOUT->ui32RealByteSize, &psMMapDataOUT->ui32UserVAddr); -#else +#else PVR_UNREFERENCED_PARAMETER(psPerProc); PVR_UNREFERENCED_PARAMETER(psMMapDataIN); psMMapDataOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED; -#endif +#endif return 0; } @@ -1151,16 +1538,59 @@ PVRMMapReleaseMMapDataBW(IMG_UINT32 ui32BridgeID, &psMMapDataOUT->ui32RealByteSize, &psMMapDataOUT->ui32UserVAddr); #else - + PVR_UNREFERENCED_PARAMETER(psPerProc); PVR_UNREFERENCED_PARAMETER(psMMapDataIN); psMMapDataOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED; -#endif +#endif return 0; } +#if defined (SUPPORT_SID_INTERFACE) +static IMG_INT +PVRSRVChangeDeviceMemoryAttributesBW(IMG_UINT32 ui32BridgeID, + PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS *psChgMemAttribIN, + PVRSRV_BRIDGE_RETURN *psRetOUT, + PVRSRV_PER_PROCESS_DATA *psPerProc) +{ + IMG_HANDLE hKernelMemInfo; + + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS); + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + &hKernelMemInfo, + psChgMemAttribIN->hKernelMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } + + psRetOUT->eError = + PVRSRVChangeDeviceMemoryAttributesKM(hKernelMemInfo, psChgMemAttribIN->ui32Attribs); + + return 0; +} +#else +static IMG_INT +PVRSRVChangeDeviceMemoryAttributesBW(IMG_UINT32 ui32BridgeID, + PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS *psChgMemAttribIN, + PVRSRV_BRIDGE_RETURN *psRetOUT, + PVRSRV_PER_PROCESS_DATA *psPerProc) +{ + PVR_UNREFERENCED_PARAMETER(ui32BridgeID); + PVR_UNREFERENCED_PARAMETER(psChgMemAttribIN); + PVR_UNREFERENCED_PARAMETER(psRetOUT); + PVR_UNREFERENCED_PARAMETER(psPerProc); + + return 0; +} +#endif + #ifdef PDUMP static IMG_INT PDumpIsCaptureFrameBW(IMG_UINT32 ui32BridgeID, @@ -1217,9 +1647,9 @@ PDumpRegWithFlagsBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_REG); psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, - (IMG_VOID **)&psDeviceNode, - psPDumpRegDumpIN->hDevCookie, + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID **)&psDeviceNode, + psPDumpRegDumpIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRetOUT->eError != PVRSRV_OK) { @@ -1245,9 +1675,9 @@ PDumpRegPolBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_REGPOL); psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, - (IMG_VOID **)&psDeviceNode, - psPDumpRegPolIN->hDevCookie, + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID **)&psDeviceNode, + psPDumpRegPolIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRetOUT->eError != PVRSRV_OK) { @@ -1255,12 +1685,13 @@ PDumpRegPolBW(IMG_UINT32 ui32BridgeID, } - psRetOUT->eError = + psRetOUT->eError = PDumpRegPolWithFlagsKM(psPDumpRegPolIN->szRegRegion, - psPDumpRegPolIN->sHWReg.ui32RegAddr, + psPDumpRegPolIN->sHWReg.ui32RegAddr, psPDumpRegPolIN->sHWReg.ui32RegVal, psPDumpRegPolIN->ui32Mask, - psPDumpRegPolIN->ui32Flags); + psPDumpRegPolIN->ui32Flags, + PDUMP_POLL_OPERATOR_EQUAL); return 0; } @@ -1278,7 +1709,11 @@ PDumpMemPolBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psPDumpMemPolIN->hKernelMemInfo, +#else psPDumpMemPolIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -1310,7 +1745,11 @@ PDumpMemBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psPDumpMemDumpIN->hKernelMemInfo, +#else psPDumpMemDumpIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -1338,7 +1777,7 @@ PDumpBitmapBW(IMG_UINT32 ui32BridgeID, { PVRSRV_DEVICE_NODE *psDeviceNode; IMG_HANDLE hDevMemContextInt; - + PVR_UNREFERENCED_PARAMETER(ui32BridgeID); psRetOUT->eError = @@ -1356,7 +1795,7 @@ PDumpBitmapBW(IMG_UINT32 ui32BridgeID, { return 0; } - + psRetOUT->eError = PDumpBitmapKM(psDeviceNode, &psPDumpBitmapIN->szFileName[0], @@ -1401,6 +1840,31 @@ PDumpReadRegBW(IMG_UINT32 ui32BridgeID, } static IMG_INT +PDumpMemPagesBW(IMG_UINT32 ui32BridgeID, + PVRSRV_BRIDGE_IN_PDUMP_MEMPAGES *psPDumpMemPagesIN, + PVRSRV_BRIDGE_RETURN *psRetOUT, + PVRSRV_PER_PROCESS_DATA *psPerProc) +{ + PVRSRV_DEVICE_NODE *psDeviceNode; + + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_MEMPAGES); + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID **)&psDeviceNode, + psPDumpMemPagesIN->hDevCookie, + PVRSRV_HANDLE_TYPE_DEV_NODE); + + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } + + + return 0; +} + +static IMG_INT PDumpDriverInfoBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_PDUMP_DRIVERINFO *psPDumpDriverInfoIN, PVRSRV_BRIDGE_RETURN *psRetOUT, @@ -1436,7 +1900,11 @@ PDumpSyncDumpBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvSyncInfo, +#if defined (SUPPORT_SID_INTERFACE) + psPDumpSyncDumpIN->hKernelSyncInfo, +#else psPDumpSyncDumpIN->psKernelSyncInfo, +#endif PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -1464,12 +1932,19 @@ PDumpSyncPolBW(IMG_UINT32 ui32BridgeID, { IMG_UINT32 ui32Offset; IMG_VOID *pvSyncInfo; + IMG_UINT32 ui32Value; + IMG_UINT32 ui32Mask; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_SYNCPOL); psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &pvSyncInfo, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &pvSyncInfo, +#if defined (SUPPORT_SID_INTERFACE) + psPDumpSyncPolIN->hKernelSyncInfo, +#else psPDumpSyncPolIN->psKernelSyncInfo, +#endif PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) { @@ -1485,11 +1960,30 @@ PDumpSyncPolBW(IMG_UINT32 ui32BridgeID, ui32Offset = offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete); } + + if (psPDumpSyncPolIN->bUseLastOpDumpVal) + { + if(psPDumpSyncPolIN->bIsRead) + { + ui32Value = ((PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)->psSyncData->ui32LastReadOpDumpVal; + } + else + { + ui32Value = ((PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)->psSyncData->ui32LastOpDumpVal; + } + ui32Mask = 0xffffffff; + } + else + { + ui32Value = psPDumpSyncPolIN->ui32Value; + ui32Mask = psPDumpSyncPolIN->ui32Mask; + } + psRetOUT->eError = PDumpMemPolKM(((PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)->psSyncDataMemInfoKM, ui32Offset, - psPDumpSyncPolIN->ui32Value, - psPDumpSyncPolIN->ui32Mask, + ui32Value, + ui32Mask, PDUMP_POLL_OPERATOR_EQUAL, 0, MAKEUNIQUETAG(((PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)->psSyncDataMemInfoKM)); @@ -1505,13 +1999,13 @@ PDumpCycleCountRegReadBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { PVRSRV_DEVICE_NODE *psDeviceNode; - + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ); psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, - (IMG_VOID **)&psDeviceNode, - psPDumpCycleCountRegReadIN->hDevCookie, + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID **)&psDeviceNode, + psPDumpCycleCountRegReadIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRetOUT->eError != PVRSRV_OK) { @@ -1594,13 +2088,30 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_OUT_GET_MISC_INFO *psGetMiscInfoOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_MISC_INFO_KM sMiscInfo = {0}; +#endif PVRSRV_ERROR eError; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_GET_MISC_INFO); +#if defined (SUPPORT_SID_INTERFACE) + sMiscInfo.ui32StateRequest = psGetMiscInfoIN->sMiscInfo.ui32StateRequest; + sMiscInfo.ui32StatePresent = psGetMiscInfoIN->sMiscInfo.ui32StatePresent; + sMiscInfo.ui32MemoryStrLen = psGetMiscInfoIN->sMiscInfo.ui32MemoryStrLen; + sMiscInfo.pszMemoryStr = psGetMiscInfoIN->sMiscInfo.pszMemoryStr; + + OSMemCopy(&sMiscInfo.sCacheOpCtl, + &psGetMiscInfoIN->sMiscInfo.sCacheOpCtl, + sizeof(sMiscInfo.sCacheOpCtl)); + OSMemCopy(&sMiscInfo.sGetRefCountCtl, + &psGetMiscInfoIN->sMiscInfo.sGetRefCountCtl, + sizeof(sMiscInfo.sGetRefCountCtl)); +#else OSMemCopy(&psGetMiscInfoOUT->sMiscInfo, - &psGetMiscInfoIN->sMiscInfo, - sizeof(PVRSRV_MISC_INFO)); + &psGetMiscInfoIN->sMiscInfo, + sizeof(PVRSRV_MISC_INFO)); +#endif if (((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_MEMSTATS_PRESENT) != 0) && ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_DDKVERSION_PRESENT) != 0) && @@ -1616,6 +2127,20 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, ((psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_FREEMEM_PRESENT) != 0)) { +#if defined (SUPPORT_SID_INTERFACE) + ASSIGN_AND_EXIT_ON_ERROR(psGetMiscInfoOUT->eError, + OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen, + (IMG_VOID **)&sMiscInfo.pszMemoryStr, 0, + "Output string buffer")); + psGetMiscInfoOUT->eError = PVRSRVGetMiscInfoKM(&sMiscInfo); + + + eError = CopyToUserWrapper(psPerProc, ui32BridgeID, + psGetMiscInfoIN->sMiscInfo.pszMemoryStr, + sMiscInfo.pszMemoryStr, + sMiscInfo.ui32MemoryStrLen); +#else ASSIGN_AND_EXIT_ON_ERROR(psGetMiscInfoOUT->eError, OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen, @@ -1629,12 +2154,18 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, psGetMiscInfoIN->sMiscInfo.pszMemoryStr, psGetMiscInfoOUT->sMiscInfo.pszMemoryStr, psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen); +#endif +#if defined (SUPPORT_SID_INTERFACE) + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sMiscInfo.ui32MemoryStrLen, + (IMG_VOID *)sMiscInfo.pszMemoryStr, 0); +#else OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psGetMiscInfoOUT->sMiscInfo.ui32MemoryStrLen, (IMG_VOID *)psGetMiscInfoOUT->sMiscInfo.pszMemoryStr, 0); - psGetMiscInfoOUT->sMiscInfo.pszMemoryStr = IMG_NULL; +#endif psGetMiscInfoOUT->sMiscInfo.pszMemoryStr = psGetMiscInfoIN->sMiscInfo.pszMemoryStr; @@ -1648,7 +2179,11 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, } else { +#if defined (SUPPORT_SID_INTERFACE) + psGetMiscInfoOUT->eError = PVRSRVGetMiscInfoKM(&sMiscInfo); +#else psGetMiscInfoOUT->eError = PVRSRVGetMiscInfoKM(&psGetMiscInfoOUT->sMiscInfo); +#endif } @@ -1658,26 +2193,48 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, } +#if defined (SUPPORT_SID_INTERFACE) + if (sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT) +#else if (psGetMiscInfoIN->sMiscInfo.ui32StateRequest & PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT) +#endif { psGetMiscInfoOUT->eError = PVRSRVAllocHandle(psPerProc->psHandleBase, &psGetMiscInfoOUT->sMiscInfo.sGlobalEventObject.hOSEventKM, +#if defined (SUPPORT_SID_INTERFACE) + sMiscInfo.sGlobalEventObject.hOSEventKM, +#else psGetMiscInfoOUT->sMiscInfo.sGlobalEventObject.hOSEventKM, +#endif PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); - if (psGetMiscInfoOUT->eError != PVRSRV_OK) - { - return 0; - } + if (psGetMiscInfoOUT->eError != PVRSRV_OK) + { + return 0; + } + +#if defined (SUPPORT_SID_INTERFACE) + OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.sGlobalEventObject.szName, + sMiscInfo.sGlobalEventObject.szName, + EVENTOBJNAME_MAXLENGTH); +#endif } +#if defined (SUPPORT_SID_INTERFACE) + if (sMiscInfo.hSOCTimerRegisterOSMemHandle) +#else if (psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle) +#endif { psGetMiscInfoOUT->eError = PVRSRVAllocHandle(psPerProc->psHandleBase, &psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle, +#if defined (SUPPORT_SID_INTERFACE) + sMiscInfo.hSOCTimerRegisterOSMemHandle, +#else psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle, +#endif PVRSRV_HANDLE_TYPE_SOC_TIMER, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); @@ -1686,6 +2243,32 @@ PVRSRVGetMiscInfoBW(IMG_UINT32 ui32BridgeID, return 0; } } +#if defined (SUPPORT_SID_INTERFACE) + else + { + psGetMiscInfoOUT->sMiscInfo.hSOCTimerRegisterOSMemHandle = 0; + } + + + psGetMiscInfoOUT->sMiscInfo.ui32StateRequest = sMiscInfo.ui32StateRequest; + psGetMiscInfoOUT->sMiscInfo.ui32StatePresent = sMiscInfo.ui32StatePresent; + + psGetMiscInfoOUT->sMiscInfo.pvSOCTimerRegisterKM = sMiscInfo.pvSOCTimerRegisterKM; + psGetMiscInfoOUT->sMiscInfo.pvSOCTimerRegisterUM = sMiscInfo.pvSOCTimerRegisterUM; + psGetMiscInfoOUT->sMiscInfo.pvSOCClockGateRegs = sMiscInfo.pvSOCClockGateRegs; + + psGetMiscInfoOUT->sMiscInfo.ui32SOCClockGateRegsSize = sMiscInfo.ui32SOCClockGateRegsSize; + + OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.aui32DDKVersion, + &sMiscInfo.aui32DDKVersion, + sizeof(psGetMiscInfoOUT->sMiscInfo.aui32DDKVersion)); + OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.sCacheOpCtl, + &sMiscInfo.sCacheOpCtl, + sizeof(psGetMiscInfoOUT->sMiscInfo.sCacheOpCtl)); + OSMemCopy(&psGetMiscInfoOUT->sMiscInfo.sGetRefCountCtl, + &sMiscInfo.sGetRefCountCtl, + sizeof(psGetMiscInfoOUT->sMiscInfo.sGetRefCountCtl)); +#endif return 0; } @@ -1700,11 +2283,17 @@ PVRSRVConnectBW(IMG_UINT32 ui32BridgeID, #if defined(PDUMP) - psPerProc->bPDumpPersistent |= ( (psConnectServicesIN->ui32Flags & SRV_FLAGS_PERSIST) != 0) ? IMG_TRUE : IMG_FALSE; + if ((psConnectServicesIN->ui32Flags & SRV_FLAGS_PERSIST) != 0) + { + psPerProc->bPDumpPersistent = IMG_TRUE; + } #if defined(SUPPORT_PDUMP_MULTI_PROCESS) - psPerProc->bPDumpActive |= ( (psConnectServicesIN->ui32Flags & SRV_FLAGS_PDUMP_ACTIVE) != 0) ? IMG_TRUE : IMG_FALSE; + if ((psConnectServicesIN->ui32Flags & SRV_FLAGS_PDUMP_ACTIVE) != 0) + { + psPerProc->bPDumpActive = IMG_TRUE; + } #endif #else PVR_UNREFERENCED_PARAMETER(psConnectServicesIN); @@ -1886,6 +2475,7 @@ PVRSRVEnumDCDimsBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined(SUPPORT_PVRSRV_GET_DC_SYSTEM_BUFFER) static IMG_INT PVRSRVGetDCSystemBufferBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_GET_DISPCLASS_SYSBUFFER *psGetDispClassSysBufferIN, @@ -1930,6 +2520,7 @@ PVRSRVGetDCSystemBufferBW(IMG_UINT32 ui32BridgeID, return 0; } +#endif static IMG_INT PVRSRVGetDCInfoBW(IMG_UINT32 ui32BridgeID, @@ -2217,6 +2808,9 @@ PVRSRVGetDCBuffersBW(IMG_UINT32 ui32BridgeID, IMG_VOID *pvDispClassInfo; IMG_VOID *pvSwapChain; IMG_UINT32 i; +#if defined (SUPPORT_SID_INTERFACE) + IMG_HANDLE *pahBuffer; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_GET_DISPCLASS_BUFFERS); @@ -2242,11 +2836,28 @@ PVRSRVGetDCBuffersBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + psGetDispClassBuffersOUT->eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_HANDLE) * PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS, + (IMG_PVOID *)&pahBuffer, 0, + "Temp Swapchain Buffers"); + + if (psGetDispClassBuffersOUT->eError != PVRSRV_OK) + { + return 0; + } +#endif + psGetDispClassBuffersOUT->eError = PVRSRVGetDCBuffersKM(pvDispClassInfo, pvSwapChain, &psGetDispClassBuffersOUT->ui32BufferCount, - psGetDispClassBuffersOUT->ahBuffer); +#if defined (SUPPORT_SID_INTERFACE) + pahBuffer, +#else + psGetDispClassBuffersOUT->ahBuffer, +#endif + psGetDispClassBuffersOUT->asPhyAddr); if (psGetDispClassBuffersOUT->eError != PVRSRV_OK) { return 0; @@ -2256,19 +2867,38 @@ PVRSRVGetDCBuffersBW(IMG_UINT32 ui32BridgeID, for(i = 0; i < psGetDispClassBuffersOUT->ui32BufferCount; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hBufferExt; +#else IMG_HANDLE hBufferExt; +#endif - + +#if defined (SUPPORT_SID_INTERFACE) + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &hBufferExt, + pahBuffer[i], + PVRSRV_HANDLE_TYPE_DISP_BUFFER, + (PVRSRV_HANDLE_ALLOC_FLAG)(PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE | PVRSRV_HANDLE_ALLOC_FLAG_SHARED), + psGetDispClassBuffersIN->hSwapChain); +#else PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &hBufferExt, psGetDispClassBuffersOUT->ahBuffer[i], PVRSRV_HANDLE_TYPE_DISP_BUFFER, (PVRSRV_HANDLE_ALLOC_FLAG)(PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE | PVRSRV_HANDLE_ALLOC_FLAG_SHARED), psGetDispClassBuffersIN->hSwapChain); +#endif psGetDispClassBuffersOUT->ahBuffer[i] = hBufferExt; } +#if defined (SUPPORT_SID_INTERFACE) + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_HANDLE) * PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS, + (IMG_PVOID)pahBuffer, 0); +#endif + COMMIT_HANDLE_BATCH_OR_ERROR(psGetDispClassBuffersOUT->eError, psPerProc) return 0; @@ -2282,6 +2912,9 @@ PVRSRVSwapToDCBufferBW(IMG_UINT32 ui32BridgeID, { IMG_VOID *pvDispClassInfo; IMG_VOID *pvSwapChainBuf; +#if defined (SUPPORT_SID_INTERFACE) + IMG_HANDLE hPrivateTag; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER); @@ -2306,11 +2939,35 @@ PVRSRVSwapToDCBufferBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + if (psSwapDispClassBufferIN->hPrivateTag != 0) + { + psRetOUT->eError = + PVRSRVLookupSubHandle(psPerProc->psHandleBase, + &hPrivateTag, + psSwapDispClassBufferIN->hPrivateTag, + PVRSRV_HANDLE_TYPE_DISP_BUFFER, + psSwapDispClassBufferIN->hDeviceKM); + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } + } + else + { + hPrivateTag = IMG_NULL; + } +#endif + psRetOUT->eError = PVRSRVSwapToDCBufferKM(pvDispClassInfo, pvSwapChainBuf, psSwapDispClassBufferIN->ui32SwapInterval, +#if defined (SUPPORT_SID_INTERFACE) + hPrivateTag, +#else psSwapDispClassBufferIN->hPrivateTag, +#endif psSwapDispClassBufferIN->ui32ClipRectCount, psSwapDispClassBufferIN->sClipRect); @@ -2318,6 +2975,136 @@ PVRSRVSwapToDCBufferBW(IMG_UINT32 ui32BridgeID, } static IMG_INT +PVRSRVSwapToDCBuffer2BW(IMG_UINT32 ui32BridgeID, + PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER2 *psSwapDispClassBufferIN, + PVRSRV_BRIDGE_RETURN *psRetOUT, + PVRSRV_PER_PROCESS_DATA *psPerProc) +{ + IMG_VOID *pvPrivData = IMG_NULL; + IMG_VOID *pvDispClassInfo; + IMG_VOID *pvSwapChain; + IMG_UINT32 i; + + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER2); + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + &pvDispClassInfo, + psSwapDispClassBufferIN->hDeviceKM, + PVRSRV_HANDLE_TYPE_DISP_INFO); + if(psRetOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up DISP_INFO handle")); + return 0; + } + + psRetOUT->eError = + PVRSRVLookupSubHandle(psPerProc->psHandleBase, + &pvSwapChain, + psSwapDispClassBufferIN->hSwapChain, + PVRSRV_HANDLE_TYPE_DISP_SWAP_CHAIN, + psSwapDispClassBufferIN->hDeviceKM); + if(psRetOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up DISP_BUFFER handle")); + return 0; + } + + if(!OSAccessOK(PVR_VERIFY_WRITE, + psSwapDispClassBufferIN->ppsKernelMemInfos, + sizeof(IMG_HANDLE) * psSwapDispClassBufferIN->ui32NumMemInfos)) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Access check failed for ppsKernelMemInfos")); + return -EFAULT; + } + + if(!OSAccessOK(PVR_VERIFY_WRITE, + psSwapDispClassBufferIN->ppsKernelSyncInfos, + sizeof(IMG_HANDLE) * psSwapDispClassBufferIN->ui32NumMemInfos)) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Access check failed for ppsKernelSyncInfos")); + return -EFAULT; + } + + for (i = 0; i < psSwapDispClassBufferIN->ui32NumMemInfos; i++) + { + PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_PVOID *)&psKernelMemInfo, + psSwapDispClassBufferIN->ppsKernelMemInfos[i], + PVRSRV_HANDLE_TYPE_MEM_INFO); + if(psRetOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up MEM_INFO handle")); + return 0; + } + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_PVOID *)&psKernelSyncInfo, + psSwapDispClassBufferIN->ppsKernelSyncInfos[i], + PVRSRV_HANDLE_TYPE_SYNC_INFO); + if(psRetOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to look up SYNC_INFO handle")); + return 0; + } + + psSwapDispClassBufferIN->ppsKernelMemInfos[i] = psKernelMemInfo; + psSwapDispClassBufferIN->ppsKernelSyncInfos[i] = psKernelSyncInfo; + } + + if(psSwapDispClassBufferIN->ui32PrivDataLength > 0) + { + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + psSwapDispClassBufferIN->ui32PrivDataLength, + (IMG_VOID **)&pvPrivData, IMG_NULL, + "Swap Command Private Data") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2BW: Failed to allocate private data space")); + return -ENOMEM; + } + + if(CopyFromUserWrapper(psPerProc, + ui32BridgeID, + pvPrivData, + psSwapDispClassBufferIN->pvPrivData, + psSwapDispClassBufferIN->ui32PrivDataLength) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSwapToDCBuffer2BW: Failed to copy private data")); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + psSwapDispClassBufferIN->ui32PrivDataLength, + pvPrivData, IMG_NULL); + return -EFAULT; + } + } + + psRetOUT->eError = + PVRSRVSwapToDCBuffer2KM(pvDispClassInfo, + pvSwapChain, + psSwapDispClassBufferIN->ui32SwapInterval, + psSwapDispClassBufferIN->ppsKernelMemInfos, + psSwapDispClassBufferIN->ppsKernelSyncInfos, + psSwapDispClassBufferIN->ui32NumMemInfos, + pvPrivData, + psSwapDispClassBufferIN->ui32PrivDataLength); + + if(psRetOUT->eError != PVRSRV_OK) + { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + psSwapDispClassBufferIN->ui32PrivDataLength, + pvPrivData, IMG_NULL); + } + + return 0; +} + + + +static IMG_INT PVRSRVSwapToDCSystemBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_SYSTEM *psSwapDispClassSystemIN, PVRSRV_BRIDGE_RETURN *psRetOUT, @@ -2539,9 +3326,24 @@ PVRSRVAllocSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, psAllocSharedSysMemOUT->sClientMemInfo.pvLinAddr = 0; psAllocSharedSysMemOUT->sClientMemInfo.ui32Flags = psKernelMemInfo->ui32Flags; - psAllocSharedSysMemOUT->sClientMemInfo.ui32AllocSize = - psKernelMemInfo->ui32AllocSize; + psAllocSharedSysMemOUT->sClientMemInfo.uAllocSize = + psKernelMemInfo->uAllocSize; +#if defined (SUPPORT_SID_INTERFACE) + if (psKernelMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocHandleNR(psPerProc->psHandleBase, + &psAllocSharedSysMemOUT->sClientMemInfo.hMappingInfo, + psKernelMemInfo->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_NONE); + } + else + { + psAllocSharedSysMemOUT->sClientMemInfo.hMappingInfo = 0; + } +#else psAllocSharedSysMemOUT->sClientMemInfo.hMappingInfo = psKernelMemInfo->sMemBlk.hOSMemHandle; +#endif PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psAllocSharedSysMemOUT->sClientMemInfo.hKernelMemInfo, @@ -2567,8 +3369,12 @@ PVRSRVFreeSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, psFreeSharedSysMemOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID **)&psKernelMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psFreeSharedSysMemIN->hKernelMemInfo, +#else psFreeSharedSysMemIN->psKernelMemInfo, - PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); +#endif + PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); if(psFreeSharedSysMemOUT->eError != PVRSRV_OK) return 0; @@ -2577,10 +3383,27 @@ PVRSRVFreeSharedSysMemoryBW(IMG_UINT32 ui32BridgeID, PVRSRVFreeSharedSysMemoryKM(psKernelMemInfo); if(psFreeSharedSysMemOUT->eError != PVRSRV_OK) return 0; +#if defined (SUPPORT_SID_INTERFACE) + if (psFreeSharedSysMemIN->hMappingInfo != 0) + { + psFreeSharedSysMemOUT->eError = + PVRSRVReleaseHandle(psPerProc->psHandleBase, + psFreeSharedSysMemIN->hMappingInfo, + PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); + if(psFreeSharedSysMemOUT->eError != PVRSRV_OK) + { + return 0; + } + } +#endif psFreeSharedSysMemOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + psFreeSharedSysMemIN->hKernelMemInfo, +#else psFreeSharedSysMemIN->psKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO); return 0; } @@ -2593,7 +3416,11 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, { PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; PVRSRV_HANDLE_TYPE eHandleType; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hParent; +#else IMG_HANDLE hParent; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_MAP_MEMINFO_MEM); NEW_HANDLE_BATCH_OR_ERROR(psMapMemInfoMemOUT->eError, psPerProc, 2) @@ -2610,7 +3437,7 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, switch (eHandleType) { -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) case PVRSRV_HANDLE_TYPE_MEM_INFO: case PVRSRV_HANDLE_TYPE_MEM_INFO_REF: case PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO: @@ -2633,7 +3460,11 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, { return 0; } +#if defined (SUPPORT_SID_INTERFACE) + if (hParent == 0) +#else if (hParent == IMG_NULL) +#endif { hParent = psMapMemInfoMemIN->hKernelMemInfo; } @@ -2650,9 +3481,25 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, psKernelMemInfo->sDevVAddr; psMapMemInfoMemOUT->sClientMemInfo.ui32Flags = psKernelMemInfo->ui32Flags; - psMapMemInfoMemOUT->sClientMemInfo.ui32AllocSize = - psKernelMemInfo->ui32AllocSize; + psMapMemInfoMemOUT->sClientMemInfo.uAllocSize = + psKernelMemInfo->uAllocSize; +#if defined (SUPPORT_SID_INTERFACE) + if (psKernelMemInfo->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psMapMemInfoMemOUT->sClientMemInfo.hMappingInfo, + psKernelMemInfo->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_MEM_INFO_REF, + PVRSRV_HANDLE_ALLOC_FLAG_MULTI, + hParent); + } + else + { + psMapMemInfoMemOUT->sClientMemInfo.hMappingInfo = 0; + } +#else psMapMemInfoMemOUT->sClientMemInfo.hMappingInfo = psKernelMemInfo->sMemBlk.hOSMemHandle; +#endif PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, &psMapMemInfoMemOUT->sClientMemInfo.hKernelMemInfo, @@ -2671,15 +3518,37 @@ PVRSRVMapMemInfoMemBW(IMG_UINT32 ui32BridgeID, else { +#if !defined(PVRSRV_DISABLE_UM_SYNCOBJ_MAPPINGS) psMapMemInfoMemOUT->sClientSyncInfo.psSyncData = psKernelMemInfo->psKernelSyncInfo->psSyncData; psMapMemInfoMemOUT->sClientSyncInfo.sWriteOpsCompleteDevVAddr = psKernelMemInfo->psKernelSyncInfo->sWriteOpsCompleteDevVAddr; psMapMemInfoMemOUT->sClientSyncInfo.sReadOpsCompleteDevVAddr = psKernelMemInfo->psKernelSyncInfo->sReadOpsCompleteDevVAddr; + psMapMemInfoMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = + psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; + psMapMemInfoMemOUT->sClientSyncInfo.sReadOps2CompleteDevVAddr = + psKernelMemInfo->psKernelSyncInfo->sReadOps2CompleteDevVAddr; +#if defined (SUPPORT_SID_INTERFACE) + if (psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle != IMG_NULL) + { + PVRSRVAllocSubHandleNR(psPerProc->psHandleBase, + &psMapMemInfoMemOUT->sClientSyncInfo.hMappingInfo, + psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle, + PVRSRV_HANDLE_TYPE_SYNC_INFO, + PVRSRV_HANDLE_ALLOC_FLAG_MULTI, + psMapMemInfoMemOUT->sClientMemInfo.hKernelMemInfo); + } + else + { + psMapMemInfoMemOUT->sClientSyncInfo.hMappingInfo = 0; + } +#else psMapMemInfoMemOUT->sClientSyncInfo.hMappingInfo = psKernelMemInfo->psKernelSyncInfo->psSyncDataMemInfoKM->sMemBlk.hOSMemHandle; +#endif +#endif psMapMemInfoMemOUT->sClientMemInfo.psClientSyncInfo = &psMapMemInfoMemOUT->sClientSyncInfo; @@ -2899,7 +3768,7 @@ PVRSRVEventObjectWaitBW(IMG_UINT32 ui32BridgeID, return 0; } - psRetOUT->eError = OSEventObjectWait(hOSEventKM); + psRetOUT->eError = OSEventObjectWaitKM(hOSEventKM); return 0; } @@ -2911,6 +3780,10 @@ PVRSRVEventObjectOpenBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_OUT_EVENT_OBJECT_OPEN *psEventObjectOpenOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_EVENTOBJECT_KM sEventObject; + IMG_HANDLE hOSEvent; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_EVENT_OBJECT_OPEN); @@ -2918,7 +3791,11 @@ PVRSRVEventObjectOpenBW(IMG_UINT32 ui32BridgeID, psEventObjectOpenOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sEventObject.hOSEventKM, +#else &psEventObjectOpenIN->sEventObject.hOSEventKM, +#endif psEventObjectOpenIN->sEventObject.hOSEventKM, PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT); @@ -2927,18 +3804,36 @@ PVRSRVEventObjectOpenBW(IMG_UINT32 ui32BridgeID, return 0; } - psEventObjectOpenOUT->eError = OSEventObjectOpen(&psEventObjectOpenIN->sEventObject, &psEventObjectOpenOUT->hOSEvent); +#if defined (SUPPORT_SID_INTERFACE) + OSMemCopy(&sEventObject.szName, + &psEventObjectOpenIN->sEventObject.szName, + EVENTOBJNAME_MAXLENGTH); + + psEventObjectOpenOUT->eError = OSEventObjectOpenKM(&sEventObject, &hOSEvent); +#else + psEventObjectOpenOUT->eError = OSEventObjectOpenKM(&psEventObjectOpenIN->sEventObject, &psEventObjectOpenOUT->hOSEvent); +#endif if(psEventObjectOpenOUT->eError != PVRSRV_OK) { return 0; } +#if defined (SUPPORT_SID_INTERFACE) +#if !defined (WINXP) && !defined(SUPPORT_VISTA) + PVRSRVAllocHandleNR(psPerProc->psHandleBase, + &psEventObjectOpenOUT->hOSEvent, + hOSEvent, + PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT, + PVRSRV_HANDLE_ALLOC_FLAG_MULTI); +#endif +#else PVRSRVAllocHandleNR(psPerProc->psHandleBase, &psEventObjectOpenOUT->hOSEvent, psEventObjectOpenOUT->hOSEvent, PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT, PVRSRV_HANDLE_ALLOC_FLAG_MULTI); +#endif COMMIT_HANDLE_BATCH_OR_ERROR(psEventObjectOpenOUT->eError, psPerProc) @@ -2953,12 +3848,19 @@ PVRSRVEventObjectCloseBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hOSEventKM; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_EVENTOBJECT_KM sEventObject; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_EVENT_OBJECT_CLOSE); psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sEventObject.hOSEventKM, +#else &psEventObjectCloseIN->sEventObject.hOSEventKM, +#endif psEventObjectCloseIN->sEventObject.hOSEventKM, PVRSRV_HANDLE_TYPE_SHARED_EVENT_OBJECT); if(psRetOUT->eError != PVRSRV_OK) @@ -2976,7 +3878,20 @@ PVRSRVEventObjectCloseBW(IMG_UINT32 ui32BridgeID, return 0; } - psRetOUT->eError = OSEventObjectClose(&psEventObjectCloseIN->sEventObject, hOSEventKM); +#if defined (SUPPORT_SID_INTERFACE) + if(CopyFromUserWrapper(psPerProc, ui32BridgeID, + &sEventObject.szName, + &psEventObjectCloseIN->sEventObject.szName, + EVENTOBJNAME_MAXLENGTH) != PVRSRV_OK) + { + + return -EFAULT; + } + + psRetOUT->eError = OSEventObjectCloseKM(&sEventObject, hOSEventKM); +#else + psRetOUT->eError = OSEventObjectCloseKM(&psEventObjectCloseIN->sEventObject, hOSEventKM); +#endif return 0; } @@ -2989,45 +3904,72 @@ typedef struct _MODIFY_SYNC_OP_INFO IMG_UINT32 ui32ModifyFlags; IMG_UINT32 ui32ReadOpsPendingSnapShot; IMG_UINT32 ui32WriteOpsPendingSnapShot; + IMG_UINT32 ui32ReadOps2PendingSnapShot; } MODIFY_SYNC_OP_INFO; -static PVRSRV_ERROR DoQuerySyncOpsSatisfied(MODIFY_SYNC_OP_INFO *psModSyncOpInfo) +static PVRSRV_ERROR DoQuerySyncOpsSatisfied(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo, + IMG_UINT32 ui32ReadOpsPendingSnapShot, + IMG_UINT32 ui32WriteOpsPendingSnapShot, + IMG_UINT32 ui32ReadOps2PendingSnapShot) { - PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; - - psKernelSyncInfo = psModSyncOpInfo->psKernelSyncInfo; + IMG_UINT32 ui32WriteOpsPending; + IMG_UINT32 ui32ReadOpsPending; + IMG_UINT32 ui32ReadOps2Pending; + if (!psKernelSyncInfo) { return PVRSRV_ERROR_INVALID_PARAMS; } - if((psModSyncOpInfo->ui32WriteOpsPendingSnapShot == psKernelSyncInfo->psSyncData->ui32WriteOpsComplete) - && (psModSyncOpInfo->ui32ReadOpsPendingSnapShot == psKernelSyncInfo->psSyncData->ui32ReadOpsComplete)) + + + + + + + + + + + ui32WriteOpsPending = psKernelSyncInfo->psSyncData->ui32WriteOpsPending; + ui32ReadOpsPending = psKernelSyncInfo->psSyncData->ui32ReadOpsPending; + ui32ReadOps2Pending = psKernelSyncInfo->psSyncData->ui32ReadOps2Pending; + + if((ui32WriteOpsPending - ui32WriteOpsPendingSnapShot >= + ui32WriteOpsPending - psKernelSyncInfo->psSyncData->ui32WriteOpsComplete) && + (ui32ReadOpsPending - ui32ReadOpsPendingSnapShot >= + ui32ReadOpsPending - psKernelSyncInfo->psSyncData->ui32ReadOpsComplete) && + (ui32ReadOps2Pending - ui32ReadOps2PendingSnapShot >= + ui32ReadOps2Pending - psKernelSyncInfo->psSyncData->ui32ReadOps2Complete)) { -#if defined(PDUMP) +#if defined(PDUMP) && !defined(SUPPORT_VGX) - - - PDumpComment("Poll for read ops complete to reach value (%u)", psModSyncOpInfo->ui32ReadOpsPendingSnapShot); + PDumpComment("Poll for read ops complete to reach value (pdump: %u, actual snapshot: %u)", + psKernelSyncInfo->psSyncData->ui32LastReadOpDumpVal, + ui32ReadOpsPendingSnapShot); PDumpMemPolKM(psKernelSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), - psModSyncOpInfo->ui32ReadOpsPendingSnapShot, - 0xFFFFFFFF, - PDUMP_POLL_OPERATOR_EQUAL, - 0, - MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); - + offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), + psKernelSyncInfo->psSyncData->ui32LastReadOpDumpVal, + 0xFFFFFFFF, + PDUMP_POLL_OPERATOR_EQUAL, + 0, + MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); + - PDumpComment("Poll for write ops complete to reach value (%u)", psModSyncOpInfo->ui32WriteOpsPendingSnapShot); + PDumpComment("Poll for write ops complete to reach value (pdump: %u, actual snapshot: %u)", + psKernelSyncInfo->psSyncData->ui32LastOpDumpVal, + ui32WriteOpsPendingSnapShot); PDumpMemPolKM(psKernelSyncInfo->psSyncDataMemInfoKM, - offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), - psModSyncOpInfo->ui32WriteOpsPendingSnapShot, - 0xFFFFFFFF, - PDUMP_POLL_OPERATOR_EQUAL, - 0, - MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); + offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), + psKernelSyncInfo->psSyncData->ui32LastOpDumpVal, + 0xFFFFFFFF, + PDUMP_POLL_OPERATOR_EQUAL, + 0, + MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); + + #endif return PVRSRV_OK; } @@ -3037,6 +3979,7 @@ static PVRSRV_ERROR DoQuerySyncOpsSatisfied(MODIFY_SYNC_OP_INFO *psModSyncOpInfo } } + static PVRSRV_ERROR DoModifyCompleteSyncOps(MODIFY_SYNC_OP_INFO *psModSyncOpInfo) { PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; @@ -3054,13 +3997,13 @@ static PVRSRV_ERROR DoModifyCompleteSyncOps(MODIFY_SYNC_OP_INFO *psModSyncOpInfo { return PVRSRV_ERROR_BAD_SYNC_STATE; } - + if(psModSyncOpInfo->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_WO_INC) { psKernelSyncInfo->psSyncData->ui32WriteOpsComplete++; } - + if(psModSyncOpInfo->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_RO_INC) { @@ -3072,11 +4015,13 @@ static PVRSRV_ERROR DoModifyCompleteSyncOps(MODIFY_SYNC_OP_INFO *psModSyncOpInfo static PVRSRV_ERROR ModifyCompleteSyncOpsCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { MODIFY_SYNC_OP_INFO *psModSyncOpInfo; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); if (!pvParam) { @@ -3091,26 +4036,30 @@ static PVRSRV_ERROR ModifyCompleteSyncOpsCallBack(IMG_PVOID pvParam, LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) { - if (DoQuerySyncOpsSatisfied(psModSyncOpInfo) == PVRSRV_OK) + if (DoQuerySyncOpsSatisfied(psModSyncOpInfo->psKernelSyncInfo, + psModSyncOpInfo->ui32ReadOpsPendingSnapShot, + psModSyncOpInfo->ui32WriteOpsPendingSnapShot, + psModSyncOpInfo->ui32ReadOps2PendingSnapShot) == PVRSRV_OK) { goto OpFlushedComplete; } PVR_DPF((PVR_DBG_WARNING, "ModifyCompleteSyncOpsCallBack: waiting for current Ops to flush")); - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); + OSSleepms(1); } END_LOOP_UNTIL_TIMEOUT(); - + PVR_DPF((PVR_DBG_ERROR, "ModifyCompleteSyncOpsCallBack: timeout whilst waiting for current Ops to flush.")); PVR_DPF((PVR_DBG_ERROR, " Write ops pending snapshot = %d, write ops complete = %d", psModSyncOpInfo->ui32WriteOpsPendingSnapShot, psModSyncOpInfo->psKernelSyncInfo->psSyncData->ui32WriteOpsComplete)); - PVR_DPF((PVR_DBG_ERROR, " Read ops pending snapshot = %d, write ops complete = %d", + PVR_DPF((PVR_DBG_ERROR, " Read ops pending snapshot = %d, read ops complete = %d", psModSyncOpInfo->ui32ReadOpsPendingSnapShot, psModSyncOpInfo->psKernelSyncInfo->psSyncData->ui32ReadOpsComplete)); - + PVR_DPF((PVR_DBG_ERROR, " Read ops pending snapshot = %d, read ops2 complete = %d", + psModSyncOpInfo->ui32ReadOps2PendingSnapShot, + psModSyncOpInfo->psKernelSyncInfo->psSyncData->ui32ReadOps2Complete)); return PVRSRV_ERROR_TIMEOUT; - - OpFlushedComplete: - + +OpFlushedComplete: DoModifyCompleteSyncOps(psModSyncOpInfo); } @@ -3206,7 +4155,7 @@ PVRSRVDestroySyncInfoModObjBW(IMG_UINT32 return 0; } - psDestroySyncInfoModObjOUT->eError = ResManFreeResByPtr(psModSyncOpInfo->hResItem); + psDestroySyncInfoModObjOUT->eError = ResManFreeResByPtr(psModSyncOpInfo->hResItem, CLEANUP_WITH_POLL); if (psDestroySyncInfoModObjOUT->eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVDestroySyncInfoModObjBW: ResManFreeResByPtr failed")); @@ -3215,7 +4164,7 @@ PVRSRVDestroySyncInfoModObjBW(IMG_UINT32 return 0; } - + static IMG_INT PVRSRVModifyPendingSyncOpsBW(IMG_UINT32 ui32BridgeID, @@ -3261,11 +4210,13 @@ PVRSRVModifyPendingSyncOpsBW(IMG_UINT32 ui32BridgeID, psModSyncOpInfo->ui32ModifyFlags = psModifySyncOpsIN->ui32ModifyFlags; psModSyncOpInfo->ui32ReadOpsPendingSnapShot = psKernelSyncInfo->psSyncData->ui32ReadOpsPending; psModSyncOpInfo->ui32WriteOpsPendingSnapShot = psKernelSyncInfo->psSyncData->ui32WriteOpsPending; + psModSyncOpInfo->ui32ReadOps2PendingSnapShot = psKernelSyncInfo->psSyncData->ui32ReadOps2Pending; psModifySyncOpsOUT->ui32ReadOpsPending = psKernelSyncInfo->psSyncData->ui32ReadOpsPending; psModifySyncOpsOUT->ui32WriteOpsPending = psKernelSyncInfo->psSyncData->ui32WriteOpsPending; + psModifySyncOpsOUT->ui32ReadOps2Pending = psKernelSyncInfo->psSyncData->ui32ReadOps2Pending; if(psModifySyncOpsIN->ui32ModifyFlags & PVRSRV_MODIFYSYNCOPS_FLAGS_WO_INC) { @@ -3336,6 +4287,78 @@ PVRSRVModifyCompleteSyncOpsBW(IMG_UINT32 ui32BridgeID, static IMG_INT +PVRSRVSyncOpsTakeTokenBW(IMG_UINT32 ui32BridgeID, + PVRSRV_BRIDGE_IN_SYNC_OPS_TAKE_TOKEN *psSyncOpsTakeTokenIN, + PVRSRV_BRIDGE_OUT_SYNC_OPS_TAKE_TOKEN *psSyncOpsTakeTokenOUT, + PVRSRV_PER_PROCESS_DATA *psPerProc) +{ + PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; + + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_OPS_TAKE_TOKEN); + + psSyncOpsTakeTokenOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID**)&psKernelSyncInfo, + psSyncOpsTakeTokenIN->hKernelSyncInfo, + PVRSRV_HANDLE_TYPE_SYNC_INFO); + if (psSyncOpsTakeTokenOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSyncOpsTakeTokenBW: PVRSRVLookupHandle failed")); + return 0; + } + + + + psSyncOpsTakeTokenOUT->ui32ReadOpsPending = psKernelSyncInfo->psSyncData->ui32ReadOpsPending; + psSyncOpsTakeTokenOUT->ui32WriteOpsPending = psKernelSyncInfo->psSyncData->ui32WriteOpsPending; + psSyncOpsTakeTokenOUT->ui32ReadOps2Pending = psKernelSyncInfo->psSyncData->ui32ReadOps2Pending; + + return 0; +} + + +static IMG_INT +PVRSRVSyncOpsFlushToTokenBW(IMG_UINT32 ui32BridgeID, + PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_TOKEN *psSyncOpsFlushToTokenIN, + PVRSRV_BRIDGE_RETURN *psSyncOpsFlushToTokenOUT, + PVRSRV_PER_PROCESS_DATA *psPerProc) +{ + PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; + IMG_UINT32 ui32ReadOpsPendingSnapshot; + IMG_UINT32 ui32WriteOpsPendingSnapshot; + IMG_UINT32 ui32ReadOps2PendingSnapshot; + + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_TOKEN); + + psSyncOpsFlushToTokenOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID**)&psKernelSyncInfo, + psSyncOpsFlushToTokenIN->hKernelSyncInfo, + PVRSRV_HANDLE_TYPE_SYNC_INFO); + if (psSyncOpsFlushToTokenOUT->eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSyncOpsFlushToTokenBW: PVRSRVLookupHandle failed")); + return 0; + } + + ui32ReadOpsPendingSnapshot = psSyncOpsFlushToTokenIN->ui32ReadOpsPendingSnapshot; + ui32WriteOpsPendingSnapshot = psSyncOpsFlushToTokenIN->ui32WriteOpsPendingSnapshot; + ui32ReadOps2PendingSnapshot = psSyncOpsFlushToTokenIN->ui32ReadOps2PendingSnapshot; + + psSyncOpsFlushToTokenOUT->eError = DoQuerySyncOpsSatisfied(psKernelSyncInfo, + ui32ReadOpsPendingSnapshot, + ui32WriteOpsPendingSnapshot, + ui32ReadOps2PendingSnapshot); + + if (psSyncOpsFlushToTokenOUT->eError != PVRSRV_OK && psSyncOpsFlushToTokenOUT->eError != PVRSRV_ERROR_RETRY) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVSyncOpsFlushToTokenBW: DoQuerySyncOpsSatisfied failed")); + return 0; + } + + return 0; +} + + +static IMG_INT PVRSRVSyncOpsFlushToModObjBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_MOD_OBJ *psSyncOpsFlushToModObjIN, PVRSRV_BRIDGE_RETURN *psSyncOpsFlushToModObjOUT, @@ -3362,7 +4385,10 @@ PVRSRVSyncOpsFlushToModObjBW(IMG_UINT32 return 0; } - psSyncOpsFlushToModObjOUT->eError = DoQuerySyncOpsSatisfied(psModSyncOpInfo); + psSyncOpsFlushToModObjOUT->eError = DoQuerySyncOpsSatisfied(psModSyncOpInfo->psKernelSyncInfo, + psModSyncOpInfo->ui32ReadOpsPendingSnapShot, + psModSyncOpInfo->ui32WriteOpsPendingSnapShot, + psModSyncOpInfo->ui32ReadOps2PendingSnapShot); if (psSyncOpsFlushToModObjOUT->eError != PVRSRV_OK && psSyncOpsFlushToModObjOUT->eError != PVRSRV_ERROR_RETRY) { @@ -3396,24 +4422,13 @@ PVRSRVSyncOpsFlushToDeltaBW(IMG_UINT32 u return 0; } + ui32DeltaRead = psSyncInfo->psSyncData->ui32ReadOpsPending - psSyncInfo->psSyncData->ui32ReadOpsComplete; ui32DeltaWrite = psSyncInfo->psSyncData->ui32WriteOpsPending - psSyncInfo->psSyncData->ui32WriteOpsComplete; if (ui32DeltaRead <= psSyncOpsFlushToDeltaIN->ui32Delta && ui32DeltaWrite <= psSyncOpsFlushToDeltaIN->ui32Delta) { -#if defined(PDUMP) - IMG_UINT32 ui32MinimumReadOpsComplete; - - ui32MinimumReadOpsComplete = psSyncInfo->psSyncData->ui32ReadOpsPending; - if (ui32MinimumReadOpsComplete < psSyncOpsFlushToDeltaIN->ui32Delta) - { - ui32MinimumReadOpsComplete = 0; - } - else - { - ui32MinimumReadOpsComplete = ui32MinimumReadOpsComplete - psSyncOpsFlushToDeltaIN->ui32Delta; - } - +#if defined(PDUMP) && !defined(SUPPORT_VGX) PDumpComment("Poll for read ops complete to delta (%u)", psSyncOpsFlushToDeltaIN->ui32Delta); @@ -3452,12 +4467,14 @@ PVRSRVSyncOpsFlushToDeltaBW(IMG_UINT32 u static PVRSRV_ERROR FreeSyncInfoCallback(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; PVRSRV_ERROR eError; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)pvParam; @@ -3466,7 +4483,7 @@ FreeSyncInfoCallback(IMG_PVOID pvParam, { return eError; } - + return PVRSRV_OK; } @@ -3481,7 +4498,7 @@ PVRSRVAllocSyncInfoBW(IMG_UINT32 ui32Bri PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; IMG_HANDLE hDevMemContext; - + PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_ALLOC_SYNC_INFO); NEW_HANDLE_BATCH_OR_ERROR(psAllocSyncInfoOUT->eError, psPerProc, 1) @@ -3496,11 +4513,11 @@ PVRSRVAllocSyncInfoBW(IMG_UINT32 ui32Bri } hDevMemContext = psDeviceNode->sDevMemoryInfo.pBMKernelContext; - + eError = PVRSRVAllocSyncInfoKM(psDeviceNode, hDevMemContext, &psSyncInfo); - + if (eError != PVRSRV_OK) { goto allocsyncinfo_errorexit; @@ -3525,7 +4542,7 @@ PVRSRVAllocSyncInfoBW(IMG_UINT32 ui32Bri goto allocsyncinfo_commit; - + allocsyncinfo_errorexit_freesyncinfo: PVRSRVFreeSyncInfoKM(psSyncInfo); @@ -3536,7 +4553,7 @@ PVRSRVAllocSyncInfoBW(IMG_UINT32 ui32Bri allocsyncinfo_commit: psAllocSyncInfoOUT->eError = eError; COMMIT_HANDLE_BATCH_OR_ERROR(eError, psPerProc); - + return 0; } @@ -3574,7 +4591,7 @@ PVRSRVFreeSyncInfoBW(IMG_UINT32 ui32Bri return 0; } - eError = ResManFreeResByPtr(psSyncInfo->hResItem); + eError = ResManFreeResByPtr(psSyncInfo->hResItem, CLEANUP_WITH_POLL); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVFreeSyncInfoBW: ResManFreeResByPtr failed")); @@ -3619,6 +4636,9 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_MEM_INFO_FROM_USER, DummyBW); SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM, PVRSRVExportDeviceMemBW); SetDispatchTableEntry(PVRSRV_BRIDGE_RELEASE_MMAP_DATA, PVRMMapReleaseMMapDataBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS, PVRSRVChangeDeviceMemoryAttributesBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEV_MEMORY_2, PVRSRVMapDeviceMemoryBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2, PVRSRVExportDeviceMemBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT, DummyBW); @@ -3657,6 +4677,7 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPREADREG, PDumpReadRegBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_SYNCPOL, PDumpSyncPolBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPSYNC, PDumpSyncDumpBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_MEMPAGES, PDumpMemPagesBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DRIVERINFO, PDumpDriverInfoBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPPDDEVPADDR, PDumpPDDevPAddrBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ, PDumpCycleCountRegReadBW); @@ -3675,7 +4696,11 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_CLOSE_DISPCLASS_DEVICE, PVRSRVCloseDCDeviceBW); SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_DISPCLASS_FORMATS, PVRSRVEnumDCFormatsBW); SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_DISPCLASS_DIMS, PVRSRVEnumDCDimsBW); +#if defined(SUPPORT_PVRSRV_GET_DC_SYSTEM_BUFFER) SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_SYSBUFFER, PVRSRVGetDCSystemBufferBW); +#else + SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_SYSBUFFER, DummyBW); +#endif SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_INFO, PVRSRVGetDCInfoBW); SetDispatchTableEntry(PVRSRV_BRIDGE_CREATE_DISPCLASS_SWAPCHAIN, PVRSRVCreateDCSwapChainBW); SetDispatchTableEntry(PVRSRV_BRIDGE_DESTROY_DISPCLASS_SWAPCHAIN, PVRSRVDestroyDCSwapChainBW); @@ -3685,6 +4710,7 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_SRCCOLOURKEY, PVRSRVSetDCSrcColourKeyBW); SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_BUFFERS, PVRSRVGetDCBuffersBW); SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER, PVRSRVSwapToDCBufferBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER2, PVRSRVSwapToDCBuffer2BW); SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_SYSTEM, PVRSRVSwapToDCSystemBW); @@ -3702,7 +4728,7 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_FREE_SHARED_SYS_MEM, PVRSRVFreeSharedSysMemoryBW); SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_MEMINFO_MEM, PVRSRVMapMemInfoMemBW); - + SetDispatchTableEntry(PVRSRV_BRIDGE_GETMMU_PD_DEVPADDR, MMU_GetPDDevPAddrBW); @@ -3718,6 +4744,8 @@ CommonBridgeInit(IMG_VOID) SetDispatchTableEntry(PVRSRV_BRIDGE_DESTROY_SYNC_INFO_MOD_OBJ, PVRSRVDestroySyncInfoModObjBW); SetDispatchTableEntry(PVRSRV_BRIDGE_MODIFY_PENDING_SYNC_OPS, PVRSRVModifyPendingSyncOpsBW); SetDispatchTableEntry(PVRSRV_BRIDGE_MODIFY_COMPLETE_SYNC_OPS, PVRSRVModifyCompleteSyncOpsBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SYNC_OPS_TAKE_TOKEN, PVRSRVSyncOpsTakeTokenBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_TOKEN, PVRSRVSyncOpsFlushToTokenBW); SetDispatchTableEntry(PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_MOD_OBJ, PVRSRVSyncOpsFlushToModObjBW); SetDispatchTableEntry(PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_DELTA, PVRSRVSyncOpsFlushToDeltaBW); SetDispatchTableEntry(PVRSRV_BRIDGE_ALLOC_SYNC_INFO, PVRSRVAllocSyncInfoBW); @@ -3733,7 +4761,6 @@ CommonBridgeInit(IMG_VOID) SetMSVDXDispatchTableEntry(); #endif - for(i=0;i<BRIDGE_DISPATCH_TABLE_ENTRY_COUNT;i++) @@ -3757,7 +4784,6 @@ CommonBridgeInit(IMG_VOID) IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc, PVRSRV_BRIDGE_PACKAGE * psBridgePackageKM) { - IMG_VOID * psBridgeIn; IMG_VOID * psBridgeOut; BridgeWrapperFunction pfBridgeHandler; @@ -3813,8 +4839,6 @@ IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc, } } - - #if defined(__linux__) { @@ -3827,10 +4851,12 @@ IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc, psBridgeOut = (IMG_PVOID)((IMG_PBYTE)psBridgeIn + PVRSRV_MAX_BRIDGE_IN_SIZE); -#if defined(DEBUG) - PVR_ASSERT(psBridgePackageKM->ui32InBufferSize < PVRSRV_MAX_BRIDGE_IN_SIZE); - PVR_ASSERT(psBridgePackageKM->ui32OutBufferSize < PVRSRV_MAX_BRIDGE_OUT_SIZE); -#endif + if((psBridgePackageKM->ui32InBufferSize > PVRSRV_MAX_BRIDGE_IN_SIZE) || + (psBridgePackageKM->ui32OutBufferSize > PVRSRV_MAX_BRIDGE_OUT_SIZE)) + { + goto return_fault; + } + if(psBridgePackageKM->ui32InBufferSize > 0) { @@ -3874,7 +4900,6 @@ IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc, goto return_fault; } - #if defined(__linux__) if(CopyToUserWrapper(psPerProc, @@ -3890,6 +4915,7 @@ IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc, err = 0; return_fault: + ReleaseHandleBatch(psPerProc); return err; } diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.h b/drivers/gpu/pvr/bridged_pvr_bridge.h index 0042574..6b0dd88 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.h +++ b/drivers/gpu/pvr/bridged_pvr_bridge.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -83,7 +83,7 @@ CopyToUserWrapper(PVRSRV_PER_PROCESS_DATA *pProcData, #define ASSIGN_AND_EXIT_ON_ERROR(error, src) \ ASSIGN_AND_RETURN_ON_ERROR(error, src, 0) -#if defined (PVR_SECURE_HANDLES) +#if defined (PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) #ifdef INLINE_IS_PRAGMA #pragma inline(NewHandleBatch) #endif diff --git a/drivers/gpu/pvr/bridged_support.c b/drivers/gpu/pvr/bridged_support.c index e10e577..dad0800 100644 --- a/drivers/gpu/pvr/bridged_support.c +++ b/drivers/gpu/pvr/bridged_support.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -30,7 +30,11 @@ PVRSRV_ERROR +#if defined (SUPPORT_SID_INTERFACE) +PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHandle, IMG_SID hMHandle) +#else PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHandle, IMG_HANDLE hMHandle) +#endif { IMG_HANDLE hMHandleInt; PVRSRV_HANDLE_TYPE eHandleType; @@ -47,7 +51,7 @@ PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHan switch(eHandleType) { -#if defined(PVR_SECURE_HANDLES) +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) case PVRSRV_HANDLE_TYPE_MEM_INFO: case PVRSRV_HANDLE_TYPE_MEM_INFO_REF: case PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO: diff --git a/drivers/gpu/pvr/bridged_support.h b/drivers/gpu/pvr/bridged_support.h index 371715d..d027290 100644 --- a/drivers/gpu/pvr/bridged_support.h +++ b/drivers/gpu/pvr/bridged_support.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -33,7 +33,11 @@ extern "C" { #endif +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phOSMemHandle, IMG_SID hMHandle); +#else PVRSRV_ERROR PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phOSMemHandle, IMG_HANDLE hMHandle); +#endif #if defined (__cplusplus) } diff --git a/drivers/gpu/pvr/buffer_manager.c b/drivers/gpu/pvr/buffer_manager.c index c5ee8c7..8907e22 100644 --- a/drivers/gpu/pvr/buffer_manager.c +++ b/drivers/gpu/pvr/buffer_manager.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -38,8 +38,9 @@ static IMG_VOID BM_FreeMemory (IMG_VOID *pH, IMG_UINTPTR_T base, BM_MAPPING *psMapping); static IMG_BOOL BM_ImportMemory(IMG_VOID *pH, IMG_SIZE_T uSize, - IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, - IMG_UINT32 uFlags, IMG_UINTPTR_T *pBase); + IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, + IMG_UINT32 uFlags, IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase); static IMG_BOOL DevMemoryAlloc (BM_CONTEXT *pBMContext, @@ -52,13 +53,15 @@ static IMG_VOID DevMemoryFree (BM_MAPPING *pMapping); static IMG_BOOL -AllocMemory (BM_CONTEXT *pBMContext, - BM_HEAP *psBMHeap, - IMG_DEV_VIRTADDR *psDevVAddr, - IMG_SIZE_T uSize, - IMG_UINT32 uFlags, - IMG_UINT32 uDevVAddrAlignment, - BM_BUF *pBuf) +AllocMemory (BM_CONTEXT *pBMContext, + BM_HEAP *psBMHeap, + IMG_DEV_VIRTADDR *psDevVAddr, + IMG_SIZE_T uSize, + IMG_UINT32 uFlags, + IMG_UINT32 uDevVAddrAlignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, + BM_BUF *pBuf) { BM_MAPPING *pMapping; IMG_UINTPTR_T uOffset; @@ -105,6 +108,8 @@ AllocMemory (BM_CONTEXT *pBMContext, uFlags, uDevVAddrAlignment, 0, + pvPrivData, + ui32PrivDataLength, (IMG_UINTPTR_T *)&(pBuf->DevVAddr.uiAddr))) { PVR_DPF((PVR_DBG_ERROR, "AllocMemory: RA_Alloc(0x%x) FAILED", uSize)); @@ -175,15 +180,22 @@ AllocMemory (BM_CONTEXT *pBMContext, } else { + IMG_BOOL bResult; - pBMContext->psDeviceNode->pfnMMUAlloc (psBMHeap->pMMUHeap, + bResult = pBMContext->psDeviceNode->pfnMMUAlloc (psBMHeap->pMMUHeap, uSize, IMG_NULL, 0, uDevVAddrAlignment, &pBuf->DevVAddr); + + if(!bResult) + { + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: MMUAlloc failed")); + return IMG_FALSE; + } } @@ -526,6 +538,7 @@ static IMG_VOID FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) { BM_MAPPING *pMapping; + PVRSRV_DEVICE_NODE *psDeviceNode; PVR_DPF ((PVR_DBG_MESSAGE, "FreeBuf: pBuf=0x%x: DevVAddr=%08X CpuVAddr=0x%x CpuPAddr=%08X", @@ -535,6 +548,12 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) pMapping = pBuf->pMapping; + psDeviceNode = pMapping->pBMHeap->pBMContext->psDeviceNode; + if (psDeviceNode->pfnCacheInvalidate) + { + psDeviceNode->pfnCacheInvalidate(psDeviceNode); + } + if(ui32Flags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) { @@ -695,7 +714,7 @@ BM_DestroyContext(IMG_HANDLE hBMContext, else { - eError = ResManFreeResByPtr(pBMContext->hResItem); + eError = ResManFreeResByPtr(pBMContext->hResItem, CLEANUP_WITH_POLL); if(eError != PVRSRV_OK) { PVR_DPF ((PVR_DBG_ERROR, "BM_DestroyContext: ResManFreeResByPtr failed %d",eError)); @@ -745,13 +764,15 @@ static PVRSRV_ERROR BM_DestroyContextCallBack_AnyVaCb(BM_HEAP *psBMHeap, va_list } -static PVRSRV_ERROR BM_DestroyContextCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +static PVRSRV_ERROR BM_DestroyContextCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { BM_CONTEXT *pBMContext = pvParam; PVRSRV_DEVICE_NODE *psDeviceNode; PVRSRV_ERROR eError; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); @@ -787,8 +808,11 @@ static PVRSRV_ERROR BM_DestroyContextCallBack(IMG_PVOID pvParam, } else { - - List_BM_CONTEXT_Remove(pBMContext); + if (pBMContext->ppsThis != IMG_NULL) + { + + List_BM_CONTEXT_Remove(pBMContext); + } } OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BM_CONTEXT), pBMContext, IMG_NULL); @@ -895,9 +919,9 @@ BM_CreateContext(PVRSRV_DEVICE_NODE *psDeviceNode, goto cleanup; } - if(psDeviceNode->pfnMMUInitialise(psDeviceNode, - &pBMContext->psMMUContext, - psPDDevPAddr) != PVRSRV_OK) + if((IMG_NULL == psDeviceNode->pfnMMUInitialise) || (psDeviceNode->pfnMMUInitialise(psDeviceNode, + &pBMContext->psMMUContext, + psPDDevPAddr) != PVRSRV_OK)) { PVR_DPF((PVR_DBG_ERROR, "BM_CreateContext: MMUInitialise failed")); goto cleanup; @@ -966,7 +990,7 @@ BM_CreateContext(PVRSRV_DEVICE_NODE *psDeviceNode, return (IMG_HANDLE)pBMContext; cleanup: - (IMG_VOID)BM_DestroyContextCallBack(pBMContext, 0); + (IMG_VOID)BM_DestroyContextCallBack(pBMContext, 0, CLEANUP_WITH_POLL); return IMG_NULL; } @@ -1006,6 +1030,11 @@ BM_CreateHeap (IMG_HANDLE hBMContext, psDeviceNode = pBMContext->psDeviceNode; + + PVR_ASSERT((psDevMemHeapInfo->ui32HeapSize & (psDevMemHeapInfo->ui32DataPageSize - 1)) == 0); + PVR_ASSERT(psDevMemHeapInfo->ui32HeapSize > 0); + + @@ -1042,6 +1071,9 @@ BM_CreateHeap (IMG_HANDLE hBMContext, psBMHeap->sDevArena.ui32DataPageSize = psDevMemHeapInfo->ui32DataPageSize; psBMHeap->sDevArena.psDeviceMemoryHeapInfo = psDevMemHeapInfo; psBMHeap->ui32Attribs = psDevMemHeapInfo->ui32Attribs; +#if defined(SUPPORT_MEMORY_TILING) + psBMHeap->ui32XTileStride = psDevMemHeapInfo->ui32XTileStride; +#endif psBMHeap->pBMContext = pBMContext; @@ -1096,7 +1128,7 @@ ErrorExit: if (psBMHeap->pMMUHeap != IMG_NULL) { psDeviceNode->pfnMMUDelete (psBMHeap->pMMUHeap); - psDeviceNode->pfnMMUFinalise (pBMContext->psMMUContext); + } @@ -1165,6 +1197,8 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, IMG_SIZE_T uSize, IMG_UINT32 *pui32Flags, IMG_UINT32 uDevVAddrAlignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, BM_HANDLE *phBuf) { BM_BUF *pBuf; @@ -1214,6 +1248,8 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, uSize, uFlags, uDevVAddrAlignment, + pvPrivData, + ui32PrivDataLength, pBuf) != IMG_TRUE) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof (BM_BUF), pBuf, IMG_NULL); @@ -1379,6 +1415,11 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, return IMG_TRUE; } + else + { + + HASH_Remove(psBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddress.uiAddr); + } } @@ -1567,7 +1608,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, { PVRSRV_DEVICE_NODE *psDeviceNode; #ifdef PDUMP - IMG_UINT32 ui32PDumpSize = pMapping->uSize; + IMG_UINT32 ui32PDumpSize = (IMG_UINT32)pMapping->uSize; #endif psDeviceNode = pBMContext->psDeviceNode; @@ -1677,41 +1718,337 @@ static IMG_VOID DevMemoryFree (BM_MAPPING *pMapping) { PVRSRV_DEVICE_NODE *psDeviceNode; + IMG_DEV_PHYADDR sDevPAddr; #ifdef PDUMP IMG_UINT32 ui32PSize; #endif + psDeviceNode = pMapping->pBMHeap->pBMContext->psDeviceNode; + sDevPAddr = psDeviceNode->pfnMMUGetPhysPageAddr(pMapping->pBMHeap->pMMUHeap, pMapping->DevVAddr); + + if (sDevPAddr.uiAddr != 0) + { #ifdef PDUMP + + if(pMapping->ui32Flags & PVRSRV_MEM_DUMMY) + { + + ui32PSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; + } + else + { + ui32PSize = (IMG_UINT32)pMapping->uSize; + } - if(pMapping->ui32Flags & PVRSRV_MEM_DUMMY) + PDUMPFREEPAGES(pMapping->pBMHeap, + pMapping->DevVAddr, + ui32PSize, + pMapping->pBMHeap->sDevArena.ui32DataPageSize, + (IMG_HANDLE)pMapping, + (pMapping->ui32Flags & PVRSRV_MEM_INTERLEAVED) ? IMG_TRUE : IMG_FALSE); +#endif + } + psDeviceNode->pfnMMUFree (pMapping->pBMHeap->pMMUHeap, pMapping->DevVAddr, IMG_CAST_TO_DEVVADDR_UINT(pMapping->uSize)); +} + +#ifndef XPROC_WORKAROUND_NUM_SHAREABLES +#define XPROC_WORKAROUND_NUM_SHAREABLES 200 +#endif + +#define XPROC_WORKAROUND_BAD_SHAREINDEX 0773407734 + +static IMG_UINT32 gXProcWorkaroundShareIndex = XPROC_WORKAROUND_BAD_SHAREINDEX; + + +static struct { + IMG_UINT32 ui32RefCount; + IMG_UINT32 ui32AllocFlags; + IMG_UINT32 ui32Size; + IMG_UINT32 ui32PageSize; + RA_ARENA *psArena; + IMG_SYS_PHYADDR sSysPAddr; + IMG_VOID *pvCpuVAddr; + IMG_HANDLE hOSMemHandle; +} gXProcWorkaroundShareData[XPROC_WORKAROUND_NUM_SHAREABLES] = {{0}}; + +PVRSRV_ERROR BM_XProcWorkaroundSetShareIndex(IMG_UINT32 ui32Index) +{ + + + + if (gXProcWorkaroundShareIndex != XPROC_WORKAROUND_BAD_SHAREINDEX) { - - ui32PSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; + PVR_DPF((PVR_DBG_ERROR, "No, it's already set!")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + gXProcWorkaroundShareIndex = ui32Index; + + return PVRSRV_OK; +} + +PVRSRV_ERROR BM_XProcWorkaroundUnsetShareIndex(IMG_UINT32 ui32Index) +{ + + + + if (gXProcWorkaroundShareIndex == XPROC_WORKAROUND_BAD_SHAREINDEX) + { + PVR_DPF((PVR_DBG_ERROR, "huh? how can it be bad??")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + if (gXProcWorkaroundShareIndex != ui32Index) + { + PVR_DPF((PVR_DBG_ERROR, "gXProcWorkaroundShareIndex == 0x%08x != 0x%08x == ui32Index", gXProcWorkaroundShareIndex, ui32Index)); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + gXProcWorkaroundShareIndex = XPROC_WORKAROUND_BAD_SHAREINDEX; + + return PVRSRV_OK; +} + +PVRSRV_ERROR BM_XProcWorkaroundFindNewBufferAndSetShareIndex(IMG_UINT32 *pui32Index) +{ + + + + if (gXProcWorkaroundShareIndex != XPROC_WORKAROUND_BAD_SHAREINDEX) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + for (*pui32Index = 0; *pui32Index < XPROC_WORKAROUND_NUM_SHAREABLES; (*pui32Index)++) + { + if (gXProcWorkaroundShareData[*pui32Index].ui32RefCount == 0) + { + gXProcWorkaroundShareIndex = *pui32Index; + return PVRSRV_OK; + } + } + + PVR_DPF((PVR_DBG_ERROR, "ran out of shared buffers")); + return PVRSRV_ERROR_OUT_OF_MEMORY; +} + +static PVRSRV_ERROR +XProcWorkaroundAllocShareable(RA_ARENA *psArena, + IMG_UINT32 ui32AllocFlags, + IMG_UINT32 ui32Size, + IMG_UINT32 ui32PageSize, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, + IMG_VOID **ppvCpuVAddr, + IMG_HANDLE *phOSMemHandle) +{ + if ((ui32AllocFlags & PVRSRV_MEM_XPROC) == 0) + { + PVR_DPF((PVR_DBG_VERBOSE, "XProcWorkaroundAllocShareable: bad flags")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if (gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32RefCount > 0) + { + PVR_DPF((PVR_DBG_VERBOSE, + "XProcWorkaroundAllocShareable: re-using previously allocated pages")); + + ui32AllocFlags &= ~PVRSRV_HAP_MAPTYPE_MASK; + ui32AllocFlags |= PVRSRV_HAP_SINGLE_PROCESS; + + if (ui32AllocFlags != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags) + { + PVR_DPF((PVR_DBG_ERROR, + "Can't! Flags don't match! (I had 0x%08x, you gave 0x%08x)", + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags, + ui32AllocFlags)); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if (ui32Size != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32Size) + { + PVR_DPF((PVR_DBG_ERROR, + "Can't! Size doesn't match!")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if (ui32PageSize != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32PageSize) + { + PVR_DPF((PVR_DBG_ERROR, + "Can't! Page Size doesn't match!")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + *ppvCpuVAddr = gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].pvCpuVAddr; + *phOSMemHandle = gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].hOSMemHandle; + + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32RefCount ++; + + return PVRSRV_OK; } else { - ui32PSize = pMapping->uSize; + if (psArena != IMG_NULL) + { + IMG_CPU_PHYADDR sCpuPAddr; + IMG_SYS_PHYADDR sSysPAddr; + + PVR_DPF((PVR_DBG_VERBOSE, + "XProcWorkaroundAllocShareable: making a NEW allocation from local mem")); + + if (!RA_Alloc (psArena, + ui32Size, + IMG_NULL, + IMG_NULL, + 0, + ui32PageSize, + 0, + pvPrivData, + ui32PrivDataLength, + (IMG_UINTPTR_T *)&sSysPAddr.uiAddr)) + { + PVR_DPF((PVR_DBG_ERROR, "XProcWorkaroundAllocShareable: RA_Alloc(0x%x) FAILED", ui32Size)); + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + + sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); + if(OSReservePhys(sCpuPAddr, + ui32Size, + ui32AllocFlags, + (IMG_VOID **)&gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].pvCpuVAddr, + &gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].hOSMemHandle) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "XProcWorkaroundAllocShareable: OSReservePhys failed")); + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].sSysPAddr = sSysPAddr; + } + else + { + PVR_DPF((PVR_DBG_VERBOSE, + "XProcWorkaroundAllocShareable: making a NEW allocation from OS")); + + ui32AllocFlags &= ~PVRSRV_HAP_MAPTYPE_MASK; + ui32AllocFlags |= PVRSRV_HAP_SINGLE_PROCESS; + + + if (OSAllocPages(ui32AllocFlags, + ui32Size, + ui32PageSize, + pvPrivData, + ui32PrivDataLength, + (IMG_VOID **)&gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].pvCpuVAddr, + &gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].hOSMemHandle) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, + "XProcWorkaroundAllocShareable: OSAllocPages(0x%x) failed", + ui32PageSize)); + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + } + + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].psArena = psArena; + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags = ui32AllocFlags; + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32Size = ui32Size; + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32PageSize = ui32PageSize; + + *ppvCpuVAddr = gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].pvCpuVAddr; + *phOSMemHandle = gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].hOSMemHandle; + + gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32RefCount ++; + + return PVRSRV_OK; } +} - PDUMPFREEPAGES(pMapping->pBMHeap, - pMapping->DevVAddr, - ui32PSize, - pMapping->pBMHeap->sDevArena.ui32DataPageSize, - (IMG_HANDLE)pMapping, - (pMapping->ui32Flags & PVRSRV_MEM_INTERLEAVED) ? IMG_TRUE : IMG_FALSE); -#endif +static PVRSRV_ERROR XProcWorkaroundHandleToSI(IMG_HANDLE hOSMemHandle, IMG_UINT32 *pui32SI) +{ + + IMG_UINT32 ui32SI; + IMG_BOOL bFound; + IMG_BOOL bErrorDups; - psDeviceNode = pMapping->pBMHeap->pBMContext->psDeviceNode; + bFound = IMG_FALSE; + bErrorDups = IMG_FALSE; - psDeviceNode->pfnMMUFree (pMapping->pBMHeap->pMMUHeap, pMapping->DevVAddr, IMG_CAST_TO_DEVVADDR_UINT(pMapping->uSize)); + for (ui32SI = 0; ui32SI < XPROC_WORKAROUND_NUM_SHAREABLES; ui32SI++) + { + if (gXProcWorkaroundShareData[ui32SI].ui32RefCount>0 && gXProcWorkaroundShareData[ui32SI].hOSMemHandle == hOSMemHandle) + { + if (bFound) + { + bErrorDups = IMG_TRUE; + } + else + { + *pui32SI = ui32SI; + bFound = IMG_TRUE; + } + } + } + + if (bErrorDups || !bFound) + { + return PVRSRV_ERROR_BM_BAD_SHAREMEM_HANDLE; + } + + return PVRSRV_OK; } +static IMG_VOID XProcWorkaroundFreeShareable(IMG_HANDLE hOSMemHandle) +{ + IMG_UINT32 ui32SI = (IMG_UINT32)((IMG_UINTPTR_T)hOSMemHandle & 0xffffU); + PVRSRV_ERROR eError; + + eError = XProcWorkaroundHandleToSI(hOSMemHandle, &ui32SI); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "bad handle")); + return; + } + + gXProcWorkaroundShareData[ui32SI].ui32RefCount --; + + PVR_DPF((PVR_DBG_VERBOSE, "Reduced refcount of SI[%d] from %d to %d", + ui32SI, gXProcWorkaroundShareData[ui32SI].ui32RefCount+1, gXProcWorkaroundShareData[ui32SI].ui32RefCount)); + + if (gXProcWorkaroundShareData[ui32SI].ui32RefCount == 0) + { + if (gXProcWorkaroundShareData[ui32SI].psArena != IMG_NULL) + { + IMG_SYS_PHYADDR sSysPAddr; + + if (gXProcWorkaroundShareData[ui32SI].pvCpuVAddr != IMG_NULL) + { + OSUnReservePhys(gXProcWorkaroundShareData[ui32SI].pvCpuVAddr, + gXProcWorkaroundShareData[ui32SI].ui32Size, + gXProcWorkaroundShareData[ui32SI].ui32AllocFlags, + gXProcWorkaroundShareData[ui32SI].hOSMemHandle); + } + sSysPAddr = gXProcWorkaroundShareData[ui32SI].sSysPAddr; + RA_Free (gXProcWorkaroundShareData[ui32SI].psArena, + sSysPAddr.uiAddr, + IMG_FALSE); + } + else + { + PVR_DPF((PVR_DBG_VERBOSE, "freeing OS memory")); + OSFreePages(gXProcWorkaroundShareData[ui32SI].ui32AllocFlags, + gXProcWorkaroundShareData[ui32SI].ui32PageSize, + gXProcWorkaroundShareData[ui32SI].pvCpuVAddr, + gXProcWorkaroundShareData[ui32SI].hOSMemHandle); + } + } +} + + static IMG_BOOL BM_ImportMemory (IMG_VOID *pH, IMG_SIZE_T uRequestSize, IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, IMG_UINT32 uFlags, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase) { BM_MAPPING *pMapping; @@ -1720,7 +2057,7 @@ BM_ImportMemory (IMG_VOID *pH, IMG_BOOL bResult; IMG_SIZE_T uSize; IMG_SIZE_T uPSize; - IMG_UINT32 uDevVAddrAlignment = 0; + IMG_SIZE_T uDevVAddrAlignment = 0; PVR_DPF ((PVR_DBG_MESSAGE, "BM_ImportMemory (pBMContext=0x%x, uRequestSize=0x%x, uFlags=0x%x, uAlign=0x%x)", @@ -1771,6 +2108,113 @@ BM_ImportMemory (IMG_VOID *pH, uPSize = pMapping->uSize; } + if (uFlags & PVRSRV_MEM_XPROC) + { + IMG_UINT32 ui32Attribs = pBMHeap->ui32Attribs | PVRSRV_MEM_XPROC; + IMG_BOOL bBadBackingStoreType; + + + if(uFlags & PVRSRV_MEM_ION) + { + ui32Attribs |= PVRSRV_MEM_ION; + } + + bBadBackingStoreType = IMG_TRUE; + + if ((ui32Attribs & PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG) != 0) + { +#ifndef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + uDevVAddrAlignment = MAX(pBMHeap->sDevArena.ui32DataPageSize, HOST_PAGESIZE()); + + + if (uPSize % uDevVAddrAlignment != 0) + { + PVR_DPF((PVR_DBG_ERROR, "Cannot use use this memory sharing workaround with allocations that might be suballocated")); + goto fail_mapping_alloc; + } + uDevVAddrAlignment = 0; + + + if (pMapping->ui32Flags & PVRSRV_HAP_CACHETYPE_MASK) + { + ui32Attribs &= ~PVRSRV_HAP_CACHETYPE_MASK; + ui32Attribs |= (pMapping->ui32Flags & PVRSRV_HAP_CACHETYPE_MASK); + } + + + if (XProcWorkaroundAllocShareable(IMG_NULL, + ui32Attribs, + (IMG_UINT32)uPSize, + pBMHeap->sDevArena.ui32DataPageSize, + pvPrivData, + ui32PrivDataLength, + (IMG_VOID **)&pMapping->CpuVAddr, + &pMapping->hOSMemHandle) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, + "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%x) failed", + uPSize)); + goto fail_mapping_alloc; + } + + + + + pMapping->eCpuMemoryOrigin = hm_env; + bBadBackingStoreType = IMG_FALSE; + } + + if ((ui32Attribs & PVRSRV_BACKINGSTORE_LOCALMEM_CONTIG) != 0) + { + uDevVAddrAlignment = pBMHeap->sDevArena.ui32DataPageSize; + + if (uPSize % uDevVAddrAlignment != 0) + { + PVR_DPF((PVR_DBG_ERROR, "Cannot use use this memory sharing workaround with allocations that might be suballocated")); + goto fail_mapping_alloc; + } + uDevVAddrAlignment = 0; + + + if (pMapping->ui32Flags & PVRSRV_HAP_CACHETYPE_MASK) + { + ui32Attribs &= ~PVRSRV_HAP_CACHETYPE_MASK; + ui32Attribs |= (pMapping->ui32Flags & PVRSRV_HAP_CACHETYPE_MASK); + } + + + if (XProcWorkaroundAllocShareable(pBMHeap->pLocalDevMemArena, + ui32Attribs, + (IMG_UINT32)uPSize, + pBMHeap->sDevArena.ui32DataPageSize, + pvPrivData, + ui32PrivDataLength, + (IMG_VOID **)&pMapping->CpuVAddr, + &pMapping->hOSMemHandle) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, + "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%x) failed", + uPSize)); + goto fail_mapping_alloc; + } + + + + + pMapping->eCpuMemoryOrigin = hm_env; + bBadBackingStoreType = IMG_FALSE; + } + + if (bBadBackingStoreType) + { + PVR_DPF((PVR_DBG_ERROR, "Cannot use this memory sharing workaround with this type of backing store")); + goto fail_mapping_alloc; + } + } + else + if(pBMHeap->ui32Attribs & PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG) @@ -1783,11 +2227,19 @@ BM_ImportMemory (IMG_VOID *pH, ui32Attribs &= ~PVRSRV_HAP_CACHETYPE_MASK; ui32Attribs |= (pMapping->ui32Flags & PVRSRV_HAP_CACHETYPE_MASK); } - + + if (pMapping->ui32Flags & PVRSRV_MEM_ALLOCATENONCACHEDMEM) + { + ui32Attribs &= ~PVRSRV_MEM_ALLOCATENONCACHEDMEM; + ui32Attribs |= (pMapping->ui32Flags & PVRSRV_MEM_ALLOCATENONCACHEDMEM); + } + if (OSAllocPages(ui32Attribs, uPSize, pBMHeap->sDevArena.ui32DataPageSize, + pvPrivData, + ui32PrivDataLength, (IMG_VOID **)&pMapping->CpuVAddr, &pMapping->hOSMemHandle) != PVRSRV_OK) { @@ -1822,6 +2274,8 @@ BM_ImportMemory (IMG_VOID *pH, 0, pBMHeap->sDevArena.ui32DataPageSize, 0, + pvPrivData, + ui32PrivDataLength, (IMG_UINTPTR_T *)&sSysPAddr.uiAddr)) { PVR_DPF((PVR_DBG_ERROR, "BM_ImportMemory: RA_Alloc(0x%x) FAILED", uPSize)); @@ -1854,7 +2308,7 @@ BM_ImportMemory (IMG_VOID *pH, pMapping, IMG_NULL, uFlags, - uDevVAddrAlignment, + (IMG_UINT32)uDevVAddrAlignment, &pMapping->DevVAddr); if (!bResult) { @@ -1892,7 +2346,12 @@ fail_dev_mem_alloc: uPSize = pMapping->uSize; } - if(pBMHeap->ui32Attribs & PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG) + if (uFlags & PVRSRV_MEM_XPROC) + { + XProcWorkaroundFreeShareable(pMapping->hOSMemHandle); + } + else + if(pBMHeap->ui32Attribs & PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG) { OSFreePages(pBMHeap->ui32Attribs, uPSize, @@ -1959,7 +2418,12 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping) uPSize = psMapping->uSize; } - if(pBMHeap->ui32Attribs & PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG) + if (psMapping->ui32Flags & PVRSRV_MEM_XPROC) + { + XProcWorkaroundFreeShareable(psMapping->hOSMemHandle); + } + else + if(pBMHeap->ui32Attribs & PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG) { OSFreePages(pBMHeap->ui32Attribs, uPSize, @@ -2002,6 +2466,7 @@ IMG_VOID BM_GetPhysPageAddr(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PVR_ASSERT((sDevVPageAddr.uiAddr & 0xFFF) == 0); + psDeviceNode = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->pBMContext->psDeviceNode; *psDevPAddr = psDeviceNode->pfnMMUGetPhysPageAddr(((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->pMMUHeap, diff --git a/drivers/gpu/pvr/buffer_manager.h b/drivers/gpu/pvr/buffer_manager.h index 1467cd3..bf7c038 100644 --- a/drivers/gpu/pvr/buffer_manager.h +++ b/drivers/gpu/pvr/buffer_manager.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -86,6 +86,8 @@ struct _BM_HEAP_ struct _BM_HEAP_ *psNext; struct _BM_HEAP_ **ppsThis; + + IMG_UINT32 ui32XTileStride; }; struct _BM_CONTEXT_ @@ -154,6 +156,8 @@ BM_Alloc (IMG_HANDLE hDevMemHeap, IMG_SIZE_T uSize, IMG_UINT32 *pui32Flags, IMG_UINT32 uDevVAddrAlignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, BM_HANDLE *phBuf); IMG_BOOL @@ -202,6 +206,11 @@ IMG_VOID BM_Export(BM_HANDLE hBuf); IMG_VOID BM_FreeExport(BM_HANDLE hBuf, IMG_UINT32 ui32Flags); +PVRSRV_ERROR BM_XProcWorkaroundSetShareIndex(IMG_UINT32 ui32Index); +PVRSRV_ERROR BM_XProcWorkaroundUnsetShareIndex(IMG_UINT32 ui32Index); +PVRSRV_ERROR BM_XProcWorkaroundFindNewBufferAndSetShareIndex(IMG_UINT32 *pui32Index); + + #if defined(__cplusplus) } #endif diff --git a/drivers/gpu/pvr/dbgdrv/Makefile b/drivers/gpu/pvr/dbgdrv/Makefile index 8b00b56..5fdb46d 100644 --- a/drivers/gpu/pvr/dbgdrv/Makefile +++ b/drivers/gpu/pvr/dbgdrv/Makefile @@ -1,6 +1,8 @@ - -ccflags-y = -DLINUX -D__linux__ -DANDROID -DPVR_BUILD_DIR="\"omap3430_android\"" -ccflags-y += -Idrivers/gpu/pvr -Idrivers/gpu/pvr/omap3430 -Idrivers/video/omap2 +ccflags-y := \ + -D__linux__ -DLINUX \ + -Idrivers/gpu/pvr \ + -DSUPPORT_DBGDRV_EVENT_OBJECTS \ + -DLDM_PLATFORM dbgdrv-$(CONFIG_PVR_PDUMP) := \ dbgdriv.o \ diff --git a/drivers/gpu/pvr/dbgdrv/dbgdriv.c b/drivers/gpu/pvr/dbgdrv/dbgdriv.c index 31c0120..386aca4 100644 --- a/drivers/gpu/pvr/dbgdrv/dbgdriv.c +++ b/drivers/gpu/pvr/dbgdrv/dbgdriv.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/dbgdriv.h b/drivers/gpu/pvr/dbgdrv/dbgdriv.h index 52caa06..2db4843 100644 --- a/drivers/gpu/pvr/dbgdrv/dbgdriv.h +++ b/drivers/gpu/pvr/dbgdrv/dbgdriv.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/dbgdriv_ioctl.h b/drivers/gpu/pvr/dbgdrv/dbgdriv_ioctl.h index 3088a3a..130c146 100644 --- a/drivers/gpu/pvr/dbgdrv/dbgdriv_ioctl.h +++ b/drivers/gpu/pvr/dbgdrv/dbgdriv_ioctl.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/handle.c b/drivers/gpu/pvr/dbgdrv/handle.c index 59d920b..ddffb3f 100644 --- a/drivers/gpu/pvr/dbgdrv/handle.c +++ b/drivers/gpu/pvr/dbgdrv/handle.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/hostfunc.c b/drivers/gpu/pvr/dbgdrv/hostfunc.c index ecd1160..18c8898 100644 --- a/drivers/gpu/pvr/dbgdrv/hostfunc.c +++ b/drivers/gpu/pvr/dbgdrv/hostfunc.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -29,6 +29,7 @@ #include <linux/module.h> #include <linux/fs.h> #include <linux/kernel.h> +#include <linux/slab.h> #include <linux/mm.h> #include <linux/string.h> #include <asm/page.h> @@ -54,7 +55,7 @@ #include "hostfunc.h" #include "dbgdriv.h" -#if defined(DEBUG) && !defined(SUPPORT_DRI_DRM) +#if defined(MODULE) && defined(DEBUG) && !defined(SUPPORT_DRI_DRM) IMG_UINT32 gPVRDebugLevel = (DBGPRIV_FATAL | DBGPRIV_ERROR | DBGPRIV_WARNING); #define PVR_STRING_TERMINATOR '\0' @@ -85,9 +86,15 @@ void PVRSRVDebugPrintf ( if (gPVRDebugLevel & ui32DebugLevel) { va_list vaArgs; - static char szBuffer[256]; + char szBuffer[256]; + char *szBufferEnd = szBuffer; + char *szBufferLimit = szBuffer + sizeof(szBuffer) - 1; - va_start (vaArgs, pszFormat); + + *szBufferLimit = '\0'; + + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, "PVR_K:"); + szBufferEnd += strlen(szBufferEnd); if (bTrace == IMG_FALSE) @@ -96,52 +103,54 @@ void PVRSRVDebugPrintf ( { case DBGPRIV_FATAL: { - strcpy (szBuffer, "PVR_K:(Fatal): "); + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, "(Fatal):"); break; } case DBGPRIV_ERROR: { - strcpy (szBuffer, "PVR_K:(Error): "); + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, "(Error):"); break; } case DBGPRIV_WARNING: { - strcpy (szBuffer, "PVR_K:(Warning): "); + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, "(Warning):"); break; } case DBGPRIV_MESSAGE: { - strcpy (szBuffer, "PVR_K:(Message): "); + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, "(Message):"); break; } case DBGPRIV_VERBOSE: { - strcpy (szBuffer, "PVR_K:(Verbose): "); + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, "(Verbose):"); break; } default: { - strcpy (szBuffer, "PVR_K:(Unknown message level)"); + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, "(Unknown message level)"); break; } } + szBufferEnd += strlen(szBufferEnd); } - else - { - strcpy (szBuffer, "PVR_K: "); - } + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, " "); + szBufferEnd += strlen(szBufferEnd); - vsprintf (&szBuffer[strlen(szBuffer)], pszFormat, vaArgs); + va_start (vaArgs, pszFormat); + vsnprintf(szBufferEnd, szBufferLimit - szBufferEnd, pszFormat, vaArgs); + va_end (vaArgs); + szBufferEnd += strlen(szBufferEnd); if (bTrace == IMG_FALSE) { - sprintf (&szBuffer[strlen(szBuffer)], " [%d, %s]", (int)ui32Line, pszFileName); + snprintf(szBufferEnd, szBufferLimit - szBufferEnd, + " [%d, %s]", (int)ui32Line, pszFileName); + szBufferEnd += strlen(szBufferEnd); } printk(KERN_INFO "%s\r\n", szBuffer); - - va_end (vaArgs); } } #endif @@ -210,17 +219,31 @@ IMG_VOID HostCreateRegDeclStreams(IMG_VOID) } -IMG_VOID * HostCreateMutex(IMG_VOID) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) +typedef struct mutex MUTEX; +#define INIT_MUTEX(m) mutex_init(m) +#define DOWN_TRYLOCK(m) (!mutex_trylock(m)) +#define DOWN(m) mutex_lock(m) +#define UP(m) mutex_unlock(m) +#else +typedef struct semaphore MUTEX; +#define INIT_MUTEX(m) init_MUTEX(m) +#define DOWN_TRYLOCK(m) down_trylock(m) +#define DOWN(m) down(m) +#define UP(m) up(m) +#endif + +IMG_VOID *HostCreateMutex(IMG_VOID) { - struct semaphore *psSem; + MUTEX *psMutex; - psSem = kmalloc(sizeof(*psSem), GFP_KERNEL); - if (psSem) + psMutex = kmalloc(sizeof(*psMutex), GFP_KERNEL); + if (psMutex) { - init_MUTEX(psSem); + INIT_MUTEX(psMutex); } - return psSem; + return psMutex; } IMG_VOID HostAquireMutex(IMG_VOID * pvMutex) @@ -228,19 +251,19 @@ IMG_VOID HostAquireMutex(IMG_VOID * pvMutex) BUG_ON(in_interrupt()); #if defined(PVR_DEBUG_DBGDRV_DETECT_HOST_MUTEX_COLLISIONS) - if (down_trylock((struct semaphore *)pvMutex)) + if (DOWN_TRYLOCK((MUTEX *)pvMutex)) { printk(KERN_INFO "HostAquireMutex: Waiting for mutex\n"); - down((struct semaphore *)pvMutex); + DOWN((MUTEX *)pvMutex); } #else - down((struct semaphore *)pvMutex); + DOWN((MUTEX *)pvMutex); #endif } IMG_VOID HostReleaseMutex(IMG_VOID * pvMutex) { - up((struct semaphore *)pvMutex); + UP((MUTEX *)pvMutex); } IMG_VOID HostDestroyMutex(IMG_VOID * pvMutex) diff --git a/drivers/gpu/pvr/dbgdrv/hostfunc.h b/drivers/gpu/pvr/dbgdrv/hostfunc.h index 3a29db6..70192fb 100644 --- a/drivers/gpu/pvr/dbgdrv/hostfunc.h +++ b/drivers/gpu/pvr/dbgdrv/hostfunc.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/hotkey.c b/drivers/gpu/pvr/dbgdrv/hotkey.c index 43592d8..a456fee 100644 --- a/drivers/gpu/pvr/dbgdrv/hotkey.c +++ b/drivers/gpu/pvr/dbgdrv/hotkey.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/hotkey.h b/drivers/gpu/pvr/dbgdrv/hotkey.h index 499d64e..c5d84bb 100644 --- a/drivers/gpu/pvr/dbgdrv/hotkey.h +++ b/drivers/gpu/pvr/dbgdrv/hotkey.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/ioctl.c b/drivers/gpu/pvr/dbgdrv/ioctl.c index a021a39..47487b0 100644 --- a/drivers/gpu/pvr/dbgdrv/ioctl.c +++ b/drivers/gpu/pvr/dbgdrv/ioctl.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/dbgdrv/linuxsrv.h b/drivers/gpu/pvr/dbgdrv/linuxsrv.h index adfcd75..f1cb02a 100644 --- a/drivers/gpu/pvr/dbgdrv/linuxsrv.h +++ b/drivers/gpu/pvr/dbgdrv/linuxsrv.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,19 +22,19 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ + **************************************************************************/ #ifndef _LINUXSRV_H__ #define _LINUXSRV_H__ typedef struct tagIOCTL_PACKAGE { - IMG_UINT32 ui32Cmd; - IMG_UINT32 ui32Size; - IMG_VOID *pInBuffer; - IMG_UINT32 ui32InBufferSize; - IMG_VOID *pOutBuffer; - IMG_UINT32 ui32OutBufferSize; + IMG_UINT32 ui32Cmd; // ioctl command + IMG_UINT32 ui32Size; // needs to be correctly set + IMG_VOID *pInBuffer; // input data buffer + IMG_UINT32 ui32InBufferSize; // size of input data buffer + IMG_VOID *pOutBuffer; // output data buffer + IMG_UINT32 ui32OutBufferSize; // size of output data buffer } IOCTL_PACKAGE; IMG_UINT32 DeviceIoControl(IMG_UINT32 hDevice, @@ -45,4 +45,4 @@ IMG_UINT32 DeviceIoControl(IMG_UINT32 hDevice, IMG_UINT32 ui32OutBufferSize, IMG_UINT32 *pui32BytesReturned); -#endif +#endif /* _LINUXSRV_H__*/ diff --git a/drivers/gpu/pvr/dbgdrv/main.c b/drivers/gpu/pvr/dbgdrv/main.c index 965c352..6556249 100644 --- a/drivers/gpu/pvr/dbgdrv/main.c +++ b/drivers/gpu/pvr/dbgdrv/main.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -116,7 +116,7 @@ IMG_VOID DBGDrvGetServiceTable(IMG_VOID **fn_table) #if defined(SUPPORT_DRI_DRM) void dbgdrv_cleanup(void) #else -void cleanup_module(void) +static void __exit dbgdrv_cleanup(void) #endif { #if !defined(SUPPORT_DRI_DRM) @@ -136,7 +136,7 @@ void cleanup_module(void) #if defined(SUPPORT_DRI_DRM) IMG_INT dbgdrv_init(void) #else -int init_module(void) +static int __init dbgdrv_init(void) #endif { #if (defined(LDM_PLATFORM) || defined(LDM_PCI)) && !defined(SUPPORT_DRI_DRM) @@ -240,7 +240,8 @@ long dbgdrv_ioctl(struct file *file, unsigned int ioctlCmd, unsigned long arg) goto init_failed; } - cmd = ((pIP->ui32Cmd >> 2) & 0xFFF) - 0x801; + + cmd = MAKEIOCTLINDEX(pIP->ui32Cmd) - DEBUG_SERVICE_IOCTL_BASE - 1; if(pIP->ui32Cmd == DEBUG_SERVICE_READ) { @@ -309,3 +310,8 @@ IMG_VOID DefineHotKey (IMG_UINT32 ui32ScanCode, IMG_UINT32 ui32ShiftState, PHOTK } EXPORT_SYMBOL(DBGDrvGetServiceTable); + +#if !defined(SUPPORT_DRI_DRM) +subsys_initcall(dbgdrv_init); +module_exit(dbgdrv_cleanup); +#endif diff --git a/drivers/gpu/pvr/dbgdrvif.h b/drivers/gpu/pvr/dbgdrvif.h index 1057c6a..09c1608 100644 --- a/drivers/gpu/pvr/dbgdrvif.h +++ b/drivers/gpu/pvr/dbgdrvif.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,14 +22,30 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +*****************************************************************************/ #ifndef _DBGDRVIF_ #define _DBGDRVIF_ +#if defined(__linux__) + +#define FILE_DEVICE_UNKNOWN 0 +#define METHOD_BUFFERED 0 +#define FILE_ANY_ACCESS 0 + +#define CTL_CODE( DeviceType, Function, Method, Access ) (Function) +#define MAKEIOCTLINDEX(i) ((i) & 0xFFF) + +#else + #include "ioctldef.h" +#endif + +/***************************************************************************** + Stream mode stuff. +*****************************************************************************/ #define DEBUG_CAPMODE_FRAMED 0x00000001UL #define DEBUG_CAPMODE_CONTINUOUS 0x00000002UL #define DEBUG_CAPMODE_HOTKEY 0x00000004UL @@ -48,6 +64,10 @@ #define DEBUG_FLAGS_TEXTSTREAM 0x80000000UL +/***************************************************************************** + Debug level control. Only bothered with the first 12 levels, I suspect you + get the idea... +*****************************************************************************/ #define DEBUG_LEVEL_0 0x00000001UL #define DEBUG_LEVEL_1 0x00000003UL #define DEBUG_LEVEL_2 0x00000007UL @@ -74,6 +94,9 @@ #define DEBUG_LEVEL_SEL10 0x00000400UL #define DEBUG_LEVEL_SEL11 0x00000800UL +/***************************************************************************** + IOCTL values. +*****************************************************************************/ #define DEBUG_SERVICE_IOCTL_BASE 0x800UL #define DEBUG_SERVICE_CREATESTREAM CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS) #define DEBUG_SERVICE_DESTROYSTREAM CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x02, METHOD_BUFFERED, FILE_ANY_ACCESS) @@ -108,6 +131,9 @@ typedef enum _DBG_EVENT_ } DBG_EVENT; +/***************************************************************************** + In/Out Structures +*****************************************************************************/ typedef struct _DBG_IN_CREATESTREAM_ { union @@ -234,23 +260,33 @@ typedef struct _DBG_IN_WRITE_LF_ IMG_UINT32 ui32BufferSize; } DBG_IN_WRITE_LF, *PDBG_IN_WRITE_LF; +/* + Flags for above struct +*/ #define WRITELF_FLAGS_RESETBUF 0x00000001UL +/* + Common control structure (don't duplicate control in main stream + and init phase stream). +*/ typedef struct _DBG_STREAM_CONTROL_ { - IMG_BOOL bInitPhaseComplete; - IMG_UINT32 ui32Flags; + IMG_BOOL bInitPhaseComplete; /*!< init phase has finished */ + IMG_UINT32 ui32Flags; /*!< flags (see DEBUG_FLAGS above) */ - IMG_UINT32 ui32CapMode; - IMG_UINT32 ui32OutMode; + IMG_UINT32 ui32CapMode; /*!< capturing mode framed/hot key */ + IMG_UINT32 ui32OutMode; /*!< output mode, e.g. files */ IMG_UINT32 ui32DebugLevel; IMG_UINT32 ui32DefaultMode; - IMG_UINT32 ui32Start; - IMG_UINT32 ui32End; - IMG_UINT32 ui32Current; - IMG_UINT32 ui32SampleRate; + IMG_UINT32 ui32Start; /*!< first capture frame */ + IMG_UINT32 ui32End; /*!< last frame */ + IMG_UINT32 ui32Current; /*!< current frame */ + IMG_UINT32 ui32SampleRate; /*!< capture frequency */ IMG_UINT32 ui32Reserved; } DBG_STREAM_CONTROL, *PDBG_STREAM_CONTROL; +/* + Per-buffer control structure. +*/ typedef struct _DBG_STREAM_ { struct _DBG_STREAM_ *psNext; @@ -262,20 +298,24 @@ typedef struct _DBG_STREAM_ IMG_UINT32 ui32RPtr; IMG_UINT32 ui32WPtr; IMG_UINT32 ui32DataWritten; - IMG_UINT32 ui32Marker; - IMG_UINT32 ui32InitPhaseWOff; - - - - - IMG_CHAR szName[30]; + IMG_UINT32 ui32Marker; /*!< marker for file splitting */ + IMG_UINT32 ui32InitPhaseWOff; /*!< snapshot offset for init phase end for follow-on pdump */ + IMG_CHAR szName[30]; /* Give this a size, some compilers don't like [] */ } DBG_STREAM,*PDBG_STREAM; +/* + * Allows dbgdrv to notify services when events happen, e.g. pdump.exe starts. + * (better than resetting psDevInfo->psKernelCCBInfo->ui32CCBDumpWOff = 0 + * in SGXGetClientInfoKM.) + */ typedef struct _DBGKM_CONNECT_NOTIFIER_ { IMG_VOID (IMG_CALLCONV *pfnConnectNotifier) (IMG_VOID); } DBGKM_CONNECT_NOTIFIER, *PDBGKM_CONNECT_NOTIFIER; +/***************************************************************************** + Kernel mode service table +*****************************************************************************/ typedef struct _DBGKM_SERVICE_TABLE_ { IMG_UINT32 ui32Size; @@ -313,3 +353,6 @@ typedef struct _DBGKM_SERVICE_TABLE_ #endif +/***************************************************************************** + End of file (DBGDRVIF.H) +*****************************************************************************/ diff --git a/drivers/gpu/pvr/device.h b/drivers/gpu/pvr/device.h index bed2351..9df2c73 100644 --- a/drivers/gpu/pvr/device.h +++ b/drivers/gpu/pvr/device.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -222,6 +222,8 @@ typedef struct _PVRSRV_DEVICE_NODE_ #endif IMG_DEV_PHYADDR (*pfnMMUGetPhysPageAddr)(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR sDevVPageAddr); IMG_DEV_PHYADDR (*pfnMMUGetPDDevPAddr)(MMU_CONTEXT *pMMUContext); + IMG_VOID (*pfnMMUGetCacheFlushRange)(MMU_CONTEXT *pMMUContext, IMG_UINT32 *pui32RangeMask); + IMG_VOID (*pfnMMUGetPDPhysAddr)(MMU_CONTEXT *pMMUContext, IMG_DEV_PHYADDR *psDevPAddr); PVRSRV_ERROR (*pfnAllocMemTilingRange)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode, @@ -244,7 +246,9 @@ typedef struct _PVRSRV_DEVICE_NODE_ IMG_VOID (*pfnDeviceCommandComplete)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode); IMG_BOOL bReProcessDeviceCommandComplete; - + + IMG_VOID (*pfnCacheInvalidate)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode); + DEVICE_MEMORY_INFO sDevMemoryInfo; @@ -288,11 +292,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDeinitialiseDevice(IMG_UINT32 ui32DevIndex); #if !defined(USE_CODE) -IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PollForValueKM(volatile IMG_UINT32* pui32LinMemAddr, - IMG_UINT32 ui32Value, - IMG_UINT32 ui32Mask, - IMG_UINT32 ui32Waitus, - IMG_UINT32 ui32Tries); +IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PollForValueKM(volatile IMG_UINT32* pui32LinMemAddr, + IMG_UINT32 ui32Value, + IMG_UINT32 ui32Mask, + IMG_UINT32 ui32Timeoutus, + IMG_UINT32 ui32PollPeriodus, + IMG_BOOL bAllowPreemption); #endif diff --git a/drivers/gpu/pvr/deviceclass.c b/drivers/gpu/pvr/deviceclass.c index 471ce0c..d011bac 100644 --- a/drivers/gpu/pvr/deviceclass.c +++ b/drivers/gpu/pvr/deviceclass.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -68,6 +68,10 @@ typedef struct PVRSRV_DC_SWAPCHAIN_TAG PVRSRV_DC_BUFFER *psLastFlipBuffer; IMG_UINT32 ui32MinSwapInterval; IMG_UINT32 ui32MaxSwapInterval; +#if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) + PVRSRV_KERNEL_SYNC_INFO **ppsLastSyncInfos; + IMG_UINT32 ui32LastNumSyncInfos; +#endif struct PVRSRV_DISPLAYCLASS_INFO_TAG *psDCInfo; struct PVRSRV_DC_SWAPCHAIN_TAG *psNext; } PVRSRV_DC_SWAPCHAIN; @@ -258,7 +262,7 @@ PVRSRV_ERROR PVRSRVRegisterDCDeviceKM (PVRSRV_DC_SRV2DISP_KMJTABLE *psFuncTable, *psDCInfo->psFuncTable = *psFuncTable; - if(OSAllocMem( PVRSRV_OS_PAGEABLE_HEAP, + if(OSAllocMem( PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), (IMG_VOID **)&psDeviceNode, IMG_NULL, "Device Node") != PVRSRV_OK) @@ -420,7 +424,7 @@ PVRSRV_ERROR PVRSRVRegisterBCDeviceKM (PVRSRV_BC_SRV2BUFFER_KMJTABLE *psFuncTabl *psBCInfo->psFuncTable = *psFuncTable; - if(OSAllocMem( PVRSRV_OS_PAGEABLE_HEAP, + if(OSAllocMem( PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_DEVICE_NODE), (IMG_VOID **)&psDeviceNode, IMG_NULL, "Device Node") != PVRSRV_OK) @@ -540,23 +544,36 @@ PVRSRV_ERROR PVRSRVCloseDCDeviceKM (IMG_HANDLE hDeviceKM, psDCPerContextInfo = (PVRSRV_DISPLAYCLASS_PERCONTEXT_INFO *)hDeviceKM; - eError = ResManFreeResByPtr(psDCPerContextInfo->hResItem); + eError = ResManFreeResByPtr(psDCPerContextInfo->hResItem, CLEANUP_WITH_POLL); return eError; } -static PVRSRV_ERROR CloseDCDeviceCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +static PVRSRV_ERROR CloseDCDeviceCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_DISPLAYCLASS_PERCONTEXT_INFO *psDCPerContextInfo; PVRSRV_DISPLAYCLASS_INFO *psDCInfo; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); psDCPerContextInfo = (PVRSRV_DISPLAYCLASS_PERCONTEXT_INFO *)pvParam; psDCInfo = psDCPerContextInfo->psDCInfo; + if(psDCInfo->sSystemBuffer.sDeviceClassBuffer.ui32MemMapRefCount != 0) + { + PVR_DPF((PVR_DBG_MESSAGE,"CloseDCDeviceCallBack: system buffer (0x%p) still mapped (refcount = %d)", + &psDCInfo->sSystemBuffer.sDeviceClassBuffer, + psDCInfo->sSystemBuffer.sDeviceClassBuffer.ui32MemMapRefCount)); +#if 0 + + return PVRSRV_ERROR_STILL_MAPPED; +#endif + } + psDCInfo->ui32RefCount--; if(psDCInfo->ui32RefCount == 0) { @@ -658,6 +675,7 @@ PVRSRV_ERROR PVRSRVOpenDCDeviceKM (PVRSRV_PER_PROCESS_DATA *psPerProc, } psDCInfo->sSystemBuffer.sDeviceClassBuffer.psKernelSyncInfo->ui32RefCount++; + psDCInfo->sSystemBuffer.sDeviceClassBuffer.ui32MemMapRefCount = 0; } psDCPerContextInfo->psDCInfo = psDCInfo; @@ -800,7 +818,7 @@ PVRSRV_ERROR PVRSRVDestroyDCSwapChainKM(IMG_HANDLE hSwapChainRef) psSwapChainRef = hSwapChainRef; - eError = ResManFreeResByPtr(psSwapChainRef->hResItem); + eError = ResManFreeResByPtr(psSwapChainRef->hResItem, CLEANUP_WITH_POLL); return eError; } @@ -812,7 +830,6 @@ static PVRSRV_ERROR DestroyDCSwapChain(PVRSRV_DC_SWAPCHAIN *psSwapChain) PVRSRV_DISPLAYCLASS_INFO *psDCInfo = psSwapChain->psDCInfo; IMG_UINT32 i; - if( psDCInfo->psDCSwapChainShared ) { @@ -862,6 +879,14 @@ static PVRSRV_ERROR DestroyDCSwapChain(PVRSRV_DC_SWAPCHAIN *psSwapChain) } } +#if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) + if (psSwapChain->ppsLastSyncInfos) + { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * psSwapChain->ui32LastNumSyncInfos, + psSwapChain->ppsLastSyncInfos, IMG_NULL); + } +#endif + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_DC_SWAPCHAIN), psSwapChain, IMG_NULL); @@ -869,12 +894,30 @@ static PVRSRV_ERROR DestroyDCSwapChain(PVRSRV_DC_SWAPCHAIN *psSwapChain) } -static PVRSRV_ERROR DestroyDCSwapChainRefCallBack(IMG_PVOID pvParam, IMG_UINT32 ui32Param) +static PVRSRV_ERROR DestroyDCSwapChainRefCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_DC_SWAPCHAIN_REF *psSwapChainRef = (PVRSRV_DC_SWAPCHAIN_REF *) pvParam; PVRSRV_ERROR eError = PVRSRV_OK; + IMG_UINT32 i; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); + + for (i = 0; i < psSwapChainRef->psSwapChain->ui32BufferCount; i++) + { + if (psSwapChainRef->psSwapChain->asBuffer[i].sDeviceClassBuffer.ui32MemMapRefCount != 0) + { + PVR_DPF((PVR_DBG_ERROR, "DestroyDCSwapChainRefCallBack: swapchain (0x%p) still mapped (ui32MemMapRefCount = %d)", + &psSwapChainRef->psSwapChain->asBuffer[i].sDeviceClassBuffer, + psSwapChainRef->psSwapChain->asBuffer[i].sDeviceClassBuffer.ui32MemMapRefCount)); +#if 0 + + return PVRSRV_ERROR_STILL_MAPPED; +#endif + } + } if(--psSwapChainRef->psSwapChain->ui32RefCount == 0) { @@ -1256,7 +1299,8 @@ IMG_EXPORT PVRSRV_ERROR PVRSRVGetDCBuffersKM(IMG_HANDLE hDeviceKM, IMG_HANDLE hSwapChainRef, IMG_UINT32 *pui32BufferCount, - IMG_HANDLE *phBuffer) + IMG_HANDLE *phBuffer, + IMG_SYS_PHYADDR *psPhyAddr) { PVRSRV_DISPLAYCLASS_INFO *psDCInfo; PVRSRV_DC_SWAPCHAIN *psSwapChain; @@ -1264,7 +1308,7 @@ PVRSRV_ERROR PVRSRVGetDCBuffersKM(IMG_HANDLE hDeviceKM, PVRSRV_ERROR eError; IMG_UINT32 i; - if(!hDeviceKM || !hSwapChainRef || !phBuffer) + if(!hDeviceKM || !hSwapChainRef || !phBuffer || !psPhyAddr) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetDCBuffersKM: Invalid parameters")); return PVRSRV_ERROR_INVALID_PARAMS; @@ -1290,6 +1334,32 @@ PVRSRV_ERROR PVRSRVGetDCBuffersKM(IMG_HANDLE hDeviceKM, phBuffer[i] = (IMG_HANDLE)&psSwapChain->asBuffer[i]; } +#if defined(SUPPORT_GET_DC_BUFFERS_SYS_PHYADDRS) + for(i = 0; i < *pui32BufferCount; i++) + { + IMG_UINT32 ui32ByteSize, ui32TilingStride; + IMG_SYS_PHYADDR *pPhyAddr; + IMG_BOOL bIsContiguous; + IMG_HANDLE hOSMapInfo; + IMG_VOID *pvVAddr; + + eError = psDCInfo->psFuncTable->pfnGetBufferAddr(psDCInfo->hExtDevice, + ahExtBuffer[i], + &pPhyAddr, + &ui32ByteSize, + &pvVAddr, + &hOSMapInfo, + &bIsContiguous, + &ui32TilingStride); + if(eError != PVRSRV_OK) + { + break; + } + + psPhyAddr[i] = *pPhyAddr; + } +#endif + return eError; } @@ -1313,6 +1383,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, IMG_UINT32 ui32NumSrcSyncs = 1; PVRSRV_KERNEL_SYNC_INFO *apsSrcSync[2]; PVRSRV_COMMAND *psCommand; + SYS_DATA *psSysData; if(!hDeviceKM || !hBuffer || !psClipRect) { @@ -1320,14 +1391,6 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, return PVRSRV_ERROR_INVALID_PARAMS; } -#if defined(SUPPORT_LMA) - eError = PVRSRVPowerLock(KERNEL_ID, IMG_FALSE); - if(eError != PVRSRV_OK) - { - return eError; - } -#endif - psBuffer = (PVRSRV_DC_BUFFER*)hBuffer; psDCInfo = DCDeviceHandleToDCInfo(hDeviceKM); @@ -1382,7 +1445,9 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, IMG_NULL, ui32NumSrcSyncs, apsSrcSync, - sizeof(DISPLAYCLASS_FLIP_COMMAND) + (sizeof(IMG_RECT) * ui32ClipRectCount)); + sizeof(DISPLAYCLASS_FLIP_COMMAND) + (sizeof(IMG_RECT) * ui32ClipRectCount), + IMG_NULL, + IMG_NULL); if(eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBufferKM: Failed to get space in queue")); @@ -1427,41 +1492,298 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, + SysAcquireData(&psSysData); + eError = OSScheduleMISR(psSysData); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBufferKM: Failed to schedule MISR")); + goto Exit; + } + + psBuffer->psSwapChain->psLastFlipBuffer = psBuffer; +Exit: + if(eError == PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE) + { + eError = PVRSRV_ERROR_RETRY; + } + return eError; +} + +typedef struct _CALLBACK_DATA_ +{ + IMG_PVOID pvPrivData; + IMG_UINT32 ui32PrivDataLength; + IMG_PVOID ppvMemInfos; + IMG_UINT32 ui32NumMemInfos; +} CALLBACK_DATA; - - LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) +static IMG_VOID FreePrivateData(IMG_HANDLE hCallbackData) +{ + CALLBACK_DATA *psCallbackData = hCallbackData; + + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psCallbackData->ui32PrivDataLength, + psCallbackData->pvPrivData, IMG_NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_VOID *) * psCallbackData->ui32NumMemInfos, + psCallbackData->ppvMemInfos, IMG_NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(CALLBACK_DATA), hCallbackData, IMG_NULL); +} + +IMG_EXPORT +PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, + IMG_HANDLE hSwapChain, + IMG_UINT32 ui32SwapInterval, + PVRSRV_KERNEL_MEM_INFO **ppsMemInfos, + PVRSRV_KERNEL_SYNC_INFO **ppsSyncInfos, + IMG_UINT32 ui32NumMemSyncInfos, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength) +{ + PVRSRV_KERNEL_SYNC_INFO **ppsCompiledSyncInfos; + IMG_UINT32 i, ui32NumCompiledSyncInfos; + DISPLAYCLASS_FLIP_COMMAND2 *psFlipCmd; + PVRSRV_DISPLAYCLASS_INFO *psDCInfo; + PVRSRV_DC_SWAPCHAIN *psSwapChain; + PVRSRV_ERROR eError = PVRSRV_OK; + CALLBACK_DATA *psCallbackData; + PVRSRV_QUEUE_INFO *psQueue; + PVRSRV_COMMAND *psCommand; + IMG_PVOID *ppvMemInfos; + SYS_DATA *psSysData; + + if(!hDeviceKM || !hSwapChain || !ppsMemInfos || !ppsSyncInfos || ui32NumMemSyncInfos < 1) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Invalid parameters")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psSwapChain = ((PVRSRV_DC_SWAPCHAIN_REF*)hSwapChain)->psSwapChain; + psDCInfo = DCDeviceHandleToDCInfo(hDeviceKM); + + + if(ui32SwapInterval < psSwapChain->ui32MinSwapInterval || + ui32SwapInterval > psSwapChain->ui32MaxSwapInterval) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Invalid swap interval. Requested %u, Allowed range %u-%u", + ui32SwapInterval, psSwapChain->ui32MinSwapInterval, psSwapChain->ui32MaxSwapInterval)); + return PVRSRV_ERROR_INVALID_SWAPINTERVAL; + } + + eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(CALLBACK_DATA), + (IMG_VOID **)&psCallbackData, IMG_NULL, + "PVRSRVSwapToDCBuffer2KM callback data"); + if (eError != PVRSRV_OK) + { + return eError; + } + + psCallbackData->pvPrivData = pvPrivData; + psCallbackData->ui32PrivDataLength = ui32PrivDataLength; + + + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_VOID *) * ui32NumMemSyncInfos, + (IMG_VOID **)&ppvMemInfos, IMG_NULL, + "Swap Command Meminfos") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); + psCallbackData->ppvMemInfos = IMG_NULL; + goto Exit; + } + + for(i = 0; i < ui32NumMemSyncInfos; i++) + { + ppvMemInfos[i] = ppsMemInfos[i]; + } + + psCallbackData->ppvMemInfos = ppvMemInfos; + psCallbackData->ui32NumMemInfos = ui32NumMemSyncInfos; + + + psQueue = psSwapChain->psQueue; + +#if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) + if(psSwapChain->ppsLastSyncInfos) { - if(PVRSRVProcessQueues(KERNEL_ID, IMG_FALSE) != PVRSRV_ERROR_PROCESSING_BLOCKED) + IMG_UINT32 ui32NumUniqueSyncInfos = psSwapChain->ui32LastNumSyncInfos; + IMG_UINT32 j; + + for(j = 0; j < psSwapChain->ui32LastNumSyncInfos; j++) { - goto ProcessedQueues; + for(i = 0; i < ui32NumMemSyncInfos; i++) + { + if(psSwapChain->ppsLastSyncInfos[j] == ppsSyncInfos[i]) + { + psSwapChain->ppsLastSyncInfos[j] = IMG_NULL; + ui32NumUniqueSyncInfos--; + } + } } - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); - } END_LOOP_UNTIL_TIMEOUT(); - PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBufferKM: Failed to process queues")); + ui32NumCompiledSyncInfos = ui32NumMemSyncInfos + ui32NumUniqueSyncInfos; - eError = PVRSRV_ERROR_FAILED_TO_PROCESS_QUEUE; - goto Exit; + + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumCompiledSyncInfos, + (IMG_VOID **)&ppsCompiledSyncInfos, IMG_NULL, + "Compiled syncinfos") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); + goto Exit; + } + + OSMemCopy(ppsCompiledSyncInfos, ppsSyncInfos, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumMemSyncInfos); + for(j = 0, i = ui32NumMemSyncInfos; j < psSwapChain->ui32LastNumSyncInfos; j++) + { + if(psSwapChain->ppsLastSyncInfos[j]) + { + ppsCompiledSyncInfos[i] = psSwapChain->ppsLastSyncInfos[j]; + i++; + } + } + } + else +#endif + { + ppsCompiledSyncInfos = ppsSyncInfos; + ui32NumCompiledSyncInfos = ui32NumMemSyncInfos; + } -ProcessedQueues: - psBuffer->psSwapChain->psLastFlipBuffer = psBuffer; + eError = PVRSRVInsertCommandKM (psQueue, + &psCommand, + psDCInfo->ui32DeviceID, + DC_FLIP_COMMAND, + 0, + IMG_NULL, + ui32NumCompiledSyncInfos, + ppsCompiledSyncInfos, + sizeof(DISPLAYCLASS_FLIP_COMMAND2), + FreePrivateData, + psCallbackData); -Exit: + if (ppsCompiledSyncInfos != ppsSyncInfos) + { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumCompiledSyncInfos, + (IMG_VOID *)ppsCompiledSyncInfos, + IMG_NULL); + } + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to get space in queue")); + goto Exit; + } + + + psFlipCmd = (DISPLAYCLASS_FLIP_COMMAND2*)psCommand->pvData; + + + psFlipCmd->hUnused = IMG_NULL; + + + psFlipCmd->hExtDevice = psDCInfo->hExtDevice; + + + psFlipCmd->hExtSwapChain = psSwapChain->hExtSwapChain; + + + psFlipCmd->ui32SwapInterval = ui32SwapInterval; + + + psFlipCmd->pvPrivData = pvPrivData; + psFlipCmd->ui32PrivDataLength = ui32PrivDataLength; + + psFlipCmd->ppvMemInfos = ppvMemInfos; + psFlipCmd->ui32NumMemInfos = ui32NumMemSyncInfos; + + SysAcquireData(&psSysData); + + + { + if(psSysData->ePendingCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_FLUSH) + { + OSFlushCPUCacheKM(); + } + else if(psSysData->ePendingCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_CLEAN) + { + OSCleanCPUCacheKM(); + } + + psSysData->ePendingCacheOpType = PVRSRV_MISC_INFO_CPUCACHEOP_NONE; + } + + + eError = PVRSRVSubmitCommandKM (psQueue, psCommand); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to submit command")); + goto Exit; + } + + + psCallbackData = IMG_NULL; + + + + eError = OSScheduleMISR(psSysData); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to schedule MISR")); + goto Exit; + } + +#if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) + + if (psSwapChain->ui32LastNumSyncInfos < ui32NumMemSyncInfos) + { + if (psSwapChain->ppsLastSyncInfos) + { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * psSwapChain->ui32LastNumSyncInfos, + psSwapChain->ppsLastSyncInfos, IMG_NULL); + } + + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumMemSyncInfos, + (IMG_VOID **)&psSwapChain->ppsLastSyncInfos, IMG_NULL, + "Last syncinfos") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); + goto Exit; + } + } + + psSwapChain->ui32LastNumSyncInfos = ui32NumMemSyncInfos; + + for(i = 0; i < ui32NumMemSyncInfos; i++) + { + psSwapChain->ppsLastSyncInfos[i] = ppsSyncInfos[i]; + } +#endif + +Exit: + if (psCallbackData) + { + if(psCallbackData->ppvMemInfos) + { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_VOID *) * psCallbackData->ui32NumMemInfos, + psCallbackData->ppvMemInfos, IMG_NULL); + } + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(CALLBACK_DATA), psCallbackData, IMG_NULL); + } if(eError == PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE) { eError = PVRSRV_ERROR_RETRY; } -#if defined(SUPPORT_LMA) - PVRSRVPowerUnlock(KERNEL_ID); -#endif return eError; } @@ -1481,6 +1803,7 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, PVRSRV_COMMAND *psCommand; IMG_BOOL bAddReferenceToLast = IMG_TRUE; IMG_UINT16 ui16SwapCommandID = DC_FLIP_COMMAND; + SYS_DATA *psSysData; if(!hDeviceKM || !hSwapChainRef) { @@ -1488,14 +1811,6 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, return PVRSRV_ERROR_INVALID_PARAMS; } -#if defined(SUPPORT_LMA) - eError = PVRSRVPowerLock(KERNEL_ID, IMG_FALSE); - if(eError != PVRSRV_OK) - { - return eError; - } -#endif - psDCInfo = DCDeviceHandleToDCInfo(hDeviceKM); psSwapChainRef = (PVRSRV_DC_SWAPCHAIN_REF*)hSwapChainRef; psSwapChain = psSwapChainRef->psSwapChain; @@ -1545,7 +1860,9 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, IMG_NULL, ui32NumSrcSyncs, apsSrcSync, - sizeof(DISPLAYCLASS_FLIP_COMMAND)); + sizeof(DISPLAYCLASS_FLIP_COMMAND), + IMG_NULL, + IMG_NULL); if(eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCSystemKM: Failed to get space in queue")); @@ -1581,28 +1898,15 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, } + SysAcquireData(&psSysData); + eError = OSScheduleMISR(psSysData); - - - - - - - LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) + if (eError != PVRSRV_OK) { - if(PVRSRVProcessQueues(KERNEL_ID, IMG_FALSE) != PVRSRV_ERROR_PROCESSING_BLOCKED) - { - goto ProcessedQueues; - } - - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); - } END_LOOP_UNTIL_TIMEOUT(); - - PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCSystemKM: Failed to process queues")); - eError = PVRSRV_ERROR_FAILED_TO_PROCESS_QUEUE; - goto Exit; + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCSystemKM: Failed to schedule MISR")); + goto Exit; + } -ProcessedQueues: psSwapChain->psLastFlipBuffer = &psDCInfo->sSystemBuffer; @@ -1615,9 +1919,6 @@ Exit: eError = PVRSRV_ERROR_RETRY; } -#if defined(SUPPORT_LMA) - PVRSRVPowerUnlock(KERNEL_ID); -#endif return eError; } @@ -1725,28 +2026,42 @@ PVRSRV_ERROR PVRSRVCloseBCDeviceKM (IMG_HANDLE hDeviceKM, psBCPerContextInfo = (PVRSRV_BUFFERCLASS_PERCONTEXT_INFO *)hDeviceKM; - eError = ResManFreeResByPtr(psBCPerContextInfo->hResItem); + eError = ResManFreeResByPtr(psBCPerContextInfo->hResItem, CLEANUP_WITH_POLL); return eError; } -static PVRSRV_ERROR CloseBCDeviceCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +static PVRSRV_ERROR CloseBCDeviceCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_BUFFERCLASS_PERCONTEXT_INFO *psBCPerContextInfo; PVRSRV_BUFFERCLASS_INFO *psBCInfo; + IMG_UINT32 i; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); psBCPerContextInfo = (PVRSRV_BUFFERCLASS_PERCONTEXT_INFO *)pvParam; + psBCInfo = psBCPerContextInfo->psBCInfo; + for (i = 0; i < psBCInfo->ui32BufferCount; i++) + { + if (psBCInfo->psBuffer[i].sDeviceClassBuffer.ui32MemMapRefCount != 0) + { + PVR_DPF((PVR_DBG_ERROR, "CloseBCDeviceCallBack: buffer %d (0x%p) still mapped (ui32MemMapRefCount = %d)", + i, + &psBCInfo->psBuffer[i].sDeviceClassBuffer, + psBCInfo->psBuffer[i].sDeviceClassBuffer.ui32MemMapRefCount)); + return PVRSRV_ERROR_STILL_MAPPED; + } + } + psBCInfo->ui32RefCount--; if(psBCInfo->ui32RefCount == 0) { - IMG_UINT32 i; - psBCInfo->psFuncTable->pfnCloseBCDevice(psBCInfo->ui32DeviceID, psBCInfo->hExtDevice); @@ -1900,6 +2215,7 @@ PVRSRV_ERROR PVRSRVOpenBCDeviceKM (PVRSRV_PER_PROCESS_DATA *psPerProc, psBCInfo->psBuffer[i].sDeviceClassBuffer.pfnGetBufferAddr = psBCInfo->psFuncTable->pfnGetBufferAddr; psBCInfo->psBuffer[i].sDeviceClassBuffer.hDevMemContext = psBCInfo->hDevMemContext; psBCInfo->psBuffer[i].sDeviceClassBuffer.hExtDevice = psBCInfo->hExtDevice; + psBCInfo->psBuffer[i].sDeviceClassBuffer.ui32MemMapRefCount = 0; } } diff --git a/drivers/gpu/pvr/deviceid.h b/drivers/gpu/pvr/deviceid.h index b6fe921..9a7bdb3 100644 --- a/drivers/gpu/pvr/deviceid.h +++ b/drivers/gpu/pvr/deviceid.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/devicemem.c b/drivers/gpu/pvr/devicemem.c index e607e58..03b28eb 100644 --- a/drivers/gpu/pvr/devicemem.c +++ b/drivers/gpu/pvr/devicemem.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -30,12 +30,15 @@ #include "buffer_manager.h" #include "pdump_km.h" #include "pvr_bridge_km.h" +#include "osfunc.h" static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, IMG_HANDLE hDevMemHeap, IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_SIZE_T ui32Alignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, PVRSRV_KERNEL_MEM_INFO **ppsMemInfo); typedef struct _RESMAN_MAP_DEVICE_MEM_DATA_ @@ -52,12 +55,18 @@ typedef struct _PVRSRV_DC_MAPINFO_ PVRSRV_DEVICE_NODE *psDeviceNode; IMG_UINT32 ui32RangeIndex; IMG_UINT32 ui32TilingStride; + PVRSRV_DEVICECLASS_BUFFER *psDeviceClassBuffer; } PVRSRV_DC_MAPINFO; +static IMG_UINT32 g_ui32SyncUID = 0; IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapsKM(IMG_HANDLE hDevCookie, +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM *psHeapInfo) +#else PVRSRV_HEAP_INFO *psHeapInfo) +#endif { PVRSRV_DEVICE_NODE *psDeviceNode; IMG_UINT32 ui32HeapCount; @@ -89,6 +98,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapsKM(IMG_HANDLE hDevCookie, psHeapInfo[i].sDevVAddrBase = psDeviceMemoryHeap[i].sDevVAddrBase; psHeapInfo[i].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[i].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; + + psHeapInfo[i].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; } for(; i < PVRSRV_MAX_CLIENT_HEAPS; i++) @@ -105,7 +116,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE *phDevMemContext, IMG_UINT32 *pui32ClientHeapCount, +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM *psHeapInfo, +#else PVRSRV_HEAP_INFO *psHeapInfo, +#endif IMG_BOOL *pbCreated, IMG_BOOL *pbShared) { @@ -117,7 +132,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook IMG_DEV_PHYADDR sPDDevPAddr; IMG_UINT32 i; -#if !defined(PVR_SECURE_HANDLES) +#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) PVR_UNREFERENCED_PARAMETER(pbShared); #endif @@ -164,7 +179,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook psHeapInfo[ui32ClientHeapCount].sDevVAddrBase = psDeviceMemoryHeap[i].sDevVAddrBase; psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; -#if defined(PVR_SECURE_HANDLES) + #if defined(SUPPORT_MEMORY_TILING) + psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; + #else + psHeapInfo[ui32ClientHeapCount].ui32XTileStride = 0; + #endif + +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) pbShared[ui32ClientHeapCount] = IMG_TRUE; #endif ui32ClientHeapCount++; @@ -172,8 +193,20 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook } case DEVICE_MEMORY_HEAP_PERCONTEXT: { - hDevMemHeap = BM_CreateHeap(hDevMemContext, - &psDeviceMemoryHeap[i]); + if (psDeviceMemoryHeap[i].ui32HeapSize > 0) + { + hDevMemHeap = BM_CreateHeap(hDevMemContext, + &psDeviceMemoryHeap[i]); + if (hDevMemHeap == IMG_NULL) + { + BM_DestroyContext(hDevMemContext, IMG_NULL); + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + } + else + { + hDevMemHeap = IMG_NULL; + } psHeapInfo[ui32ClientHeapCount].ui32HeapID = psDeviceMemoryHeap[i].ui32HeapID; @@ -181,7 +214,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook psHeapInfo[ui32ClientHeapCount].sDevVAddrBase = psDeviceMemoryHeap[i].sDevVAddrBase; psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; -#if defined(PVR_SECURE_HANDLES) + #if defined(SUPPORT_MEMORY_TILING) + psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; + #else + psHeapInfo[ui32ClientHeapCount].ui32XTileStride = 0; + #endif +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) pbShared[ui32ClientHeapCount] = IMG_FALSE; #endif @@ -215,7 +253,11 @@ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie, IMG_HANDLE hDevMemContext, IMG_UINT32 *pui32ClientHeapCount, +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM *psHeapInfo, +#else PVRSRV_HEAP_INFO *psHeapInfo, +#endif IMG_BOOL *pbShared) { PVRSRV_DEVICE_NODE *psDeviceNode; @@ -224,7 +266,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie IMG_HANDLE hDevMemHeap; IMG_UINT32 i; -#if !defined(PVR_SECURE_HANDLES) +#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) PVR_UNREFERENCED_PARAMETER(pbShared); #endif @@ -259,7 +301,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie psHeapInfo[ui32ClientHeapCount].sDevVAddrBase = psDeviceMemoryHeap[i].sDevVAddrBase; psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; -#if defined(PVR_SECURE_HANDLES) + psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) pbShared[ui32ClientHeapCount] = IMG_TRUE; #endif ui32ClientHeapCount++; @@ -267,8 +310,20 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie } case DEVICE_MEMORY_HEAP_PERCONTEXT: { - hDevMemHeap = BM_CreateHeap(hDevMemContext, - &psDeviceMemoryHeap[i]); + if (psDeviceMemoryHeap[i].ui32HeapSize > 0) + { + hDevMemHeap = BM_CreateHeap(hDevMemContext, + &psDeviceMemoryHeap[i]); + + if (hDevMemHeap == IMG_NULL) + { + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + } + else + { + hDevMemHeap = IMG_NULL; + } psHeapInfo[ui32ClientHeapCount].ui32HeapID = psDeviceMemoryHeap[i].ui32HeapID; @@ -276,7 +331,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie psHeapInfo[ui32ClientHeapCount].sDevVAddrBase = psDeviceMemoryHeap[i].sDevVAddrBase; psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; -#if defined(PVR_SECURE_HANDLES) + psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) pbShared[ui32ClientHeapCount] = IMG_FALSE; #endif @@ -294,11 +350,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, - IMG_HANDLE hDevMemHeap, - IMG_UINT32 ui32Flags, - IMG_SIZE_T ui32Size, - IMG_SIZE_T ui32Alignment, - PVRSRV_KERNEL_MEM_INFO **ppsMemInfo) + IMG_HANDLE hDevMemHeap, + IMG_UINT32 ui32Flags, + IMG_SIZE_T ui32Size, + IMG_SIZE_T ui32Alignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, + PVRSRV_KERNEL_MEM_INFO **ppsMemInfo) { PVRSRV_KERNEL_MEM_INFO *psMemInfo; BM_HANDLE hBuffer; @@ -331,6 +389,8 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, ui32Size, &psMemInfo->ui32Flags, IMG_CAST_TO_DEVVADDR_UINT(ui32Alignment), + pvPrivData, + ui32PrivDataLength, &hBuffer); if (!bBMError) @@ -354,7 +414,7 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, psMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psMemInfo->ui32AllocSize = ui32Size; + psMemInfo->uAllocSize = ui32Size; psMemInfo->pvSysBackupBuffer = IMG_NULL; @@ -366,7 +426,7 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, return (PVRSRV_OK); } -static PVRSRV_ERROR FreeDeviceMem2(PVRSRV_KERNEL_MEM_INFO *psMemInfo, IMG_BOOL bFromAllocator) +static PVRSRV_ERROR FreeDeviceMem2(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PVRSRV_FREE_CALLBACK_ORIGIN eCallbackOrigin) { BM_HANDLE hBuffer; @@ -378,16 +438,24 @@ static PVRSRV_ERROR FreeDeviceMem2(PVRSRV_KERNEL_MEM_INFO *psMemInfo, IMG_BOOL b hBuffer = psMemInfo->sMemBlk.hBuffer; - if (bFromAllocator) - BM_Free(hBuffer, psMemInfo->ui32Flags); - else - BM_FreeExport(hBuffer, psMemInfo->ui32Flags); + switch(eCallbackOrigin) + { + case PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR: + BM_Free(hBuffer, psMemInfo->ui32Flags); + break; + case PVRSRV_FREE_CALLBACK_ORIGIN_IMPORTER: + BM_FreeExport(hBuffer, psMemInfo->ui32Flags); + break; + default: + break; + } - if ((psMemInfo->pvSysBackupBuffer) && bFromAllocator) + if (psMemInfo->pvSysBackupBuffer && + eCallbackOrigin == PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psMemInfo->ui32AllocSize, psMemInfo->pvSysBackupBuffer, IMG_NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psMemInfo->uAllocSize, psMemInfo->pvSysBackupBuffer, IMG_NULL); psMemInfo->pvSysBackupBuffer = IMG_NULL; } @@ -415,7 +483,7 @@ static PVRSRV_ERROR FreeDeviceMem(PVRSRV_KERNEL_MEM_INFO *psMemInfo) if(psMemInfo->pvSysBackupBuffer) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psMemInfo->ui32AllocSize, psMemInfo->pvSysBackupBuffer, IMG_NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, psMemInfo->uAllocSize, psMemInfo->pvSysBackupBuffer, IMG_NULL); psMemInfo->pvSysBackupBuffer = IMG_NULL; } @@ -465,6 +533,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, PVRSRV_MEM_CACHE_CONSISTENT, sizeof(PVRSRV_SYNC_DATA), sizeof(IMG_UINT32), + IMG_NULL, + 0, &psKernelSyncInfo->psSyncDataMemInfoKM); if (eError != PVRSRV_OK) @@ -484,6 +554,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, psSyncData->ui32WriteOpsComplete = 0; psSyncData->ui32ReadOpsPending = 0; psSyncData->ui32ReadOpsComplete = 0; + psSyncData->ui32ReadOps2Pending = 0; + psSyncData->ui32ReadOps2Complete = 0; psSyncData->ui32LastOpDumpVal = 0; psSyncData->ui32LastReadOpDumpVal = 0; @@ -492,13 +564,15 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, PDUMPMEM(psKernelSyncInfo->psSyncDataMemInfoKM->pvLinAddrKM, psKernelSyncInfo->psSyncDataMemInfoKM, 0, - psKernelSyncInfo->psSyncDataMemInfoKM->ui32AllocSize, + (IMG_UINT32)psKernelSyncInfo->psSyncDataMemInfoKM->uAllocSize, PDUMP_FLAGS_CONTINUOUS, MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); #endif psKernelSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr = psKernelSyncInfo->psSyncDataMemInfoKM->sDevVAddr.uiAddr + offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete); psKernelSyncInfo->sReadOpsCompleteDevVAddr.uiAddr = psKernelSyncInfo->psSyncDataMemInfoKM->sDevVAddr.uiAddr + offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete); + psKernelSyncInfo->sReadOps2CompleteDevVAddr.uiAddr = psKernelSyncInfo->psSyncDataMemInfoKM->sDevVAddr.uiAddr + offsetof(PVRSRV_SYNC_DATA, ui32ReadOps2Complete); + psKernelSyncInfo->ui32UID = g_ui32SyncUID++; psKernelSyncInfo->psSyncDataMemInfoKM->psKernelSyncInfo = IMG_NULL; @@ -514,14 +588,14 @@ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) { PVRSRV_ERROR eError; - + if (psKernelSyncInfo->ui32RefCount != 0) { PVR_DPF((PVR_DBG_ERROR, "oops: sync info ref count not zero at destruction")); return PVRSRV_ERROR_OUT_OF_MEMORY; } - + eError = FreeDeviceMem(psKernelSyncInfo->psSyncDataMemInfoKM); (IMG_VOID)OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_SYNC_INFO), psKernelSyncInfo, IMG_NULL); @@ -546,47 +620,167 @@ static IMG_VOID freeWrapped(PVRSRV_KERNEL_MEM_INFO *psMemInfo) } } -static PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, - IMG_UINT32 ui32Param, - IMG_BOOL bFromAllocator) -{ - PVRSRV_ERROR eError = PVRSRV_OK; - - PVR_UNREFERENCED_PARAMETER(ui32Param); - - psMemInfo->ui32RefCount--; +#if defined (PVRSRV_FLUSH_KERNEL_OPS_LAST_ONLY) +static +PVRSRV_ERROR _PollUntilAtLeast(volatile IMG_UINT32* pui32WatchedValue, + IMG_UINT32 ui32MinimumValue, + IMG_UINT32 ui32Waitus, + IMG_UINT32 ui32Tries) +{ + PVRSRV_ERROR eError; + IMG_INT32 iDiff; - - if((psMemInfo->ui32Flags & PVRSRV_MEM_EXPORTED) && (bFromAllocator == IMG_TRUE)) + for(;;) { - IMG_HANDLE hMemInfo = IMG_NULL; + SYS_DATA *psSysData = SysAcquireDataNoCheck(); + iDiff = *pui32WatchedValue - ui32MinimumValue; - - eError = PVRSRVFindHandle(KERNEL_HANDLE_BASE, - &hMemInfo, - psMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if(eError != PVRSRV_OK) + if (iDiff >= 0) { - PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: can't find exported meminfo in the global handle list")); - return eError; + eError = PVRSRV_OK; + break; } + if(!ui32Tries) + { + eError = PVRSRV_ERROR_TIMEOUT_POLLING_FOR_VALUE; + break; + } + + ui32Tries--; + - eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE, - hMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - if(eError != PVRSRV_OK) + if (psSysData->psGlobalEventObject) { - PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: PVRSRVReleaseHandle failed for exported meminfo")); - return eError; + IMG_HANDLE hOSEventKM; + if(psSysData->psGlobalEventObject) + { + eError = OSEventObjectOpenKM(psSysData->psGlobalEventObject, &hOSEventKM); + if (eError |= PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, + "_PollUntilAtLeast: OSEventObjectOpen failed")); + goto Exit; + } + eError = OSEventObjectWaitKM(hOSEventKM); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, + "_PollUntilAtLeast: PVRSRVEventObjectWait failed")); + goto Exit; + } + eError = OSEventObjectCloseKM(psSysData->psGlobalEventObject, hOSEventKM); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, + "_PollUntilAtLeast: OSEventObjectClose failed")); + } + } } } +Exit: + return eError; +} + +static PVRSRV_ERROR FlushKernelOps(PVRSRV_SYNC_DATA *psSyncData) +{ + PVRSRV_ERROR eError; + + if(!psSyncData) + { + PVR_DPF((PVR_DBG_ERROR, "FlushKernelOps: invalid psSyncData")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + + + + + + + + + + eError = _PollUntilAtLeast(&psSyncData->ui32ReadOpsComplete, + psSyncData->ui32ReadOpsPending, + MAX_HW_TIME_US/WAIT_TRY_COUNT, + WAIT_TRY_COUNT); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "FlushClientOps: Read ops pending timeout")); + PVR_DBG_BREAK; + return eError; + } + + eError = _PollUntilAtLeast(&psSyncData->ui32WriteOpsComplete, + psSyncData->ui32WriteOpsPending, + MAX_HW_TIME_US/WAIT_TRY_COUNT, + WAIT_TRY_COUNT); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "FlushClientOps: Write ops pending timeout")); + PVR_DBG_BREAK; + } + + return eError; +} +#endif + +IMG_EXPORT +PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, + IMG_UINT32 ui32Param, + PVRSRV_FREE_CALLBACK_ORIGIN eCallbackOrigin) +{ + PVRSRV_ERROR eError = PVRSRV_OK; + + PVR_UNREFERENCED_PARAMETER(ui32Param); + + + psMemInfo->ui32RefCount--; if (psMemInfo->ui32RefCount == 0) { + if((psMemInfo->ui32Flags & PVRSRV_MEM_EXPORTED) != 0) + { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMemInfo = 0; +#else + IMG_HANDLE hMemInfo = IMG_NULL; +#endif + + + eError = PVRSRVFindHandle(KERNEL_HANDLE_BASE, + &hMemInfo, + psMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: can't find exported meminfo in the global handle list")); + return eError; + } + + + eError = PVRSRVReleaseHandle(KERNEL_HANDLE_BASE, + hMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "FreeMemCallBackCommon: PVRSRVReleaseHandle failed for exported meminfo")); + return eError; + } + } + +#if defined (PVRSRV_FLUSH_KERNEL_OPS_LAST_ONLY) + if (psMemInfo->psKernelSyncInfo) + { + if (psMemInfo->psKernelSyncInfo->ui32RefCount == 1) + { + FlushKernelOps(psMemInfo->psKernelSyncInfo->psSyncData); + } + } +#endif switch(psMemInfo->memType) { @@ -611,18 +805,24 @@ static PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, } - - eError = FreeDeviceMem2(psMemInfo, bFromAllocator); + if (eError == PVRSRV_OK) + { + eError = FreeDeviceMem2(psMemInfo, eCallbackOrigin); + } return eError; } -static PVRSRV_ERROR FreeDeviceMemCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +static PVRSRV_ERROR FreeDeviceMemCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_KERNEL_MEM_INFO *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)pvParam; + + PVR_UNREFERENCED_PARAMETER(bDummy); - return FreeMemCallBackCommon(psMemInfo, ui32Param, IMG_TRUE); + return FreeMemCallBackCommon(psMemInfo, ui32Param, + PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR); } @@ -641,12 +841,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE hDevCookie, if (psMemInfo->sMemBlk.hResItem != IMG_NULL) { - eError = ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem); + eError = ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL); } else { - eError = FreeDeviceMemCallBack(psMemInfo, 0); + eError = FreeDeviceMemCallBack(psMemInfo, 0, CLEANUP_WITH_POLL); } return eError; @@ -654,13 +854,15 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE hDevCookie, IMG_EXPORT -PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, - PVRSRV_PER_PROCESS_DATA *psPerProc, - IMG_HANDLE hDevMemHeap, - IMG_UINT32 ui32Flags, - IMG_SIZE_T ui32Size, - IMG_SIZE_T ui32Alignment, - PVRSRV_KERNEL_MEM_INFO **ppsMemInfo) +PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, + PVRSRV_PER_PROCESS_DATA *psPerProc, + IMG_HANDLE hDevMemHeap, + IMG_UINT32 ui32Flags, + IMG_SIZE_T ui32Size, + IMG_SIZE_T ui32Alignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, + PVRSRV_KERNEL_MEM_INFO **ppsMemInfo) { PVRSRV_KERNEL_MEM_INFO *psMemInfo; PVRSRV_ERROR eError; @@ -689,6 +891,8 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, ui32Flags, ui32Size, ui32Alignment, + pvPrivData, + ui32PrivDataLength, &psMemInfo); if (eError != PVRSRV_OK) @@ -804,16 +1008,20 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnwrapExtMemoryKM (PVRSRV_KERNEL_MEM_INFO *psMem return PVRSRV_ERROR_INVALID_PARAMS; } - return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem); + return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL); } -static PVRSRV_ERROR UnwrapExtMemoryCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +static PVRSRV_ERROR UnwrapExtMemoryCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_KERNEL_MEM_INFO *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)pvParam; + + PVR_UNREFERENCED_PARAMETER(bDummy); - return FreeMemCallBackCommon(psMemInfo, ui32Param, IMG_TRUE); + return FreeMemCallBackCommon(psMemInfo, ui32Param, + PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR); } @@ -821,8 +1029,8 @@ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevMemContext, - IMG_SIZE_T ui32ByteSize, - IMG_SIZE_T ui32PageOffset, + IMG_SIZE_T uByteSize, + IMG_SIZE_T uPageOffset, IMG_BOOL bPhysContig, IMG_SYS_PHYADDR *psExtSysPAddr, IMG_VOID *pvLinAddr, @@ -842,11 +1050,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, IMG_VOID *pvPageAlignedCPUVAddr; IMG_SYS_PHYADDR *psIntSysPAddr = IMG_NULL; IMG_HANDLE hOSWrapMem = IMG_NULL; - DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; IMG_UINT32 i; - IMG_SIZE_T ui32PageCount = 0; - - + IMG_SIZE_T uPageCount = 0; + + psDeviceNode = (PVRSRV_DEVICE_NODE*)hDevCookie; PVR_ASSERT(psDeviceNode != IMG_NULL); @@ -859,15 +1067,15 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, if(pvLinAddr) { - ui32PageOffset = (IMG_UINTPTR_T)pvLinAddr & (ui32HostPageSize - 1); + uPageOffset = (IMG_UINTPTR_T)pvLinAddr & (ui32HostPageSize - 1); - ui32PageCount = HOST_PAGEALIGN(ui32ByteSize + ui32PageOffset) / ui32HostPageSize; - pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)pvLinAddr - ui32PageOffset); + uPageCount = HOST_PAGEALIGN(uByteSize + uPageOffset) / ui32HostPageSize; + pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)pvLinAddr - uPageOffset); if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - ui32PageCount * sizeof(IMG_SYS_PHYADDR), + uPageCount * sizeof(IMG_SYS_PHYADDR), (IMG_VOID **)&psIntSysPAddr, IMG_NULL, "Array of Page Addresses") != PVRSRV_OK) { @@ -876,7 +1084,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, } eError = OSAcquirePhysPageAddr(pvPageAlignedCPUVAddr, - ui32PageCount * ui32HostPageSize, + uPageCount * ui32HostPageSize, psIntSysPAddr, &hOSWrapMem); if(eError != PVRSRV_OK) @@ -897,7 +1105,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, { } - + psDevMemoryInfo = &((BM_CONTEXT*)hDevMemContext)->psDeviceNode->sDevMemoryInfo; psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; @@ -908,7 +1116,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, if(psDeviceMemoryHeap[i].DevMemHeapType == DEVICE_MEMORY_HEAP_PERCONTEXT) { - hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + if (psDeviceMemoryHeap[i].ui32HeapSize > 0) + { + hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + } + else + { + hDevMemHeap = IMG_NULL; + } } else { @@ -941,8 +1156,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, psMemBlock = &(psMemInfo->sMemBlk); bBMError = BM_Wrap(hDevMemHeap, - ui32ByteSize, - ui32PageOffset, + uByteSize, + uPageOffset, bPhysContig, psExtSysPAddr, IMG_NULL, @@ -967,7 +1182,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, psMemInfo->pvLinAddrKM = BM_HandleToCpuVaddr(hBuffer); psMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psMemInfo->ui32AllocSize = ui32ByteSize; + psMemInfo->uAllocSize = uByteSize; @@ -1033,10 +1248,10 @@ ErrorExitPhase2: ErrorExitPhase1: if(psIntSysPAddr) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32PageCount * sizeof(IMG_SYS_PHYADDR), psIntSysPAddr, IMG_NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, uPageCount * sizeof(IMG_SYS_PHYADDR), psIntSysPAddr, IMG_NULL); } - + return eError; } @@ -1049,17 +1264,19 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceMemoryKM (PVRSRV_KERNEL_MEM_INFO *psM return PVRSRV_ERROR_INVALID_PARAMS; } - return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem); + return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL); } -static PVRSRV_ERROR UnmapDeviceMemoryCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +static PVRSRV_ERROR UnmapDeviceMemoryCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_ERROR eError; RESMAN_MAP_DEVICE_MEM_DATA *psMapData = pvParam; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); if(psMapData->psMemInfo->sMemBlk.psIntSysPAddr) { @@ -1067,7 +1284,7 @@ static PVRSRV_ERROR UnmapDeviceMemoryCallBack(IMG_PVOID pvParam, psMapData->psMemInfo->sMemBlk.psIntSysPAddr = IMG_NULL; } - if( psMapData->psMemInfo->psKernelSyncInfo ) + if( psMapData->psMemInfo->psKernelSyncInfo ) { psMapData->psMemInfo->psKernelSyncInfo->ui32RefCount--; if (psMapData->psMemInfo->psKernelSyncInfo->ui32RefCount == 0) @@ -1080,7 +1297,7 @@ static PVRSRV_ERROR UnmapDeviceMemoryCallBack(IMG_PVOID pvParam, } } } - + eError = FreeDeviceMem(psMapData->psMemInfo); if(eError != PVRSRV_OK) { @@ -1089,7 +1306,8 @@ static PVRSRV_ERROR UnmapDeviceMemoryCallBack(IMG_PVOID pvParam, } - eError = FreeMemCallBackCommon(psMapData->psSrcMemInfo, 0, IMG_FALSE); + eError = FreeMemCallBackCommon(psMapData->psSrcMemInfo, 0, + PVRSRV_FREE_CALLBACK_ORIGIN_IMPORTER); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RESMAN_MAP_DEVICE_MEM_DATA), psMapData, IMG_NULL); @@ -1106,7 +1324,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer { PVRSRV_ERROR eError; IMG_UINT32 i; - IMG_SIZE_T ui32PageCount, ui32PageOffset; + IMG_SIZE_T uPageCount, uPageOffset; IMG_SIZE_T ui32HostPageSize = HOST_PAGESIZE(); IMG_SYS_PHYADDR *psSysPAddr = IMG_NULL; IMG_DEV_PHYADDR sDevPAddr; @@ -1130,16 +1348,16 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer *ppsDstMemInfo = IMG_NULL; - ui32PageOffset = psSrcMemInfo->sDevVAddr.uiAddr & (ui32HostPageSize - 1); - ui32PageCount = HOST_PAGEALIGN(psSrcMemInfo->ui32AllocSize + ui32PageOffset) / ui32HostPageSize; - pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)psSrcMemInfo->pvLinAddrKM - ui32PageOffset); + uPageOffset = psSrcMemInfo->sDevVAddr.uiAddr & (ui32HostPageSize - 1); + uPageCount = HOST_PAGEALIGN(psSrcMemInfo->uAllocSize + uPageOffset) / ui32HostPageSize; + pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)psSrcMemInfo->pvLinAddrKM - uPageOffset); if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - ui32PageCount*sizeof(IMG_SYS_PHYADDR), + uPageCount*sizeof(IMG_SYS_PHYADDR), (IMG_VOID **)&psSysPAddr, IMG_NULL, "Array of Page Addresses") != PVRSRV_OK) { @@ -1153,8 +1371,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer psDeviceNode = psBuf->pMapping->pBMHeap->pBMContext->psDeviceNode; - sDevVAddr.uiAddr = psSrcMemInfo->sDevVAddr.uiAddr - IMG_CAST_TO_DEVVADDR_UINT(ui32PageOffset); - for(i=0; i<ui32PageCount; i++) + sDevVAddr.uiAddr = psSrcMemInfo->sDevVAddr.uiAddr - IMG_CAST_TO_DEVVADDR_UINT(uPageOffset); + for(i=0; i<uPageCount; i++) { BM_GetPhysPageAddr(psSrcMemInfo, sDevVAddr, &sDevPAddr); @@ -1176,7 +1394,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer goto ErrorExit; } - if(OSAllocMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_MEM_INFO), (IMG_VOID **)&psMemInfo, IMG_NULL, @@ -1193,8 +1410,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer psMemBlock = &(psMemInfo->sMemBlk); bBMError = BM_Wrap(hDstDevMemHeap, - psSrcMemInfo->ui32AllocSize, - ui32PageOffset, + psSrcMemInfo->uAllocSize, + uPageOffset, IMG_FALSE, psSysPAddr, pvPageAlignedCPUVAddr, @@ -1223,12 +1440,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer psMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psMemInfo->ui32AllocSize = psSrcMemInfo->ui32AllocSize; + psMemInfo->uAllocSize = psSrcMemInfo->uAllocSize; psMemInfo->psKernelSyncInfo = psSrcMemInfo->psKernelSyncInfo; - if( psMemInfo->psKernelSyncInfo ) + if(psMemInfo->psKernelSyncInfo) + { psMemInfo->psKernelSyncInfo->ui32RefCount++; + } @@ -1297,17 +1516,19 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemoryKM(PVRSRV_KERNEL_MEM_INFO return PVRSRV_ERROR_INVALID_PARAMS; } - return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem); + return ResManFreeResByPtr(psMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL); } -static PVRSRV_ERROR UnmapDeviceClassMemoryCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +static PVRSRV_ERROR UnmapDeviceClassMemoryCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_DC_MAPINFO *psDCMapInfo = pvParam; PVRSRV_KERNEL_MEM_INFO *psMemInfo; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); psMemInfo = psDCMapInfo->psMemInfo; @@ -1324,9 +1545,12 @@ static PVRSRV_ERROR UnmapDeviceClassMemoryCallBack(IMG_PVOID pvParam, } #endif + (psDCMapInfo->psDeviceClassBuffer->ui32MemMapRefCount)--; + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_DC_MAPINFO), psDCMapInfo, IMG_NULL); - return FreeMemCallBackCommon(psMemInfo, ui32Param, IMG_TRUE); + return FreeMemCallBackCommon(psMemInfo, ui32Param, + PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR); } @@ -1348,7 +1572,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * DEVICE_MEMORY_INFO *psDevMemoryInfo; DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; IMG_HANDLE hDevMemHeap = IMG_NULL; - IMG_SIZE_T ui32ByteSize; + IMG_SIZE_T uByteSize; IMG_SIZE_T ui32Offset; IMG_SIZE_T ui32PageSize = HOST_PAGESIZE(); BM_HANDLE hBuffer; @@ -1398,7 +1622,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * eError = psDeviceClassBuffer->pfnGetBufferAddr(psDeviceClassBuffer->hExtDevice, psDeviceClassBuffer->hExtBuffer, &psSysPAddr, - &ui32ByteSize, + &uByteSize, &pvCPUVAddr, phOSMapInfo, &bPhysContig, @@ -1421,7 +1645,14 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * if(psDeviceMemoryHeap[i].DevMemHeapType == DEVICE_MEMORY_HEAP_PERCONTEXT) { - hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + if (psDeviceMemoryHeap[i].ui32HeapSize > 0) + { + hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + } + else + { + hDevMemHeap = IMG_NULL; + } } else { @@ -1457,7 +1688,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * psMemBlock = &(psMemInfo->sMemBlk); bBMError = BM_Wrap(hDevMemHeap, - ui32ByteSize, + uByteSize, ui32Offset, bPhysContig, psSysPAddr, @@ -1486,7 +1717,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * psMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psMemInfo->ui32AllocSize = ui32ByteSize; + psMemInfo->uAllocSize = uByteSize; psMemInfo->psKernelSyncInfo = psDeviceClassBuffer->psKernelSyncInfo; @@ -1495,6 +1726,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * psDCMapInfo->psMemInfo = psMemInfo; + psDCMapInfo->psDeviceClassBuffer = psDeviceClassBuffer; #if defined(SUPPORT_MEMORY_TILING) psDCMapInfo->psDeviceNode = psDeviceNode; @@ -1521,6 +1753,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * 0, &UnmapDeviceClassMemoryCallBack); + (psDeviceClassBuffer->ui32MemMapRefCount)++; psMemInfo->ui32RefCount++; psMemInfo->memType = PVRSRV_MEMTYPE_DEVICECLASS; @@ -1531,7 +1764,7 @@ 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->ui32AllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); + PDUMPMEM(IMG_NULL, psMemInfo, ui32Offset, psMemInfo->uAllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); #endif return PVRSRV_OK; @@ -1562,3 +1795,29 @@ ErrorExitPhase1: return eError; } + +IMG_EXPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVChangeDeviceMemoryAttributesKM(IMG_HANDLE hKernelMemInfo, IMG_UINT32 ui32Attribs) +{ + PVRSRV_KERNEL_MEM_INFO *psKMMemInfo; + + if (hKernelMemInfo == IMG_NULL) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psKMMemInfo = (PVRSRV_KERNEL_MEM_INFO *)hKernelMemInfo; + + if (ui32Attribs & PVRSRV_CHANGEDEVMEM_ATTRIBS_CACHECOHERENT) + { + psKMMemInfo->ui32Flags |= PVRSRV_MEM_CACHE_CONSISTENT; + } + else + { + psKMMemInfo->ui32Flags &= ~PVRSRV_MEM_CACHE_CONSISTENT; + } + + return PVRSRV_OK; +} + + diff --git a/drivers/gpu/pvr/env_data.h b/drivers/gpu/pvr/env_data.h index 3d41219..7716529 100644 --- a/drivers/gpu/pvr/env_data.h +++ b/drivers/gpu/pvr/env_data.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/env_perproc.h b/drivers/gpu/pvr/env_perproc.h index a6e49db..dabf1e3 100644 --- a/drivers/gpu/pvr/env_perproc.h +++ b/drivers/gpu/pvr/env_perproc.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/event.c b/drivers/gpu/pvr/event.c index 2a930a6..7e160c3 100644 --- a/drivers/gpu/pvr/event.c +++ b/drivers/gpu/pvr/event.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,11 +24,14 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#include <linux/version.h> #include <asm/io.h> #include <asm/page.h> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)) @@ -140,7 +143,7 @@ PVRSRV_ERROR LinuxEventObjectDelete(IMG_HANDLE hOSEventObjectList, IMG_HANDLE hO #if defined(DEBUG) PVR_DPF((PVR_DBG_MESSAGE, "LinuxEventObjectListDelete: Event object waits: %u", psLinuxEventObject->ui32Stats)); #endif - if(ResManFreeResByPtr(psLinuxEventObject->hResItem) != PVRSRV_OK) + if(ResManFreeResByPtr(psLinuxEventObject->hResItem, CLEANUP_WITH_POLL) != PVRSRV_OK) { return PVRSRV_ERROR_UNABLE_TO_DESTROY_EVENT; } @@ -152,13 +155,14 @@ PVRSRV_ERROR LinuxEventObjectDelete(IMG_HANDLE hOSEventObjectList, IMG_HANDLE hO } -static PVRSRV_ERROR LinuxEventObjectDeleteCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param) +static PVRSRV_ERROR LinuxEventObjectDeleteCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bForceCleanup) { PVRSRV_LINUX_EVENT_OBJECT *psLinuxEventObject = pvParam; PVRSRV_LINUX_EVENT_OBJECT_LIST *psLinuxEventObjectList = psLinuxEventObject->psLinuxEventObjectList; unsigned long ulLockFlags; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bForceCleanup); write_lock_irqsave(&psLinuxEventObjectList->sLock, ulLockFlags); list_del(&psLinuxEventObject->sList); diff --git a/drivers/gpu/pvr/event.h b/drivers/gpu/pvr/event.h index d07bc97..3035283 100644 --- a/drivers/gpu/pvr/event.h +++ b/drivers/gpu/pvr/event.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/handle.c b/drivers/gpu/pvr/handle.c index 5e34af5..d911b38 100644 --- a/drivers/gpu/pvr/handle.c +++ b/drivers/gpu/pvr/handle.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,7 +24,7 @@ * ******************************************************************************/ -#ifdef PVR_SECURE_HANDLES +#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) #include <stddef.h> #include "services_headers.h" @@ -47,8 +47,14 @@ #define INDEX_IS_VALID(psBase, i) ((i) < (psBase)->ui32TotalHandCount) -#define INDEX_TO_HANDLE(i) ((IMG_HANDLE)((i) + 1)) +#if defined (SUPPORT_SID_INTERFACE) +#define INDEX_TO_HANDLE(i) ((IMG_SID)((i) + 1)) #define HANDLE_TO_INDEX(h) ((IMG_UINT32)(h) - 1) +#else +#define INDEX_TO_HANDLE(i) ((IMG_HANDLE)((IMG_UINTPTR_T)(i) + 1)) +#define HANDLE_TO_INDEX(h) ((IMG_UINT32)(IMG_UINTPTR_T)(h) - 1) + +#endif #define INDEX_TO_BLOCK_INDEX(i) DIVIDE_BY_BLOCK_SIZE(i) #define BLOCK_INDEX_TO_INDEX(i) MULTIPLY_BY_BLOCK_SIZE(i) @@ -108,7 +114,11 @@ struct sHandleList { IMG_UINT32 ui32Prev; IMG_UINT32 ui32Next; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hParent; +#else IMG_HANDLE hParent; +#endif }; enum ePVRSRVInternalHandleFlag @@ -217,7 +227,11 @@ typedef IMG_UINTPTR_T HAND_KEY[HAND_KEY_LEN]; #pragma inline(HandleListInit) #endif static INLINE +#if defined (SUPPORT_SID_INTERFACE) +IMG_VOID HandleListInit(IMG_UINT32 ui32Index, struct sHandleList *psList, IMG_SID hParent) +#else IMG_VOID HandleListInit(IMG_UINT32 ui32Index, struct sHandleList *psList, IMG_HANDLE hParent) +#endif { psList->ui32Next = ui32Index; psList->ui32Prev = ui32Index; @@ -259,7 +273,7 @@ IMG_BOOL HandleListIsEmpty(IMG_UINT32 ui32Index, struct sHandleList *psList) IMG_BOOL bIsEmpty2; bIsEmpty2 = (IMG_BOOL)(psList->ui32Prev == ui32Index); - PVR_ASSERT(bIsEmpty == bIsEmpty2); + PVR_ASSERT(bIsEmpty == bIsEmpty2) } #endif @@ -273,7 +287,7 @@ IMG_BOOL HandleListIsEmpty(IMG_UINT32 ui32Index, struct sHandleList *psList) static INLINE IMG_BOOL NoChildren(struct sHandle *psHandle) { - PVR_ASSERT(psHandle->sChildren.hParent == HANDLE_PTR_TO_HANDLE(psHandle)); + PVR_ASSERT(psHandle->sChildren.hParent == HANDLE_PTR_TO_HANDLE(psHandle)) return HandleListIsEmpty(HANDLE_PTR_TO_INDEX(psHandle), &psHandle->sChildren); } @@ -286,13 +300,13 @@ IMG_BOOL NoParent(struct sHandle *psHandle) { if (HandleListIsEmpty(HANDLE_PTR_TO_INDEX(psHandle), &psHandle->sSiblings)) { - PVR_ASSERT(psHandle->sSiblings.hParent == IMG_NULL); + PVR_ASSERT(psHandle->sSiblings.hParent == IMG_NULL) return IMG_TRUE; } else { - PVR_ASSERT(psHandle->sSiblings.hParent != IMG_NULL); + PVR_ASSERT(psHandle->sSiblings.hParent != IMG_NULL) } return IMG_FALSE; } @@ -301,7 +315,11 @@ IMG_BOOL NoParent(struct sHandle *psHandle) #pragma inline(ParentHandle) #endif static INLINE +#if defined (SUPPORT_SID_INTERFACE) +IMG_SID ParentHandle(struct sHandle *psHandle) +#else IMG_HANDLE ParentHandle(struct sHandle *psHandle) +#endif { return psHandle->sSiblings.hParent; } @@ -318,9 +336,9 @@ IMG_VOID HandleListInsertBefore(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32InsIn struct sHandleList *psPrevIns = LIST_PTR_FROM_INDEX_AND_OFFSET(psBase, psIns->ui32Prev, ui32ParentIndex, uiParentOffset, uiEntryOffset); - PVR_ASSERT(psEntry->hParent == IMG_NULL); - PVR_ASSERT(ui32InsIndex == psPrevIns->ui32Next); - PVR_ASSERT(LIST_PTR_FROM_INDEX_AND_OFFSET(psBase, ui32ParentIndex, ui32ParentIndex, uiParentOffset, uiParentOffset)->hParent == INDEX_TO_HANDLE(ui32ParentIndex)); + PVR_ASSERT(psEntry->hParent == IMG_NULL) + PVR_ASSERT(ui32InsIndex == psPrevIns->ui32Next) + PVR_ASSERT(LIST_PTR_FROM_INDEX_AND_OFFSET(psBase, ui32ParentIndex, ui32ParentIndex, uiParentOffset, uiParentOffset)->hParent == INDEX_TO_HANDLE(ui32ParentIndex)) psEntry->ui32Prev = psIns->ui32Prev; psIns->ui32Prev = ui32EntryIndex; @@ -338,7 +356,7 @@ IMG_VOID AdoptChild(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psParent, struct { IMG_UINT32 ui32Parent = HANDLE_TO_INDEX(psParent->sChildren.hParent); - PVR_ASSERT(ui32Parent == HANDLE_PTR_TO_INDEX(psParent)); + PVR_ASSERT(ui32Parent == HANDLE_PTR_TO_INDEX(psParent)) HandleListInsertBefore(psBase, ui32Parent, &psParent->sChildren, offsetof(struct sHandle, sChildren), HANDLE_PTR_TO_INDEX(psChild), &psChild->sSiblings, offsetof(struct sHandle, sSiblings), ui32Parent); @@ -357,7 +375,7 @@ IMG_VOID HandleListRemove(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32EntryIndex, struct sHandleList *psNext = LIST_PTR_FROM_INDEX_AND_OFFSET(psBase, psEntry->ui32Next, HANDLE_TO_INDEX(psEntry->hParent), uiParentOffset, uiEntryOffset); - PVR_ASSERT(psEntry->hParent != IMG_NULL); + PVR_ASSERT(psEntry->hParent != IMG_NULL) psPrev->ui32Next = psEntry->ui32Next; psNext->ui32Prev = psEntry->ui32Prev; @@ -384,7 +402,7 @@ PVRSRV_ERROR HandleListIterate(PVRSRV_HANDLE_BASE *psBase, struct sHandleList *p IMG_UINT32 ui32Index; IMG_UINT32 ui32Parent = HANDLE_TO_INDEX(psHead->hParent); - PVR_ASSERT(psHead->hParent != IMG_NULL); + PVR_ASSERT(psHead->hParent != IMG_NULL) for(ui32Index = psHead->ui32Next; ui32Index != ui32Parent; ) @@ -394,7 +412,7 @@ PVRSRV_ERROR HandleListIterate(PVRSRV_HANDLE_BASE *psBase, struct sHandleList *p struct sHandleList *psEntry = LIST_PTR_FROM_INDEX_AND_OFFSET(psBase, ui32Index, ui32Parent, uiParentOffset, uiEntryOffset); PVRSRV_ERROR eError; - PVR_ASSERT(psEntry->hParent == psHead->hParent); + PVR_ASSERT(psEntry->hParent == psHead->hParent) ui32Index = psEntry->ui32Next; @@ -421,7 +439,11 @@ PVRSRV_ERROR IterateOverChildren(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psP #pragma inline(GetHandleStructure) #endif static INLINE +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **ppsHandle, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) +#else PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **ppsHandle, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) +#endif { IMG_UINT32 ui32Index = HANDLE_TO_INDEX(hHandle); struct sHandle *psHandle; @@ -430,6 +452,9 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps if (!INDEX_IS_VALID(psBase, ui32Index)) { PVR_DPF((PVR_DBG_ERROR, "GetHandleStructure: Handle index out of range (%u >= %u)", ui32Index, psBase->ui32TotalHandCount)); +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return PVRSRV_ERROR_HANDLE_INDEX_OUT_OF_RANGE; } @@ -437,6 +462,9 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps if (psHandle->eType == PVRSRV_HANDLE_TYPE_NONE) { PVR_DPF((PVR_DBG_ERROR, "GetHandleStructure: Handle not allocated (index: %u)", ui32Index)); +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return PVRSRV_ERROR_HANDLE_NOT_ALLOCATED; } @@ -444,6 +472,9 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps if (eType != PVRSRV_HANDLE_TYPE_NONE && eType != psHandle->eType) { PVR_DPF((PVR_DBG_ERROR, "GetHandleStructure: Handle type mismatch (%d != %d)", eType, psHandle->eType)); +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return PVRSRV_ERROR_HANDLE_TYPE_MISMATCH; } @@ -457,7 +488,11 @@ PVRSRV_ERROR GetHandleStructure(PVRSRV_HANDLE_BASE *psBase, struct sHandle **pps #pragma inline(ParentIfPrivate) #endif static INLINE +#if defined (SUPPORT_SID_INTERFACE) +IMG_SID ParentIfPrivate(struct sHandle *psHandle) +#else IMG_HANDLE ParentIfPrivate(struct sHandle *psHandle) +#endif { return TEST_ALLOC_FLAG(psHandle, PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE) ? ParentHandle(psHandle) : IMG_NULL; @@ -467,7 +502,11 @@ IMG_HANDLE ParentIfPrivate(struct sHandle *psHandle) #pragma inline(InitKey) #endif static INLINE +#if defined (SUPPORT_SID_INTERFACE) +IMG_VOID InitKey(HAND_KEY aKey, PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_SID hParent) +#else IMG_VOID InitKey(HAND_KEY aKey, PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_HANDLE hParent) +#endif { PVR_UNREFERENCED_PARAMETER(psBase); @@ -502,8 +541,8 @@ PVRSRV_ERROR ReallocHandleArray(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32NewCo if (((ui32OldCount % HANDLE_BLOCK_SIZE) != 0) || ((ui32NewCount % HANDLE_BLOCK_SIZE) != 0)) { - PVR_ASSERT((ui32OldCount % HANDLE_BLOCK_SIZE) == 0); - PVR_ASSERT((ui32NewCount % HANDLE_BLOCK_SIZE) == 0); + PVR_ASSERT((ui32OldCount % HANDLE_BLOCK_SIZE) == 0) + PVR_ASSERT((ui32NewCount % HANDLE_BLOCK_SIZE) == 0) return PVRSRV_ERROR_INVALID_PARAMS; } @@ -511,7 +550,7 @@ PVRSRV_ERROR ReallocHandleArray(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32NewCo if (ui32NewCount != 0) { - eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, HANDLE_ARRAY_SIZE(ui32NewCount) * sizeof(struct sHandleIndex), (IMG_VOID **)&psNewArray, &hNewArrayBlockAlloc, @@ -550,7 +589,7 @@ PVRSRV_ERROR ReallocHandleArray(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32NewCo struct sHandleIndex *psIndex = INDEX_TO_INDEX_STRUCT_PTR(psNewArray, ui32Index); - eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(struct sHandle) * HANDLE_BLOCK_SIZE, (IMG_VOID **)&psIndex->psHandle, &psIndex->hBlockAlloc, @@ -658,12 +697,12 @@ PVRSRV_ERROR ReallocHandleArray(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32NewCo } } - PVR_ASSERT(psBase->ui32FirstFreeIndex <= psBase->ui32TotalHandCount); + PVR_ASSERT(psBase->ui32FirstFreeIndex <= psBase->ui32TotalHandCount) return PVRSRV_OK; error: - PVR_ASSERT(eReturn != PVRSRV_OK); + PVR_ASSERT(eReturn != PVRSRV_OK) if (psNewArray != IMG_NULL) { @@ -714,11 +753,17 @@ static PVRSRV_ERROR FreeHandle(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psHan if (!TEST_ALLOC_FLAG(psHandle, PVRSRV_HANDLE_ALLOC_FLAG_MULTI) && !BATCHED_HANDLE_PARTIALLY_FREE(psHandle)) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHandle; + hHandle = (IMG_SID) HASH_Remove_Extended(psBase->psHashTab, aKey); +#else IMG_HANDLE hHandle; hHandle = (IMG_HANDLE) HASH_Remove_Extended(psBase->psHashTab, aKey); - PVR_ASSERT(hHandle != IMG_NULL); - PVR_ASSERT(hHandle == INDEX_TO_HANDLE(ui32Index)); +#endif + + PVR_ASSERT(hHandle != IMG_NULL) + PVR_ASSERT(hHandle == INDEX_TO_HANDLE(ui32Index)) PVR_UNREFERENCED_PARAMETER(hHandle); } @@ -749,20 +794,20 @@ static PVRSRV_ERROR FreeHandle(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psHan { if (psBase->ui32FreeHandCount == 0) { - PVR_ASSERT(psBase->ui32FirstFreeIndex == 0); - PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne == 0); + PVR_ASSERT(psBase->ui32FirstFreeIndex == 0) + PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne == 0) psBase->ui32FirstFreeIndex = ui32Index; } else { - PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne != 0); - PVR_ASSERT(INDEX_TO_HANDLE_STRUCT_PTR(psBase, psBase->ui32LastFreeIndexPlusOne - 1)->ui32NextIndexPlusOne == 0); + PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne != 0) + PVR_ASSERT(INDEX_TO_HANDLE_STRUCT_PTR(psBase, psBase->ui32LastFreeIndexPlusOne - 1)->ui32NextIndexPlusOne == 0) INDEX_TO_HANDLE_STRUCT_PTR(psBase, psBase->ui32LastFreeIndexPlusOne - 1)->ui32NextIndexPlusOne = ui32Index + 1; } - PVR_ASSERT(psHandle->ui32NextIndexPlusOne == 0); + PVR_ASSERT(psHandle->ui32NextIndexPlusOne == 0) psBase->ui32LastFreeIndexPlusOne = ui32Index + 1; @@ -771,7 +816,7 @@ static PVRSRV_ERROR FreeHandle(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psHan psBase->ui32FreeHandCount++; INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32Index)++; - PVR_ASSERT(INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32Index)<= HANDLE_BLOCK_SIZE); + PVR_ASSERT(INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32Index)<= HANDLE_BLOCK_SIZE) #ifdef DEBUG { @@ -783,7 +828,7 @@ static PVRSRV_ERROR FreeHandle(PVRSRV_HANDLE_BASE *psBase, struct sHandle *psHan ui32FreeHandCount += INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32BlockedIndex); } - PVR_ASSERT(ui32FreeHandCount == psBase->ui32FreeHandCount); + PVR_ASSERT(ui32FreeHandCount == psBase->ui32FreeHandCount) } #endif @@ -875,15 +920,23 @@ static PVRSRV_ERROR FreeHandleBase(PVRSRV_HANDLE_BASE *psBase) #pragma inline(FindHandle) #endif static INLINE +#if defined (SUPPORT_SID_INTERFACE) +IMG_SID FindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_SID hParent) +#else IMG_HANDLE FindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, IMG_HANDLE hParent) +#endif { HAND_KEY aKey; - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) InitKey(aKey, psBase, pvData, eType, hParent); +#if defined (SUPPORT_SID_INTERFACE) + return (IMG_SID) HASH_Retrieve_Extended(psBase->psHashTab, aKey); +#else return (IMG_HANDLE) HASH_Retrieve_Extended(psBase->psHashTab, aKey); +#endif } static PVRSRV_ERROR IncreaseHandleArraySize(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32Delta) @@ -893,7 +946,7 @@ static PVRSRV_ERROR IncreaseHandleArraySize(PVRSRV_HANDLE_BASE *psBase, IMG_UINT IMG_UINT32 ui32NewTotalHandCount = psBase->ui32TotalHandCount + ui32DeltaAdjusted; ; - PVR_ASSERT(ui32Delta != 0); + PVR_ASSERT(ui32Delta != 0) if (ui32NewTotalHandCount > psBase->ui32MaxIndexPlusOne || ui32NewTotalHandCount <= psBase->ui32TotalHandCount) @@ -909,7 +962,7 @@ static PVRSRV_ERROR IncreaseHandleArraySize(PVRSRV_HANDLE_BASE *psBase, IMG_UINT } } - PVR_ASSERT(ui32DeltaAdjusted >= ui32Delta); + PVR_ASSERT(ui32DeltaAdjusted >= ui32Delta) eError = ReallocHandleArray(psBase, ui32NewTotalHandCount); @@ -941,28 +994,36 @@ static PVRSRV_ERROR EnsureFreeHandles(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui3 return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_SID hParent) +#else static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent) +#endif { IMG_UINT32 ui32NewIndex = DEFAULT_MAX_INDEX_PLUS_ONE; struct sHandle *psNewHandle = IMG_NULL; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHandle; +#else IMG_HANDLE hHandle; +#endif HAND_KEY aKey; PVRSRV_ERROR eError; - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); - PVR_ASSERT(psBase != IMG_NULL); - PVR_ASSERT(psBase->psHashTab != IMG_NULL); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) + PVR_ASSERT(psBase != IMG_NULL) + PVR_ASSERT(psBase->psHashTab != IMG_NULL) if (!TEST_FLAG(eFlag, PVRSRV_HANDLE_ALLOC_FLAG_MULTI)) { - PVR_ASSERT(FindHandle(psBase, pvData, eType, hParent) == IMG_NULL); + PVR_ASSERT(FindHandle(psBase, pvData, eType, hParent) == IMG_NULL) } if (psBase->ui32FreeHandCount == 0 && HANDLES_BATCHED(psBase)) { - PVR_DPF((PVR_DBG_WARNING, "AllocHandle: Handle batch size (%u) was too small, allocating additional space", psBase->ui32HandBatchSize)); + PVR_DPF((PVR_DBG_WARNING, "AllocHandle: Handle batch size (%u) was too small, allocating additional space", psBase->ui32HandBatchSize)); } @@ -988,7 +1049,7 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle - PVR_ASSERT((psBase->ui32FirstFreeIndex % HANDLE_BLOCK_SIZE) == 0); + PVR_ASSERT((psBase->ui32FirstFreeIndex % HANDLE_BLOCK_SIZE) == 0) for (ui32BlockedIndex = ROUND_DOWN_TO_MULTIPLE_OF_BLOCK_SIZE(psBase->ui32FirstFreeIndex); ui32BlockedIndex < psBase->ui32TotalHandCount; ui32BlockedIndex += HANDLE_BLOCK_SIZE) { @@ -1009,9 +1070,9 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle } } psBase->ui32FirstFreeIndex = 0; - PVR_ASSERT(ui32NewIndex < psBase->ui32TotalHandCount); + PVR_ASSERT(ui32NewIndex < psBase->ui32TotalHandCount) } - PVR_ASSERT(psNewHandle != IMG_NULL); + PVR_ASSERT(psNewHandle != IMG_NULL) hHandle = INDEX_TO_HANDLE(ui32NewIndex); @@ -1033,8 +1094,8 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle psBase->ui32FreeHandCount--; - PVR_ASSERT(INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32NewIndex) <= HANDLE_BLOCK_SIZE); - PVR_ASSERT(INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32NewIndex) > 0); + PVR_ASSERT(INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32NewIndex) <= HANDLE_BLOCK_SIZE) + PVR_ASSERT(INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32NewIndex) > 0) INDEX_TO_FREE_HAND_BLOCK_COUNT(psBase, ui32NewIndex)--; @@ -1044,8 +1105,8 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle if (psBase->ui32FreeHandCount == 0) { - PVR_ASSERT(psBase->ui32FirstFreeIndex == ui32NewIndex); - PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne == (ui32NewIndex + 1)); + PVR_ASSERT(psBase->ui32FirstFreeIndex == ui32NewIndex) + PVR_ASSERT(psBase->ui32LastFreeIndexPlusOne == (ui32NewIndex + 1)) psBase->ui32LastFreeIndexPlusOne = 0; psBase->ui32FirstFreeIndex = 0; @@ -1060,7 +1121,7 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle } - PVR_ASSERT(psNewHandle->ui32Index == ui32NewIndex); + PVR_ASSERT(psNewHandle->ui32Index == ui32NewIndex) psNewHandle->eType = eType; @@ -1070,12 +1131,12 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle InitParentList(psNewHandle); #if defined(DEBUG) - PVR_ASSERT(NoChildren(psNewHandle)); + PVR_ASSERT(NoChildren(psNewHandle)) #endif InitChildEntry(psNewHandle); #if defined(DEBUG) - PVR_ASSERT(NoParent(psNewHandle)); + PVR_ASSERT(NoParent(psNewHandle)) #endif if (HANDLES_BATCHED(psBase)) @@ -1099,12 +1160,24 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag) +#else PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag) +#endif { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHandle; +#else IMG_HANDLE hHandle; +#endif PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + *phHandle = 0; +#else *phHandle = IMG_NULL; +#endif if (HANDLES_BATCHED(psBase)) { @@ -1113,13 +1186,17 @@ PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, } - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) if (!TEST_FLAG(eFlag, PVRSRV_HANDLE_ALLOC_FLAG_MULTI)) { hHandle = FindHandle(psBase, pvData, eType, IMG_NULL); +#if defined (SUPPORT_SID_INTERFACE) + if (hHandle != 0) +#else if (hHandle != IMG_NULL) +#endif { struct sHandle *psHandle; @@ -1137,12 +1214,16 @@ PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, eError = PVRSRV_OK; goto exit_ok; } + +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return PVRSRV_ERROR_HANDLE_NOT_SHAREABLE; } } eError = AllocHandle(psBase, phHandle, pvData, eType, eFlag, IMG_NULL); - + exit_ok: if (HANDLES_BATCHED(psBase) && (eError == PVRSRV_OK)) { @@ -1152,15 +1233,26 @@ exit_ok: return eError; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_SID hParent) +#else PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent) +#endif { struct sHandle *psPHand; struct sHandle *psCHand; PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hParentKey; + IMG_SID hHandle; + + *phHandle = 0; +#else IMG_HANDLE hParentKey; IMG_HANDLE hHandle; *phHandle = IMG_NULL; +#endif if (HANDLES_BATCHED(psBase)) { @@ -1169,7 +1261,7 @@ PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHand } - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) hParentKey = TEST_FLAG(eFlag, PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE) ? hParent : IMG_NULL; @@ -1185,7 +1277,11 @@ PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHand { hHandle = FindHandle(psBase, pvData, eType, hParentKey); +#if defined (SUPPORT_SID_INTERFACE) + if (hHandle != 0) +#else if (hHandle != IMG_NULL) +#endif { struct sHandle *psCHandle; PVRSRV_ERROR eErr; @@ -1197,7 +1293,7 @@ PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHand return eErr; } - PVR_ASSERT(hParentKey != IMG_NULL && ParentHandle(HANDLE_TO_HANDLE_STRUCT_PTR(psBase, hHandle)) == hParent); + PVR_ASSERT(hParentKey != IMG_NULL && ParentHandle(HANDLE_TO_HANDLE_STRUCT_PTR(psBase, hHandle)) == hParent) if (TEST_FLAG(psCHandle->eFlag & eFlag, PVRSRV_HANDLE_ALLOC_FLAG_SHARED) && ParentHandle(HANDLE_TO_HANDLE_STRUCT_PTR(psBase, hHandle)) == hParent) @@ -1205,6 +1301,9 @@ PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHand *phHandle = hHandle; goto exit_ok; } +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return PVRSRV_ERROR_HANDLE_NOT_SHAREABLE; } } @@ -1233,14 +1332,26 @@ exit_ok: return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType) +#else PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType) +#endif { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHandle; +#else IMG_HANDLE hHandle; +#endif - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) +#if defined (SUPPORT_SID_INTERFACE) + hHandle = (IMG_SID) FindHandle(psBase, pvData, eType, IMG_NULL); +#else hHandle = (IMG_HANDLE) FindHandle(psBase, pvData, eType, IMG_NULL); +#endif if (hHandle == IMG_NULL) { return PVRSRV_ERROR_HANDLE_NOT_FOUND; @@ -1251,7 +1362,11 @@ PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, PVRSRV_HANDLE_TYPE *peType, IMG_SID hHandle) +#else PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, PVRSRV_HANDLE_TYPE *peType, IMG_HANDLE hHandle) +#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; @@ -1260,6 +1375,9 @@ PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *pp if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupHandleAnyType: Error looking up handle (%d)", eError)); +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return eError; } @@ -1269,17 +1387,27 @@ PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *pp return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) +#else PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) +#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) +#if defined (SUPPORT_SID_INTERFACE) + PVR_ASSERT(hHandle != 0) +#endif eError = GetHandleStructure(psBase, &psHandle, hHandle, eType); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupHandle: Error looking up handle (%d)", eError)); +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return eError; } @@ -1288,13 +1416,20 @@ PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType, IMG_SID hAncestor) +#else PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType, IMG_HANDLE hAncestor) +#endif { struct sHandle *psPHand; struct sHandle *psCHand; PVRSRV_ERROR eError; - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) +#if defined (SUPPORT_SID_INTERFACE) + PVR_ASSERT(hHandle != 0) +#endif eError = GetHandleStructure(psBase, &psCHand, hHandle, eType); if (eError != PVRSRV_OK) @@ -1319,12 +1454,16 @@ PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvDat return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phParent, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) +#else PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phParent, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) +#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) eError = GetHandleStructure(psBase, &psHandle, hHandle, eType); if (eError != PVRSRV_OK) @@ -1338,17 +1477,24 @@ PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phPare return PVRSRV_OK; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) +#else PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) +#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) eError = GetHandleStructure(psBase, &psHandle, hHandle, eType); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupAndReleaseHandle: Error looking up handle (%d)", eError)); +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#endif return eError; } @@ -1359,12 +1505,16 @@ PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID return eError; } +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType) +#else PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType) +#endif { struct sHandle *psHandle; PVRSRV_ERROR eError; - PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE); + PVR_ASSERT(eType != PVRSRV_HANDLE_TYPE_NONE) eError = GetHandleStructure(psBase, &psHandle, hHandle, eType); if (eError != PVRSRV_OK) @@ -1406,11 +1556,11 @@ PVRSRV_ERROR PVRSRVNewHandleBatch(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32Bat psBase->ui32TotalHandCountPreBatch = psBase->ui32TotalHandCount; - PVR_ASSERT(psBase->ui32BatchHandAllocFailures == 0); + PVR_ASSERT(psBase->ui32BatchHandAllocFailures == 0) - PVR_ASSERT(psBase->ui32FirstBatchIndexPlusOne == 0); + PVR_ASSERT(psBase->ui32FirstBatchIndexPlusOne == 0) - PVR_ASSERT(HANDLES_BATCHED(psBase)); + PVR_ASSERT(HANDLES_BATCHED(psBase)) return PVRSRV_OK; } @@ -1437,14 +1587,14 @@ static PVRSRV_ERROR PVRSRVHandleBatchCommitOrRelease(PVRSRV_HANDLE_BASE *psBase, bCommitBatch = IMG_FALSE; } - PVR_ASSERT(psBase->ui32BatchHandAllocFailures == 0 || !bCommit); + PVR_ASSERT(psBase->ui32BatchHandAllocFailures == 0 || !bCommit) ui32IndexPlusOne = psBase->ui32FirstBatchIndexPlusOne; while(ui32IndexPlusOne != 0) { struct sHandle *psHandle = INDEX_TO_HANDLE_STRUCT_PTR(psBase, ui32IndexPlusOne - 1); IMG_UINT32 ui32NextIndexPlusOne = psHandle->ui32NextIndexPlusOne; - PVR_ASSERT(BATCHED_HANDLE(psHandle)); + PVR_ASSERT(BATCHED_HANDLE(psHandle)) psHandle->ui32NextIndexPlusOne = 0; @@ -1464,7 +1614,7 @@ static PVRSRV_ERROR PVRSRVHandleBatchCommitOrRelease(PVRSRV_HANDLE_BASE *psBase, { PVR_DPF((PVR_DBG_ERROR, "PVRSRVHandleBatchCommitOrRelease: Error freeing handle (%d)", eError)); } - PVR_ASSERT(eError == PVRSRV_OK); + PVR_ASSERT(eError == PVRSRV_OK) } else { @@ -1480,7 +1630,7 @@ static PVRSRV_ERROR PVRSRVHandleBatchCommitOrRelease(PVRSRV_HANDLE_BASE *psBase, { IMG_UINT32 ui32Delta = psBase->ui32TotalHandCount - psBase->ui32TotalHandCountPreBatch; - PVR_ASSERT(psBase->ui32TotalHandCount > psBase->ui32TotalHandCountPreBatch); + PVR_ASSERT(psBase->ui32TotalHandCount > psBase->ui32TotalHandCountPreBatch) PVR_DPF((PVR_DBG_WARNING, "PVRSRVHandleBatchCommitOrRelease: The batch size was too small. Batch size was %u, but needs to be %u", psBase->ui32HandBatchSize, psBase->ui32HandBatchSize + ui32Delta)); @@ -1494,7 +1644,7 @@ static PVRSRV_ERROR PVRSRVHandleBatchCommitOrRelease(PVRSRV_HANDLE_BASE *psBase, if (psBase->ui32BatchHandAllocFailures != 0 && bCommit) { - PVR_ASSERT(!bCommitBatch); + PVR_ASSERT(!bCommitBatch) return PVRSRV_ERROR_HANDLE_BATCH_COMMIT_FAILURE; } @@ -1546,9 +1696,9 @@ PVRSRV_ERROR PVRSRVSetMaxHandle(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32MaxHa psBase->ui32MaxIndexPlusOne = ui32MaxHandleRounded; } - PVR_ASSERT(psBase->ui32MaxIndexPlusOne != 0); - PVR_ASSERT(psBase->ui32MaxIndexPlusOne <= DEFAULT_MAX_INDEX_PLUS_ONE); - PVR_ASSERT((psBase->ui32MaxIndexPlusOne % HANDLE_BLOCK_SIZE) == 0); + PVR_ASSERT(psBase->ui32MaxIndexPlusOne != 0) + PVR_ASSERT(psBase->ui32MaxIndexPlusOne <= DEFAULT_MAX_INDEX_PLUS_ONE) + PVR_ASSERT((psBase->ui32MaxIndexPlusOne % HANDLE_BLOCK_SIZE) == 0) return PVRSRV_OK; } @@ -1595,7 +1745,7 @@ PVRSRV_ERROR PVRSRVPurgeHandles(PVRSRV_HANDLE_BASE *psBase) return PVRSRV_ERROR_INVALID_PARAMS; } - PVR_ASSERT((psBase->ui32TotalHandCount % HANDLE_BLOCK_SIZE) == 0); + PVR_ASSERT((psBase->ui32TotalHandCount % HANDLE_BLOCK_SIZE) == 0) for (ui32BlockIndex = INDEX_TO_BLOCK_INDEX(psBase->ui32TotalHandCount); ui32BlockIndex != 0; ui32BlockIndex--) { @@ -1629,7 +1779,7 @@ PVRSRV_ERROR PVRSRVAllocHandleBase(PVRSRV_HANDLE_BASE **ppsBase) IMG_HANDLE hBlockAlloc; PVRSRV_ERROR eError; - eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(*psBase), (IMG_PVOID *)&psBase, &hBlockAlloc, @@ -1663,7 +1813,7 @@ PVRSRV_ERROR PVRSRVFreeHandleBase(PVRSRV_HANDLE_BASE *psBase) { PVRSRV_ERROR eError; - PVR_ASSERT(psBase != gpsKernelHandleBase); + PVR_ASSERT(psBase != gpsKernelHandleBase) eError = FreeHandleBase(psBase); if (eError != PVRSRV_OK) @@ -1678,7 +1828,7 @@ PVRSRV_ERROR PVRSRVHandleInit(IMG_VOID) { PVRSRV_ERROR eError; - PVR_ASSERT(gpsKernelHandleBase == IMG_NULL); + PVR_ASSERT(gpsKernelHandleBase == IMG_NULL) eError = PVRSRVAllocHandleBase(&gpsKernelHandleBase); if (eError != PVRSRV_OK) diff --git a/drivers/gpu/pvr/handle.h b/drivers/gpu/pvr/handle.h index 56de04a..536fa56 100644 --- a/drivers/gpu/pvr/handle.h +++ b/drivers/gpu/pvr/handle.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -59,7 +59,8 @@ typedef enum PVRSRV_HANDLE_TYPE_EVENT_OBJECT_CONNECT, PVRSRV_HANDLE_TYPE_MMAP_INFO, PVRSRV_HANDLE_TYPE_SOC_TIMER, - PVRSRV_HANDLE_TYPE_SYNC_INFO_MOD_OBJ + PVRSRV_HANDLE_TYPE_SYNC_INFO_MOD_OBJ, + PVRSRV_HANDLE_TYPE_RESITEM_INFO } PVRSRV_HANDLE_TYPE; typedef enum @@ -77,11 +78,30 @@ typedef enum struct _PVRSRV_HANDLE_BASE_; typedef struct _PVRSRV_HANDLE_BASE_ PVRSRV_HANDLE_BASE; -#ifdef PVR_SECURE_HANDLES +#if defined (PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) extern PVRSRV_HANDLE_BASE *gpsKernelHandleBase; #define KERNEL_HANDLE_BASE (gpsKernelHandleBase) +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag); + +PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_SID hParent); + +PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType); + +PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, PVRSRV_HANDLE_TYPE *peType, IMG_SID hHandle); + +PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); + +PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType, IMG_SID hAncestor); + +PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID *phParent, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); + +PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); + +PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_SID hHandle, PVRSRV_HANDLE_TYPE eType); +#else PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag); PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, IMG_VOID *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent); @@ -99,6 +119,7 @@ PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phPare PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType); PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType); +#endif PVRSRV_ERROR PVRSRVNewHandleBatch(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui32BatchSize); diff --git a/drivers/gpu/pvr/hash.c b/drivers/gpu/pvr/hash.c index 32b0779..78eab44 100644 --- a/drivers/gpu/pvr/hash.c +++ b/drivers/gpu/pvr/hash.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -80,7 +80,7 @@ IMG_UINT32 HASH_Func_Default (IMG_SIZE_T uKeySize, IMG_VOID *pKey, IMG_UINT32 uHashTabLen) { IMG_UINTPTR_T *p = (IMG_UINTPTR_T *)pKey; - IMG_UINT32 uKeyLen = uKeySize / sizeof(IMG_UINTPTR_T); + IMG_UINT32 uKeyLen = (IMG_UINT32)(uKeySize / sizeof(IMG_UINTPTR_T)); IMG_UINT32 ui; IMG_UINT32 uHashKey = 0; @@ -112,7 +112,7 @@ HASH_Key_Comp_Default (IMG_SIZE_T uKeySize, IMG_VOID *pKey1, IMG_VOID *pKey2) { IMG_UINTPTR_T *p1 = (IMG_UINTPTR_T *)pKey1; IMG_UINTPTR_T *p2 = (IMG_UINTPTR_T *)pKey2; - IMG_UINT32 uKeyLen = uKeySize / sizeof(IMG_UINTPTR_T); + IMG_UINT32 uKeyLen = (IMG_UINT32)(uKeySize / sizeof(IMG_UINTPTR_T)); IMG_UINT32 ui; PVR_ASSERT((uKeySize % sizeof(IMG_UINTPTR_T)) == 0); @@ -228,7 +228,7 @@ HASH_TABLE * HASH_Create_Extended (IMG_UINT32 uInitialLen, IMG_SIZE_T uKeySize, pHash->uCount = 0; pHash->uSize = uInitialLen; pHash->uMinimumSize = uInitialLen; - pHash->uKeySize = uKeySize; + pHash->uKeySize = (IMG_UINT32)uKeySize; pHash->pfnHashFunc = pfnHashFunc; pHash->pfnKeyComp = pfnKeyComp; @@ -305,6 +305,9 @@ HASH_Insert_Extended (HASH_TABLE *pHash, IMG_VOID *pKey, IMG_UINTPTR_T v) OSMemCopy(pBucket->k, pKey, pHash->uKeySize); if (_ChainInsert (pHash, pBucket, pHash->ppBucketTable, pHash->uSize) != PVRSRV_OK) { + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(BUCKET) + pHash->uKeySize, + pBucket, IMG_NULL); return IMG_FALSE; } @@ -444,6 +447,31 @@ HASH_Retrieve (HASH_TABLE *pHash, IMG_UINTPTR_T k) return HASH_Retrieve_Extended(pHash, &k); } +PVRSRV_ERROR +HASH_Iterate(HASH_TABLE *pHash, HASH_pfnCallback pfnCallback) +{ + IMG_UINT32 uIndex; + for (uIndex=0; uIndex < pHash->uSize; uIndex++) + { + BUCKET *pBucket; + pBucket = pHash->ppBucketTable[uIndex]; + while (pBucket != IMG_NULL) + { + PVRSRV_ERROR eError; + BUCKET *pNextBucket = pBucket->pNext; + + eError = pfnCallback((IMG_UINTPTR_T) ((IMG_VOID *) *(pBucket->k)), (IMG_UINTPTR_T) pBucket->v); + + + if (eError != PVRSRV_OK) + return eError; + + pBucket = pNextBucket; + } + } + return PVRSRV_OK; +} + #ifdef HASH_TRACE IMG_VOID HASH_Dump (HASH_TABLE *pHash) diff --git a/drivers/gpu/pvr/hash.h b/drivers/gpu/pvr/hash.h index d45f4a9..3662089 100644 --- a/drivers/gpu/pvr/hash.h +++ b/drivers/gpu/pvr/hash.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -39,6 +39,11 @@ typedef IMG_BOOL HASH_KEY_COMP(IMG_SIZE_T uKeySize, IMG_VOID *pKey1, IMG_VOID *p typedef struct _HASH_TABLE_ HASH_TABLE; +typedef PVRSRV_ERROR (*HASH_pfnCallback) ( + IMG_UINTPTR_T k, + IMG_UINTPTR_T v +); + IMG_UINT32 HASH_Func_Default (IMG_SIZE_T uKeySize, IMG_VOID *pKey, IMG_UINT32 uHashTabLen); IMG_BOOL HASH_Key_Comp_Default (IMG_SIZE_T uKeySize, IMG_VOID *pKey1, IMG_VOID *pKey2); @@ -61,6 +66,8 @@ IMG_UINTPTR_T HASH_Retrieve_Extended (HASH_TABLE *pHash, IMG_VOID *pKey); IMG_UINTPTR_T HASH_Retrieve (HASH_TABLE *pHash, IMG_UINTPTR_T k); +PVRSRV_ERROR HASH_Iterate(HASH_TABLE *pHash, HASH_pfnCallback pfnCallback); + #ifdef HASH_TRACE IMG_VOID HASH_Dump (HASH_TABLE *pHash); #endif diff --git a/drivers/gpu/pvr/img_defs.h b/drivers/gpu/pvr/img_defs.h index 3ba2d2f..d5408cf 100644 --- a/drivers/gpu/pvr/img_defs.h +++ b/drivers/gpu/pvr/img_defs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,8 +22,7 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ - +*******************************************************************************/ #if !defined (__IMG_DEFS_H__) #define __IMG_DEFS_H__ @@ -57,24 +56,33 @@ typedef enum img_tag_TriStateSwitch #endif +/* Use this in any file, or use attributes under GCC - see below */ #ifndef PVR_UNREFERENCED_PARAMETER #define PVR_UNREFERENCED_PARAMETER(param) (param) = (param) #endif +/* The best way to supress unused parameter warnings using GCC is to use a + * variable attribute. Place the unref__ between the type and name of an + * unused parameter in a function parameter list, eg `int unref__ var'. This + * should only be used in GCC build environments, for example, in files that + * compile only on Linux. Other files should use UNREFERENCED_PARAMETER */ #ifdef __GNUC__ #define unref__ __attribute__ ((unused)) #else #define unref__ #endif +/* + Wide character definitions +*/ #ifndef _TCHAR_DEFINED #if defined(UNICODE) typedef unsigned short TCHAR, *PTCHAR, *PTSTR; -#else +#else /* #if defined(UNICODE) */ typedef char TCHAR, *PTCHAR, *PTSTR; -#endif +#endif /* #if defined(UNICODE) */ #define _TCHAR_DEFINED -#endif +#endif /* #ifndef _TCHAR_DEFINED */ #if defined(__linux__) || defined(__METAG) @@ -89,6 +97,7 @@ typedef char TCHAR, *PTCHAR, *PTSTR; #error("define an OS") #endif +// Use default definition if not overridden #ifndef IMG_ABORT #define IMG_ABORT() abort() #endif @@ -109,10 +118,19 @@ typedef char TCHAR, *PTCHAR, *PTSTR; #define IMG_FORMAT_PRINTF(x,y) #endif +/* + * Cleanup request defines + */ +#define CLEANUP_WITH_POLL IMG_FALSE +#define FORCE_CLEANUP IMG_TRUE + #if defined (_WIN64) #define IMG_UNDEF (~0ULL) #else #define IMG_UNDEF (~0UL) #endif -#endif +#endif /* #if !defined (__IMG_DEFS_H__) */ +/***************************************************************************** + End of file (IMG_DEFS.H) +*****************************************************************************/ diff --git a/drivers/gpu/pvr/img_types.h b/drivers/gpu/pvr/img_types.h index 31962aa..71dcebb 100644 --- a/drivers/gpu/pvr/img_types.h +++ b/drivers/gpu/pvr/img_types.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,15 +22,18 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +******************************************************************************/ #ifndef __IMG_TYPES_H__ #define __IMG_TYPES_H__ +/* define all address space bit depths: */ +/* CPU virtual address space defaults to 32bits */ #if !defined(IMG_ADDRSPACE_CPUVADDR_BITS) #define IMG_ADDRSPACE_CPUVADDR_BITS 32 #endif +/* Physical address space defaults to 32bits */ #if !defined(IMG_ADDRSPACE_PHYSADDR_BITS) #define IMG_ADDRSPACE_PHYSADDR_BITS 32 #endif @@ -56,18 +59,22 @@ typedef signed long IMG_INT32, *IMG_PINT32; #define IMG_UINT32_MAX 0xFFFFFFFFUL #endif +#if defined(USE_CODE) + +typedef unsigned __int64 IMG_UINT64, *IMG_PUINT64; +typedef __int64 IMG_INT64, *IMG_PINT64; + +#else #if (defined(LINUX) || defined(__METAG)) -#if !defined(USE_CODE) typedef unsigned long long IMG_UINT64, *IMG_PUINT64; typedef long long IMG_INT64, *IMG_PINT64; -#endif #else - #error("define an OS") - #endif +#endif #if !(defined(LINUX) && defined (__KERNEL__)) +/* Linux kernel mode does not use floating point */ typedef float IMG_FLOAT, *IMG_PFLOAT; typedef double IMG_DOUBLE, *IMG_PDOUBLE; #endif @@ -84,42 +91,99 @@ typedef void IMG_VOID, *IMG_PVOID; typedef IMG_INT32 IMG_RESULT; #if defined(_WIN64) -typedef unsigned __int64 IMG_UINTPTR_T; + typedef unsigned __int64 IMG_UINTPTR_T; + typedef signed __int64 IMG_PTRDIFF_T; + typedef IMG_UINT64 IMG_SIZE_T; #else -typedef unsigned int IMG_UINTPTR_T; + typedef unsigned int IMG_UINTPTR_T; + typedef IMG_UINT32 IMG_SIZE_T; #endif typedef IMG_PVOID IMG_HANDLE; typedef void** IMG_HVOID, * IMG_PHVOID; -typedef IMG_UINT32 IMG_SIZE_T; - #define IMG_NULL 0 +/* services/stream ID */ typedef IMG_UINT32 IMG_SID; +typedef IMG_UINT32 IMG_EVENTSID; + +/* Which of IMG_HANDLE/IMG_SID depends on SUPPORT_SID_INTERFACE */ +#if defined(SUPPORT_SID_INTERFACE) + typedef IMG_SID IMG_S_HANDLE; +#else + typedef IMG_HANDLE IMG_S_HANDLE; +#endif + +/* + * Address types. + * All types used to refer to a block of memory are wrapped in structures + * to enforce some degree of type safety, i.e. a IMG_DEV_VIRTADDR cannot + * be assigned to a variable of type IMG_DEV_PHYADDR because they are not the + * same thing. + * + * There is an assumption that the system contains at most one non-cpu mmu, + * and a memory block is only mapped by the MMU once. + * + * Different devices could have offset views of the physical address space. + * + */ + + +/* + * + * +------------+ +------------+ +------------+ +------------+ + * | CPU | | DEV | | DEV | | DEV | + * +------------+ +------------+ +------------+ +------------+ + * | | | | + * | PVOID |IMG_DEV_VIRTADDR |IMG_DEV_VIRTADDR | + * | \-------------------/ | + * | | | + * +------------+ +------------+ | + * | MMU | | MMU | | + * +------------+ +------------+ | + * | | | + * | | | + * | | | + * +--------+ +---------+ +--------+ + * | Offset | | (Offset)| | Offset | + * +--------+ +---------+ +--------+ + * | | IMG_DEV_PHYADDR | + * | | | + * | | IMG_DEV_PHYADDR | + * +---------------------------------------------------------------------+ + * | System Address bus | + * +---------------------------------------------------------------------+ + * + */ typedef IMG_PVOID IMG_CPU_VIRTADDR; +/* device virtual address */ typedef struct _IMG_DEV_VIRTADDR { - + /* device virtual addresses are 32bit for now */ IMG_UINT32 uiAddr; #define IMG_CAST_TO_DEVVADDR_UINT(var) (IMG_UINT32)(var) } IMG_DEV_VIRTADDR; +typedef IMG_UINT32 IMG_DEVMEM_SIZE_T; + +/* cpu physical address */ typedef struct _IMG_CPU_PHYADDR { - + /* variable sized type (32,64) */ IMG_UINTPTR_T uiAddr; } IMG_CPU_PHYADDR; +/* device physical address */ typedef struct _IMG_DEV_PHYADDR { #if IMG_ADDRSPACE_PHYSADDR_BITS == 32 - + /* variable sized type (32,64) */ IMG_UINTPTR_T uiAddr; #else IMG_UINT32 uiAddr; @@ -127,12 +191,16 @@ typedef struct _IMG_DEV_PHYADDR #endif } IMG_DEV_PHYADDR; +/* system physical address */ typedef struct _IMG_SYS_PHYADDR { - + /* variable sized type (32,64) */ IMG_UINTPTR_T uiAddr; } IMG_SYS_PHYADDR; #include "img_defs.h" -#endif +#endif /* __IMG_TYPES_H__ */ +/****************************************************************************** + End of file (img_types.h) +******************************************************************************/ diff --git a/drivers/gpu/pvr/ion.c b/drivers/gpu/pvr/ion.c new file mode 100644 index 0000000..f897ffa --- /dev/null +++ b/drivers/gpu/pvr/ion.c @@ -0,0 +1,104 @@ +/********************************************************************** + * + * 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 + * + *****************************************************************************/ + +#include "ion.h" + +#include "services.h" +#include "servicesint.h" +#include "mutex.h" +#include "lock.h" +#include "mm.h" +#include "handle.h" +#include "perproc.h" +#include "env_perproc.h" +#include "private_data.h" +#include "pvr_debug.h" + +#include <linux/module.h> +#include <linux/file.h> +#include <linux/fs.h> + +extern struct ion_client *gpsIONClient; + +struct ion_handle * +PVRSRVExportFDToIONHandle(int fd, struct ion_client **client) +{ + struct ion_handle *psIONHandle = IMG_NULL; + PVRSRV_FILE_PRIVATE_DATA *psPrivateData; + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + LinuxMemArea *psLinuxMemArea; + PVRSRV_ERROR eError; + struct file *psFile; + + /* Take the bridge mutex so the handle won't be freed underneath us */ + LinuxLockMutex(&gPVRSRVLock); + + psFile = fget(fd); + if(!psFile) + goto err_unlock; + + psPrivateData = psFile->private_data; + if(!psPrivateData) + { + PVR_DPF((PVR_DBG_ERROR, "%s: struct file* has no private_data; " + "invalid export handle", __func__)); + goto err_fput; + } + + eError = PVRSRVLookupHandle(KERNEL_HANDLE_BASE, + (IMG_PVOID *)&psKernelMemInfo, + psPrivateData->hKernelMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to look up MEM_INFO handle", + __func__)); + goto err_fput; + } + + psLinuxMemArea = (LinuxMemArea *)psKernelMemInfo->sMemBlk.hOSMemHandle; + BUG_ON(psLinuxMemArea == IMG_NULL); + + if(psLinuxMemArea->eAreaType != LINUX_MEM_AREA_ION) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Valid handle, but not an ION buffer", + __func__)); + goto err_fput; + } + + psIONHandle = psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle; + if(client) + *client = gpsIONClient; + +err_fput: + fput(psFile); +err_unlock: + /* Allow PVRSRV clients to communicate with srvkm again */ + LinuxUnLockMutex(&gPVRSRVLock); + return psIONHandle; +} + +EXPORT_SYMBOL(PVRSRVExportFDToIONHandle); diff --git a/drivers/gpu/pvr/ion.h b/drivers/gpu/pvr/ion.h new file mode 100644 index 0000000..13f20e6 --- /dev/null +++ b/drivers/gpu/pvr/ion.h @@ -0,0 +1,36 @@ +/********************************************************************** + * + * 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 + * + *****************************************************************************/ + +#ifndef __IMG_LINUX_ION_H__ +#define __IMG_LINUX_ION_H__ + +#include <linux/ion.h> +#include <linux/omap_ion.h> + +struct ion_handle *PVRSRVExportFDToIONHandle(int fd, + struct ion_client **client); + +#endif /* __IMG_LINUX_ION_H__ */ diff --git a/drivers/gpu/pvr/kernelbuffer.h b/drivers/gpu/pvr/kernelbuffer.h index 5243aaf..4cd36d2 100644 --- a/drivers/gpu/pvr/kernelbuffer.h +++ b/drivers/gpu/pvr/kernelbuffer.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/kerneldisplay.h b/drivers/gpu/pvr/kerneldisplay.h index b5c1c7a..76ee4b8 100644 --- a/drivers/gpu/pvr/kerneldisplay.h +++ b/drivers/gpu/pvr/kerneldisplay.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -146,6 +146,35 @@ typedef struct DISPLAYCLASS_FLIP_COMMAND_TAG } DISPLAYCLASS_FLIP_COMMAND; + +typedef struct DISPLAYCLASS_FLIP_COMMAND2_TAG +{ + + IMG_HANDLE hExtDevice; + + + IMG_HANDLE hExtSwapChain; + + + IMG_HANDLE hUnused; + + + IMG_UINT32 ui32SwapInterval; + + + IMG_PVOID pvPrivData; + + + IMG_UINT32 ui32PrivDataLength; + + + IMG_VOID **ppvMemInfos; + + + IMG_UINT32 ui32NumMemInfos; + +} DISPLAYCLASS_FLIP_COMMAND2; + #define DC_FLIP_COMMAND 0 #define DC_STATE_NO_FLUSH_COMMANDS 0 diff --git a/drivers/gpu/pvr/linkage.h b/drivers/gpu/pvr/linkage.h index 7e6d09a..e64012c 100644 --- a/drivers/gpu/pvr/linkage.h +++ b/drivers/gpu/pvr/linkage.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/lists.c b/drivers/gpu/pvr/lists.c index 58389bf..1081781 100644 --- a/drivers/gpu/pvr/lists.c +++ b/drivers/gpu/pvr/lists.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/lists.h b/drivers/gpu/pvr/lists.h index 0d74788..a02307a 100644 --- a/drivers/gpu/pvr/lists.h +++ b/drivers/gpu/pvr/lists.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/lock.h b/drivers/gpu/pvr/lock.h index e0bf5ee..a0854c3 100644 --- a/drivers/gpu/pvr/lock.h +++ b/drivers/gpu/pvr/lock.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/mem.c b/drivers/gpu/pvr/mem.c index a2673d5..746494a 100644 --- a/drivers/gpu/pvr/mem.c +++ b/drivers/gpu/pvr/mem.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -29,15 +29,17 @@ static PVRSRV_ERROR -FreeSharedSysMemCallBack(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) +FreeSharedSysMemCallBack(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bDummy) { PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo = pvParam; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); OSFreePages(psKernelMemInfo->ui32Flags, - psKernelMemInfo->ui32AllocSize, + psKernelMemInfo->uAllocSize, psKernelMemInfo->pvLinAddrKM, psKernelMemInfo->sMemBlk.hOSMemHandle); @@ -54,7 +56,7 @@ FreeSharedSysMemCallBack(IMG_PVOID pvParam, IMG_EXPORT PVRSRV_ERROR PVRSRVAllocSharedSysMemoryKM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_UINT32 ui32Flags, - IMG_SIZE_T ui32Size, + IMG_SIZE_T uSize, PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo) { PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; @@ -73,11 +75,13 @@ PVRSRVAllocSharedSysMemoryKM(PVRSRV_PER_PROCESS_DATA *psPerProc, ui32Flags &= ~PVRSRV_HAP_MAPTYPE_MASK; ui32Flags |= PVRSRV_HAP_MULTI_PROCESS; psKernelMemInfo->ui32Flags = ui32Flags; - psKernelMemInfo->ui32AllocSize = ui32Size; + psKernelMemInfo->uAllocSize = uSize; if(OSAllocPages(psKernelMemInfo->ui32Flags, - psKernelMemInfo->ui32AllocSize, - HOST_PAGESIZE(), + psKernelMemInfo->uAllocSize, + (IMG_UINT32)HOST_PAGESIZE(), + IMG_NULL, + 0, &psKernelMemInfo->pvLinAddrKM, &psKernelMemInfo->sMemBlk.hOSMemHandle) != PVRSRV_OK) @@ -111,11 +115,11 @@ PVRSRVFreeSharedSysMemoryKM(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) if(psKernelMemInfo->sMemBlk.hResItem) { - eError = ResManFreeResByPtr(psKernelMemInfo->sMemBlk.hResItem); + eError = ResManFreeResByPtr(psKernelMemInfo->sMemBlk.hResItem, CLEANUP_WITH_POLL); } else { - eError = FreeSharedSysMemCallBack(psKernelMemInfo, 0); + eError = FreeSharedSysMemCallBack(psKernelMemInfo, 0, CLEANUP_WITH_POLL); } return eError; diff --git a/drivers/gpu/pvr/mem_debug.c b/drivers/gpu/pvr/mem_debug.c index cbe9912..b9cc780 100644 --- a/drivers/gpu/pvr/mem_debug.c +++ b/drivers/gpu/pvr/mem_debug.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -41,8 +41,6 @@ extern "C" - - @@ -187,7 +185,6 @@ extern "C" return eError; } - OSMemSet((IMG_CHAR *)(*ppvCpuVAddr) + TEST_BUFFER_PADDING_STATUS, 0xBB, ui32Size); OSMemSet((IMG_CHAR *)(*ppvCpuVAddr) + ui32Size + TEST_BUFFER_PADDING_STATUS, 0xB2, TEST_BUFFER_PADDING_AFTER); @@ -247,4 +244,4 @@ extern "C" #endif -#endif +#endif diff --git a/drivers/gpu/pvr/metrics.c b/drivers/gpu/pvr/metrics.c index ee5cabd..640eb04 100644 --- a/drivers/gpu/pvr/metrics.c +++ b/drivers/gpu/pvr/metrics.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/metrics.h b/drivers/gpu/pvr/metrics.h index 2632f8d..69e1b3d 100644 --- a/drivers/gpu/pvr/metrics.h +++ b/drivers/gpu/pvr/metrics.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/mm.c b/drivers/gpu/pvr/mm.c index ecaba8e..9054a55 100644 --- a/drivers/gpu/pvr/mm.c +++ b/drivers/gpu/pvr/mm.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,11 +24,14 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#include <linux/version.h> #include <linux/mm.h> #include <linux/vmalloc.h> #include <asm/io.h> @@ -65,7 +68,8 @@ typedef enum { DEBUG_MEM_ALLOC_TYPE_IOREMAP, DEBUG_MEM_ALLOC_TYPE_IO, DEBUG_MEM_ALLOC_TYPE_KMEM_CACHE, - DEBUG_MEM_ALLOC_TYPE_COUNT + DEBUG_MEM_ALLOC_TYPE_COUNT, + DEBUG_MEM_ALLOC_TYPE_ION }DEBUG_MEM_ALLOC_TYPE; typedef struct _DEBUG_MEM_ALLOC_REC @@ -335,10 +339,10 @@ LinuxMMCleanup(IMG_VOID) IMG_VOID * -_KMallocWrapper(IMG_UINT32 ui32ByteSize, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) +_KMallocWrapper(IMG_UINT32 ui32ByteSize, gfp_t uFlags, IMG_CHAR *pszFileName, IMG_UINT32 ui32Line) { IMG_VOID *pvRet; - pvRet = kmalloc(ui32ByteSize, GFP_KERNEL); + pvRet = kmalloc(ui32ByteSize, uFlags); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) if(pvRet) { @@ -395,7 +399,7 @@ DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE eAllocType, psRecord->pvCpuVAddr = pvCpuVAddr; psRecord->ulCpuPAddr = ulCpuPAddr; psRecord->pvPrivateData = pvPrivateData; - psRecord->pid = current->pid; + psRecord->pid = OSGetCurrentProcessIDKM(); psRecord->ui32Bytes = ui32Bytes; psRecord->pszFileName = pszFileName; psRecord->ui32Line = ui32Line; @@ -1073,6 +1077,113 @@ FreeAllocPagesLinuxMemArea(LinuxMemArea *psLinuxMemArea) LinuxMemAreaStructFree(psLinuxMemArea); } +#if defined(CONFIG_ION_OMAP) + +#include "env_perproc.h" + +#include <linux/ion.h> +#include <linux/omap_ion.h> + +extern struct ion_client *gpsIONClient; + +LinuxMemArea * +NewIONLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags, + IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength) +{ + struct omap_ion_tiler_alloc_data sAllocData; + LinuxMemArea *psLinuxMemArea; + u32 *pu32PageAddrs; + int iNumPages; + + psLinuxMemArea = LinuxMemAreaStructAlloc(); + if(!psLinuxMemArea) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate LinuxMemArea struct", __func__)); + goto err_out; + } + + + BUG_ON(ui32PrivDataLength != offsetof(struct omap_ion_tiler_alloc_data, handle)); + memcpy(&sAllocData, pvPrivData, offsetof(struct omap_ion_tiler_alloc_data, handle)); + + if(omap_ion_tiler_alloc(gpsIONClient, &sAllocData) < 0) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to allocate via ion_tiler", __func__)); + goto err_free; + } + + if(omap_tiler_pages(gpsIONClient, sAllocData.handle, &iNumPages, + &pu32PageAddrs) < 0) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to compute tiler pages", __func__)); + goto err_free; + } + + + BUG_ON(ui32Bytes != iNumPages * PAGE_SIZE); + +#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) + DebugMemAllocRecordAdd(DEBUG_MEM_ALLOC_TYPE_ION, + sAllocData.handle, + 0, + 0, + NULL, + PAGE_ALIGN(ui32Bytes), + "unknown", + 0 + ); +#endif + + psLinuxMemArea->eAreaType = LINUX_MEM_AREA_ION; + psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs = (IMG_CPU_PHYADDR *)pu32PageAddrs; + psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle = sAllocData.handle; + psLinuxMemArea->ui32ByteSize = ui32Bytes; + psLinuxMemArea->ui32AreaFlags = ui32AreaFlags; + INIT_LIST_HEAD(&psLinuxMemArea->sMMapOffsetStructList); + + + if(ui32AreaFlags & (PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_UNCACHED)) + { + psLinuxMemArea->bNeedsCacheInvalidate = IMG_TRUE; + } + +#if defined(DEBUG_LINUX_MEM_AREAS) + DebugLinuxMemAreaRecordAdd(psLinuxMemArea, ui32AreaFlags); +#endif + +err_out: + return psLinuxMemArea; + +err_free: + LinuxMemAreaStructFree(psLinuxMemArea); + psLinuxMemArea = IMG_NULL; + goto err_out; +} + + +IMG_VOID +FreeIONLinuxMemArea(LinuxMemArea *psLinuxMemArea) +{ +#if defined(DEBUG_LINUX_MEM_AREAS) + DebugLinuxMemAreaRecordRemove(psLinuxMemArea); +#endif + + ion_free(gpsIONClient, psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle); + +#if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) + DebugMemAllocRecordRemove(DEBUG_MEM_ALLOC_TYPE_ION, + psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle, + __FILE__, __LINE__); +#endif + + + psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs = IMG_NULL; + psLinuxMemArea->uData.sIONTilerAlloc.psIONHandle = IMG_NULL; + + LinuxMemAreaStructFree(psLinuxMemArea); +} + +#endif struct page* LinuxMemAreaOffsetToPage(LinuxMemArea *psLinuxMemArea, @@ -1275,15 +1386,18 @@ LinuxMemAreaDeepFree(LinuxMemArea *psLinuxMemArea) case LINUX_MEM_AREA_IOREMAP: FreeIORemapLinuxMemArea(psLinuxMemArea); break; - case LINUX_MEM_AREA_EXTERNAL_KV: - FreeExternalKVLinuxMemArea(psLinuxMemArea); - break; + case LINUX_MEM_AREA_EXTERNAL_KV: + FreeExternalKVLinuxMemArea(psLinuxMemArea); + break; case LINUX_MEM_AREA_IO: FreeIOLinuxMemArea(psLinuxMemArea); break; case LINUX_MEM_AREA_SUB_ALLOC: FreeSubLinuxMemArea(psLinuxMemArea); break; + case LINUX_MEM_AREA_ION: + FreeIONLinuxMemArea(psLinuxMemArea); + break; default: PVR_DPF((PVR_DBG_ERROR, "%s: Unknown are type (%d)\n", __FUNCTION__, psLinuxMemArea->eAreaType)); @@ -1318,7 +1432,7 @@ DebugLinuxMemAreaRecordAdd(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32Flags) psNewRecord->psLinuxMemArea = psLinuxMemArea; psNewRecord->ui32Flags = ui32Flags; - psNewRecord->pid = current->pid; + psNewRecord->pid = OSGetCurrentProcessIDKM(); List_DEBUG_LINUX_MEM_AREA_REC_Insert(&g_LinuxMemAreaRecords, psNewRecord); } @@ -1487,6 +1601,13 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset) CpuPAddr.uiAddr = VMallocToPhys(pCpuVAddr); break; } + case LINUX_MEM_AREA_ION: + { + IMG_UINT32 ui32PageIndex = PHYS_TO_PFN(ui32ByteOffset); + CpuPAddr = psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs[ui32PageIndex]; + CpuPAddr.uiAddr += ADDR_TO_PAGE_OFFSET(ui32ByteOffset); + break; + } case LINUX_MEM_AREA_ALLOC_PAGES: { struct page *page; @@ -1506,8 +1627,9 @@ LinuxMemAreaToCpuPAddr(LinuxMemArea *psLinuxMemArea, IMG_UINT32 ui32ByteOffset) } default: { - PVR_DPF((PVR_DBG_ERROR, "%s: Unknown LinuxMemArea type (%d)\n", + PVR_DPF((PVR_DBG_ERROR, "%s: Unknown LinuxMemArea type (%d)", __FUNCTION__, psLinuxMemArea->eAreaType)); + dump_stack(); PVR_ASSERT(CpuPAddr.uiAddr); break; } @@ -1526,19 +1648,20 @@ LinuxMemAreaPhysIsContig(LinuxMemArea *psLinuxMemArea) case LINUX_MEM_AREA_IO: return IMG_TRUE; - case LINUX_MEM_AREA_EXTERNAL_KV: - return psLinuxMemArea->uData.sExternalKV.bPhysContig; + case LINUX_MEM_AREA_EXTERNAL_KV: + return psLinuxMemArea->uData.sExternalKV.bPhysContig; + case LINUX_MEM_AREA_ION: case LINUX_MEM_AREA_VMALLOC: case LINUX_MEM_AREA_ALLOC_PAGES: - return IMG_FALSE; + return IMG_FALSE; case LINUX_MEM_AREA_SUB_ALLOC: - return LinuxMemAreaPhysIsContig(psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea); + return LinuxMemAreaPhysIsContig(psLinuxMemArea->uData.sSubAlloc.psParentLinuxMemArea); default: - PVR_DPF((PVR_DBG_ERROR, "%s: Unknown LinuxMemArea type (%d)\n", + PVR_DPF((PVR_DBG_ERROR, "%s: Unknown LinuxMemArea type (%d)", __FUNCTION__, psLinuxMemArea->eAreaType)); break; } @@ -1564,6 +1687,8 @@ LinuxMemAreaTypeToString(LINUX_MEM_AREA_TYPE eMemAreaType) return "LINUX_MEM_AREA_SUB_ALLOC"; case LINUX_MEM_AREA_ALLOC_PAGES: return "LINUX_MEM_AREA_ALLOC_PAGES"; + case LINUX_MEM_AREA_ION: + return "LINUX_MEM_AREA_ION"; default: PVR_ASSERT(0); } diff --git a/drivers/gpu/pvr/mm.h b/drivers/gpu/pvr/mm.h index 047b3ad..dac7815 100644 --- a/drivers/gpu/pvr/mm.h +++ b/drivers/gpu/pvr/mm.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -27,11 +27,14 @@ #ifndef __IMG_LINUX_MM_H__ #define __IMG_LINUX_MM_H__ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#include <linux/version.h> #include <linux/slab.h> #include <linux/mm.h> #include <linux/list.h> @@ -80,7 +83,8 @@ typedef enum { LINUX_MEM_AREA_VMALLOC, LINUX_MEM_AREA_ALLOC_PAGES, LINUX_MEM_AREA_SUB_ALLOC, - LINUX_MEM_AREA_TYPE_COUNT + LINUX_MEM_AREA_TYPE_COUNT, + LINUX_MEM_AREA_ION, }LINUX_MEM_AREA_TYPE; typedef struct _LinuxMemArea LinuxMemArea; @@ -123,6 +127,12 @@ struct _LinuxMemArea { struct page **pvPageList; IMG_HANDLE hBlockPageList; }sPageList; + struct _sIONTilerAlloc + { + + IMG_CPU_PHYADDR *pCPUPhysAddrs; + struct ion_handle *psIONHandle; + }sIONTilerAlloc; struct _sSubAlloc { @@ -160,11 +170,11 @@ IMG_VOID LinuxMMCleanup(IMG_VOID); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) -#define KMallocWrapper(ui32ByteSize) _KMallocWrapper(ui32ByteSize, __FILE__, __LINE__) +#define KMallocWrapper(ui32ByteSize, uFlags) _KMallocWrapper(ui32ByteSize, uFlags, __FILE__, __LINE__) #else -#define KMallocWrapper(ui32ByteSize) _KMallocWrapper(ui32ByteSize, NULL, 0) +#define KMallocWrapper(ui32ByteSize, uFlags) _KMallocWrapper(ui32ByteSize, uFlags, NULL, 0) #endif -IMG_VOID *_KMallocWrapper(IMG_UINT32 ui32ByteSize, IMG_CHAR *szFileName, IMG_UINT32 ui32Line); +IMG_VOID *_KMallocWrapper(IMG_UINT32 ui32ByteSize, gfp_t uFlags, IMG_CHAR *szFileName, IMG_UINT32 ui32Line); #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) @@ -276,6 +286,38 @@ LinuxMemArea *NewAllocPagesLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32Are IMG_VOID FreeAllocPagesLinuxMemArea(LinuxMemArea *psLinuxMemArea); +#if defined(CONFIG_ION_OMAP) + +LinuxMemArea * +NewIONLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags, + IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength); + + +IMG_VOID FreeIONLinuxMemArea(LinuxMemArea *psLinuxMemArea); + +#else + +static inline LinuxMemArea * +NewIONLinuxMemArea(IMG_UINT32 ui32Bytes, IMG_UINT32 ui32AreaFlags, + IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength) +{ + PVR_UNREFERENCED_PARAMETER(ui32Bytes); + PVR_UNREFERENCED_PARAMETER(ui32AreaFlags); + PVR_UNREFERENCED_PARAMETER(pvPrivData); + PVR_UNREFERENCED_PARAMETER(ui32PrivDataLength); + BUG(); + return IMG_NULL; +} + +static inline IMG_VOID FreeIONLinuxMemArea(LinuxMemArea *psLinuxMemArea) +{ + PVR_UNREFERENCED_PARAMETER(psLinuxMemArea); + BUG(); +} + +#endif + + LinuxMemArea *NewSubLinuxMemArea(LinuxMemArea *psParentLinuxMemArea, IMG_UINT32 ui32ByteOffset, IMG_UINT32 ui32Bytes); diff --git a/drivers/gpu/pvr/mmap.c b/drivers/gpu/pvr/mmap.c index 66cef26..d2a09a7 100644 --- a/drivers/gpu/pvr/mmap.c +++ b/drivers/gpu/pvr/mmap.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,11 +24,14 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#include <linux/version.h> #include <linux/mm.h> #include <linux/module.h> #include <linux/vmalloc.h> @@ -36,6 +39,9 @@ #include <linux/wrapper.h> #endif #include <linux/slab.h> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) +#include <linux/highmem.h> +#endif #include <asm/io.h> #include <asm/page.h> #include <asm/shmparam.h> @@ -67,11 +73,11 @@ #include "pvr_drm.h" #endif -#if !defined(PVR_SECURE_HANDLES) +#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) #error "The mmap code requires PVR_SECURE_HANDLES" #endif -static PVRSRV_LINUX_MUTEX g_sMMapMutex; +PVRSRV_LINUX_MUTEX g_sMMapMutex; static LinuxKMemCache *g_psMemmapCache = NULL; static LIST_HEAD(g_sMMapAreaList); @@ -146,7 +152,11 @@ MMapOffsetToHandle(IMG_UINT32 pfn) #endif static inline IMG_UINT32 +#if defined (SUPPORT_SID_INTERFACE) +HandleToMMapOffset(IMG_SID hHandle) +#else HandleToMMapOffset(IMG_HANDLE hHandle) +#endif { IMG_UINT32 ulHandle = (IMG_UINT32)hHandle; @@ -270,11 +280,15 @@ DetermineUsersSizeAndByteOffset(LinuxMemArea *psLinuxMemArea, PVRSRV_ERROR PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, - IMG_HANDLE hMHandle, - IMG_UINT32 *pui32MMapOffset, - IMG_UINT32 *pui32ByteOffset, - IMG_UINT32 *pui32RealByteSize, - IMG_UINT32 *pui32UserVAddr) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMHandle, +#else + IMG_HANDLE hMHandle, +#endif + IMG_UINT32 *pui32MMapOffset, + IMG_UINT32 *pui32ByteOffset, + IMG_UINT32 *pui32RealByteSize, + IMG_UINT32 *pui32UserVAddr) { LinuxMemArea *psLinuxMemArea; PKV_OFFSET_STRUCT psOffsetStruct; @@ -288,9 +302,13 @@ PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, eError = PVRSRVLookupOSMemHandle(psPerProc->psHandleBase, &hOSMemHandle, hMHandle); if (eError != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %p failed", __FUNCTION__, hMHandle)); +#if defined (SUPPORT_SID_INTERFACE) + PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %x failed", __FUNCTION__, hMHandle)); +#else + PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %p failed", __FUNCTION__, hMHandle)); +#endif - goto exit_unlock; + goto exit_unlock; } psLinuxMemArea = (LinuxMemArea *)hOSMemHandle; @@ -364,7 +382,11 @@ exit_unlock: PVRSRV_ERROR PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMHandle, +#else IMG_HANDLE hMHandle, +#endif IMG_BOOL *pbMUnmap, IMG_UINT32 *pui32RealByteSize, IMG_UINT32 *pui32UserVAddr) @@ -382,7 +404,11 @@ PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, eError = PVRSRVLookupOSMemHandle(psPerProc->psHandleBase, &hOSMemHandle, hMHandle); if (eError != PVRSRV_OK) { +#if defined (SUPPORT_SID_INTERFACE) + PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %x failed", __FUNCTION__, hMHandle)); +#else PVR_DPF((PVR_DBG_ERROR, "%s: Lookup of handle %p failed", __FUNCTION__, hMHandle)); +#endif goto exit_unlock; } @@ -414,7 +440,11 @@ PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, } +#if defined (SUPPORT_SID_INTERFACE) + PVR_DPF((PVR_DBG_ERROR, "%s: Mapping data not found for handle %x (memory area %p)", __FUNCTION__, hMHandle, psLinuxMemArea)); +#else PVR_DPF((PVR_DBG_ERROR, "%s: Mapping data not found for handle %p (memory area %p)", __FUNCTION__, hMHandle, psLinuxMemArea)); +#endif eError = PVRSRV_ERROR_MAPPING_NOT_FOUND; @@ -590,10 +620,6 @@ MMapVOpenNoLock(struct vm_area_struct* ps_vma) psOffsetStruct->ui32MMapOffset, psOffsetStruct->ui32Mapped)); #endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) - MOD_INC_USE_COUNT; -#endif } @@ -637,10 +663,6 @@ MMapVCloseNoLock(struct vm_area_struct* ps_vma) } ps_vma->vm_private_data = NULL; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) - MOD_DEC_USE_COUNT; -#endif } static void @@ -653,19 +675,80 @@ MMapVClose(struct vm_area_struct* ps_vma) LinuxUnLockMutex(&g_sMMapMutex); } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) +static int MMapVAccess(struct vm_area_struct *ps_vma, unsigned long addr, + void *buf, int len, int write) +{ + PKV_OFFSET_STRUCT psOffsetStruct; + LinuxMemArea *psLinuxMemArea; + unsigned long ulOffset; + int iRetVal = -EINVAL; + IMG_VOID *pvKernelAddr; + + LinuxLockMutex(&g_sMMapMutex); + + psOffsetStruct = (PKV_OFFSET_STRUCT)ps_vma->vm_private_data; + psLinuxMemArea = psOffsetStruct->psLinuxMemArea; + ulOffset = addr - ps_vma->vm_start; + + if (ulOffset+len > psLinuxMemArea->ui32ByteSize) + + goto exit_unlock; + + pvKernelAddr = LinuxMemAreaToCpuVAddr(psLinuxMemArea); + + if (pvKernelAddr) + { + memcpy(buf, pvKernelAddr+ulOffset, len); + iRetVal = len; + } + else + { + IMG_UINT32 pfn, ui32OffsetInPage; + struct page *page; + + pfn = LinuxMemAreaToCpuPFN(psLinuxMemArea, ulOffset); + + if (!pfn_valid(pfn)) + goto exit_unlock; + + page = pfn_to_page(pfn); + ui32OffsetInPage = ADDR_TO_PAGE_OFFSET(ulOffset); + + if (ui32OffsetInPage+len > PAGE_SIZE) + + goto exit_unlock; + + pvKernelAddr = kmap(page); + memcpy(buf, pvKernelAddr+ui32OffsetInPage, len); + kunmap(page); + + iRetVal = len; + } + +exit_unlock: + LinuxUnLockMutex(&g_sMMapMutex); + return iRetVal; +} +#endif static struct vm_operations_struct MMapIOOps = { .open=MMapVOpen, - .close=MMapVClose + .close=MMapVClose, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + .access=MMapVAccess, +#endif }; int PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) { - IMG_UINT32 ui32ByteSize; + LinuxMemArea *psFlushMemArea = IMG_NULL; PKV_OFFSET_STRUCT psOffsetStruct; + IMG_UINT32 ui32ByteSize; + IMG_VOID *pvBase = IMG_NULL; int iRetVal = 0; PVR_UNREFERENCED_PARAMETER(pFile); @@ -687,11 +770,11 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) LinuxUnLockMutex(&g_sMMapMutex); #if !defined(SUPPORT_DRI_DRM_EXT) - + return drm_mmap(pFile, ps_vma); #else - - return -ENOENT; + + return -ENOENT; #endif #else PVR_UNREFERENCED_PARAMETER(pFile); @@ -703,6 +786,7 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) #endif goto unlock_and_return; } + list_del(&psOffsetStruct->sMMapItem); psOffsetStruct->bOnMMapList = IMG_FALSE; @@ -735,14 +819,14 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) break; case PVRSRV_HAP_WRITECOMBINE: - ps_vma->vm_page_prot = PGPROT_WC(ps_vma->vm_page_prot); + ps_vma->vm_page_prot = PGPROT_WC(ps_vma->vm_page_prot); break; case PVRSRV_HAP_UNCACHED: ps_vma->vm_page_prot = PGPROT_UC(ps_vma->vm_page_prot); break; default: PVR_DPF((PVR_DBG_ERROR, "%s: unknown cache type", __FUNCTION__)); - iRetVal = -EINVAL; + iRetVal = -EINVAL; goto unlock_and_return; } @@ -762,35 +846,38 @@ PVRMMap(struct file* pFile, struct vm_area_struct* ps_vma) if(psOffsetStruct->psLinuxMemArea->bNeedsCacheInvalidate) { - IMG_UINT32 ui32RealByteSize, ui32ByteOffset; - IMG_VOID *pvBase; + IMG_UINT32 ui32ByteOffset, ui32DummyByteSize; DetermineUsersSizeAndByteOffset(psOffsetStruct->psLinuxMemArea, - &ui32RealByteSize, + &ui32DummyByteSize, &ui32ByteOffset); - ui32RealByteSize = psOffsetStruct->psLinuxMemArea->ui32ByteSize; pvBase = (IMG_VOID *)ps_vma->vm_start + ui32ByteOffset; + psFlushMemArea = psOffsetStruct->psLinuxMemArea; - OSInvalidateCPUCacheRangeKM(psOffsetStruct->psLinuxMemArea, - pvBase, ui32RealByteSize); psOffsetStruct->psLinuxMemArea->bNeedsCacheInvalidate = IMG_FALSE; } MMapVOpenNoLock(ps_vma); - + PVR_DPF((PVR_DBG_MESSAGE, "%s: Mapped area at offset 0x%08lx\n", __FUNCTION__, ps_vma->vm_pgoff)); - + unlock_and_return: if (iRetVal != 0 && psOffsetStruct != IMG_NULL) { - DestroyOffsetStruct(psOffsetStruct); + DestroyOffsetStruct(psOffsetStruct); } LinuxUnLockMutex(&g_sMMapMutex); - + + if(psFlushMemArea) + { + OSInvalidateCPUCacheRangeKM(psFlushMemArea, pvBase, + psFlushMemArea->ui32ByteSize); + } + return iRetVal; } diff --git a/drivers/gpu/pvr/mmap.h b/drivers/gpu/pvr/mmap.h index 486154a..224e652 100644 --- a/drivers/gpu/pvr/mmap.h +++ b/drivers/gpu/pvr/mmap.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -94,14 +94,23 @@ PVRSRV_ERROR PVRMMapRemoveRegisteredArea(LinuxMemArea *psLinuxMemArea); PVRSRV_ERROR PVRMMapOSMemHandleToMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, - IMG_HANDLE hMHandle, - IMG_UINT32 *pui32MMapOffset, - IMG_UINT32 *pui32ByteOffset, - IMG_UINT32 *pui32RealByteSize, IMG_UINT32 *pui32UserVAddr); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMHandle, +#else + IMG_HANDLE hMHandle, +#endif + IMG_UINT32 *pui32MMapOffset, + IMG_UINT32 *pui32ByteOffset, + IMG_UINT32 *pui32RealByteSize, + IMG_UINT32 *pui32UserVAddr); PVRSRV_ERROR PVRMMapReleaseMMapData(PVRSRV_PER_PROCESS_DATA *psPerProc, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMHandle, +#else IMG_HANDLE hMHandle, +#endif IMG_BOOL *pbMUnmap, IMG_UINT32 *pui32RealByteSize, IMG_UINT32 *pui32UserVAddr); diff --git a/drivers/gpu/pvr/module.c b/drivers/gpu/pvr/module.c index 7263ba5..ff5eed5 100644 --- a/drivers/gpu/pvr/module.c +++ b/drivers/gpu/pvr/module.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,11 +24,17 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#if !defined(SUPPORT_DRI_DRM) +#if defined(SUPPORT_DRI_DRM) && !defined(SUPPORT_DRI_DRM_PLUGIN) +#define PVR_MOD_STATIC +#else #if defined(LDM_PLATFORM) #define PVR_LDM_PLATFORM_MODULE @@ -39,12 +45,18 @@ #define PVR_LDM_MODULE #endif #endif +#define PVR_MOD_STATIC static +#endif + +#if defined(PVR_LDM_PLATFORM_PRE_REGISTERED) +#if !defined(NO_HARDWARE) +#define PVR_USE_PRE_REGISTERED_PLATFORM_DEV +#endif #endif #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/version.h> #include <linux/fs.h> #include <linux/proc_fs.h> @@ -63,12 +75,6 @@ #include <linux/pci.h> #endif -#if defined(SLSI_S5PC110) && defined(CONFIG_HAS_EARLYSUSPEND) -#include <linux/earlysuspend.h> -#include <linux/suspend.h> -#include <linux/errno.h> -#endif - #if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) #include <asm/uaccess.h> #endif @@ -93,16 +99,13 @@ #include "private_data.h" #include "lock.h" #include "linkage.h" -#if defined(SLSI_S5PC110) -/*zepplin 2010.03.04 */ -#include "sysconfig.h" - -#endif #if defined(SUPPORT_DRI_DRM) #include "pvr_drm.h" #endif -#define DRVNAME PVRSRV_MODNAME +#if defined(PVR_LDM_MODULE) +#define DRVNAME PVR_LDM_DRIVER_REGISTRATION_NAME +#endif #define DEVNAME PVRSRV_MODNAME #if defined(SUPPORT_DRI_DRM) @@ -120,11 +123,18 @@ module_param(gPVRDebugLevel, uint, 0644); MODULE_PARM_DESC(gPVRDebugLevel, "Sets the level of debug output (default 0x7)"); #endif +#if defined(CONFIG_ION_OMAP) +#include <linux/ion.h> +#include <linux/omap_ion.h> +extern struct ion_device *omap_ion_device; +struct ion_client *gpsIONClient; +#endif + EXPORT_SYMBOL(PVRGetDisplayClassJTable); EXPORT_SYMBOL(PVRGetBufferClassJTable); -#if defined(PVR_LDM_MODULE) +#if defined(PVR_LDM_MODULE) && !defined(SUPPORT_DRI_DRM) static struct class *psPvrClass; #endif @@ -136,11 +146,11 @@ static int PVRSRVRelease(struct inode* pInode, struct file* pFile); static struct file_operations pvrsrv_fops = { - .owner = THIS_MODULE, + .owner=THIS_MODULE, .unlocked_ioctl = PVRSRV_BridgeDispatchKM, - .open = PVRSRVOpen, - .release = PVRSRVRelease, - .mmap = PVRMMap, + .open=PVRSRVOpen, + .release=PVRSRVRelease, + .mmap=PVRMMap, }; #endif @@ -152,10 +162,6 @@ IMG_UINT32 gui32ReleasePID; static IMG_UINT32 gPVRPowerLevel; #endif -#if defined(SLSI_S5PC110) -#define SLSI_POWER_GATING -#endif - #if defined(PVR_LDM_MODULE) #if defined(PVR_LDM_PLATFORM_MODULE) @@ -167,7 +173,6 @@ static IMG_UINT32 gPVRPowerLevel; #define LDM_DEV struct pci_dev #define LDM_DRV struct pci_driver #endif - #if defined(PVR_LDM_PLATFORM_MODULE) static int PVRSRVDriverRemove(LDM_DEV *device); static int PVRSRVDriverProbe(LDM_DEV *device); @@ -182,16 +187,23 @@ static int PVRSRVDriverResume(LDM_DEV *device); #if defined(PVR_LDM_PCI_MODULE) struct pci_device_id powervr_id_table[] __devinitdata = { - { PCI_DEVICE(SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV_DEVICE_ID) }, + {PCI_DEVICE(SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV_DEVICE_ID)}, #if defined (SYS_SGX_DEV1_DEVICE_ID) - { PCI_DEVICE(SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV1_DEVICE_ID) }, + {PCI_DEVICE(SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV1_DEVICE_ID)}, #endif - { 0 } + {0} }; MODULE_DEVICE_TABLE(pci, powervr_id_table); #endif +#if defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) +static struct platform_device_id powervr_id_table[] __devinitdata = { + {SYS_SGX_DEV_NAME, 0}, + {} +}; +#endif + static LDM_DRV powervr_driver = { #if defined(PVR_LDM_PLATFORM_MODULE) .driver = { @@ -200,6 +212,8 @@ static LDM_DRV powervr_driver = { #endif #if defined(PVR_LDM_PCI_MODULE) .name = DRVNAME, +#endif +#if defined(PVR_LDM_PCI_MODULE) || defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) .id_table = powervr_id_table, #endif .probe = PVRSRVDriverProbe, @@ -209,25 +223,16 @@ static LDM_DRV powervr_driver = { #if defined(PVR_LDM_PCI_MODULE) .remove = __devexit_p(PVRSRVDriverRemove), #endif - -#if defined(SLSI_S5PC110) -//#ifndef CONFIG_HAS_EARLYSUSPEND .suspend = PVRSRVDriverSuspend, .resume = PVRSRVDriverResume, -//#endif -#endif .shutdown = PVRSRVDriverShutdown, }; LDM_DEV *gpsPVRLDMDev; -#if 0// defined(SLSI_S5PC110) && defined(CONFIG_HAS_EARLYSUSPEND) -struct early_suspend s5pc110_g3d_early_suspend; -#endif - -#if defined(MODULE) && defined(PVR_LDM_PLATFORM_MODULE) - -static IMG_VOID PVRSRVDeviceRelease(struct device unref__ *pDevice) +#if defined(MODULE) && defined(PVR_LDM_PLATFORM_MODULE) && \ + !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) +static void PVRSRVDeviceRelease(struct device unref__ *pDevice) { } @@ -238,8 +243,7 @@ static struct platform_device powervr_device = { .release = PVRSRVDeviceRelease } }; - -#endif +#endif #if defined(PVR_LDM_PLATFORM_MODULE) static int PVRSRVDriverProbe(LDM_DEV *pDevice) @@ -261,16 +265,27 @@ static int __devinit PVRSRVDriverProbe(LDM_DEV *pDevice, const struct pci_device #endif psSysData = SysAcquireDataNoCheck(); - if ( psSysData == IMG_NULL) + if (psSysData == IMG_NULL) { gpsPVRLDMDev = pDevice; - if (SysInitialise() != PVRSRV_OK) { return -ENODEV; } } +#if defined(CONFIG_ION_OMAP) + gpsIONClient = ion_client_create(omap_ion_device, + 1 << ION_HEAP_TYPE_CARVEOUT | + 1 << OMAP_ION_HEAP_TYPE_TILER, + "pvr"); + if (IS_ERR_OR_NULL(gpsIONClient)) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVDriverProbe: Couldn't create ion client")); + return PTR_ERR(gpsIONClient); + } +#endif + return 0; } @@ -286,6 +301,11 @@ static void __devexit PVRSRVDriverRemove(LDM_DEV *pDevice) PVR_TRACE(("PVRSRVDriverRemove(pDevice=%p)", pDevice)); +#if defined(CONFIG_ION_OMAP) + ion_client_destroy(gpsIONClient); + gpsIONClient = IMG_NULL; +#endif + SysAcquireData(&psSysData); #if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) @@ -297,7 +317,7 @@ static void __devexit PVRSRVDriverRemove(LDM_DEV *pDevice) } } #endif - (IMG_VOID)SysDeinitialise(psSysData); + (void) SysDeinitialise(psSysData); gpsPVRLDMDev = IMG_NULL; @@ -315,23 +335,31 @@ static void __devexit PVRSRVDriverRemove(LDM_DEV *pDevice) return; #endif } +#endif -static IMG_VOID PVRSRVDriverShutdown(LDM_DEV *pDevice) +#if defined(PVR_LDM_MODULE) || defined(PVR_DRI_DRM_PLATFORM_DEV) +#if defined(SUPPORT_DRI_DRM) && !defined(PVR_DRI_DRM_PLATFORM_DEV) && \ + !defined(SUPPORT_DRI_DRM_PLUGIN) +void PVRSRVDriverShutdown(struct drm_device *pDevice) +#else +PVR_MOD_STATIC void PVRSRVDriverShutdown(LDM_DEV *pDevice) +#endif { PVR_TRACE(("PVRSRVDriverShutdown(pDevice=%p)", pDevice)); - (IMG_VOID) PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D3); + (void) PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D3); } #endif #if defined(PVR_LDM_MODULE) || defined(SUPPORT_DRI_DRM) -#if defined(SUPPORT_DRI_DRM) +#if defined(SUPPORT_DRI_DRM) && !defined(PVR_DRI_DRM_PLATFORM_DEV) && \ + !defined(SUPPORT_DRI_DRM_PLUGIN) int PVRSRVDriverSuspend(struct drm_device *pDevice, pm_message_t state) #else -static int PVRSRVDriverSuspend(LDM_DEV *pDevice, pm_message_t state) +PVR_MOD_STATIC int PVRSRVDriverSuspend(LDM_DEV *pDevice, pm_message_t state) #endif { #if !(defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) && !defined(SUPPORT_DRI_DRM)) @@ -346,10 +374,11 @@ static int PVRSRVDriverSuspend(LDM_DEV *pDevice, pm_message_t state) } -#if defined(SUPPORT_DRI_DRM) +#if defined(SUPPORT_DRI_DRM) && !defined(PVR_DRI_DRM_PLATFORM_DEV) && \ + !defined(SUPPORT_DRI_DRM_PLUGIN) int PVRSRVDriverResume(struct drm_device *pDevice) #else -static int PVRSRVDriverResume(LDM_DEV *pDevice) +PVR_MOD_STATIC int PVRSRVDriverResume(LDM_DEV *pDevice) #endif { #if !(defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) && !defined(SUPPORT_DRI_DRM)) @@ -452,7 +481,9 @@ static int PVRSRVOpen(struct inode unref__ * pInode, struct file *pFile) if(eError != PVRSRV_OK) goto err_unlock; -#if defined(PVR_SECURE_FD_EXPORT) +#if defined (SUPPORT_SID_INTERFACE) + psPrivateData->hKernelMemInfo = 0; +#else psPrivateData->hKernelMemInfo = NULL; #endif #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) @@ -477,6 +508,7 @@ static int PVRSRVRelease(struct inode unref__ * pInode, struct file *pFile) #endif { PVRSRV_FILE_PRIVATE_DATA *psPrivateData; + int err = 0; LinuxLockMutex(&gPVRSRVLock); @@ -491,6 +523,31 @@ static int PVRSRVRelease(struct inode unref__ * pInode, struct file *pFile) list_del(&psPrivateData->sDRMAuthListItem); #endif + if(psPrivateData->hKernelMemInfo) + { + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + + + if(PVRSRVLookupHandle(KERNEL_HANDLE_BASE, + (IMG_PVOID *)&psKernelMemInfo, + psPrivateData->hKernelMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to look up export handle", __FUNCTION__)); + err = -EFAULT; + goto err_unlock; + } + + + if(FreeMemCallBackCommon(psKernelMemInfo, 0, + PVRSRV_FREE_CALLBACK_ORIGIN_EXTERNAL) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: FreeMemCallBackCommon failed", __FUNCTION__)); + err = -EFAULT; + goto err_unlock; + } + } + gui32ReleasePID = psPrivateData->ui32OpenPID; PVRSRVProcessDisconnect(psPrivateData->ui32OpenPID); @@ -505,26 +562,30 @@ static int PVRSRVRelease(struct inode unref__ * pInode, struct file *pFile) #endif } +err_unlock: LinuxUnLockMutex(&gPVRSRVLock); - -#if !defined(SUPPORT_DRI_DRM) - return 0; +#if defined(SUPPORT_DRI_DRM) + return; +#else + return err; #endif } #if defined(SUPPORT_DRI_DRM) -int PVRCore_Init(IMG_VOID) +int PVRCore_Init(void) #else -static int __init PVRCore_Init(IMG_VOID) +static int __init PVRCore_Init(void) #endif { int error; #if !defined(PVR_LDM_MODULE) PVRSRV_ERROR eError; #else +#if !defined(SUPPORT_DRI_DRM) struct device *psDev; #endif +#endif #if !defined(SUPPORT_DRI_DRM) @@ -560,7 +621,7 @@ static int __init PVRCore_Init(IMG_VOID) #if defined(PVR_LDM_MODULE) -#if defined(PVR_LDM_PLATFORM_MODULE) +#if defined(PVR_LDM_PLATFORM_MODULE) || defined(SUPPORT_DRI_DRM_PLUGIN) if ((error = platform_driver_register(&powervr_driver)) != 0) { PVR_DPF((PVR_DBG_ERROR, "PVRCore_Init: unable to register platform driver (%d)", error)); @@ -568,7 +629,7 @@ static int __init PVRCore_Init(IMG_VOID) goto init_failed; } -#if defined(MODULE) +#if defined(MODULE) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) if ((error = platform_device_register(&powervr_device)) != 0) { platform_driver_unregister(&powervr_driver); @@ -588,8 +649,9 @@ static int __init PVRCore_Init(IMG_VOID) goto init_failed; } #endif +#endif -#else +#if !defined(PVR_LDM_MODULE) if ((eError = SysInitialise()) != PVRSRV_OK) { @@ -617,7 +679,6 @@ static int __init PVRCore_Init(IMG_VOID) } PVR_TRACE(("PVRCore_Init: major device %d", AssignedMajorNumber)); -#endif #if defined(PVR_LDM_MODULE) @@ -642,16 +703,17 @@ static int __init PVRCore_Init(IMG_VOID) goto destroy_class; } #endif +#endif return 0; +#if !defined(SUPPORT_DRI_DRM) #if defined(PVR_LDM_MODULE) destroy_class: class_destroy(psPvrClass); unregister_device: - unregister_chrdev((IMG_UINT)AssignedMajorNumber, DRVNAME); + unregister_chrdev((IMG_UINT)AssignedMajorNumber, DEVNAME); #endif -#if !defined(SUPPORT_DRI_DRM) sys_deinit: #endif #if defined(PVR_LDM_MODULE) @@ -660,7 +722,7 @@ sys_deinit: #endif #if defined (PVR_LDM_PLATFORM_MODULE) -#if defined (MODULE) +#if defined(MODULE) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) platform_device_unregister(&powervr_device); #endif platform_driver_unregister(&powervr_driver); @@ -674,7 +736,7 @@ sys_deinit: psSysData = SysAcquireDataNoCheck(); if (psSysData != IMG_NULL) { - (IMG_VOID)SysDeinitialise(psSysData); + (void) SysDeinitialise(psSysData); } } #endif @@ -696,22 +758,26 @@ void PVRCore_Cleanup(void) static void __exit PVRCore_Cleanup(void) #endif { +#if !defined(PVR_LDM_MODULE) SYS_DATA *psSysData; - +#endif PVR_TRACE(("PVRCore_Cleanup")); +#if !defined(PVR_LDM_MODULE) SysAcquireData(&psSysData); +#endif + +#if !defined(SUPPORT_DRI_DRM) #if defined(PVR_LDM_MODULE) device_destroy(psPvrClass, MKDEV(AssignedMajorNumber, 0)); class_destroy(psPvrClass); #endif -#if !defined(SUPPORT_DRI_DRM) #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22)) if ( #endif - unregister_chrdev((IMG_UINT)AssignedMajorNumber, DRVNAME) + unregister_chrdev((IMG_UINT)AssignedMajorNumber, DEVNAME) #if !(LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22)) ; #else @@ -729,7 +795,7 @@ static void __exit PVRCore_Cleanup(void) #endif #if defined (PVR_LDM_PLATFORM_MODULE) -#if defined (MODULE) +#if defined(MODULE) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV) platform_device_unregister(&powervr_device); #endif platform_driver_unregister(&powervr_driver); diff --git a/drivers/gpu/pvr/mutex.c b/drivers/gpu/pvr/mutex.c index 09963ad..742fa03 100644 --- a/drivers/gpu/pvr/mutex.c +++ b/drivers/gpu/pvr/mutex.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/mutex.h b/drivers/gpu/pvr/mutex.h index b24a599..5e787b7 100644 --- a/drivers/gpu/pvr/mutex.h +++ b/drivers/gpu/pvr/mutex.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/mutils.c b/drivers/gpu/pvr/mutils.c index 83eab51..a012cf5 100644 --- a/drivers/gpu/pvr/mutils.c +++ b/drivers/gpu/pvr/mutils.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,10 +24,13 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED #include <linux/config.h> #endif -#include <linux/version.h> +#endif #include <linux/spinlock.h> #include <linux/mm.h> diff --git a/drivers/gpu/pvr/mutils.h b/drivers/gpu/pvr/mutils.h index 943c2bd..b2a8ba0 100644 --- a/drivers/gpu/pvr/mutils.h +++ b/drivers/gpu/pvr/mutils.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -27,11 +27,13 @@ #ifndef __IMG_LINUX_MUTILS_H__ #define __IMG_LINUX_MUTILS_H__ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED #include <linux/config.h> #endif - -#include <linux/version.h> +#endif #if !(defined(__i386__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))) #if defined(SUPPORT_LINUX_X86_PAT) @@ -46,7 +48,7 @@ #if defined(__arm__) || defined(__sh__) #define PGPROT_WC(pv) pgprot_writecombine(pv) #else - #if defined(__i386__) + #if defined(__i386__) || defined(__mips__) #define PGPROT_WC(pv) pgprot_noncached(pv) #else #define PGPROT_WC(pv) pgprot_noncached(pv) diff --git a/drivers/gpu/pvr/ocpdefs.h b/drivers/gpu/pvr/ocpdefs.h index 43744e3..3bbab7b 100644 --- a/drivers/gpu/pvr/ocpdefs.h +++ b/drivers/gpu/pvr/ocpdefs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/osfunc.c b/drivers/gpu/pvr/osfunc.c index 8ee4d6a..6adfb55 100644 --- a/drivers/gpu/pvr/osfunc.c +++ b/drivers/gpu/pvr/osfunc.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,11 +24,14 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#include <linux/version.h> #include <asm/io.h> #include <asm/page.h> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)) @@ -81,10 +84,11 @@ #error "A preemptible Linux kernel is required when using workqueues" #endif -#define EVENT_OBJECT_TIMEOUT_MS (300) - -#define HOST_ALLOC_MEM_USING_KMALLOC ((IMG_HANDLE)0) -#define HOST_ALLOC_MEM_USING_VMALLOC ((IMG_HANDLE)1) +#if defined(EMULATOR) +#define EVENT_OBJECT_TIMEOUT_MS (2000) +#else +#define EVENT_OBJECT_TIMEOUT_MS (100) +#endif #if !defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID *ppvCpuVAddr, IMG_HANDLE *phBlockAlloc) @@ -93,46 +97,45 @@ PVRSRV_ERROR OSAllocMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOI #endif { PVR_UNREFERENCED_PARAMETER(ui32Flags); + PVR_UNREFERENCED_PARAMETER(phBlockAlloc); + if (ui32Size > PAGE_SIZE) + { + #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - *ppvCpuVAddr = _KMallocWrapper(ui32Size, pszFilename, ui32Line); + *ppvCpuVAddr = _VMallocWrapper(ui32Size, PVRSRV_HAP_CACHED, pszFilename, ui32Line); #else - *ppvCpuVAddr = KMallocWrapper(ui32Size); + *ppvCpuVAddr = VMallocWrapper(ui32Size, PVRSRV_HAP_CACHED); #endif - if(*ppvCpuVAddr) - { - if (phBlockAlloc) - { - - *phBlockAlloc = HOST_ALLOC_MEM_USING_KMALLOC; - } - } - else - { - if (!phBlockAlloc) - { - return PVRSRV_ERROR_OUT_OF_MEMORY; + if (*ppvCpuVAddr) + { + return PVRSRV_OK; + } } - #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - *ppvCpuVAddr = _VMallocWrapper(ui32Size, PVRSRV_HAP_CACHED, pszFilename, ui32Line); + *ppvCpuVAddr = _KMallocWrapper(ui32Size, GFP_KERNEL | __GFP_NOWARN, pszFilename, ui32Line); #else - *ppvCpuVAddr = VMallocWrapper(ui32Size, PVRSRV_HAP_CACHED); + *ppvCpuVAddr = KMallocWrapper(ui32Size, GFP_KERNEL | __GFP_NOWARN); #endif if (!*ppvCpuVAddr) { - return PVRSRV_ERROR_OUT_OF_MEMORY; - } - - - *phBlockAlloc = HOST_ALLOC_MEM_USING_VMALLOC; + return PVRSRV_ERROR_OUT_OF_MEMORY; } return PVRSRV_OK; } - +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24)) + +static inline int is_vmalloc_addr(const void *pvCpuVAddr) +{ + unsigned long lAddr = (unsigned long)pvCpuVAddr; + return lAddr >= VMALLOC_START && lAddr < VMALLOC_END; +} + +#endif + #if !defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID pvCpuVAddr, IMG_HANDLE hBlockAlloc) #else @@ -141,19 +144,20 @@ PVRSRV_ERROR OSFreeMem_Impl(IMG_UINT32 ui32Flags, IMG_UINT32 ui32Size, IMG_PVOID { PVR_UNREFERENCED_PARAMETER(ui32Flags); PVR_UNREFERENCED_PARAMETER(ui32Size); + PVR_UNREFERENCED_PARAMETER(hBlockAlloc); - if (hBlockAlloc == HOST_ALLOC_MEM_USING_VMALLOC) + if (is_vmalloc_addr(pvCpuVAddr)) { #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - _VFreeWrapper(pvCpuVAddr, pszFilename, ui32Line); + _VFreeWrapper(pvCpuVAddr, pszFilename, ui32Line); #else - VFreeWrapper(pvCpuVAddr); + VFreeWrapper(pvCpuVAddr); #endif } else { #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - _KFreeWrapper(pvCpuVAddr, pszFilename, ui32Line); + _KFreeWrapper(pvCpuVAddr, pszFilename, ui32Line); #else KFreeWrapper(pvCpuVAddr); #endif @@ -167,6 +171,8 @@ PVRSRV_ERROR OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, IMG_UINT32 ui32Size, IMG_UINT32 ui32PageSize, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle) { @@ -183,6 +189,22 @@ OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, } #endif + if(ui32AllocFlags & PVRSRV_MEM_ION) + { + + BUG_ON((ui32AllocFlags & PVRSRV_HAP_MAPTYPE_MASK) != PVRSRV_HAP_SINGLE_PROCESS); + + psLinuxMemArea = NewIONLinuxMemArea(ui32Size, ui32AllocFlags, + pvPrivData, ui32PrivDataLength); + if(!psLinuxMemArea) + { + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + + PVRMMapRegisterArea(psLinuxMemArea); + goto ExitSkipSwitch; + } + switch(ui32AllocFlags & PVRSRV_HAP_MAPTYPE_MASK) { case PVRSRV_HAP_KERNEL_ONLY: @@ -197,7 +219,6 @@ OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, case PVRSRV_HAP_SINGLE_PROCESS: { - psLinuxMemArea = NewAllocPagesLinuxMemArea(ui32Size, ui32AllocFlags); if(!psLinuxMemArea) { @@ -229,6 +250,7 @@ OSAllocPages_Impl(IMG_UINT32 ui32AllocFlags, return PVRSRV_ERROR_INVALID_PARAMS; } +ExitSkipSwitch: *ppvCpuVAddr = LinuxMemAreaToCpuVAddr(psLinuxMemArea); *phOSMemHandle = psLinuxMemArea; @@ -305,7 +327,7 @@ OSGetSubMemHandle(IMG_HANDLE hOSMemHandle, eError = PVRMMapRegisterArea(psLinuxMemArea); if(eError != PVRSRV_OK) - { + { goto failed_register_area; } @@ -512,17 +534,36 @@ IMG_UINT32 OSClockus(IMG_VOID) } - IMG_VOID OSWaitus(IMG_UINT32 ui32Timeus) { + udelay(ui32Timeus); +} - if( (ui32Timeus/1000) > 0 ) - msleep(ui32Timeus/1000); // ms - - if( (ui32Timeus%1000) > 0 ) - udelay(ui32Timeus%1000); // us + +IMG_VOID OSSleepms(IMG_UINT32 ui32Timems) +{ + msleep(ui32Timems); +} + + + +IMG_HANDLE OSFuncHighResTimerCreate(IMG_VOID) +{ + + return (IMG_HANDLE) 1; } + +IMG_UINT32 OSFuncHighResTimerGetus(IMG_HANDLE hTimer) +{ + return (IMG_UINT32) jiffies_to_usecs(jiffies); +} + + +IMG_VOID OSFuncHighResTimerDestroy(IMG_HANDLE hTimer) +{ + PVR_UNREFERENCED_PARAMETER(hTimer); +} IMG_UINT32 OSGetCurrentProcessIDKM(IMG_VOID) { @@ -1002,7 +1043,7 @@ PVRSRV_ERROR OSUnlockResource (PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID) if(psResource->ui32ID == ui32ID) { psResource->ui32ID = 0; - smp_mb(); + smp_mb(); *pui32Access = 0; } else @@ -1032,6 +1073,20 @@ IMG_BOOL OSIsResourceLocked (PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID) } +#if !defined(SYS_CUSTOM_POWERLOCK_WRAP) +PVRSRV_ERROR OSPowerLockWrap(IMG_BOOL bTryLock) +{ + PVR_UNREFERENCED_PARAMETER(bTryLock); + + return PVRSRV_OK; +} + +IMG_VOID OSPowerLockUnwrap (IMG_VOID) +{ +} +#endif + + IMG_CPU_PHYADDR OSMapLinToCPUPhys(IMG_HANDLE hOSMemHandle, IMG_VOID *pvLinAddr) { @@ -1382,9 +1437,9 @@ PVRSRV_ERROR OSBaseAllocContigMemory(IMG_UINT32 ui32Size, IMG_CPU_VIRTADDR *pvLi IMG_VOID *pvKernLinAddr; #if defined(DEBUG_LINUX_MEMORY_ALLOCATIONS) - pvKernLinAddr = _KMallocWrapper(ui32Size, __FILE__, __LINE__); + pvKernLinAddr = _KMallocWrapper(ui32Size, GFP_KERNEL, __FILE__, __LINE__); #else - pvKernLinAddr = KMallocWrapper(ui32Size); + pvKernLinAddr = KMallocWrapper(ui32Size, GFP_KERNEL); #endif if (!pvKernLinAddr) { @@ -1705,12 +1760,16 @@ PVRSRV_ERROR OSPCIResumeDev(PVRSRV_PCI_DEV_HANDLE hPVRPCI) return PVRSRV_ERROR_UNKNOWN_POWER_STATE; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) + pci_restore_state(psPVRPCI->psPCIDev); +#else err = pci_restore_state(psPVRPCI->psPCIDev); if (err != 0) { PVR_DPF((PVR_DBG_ERROR, "OSPCIResumeDev: pci_restore_state failed (%d)", err)); return PVRSRV_ERROR_PCI_CALL_FAILED; } +#endif err = pci_enable_device(psPVRPCI->psPCIDev); if (err != 0) @@ -1765,8 +1824,12 @@ static TIMER_CALLBACK_DATA sTimers[OS_MAX_TIMERS]; #if defined(PVR_LINUX_TIMERS_USING_WORKQUEUES) || defined(PVR_LINUX_TIMERS_USING_SHARED_WORKQUEUE) DEFINE_MUTEX(sTimerStructLock); #else +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) static spinlock_t sTimerStructLock = SPIN_LOCK_UNLOCKED; +#else +static DEFINE_SPINLOCK(sTimerStructLock); +#endif #endif static void OSTimerCallbackBody(TIMER_CALLBACK_DATA *psTimerCBData) @@ -1952,7 +2015,11 @@ PVRSRV_ERROR OSDisableTimer (IMG_HANDLE hTimer) } -PVRSRV_ERROR OSEventObjectCreate(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *psEventObject) +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT_KM *psEventObject) +#else +PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *psEventObject) +#endif { PVRSRV_ERROR eError = PVRSRV_OK; @@ -1968,7 +2035,11 @@ PVRSRV_ERROR OSEventObjectCreate(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *ps { static IMG_UINT16 ui16NameIndex = 0; +#if defined (SUPPORT_SID_INTERFACE) + snprintf(psEventObject->szName, EVENTOBJNAME_MAXLENGTH, "PVRSRV_EVENTOBJECT_KM_%d", ui16NameIndex++); +#else snprintf(psEventObject->szName, EVENTOBJNAME_MAXLENGTH, "PVRSRV_EVENTOBJECT_%d", ui16NameIndex++); +#endif } if(LinuxEventObjectListCreate(&psEventObject->hOSEventKM) != PVRSRV_OK) @@ -1979,7 +2050,7 @@ PVRSRV_ERROR OSEventObjectCreate(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *ps } else { - PVR_DPF((PVR_DBG_ERROR, "OSEventObjectCreate: psEventObject is not a valid pointer")); + PVR_DPF((PVR_DBG_ERROR, "OSEventObjectCreateKM: psEventObject is not a valid pointer")); eError = PVRSRV_ERROR_UNABLE_TO_CREATE_EVENT; } @@ -1988,7 +2059,11 @@ PVRSRV_ERROR OSEventObjectCreate(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *ps } -PVRSRV_ERROR OSEventObjectDestroy(PVRSRV_EVENTOBJECT *psEventObject) +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT_KM *psEventObject) +#else +PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT *psEventObject) +#endif { PVRSRV_ERROR eError = PVRSRV_OK; @@ -2000,20 +2075,20 @@ PVRSRV_ERROR OSEventObjectDestroy(PVRSRV_EVENTOBJECT *psEventObject) } else { - PVR_DPF((PVR_DBG_ERROR, "OSEventObjectDestroy: hOSEventKM is not a valid pointer")); + PVR_DPF((PVR_DBG_ERROR, "OSEventObjectDestroyKM: hOSEventKM is not a valid pointer")); eError = PVRSRV_ERROR_INVALID_PARAMS; } } else { - PVR_DPF((PVR_DBG_ERROR, "OSEventObjectDestroy: psEventObject is not a valid pointer")); + PVR_DPF((PVR_DBG_ERROR, "OSEventObjectDestroyKM: psEventObject is not a valid pointer")); eError = PVRSRV_ERROR_INVALID_PARAMS; } return eError; } -PVRSRV_ERROR OSEventObjectWait(IMG_HANDLE hOSEventKM) +PVRSRV_ERROR OSEventObjectWaitKM(IMG_HANDLE hOSEventKM) { PVRSRV_ERROR eError; @@ -2023,14 +2098,18 @@ PVRSRV_ERROR OSEventObjectWait(IMG_HANDLE hOSEventKM) } else { - PVR_DPF((PVR_DBG_ERROR, "OSEventObjectWait: hOSEventKM is not a valid handle")); + PVR_DPF((PVR_DBG_ERROR, "OSEventObjectWaitKM: hOSEventKM is not a valid handle")); eError = PVRSRV_ERROR_INVALID_PARAMS; } return eError; } -PVRSRV_ERROR OSEventObjectOpen(PVRSRV_EVENTOBJECT *psEventObject, +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT_KM *psEventObject, +#else +PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT *psEventObject, +#endif IMG_HANDLE *phOSEvent) { PVRSRV_ERROR eError = PVRSRV_OK; @@ -2046,14 +2125,18 @@ PVRSRV_ERROR OSEventObjectOpen(PVRSRV_EVENTOBJECT *psEventObject, } else { - PVR_DPF((PVR_DBG_ERROR, "OSEventObjectCreate: psEventObject is not a valid pointer")); + PVR_DPF((PVR_DBG_ERROR, "OSEventObjectCreateKM: psEventObject is not a valid pointer")); eError = PVRSRV_ERROR_INVALID_PARAMS; } return eError; } -PVRSRV_ERROR OSEventObjectClose(PVRSRV_EVENTOBJECT *psEventObject, +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT_KM *psEventObject, +#else +PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT *psEventObject, +#endif IMG_HANDLE hOSEventKM) { PVRSRV_ERROR eError = PVRSRV_OK; @@ -2069,7 +2152,7 @@ PVRSRV_ERROR OSEventObjectClose(PVRSRV_EVENTOBJECT *psEventObject, } else { - PVR_DPF((PVR_DBG_ERROR, "OSEventObjectDestroy: psEventObject is not a valid pointer")); + PVR_DPF((PVR_DBG_ERROR, "OSEventObjectDestroyKM: psEventObject is not a valid pointer")); eError = PVRSRV_ERROR_INVALID_PARAMS; } @@ -2077,7 +2160,7 @@ PVRSRV_ERROR OSEventObjectClose(PVRSRV_EVENTOBJECT *psEventObject, } -PVRSRV_ERROR OSEventObjectSignal(IMG_HANDLE hOSEventKM) +PVRSRV_ERROR OSEventObjectSignalKM(IMG_HANDLE hOSEventKM) { PVRSRV_ERROR eError; @@ -2087,7 +2170,7 @@ PVRSRV_ERROR OSEventObjectSignal(IMG_HANDLE hOSEventKM) } else { - PVR_DPF((PVR_DBG_ERROR, "OSEventObjectSignal: hOSEventKM is not a valid handle")); + PVR_DPF((PVR_DBG_ERROR, "OSEventObjectSignalKM: hOSEventKM is not a valid handle")); eError = PVRSRV_ERROR_INVALID_PARAMS; } @@ -2288,6 +2371,47 @@ PVRSRV_ERROR OSReleasePhysPageAddr(IMG_HANDLE hOSWrapMem) return PVRSRV_OK; } +#if defined(CONFIG_TI_TILER) + +static IMG_UINT32 CPUAddrToTilerPhy(IMG_UINT32 uiAddr) +{ + IMG_UINT32 ui32PhysAddr = 0; + pte_t *ptep, pte; + pgd_t *pgd; + pmd_t *pmd; + + pgd = pgd_offset(current->mm, uiAddr); + if (pgd_none(*pgd) || pgd_bad(*pgd)) + goto err_out; + + pmd = pmd_offset(pgd, uiAddr); + if (pmd_none(*pmd) || pmd_bad(*pmd)) + goto err_out; + + ptep = pte_offset_map(pmd, uiAddr); + if (!ptep) + goto err_out; + + pte = *ptep; + if (!pte_present(pte)) + goto err_out; + + ui32PhysAddr = (pte & PAGE_MASK) | (~PAGE_MASK & uiAddr); + + + if (ui32PhysAddr < 0x60000000 && ui32PhysAddr > 0x7fffffff) + { + PVR_DPF((PVR_DBG_ERROR, "CPUAddrToTilerPhy: Not in tiler range")); + ui32PhysAddr = 0; + goto err_out; + } + +err_out: + return ui32PhysAddr; +} + +#endif + PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, IMG_UINT32 ui32Bytes, IMG_SYS_PHYADDR *psSysPAddr, @@ -2305,7 +2429,6 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, sWrapMemInfo *psInfo = NULL; IMG_BOOL bHavePageStructs = IMG_FALSE; IMG_BOOL bHaveNoPageStructs = IMG_FALSE; - IMG_BOOL bPFNMismatch = IMG_FALSE; IMG_BOOL bMMapSemHeld = IMG_FALSE; PVRSRV_ERROR eError = PVRSRV_ERROR_OUT_OF_MEMORY; @@ -2478,20 +2601,20 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, } if (psInfo->ppsPages[i] == NULL) { +#if defined(CONFIG_TI_TILER) + + IMG_UINT32 ui32TilerAddr = CPUAddrToTilerPhy(ulAddr); + if (ui32TilerAddr) + { + bHavePageStructs = IMG_TRUE; + psInfo->iNumPagesMapped++; + psInfo->psPhysAddr[i].uiAddr = ui32TilerAddr; + psSysPAddr[i].uiAddr = ui32TilerAddr; + continue; + } +#endif bHaveNoPageStructs = IMG_TRUE; - -#if defined(VM_PFNMAP) - if ((psVMArea->vm_flags & VM_PFNMAP) != 0) - { - IMG_UINT32 ulPFNRaw = ((ulAddr - psVMArea->vm_start) >> PAGE_SHIFT) + psVMArea->vm_pgoff; - - if (ulPFNRaw != ulPFN) - { - bPFNMismatch = IMG_TRUE; - } - } -#endif } else { @@ -2545,13 +2668,6 @@ PVRSRV_ERROR OSAcquirePhysPageAddr(IMG_VOID *pvCPUVAddr, goto error; } - if (bPFNMismatch) - { - PVR_DPF((PVR_DBG_ERROR, - "OSAcquirePhysPageAddr: PFN calculation mismatch for VM_PFNMAP region")); - goto error; - } - exit: PVR_ASSERT(bMMapSemHeld); up_read(¤t->mm->mmap_sem); @@ -2561,7 +2677,7 @@ exit: if (bHaveNoPageStructs) { - PVR_DPF((PVR_DBG_WARNING, + PVR_DPF((PVR_DBG_MESSAGE, "OSAcquirePhysPageAddr: Region contains pages which can't be locked down (no page structures)")); } @@ -2588,7 +2704,12 @@ error: } typedef void (*InnerCacheOp_t)(const void *pvStart, const void *pvEnd); + +#if defined(__arm__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) +typedef void (*OuterCacheOp_t)(phys_addr_t uStart, phys_addr_t uEnd); +#else typedef void (*OuterCacheOp_t)(unsigned long ulStart, unsigned long ulEnd); +#endif #if defined(CONFIG_OUTER_CACHE) @@ -2627,9 +2748,18 @@ static unsigned long AllocPagesAreaToPhys(LinuxMemArea *psLinuxMemArea, return page_to_pfn(pPage) << PAGE_SHIFT; } +static unsigned long IONAreaToPhys(LinuxMemArea *psLinuxMemArea, + IMG_VOID *pvRangeAddrStart, + IMG_UINT32 ui32PageNumOffset, + IMG_UINT32 ui32PageNum) +{ + IMG_CPU_PHYADDR CpuPAddr; + CpuPAddr = psLinuxMemArea->uData.sIONTilerAlloc.pCPUPhysAddrs[ui32PageNumOffset + ui32PageNum]; + return CpuPAddr.uiAddr; +} + #endif -#ifndef __mips__ static IMG_VOID *FindMMapBaseVAddr(struct list_head *psMMapOffsetStructList, IMG_VOID *pvRangeAddrStart, IMG_UINT32 ui32Length) @@ -2654,6 +2784,8 @@ IMG_VOID *FindMMapBaseVAddr(struct list_head *psMMapOffsetStructList, return IMG_NULL; } +extern PVRSRV_LINUX_MUTEX g_sMMapMutex; + static IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, IMG_VOID *pvRangeAddrStart, @@ -2673,8 +2805,10 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, PVR_ASSERT(psLinuxMemArea != IMG_NULL); - ui32AreaLength = psLinuxMemArea->ui32ByteSize; + LinuxLockMutex(&g_sMMapMutex); + psMMapOffsetStructList = &psLinuxMemArea->sMMapOffsetStructList; + ui32AreaLength = psLinuxMemArea->ui32ByteSize; PVR_ASSERT(ui32Length <= ui32AreaLength); @@ -2691,16 +2825,36 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, { case LINUX_MEM_AREA_VMALLOC: { - pvMinVAddr = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress + ui32AreaOffset; + if(is_vmalloc_addr(pvRangeAddrStart)) + { + pvMinVAddr = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress + ui32AreaOffset; - - if(pvRangeAddrStart < pvMinVAddr && - ui32AreaOffset + ui32Length > ui32AreaLength) - goto err_blocked; + + if(pvRangeAddrStart < pvMinVAddr) + goto err_blocked; + + pfnInnerCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); + } + else + { + + pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, + pvRangeAddrStart, ui32Length); + if(!pvMinVAddr) + goto err_blocked; + + pfnInnerCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); #if defined(CONFIG_OUTER_CACHE) + + pvRangeAddrStart = psLinuxMemArea->uData.sVmalloc.pvVmallocAddress + + (ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr); + } + pfnMemAreaToPhys = VMallocAreaToPhys; -#endif +#else + } +#endif break; } @@ -2710,7 +2864,6 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, if (psLinuxMemArea->uData.sExternalKV.bPhysContig == IMG_TRUE) { PVR_DPF((PVR_DBG_WARNING, "%s: Attempt to flush contiguous external memory", __func__)); - goto err_blocked; } @@ -2718,17 +2871,16 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, if (psLinuxMemArea->uData.sExternalKV.pvExternalKV != IMG_NULL) { PVR_DPF((PVR_DBG_WARNING, "%s: Attempt to flush external memory with a kernel virtual address", __func__)); - goto err_blocked; } - - pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, pvRangeAddrStart, ui32Length); if(!pvMinVAddr) goto err_blocked; + pfnInnerCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); + #if defined(CONFIG_OUTER_CACHE) ui32PageNumOffset = ((ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr)) >> PAGE_SHIFT; pfnMemAreaToPhys = ExternalKVAreaToPhys; @@ -2736,6 +2888,22 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, break; } + case LINUX_MEM_AREA_ION: + { + pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, + pvRangeAddrStart, ui32Length); + if(!pvMinVAddr) + goto err_blocked; + + pfnInnerCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); + +#if defined(CONFIG_OUTER_CACHE) + ui32PageNumOffset = ((ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr)) >> PAGE_SHIFT; + pfnMemAreaToPhys = IONAreaToPhys; +#endif + break; + } + case LINUX_MEM_AREA_ALLOC_PAGES: { pvMinVAddr = FindMMapBaseVAddr(psMMapOffsetStructList, @@ -2743,6 +2911,8 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, if(!pvMinVAddr) goto err_blocked; + pfnInnerCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); + #if defined(CONFIG_OUTER_CACHE) ui32PageNumOffset = ((ui32AreaOffset & PAGE_MASK) + (pvRangeAddrStart - pvMinVAddr)) >> PAGE_SHIFT; pfnMemAreaToPhys = AllocPagesAreaToPhys; @@ -2754,12 +2924,12 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, PVR_DBG_BREAK; } - - pfnInnerCacheOp(pvRangeAddrStart, pvRangeAddrStart + ui32Length); + LinuxUnLockMutex(&g_sMMapMutex); #if defined(CONFIG_OUTER_CACHE) + PVR_ASSERT(pfnMemAreaToPhys != IMG_NULL); + - if (pfnMemAreaToPhys != IMG_NULL) { unsigned long ulStart, ulEnd, ulLength, ulStartOffset, ulEndOffset; IMG_UINT32 i, ui32NumPages; @@ -2787,10 +2957,6 @@ IMG_BOOL CheckExecuteCacheOp(IMG_HANDLE hOSMemHandle, pfnOuterCacheOp(ulStart, ulEnd); } } - else - { - PVR_DBG_BREAK; - } #endif return IMG_TRUE; @@ -2800,9 +2966,9 @@ err_blocked: "%p-%p (type %d)", __func__, pvRangeAddrStart, pvRangeAddrStart + ui32Length, psLinuxMemArea->eAreaType)); + LinuxUnLockMutex(&g_sMMapMutex); return IMG_FALSE; } -#endif #if defined(__i386__) @@ -2882,7 +3048,7 @@ IMG_VOID OSCleanCPUCacheKM(IMG_VOID) ON_EACH_CPU(per_cpu_cache_flush, NULL, 1); #if defined(CONFIG_OUTER_CACHE) && !defined(PVR_NO_FULL_CACHE_OPS) - outer_clean_all(); + outer_clean_range(0, ULONG_MAX); #endif } @@ -2894,16 +3060,30 @@ IMG_VOID OSFlushCPUCacheKM(IMG_VOID) #endif } -#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,35)) -static IMG_VOID _dmac_inv_range(const void *pvRangeAddrStart, const void *pvRangeAddrEnd) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +static inline size_t pvr_dmac_range_len(const void *pvStart, const void *pvEnd) { - dmac_map_area(pvRangeAddrStart, (IMG_UINT32)pvRangeAddrEnd - (IMG_UINT32)pvRangeAddrStart, DMA_FROM_DEVICE); + return (size_t)((char *)pvEnd - (char *)pvStart); } -static IMG_VOID _dmac_clean_range(const void *pvRangeAddrStart, const void *pvRangeAddrEnd) +#endif + +static void pvr_dmac_inv_range(const void *pvStart, const void *pvEnd) { - dmac_map_area(pvRangeAddrStart, (IMG_UINT32)pvRangeAddrEnd - (IMG_UINT32)pvRangeAddrStart, DMA_TO_DEVICE); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) + dmac_inv_range(pvStart, pvEnd); +#else + dmac_map_area(pvStart, pvr_dmac_range_len(pvStart, pvEnd), DMA_FROM_DEVICE); +#endif } + +static void pvr_dmac_clean_range(const void *pvStart, const void *pvEnd) +{ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) + dmac_clean_range(pvStart, pvEnd); +#else + dmac_map_area(pvStart, pvr_dmac_range_len(pvStart, pvEnd), DMA_TO_DEVICE); #endif +} IMG_BOOL OSFlushCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_VOID *pvRangeAddrStart, @@ -2918,12 +3098,7 @@ IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Length) { return CheckExecuteCacheOp(hOSMemHandle, pvRangeAddrStart, ui32Length, -#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,35)) - _dmac_clean_range, -#else - dmac_clean_range, -#endif - outer_clean_range); + pvr_dmac_clean_range, outer_clean_range); } IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, @@ -2931,18 +3106,12 @@ IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Length) { return CheckExecuteCacheOp(hOSMemHandle, pvRangeAddrStart, ui32Length, -#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,35)) - _dmac_inv_range, -#else - dmac_inv_range, -#endif - outer_inv_range); + pvr_dmac_inv_range, outer_inv_range); } #else #if defined(__mips__) - IMG_VOID OSCleanCPUCacheKM(IMG_VOID) { @@ -2959,7 +3128,8 @@ IMG_BOOL OSFlushCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_VOID *pvRangeAddrStart, IMG_UINT32 ui32Length) { - dma_cache_wback_inv((IMG_UINTPTR_T)pvRangeAddrStart, ui32Length); + if (ui32Length) + dma_cache_wback_inv((IMG_UINTPTR_T)pvRangeAddrStart, ui32Length); return IMG_TRUE; } @@ -2967,7 +3137,8 @@ IMG_BOOL OSCleanCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_VOID *pvRangeAddrStart, IMG_UINT32 ui32Length) { - dma_cache_wback((IMG_UINTPTR_T)pvRangeAddrStart, ui32Length); + if (ui32Length) + dma_cache_wback((IMG_UINTPTR_T)pvRangeAddrStart, ui32Length); return IMG_TRUE; } @@ -2975,12 +3146,12 @@ IMG_BOOL OSInvalidateCPUCacheRangeKM(IMG_HANDLE hOSMemHandle, IMG_VOID *pvRangeAddrStart, IMG_UINT32 ui32Length) { - dma_cache_inv((IMG_UINTPTR_T)pvRangeAddrStart, ui32Length); + if (ui32Length) + dma_cache_inv((IMG_UINTPTR_T)pvRangeAddrStart, ui32Length); return IMG_TRUE; } - -#else +#else #error "Implement CPU cache flush/clean/invalidate primitives for this CPU!" diff --git a/drivers/gpu/pvr/osfunc.h b/drivers/gpu/pvr/osfunc.h index 8ffbea6..7195a07 100644 --- a/drivers/gpu/pvr/osfunc.h +++ b/drivers/gpu/pvr/osfunc.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -83,7 +83,7 @@ IMG_BOOL OSUnMapPhysToLin(IMG_VOID *pvLinAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 PVRSRV_ERROR OSReservePhys(IMG_CPU_PHYADDR BasePAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_VOID **ppvCpuVAddr, IMG_HANDLE *phOSMemHandle); PVRSRV_ERROR OSUnReservePhys(IMG_VOID *pvCpuVAddr, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hOSMemHandle); -#if defined(__linux__) && defined(__KERNEL__) +#if (defined(__linux__) && defined(__KERNEL__)) || (UNDER_CE >= 600) IMG_VOID OSFlushCPUCacheKM(IMG_VOID); @@ -304,7 +304,8 @@ IMG_UINT32 OSGetCurrentProcessIDKM(IMG_VOID); IMG_UINTPTR_T OSGetCurrentThreadID( IMG_VOID ); IMG_VOID OSMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T ui32Size); -PVRSRV_ERROR OSAllocPages_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_UINT32 ui32PageSize, IMG_PVOID *ppvLinAddr, IMG_HANDLE *phPageAlloc); +PVRSRV_ERROR OSAllocPages_Impl(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_UINT32 ui32PageSize, + IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, IMG_PVOID *ppvLinAddr, IMG_HANDLE *phPageAlloc); PVRSRV_ERROR OSFreePages(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_PVOID pvLinAddr, IMG_HANDLE hPageAlloc); @@ -313,9 +314,9 @@ PVRSRV_ERROR OSFreePages(IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_PVOID pv (PVR_TRACE(("OSAllocMem(" #flags ", " #size ", " #linAddr ", " #blockAlloc "): " logStr " (size = 0x%lx)", size)), \ OSAllocMem_Debug_Wrapper(flags, size, linAddr, blockAlloc, __FILE__, __LINE__)) - #define OSAllocPages(flags, size, pageSize, linAddr, pageAlloc) \ + #define OSAllocPages(flags, size, pageSize, privdata, privdatalength, linAddr, pageAlloc) \ (PVR_TRACE(("OSAllocPages(" #flags ", " #size ", " #pageSize ", " #linAddr ", " #pageAlloc "): (size = 0x%lx)", size)), \ - OSAllocPages_Impl(flags, size, pageSize, linAddr, pageAlloc)) + OSAllocPages_Impl(flags, size, pageSize, linAddr, privdata, privdatalength, pageAlloc)) #define OSFreeMem(flags, size, linAddr, blockAlloc) \ (PVR_TRACE(("OSFreeMem(" #flags ", " #size ", " #linAddr ", " #blockAlloc "): (pointer = 0x%X)", linAddr)), \ @@ -406,15 +407,27 @@ IMG_CHAR* OSStringCopy(IMG_CHAR *pszDest, const IMG_CHAR *pszSrc); IMG_INT32 OSSNPrintf(IMG_CHAR *pStr, IMG_SIZE_T ui32Size, const IMG_CHAR *pszFormat, ...) IMG_FORMAT_PRINTF(3, 4); #define OSStringLength(pszString) strlen(pszString) -PVRSRV_ERROR OSEventObjectCreate(const IMG_CHAR *pszName, +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, + PVRSRV_EVENTOBJECT_KM *psEventObject); +PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT_KM *psEventObject); +PVRSRV_ERROR OSEventObjectSignalKM(IMG_HANDLE hOSEventKM); +PVRSRV_ERROR OSEventObjectWaitKM(IMG_HANDLE hOSEventKM); +PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT_KM *psEventObject, + IMG_HANDLE *phOSEvent); +PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT_KM *psEventObject, + IMG_HANDLE hOSEventKM); +#else +PVRSRV_ERROR OSEventObjectCreateKM(const IMG_CHAR *pszName, PVRSRV_EVENTOBJECT *psEventObject); -PVRSRV_ERROR OSEventObjectDestroy(PVRSRV_EVENTOBJECT *psEventObject); -PVRSRV_ERROR OSEventObjectSignal(IMG_HANDLE hOSEventKM); -PVRSRV_ERROR OSEventObjectWait(IMG_HANDLE hOSEventKM); -PVRSRV_ERROR OSEventObjectOpen(PVRSRV_EVENTOBJECT *psEventObject, +PVRSRV_ERROR OSEventObjectDestroyKM(PVRSRV_EVENTOBJECT *psEventObject); +PVRSRV_ERROR OSEventObjectSignalKM(IMG_HANDLE hOSEventKM); +PVRSRV_ERROR OSEventObjectWaitKM(IMG_HANDLE hOSEventKM); +PVRSRV_ERROR OSEventObjectOpenKM(PVRSRV_EVENTOBJECT *psEventObject, IMG_HANDLE *phOSEvent); -PVRSRV_ERROR OSEventObjectClose(PVRSRV_EVENTOBJECT *psEventObject, +PVRSRV_ERROR OSEventObjectCloseKM(PVRSRV_EVENTOBJECT *psEventObject, IMG_HANDLE hOSEventKM); +#endif PVRSRV_ERROR OSBaseAllocContigMemory(IMG_SIZE_T ui32Size, IMG_CPU_VIRTADDR *pLinAddr, IMG_CPU_PHYADDR *pPhysAddr); @@ -444,7 +457,25 @@ IMG_BOOL OSIsResourceLocked(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID); PVRSRV_ERROR OSCreateResource(PVRSRV_RESOURCE *psResource); PVRSRV_ERROR OSDestroyResource(PVRSRV_RESOURCE *psResource); IMG_VOID OSBreakResourceLock(PVRSRV_RESOURCE *psResource, IMG_UINT32 ui32ID); + +#if defined(SYS_CUSTOM_POWERLOCK_WRAP) +#define OSPowerLockWrap SysPowerLockWrap +#define OSPowerLockUnwrap SysPowerLockUnwrap +#else +PVRSRV_ERROR OSPowerLockWrap(IMG_BOOL bTryLock); + +IMG_VOID OSPowerLockUnwrap(IMG_VOID); +#endif + + IMG_VOID OSWaitus(IMG_UINT32 ui32Timeus); + + +IMG_VOID OSSleepms(IMG_UINT32 ui32Timems); + +IMG_HANDLE OSFuncHighResTimerCreate(IMG_VOID); +IMG_UINT32 OSFuncHighResTimerGetus(IMG_HANDLE hTimer); +IMG_VOID OSFuncHighResTimerDestroy(IMG_HANDLE hTimer); IMG_VOID OSReleaseThreadQuanta(IMG_VOID); IMG_UINT32 OSPCIReadDword(IMG_UINT32 ui32Bus, IMG_UINT32 ui32Dev, IMG_UINT32 ui32Func, IMG_UINT32 ui32Reg); IMG_VOID OSPCIWriteDword(IMG_UINT32 ui32Bus, IMG_UINT32 ui32Dev, IMG_UINT32 ui32Func, IMG_UINT32 ui32Reg, IMG_UINT32 ui32Value); diff --git a/drivers/gpu/pvr/osfunc_common.c b/drivers/gpu/pvr/osfunc_common.c index 25ac667..e0a46da 100644 --- a/drivers/gpu/pvr/osfunc_common.c +++ b/drivers/gpu/pvr/osfunc_common.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/osperproc.c b/drivers/gpu/pvr/osperproc.c index 011c8f3..6b57dfc 100644 --- a/drivers/gpu/pvr/osperproc.c +++ b/drivers/gpu/pvr/osperproc.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/osperproc.h b/drivers/gpu/pvr/osperproc.h index 80a912f..02aa230 100644 --- a/drivers/gpu/pvr/osperproc.h +++ b/drivers/gpu/pvr/osperproc.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 0b932b0..13d9b0d 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -431,7 +431,7 @@ IMG_VOID PDumpInit(IMG_VOID) } PDUMPCOMMENT("Driver Product Name: %s", VS_PRODUCT_NAME); - PDUMPCOMMENT("Driver Product Version: %s (%s)", PVRVERSION_STRING, PVRVERSION_FILE); + PDUMPCOMMENT("Driver Product Version: %s (%s)", PVRVERSION_STRING, PVRVERSION_FAMILY); PDUMPCOMMENT("Start of Init Phase"); } diff --git a/drivers/gpu/pvr/pdump.h b/drivers/gpu/pvr/pdump.h index 78d9073..c41a6d4 100644 --- a/drivers/gpu/pvr/pdump.h +++ b/drivers/gpu/pvr/pdump.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/pdump_common.c b/drivers/gpu/pvr/pdump_common.c index 9c9b730..45845b6cc 100644 --- a/drivers/gpu/pvr/pdump_common.c +++ b/drivers/gpu/pvr/pdump_common.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -28,9 +28,6 @@ #include <stdarg.h> #include "services_headers.h" -#if defined(SUPPORT_SGX) -#include "sgxdefs.h" -#endif #include "perproc.h" #include "pdump_km.h" @@ -46,8 +43,6 @@ #define PDUMP_DBG(a) #endif -#define PDUMP_DATAMASTER_PIXEL (1) -#define PDUMP_DATAMASTER_EDM (3) #define PTR_PLUS(t, p, x) ((t)(((IMG_CHAR *)(p)) + (x))) #define VPTR_PLUS(p, x) PTR_PLUS(IMG_VOID *, p, x) @@ -68,6 +63,7 @@ static INLINE IMG_BOOL _PDumpIsPersistent(IMG_VOID) { PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); + if(psPerProc == IMG_NULL) { @@ -77,6 +73,8 @@ IMG_BOOL _PDumpIsPersistent(IMG_VOID) } #if defined(SUPPORT_PDUMP_MULTI_PROCESS) + + static INLINE IMG_BOOL _PDumpIsProcessActive(IMG_VOID) { @@ -88,6 +86,7 @@ IMG_BOOL _PDumpIsProcessActive(IMG_VOID) } return psPerProc->bPDumpActive; } + #endif #if defined(PDUMP_DEBUG_OUTFILES) @@ -192,7 +191,6 @@ PVRSRV_ERROR PDumpSetFrameKM(IMG_UINT32 ui32Frame) #endif } - PVRSRV_ERROR PDumpRegWithFlagsKM(IMG_CHAR *pszPDumpRegName, IMG_UINT32 ui32Reg, IMG_UINT32 ui32Data, @@ -224,7 +222,8 @@ PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, IMG_UINT32 ui32RegAddr, IMG_UINT32 ui32RegValue, IMG_UINT32 ui32Mask, - IMG_UINT32 ui32Flags) + IMG_UINT32 ui32Flags, + PDUMP_POLL_OPERATOR eOperator) { #define POLL_DELAY 1000U @@ -260,7 +259,7 @@ PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "POL :%s:0x%08X 0x%08X 0x%08X %d %u %d\r\n", pszPDumpRegName, ui32RegAddr, ui32RegValue, - ui32Mask, 0, ui32PollCount, POLL_DELAY); + ui32Mask, eOperator, ui32PollCount, POLL_DELAY); if(eErr != PVRSRV_OK) { return eErr; @@ -271,9 +270,9 @@ PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, } -PVRSRV_ERROR PDumpRegPolKM(IMG_CHAR *pszPDumpRegName, IMG_UINT32 ui32RegAddr, IMG_UINT32 ui32RegValue, IMG_UINT32 ui32Mask) +PVRSRV_ERROR PDumpRegPolKM(IMG_CHAR *pszPDumpRegName, IMG_UINT32 ui32RegAddr, IMG_UINT32 ui32RegValue, IMG_UINT32 ui32Mask, PDUMP_POLL_OPERATOR eOperator) { - return PDumpRegPolWithFlagsKM(pszPDumpRegName, ui32RegAddr, ui32RegValue, ui32Mask, PDUMP_FLAGS_CONTINUOUS); + return PDumpRegPolWithFlagsKM(pszPDumpRegName, ui32RegAddr, ui32RegValue, ui32Mask, PDUMP_FLAGS_CONTINUOUS, eOperator); } PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, @@ -366,23 +365,24 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, return PVRSRV_OK; } + PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32Offset, - IMG_CPU_VIRTADDR pvLinAddr, + IMG_CPU_VIRTADDR pvLinAddr, IMG_UINT32 ui32PTSize, IMG_UINT32 ui32Flags, - IMG_HANDLE hUniqueTag) + IMG_HANDLE hUniqueTag) { PVRSRV_ERROR eErr; IMG_DEV_PHYADDR sDevPAddr; PDUMP_GET_SCRIPT_STRING(); - PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize - 1)) == 0); + PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize - 1)) == 0); ui32Flags |= PDUMP_FLAGS_CONTINUOUS; ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; - + eErr = PDumpOSBufprintf(hScript, @@ -478,15 +478,16 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, if (!bInterleaved || (ui32PageCounter % 2) == 0) { sDevPAddr = psDeviceNode->pfnMMUGetPhysPageAddr(psBMHeap->pMMUHeap, sDevVAddr); + + PVR_ASSERT(sDevPAddr.uiAddr != 0) + + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_%08X%08X\r\n", + psDeviceNode->sDevId.pszPDumpDevName, (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr); + if(eErr != PVRSRV_OK) { - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_%08X%08X\r\n", - psDeviceNode->sDevId.pszPDumpDevName, (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); + return eErr; } + PDumpOSWriteString2(hScript, ui32Flags); } else { @@ -652,6 +653,12 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PDUMP_MMU_ATTRIB *psMMUAttrib; PDUMP_GET_SCRIPT_STRING(); + + if (PDumpOSIsSuspended()) + { + return PVRSRV_OK; + } + if ( _PDumpIsPersistent() ) { @@ -659,7 +666,7 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, } - PVR_ASSERT((ui32Offset + sizeof(IMG_UINT32)) <= psMemInfo->ui32AllocSize); + PVR_ASSERT((ui32Offset + sizeof(IMG_UINT32)) <= psMemInfo->uAllocSize); psMMUAttrib = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; @@ -750,23 +757,23 @@ PVRSRV_ERROR PDumpMemKM(IMG_PVOID pvAltLinAddr, PDUMP_GET_SCRIPT_AND_FILE_STRING(); + + if (ui32Bytes == 0 || PDumpOSIsSuspended()) + { + return PVRSRV_OK; + } + psMMUAttrib = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; - PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); + PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->uAllocSize); if (!PDumpOSJTInitialised()) { return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; } - - if (ui32Bytes == 0 || PDumpOSIsSuspended()) - { - return PVRSRV_OK; - } - #if defined(SUPPORT_PDUMP_MULTI_PROCESS) { @@ -936,7 +943,7 @@ PVRSRV_ERROR PDumpMemPDEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, sMMUAttrib = *psMMUAttrib; - sMMUAttrib.ui32PTSize = HOST_PAGESIZE(); + sMMUAttrib.ui32PTSize = (IMG_UINT32)HOST_PAGESIZE(); return PDumpMemPTEntriesKM( &sMMUAttrib, hOSMemHandle, pvLinAddr, @@ -970,6 +977,11 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, PDUMP_GET_SCRIPT_AND_FILE_STRING(); ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; + if (PDumpOSIsSuspended()) + { + return PVRSRV_OK; + } + if (!PDumpOSJTInitialised()) { return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; @@ -980,11 +992,6 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, return PVRSRV_ERROR_INVALID_PARAMS; } - if (PDumpOSIsSuspended()) - { - return PVRSRV_OK; - } - PDumpOSCheckForSplitting(PDumpOSGetStream(PDUMP_STREAM_PARAM2), ui32Bytes, ui32Flags); ui32ParamOutPos = PDumpOSGetStreamOffset(PDUMP_STREAM_PARAM2); @@ -1079,7 +1086,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, { for (ui32Offset = 0; ui32Offset < ui32BlockBytes; ui32Offset += sizeof(IMG_UINT32)) { - IMG_UINT32 ui32PTE = *((IMG_UINT32 *) (pui8LinAddr + ui32Offset)); + IMG_UINT32 ui32PTE = *((IMG_UINT32 *)(IMG_UINTPTR_T)(pui8LinAddr + ui32Offset)); if ((ui32PTE & psMMUAttrib->ui32PDEMask) != 0) { @@ -1148,7 +1155,9 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, } else { +#if !defined(FIX_HW_BRN_31620) PVR_ASSERT((ui32PTE & psMMUAttrib->ui32PTEValid) == 0UL); +#endif eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "WRW :%s:PA_%08X%08X:0x%08X 0x%08X%08X\r\n", @@ -1380,20 +1389,38 @@ PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) ui32LenCommentPrefix = PDumpOSBuflen(pszCommentPrefix, sizeof(pszCommentPrefix)); + if (!PDumpOSWriteString(PDumpOSGetStream(PDUMP_STREAM_SCRIPT2), (IMG_UINT8*)pszCommentPrefix, ui32LenCommentPrefix, ui32Flags)) { +#if defined(PDUMP_DEBUG_OUTFILES) if(ui32Flags & PDUMP_FLAGS_CONTINUOUS) { + PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s (continuous set)", + g_ui32EveryLineCounter, pszComment)); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } + else if(ui32Flags & PDUMP_FLAGS_PERSISTENT) + { + PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s (persistent set)", + g_ui32EveryLineCounter, pszComment)); + return PVRSRV_ERROR_CMD_NOT_PROCESSED; + } else { + PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s", + g_ui32EveryLineCounter, pszComment)); return PVRSRV_ERROR_CMD_NOT_PROCESSED; } +#else + PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %s", + pszComment)); + return PVRSRV_ERROR_CMD_NOT_PROCESSED; +#endif } + #if defined(PDUMP_DEBUG_OUTFILES) eErr = PDumpOSSprintf(pszTemp, 256, "%d-%d %s", @@ -1501,7 +1528,7 @@ PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, IMG_UINT32 ui32PDumpFlags) { PVRSRV_DEVICE_IDENTIFIER *psDevId = &psDeviceNode->sDevId; - + IMG_UINT32 ui32MMUContextID; PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); @@ -1513,34 +1540,15 @@ PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); - - - PVR_UNREFERENCED_PARAMETER(hDevMemContext); - -#if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) - + ui32MMUContextID = psDeviceNode->pfnMMUGetContextID( hDevMemContext ); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SII %s %s.bin :%s:v%x:0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", pszFileName, pszFileName, psDevId->pszPDumpDevName, - PDUMP_DATAMASTER_PIXEL, - sDevBaseAddr.uiAddr, - ui32Size, - ui32FileOffset, - ePixelFormat, - ui32Width, - ui32Height, - ui32StrideInBytes, - eMemFormat); -#else - eErr = PDumpOSBufprintf(hScript, - ui32MaxLen, - "SII %s %s.bin :%s:v:0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", - pszFileName, - pszFileName, - psDevId->pszPDumpDevName, + ui32MMUContextID, sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, @@ -1549,7 +1557,6 @@ PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, ui32Height, ui32StrideInBytes, eMemFormat); -#endif if(eErr != PVRSRV_OK) { return eErr; @@ -1762,26 +1769,17 @@ PVRSRV_ERROR PDumpSaveMemKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, IMG_UINT32 ui32FileOffset, IMG_DEV_VIRTADDR sDevBaseAddr, IMG_UINT32 ui32Size, - IMG_UINT32 ui32DataMaster, + IMG_UINT32 ui32MMUContextID, IMG_UINT32 ui32PDumpFlags) { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); -#if !defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) - PVR_UNREFERENCED_PARAMETER(ui32DataMaster); -#endif - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, -#if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) "SAB :%s:v%x:0x%08X 0x%08X 0x%08X %s.bin\r\n", psDevId->pszPDumpDevName, - ui32DataMaster, -#else - "SAB :%s:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", - psDevId->pszPDumpDevName, -#endif + ui32MMUContextID, sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, @@ -1820,6 +1818,7 @@ PVRSRV_ERROR PDumpSignatureBuffer (PVRSRV_DEVICE_IDENTIFIER *psDevId, IMG_UINT32 ui32FileOffset, IMG_DEV_VIRTADDR sDevBaseAddr, IMG_UINT32 ui32Size, + IMG_UINT32 ui32MMUContextID, IMG_UINT32 ui32PDumpFlags) { PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump microkernel %s signature Buffer\r\n", @@ -1831,7 +1830,7 @@ PVRSRV_ERROR PDumpSignatureBuffer (PVRSRV_DEVICE_IDENTIFIER *psDevId, PDumpCommentWithFlags(ui32PDumpFlags, "\tSignature sample values (number of samples * number of signatures)\r\n"); PDumpCommentWithFlags(ui32PDumpFlags, "Note: If buffer is full, last sample is final state after test completed\r\n"); return PDumpSaveMemKM(psDevId, pszFileName, ui32FileOffset, sDevBaseAddr, ui32Size, - PDUMP_DATAMASTER_EDM, ui32PDumpFlags); + ui32MMUContextID, ui32PDumpFlags); } @@ -1840,11 +1839,12 @@ PVRSRV_ERROR PDumpHWPerfCBKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, IMG_UINT32 ui32FileOffset, IMG_DEV_VIRTADDR sDevBaseAddr, IMG_UINT32 ui32Size, + IMG_UINT32 ui32MMUContextID, IMG_UINT32 ui32PDumpFlags) { PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump Hardware Performance Circular Buffer\r\n"); return PDumpSaveMemKM(psDevId, pszFileName, ui32FileOffset, sDevBaseAddr, ui32Size, - PDUMP_DATAMASTER_EDM, ui32PDumpFlags); + ui32MMUContextID, ui32PDumpFlags); } @@ -1870,7 +1870,7 @@ PVRSRV_ERROR PDumpCBP(PPVRSRV_KERNEL_MEM_INFO psROffMemInfo, psMMUAttrib = ((BM_BUF*)psROffMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; - PVR_ASSERT((ui32ROffOffset + sizeof(IMG_UINT32)) <= psROffMemInfo->ui32AllocSize); + PVR_ASSERT((ui32ROffOffset + sizeof(IMG_UINT32)) <= psROffMemInfo->uAllocSize); pui8LinAddr = psROffMemInfo->pvLinAddrKM; sDevVAddr = psROffMemInfo->sDevVAddr; @@ -2073,13 +2073,14 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, IMG_CPU_PHYADDR sCpuPAddr; IMG_DEV_PHYADDR sDevPAddr; IMG_UINT32 ui32MMUContextID; - PVRSRV_ERROR eError; + PVRSRV_ERROR eErr; + PDUMP_GET_SCRIPT_STRING(); - eError = _PdumpAllocMMUContext(&ui32MMUContextID); - if(eError != PVRSRV_OK) + eErr = _PdumpAllocMMUContext(&ui32MMUContextID); + if(eErr != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "PDumpSetMMUContext: _PdumpAllocMMUContext failed: %d", eError)); - return eError; + PVR_DPF((PVR_DBG_ERROR, "PDumpSetMMUContext: _PdumpAllocMMUContext failed: %d", eErr)); + return eErr; } @@ -2089,15 +2090,20 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, sDevPAddr.uiAddr &= ~((PVRSRV_4K_PAGE_SIZE) -1); - PDumpComment("Set MMU Context\r\n"); - - PDumpComment("MMU :%s:v%d %d :%s:PA_%08X%08X\r\n", + eErr = PDumpOSBufprintf(hScript, + ui32MaxLen, + "MMU :%s:v%d %d :%s:PA_%08X%08X\r\n", pszMemSpace, ui32MMUContextID, ui32MMUType, pszMemSpace, (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, sDevPAddr.uiAddr); + if(eErr != PVRSRV_OK) + { + return eErr; + } + PDumpOSWriteString2(hScript, PDUMP_FLAGS_CONTINUOUS); *pui32MMUContextID = ui32MMUContextID; @@ -2111,23 +2117,29 @@ PVRSRV_ERROR PDumpClearMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, IMG_UINT32 ui32MMUContextID, IMG_UINT32 ui32MMUType) { - PVRSRV_ERROR eError; - + PVRSRV_ERROR eErr; + PDUMP_GET_SCRIPT_STRING(); PVR_UNREFERENCED_PARAMETER(eDeviceType); + PVR_UNREFERENCED_PARAMETER(ui32MMUType); PDumpComment("Clear MMU Context for memory space %s\r\n", pszMemSpace); - - PDumpComment("MMU :%s:v%d %d\r\n", + eErr = PDumpOSBufprintf(hScript, + ui32MaxLen, + "MMU :%s:v%d\r\n", pszMemSpace, - ui32MMUContextID, - ui32MMUType); + ui32MMUContextID); + if(eErr != PVRSRV_OK) + { + return eErr; + } + PDumpOSWriteString2(hScript, PDUMP_FLAGS_CONTINUOUS); - eError = _PdumpFreeMMUContext(ui32MMUContextID); - if(eError != PVRSRV_OK) + eErr = _PdumpFreeMMUContext(ui32MMUContextID); + if(eErr != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "PDumpClearMMUContext: _PdumpFreeMMUContext failed: %d", eError)); - return eError; + PVR_DPF((PVR_DBG_ERROR, "PDumpClearMMUContext: _PdumpFreeMMUContext failed: %d", eErr)); + return eErr; } return PVRSRV_OK; @@ -2151,7 +2163,7 @@ PVRSRV_ERROR PDumpStoreMemToFile(PDUMP_MMU_ATTRIB *psMMUAttrib, - ui32PageOffset = (IMG_UINT32)psMemInfo->pvLinAddrKM & psMMUAttrib->ui32DataPageMask; + ui32PageOffset = (IMG_UINT32)((IMG_UINTPTR_T)psMemInfo->pvLinAddrKM & psMMUAttrib->ui32DataPageMask); sDevVPageAddr.uiAddr = uiAddr - ui32PageOffset; @@ -2201,6 +2213,7 @@ PVRSRV_ERROR PDumpRegBasedCBP(IMG_CHAR *pszPDumpRegName, } + #include "syscommon.h" IMG_EXPORT IMG_VOID PDumpConnectionNotify(IMG_VOID) @@ -2235,7 +2248,7 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC { return ui32BCount; } - + #if defined(SUPPORT_PDUMP_MULTI_PROCESS) if ( (_PDumpIsProcessActive() == IMG_FALSE ) && @@ -2248,7 +2261,7 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC if ( ((ui32Flags & PDUMP_FLAGS_PERSISTENT) != 0) && (psCtrl->bInitPhaseComplete) ) { - while (((IMG_UINT32) ui32BCount > 0) && (ui32BytesWritten != 0xFFFFFFFFU)) + while (ui32BCount > 0) { diff --git a/drivers/gpu/pvr/pdump_int.h b/drivers/gpu/pvr/pdump_int.h index 3c03888..9f68549 100644 --- a/drivers/gpu/pvr/pdump_int.h +++ b/drivers/gpu/pvr/pdump_int.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 1be14d6..224e922 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -79,7 +79,7 @@ extern IMG_UINT32 g_ui32EveryLineCounter; IMG_UINT32 ui32Bytes, IMG_UINT32 ui32Flags, IMG_HANDLE hUniqueTag); - PVRSRV_ERROR PDumpMemPagesKM(PVRSRV_DEVICE_TYPE eDeviceType, + PVRSRV_ERROR PDumpMemPagesKM(PVRSRV_DEVICE_IDENTIFIER *psDevID, IMG_DEV_PHYADDR *pPages, IMG_UINT32 ui32NumPages, IMG_DEV_VIRTADDR sDevAddr, @@ -124,11 +124,13 @@ extern IMG_UINT32 g_ui32EveryLineCounter; IMG_UINT32 ui32RegAddr, IMG_UINT32 ui32RegValue, IMG_UINT32 ui32Mask, - IMG_UINT32 ui32Flags); + IMG_UINT32 ui32Flags, + PDUMP_POLL_OPERATOR eOperator); PVRSRV_ERROR PDumpRegPolKM(IMG_CHAR *pszPDumpRegName, IMG_UINT32 ui32RegAddr, IMG_UINT32 ui32RegValue, - IMG_UINT32 ui32Mask); + IMG_UINT32 ui32Mask, + PDUMP_POLL_OPERATOR eOperator); IMG_IMPORT PVRSRV_ERROR PDumpBitmapKM(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_CHAR *pszFileName, @@ -171,7 +173,7 @@ extern IMG_UINT32 g_ui32EveryLineCounter; IMG_BOOL PDumpIsLastCaptureFrameKM(IMG_VOID); IMG_IMPORT IMG_BOOL PDumpIsCaptureFrameKM(IMG_VOID); - IMG_VOID PDumpMallocPagesPhys(PVRSRV_DEVICE_TYPE eDeviceType, + IMG_VOID PDumpMallocPagesPhys(PVRSRV_DEVICE_IDENTIFIER *psDevID, IMG_UINT32 ui32DevVAddr, IMG_PUINT32 pui32PhysPages, IMG_UINT32 ui32NumPages, @@ -267,6 +269,7 @@ extern IMG_UINT32 g_ui32EveryLineCounter; IMG_UINT32 ui32FileOffset, IMG_DEV_VIRTADDR sDevBaseAddr, IMG_UINT32 ui32Size, + IMG_UINT32 ui32MMUContextID, IMG_UINT32 ui32PDumpFlags); PVRSRV_ERROR PDumpSignatureBuffer(PVRSRV_DEVICE_IDENTIFIER *psDevId, @@ -275,6 +278,7 @@ extern IMG_UINT32 g_ui32EveryLineCounter; IMG_UINT32 ui32FileOffset, IMG_DEV_VIRTADDR sDevBaseAddr, IMG_UINT32 ui32Size, + IMG_UINT32 ui32MMUContextID, IMG_UINT32 ui32PDumpFlags); PVRSRV_ERROR PDumpCBP(PPVRSRV_KERNEL_MEM_INFO psROffMemInfo, diff --git a/drivers/gpu/pvr/pdump_osfunc.h b/drivers/gpu/pvr/pdump_osfunc.h index 2c3b1e5..4daacf4 100644 --- a/drivers/gpu/pvr/pdump_osfunc.h +++ b/drivers/gpu/pvr/pdump_osfunc.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/pdumpdefs.h b/drivers/gpu/pvr/pdumpdefs.h index 83ccbb2..e43ce2f 100644 --- a/drivers/gpu/pvr/pdumpdefs.h +++ b/drivers/gpu/pvr/pdumpdefs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,7 +22,7 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +*****************************************************************************/ #if !defined (__PDUMPDEFS_H__) #define __PDUMPDEFS_H__ @@ -68,6 +68,15 @@ typedef enum _PDUMP_PIXEL_FORMAT_ PVRSRV_PDUMP_PIXEL_FORMAT_F32 = 36, PVRSRV_PDUMP_PIXEL_FORMAT_L16 = 37, PVRSRV_PDUMP_PIXEL_FORMAT_L32 = 38, + PVRSRV_PDUMP_PIXEL_FORMAT_RGBA8888 = 39, + PVRSRV_PDUMP_PIXEL_FORMAT_ABGR4444 = 40, + PVRSRV_PDUMP_PIXEL_FORMAT_RGBA4444 = 41, + PVRSRV_PDUMP_PIXEL_FORMAT_BGRA4444 = 42, + PVRSRV_PDUMP_PIXEL_FORMAT_ABGR1555 = 43, + PVRSRV_PDUMP_PIXEL_FORMAT_RGBA5551 = 44, + PVRSRV_PDUMP_PIXEL_FORMAT_BGRA5551 = 45, + PVRSRV_PDUMP_PIXEL_FORMAT_BGR565 = 46, + PVRSRV_PDUMP_PIXEL_FORMAT_A8 = 47, PVRSRV_PDUMP_PIXEL_FORMAT_FORCE_I32 = 0x7fffffff @@ -95,5 +104,8 @@ typedef enum _PDUMP_POLL_OPERATOR } PDUMP_POLL_OPERATOR; -#endif +#endif /* __PDUMPDEFS_H__ */ +/***************************************************************************** + End of file (pdumpdefs.h) +*****************************************************************************/ diff --git a/drivers/gpu/pvr/perfkm.h b/drivers/gpu/pvr/perfkm.h new file mode 100644 index 0000000..e12bc2e --- /dev/null +++ b/drivers/gpu/pvr/perfkm.h @@ -0,0 +1,36 @@ +/********************************************************************** + * + * 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 + * + ******************************************************************************/ + +#ifndef _PERFKM_H_ +#define _PERFKM_H_ + +#include "img_types.h" + +#define PERFINIT() +#define PERFDEINIT() + +#endif + diff --git a/drivers/gpu/pvr/perproc.c b/drivers/gpu/pvr/perproc.c index eb2530c..eb73166 100644 --- a/drivers/gpu/pvr/perproc.c +++ b/drivers/gpu/pvr/perproc.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -29,6 +29,9 @@ #include "handle.h" #include "perproc.h" #include "osperproc.h" +#if defined(TTRACE) +#include "ttrace.h" +#endif #define HASH_TAB_INIT_SIZE 32 @@ -124,7 +127,10 @@ PVRSRV_ERROR PVRSRVPerProcessDataConnect(IMG_UINT32 ui32PID, IMG_UINT32 ui32Flag IMG_HANDLE hBlockAlloc; PVRSRV_ERROR eError = PVRSRV_OK; - PVR_ASSERT(psHashTab != IMG_NULL); + if (psHashTab == IMG_NULL) + { + return PVRSRV_ERROR_INIT_FAILURE; + } psPerProc = (PVRSRV_PER_PROCESS_DATA *)HASH_Retrieve(psHashTab, (IMG_UINTPTR_T)ui32PID); @@ -161,7 +167,7 @@ PVRSRV_ERROR PVRSRVPerProcessDataConnect(IMG_UINT32 ui32PID, IMG_UINT32 ui32Flag psPerProc->bPDumpActive = IMG_TRUE; } #else - PVR_UNREFERENCED_PARAMETER(ui32Flags); + PVR_UNREFERENCED_PARAMETER(ui32Flags); #endif @@ -207,6 +213,9 @@ PVRSRV_ERROR PVRSRVPerProcessDataConnect(IMG_UINT32 ui32PID, IMG_UINT32 ui32Flag PVR_DPF((PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: Couldn't register with the resource manager")); goto failure; } +#if defined (TTRACE) + PVRSRVTimeTraceBufferCreate(ui32PID); +#endif } psPerProc->ui32RefCount++; @@ -242,6 +251,10 @@ IMG_VOID PVRSRVPerProcessDataDisconnect(IMG_UINT32 ui32PID) PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVPerProcessDataDisconnect: " "Last close from process 0x%x received", ui32PID)); +#if defined (TTRACE) + PVRSRVTimeTraceBufferDestroy(ui32PID); +#endif + PVRSRVResManDisconnect(psPerProc->hResManContext, IMG_FALSE); diff --git a/drivers/gpu/pvr/perproc.h b/drivers/gpu/pvr/perproc.h index c73ecf5..842680c 100644 --- a/drivers/gpu/pvr/perproc.h +++ b/drivers/gpu/pvr/perproc.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -41,12 +41,21 @@ typedef struct _PVRSRV_PER_PROCESS_DATA_ IMG_UINT32 ui32PID; IMG_HANDLE hBlockAlloc; PRESMAN_CONTEXT hResManContext; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hPerProcData; +#else IMG_HANDLE hPerProcData; +#endif PVRSRV_HANDLE_BASE *psHandleBase; +#if defined (SUPPORT_SID_INTERFACE) + + IMG_BOOL bHandlesBatched; +#else #if defined (PVR_SECURE_HANDLES) IMG_BOOL bHandlesBatched; #endif +#endif IMG_UINT32 ui32RefCount; diff --git a/drivers/gpu/pvr/power.c b/drivers/gpu/pvr/power.c index 04b3bf5..21d7ad4 100644 --- a/drivers/gpu/pvr/power.c +++ b/drivers/gpu/pvr/power.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -29,10 +29,6 @@ #include "lists.h" -#ifdef __linux__ -#include <linux/delay.h> -#endif - static IMG_BOOL gbInitServerRunning = IMG_FALSE; static IMG_BOOL gbInitServerRan = IMG_FALSE; static IMG_BOOL gbInitSuccessful = IMG_FALSE; @@ -97,28 +93,18 @@ PVRSRV_ERROR PVRSRVPowerLock(IMG_UINT32 ui32CallerID, IMG_BOOL bSystemPowerEvent) { PVRSRV_ERROR eError; - SYS_DATA *psSysData; - -#ifdef __linux__ - IMG_UINT32 ui32Timeout = 1000; -#else - IMG_UINT32 ui32Timeout = 1000000; -#endif - -#if defined(SUPPORT_LMA) - - ui32Timeout *= 60; -#endif + SYS_DATA *psSysData; + IMG_UINT32 ui32Timeout = 1000000; + IMG_BOOL bTryLock = (ui32CallerID == ISR_ID); SysAcquireData(&psSysData); -#if defined(SYS_CUSTOM_POWERLOCK_WRAP) - eError = SysPowerLockWrap(psSysData); + eError = OSPowerLockWrap(bTryLock); if (eError != PVRSRV_OK) { return eError; } -#endif + do { eError = OSLockResource(&psSysData->sPowerStateChangeResource, @@ -127,7 +113,7 @@ PVRSRV_ERROR PVRSRVPowerLock(IMG_UINT32 ui32CallerID, { break; } - else if (ui32CallerID == ISR_ID) + else if (bTryLock) { @@ -135,20 +121,15 @@ PVRSRV_ERROR PVRSRVPowerLock(IMG_UINT32 ui32CallerID, break; } -#ifdef __linux__ - msleep(1); -#else OSWaitus(1); -#endif ui32Timeout--; } while (ui32Timeout > 0); -#if defined(SYS_CUSTOM_POWERLOCK_WRAP) if (eError != PVRSRV_OK) { - SysPowerLockUnwrap(psSysData); + OSPowerLockUnwrap(); } -#endif + if ((eError == PVRSRV_OK) && !bSystemPowerEvent && @@ -167,9 +148,7 @@ IMG_EXPORT IMG_VOID PVRSRVPowerUnlock(IMG_UINT32 ui32CallerID) { OSUnlockResource(&gpsSysData->sPowerStateChangeResource, ui32CallerID); -#if defined(SYS_CUSTOM_POWERLOCK_WRAP) - SysPowerLockUnwrap(gpsSysData); -#endif + OSPowerLockUnwrap(); } @@ -573,7 +552,7 @@ PVRSRV_ERROR PVRSRVRegisterPowerDevice(IMG_UINT32 ui32DeviceIndex, SysAcquireData(&psSysData); - eError = OSAllocMem( PVRSRV_OS_PAGEABLE_HEAP, + eError = OSAllocMem( PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_POWER_DEV), (IMG_VOID **)&psPowerDevice, IMG_NULL, "Power Device"); diff --git a/drivers/gpu/pvr/power.h b/drivers/gpu/pvr/power.h index 079f212..9e3dcc40 100644 --- a/drivers/gpu/pvr/power.h +++ b/drivers/gpu/pvr/power.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/private_data.h b/drivers/gpu/pvr/private_data.h index 49974b8..b8751d3 100644 --- a/drivers/gpu/pvr/private_data.h +++ b/drivers/gpu/pvr/private_data.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -32,36 +32,24 @@ #include <drm/drmP.h> #endif -#if defined(SUPPORT_DRI_DRM) && defined(PVR_LINUX_USING_WORKQUEUES) -#include <linux/workqueue.h> -#endif - typedef struct { IMG_UINT32 ui32OpenPID; -#if defined(PVR_SECURE_FD_EXPORT) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else IMG_HANDLE hKernelMemInfo; -#endif - -#if defined(SUPPORT_DRI_DRM) -#if defined(PVR_SECURE_DRM_AUTH_EXPORT) - struct drm_file *psDRMFile; +#endif +#if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) struct list_head sDRMAuthListItem; -#endif -#if defined(PVR_LINUX_USING_WORKQUEUES) - struct work_struct sReleaseWork; -#endif - -#if defined(SUPPORT_DRI_DRM_EXT) - IMG_PVOID pPriv; + struct drm_file *psDRMFile; #endif -#endif #if defined(SUPPORT_MEMINFO_IDS) @@ -70,6 +58,10 @@ typedef struct IMG_HANDLE hBlockAlloc; + +#if defined(SUPPORT_DRI_DRM_EXT) + IMG_PVOID pPriv; +#endif } PVRSRV_FILE_PRIVATE_DATA; diff --git a/drivers/gpu/pvr/proc.c b/drivers/gpu/pvr/proc.c index 965346d..1df8aff 100644 --- a/drivers/gpu/pvr/proc.c +++ b/drivers/gpu/pvr/proc.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,13 +24,16 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif #include <linux/init.h> #include <linux/module.h> -#include <linux/version.h> #include <linux/fs.h> #include <linux/proc_fs.h> #include <linux/seq_file.h> diff --git a/drivers/gpu/pvr/proc.h b/drivers/gpu/pvr/proc.h index 823b666..2066d71 100644 --- a/drivers/gpu/pvr/proc.h +++ b/drivers/gpu/pvr/proc.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/pvr_bridge.h b/drivers/gpu/pvr/pvr_bridge.h index 7e4697d..d3e5916 100644 --- a/drivers/gpu/pvr/pvr_bridge.h +++ b/drivers/gpu/pvr/pvr_bridge.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -68,7 +68,7 @@ extern "C" { #define PVRSRV_BRIDGE_GETFREE_DEVICEMEM PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+8) #define PVRSRV_BRIDGE_CREATE_COMMANDQUEUE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+9) #define PVRSRV_BRIDGE_DESTROY_COMMANDQUEUE PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+10) -#define PVRSRV_BRIDGE_MHANDLE_TO_MMAP_DATA PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+11) +#define PVRSRV_BRIDGE_MHANDLE_TO_MMAP_DATA PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+11) #define PVRSRV_BRIDGE_CONNECT_SERVICES PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+12) #define PVRSRV_BRIDGE_DISCONNECT_SERVICES PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+13) #define PVRSRV_BRIDGE_WRAP_DEVICE_MEM PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+14) @@ -85,7 +85,10 @@ extern "C" { #define PVRSRV_BRIDGE_UNMAP_MEM_INFO_FROM_USER PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+25) #define PVRSRV_BRIDGE_EXPORT_DEVICEMEM PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+26) #define PVRSRV_BRIDGE_RELEASE_MMAP_DATA PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+27) -#define PVRSRV_BRIDGE_CORE_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+27) +#define PVRSRV_BRIDGE_CHG_DEV_MEM_ATTRIBS PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+28) +#define PVRSRV_BRIDGE_MAP_DEV_MEMORY_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+29) +#define PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2 PVRSRV_IOWR(PVRSRV_BRIDGE_CORE_CMD_FIRST+30) +#define PVRSRV_BRIDGE_CORE_CMD_LAST (PVRSRV_BRIDGE_CORE_CMD_FIRST+30) #define PVRSRV_BRIDGE_SIM_CMD_FIRST (PVRSRV_BRIDGE_CORE_CMD_LAST+1) #define PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT PVRSRV_IOWR(PVRSRV_BRIDGE_SIM_CMD_FIRST+0) @@ -165,10 +168,10 @@ extern "C" { #define PVRSRV_BRIDGE_SET_DISPCLASS_SRCCOLOURKEY PVRSRV_IOWR(PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+11) #define PVRSRV_BRIDGE_GET_DISPCLASS_BUFFERS PVRSRV_IOWR(PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+12) #define PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER PVRSRV_IOWR(PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+13) -#define PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_SYSTEM PVRSRV_IOWR(PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+14) -#define PVRSRV_BRIDGE_DISPCLASS_CMD_LAST (PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+14) +#define PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER2 PVRSRV_IOWR(PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+14) +#define PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_SYSTEM PVRSRV_IOWR(PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+15) +#define PVRSRV_BRIDGE_DISPCLASS_CMD_LAST (PVRSRV_BRIDGE_DISPCLASS_CMD_FIRST+15) - #define PVRSRV_BRIDGE_BUFCLASS_CMD_FIRST (PVRSRV_BRIDGE_DISPCLASS_CMD_LAST+1) #define PVRSRV_BRIDGE_OPEN_BUFFERCLASS_DEVICE PVRSRV_IOWR(PVRSRV_BRIDGE_BUFCLASS_CMD_FIRST+0) #define PVRSRV_BRIDGE_CLOSE_BUFFERCLASS_DEVICE PVRSRV_IOWR(PVRSRV_BRIDGE_BUFCLASS_CMD_FIRST+1) @@ -197,7 +200,7 @@ extern "C" { #define PVRSRV_BRIDGE_INITSRV_DISCONNECT PVRSRV_IOWR(PVRSRV_BRIDGE_INITSRV_CMD_FIRST+1) #define PVRSRV_BRIDGE_INITSRV_CMD_LAST (PVRSRV_BRIDGE_INITSRV_CMD_FIRST+1) -#define PVRSRV_BRIDGE_EVENT_OBJECT_CMD_FIRST (PVRSRV_BRIDGE_INITSRV_CMD_LAST+1) +#define PVRSRV_BRIDGE_EVENT_OBJECT_CMD_FIRST (PVRSRV_BRIDGE_INITSRV_CMD_LAST+1) #define PVRSRV_BRIDGE_EVENT_OBJECT_WAIT PVRSRV_IOWR(PVRSRV_BRIDGE_EVENT_OBJECT_CMD_FIRST+0) #define PVRSRV_BRIDGE_EVENT_OBJECT_OPEN PVRSRV_IOWR(PVRSRV_BRIDGE_EVENT_OBJECT_CMD_FIRST+1) #define PVRSRV_BRIDGE_EVENT_OBJECT_CLOSE PVRSRV_IOWR(PVRSRV_BRIDGE_EVENT_OBJECT_CMD_FIRST+2) @@ -208,12 +211,14 @@ extern "C" { #define PVRSRV_BRIDGE_DESTROY_SYNC_INFO_MOD_OBJ PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+1) #define PVRSRV_BRIDGE_MODIFY_PENDING_SYNC_OPS PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+2) #define PVRSRV_BRIDGE_MODIFY_COMPLETE_SYNC_OPS PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+3) -#define PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_MOD_OBJ PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+4) -#define PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_DELTA PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+5) -#define PVRSRV_BRIDGE_ALLOC_SYNC_INFO PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+6) -#define PVRSRV_BRIDGE_FREE_SYNC_INFO PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+7) -#define PVRSRV_BRIDGE_SYNC_OPS_CMD_LAST (PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+7) - +#define PVRSRV_BRIDGE_SYNC_OPS_TAKE_TOKEN PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+4) +#define PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_TOKEN PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+5) +#define PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_MOD_OBJ PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+6) +#define PVRSRV_BRIDGE_SYNC_OPS_FLUSH_TO_DELTA PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+7) +#define PVRSRV_BRIDGE_ALLOC_SYNC_INFO PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+8) +#define PVRSRV_BRIDGE_FREE_SYNC_INFO PVRSRV_IOWR(PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+9) +#define PVRSRV_BRIDGE_SYNC_OPS_CMD_LAST (PVRSRV_BRIDGE_SYNC_OPS_CMD_FIRST+9) + #define PVRSRV_BRIDGE_LAST_NON_DEVICE_CMD (PVRSRV_BRIDGE_SYNC_OPS_CMD_LAST+1) @@ -231,19 +236,19 @@ typedef struct PVRSRV_BRIDGE_PACKAGE_TAG { IMG_UINT32 ui32BridgeID; IMG_UINT32 ui32Size; - IMG_VOID *pvParamIn; + IMG_VOID *pvParamIn; IMG_UINT32 ui32InBufferSize; IMG_VOID *pvParamOut; IMG_UINT32 ui32OutBufferSize; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelServices; +#else IMG_HANDLE hKernelServices; +#endif }PVRSRV_BRIDGE_PACKAGE; - - - - typedef struct PVRSRV_BRIDGE_IN_CONNECT_SERVICES_TAG { IMG_UINT32 ui32BridgeFlags; @@ -268,56 +273,82 @@ typedef struct PVRSRV_BRIDGE_IN_ENUMCLASS_TAG typedef struct PVRSRV_BRIDGE_IN_CLOSE_DISPCLASS_DEVICE_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif } PVRSRV_BRIDGE_IN_CLOSE_DISPCLASS_DEVICE; typedef struct PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_FORMATS_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif } PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_FORMATS; typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_SYSBUFFER_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif } PVRSRV_BRIDGE_IN_GET_DISPCLASS_SYSBUFFER; typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_INFO_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif } PVRSRV_BRIDGE_IN_GET_DISPCLASS_INFO; typedef struct PVRSRV_BRIDGE_IN_CLOSE_BUFFERCLASS_DEVICE_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif } PVRSRV_BRIDGE_IN_CLOSE_BUFFERCLASS_DEVICE; typedef struct PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_INFO_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif } PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_INFO; - typedef struct PVRSRV_BRIDGE_IN_RELEASE_DEVICEINFO_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif } PVRSRV_BRIDGE_IN_RELEASE_DEVICEINFO; - typedef struct PVRSRV_BRIDGE_IN_FREE_CLASSDEVICEINFO_TAG { IMG_UINT32 ui32BridgeFlags; @@ -327,85 +358,119 @@ typedef struct PVRSRV_BRIDGE_IN_FREE_CLASSDEVICEINFO_TAG }PVRSRV_BRIDGE_IN_FREE_CLASSDEVICEINFO; - typedef struct PVRSRV_BRIDGE_IN_GET_DEVMEM_HEAPINFO_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; +#endif }PVRSRV_BRIDGE_IN_GET_DEVMEM_HEAPINFO; - typedef struct PVRSRV_BRIDGE_IN_CREATE_DEVMEMCONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif }PVRSRV_BRIDGE_IN_CREATE_DEVMEMCONTEXT; - typedef struct PVRSRV_BRIDGE_IN_DESTROY_DEVMEMCONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; +#endif }PVRSRV_BRIDGE_IN_DESTROY_DEVMEMCONTEXT; - typedef struct PVRSRV_BRIDGE_IN_ALLOCDEVICEMEM_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemHeap; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemHeap; +#endif IMG_UINT32 ui32Attribs; IMG_SIZE_T ui32Size; IMG_SIZE_T ui32Alignment; + IMG_PVOID pvPrivData; + IMG_UINT32 ui32PrivDataLength; }PVRSRV_BRIDGE_IN_ALLOCDEVICEMEM; - typedef struct PVRSRV_BRIDGE_IN_MAPMEMINFOTOUSER_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; +#endif }PVRSRV_BRIDGE_IN_MAPMEMINFOTOUSER; - typedef struct PVRSRV_BRIDGE_IN_UNMAPMEMINFOFROMUSER_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; +#endif IMG_PVOID pvLinAddr; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMappingInfo; +#else IMG_HANDLE hMappingInfo; +#endif }PVRSRV_BRIDGE_IN_UNMAPMEMINFOFROMUSER; - typedef struct PVRSRV_BRIDGE_IN_FREEDEVICEMEM_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hKernelMemInfo; +#else IMG_HANDLE hDevCookie; PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; }PVRSRV_BRIDGE_IN_FREEDEVICEMEM; - typedef struct PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hKernelMemInfo; +#else IMG_HANDLE hDevCookie; PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; +#endif }PVRSRV_BRIDGE_IN_EXPORTDEVICEMEM; - typedef struct PVRSRV_BRIDGE_IN_GETFREEDEVICEMEM_TAG { IMG_UINT32 ui32BridgeFlags; @@ -413,126 +478,163 @@ typedef struct PVRSRV_BRIDGE_IN_GETFREEDEVICEMEM_TAG } PVRSRV_BRIDGE_IN_GETFREEDEVICEMEM; - typedef struct PVRSRV_BRIDGE_IN_CREATECOMMANDQUEUE_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_SIZE_T ui32QueueSize; }PVRSRV_BRIDGE_IN_CREATECOMMANDQUEUE; - typedef struct PVRSRV_BRIDGE_IN_DESTROYCOMMANDQUEUE_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif PVRSRV_QUEUE_INFO *psQueueInfo; }PVRSRV_BRIDGE_IN_DESTROYCOMMANDQUEUE; - typedef struct PVRSRV_BRIDGE_IN_MHANDLE_TO_MMAP_DATA_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMHandle; +#else IMG_HANDLE hMHandle; +#endif } PVRSRV_BRIDGE_IN_MHANDLE_TO_MMAP_DATA; - typedef struct PVRSRV_BRIDGE_IN_RELEASE_MMAP_DATA_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMHandle; +#else IMG_HANDLE hMHandle; +#endif } PVRSRV_BRIDGE_IN_RELEASE_MMAP_DATA; - typedef struct PVRSRV_BRIDGE_IN_RESERVE_DEV_VIRTMEM_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeap; +#else IMG_HANDLE hDevMemHeap; +#endif IMG_DEV_VIRTADDR *psDevVAddr; IMG_SIZE_T ui32Size; IMG_SIZE_T ui32Alignment; }PVRSRV_BRIDGE_IN_RESERVE_DEV_VIRTMEM; - typedef struct PVRSRV_BRIDGE_OUT_CONNECT_SERVICES_TAG { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelServices; +#else IMG_HANDLE hKernelServices; +#endif }PVRSRV_BRIDGE_OUT_CONNECT_SERVICES; - typedef struct PVRSRV_BRIDGE_OUT_RESERVE_DEV_VIRTMEM_TAG { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; + IMG_SID hKernelSyncInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; - PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; + PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; }PVRSRV_BRIDGE_OUT_RESERVE_DEV_VIRTMEM; - typedef struct PVRSRV_BRIDGE_IN_FREE_DEV_VIRTMEM_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; - PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; + PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; }PVRSRV_BRIDGE_IN_FREE_DEV_VIRTMEM; - typedef struct PVRSRV_BRIDGE_IN_MAP_DEV_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; + IMG_SID hDstDevMemHeap; +#else IMG_HANDLE hKernelMemInfo; IMG_HANDLE hDstDevMemHeap; +#endif }PVRSRV_BRIDGE_IN_MAP_DEV_MEMORY; - typedef struct PVRSRV_BRIDGE_OUT_MAP_DEV_MEMORY_TAG { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDstKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psDstKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sDstClientMemInfo; - PVRSRV_CLIENT_SYNC_INFO sDstClientSyncInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sDstClientMemInfo; + PVRSRV_CLIENT_SYNC_INFO sDstClientSyncInfo; }PVRSRV_BRIDGE_OUT_MAP_DEV_MEMORY; - typedef struct PVRSRV_BRIDGE_IN_UNMAP_DEV_MEMORY_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; - PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; + PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; }PVRSRV_BRIDGE_IN_UNMAP_DEV_MEMORY; - typedef struct PVRSRV_BRIDGE_IN_MAP_EXT_MEMORY_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - IMG_SYS_PHYADDR *psSysPAddr; - IMG_UINT32 ui32Flags; +#endif + IMG_SYS_PHYADDR *psSysPAddr; + IMG_UINT32 ui32Flags; }PVRSRV_BRIDGE_IN_MAP_EXT_MEMORY; - typedef struct PVRSRV_BRIDGE_IN_UNMAP_EXT_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; @@ -542,44 +644,58 @@ typedef struct PVRSRV_BRIDGE_IN_UNMAP_EXT_MEMORY_TAG }PVRSRV_BRIDGE_IN_UNMAP_EXT_MEMORY; - typedef struct PVRSRV_BRIDGE_IN_MAP_DEVICECLASS_MEMORY_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceClassBuffer; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDeviceClassBuffer; IMG_HANDLE hDevMemContext; +#endif }PVRSRV_BRIDGE_IN_MAP_DEVICECLASS_MEMORY; - typedef struct PVRSRV_BRIDGE_OUT_MAP_DEVICECLASS_MEMORY_TAG { - PVRSRV_ERROR eError; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; + PVRSRV_ERROR eError; + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; + IMG_SID hMappingInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; IMG_HANDLE hMappingInfo; +#endif }PVRSRV_BRIDGE_OUT_MAP_DEVICECLASS_MEMORY; - typedef struct PVRSRV_BRIDGE_IN_UNMAP_DEVICECLASS_MEMORY_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; - PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; + PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; }PVRSRV_BRIDGE_IN_UNMAP_DEVICECLASS_MEMORY; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_MEMPOL_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; +#endif IMG_UINT32 ui32Offset; IMG_UINT32 ui32Value; IMG_UINT32 ui32Mask; @@ -588,25 +704,32 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_MEMPOL_TAG }PVRSRV_BRIDGE_IN_PDUMP_MEMPOL; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_SYNCPOL_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; - IMG_BOOL bIsRead; +#endif + IMG_BOOL bIsRead; + IMG_BOOL bUseLastOpDumpVal; IMG_UINT32 ui32Value; IMG_UINT32 ui32Mask; }PVRSRV_BRIDGE_IN_PDUMP_SYNCPOL; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPMEM_TAG { IMG_UINT32 ui32BridgeFlags; - IMG_PVOID pvLinAddr; - IMG_PVOID pvAltLinAddr; + IMG_PVOID pvLinAddr; + IMG_PVOID pvAltLinAddr; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; +#endif IMG_UINT32 ui32Offset; IMG_UINT32 ui32Bytes; IMG_UINT32 ui32Flags; @@ -614,41 +737,49 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPMEM_TAG }PVRSRV_BRIDGE_IN_PDUMP_DUMPMEM; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPSYNC_TAG { IMG_UINT32 ui32BridgeFlags; - IMG_PVOID pvAltLinAddr; + IMG_PVOID pvAltLinAddr; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; +#endif IMG_UINT32 ui32Offset; IMG_UINT32 ui32Bytes; }PVRSRV_BRIDGE_IN_PDUMP_DUMPSYNC; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPREG_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif PVRSRV_HWREG sHWReg; IMG_UINT32 ui32Flags; IMG_CHAR szRegRegion[32]; }PVRSRV_BRIDGE_IN_PDUMP_DUMPREG; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_REGPOL_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif PVRSRV_HWREG sHWReg; IMG_UINT32 ui32Mask; IMG_UINT32 ui32Flags; - IMG_CHAR szRegRegion[32]; + IMG_CHAR szRegRegion[32]; }PVRSRV_BRIDGE_IN_PDUMP_REGPOL; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPPDREG_TAG { IMG_UINT32 ui32BridgeFlags; @@ -657,21 +788,25 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPPDREG_TAG }PVRSRV_BRIDGE_IN_PDUMP_DUMPPDREG; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_MEMPAGES_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hKernelMemInfo; +#else + IMG_HANDLE hDevCookie; IMG_HANDLE hKernelMemInfo; +#endif IMG_DEV_PHYADDR *pPages; IMG_UINT32 ui32NumPages; - IMG_DEV_VIRTADDR sDevAddr; + IMG_DEV_VIRTADDR sDevVAddr; IMG_UINT32 ui32Start; IMG_UINT32 ui32Length; - IMG_BOOL bContinuous; + IMG_UINT32 ui32Flags; }PVRSRV_BRIDGE_IN_PDUMP_MEMPAGES; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_COMMENT_TAG { IMG_UINT32 ui32BridgeFlags; @@ -681,7 +816,6 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_COMMENT_TAG }PVRSRV_BRIDGE_IN_PDUMP_COMMENT; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_SETFRAME_TAG { IMG_UINT32 ui32BridgeFlags; @@ -690,19 +824,25 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_SETFRAME_TAG }PVRSRV_BRIDGE_IN_PDUMP_SETFRAME; - - typedef struct PVRSRV_BRIDGE_IN_PDUMP_BITMAP_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; - IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; +#endif + IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_UINT32 ui32Width; IMG_UINT32 ui32Height; IMG_UINT32 ui32StrideInBytes; IMG_DEV_VIRTADDR sDevBaseAddr; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevMemContext; +#endif IMG_UINT32 ui32Size; PDUMP_PIXEL_FORMAT ePixelFormat; PDUMP_MEM_FORMAT eMemFormat; @@ -711,21 +851,23 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_BITMAP_TAG }PVRSRV_BRIDGE_IN_PDUMP_BITMAP; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_READREG_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; - IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; +#endif + IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_UINT32 ui32Address; IMG_UINT32 ui32Size; IMG_UINT32 ui32Flags; - IMG_CHAR szRegRegion[32]; + IMG_CHAR szRegRegion[32]; }PVRSRV_BRIDGE_IN_PDUMP_READREG; - typedef struct PVRSRV_BRIDGE_IN_PDUMP_DRIVERINFO_TAG { IMG_UINT32 ui32BridgeFlags; @@ -737,21 +879,27 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_DRIVERINFO_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_DUMPPDDEVPADDR_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else IMG_HANDLE hKernelMemInfo; +#endif IMG_UINT32 ui32Offset; IMG_DEV_PHYADDR sPDDevPAddr; }PVRSRV_BRIDGE_IN_PDUMP_DUMPPDDEVPADDR; - typedef struct PVRSRV_BRIDGE_PDUM_IN_CYCLE_COUNT_REG_READ_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_UINT32 ui32RegOffset; IMG_BOOL bLastFrame; }PVRSRV_BRIDGE_IN_PDUMP_CYCLE_COUNT_REG_READ; - typedef struct PVRSRV_BRIDGE_OUT_ENUMDEVICE_TAG { PVRSRV_ERROR eError; @@ -761,17 +909,19 @@ typedef struct PVRSRV_BRIDGE_OUT_ENUMDEVICE_TAG }PVRSRV_BRIDGE_OUT_ENUMDEVICE; - typedef struct PVRSRV_BRIDGE_OUT_ACQUIRE_DEVICEINFO_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif } PVRSRV_BRIDGE_OUT_ACQUIRE_DEVICEINFO; - typedef struct PVRSRV_BRIDGE_OUT_ENUMCLASS_TAG { PVRSRV_ERROR eError; @@ -781,30 +931,40 @@ typedef struct PVRSRV_BRIDGE_OUT_ENUMCLASS_TAG }PVRSRV_BRIDGE_OUT_ENUMCLASS; - typedef struct PVRSRV_BRIDGE_IN_OPEN_DISPCLASS_DEVICE_TAG { IMG_UINT32 ui32BridgeFlags; IMG_UINT32 ui32DeviceID; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; - +#endif + }PVRSRV_BRIDGE_IN_OPEN_DISPCLASS_DEVICE; - typedef struct PVRSRV_BRIDGE_OUT_OPEN_DISPCLASS_DEVICE_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif }PVRSRV_BRIDGE_OUT_OPEN_DISPCLASS_DEVICE; - typedef struct PVRSRV_BRIDGE_IN_WRAP_EXT_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; +#endif IMG_VOID *pvLinAddr; IMG_SIZE_T ui32ByteSize; IMG_SIZE_T ui32PageOffset; @@ -815,7 +975,6 @@ typedef struct PVRSRV_BRIDGE_IN_WRAP_EXT_MEMORY_TAG }PVRSRV_BRIDGE_IN_WRAP_EXT_MEMORY; - typedef struct PVRSRV_BRIDGE_OUT_WRAP_EXT_MEMORY_TAG { PVRSRV_ERROR eError; @@ -824,11 +983,14 @@ typedef struct PVRSRV_BRIDGE_OUT_WRAP_EXT_MEMORY_TAG }PVRSRV_BRIDGE_OUT_WRAP_EXT_MEMORY; - typedef struct PVRSRV_BRIDGE_IN_UNWRAP_EXT_MEMORY_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else IMG_HANDLE hKernelMemInfo; +#endif PVRSRV_CLIENT_MEM_INFO sClientMemInfo; PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; @@ -840,7 +1002,6 @@ typedef struct PVRSRV_BRIDGE_IN_UNWRAP_EXT_MEMORY_TAG #define PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS 4 #define PVRSRV_MAX_DC_CLIP_RECTS 32 - typedef struct PVRSRV_BRIDGE_OUT_ENUM_DISPCLASS_FORMATS_TAG { PVRSRV_ERROR eError; @@ -850,17 +1011,19 @@ typedef struct PVRSRV_BRIDGE_OUT_ENUM_DISPCLASS_FORMATS_TAG }PVRSRV_BRIDGE_OUT_ENUM_DISPCLASS_FORMATS; - typedef struct PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_DIMS_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif DISPLAY_FORMAT sFormat; }PVRSRV_BRIDGE_IN_ENUM_DISPCLASS_DIMS; - typedef struct PVRSRV_BRIDGE_OUT_ENUM_DISPCLASS_DIMS_TAG { PVRSRV_ERROR eError; @@ -870,7 +1033,6 @@ typedef struct PVRSRV_BRIDGE_OUT_ENUM_DISPCLASS_DIMS_TAG }PVRSRV_BRIDGE_OUT_ENUM_DISPCLASS_DIMS; - typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_INFO_TAG { PVRSRV_ERROR eError; @@ -879,20 +1041,26 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_INFO_TAG }PVRSRV_BRIDGE_OUT_GET_DISPCLASS_INFO; - typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_SYSBUFFER_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hBuffer; +#else IMG_HANDLE hBuffer; +#endif }PVRSRV_BRIDGE_OUT_GET_DISPCLASS_SYSBUFFER; - typedef struct PVRSRV_BRIDGE_IN_CREATE_DISPCLASS_SWAPCHAIN_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif IMG_UINT32 ui32Flags; DISPLAY_SURF_ATTRIBUTES sDstSurfAttrib; DISPLAY_SURF_ATTRIBUTES sSrcSurfAttrib; @@ -903,112 +1071,171 @@ typedef struct PVRSRV_BRIDGE_IN_CREATE_DISPCLASS_SWAPCHAIN_TAG } PVRSRV_BRIDGE_IN_CREATE_DISPCLASS_SWAPCHAIN; - typedef struct PVRSRV_BRIDGE_OUT_CREATE_DISPCLASS_SWAPCHAIN_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain; +#else IMG_HANDLE hSwapChain; +#endif IMG_UINT32 ui32SwapChainID; } PVRSRV_BRIDGE_OUT_CREATE_DISPCLASS_SWAPCHAIN; - typedef struct PVRSRV_BRIDGE_IN_DESTROY_DISPCLASS_SWAPCHAIN_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; + IMG_SID hSwapChain; +#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; +#endif } PVRSRV_BRIDGE_IN_DESTROY_DISPCLASS_SWAPCHAIN; - typedef struct PVRSRV_BRIDGE_IN_SET_DISPCLASS_RECT_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; + IMG_SID hSwapChain; +#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; +#endif IMG_RECT sRect; } PVRSRV_BRIDGE_IN_SET_DISPCLASS_RECT; - typedef struct PVRSRV_BRIDGE_IN_SET_DISPCLASS_COLOURKEY_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; + IMG_SID hSwapChain; +#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; +#endif IMG_UINT32 ui32CKColour; } PVRSRV_BRIDGE_IN_SET_DISPCLASS_COLOURKEY; - typedef struct PVRSRV_BRIDGE_IN_GET_DISPCLASS_BUFFERS_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; + IMG_SID hSwapChain; +#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; +#endif } PVRSRV_BRIDGE_IN_GET_DISPCLASS_BUFFERS; - typedef struct PVRSRV_BRIDGE_OUT_GET_DISPCLASS_BUFFERS_TAG { PVRSRV_ERROR eError; IMG_UINT32 ui32BufferCount; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahBuffer[PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS]; +#else IMG_HANDLE ahBuffer[PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS]; - +#endif + IMG_SYS_PHYADDR asPhyAddr[PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS]; } PVRSRV_BRIDGE_OUT_GET_DISPCLASS_BUFFERS; - typedef struct PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; + IMG_SID hBuffer; +#else IMG_HANDLE hDeviceKM; IMG_HANDLE hBuffer; +#endif IMG_UINT32 ui32SwapInterval; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hPrivateTag; +#else IMG_HANDLE hPrivateTag; +#endif IMG_UINT32 ui32ClipRectCount; IMG_RECT sClipRect[PVRSRV_MAX_DC_CLIP_RECTS]; } PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER; +typedef struct PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER2_TAG +{ + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; + IMG_SID hSwapChain; +#else + IMG_HANDLE hDeviceKM; + IMG_HANDLE hSwapChain; +#endif + IMG_UINT32 ui32SwapInterval; + + IMG_UINT32 ui32NumMemInfos; + PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfos; + PVRSRV_KERNEL_SYNC_INFO **ppsKernelSyncInfos; + + IMG_UINT32 ui32PrivDataLength; + IMG_PVOID pvPrivData; + +} PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_BUFFER2; - typedef struct PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_SYSTEM_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; + IMG_SID hSwapChain; +#else IMG_HANDLE hDeviceKM; IMG_HANDLE hSwapChain; +#endif } PVRSRV_BRIDGE_IN_SWAP_DISPCLASS_TO_SYSTEM; - typedef struct PVRSRV_BRIDGE_IN_OPEN_BUFFERCLASS_DEVICE_TAG { IMG_UINT32 ui32BridgeFlags; IMG_UINT32 ui32DeviceID; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; - +#endif + } PVRSRV_BRIDGE_IN_OPEN_BUFFERCLASS_DEVICE; - typedef struct PVRSRV_BRIDGE_OUT_OPEN_BUFFERCLASS_DEVICE_TAG { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif } PVRSRV_BRIDGE_OUT_OPEN_BUFFERCLASS_DEVICE; - typedef struct PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_INFO_TAG { PVRSRV_ERROR eError; @@ -1017,26 +1244,31 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_INFO_TAG } PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_INFO; - typedef struct PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_BUFFER_TAG { - IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; - IMG_UINT32 ui32BufferIndex; +#endif + IMG_UINT32 ui32BufferIndex; } PVRSRV_BRIDGE_IN_GET_BUFFERCLASS_BUFFER; - typedef struct PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_BUFFER_TAG { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hBuffer; +#else IMG_HANDLE hBuffer; +#endif } PVRSRV_BRIDGE_OUT_GET_BUFFERCLASS_BUFFER; - typedef struct PVRSRV_BRIDGE_OUT_GET_DEVMEM_HEAPINFO_TAG { PVRSRV_ERROR eError; @@ -1046,42 +1278,54 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_DEVMEM_HEAPINFO_TAG } PVRSRV_BRIDGE_OUT_GET_DEVMEM_HEAPINFO; - typedef struct PVRSRV_BRIDGE_OUT_CREATE_DEVMEMCONTEXT_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevMemContext; +#endif IMG_UINT32 ui32ClientHeapCount; PVRSRV_HEAP_INFO sHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; } PVRSRV_BRIDGE_OUT_CREATE_DEVMEMCONTEXT; - typedef struct PVRSRV_BRIDGE_OUT_CREATE_DEVMEMHEAP_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeap; +#else IMG_HANDLE hDevMemHeap; +#endif } PVRSRV_BRIDGE_OUT_CREATE_DEVMEMHEAP; - typedef struct PVRSRV_BRIDGE_OUT_ALLOCDEVICEMEM_TAG { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; - PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; + PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; } PVRSRV_BRIDGE_OUT_ALLOCDEVICEMEM; - typedef struct PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMemInfo; +#else IMG_HANDLE hMemInfo; +#endif #if defined(SUPPORT_MEMINFO_IDS) IMG_UINT64 ui64Stamp; #endif @@ -1093,12 +1337,15 @@ typedef struct PVRSRV_BRIDGE_OUT_MAPMEMINFOTOUSER_TAG { PVRSRV_ERROR eError; IMG_PVOID pvLinAddr; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMappingInfo; +#else IMG_HANDLE hMappingInfo; +#endif }PVRSRV_BRIDGE_OUT_MAPMEMINFOTOUSER; - typedef struct PVRSRV_BRIDGE_OUT_GETFREEDEVICEMEM_TAG { PVRSRV_ERROR eError; @@ -1113,7 +1360,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GETFREEDEVICEMEM_TAG typedef struct PVRSRV_BRIDGE_OUT_MHANDLE_TO_MMAP_DATA_TAG { PVRSRV_ERROR eError; - + IMG_UINT32 ui32MMapOffset; @@ -1131,7 +1378,7 @@ typedef struct PVRSRV_BRIDGE_OUT_MHANDLE_TO_MMAP_DATA_TAG typedef struct PVRSRV_BRIDGE_OUT_RELEASE_MMAP_DATA_TAG { PVRSRV_ERROR eError; - + IMG_BOOL bMUnmap; @@ -1141,7 +1388,6 @@ typedef struct PVRSRV_BRIDGE_OUT_RELEASE_MMAP_DATA_TAG IMG_UINT32 ui32RealByteSize; } PVRSRV_BRIDGE_OUT_RELEASE_MMAP_DATA; - typedef struct PVRSRV_BRIDGE_IN_GET_MISC_INFO_TAG { IMG_UINT32 ui32BridgeFlags; @@ -1150,7 +1396,6 @@ typedef struct PVRSRV_BRIDGE_IN_GET_MISC_INFO_TAG }PVRSRV_BRIDGE_IN_GET_MISC_INFO; - typedef struct PVRSRV_BRIDGE_OUT_GET_MISC_INFO_TAG { PVRSRV_ERROR eError; @@ -1159,7 +1404,6 @@ typedef struct PVRSRV_BRIDGE_OUT_GET_MISC_INFO_TAG }PVRSRV_BRIDGE_OUT_GET_MISC_INFO; - typedef struct PVRSRV_BRIDGE_IN_RELEASE_MISC_INFO_TAG { IMG_UINT32 ui32BridgeFlags; @@ -1168,7 +1412,6 @@ typedef struct PVRSRV_BRIDGE_IN_RELEASE_MISC_INFO_TAG }PVRSRV_BRIDGE_IN_RELEASE_MISC_INFO; - typedef struct PVRSRV_BRIDGE_OUT_RELEASE_MISC_INFO_TAG { PVRSRV_ERROR eError; @@ -1177,8 +1420,6 @@ typedef struct PVRSRV_BRIDGE_OUT_RELEASE_MISC_INFO_TAG }PVRSRV_BRIDGE_OUT_RELEASE_MISC_INFO; - - typedef struct PVRSRV_BRIDGE_OUT_PDUMP_ISCAPTURING_TAG { PVRSRV_ERROR eError; @@ -1186,8 +1427,7 @@ typedef struct PVRSRV_BRIDGE_OUT_PDUMP_ISCAPTURING_TAG } PVRSRV_BRIDGE_OUT_PDUMP_ISCAPTURING; - -typedef struct PVRSRV_BRIDGE_IN_GET_FB_STATS_TAG +typedef struct PVRSRV_BRIDGE_IN_GET_FB_STATS_TAG { IMG_UINT32 ui32BridgeFlags; IMG_SIZE_T ui32Total; @@ -1196,18 +1436,20 @@ typedef struct PVRSRV_BRIDGE_IN_GET_FB_STATS_TAG } PVRSRV_BRIDGE_IN_GET_FB_STATS; - typedef struct PVRSRV_BRIDGE_IN_MAPPHYSTOUSERSPACE_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_SYS_PHYADDR sSysPhysAddr; IMG_UINT32 uiSizeInBytes; } PVRSRV_BRIDGE_IN_MAPPHYSTOUSERSPACE; - typedef struct PVRSRV_BRIDGE_OUT_MAPPHYSTOUSERSPACE_TAG { IMG_PVOID pvUserAddr; @@ -1217,18 +1459,20 @@ typedef struct PVRSRV_BRIDGE_OUT_MAPPHYSTOUSERSPACE_TAG } PVRSRV_BRIDGE_OUT_MAPPHYSTOUSERSPACE; - typedef struct PVRSRV_BRIDGE_IN_UNMAPPHYSTOUSERSPACE_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_PVOID pvUserAddr; IMG_PVOID pvProcess; } PVRSRV_BRIDGE_IN_UNMAPPHYSTOUSERSPACE; - typedef struct PVRSRV_BRIDGE_OUT_GETPHYSTOUSERSPACEMAP_TAG { IMG_PVOID *ppvTbl; @@ -1237,7 +1481,7 @@ typedef struct PVRSRV_BRIDGE_OUT_GETPHYSTOUSERSPACEMAP_TAG } PVRSRV_BRIDGE_OUT_GETPHYSTOUSERSPACEMAP; - +#if !defined (SUPPORT_SID_INTERFACE) typedef struct PVRSRV_BRIDGE_IN_REGISTER_SIM_PROCESS_TAG { IMG_UINT32 ui32BridgeFlags; @@ -1275,6 +1519,7 @@ typedef struct PVRSRV_BRIDGE_IN_PROCESS_SIMISR_EVENT_TAG PVRSRV_ERROR eError; } PVRSRV_BRIDGE_IN_PROCESS_SIMISR_EVENT; +#endif typedef struct PVRSRV_BRIDGE_IN_INITSRV_DISCONNECT_TAG { @@ -1292,16 +1537,24 @@ typedef struct PVRSRV_BRIDGE_IN_ALLOC_SHARED_SYS_MEM_TAG typedef struct PVRSRV_BRIDGE_OUT_ALLOC_SHARED_SYS_MEM_TAG { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; }PVRSRV_BRIDGE_OUT_ALLOC_SHARED_SYS_MEM; typedef struct PVRSRV_BRIDGE_IN_FREE_SHARED_SYS_MEM_TAG { - IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; + IMG_SID hMappingInfo; +#else + IMG_UINT32 ui32BridgeFlags; PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; - PVRSRV_CLIENT_MEM_INFO sClientMemInfo; +#endif + PVRSRV_CLIENT_MEM_INFO sClientMemInfo; }PVRSRV_BRIDGE_IN_FREE_SHARED_SYS_MEM; typedef struct PVRSRV_BRIDGE_OUT_FREE_SHARED_SYS_MEM_TAG @@ -1312,14 +1565,22 @@ typedef struct PVRSRV_BRIDGE_OUT_FREE_SHARED_SYS_MEM_TAG typedef struct PVRSRV_BRIDGE_IN_MAP_MEMINFO_MEM_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else IMG_HANDLE hKernelMemInfo; +#endif }PVRSRV_BRIDGE_IN_MAP_MEMINFO_MEM; typedef struct PVRSRV_BRIDGE_OUT_MAP_MEMINFO_MEM_TAG { PVRSRV_CLIENT_MEM_INFO sClientMemInfo; - PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; + PVRSRV_CLIENT_SYNC_INFO sClientSyncInfo; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; +#endif PVRSRV_ERROR eError; }PVRSRV_BRIDGE_OUT_MAP_MEMINFO_MEM; @@ -1337,7 +1598,11 @@ typedef struct PVRSRV_BRIDGE_OUT_UNMAP_MEMINFO_MEM_TAG typedef struct PVRSRV_BRIDGE_IN_GETMMU_PD_DEVPADDR_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevMemContext; +#endif }PVRSRV_BRIDGE_IN_GETMMU_PD_DEVPADDR; typedef struct PVRSRV_BRIDGE_OUT_GETMMU_PD_DEVPADDR_TAG @@ -1349,7 +1614,11 @@ typedef struct PVRSRV_BRIDGE_OUT_GETMMU_PD_DEVPADDR_TAG typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_WAI_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hOSEventKM; +#else IMG_HANDLE hOSEventKM; +#endif } PVRSRV_BRIDGE_IN_EVENT_OBJECT_WAIT; typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_OPEN_TAG @@ -1359,35 +1628,56 @@ typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_OPEN_TAG typedef struct PVRSRV_BRIDGE_OUT_EVENT_OBJECT_OPEN_TAG { +#if defined (SUPPORT_SID_INTERFACE) + IMG_UINT32 hOSEvent; +#else IMG_HANDLE hOSEvent; +#endif PVRSRV_ERROR eError; } PVRSRV_BRIDGE_OUT_EVENT_OBJECT_OPEN; typedef struct PVRSRV_BRIDGE_IN_EVENT_OBJECT_CLOSE_TAG { PVRSRV_EVENTOBJECT sEventObject; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hOSEventKM; +#else IMG_HANDLE hOSEventKM; +#endif } PVRSRV_BRIDGE_IN_EVENT_OBJECT_CLOSE; typedef struct PVRSRV_BRIDGE_OUT_CREATE_SYNC_INFO_MOD_OBJ_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj; +#else IMG_HANDLE hKernelSyncInfoModObj; +#endif } PVRSRV_BRIDGE_OUT_CREATE_SYNC_INFO_MOD_OBJ; typedef struct PVRSRV_BRIDGE_IN_DESTROY_SYNC_INFO_MOD_OBJ { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj; +#else IMG_HANDLE hKernelSyncInfoModObj; +#endif } PVRSRV_BRIDGE_IN_DESTROY_SYNC_INFO_MOD_OBJ; typedef struct PVRSRV_BRIDGE_IN_MODIFY_PENDING_SYNC_OPS_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj; + IMG_SID hKernelSyncInfo; +#else IMG_HANDLE hKernelSyncInfoModObj; IMG_HANDLE hKernelSyncInfo; +#endif IMG_UINT32 ui32ModifyFlags; } PVRSRV_BRIDGE_IN_MODIFY_PENDING_SYNC_OPS; @@ -1395,7 +1685,11 @@ typedef struct PVRSRV_BRIDGE_IN_MODIFY_PENDING_SYNC_OPS_TAG typedef struct PVRSRV_BRIDGE_IN_MODIFY_COMPLETE_SYNC_OPS_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj; +#else IMG_HANDLE hKernelSyncInfoModObj; +#endif } PVRSRV_BRIDGE_IN_MODIFY_COMPLETE_SYNC_OPS; typedef struct PVRSRV_BRIDGE_OUT_MODIFY_PENDING_SYNC_OPS_TAG @@ -1405,19 +1699,62 @@ typedef struct PVRSRV_BRIDGE_OUT_MODIFY_PENDING_SYNC_OPS_TAG IMG_UINT32 ui32ReadOpsPending; IMG_UINT32 ui32WriteOpsPending; + IMG_UINT32 ui32ReadOps2Pending; } PVRSRV_BRIDGE_OUT_MODIFY_PENDING_SYNC_OPS; +typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_TAKE_TOKEN_TAG +{ + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else + IMG_HANDLE hKernelSyncInfo; +#endif + +} PVRSRV_BRIDGE_IN_SYNC_OPS_TAKE_TOKEN; + +typedef struct PVRSRV_BRIDGE_OUT_SYNC_OPS_TAKE_TOKEN_TAG +{ + PVRSRV_ERROR eError; + + IMG_UINT32 ui32ReadOpsPending; + IMG_UINT32 ui32WriteOpsPending; + IMG_UINT32 ui32ReadOps2Pending; + +} PVRSRV_BRIDGE_OUT_SYNC_OPS_TAKE_TOKEN; + +typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_TOKEN_TAG +{ + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else + IMG_HANDLE hKernelSyncInfo; +#endif + IMG_UINT32 ui32ReadOpsPendingSnapshot; + IMG_UINT32 ui32WriteOpsPendingSnapshot; + IMG_UINT32 ui32ReadOps2PendingSnapshot; +} PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_TOKEN; + typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_MOD_OBJ_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj; +#else IMG_HANDLE hKernelSyncInfoModObj; +#endif } PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_MOD_OBJ; typedef struct PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_DELTA_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else IMG_HANDLE hKernelSyncInfo; +#endif IMG_UINT32 ui32Delta; } PVRSRV_BRIDGE_IN_SYNC_OPS_FLUSH_TO_DELTA; @@ -1425,23 +1762,41 @@ typedef struct PVRSRV_BRIDGE_IN_ALLOC_SYNC_INFO_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif } PVRSRV_BRIDGE_IN_ALLOC_SYNC_INFO; typedef struct PVRSRV_BRIDGE_OUT_ALLOC_SYNC_INFO_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else IMG_HANDLE hKernelSyncInfo; +#endif } PVRSRV_BRIDGE_OUT_ALLOC_SYNC_INFO; typedef struct PVRSRV_BRIDGE_IN_FREE_SYNC_INFO_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else IMG_HANDLE hKernelSyncInfo; +#endif } PVRSRV_BRIDGE_IN_FREE_SYNC_INFO; +typedef struct PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS_TAG +{ + IMG_SID hKernelMemInfo; + IMG_UINT32 ui32Attribs; +} PVRSRV_BRIDGE_IN_CHG_DEV_MEM_ATTRIBS; + #if defined (__cplusplus) } diff --git a/drivers/gpu/pvr/pvr_bridge_k.c b/drivers/gpu/pvr/pvr_bridge_k.c index 3abf604..91a75a9 100644 --- a/drivers/gpu/pvr/pvr_bridge_k.c +++ b/drivers/gpu/pvr/pvr_bridge_k.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -54,12 +54,6 @@ #include "bridged_pvr_bridge.h" -#ifdef MODULE_TEST -#include "pvr_test_bridge.h" -#include "kern_test.h" -#endif - - #if defined(SUPPORT_DRI_DRM) #define PRIVATE_DATA(pFile) ((pFile)->driver_priv) #else @@ -234,150 +228,6 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig #endif cmd = psBridgePackageKM->ui32BridgeID; - -#if defined(MODULE_TEST) - switch (cmd) - { - case PVRSRV_BRIDGE_SERVICES_TEST_MEM1: - { - PVRSRV_ERROR eError = MemTest1(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - case PVRSRV_BRIDGE_SERVICES_TEST_MEM2: - { - PVRSRV_ERROR eError = MemTest2(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - case PVRSRV_BRIDGE_SERVICES_TEST_RESOURCE: - { - PVRSRV_ERROR eError = ResourceTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - case PVRSRV_BRIDGE_SERVICES_TEST_EVENTOBJECT: - { - PVRSRV_ERROR eError = EventObjectTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - case PVRSRV_BRIDGE_SERVICES_TEST_MEMMAPPING: - { - PVRSRV_ERROR eError = MemMappingTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - case PVRSRV_BRIDGE_SERVICES_TEST_PROCESSID: - { - PVRSRV_ERROR eError = ProcessIDTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - case PVRSRV_BRIDGE_SERVICES_TEST_CLOCKUSWAITUS: - { - PVRSRV_ERROR eError = ClockusWaitusTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - case PVRSRV_BRIDGE_SERVICES_TEST_TIMER: - { - PVRSRV_ERROR eError = TimerTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - case PVRSRV_BRIDGE_SERVICES_TEST_PRIVSRV: - { - PVRSRV_ERROR eError = PrivSrvTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - case PVRSRV_BRIDGE_SERVICES_TEST_COPYDATA: - { - IMG_UINT32 ui32PID; - PVRSRV_PER_PROCESS_DATA *psPerProc; - PVRSRV_ERROR eError; - - ui32PID = OSGetCurrentProcessIDKM(); - - PVRSRVTrace("PVRSRV_BRIDGE_SERVICES_TEST_COPYDATA %d", ui32PID); - - psPerProc = PVRSRVPerProcessData(ui32PID); - - eError = CopyDataTest(psBridgePackageKM->pvParamIn, psBridgePackageKM->pvParamOut, psPerProc); - - *(PVRSRV_ERROR*)psBridgePackageKM->pvParamOut = eError; - err = 0; - goto unlock_and_return; - } - - - case PVRSRV_BRIDGE_SERVICES_TEST_POWERMGMT: - { - PVRSRV_ERROR eError = PowerMgmtTest(); - if (psBridgePackageKM->ui32OutBufferSize == sizeof(PVRSRV_BRIDGE_RETURN)) - { - PVRSRV_BRIDGE_RETURN* pReturn = (PVRSRV_BRIDGE_RETURN*)psBridgePackageKM->pvParamOut ; - pReturn->eError = eError; - } - } - err = 0; - goto unlock_and_return; - - } -#endif if(cmd != PVRSRV_BRIDGE_CONNECT_SERVICES) { @@ -416,10 +266,9 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig psBridgePackageKM->ui32BridgeID = PVRSRV_GET_BRIDGE_ID(psBridgePackageKM->ui32BridgeID); -#if defined(PVR_SECURE_FD_EXPORT) switch(cmd) { - case PVRSRV_BRIDGE_EXPORT_DEVICEMEM: + case PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2: { PVRSRV_FILE_PRIVATE_DATA *psPrivateData = PRIVATE_DATA(pFile); @@ -433,7 +282,7 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig break; } - case PVRSRV_BRIDGE_MAP_DEV_MEMORY: + case PVRSRV_BRIDGE_MAP_DEV_MEMORY_2: { PVRSRV_BRIDGE_IN_MAP_DEV_MEMORY *psMapDevMemIN = (PVRSRV_BRIDGE_IN_MAP_DEV_MEMORY *)psBridgePackageKM->pvParamIn; @@ -464,7 +313,7 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig break; } } -#endif + #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) switch(cmd) { @@ -522,23 +371,39 @@ PVRSRV_BridgeDispatchKM(struct file *pFile, unsigned int unref__ ioctlCmd, unsig switch(cmd) { -#if defined(PVR_SECURE_FD_EXPORT) - case PVRSRV_BRIDGE_EXPORT_DEVICEMEM: + case PVRSRV_BRIDGE_EXPORT_DEVICEMEM_2: { PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM *psExportDeviceMemOUT = (PVRSRV_BRIDGE_OUT_EXPORTDEVICEMEM *)psBridgePackageKM->pvParamOut; PVRSRV_FILE_PRIVATE_DATA *psPrivateData = PRIVATE_DATA(pFile); + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + + + if(PVRSRVLookupHandle(KERNEL_HANDLE_BASE, + (IMG_PVOID *)&psKernelMemInfo, + psExportDeviceMemOUT->hMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to look up export handle", __FUNCTION__)); + err = -EFAULT; + goto unlock_and_return; + } + + + psKernelMemInfo->ui32RefCount++; psPrivateData->hKernelMemInfo = psExportDeviceMemOUT->hMemInfo; #if defined(SUPPORT_MEMINFO_IDS) - psExportDeviceMemOUT->ui64Stamp = psPrivateData->ui64Stamp = ++ui64Stamp; + psKernelMemInfo->ui64Stamp = + psExportDeviceMemOUT->ui64Stamp = + psPrivateData->ui64Stamp = ++ui64Stamp; #endif break; } -#endif #if defined(SUPPORT_MEMINFO_IDS) case PVRSRV_BRIDGE_MAP_DEV_MEMORY: + case PVRSRV_BRIDGE_MAP_DEV_MEMORY_2: { PVRSRV_BRIDGE_OUT_MAP_DEV_MEMORY *psMapDeviceMemoryOUT = (PVRSRV_BRIDGE_OUT_MAP_DEV_MEMORY *)psBridgePackageKM->pvParamOut; diff --git a/drivers/gpu/pvr/pvr_bridge_km.h b/drivers/gpu/pvr/pvr_bridge_km.h index d5592c2..184e999 100644 --- a/drivers/gpu/pvr/pvr_bridge_km.h +++ b/drivers/gpu/pvr/pvr_bridge_km.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -57,14 +57,22 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapsKM(IMG_HANDLE hDevCookie, +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM *psHeapInfo); +#else PVRSRV_HEAP_INFO *psHeapInfo); +#endif IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCookie, PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE *phDevMemContext, IMG_UINT32 *pui32ClientHeapCount, +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM *psHeapInfo, +#else PVRSRV_HEAP_INFO *psHeapInfo, +#endif IMG_BOOL *pbCreated, IMG_BOOL *pbShared); @@ -79,7 +87,11 @@ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie, IMG_HANDLE hDevMemContext, IMG_UINT32 *pui32ClientHeapCount, +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM *psHeapInfo, +#else PVRSRV_HEAP_INFO *psHeapInfo, +#endif IMG_BOOL *pbShared ); @@ -91,17 +103,19 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, IMG_UINT32 ui32Flags, IMG_SIZE_T ui32Size, IMG_SIZE_T ui32Alignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, PVRSRV_KERNEL_MEM_INFO **ppsMemInfo); #if defined(PVRSRV_LOG_MEMORY_ALLOCS) - #define PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, memInfo, logStr) \ + #define PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, privdata, privdatalength, memInfo, logStr) \ (PVR_TRACE(("PVRSRVAllocDeviceMemKM(" #devCookie ", " #perProc ", " #devMemHeap ", " #flags ", " #size \ - ", " #alignment "," #memInfo "): " logStr " (size = 0x%;x)", size)),\ - _PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, memInfo)) + ", " #alignment "," #memInfo "): " logStr " (size = 0x%x)", size)),\ + _PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, privdata, privdatalength, memInfo)) #else - #define PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, memInfo, logStr) \ - _PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, memInfo) + #define PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, privdata, privdatalength, memInfo, logStr) \ + _PVRSRVAllocDeviceMemKM(devCookie, perProc, devMemHeap, flags, size, alignment, privdata, privdatalength, memInfo) #endif @@ -211,7 +225,8 @@ IMG_IMPORT PVRSRV_ERROR PVRSRVGetDCBuffersKM(IMG_HANDLE hDeviceKM, IMG_HANDLE hSwapChain, IMG_UINT32 *pui32BufferCount, - IMG_HANDLE *phBuffer); + IMG_HANDLE *phBuffer, + IMG_SYS_PHYADDR *psPhyAddr); IMG_IMPORT PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, IMG_HANDLE hBuffer, @@ -220,6 +235,15 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, IMG_UINT32 ui32ClipRectCount, IMG_RECT *psClipRect); IMG_IMPORT +PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, + IMG_HANDLE hBuffer, + IMG_UINT32 ui32SwapInterval, + PVRSRV_KERNEL_MEM_INFO **ppsMemInfos, + PVRSRV_KERNEL_SYNC_INFO **ppsSyncInfos, + IMG_UINT32 ui32NumMemSyncInfos, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength); +IMG_IMPORT PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, IMG_HANDLE hSwapChain); @@ -247,6 +271,10 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * PVRSRV_KERNEL_MEM_INFO **ppsMemInfo, IMG_HANDLE *phOSMapInfo); +IMG_EXPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVChangeDeviceMemoryAttributesKM(IMG_HANDLE hKernelMemInfo, + IMG_UINT32 ui32Attribs); + IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemoryKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo); @@ -263,7 +291,11 @@ IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo); IMG_IMPORT +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO_KM *psMiscInfo); +#else PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo); +#endif IMG_IMPORT PVRSRV_ERROR PVRSRVAllocSharedSysMemoryKM(PVRSRV_PER_PROCESS_DATA *psPerProc, diff --git a/drivers/gpu/pvr/pvr_debug.c b/drivers/gpu/pvr/pvr_debug.c index 91c0873..9f0016f 100644 --- a/drivers/gpu/pvr/pvr_debug.c +++ b/drivers/gpu/pvr/pvr_debug.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -24,8 +24,12 @@ * ******************************************************************************/ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif #include <asm/io.h> @@ -45,6 +49,10 @@ #include "linkage.h" #include "pvr_uaccess.h" +#if !defined(CONFIG_PREEMPT) +#define PVR_DEBUG_ALWAYS_USE_SPINLOCK +#endif + static IMG_BOOL VBAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, const IMG_CHAR* pszFormat, va_list VArgs) IMG_FORMAT_PRINTF(3, 0); @@ -65,55 +73,77 @@ IMG_UINT32 gPVRDebugLevel = #define PVR_MAX_MSG_LEN PVR_MAX_DEBUG_MESSAGE_LEN +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) static IMG_CHAR gszBufferNonIRQ[PVR_MAX_MSG_LEN + 1]; +#endif static IMG_CHAR gszBufferIRQ[PVR_MAX_MSG_LEN + 1]; +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) static PVRSRV_LINUX_MUTEX gsDebugMutexNonIRQ; +#endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) static spinlock_t gsDebugLockIRQ = SPIN_LOCK_UNLOCKED; +#else +static DEFINE_SPINLOCK(gsDebugLockIRQ); +#endif +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) #if !defined (USE_SPIN_LOCK) #define USE_SPIN_LOCK (in_interrupt() || !preemptible()) #endif +#endif static inline void GetBufferLock(unsigned long *pulLockFlags) { +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) if (USE_SPIN_LOCK) +#endif { spin_lock_irqsave(&gsDebugLockIRQ, *pulLockFlags); } +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) else { LinuxLockMutex(&gsDebugMutexNonIRQ); } +#endif } static inline void ReleaseBufferLock(unsigned long ulLockFlags) { +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) if (USE_SPIN_LOCK) +#endif { spin_unlock_irqrestore(&gsDebugLockIRQ, ulLockFlags); } +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) else { LinuxUnLockMutex(&gsDebugMutexNonIRQ); } +#endif } static inline void SelectBuffer(IMG_CHAR **ppszBuf, IMG_UINT32 *pui32BufSiz) { +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) if (USE_SPIN_LOCK) +#endif { *ppszBuf = gszBufferIRQ; *pui32BufSiz = sizeof(gszBufferIRQ); } +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) else { *ppszBuf = gszBufferNonIRQ; *pui32BufSiz = sizeof(gszBufferNonIRQ); } +#endif } static IMG_BOOL VBAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, const IMG_CHAR* pszFormat, va_list VArgs) @@ -135,7 +165,9 @@ static IMG_BOOL VBAppend(IMG_CHAR *pszBuf, IMG_UINT32 ui32BufSiz, const IMG_CHAR IMG_VOID PVRDPFInit(IMG_VOID) { +#if !defined(PVR_DEBUG_ALWAYS_USE_SPINLOCK) LinuxInitMutex(&gsDebugMutexNonIRQ); +#endif } IMG_VOID PVRSRVReleasePrintf(const IMG_CHAR *pszFormat, ...) @@ -171,9 +203,7 @@ IMG_VOID PVRSRVReleasePrintf(const IMG_CHAR *pszFormat, ...) IMG_VOID PVRSRVDebugAssertFail(const IMG_CHAR* pszFile, IMG_UINT32 uLine) { PVRSRVDebugPrintf(DBGPRIV_FATAL, pszFile, uLine, "Debug assertion failed!"); -#if !defined(SLSI_S5PC110) BUG(); -#endif } #endif @@ -314,7 +344,8 @@ IMG_VOID PVRSRVDebugPrintf ( IMG_CHAR* pszTruncBackInter; - pszFileName = pszFullFileName + strlen(DEBUG_LOG_PATH_TRUNCATE)+1; + if (strlen(pszFullFileName) > strlen(DEBUG_LOG_PATH_TRUNCATE)+1) + pszFileName = pszFullFileName + strlen(DEBUG_LOG_PATH_TRUNCATE)+1; strncpy(szFileNameRewrite, pszFileName,PVR_MAX_FILEPATH_LEN); diff --git a/drivers/gpu/pvr/pvr_debug.h b/drivers/gpu/pvr/pvr_debug.h index 21fa2cd..e66fdab 100644 --- a/drivers/gpu/pvr/pvr_debug.h +++ b/drivers/gpu/pvr/pvr_debug.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,7 +22,7 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +******************************************************************************/ #ifndef __PVR_DEBUG_H__ #define __PVR_DEBUG_H__ @@ -30,35 +30,22 @@ #include "img_types.h" + #if defined (__cplusplus) extern "C" { #endif #define PVR_MAX_DEBUG_MESSAGE_LEN (512) -#define DBGPRIV_FATAL 0x01UL -#define DBGPRIV_ERROR 0x02UL -#define DBGPRIV_WARNING 0x04UL -#define DBGPRIV_MESSAGE 0x08UL -#define DBGPRIV_VERBOSE 0x10UL -#define DBGPRIV_CALLTRACE 0x20UL -#define DBGPRIV_ALLOC 0x40UL - -#define DBGPRIV_DBGDRV_MESSAGE 0x1000UL - -#define DBGPRIV_ALLLEVELS (DBGPRIV_FATAL | DBGPRIV_ERROR | DBGPRIV_WARNING | DBGPRIV_MESSAGE | DBGPRIV_VERBOSE) - - - -#define PVR_DBG_FATAL DBGPRIV_FATAL,__FILE__, __LINE__ -#define PVR_DBG_ERROR DBGPRIV_ERROR,__FILE__, __LINE__ -#define PVR_DBG_WARNING DBGPRIV_WARNING,__FILE__, __LINE__ -#define PVR_DBG_MESSAGE DBGPRIV_MESSAGE,__FILE__, __LINE__ -#define PVR_DBG_VERBOSE DBGPRIV_VERBOSE,__FILE__, __LINE__ -#define PVR_DBG_CALLTRACE DBGPRIV_CALLTRACE,__FILE__, __LINE__ -#define PVR_DBG_ALLOC DBGPRIV_ALLOC,__FILE__, __LINE__ - -#define PVR_DBGDRIV_MESSAGE DBGPRIV_DBGDRV_MESSAGE, "", 0 +/* These are privately used by pvr_debug, use the PVR_DBG_ defines instead */ +#define DBGPRIV_FATAL 0x01UL +#define DBGPRIV_ERROR 0x02UL +#define DBGPRIV_WARNING 0x04UL +#define DBGPRIV_MESSAGE 0x08UL +#define DBGPRIV_VERBOSE 0x10UL +#define DBGPRIV_CALLTRACE 0x20UL +#define DBGPRIV_ALLOC 0x40UL +#define DBGPRIV_DBGDRV_MESSAGE 0x80UL #if !defined(PVRSRV_NEED_PVR_ASSERT) && defined(DEBUG) #define PVRSRV_NEED_PVR_ASSERT @@ -72,6 +59,7 @@ extern "C" { #define PVRSRV_NEED_PVR_TRACE #endif +/* PVR_ASSERT() and PVR_DBG_BREAK handling */ #if defined(PVRSRV_NEED_PVR_ASSERT) @@ -80,23 +68,80 @@ extern "C" { IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugAssertFail(const IMG_CHAR *pszFile, IMG_UINT32 ui32Line); - #if defined(PVR_DBG_BREAK_ASSERT_FAIL) - #define PVR_DBG_BREAK PVRSRVDebugAssertFail("PVR_DBG_BREAK", 0) - #else - #define PVR_DBG_BREAK - #endif + #define PVR_DBG_BREAK PVRSRVDebugAssertFail(__FILE__, __LINE__) -#else +#else /* defined(PVRSRV_NEED_PVR_ASSERT) */ #define PVR_ASSERT(EXPR) #define PVR_DBG_BREAK -#endif +#endif /* defined(PVRSRV_NEED_PVR_ASSERT) */ +/* PVR_DPF() handling */ + #if defined(PVRSRV_NEED_PVR_DPF) - #define PVR_DPF(X) PVRSRVDebugPrintf X +#if defined(PVRSRV_NEW_PVR_DPF) + + /* New logging mechanism */ + #define PVR_DBG_FATAL DBGPRIV_FATAL + #define PVR_DBG_ERROR DBGPRIV_ERROR + #define PVR_DBG_WARNING DBGPRIV_WARNING + #define PVR_DBG_MESSAGE DBGPRIV_MESSAGE + #define PVR_DBG_VERBOSE DBGPRIV_VERBOSE + #define PVR_DBG_CALLTRACE DBGPRIV_CALLTRACE + #define PVR_DBG_ALLOC DBGPRIV_ALLOC + #define PVR_DBGDRIV_MESSAGE DBGPRIV_DBGDRV_MESSAGE + + /* These levels are always on with PVRSRV_NEED_PVR_DPF */ + #define __PVR_DPF_0x01UL(x...) PVRSRVDebugPrintf(DBGPRIV_FATAL, x) + #define __PVR_DPF_0x02UL(x...) PVRSRVDebugPrintf(DBGPRIV_ERROR, x) + + /* Some are compiled out completely in release builds */ +#if defined(DEBUG) + #define __PVR_DPF_0x04UL(x...) PVRSRVDebugPrintf(DBGPRIV_WARNING, x) + #define __PVR_DPF_0x08UL(x...) PVRSRVDebugPrintf(DBGPRIV_MESSAGE, x) + #define __PVR_DPF_0x10UL(x...) PVRSRVDebugPrintf(DBGPRIV_VERBOSE, x) + #define __PVR_DPF_0x20UL(x...) PVRSRVDebugPrintf(DBGPRIV_CALLTRACE, x) + #define __PVR_DPF_0x40UL(x...) PVRSRVDebugPrintf(DBGPRIV_ALLOC, x) + #define __PVR_DPF_0x80UL(x...) PVRSRVDebugPrintf(DBGPRIV_DBGDRV_MESSAGE, x) +#else + #define __PVR_DPF_0x04UL(x...) + #define __PVR_DPF_0x08UL(x...) + #define __PVR_DPF_0x10UL(x...) + #define __PVR_DPF_0x20UL(x...) + #define __PVR_DPF_0x40UL(x...) + #define __PVR_DPF_0x80UL(x...) +#endif + + /* Translate the different log levels to separate macros + * so they can each be compiled out. + */ +#if defined(DEBUG) + #define __PVR_DPF(lvl, x...) __PVR_DPF_ ## lvl (__FILE__, __LINE__, x) +#else + #define __PVR_DPF(lvl, x...) __PVR_DPF_ ## lvl ("", 0, x) +#endif + + /* Get rid of the double bracketing */ + #define PVR_DPF(x) __PVR_DPF x + +#else /* defined(PVRSRV_NEW_PVR_DPF) */ + + /* Old logging mechanism */ + #define PVR_DBG_FATAL DBGPRIV_FATAL,__FILE__, __LINE__ + #define PVR_DBG_ERROR DBGPRIV_ERROR,__FILE__, __LINE__ + #define PVR_DBG_WARNING DBGPRIV_WARNING,__FILE__, __LINE__ + #define PVR_DBG_MESSAGE DBGPRIV_MESSAGE,__FILE__, __LINE__ + #define PVR_DBG_VERBOSE DBGPRIV_VERBOSE,__FILE__, __LINE__ + #define PVR_DBG_CALLTRACE DBGPRIV_CALLTRACE,__FILE__, __LINE__ + #define PVR_DBG_ALLOC DBGPRIV_ALLOC,__FILE__, __LINE__ + #define PVR_DBGDRIV_MESSAGE DBGPRIV_DBGDRV_MESSAGE, "", 0 + + #define PVR_DPF(X) PVRSRVDebugPrintf X + +#endif /* defined(PVRSRV_NEW_PVR_DPF) */ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintf(IMG_UINT32 ui32DebugLevel, const IMG_CHAR *pszFileName, @@ -104,13 +149,15 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintf(IMG_UINT32 ui32DebugLevel, const IMG_CHAR *pszFormat, ...) IMG_FORMAT_PRINTF(4, 5); -#else +#else /* defined(PVRSRV_NEED_PVR_DPF) */ #define PVR_DPF(X) -#endif +#endif /* defined(PVRSRV_NEED_PVR_DPF) */ +/* PVR_TRACE() handling */ + #if defined(PVRSRV_NEED_PVR_TRACE) #define PVR_TRACE(X) PVRSRVTrace X @@ -118,16 +165,20 @@ IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDebugPrintf(IMG_UINT32 ui32DebugLevel, IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVTrace(const IMG_CHAR* pszFormat, ... ) IMG_FORMAT_PRINTF(1, 2); -#else +#else /* defined(PVRSRV_NEED_PVR_TRACE) */ #define PVR_TRACE(X) -#endif +#endif /* defined(PVRSRV_NEED_PVR_TRACE) */ #if defined (__cplusplus) } #endif -#endif +#endif /* __PVR_DEBUG_H__ */ + +/****************************************************************************** + End of file (pvr_debug.h) +******************************************************************************/ diff --git a/drivers/gpu/pvr/pvr_uaccess.h b/drivers/gpu/pvr/pvr_uaccess.h index 04fdcc2..bacafe9 100644 --- a/drivers/gpu/pvr/pvr_uaccess.h +++ b/drivers/gpu/pvr/pvr_uaccess.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -27,11 +27,14 @@ #ifndef __PVR_UACCESS_H__ #define __PVR_UACCESS_H__ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#include <linux/version.h> #include <asm/uaccess.h> static inline unsigned long pvr_copy_to_user(void __user *pvTo, const void *pvFrom, unsigned long ulBytes) diff --git a/drivers/gpu/pvr/pvrmmap.h b/drivers/gpu/pvr/pvrmmap.h index 4404d88..242d953 100644 --- a/drivers/gpu/pvr/pvrmmap.h +++ b/drivers/gpu/pvr/pvrmmap.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -27,10 +27,18 @@ #ifndef __PVRMMAP_H__ #define __PVRMMAP_H__ +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR PVRPMapKMem(IMG_HANDLE hModule, IMG_VOID **ppvLinAddr, IMG_VOID *pvLinAddrKM, IMG_SID *phMappingInfo, IMG_SID hMHandle); +#else PVRSRV_ERROR PVRPMapKMem(IMG_HANDLE hModule, IMG_VOID **ppvLinAddr, IMG_VOID *pvLinAddrKM, IMG_HANDLE *phMappingInfo, IMG_HANDLE hMHandle); +#endif +#if defined (SUPPORT_SID_INTERFACE) +IMG_BOOL PVRUnMapKMem(IMG_HANDLE hModule, IMG_SID hMappingInfo, IMG_SID hMHandle); +#else IMG_BOOL PVRUnMapKMem(IMG_HANDLE hModule, IMG_HANDLE hMappingInfo, IMG_HANDLE hMHandle); +#endif #endif diff --git a/drivers/gpu/pvr/pvrmodule.h b/drivers/gpu/pvr/pvrmodule.h index 30cb2c3..3dd5845 100644 --- a/drivers/gpu/pvr/pvrmodule.h +++ b/drivers/gpu/pvr/pvrmodule.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/pvrsrv.c b/drivers/gpu/pvr/pvrsrv.c index 6e19974..1b730f5 100644 --- a/drivers/gpu/pvr/pvrsrv.c +++ b/drivers/gpu/pvr/pvrsrv.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -32,6 +32,10 @@ #include "pdump_km.h" #include "deviceid.h" #include "ra.h" +#if defined(TTRACE) +#include "ttrace.h" +#endif +#include "perfkm.h" #include "pvrversion.h" @@ -40,6 +44,7 @@ IMG_UINT32 g_ui32InitFlags; #define INIT_DATA_ENABLE_PDUMPINIT 0x1U +#define INIT_DATA_ENABLE_TTARCE 0x2U PVRSRV_ERROR AllocateDeviceID(SYS_DATA *psSysData, IMG_UINT32 *pui32DevID) { @@ -238,15 +243,28 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) goto Error; } - if(OSEventObjectCreate("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject) != PVRSRV_OK) + if(OSEventObjectCreateKM("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject) != PVRSRV_OK) { goto Error; } + psSysData->pfnHighResTimerCreate = OSFuncHighResTimerCreate; + psSysData->pfnHighResTimerGetus = OSFuncHighResTimerGetus; + psSysData->pfnHighResTimerDestroy = OSFuncHighResTimerDestroy; + +#if defined(TTRACE) + eError = PVRSRVTimeTraceInit(); + if (eError != PVRSRV_OK) + goto Error; + g_ui32InitFlags |= INIT_DATA_ENABLE_TTARCE; +#endif + + PDUMPINIT(); g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT; + PERFINIT(); return eError; Error: @@ -268,6 +286,15 @@ IMG_VOID IMG_CALLCONV PVRSRVDeInit(PSYS_DATA psSysData) return; } + PERFDEINIT(); + +#if defined(TTRACE) + + if ((g_ui32InitFlags & INIT_DATA_ENABLE_TTARCE) > 0) + { + PVRSRVTimeTraceDeinit(); + } +#endif if( (g_ui32InitFlags & INIT_DATA_ENABLE_PDUMPINIT) > 0) { @@ -277,7 +304,7 @@ IMG_VOID IMG_CALLCONV PVRSRVDeInit(PSYS_DATA psSysData) if(psSysData->psGlobalEventObject) { - OSEventObjectDestroy(psSysData->psGlobalEventObject); + OSEventObjectDestroyKM(psSysData->psGlobalEventObject); OSFreeMem( PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_EVENTOBJECT), psSysData->psGlobalEventObject, @@ -613,31 +640,69 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDeinitialiseDevice(IMG_UINT32 ui32DevIndex) IMG_EXPORT -PVRSRV_ERROR IMG_CALLCONV PollForValueKM (volatile IMG_UINT32* pui32LinMemAddr, - IMG_UINT32 ui32Value, - IMG_UINT32 ui32Mask, - IMG_UINT32 ui32Waitus, - IMG_UINT32 ui32Tries) +PVRSRV_ERROR IMG_CALLCONV PollForValueKM (volatile IMG_UINT32* pui32LinMemAddr, + IMG_UINT32 ui32Value, + IMG_UINT32 ui32Mask, + IMG_UINT32 ui32Timeoutus, + IMG_UINT32 ui32PollPeriodus, + IMG_BOOL bAllowPreemption) { +#if defined (EMULATOR) + { + PVR_UNREFERENCED_PARAMETER(bAllowPreemption); + #if !defined(__linux__) + PVR_UNREFERENCED_PARAMETER(ui32PollPeriodus); + #endif + + + + do + { + if((*pui32LinMemAddr & ui32Mask) == ui32Value) + { + return PVRSRV_OK; + } + + #if defined(__linux__) + OSWaitus(ui32PollPeriodus); + #else + OSReleaseThreadQuanta(); + #endif + + } while (ui32Timeoutus); + } +#else { IMG_UINT32 ui32ActualValue = 0xFFFFFFFFU; - IMG_UINT32 uiMaxTime = ui32Tries * ui32Waitus; + + if (bAllowPreemption) + { + PVR_ASSERT(ui32PollPeriodus >= 1000); + } - LOOP_UNTIL_TIMEOUT(uiMaxTime) + LOOP_UNTIL_TIMEOUT(ui32Timeoutus) { ui32ActualValue = (*pui32LinMemAddr & ui32Mask); if(ui32ActualValue == ui32Value) { return PVRSRV_OK; } - OSWaitus(ui32Waitus); + + if (bAllowPreemption) + { + OSSleepms(ui32PollPeriodus / 1000); + } + else + { + OSWaitus(ui32PollPeriodus); + } } END_LOOP_UNTIL_TIMEOUT(); PVR_DPF((PVR_DBG_ERROR,"PollForValueKM: Timeout. Expected 0x%x but found 0x%x (mask 0x%x).", ui32Value, ui32ActualValue, ui32Mask)); } - +#endif return PVRSRV_ERROR_TIMEOUT; } @@ -750,7 +815,11 @@ static PVRSRV_ERROR PVRSRVGetMiscInfoKM_Device_AnyVaCb(PVRSRV_DEVICE_NODE *psDev IMG_EXPORT +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO_KM *psMiscInfo) +#else PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) +#endif { SYS_DATA *psSysData; @@ -770,7 +839,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) |PVRSRV_MISC_INFO_DDKVERSION_PRESENT |PVRSRV_MISC_INFO_CPUCACHEOP_PRESENT |PVRSRV_MISC_INFO_RESET_PRESENT - |PVRSRV_MISC_INFO_FREEMEM_PRESENT)) + |PVRSRV_MISC_INFO_FREEMEM_PRESENT + |PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT)) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVGetMiscInfoKM: invalid state request flags")); return PVRSRV_ERROR_INVALID_PARAMS; @@ -845,7 +915,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } - if((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_FREEMEM_PRESENT) + if(((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_FREEMEM_PRESENT) != 0) && psMiscInfo->pszMemoryStr) { IMG_CHAR *pszStr; @@ -892,8 +962,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) psMiscInfo->aui32DDKVersion[0] = PVRVERSION_MAJ; psMiscInfo->aui32DDKVersion[1] = PVRVERSION_MIN; - psMiscInfo->aui32DDKVersion[2] = PVRVERSION_BRANCH; - psMiscInfo->aui32DDKVersion[3] = PVRVERSION_BUILD; + psMiscInfo->aui32DDKVersion[2] = PVRVERSION_BUILD_HI; + psMiscInfo->aui32DDKVersion[3] = PVRVERSION_BUILD_LO; pszStr = psMiscInfo->pszMemoryStr; ui32StrLen = psMiscInfo->ui32MemoryStrLen; @@ -917,6 +987,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) if((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_CPUCACHEOP_PRESENT) != 0UL) { + psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_CPUCACHEOP_PRESENT; + if(psMiscInfo->sCacheOpCtl.bDeferOp) { @@ -924,10 +996,16 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } else { +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo = psMiscInfo->sCacheOpCtl.psKernelMemInfo; + + if(!psMiscInfo->sCacheOpCtl.psKernelMemInfo) +#else PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; PVRSRV_PER_PROCESS_DATA *psPerProc; if(!psMiscInfo->sCacheOpCtl.u.psKernelMemInfo) +#endif { PVR_DPF((PVR_DBG_WARNING, "PVRSRVGetMiscInfoKM: " "Ignoring non-deferred cache op with no meminfo")); @@ -941,6 +1019,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) "to combine deferred cache ops with immediate ones")); } +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#else psPerProc = PVRSRVFindPerProcessData(); @@ -953,6 +1034,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) "Can't find kernel meminfo")); return PVRSRV_ERROR_INVALID_PARAMS; } +#endif if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_FLUSH) { @@ -975,6 +1057,35 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } } + if((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT) != 0UL) + { +#if !defined (SUPPORT_SID_INTERFACE) + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + PVRSRV_PER_PROCESS_DATA *psPerProc; +#endif + + psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT; + +#if defined (SUPPORT_SID_INTERFACE) + PVR_DBG_BREAK +#else + + psPerProc = PVRSRVFindPerProcessData(); + + if(PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_PVOID *)&psKernelMemInfo, + psMiscInfo->sGetRefCountCtl.u.psKernelMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVGetMiscInfoKM: " + "Can't find kernel meminfo")); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psMiscInfo->sGetRefCountCtl.ui32RefCount = psKernelMemInfo->ui32RefCount; +#endif + } + #if defined(PVRSRV_RESET_ON_HWTIMEOUT) if((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_RESET_PRESENT) != 0UL) { @@ -1097,9 +1208,9 @@ IMG_VOID IMG_CALLCONV PVRSRVMISR(IMG_VOID *pvSysData) &PVRSRVMISR_ForEachCb); - if (PVRSRVProcessQueues(ISR_ID, IMG_FALSE) == PVRSRV_ERROR_PROCESSING_BLOCKED) + if (PVRSRVProcessQueues(IMG_FALSE) == PVRSRV_ERROR_PROCESSING_BLOCKED) { - PVRSRVProcessQueues(ISR_ID, IMG_FALSE); + PVRSRVProcessQueues(IMG_FALSE); } @@ -1108,7 +1219,7 @@ IMG_VOID IMG_CALLCONV PVRSRVMISR(IMG_VOID *pvSysData) IMG_HANDLE hOSEventKM = psSysData->psGlobalEventObject->hOSEventKM; if(hOSEventKM) { - OSEventObjectSignal(hOSEventKM); + OSEventObjectSignalKM(hOSEventKM); } } } diff --git a/drivers/gpu/pvr/pvrsrv_errors.h b/drivers/gpu/pvr/pvrsrv_errors.h index 56c7184..5474984 100644 --- a/drivers/gpu/pvr/pvrsrv_errors.h +++ b/drivers/gpu/pvr/pvrsrv_errors.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -88,6 +88,8 @@ extern "C" { case PVRSRV_ERROR_REGISTER_BASE_NOT_SET: return "PVRSRV_ERROR_REGISTER_BASE_NOT_SET"; + case PVRSRV_ERROR_BM_BAD_SHAREMEM_HANDLE: return "PVRSRV_ERROR_BM_BAD_SHAREMEM_HANDLE"; + case PVRSRV_ERROR_FAILED_TO_ALLOC_USER_MEM: return "PVRSRV_ERROR_FAILED_TO_ALLOC_USER_MEM"; case PVRSRV_ERROR_FAILED_TO_ALLOC_VP_MEMORY: return "PVRSRV_ERROR_FAILED_TO_ALLOC_VP_MEMORY"; case PVRSRV_ERROR_FAILED_TO_MAP_SHARED_PBDESC: return "PVRSRV_ERROR_FAILED_TO_MAP_SHARED_PBDESC"; diff --git a/drivers/gpu/pvr/pvrversion.h b/drivers/gpu/pvr/pvrversion.h index 923be86..8f987ef 100644 --- a/drivers/gpu/pvr/pvrversion.h +++ b/drivers/gpu/pvr/pvrversion.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,17 +22,30 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +*/ /**************************************************************************/ #ifndef _PVRVERSION_H_ #define _PVRVERSION_H_ -#define PVRVERSION_MAJ 1 -#define PVRVERSION_MIN 6 -#define PVRVERSION_BRANCH 16 -#define PVRVERSION_BUILD 3947 -#define PVRVERSION_STRING "1.6.16.3947" -#define PVRVERSION_FILE "eurasiacon.pj" +#define PVR_STR(X) #X +#define PVR_STR2(X) PVR_STR(X) -#endif +#define PVRVERSION_MAJ 1 +#define PVRVERSION_MIN 8 +#define PVRVERSION_BRANCH 18 +#define PVRVERSION_FAMILY "sgxddk" +#define PVRVERSION_BRANCHNAME "1.8" +#define PVRVERSION_BUILD 300406 +#define PVRVERSION_BSCONTROL "CustomerGoogle_Android_ogles1_ogles2_GPL" + +#define PVRVERSION_STRING "CustomerGoogle_Android_ogles1_ogles2_GPL sgxddk 18 1.8@" PVR_STR2(PVRVERSION_BUILD) +#define PVRVERSION_STRING_SHORT "1.8@" PVR_STR2(PVRVERSION_BUILD) + +#define COPYRIGHT_TXT "Copyright (c) Imagination Technologies Ltd. All Rights Reserved." + +#define PVRVERSION_BUILD_HI 30 +#define PVRVERSION_BUILD_LO 406 +#define PVRVERSION_STRING_NUMERIC PVR_STR2(PVRVERSION_MAJ) "." PVR_STR2(PVRVERSION_MIN) "." PVR_STR2(PVRVERSION_BUILD_HI) "." PVR_STR2(PVRVERSION_BUILD_LO) + +#endif /* _PVRVERSION_H_ */ diff --git a/drivers/gpu/pvr/queue.c b/drivers/gpu/pvr/queue.c index 28602df..4682094 100644 --- a/drivers/gpu/pvr/queue.c +++ b/drivers/gpu/pvr/queue.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -27,15 +27,21 @@ #include "services_headers.h" #include "lists.h" +#include "ttrace.h" - +#if defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) +#define DC_NUM_COMMANDS_PER_TYPE 2 +#else #define DC_NUM_COMMANDS_PER_TYPE 1 +#endif typedef struct _DEVICE_COMMAND_DATA_ { PFN_CMD_PROC pfnCmdProc; PCOMMAND_COMPLETE_DATA apsCmdCompleteData[DC_NUM_COMMANDS_PER_TYPE]; IMG_UINT32 ui32CCBOffset; + IMG_UINT32 ui32MaxDstSyncCount; + IMG_UINT32 ui32MaxSrcSyncCount; } DEVICE_COMMAND_DATA; @@ -71,13 +77,29 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el) (IMG_UINTPTR_T)psCmd, psCmd->ui32ProcessID, psCmd->CommandType, - psCmd->ui32CmdSize, + psCmd->uCmdSize, psCmd->ui32DevIndex, psCmd->ui32DstSyncCount, psCmd->ui32SrcSyncCount, - psCmd->ui32DataSize); + psCmd->uDataSize); + { + IMG_UINT32 i; + for (i = 0; i < psCmd->ui32SrcSyncCount; i++) + { + PVRSRV_SYNC_DATA *psSyncData = psCmd->psSrcSync[i].psKernelSyncInfoKM->psSyncData; + seq_printf(sfile, " Sync %u: ROP/ROC: 0x%x/0x%x WOP/WOC: 0x%x/0x%x ROC-VA: 0x%x WOC-VA: 0x%x\n", + i, + psCmd->psSrcSync[i].ui32ReadOps2Pending, + psSyncData->ui32ReadOps2Complete, + psCmd->psSrcSync[i].ui32WriteOpsPending, + psSyncData->ui32WriteOpsComplete, + psCmd->psSrcSync[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, + psCmd->psSrcSync[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr); + } + } + - ui32ReadOffset += psCmd->ui32CmdSize; + ui32ReadOffset += psCmd->uCmdSize; ui32ReadOffset &= psQueue->ui32QueueSize - 1; cmds++; } @@ -122,6 +144,48 @@ void* ProcSeqOff2ElementQueue(struct seq_file * sfile, loff_t off) #define SYNCOPS_STALE(ui32OpsComplete, ui32OpsPending) \ ((ui32OpsComplete) >= (ui32OpsPending)) +#ifdef INLINE_IS_PRAGMA +#pragma inline(PVRSRVGetWriteOpsPending) +#endif +static INLINE +IMG_UINT32 PVRSRVGetWriteOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL bIsReadOp) +{ + IMG_UINT32 ui32WriteOpsPending; + + if(bIsReadOp) + { + ui32WriteOpsPending = psSyncInfo->psSyncData->ui32WriteOpsPending; + } + else + { + + + + ui32WriteOpsPending = psSyncInfo->psSyncData->ui32WriteOpsPending++; + } + + return ui32WriteOpsPending; +} + +#ifdef INLINE_IS_PRAGMA +#pragma inline(PVRSRVGetReadOpsPending) +#endif +static INLINE +IMG_UINT32 PVRSRVGetReadOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL bIsReadOp) +{ + IMG_UINT32 ui32ReadOpsPending; + + if(bIsReadOp) + { + ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOps2Pending++; + } + else + { + ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOps2Pending; + } + + return ui32ReadOpsPending; +} static IMG_VOID QueueDumpCmdComplete(COMMAND_COMPLETE_DATA *psCmdCompleteData, IMG_UINT32 i, @@ -135,9 +199,9 @@ static IMG_VOID QueueDumpCmdComplete(COMMAND_COMPLETE_DATA *psCmdCompleteData, { PVR_LOG(("\t%s %u: ROC DevVAddr:0x%X ROP:0x%x ROC:0x%x, WOC DevVAddr:0x%X WOP:0x%x WOC:0x%x", bIsSrc ? "SRC" : "DEST", i, - psSyncObject[i].psKernelSyncInfoKM->sReadOpsCompleteDevVAddr.uiAddr, - psSyncObject[i].psKernelSyncInfoKM->psSyncData->ui32ReadOpsPending, - psSyncObject[i].psKernelSyncInfoKM->psSyncData->ui32ReadOpsComplete, + psSyncObject[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, + psSyncObject[i].psKernelSyncInfoKM->psSyncData->ui32ReadOps2Pending, + psSyncObject[i].psKernelSyncInfoKM->psSyncData->ui32ReadOps2Complete, psSyncObject[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr, psSyncObject[i].psKernelSyncInfoKM->psSyncData->ui32WriteOpsPending, psSyncObject[i].psKernelSyncInfoKM->psSyncData->ui32WriteOpsComplete)) @@ -342,7 +406,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue bTimeout = IMG_FALSE; break; } - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); + OSSleepms(1); } END_LOOP_UNTIL_TIMEOUT(); if (bTimeout) @@ -460,7 +524,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetQueueSpaceKM(PVRSRV_QUEUE_INFO *psQueue, bTimeout = IMG_FALSE; break; } - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); + OSSleepms(1); } END_LOOP_UNTIL_TIMEOUT(); if (bTimeout == IMG_TRUE) @@ -487,12 +551,27 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, PVRSRV_KERNEL_SYNC_INFO *apsDstSync[], IMG_UINT32 ui32SrcSyncCount, PVRSRV_KERNEL_SYNC_INFO *apsSrcSync[], - IMG_SIZE_T ui32DataByteSize ) + IMG_SIZE_T ui32DataByteSize, + PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete, + IMG_HANDLE hCallbackData) { PVRSRV_ERROR eError; PVRSRV_COMMAND *psCommand; IMG_SIZE_T ui32CommandSize; IMG_UINT32 i; + SYS_DATA *psSysData; + DEVICE_COMMAND_DATA *psDeviceCommandData; + + + SysAcquireData(&psSysData); + psDeviceCommandData = psSysData->apsDeviceCommandData[ui32DevIndex]; + + if ((psDeviceCommandData[CommandType].ui32MaxDstSyncCount < ui32DstSyncCount) || + (psDeviceCommandData[CommandType].ui32MaxSrcSyncCount < ui32SrcSyncCount)) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVInsertCommandKM: Too many syncs")); + return PVRSRV_ERROR_INVALID_PARAMS; + } ui32DataByteSize = (ui32DataByteSize + 3UL) & ~3UL; @@ -512,7 +591,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, psCommand->ui32ProcessID = OSGetCurrentProcessIDKM(); - psCommand->ui32CmdSize = ui32CommandSize; + psCommand->uCmdSize = ui32CommandSize; psCommand->ui32DevIndex = ui32DevIndex; psCommand->CommandType = CommandType; psCommand->ui32DstSyncCount = ui32DstSyncCount; @@ -527,35 +606,49 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, psCommand->pvData = (PVRSRV_SYNC_OBJECT*)(((IMG_UINTPTR_T)psCommand->psSrcSync) + (ui32SrcSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); - psCommand->ui32DataSize = ui32DataByteSize; + psCommand->uDataSize = ui32DataByteSize; + + psCommand->pfnCommandComplete = pfnCommandComplete; + psCommand->hCallbackData = hCallbackData; + + PVR_TTRACE(PVRSRV_TRACE_GROUP_QUEUE, PVRSRV_TRACE_CLASS_CMD_START, QUEUE_TOKEN_INSERTKM); + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_QUEUE, PVRSRV_TRACE_CLASS_NONE, + QUEUE_TOKEN_COMMAND_TYPE, CommandType); for (i=0; i<ui32DstSyncCount; i++) { + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_DST_SYNC, + apsDstSync[i], PVRSRV_SYNCOP_SAMPLE); + psCommand->psDstSync[i].psKernelSyncInfoKM = apsDstSync[i]; psCommand->psDstSync[i].ui32WriteOpsPending = PVRSRVGetWriteOpsPending(apsDstSync[i], IMG_FALSE); - psCommand->psDstSync[i].ui32ReadOpsPending = PVRSRVGetReadOpsPending(apsDstSync[i], IMG_FALSE); + psCommand->psDstSync[i].ui32ReadOps2Pending = PVRSRVGetReadOpsPending(apsDstSync[i], IMG_FALSE); PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVInsertCommandKM: Dst %u RO-VA:0x%x WO-VA:0x%x ROP:0x%x WOP:0x%x", - i, psCommand->psDstSync[i].psKernelSyncInfoKM->sReadOpsCompleteDevVAddr.uiAddr, + i, psCommand->psDstSync[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, psCommand->psDstSync[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr, - psCommand->psDstSync[i].ui32ReadOpsPending, + psCommand->psDstSync[i].ui32ReadOps2Pending, psCommand->psDstSync[i].ui32WriteOpsPending)); } for (i=0; i<ui32SrcSyncCount; i++) { + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_DST_SYNC, + apsSrcSync[i], PVRSRV_SYNCOP_SAMPLE); + psCommand->psSrcSync[i].psKernelSyncInfoKM = apsSrcSync[i]; psCommand->psSrcSync[i].ui32WriteOpsPending = PVRSRVGetWriteOpsPending(apsSrcSync[i], IMG_TRUE); - psCommand->psSrcSync[i].ui32ReadOpsPending = PVRSRVGetReadOpsPending(apsSrcSync[i], IMG_TRUE); + psCommand->psSrcSync[i].ui32ReadOps2Pending = PVRSRVGetReadOpsPending(apsSrcSync[i], IMG_TRUE); PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVInsertCommandKM: Src %u RO-VA:0x%x WO-VA:0x%x ROP:0x%x WOP:0x%x", - i, psCommand->psSrcSync[i].psKernelSyncInfoKM->sReadOpsCompleteDevVAddr.uiAddr, + i, psCommand->psSrcSync[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, psCommand->psSrcSync[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr, - psCommand->psSrcSync[i].ui32ReadOpsPending, + psCommand->psSrcSync[i].ui32ReadOps2Pending, psCommand->psSrcSync[i].ui32WriteOpsPending)); } + PVR_TTRACE(PVRSRV_TRACE_GROUP_QUEUE, PVRSRV_TRACE_CLASS_CMD_END, QUEUE_TOKEN_INSERTKM); *ppsCommand = psCommand; @@ -590,13 +683,48 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVSubmitCommandKM(PVRSRV_QUEUE_INFO *psQueue, + (psCommand->ui32SrcSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); - UPDATE_QUEUE_WOFF(psQueue, psCommand->ui32CmdSize); + UPDATE_QUEUE_WOFF(psQueue, psCommand->uCmdSize); return PVRSRV_OK; } +static +PVRSRV_ERROR CheckIfSyncIsQueued(PVRSRV_SYNC_OBJECT *psSync, COMMAND_COMPLETE_DATA *psCmdData) +{ + IMG_UINT32 k; + + if (psCmdData->bInUse) + { + for (k=0;k<psCmdData->ui32SrcSyncCount;k++) + { + if (psSync->psKernelSyncInfoKM == psCmdData->psSrcSync[k].psKernelSyncInfoKM) + { + PVRSRV_SYNC_DATA *psSyncData = psSync->psKernelSyncInfoKM->psSyncData; + IMG_UINT32 ui32WriteOpsComplete = psSyncData->ui32WriteOpsComplete; + + + if (ui32WriteOpsComplete == psSync->ui32WriteOpsPending) + { + return PVRSRV_OK; + } + else + { + if (SYNCOPS_STALE(ui32WriteOpsComplete, psSync->ui32WriteOpsPending)) + { + PVR_DPF((PVR_DBG_WARNING, + "CheckIfSyncIsQueued: Stale syncops psSyncData:0x%x ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", + (IMG_UINTPTR_T)psSyncData, ui32WriteOpsComplete, psSync->ui32WriteOpsPending)); + return PVRSRV_OK; + } + } + } + } + } + return PVRSRV_ERROR_FAILED_DEPENDENCIES; +} + static PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, PVRSRV_COMMAND *psCommand, @@ -620,14 +748,14 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, PVRSRV_SYNC_DATA *psSyncData = psWalkerObj->psKernelSyncInfoKM->psSyncData; ui32WriteOpsComplete = psSyncData->ui32WriteOpsComplete; - ui32ReadOpsComplete = psSyncData->ui32ReadOpsComplete; + ui32ReadOpsComplete = psSyncData->ui32ReadOps2Complete; if ((ui32WriteOpsComplete != psWalkerObj->ui32WriteOpsPending) - || (ui32ReadOpsComplete != psWalkerObj->ui32ReadOpsPending)) + || (ui32ReadOpsComplete != psWalkerObj->ui32ReadOps2Pending)) { if (!bFlush || !SYNCOPS_STALE(ui32WriteOpsComplete, psWalkerObj->ui32WriteOpsPending) || - !SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOpsPending)) + !SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOps2Pending)) { return PVRSRV_ERROR_FAILED_DEPENDENCIES; } @@ -643,15 +771,15 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, { PVRSRV_SYNC_DATA *psSyncData = psWalkerObj->psKernelSyncInfoKM->psSyncData; - ui32ReadOpsComplete = psSyncData->ui32ReadOpsComplete; + ui32ReadOpsComplete = psSyncData->ui32ReadOps2Complete; ui32WriteOpsComplete = psSyncData->ui32WriteOpsComplete; if ((ui32WriteOpsComplete != psWalkerObj->ui32WriteOpsPending) - || (ui32ReadOpsComplete != psWalkerObj->ui32ReadOpsPending)) + || (ui32ReadOpsComplete != psWalkerObj->ui32ReadOps2Pending)) { if (!bFlush && SYNCOPS_STALE(ui32WriteOpsComplete, psWalkerObj->ui32WriteOpsPending) && - SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOpsPending)) + SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOps2Pending)) { PVR_DPF((PVR_DBG_WARNING, "PVRSRVProcessCommand: Stale syncops psSyncData:0x%x ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", @@ -660,9 +788,24 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, if (!bFlush || !SYNCOPS_STALE(ui32WriteOpsComplete, psWalkerObj->ui32WriteOpsPending) || - !SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOpsPending)) + !SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOps2Pending)) { - return PVRSRV_ERROR_FAILED_DEPENDENCIES; + IMG_UINT32 j; + PVRSRV_ERROR eError; + IMG_BOOL bFound = IMG_FALSE; + + psDeviceCommandData = psSysData->apsDeviceCommandData[psCommand->ui32DevIndex]; + for (j=0;j<DC_NUM_COMMANDS_PER_TYPE;j++) + { + eError = CheckIfSyncIsQueued(psWalkerObj, psDeviceCommandData[psCommand->CommandType].apsCmdCompleteData[j]); + + if (eError == PVRSRV_OK) + { + bFound = IMG_TRUE; + } + } + if (!bFound) + return PVRSRV_ERROR_FAILED_DEPENDENCIES; } } psWalkerObj++; @@ -697,13 +840,15 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, psCmdCompleteData->psDstSync[i] = psCommand->psDstSync[i]; PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVProcessCommand: Dst %u RO-VA:0x%x WO-VA:0x%x ROP:0x%x WOP:0x%x (CCB:%u)", - i, psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->sReadOpsCompleteDevVAddr.uiAddr, + i, psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr, - psCmdCompleteData->psDstSync[i].ui32ReadOpsPending, + psCmdCompleteData->psDstSync[i].ui32ReadOps2Pending, psCmdCompleteData->psDstSync[i].ui32WriteOpsPending, ui32CCBOffset)); } + psCmdCompleteData->pfnCommandComplete = psCommand->pfnCommandComplete; + psCmdCompleteData->hCallbackData = psCommand->hCallbackData; psCmdCompleteData->ui32SrcSyncCount = psCommand->ui32SrcSyncCount; @@ -712,9 +857,9 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, psCmdCompleteData->psSrcSync[i] = psCommand->psSrcSync[i]; PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVProcessCommand: Src %u RO-VA:0x%x WO-VA:0x%x ROP:0x%x WOP:0x%x (CCB:%u)", - i, psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->sReadOpsCompleteDevVAddr.uiAddr, + i, psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr, - psCmdCompleteData->psSrcSync[i].ui32ReadOpsPending, + psCmdCompleteData->psSrcSync[i].ui32ReadOps2Pending, psCmdCompleteData->psSrcSync[i].ui32WriteOpsPending, ui32CCBOffset)); } @@ -730,7 +875,7 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, if (psDeviceCommandData[psCommand->CommandType].pfnCmdProc((IMG_HANDLE)psCmdCompleteData, - psCommand->ui32DataSize, + (IMG_UINT32)psCommand->uDataSize, psCommand->pvData) == IMG_FALSE) { @@ -757,48 +902,20 @@ static IMG_VOID PVRSRVProcessQueues_ForEachCb(PVRSRV_DEVICE_NODE *psDeviceNode) } IMG_EXPORT -PVRSRV_ERROR PVRSRVProcessQueues(IMG_UINT32 ui32CallerID, - IMG_BOOL bFlush) +PVRSRV_ERROR PVRSRVProcessQueues(IMG_BOOL bFlush) { PVRSRV_QUEUE_INFO *psQueue; SYS_DATA *psSysData; PVRSRV_COMMAND *psCommand; - PVRSRV_ERROR eError; - SysAcquireData(&psSysData); - psSysData->bReProcessQueues = IMG_FALSE; - - eError = OSLockResource(&psSysData->sQProcessResource, - ui32CallerID); - if(eError != PVRSRV_OK) + while (OSLockResource(&psSysData->sQProcessResource, ISR_ID) != PVRSRV_OK) { - - psSysData->bReProcessQueues = IMG_TRUE; - - - if(ui32CallerID == ISR_ID) - { - if (bFlush) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVProcessQueues: Couldn't acquire queue processing lock for FLUSH")); - } - else - { - PVR_DPF((PVR_DBG_MESSAGE,"PVRSRVProcessQueues: Couldn't acquire queue processing lock")); - } - } - else - { - PVR_DPF((PVR_DBG_MESSAGE,"PVRSRVProcessQueues: Queue processing lock-acquire failed when called from the Services driver.")); - PVR_DPF((PVR_DBG_MESSAGE," This is due to MISR queue processing being interrupted by the Services driver.")); - } - - return PVRSRV_OK; - } - + OSWaitus(1); + }; + psQueue = psSysData->psQueueList; if(!psQueue) @@ -820,12 +937,8 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_UINT32 ui32CallerID, if (PVRSRVProcessCommand(psSysData, psCommand, bFlush) == PVRSRV_OK) { - UPDATE_QUEUE_ROFF(psQueue, psCommand->ui32CmdSize) - - if (bFlush) - { - continue; - } + UPDATE_QUEUE_ROFF(psQueue, psCommand->uCmdSize) + continue; } break; @@ -842,15 +955,7 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_UINT32 ui32CallerID, List_PVRSRV_DEVICE_NODE_ForEach(psSysData->psDeviceNodeList, &PVRSRVProcessQueues_ForEachCb); - - - OSUnlockResource(&psSysData->sQProcessResource, ui32CallerID); - - - if(psSysData->bReProcessQueues) - { - return PVRSRV_ERROR_PROCESSING_BLOCKED; - } + OSUnlockResource(&psSysData->sQProcessResource, ISR_ID); return PVRSRV_OK; } @@ -890,30 +995,49 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie, SysAcquireData(&psSysData); + PVR_TTRACE(PVRSRV_TRACE_GROUP_QUEUE, PVRSRV_TRACE_CLASS_CMD_COMP_START, + QUEUE_TOKEN_COMMAND_COMPLETE); + for (i=0; i<psCmdCompleteData->ui32DstSyncCount; i++) { psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->psSyncData->ui32WriteOpsComplete++; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_UPDATE_DST, + psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM, + PVRSRV_SYNCOP_COMPLETE); + PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVCommandCompleteKM: Dst %u RO-VA:0x%x WO-VA:0x%x ROP:0x%x WOP:0x%x", - i, psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->sReadOpsCompleteDevVAddr.uiAddr, + i, psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, psCmdCompleteData->psDstSync[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr, - psCmdCompleteData->psDstSync[i].ui32ReadOpsPending, + psCmdCompleteData->psDstSync[i].ui32ReadOps2Pending, psCmdCompleteData->psDstSync[i].ui32WriteOpsPending)); } for (i=0; i<psCmdCompleteData->ui32SrcSyncCount; i++) { - psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->psSyncData->ui32ReadOpsComplete++; + psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->psSyncData->ui32ReadOps2Complete++; + + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_QUEUE, QUEUE_TOKEN_UPDATE_SRC, + psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM, + PVRSRV_SYNCOP_COMPLETE); PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVCommandCompleteKM: Src %u RO-VA:0x%x WO-VA:0x%x ROP:0x%x WOP:0x%x", - i, psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->sReadOpsCompleteDevVAddr.uiAddr, + i, psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->sReadOps2CompleteDevVAddr.uiAddr, psCmdCompleteData->psSrcSync[i].psKernelSyncInfoKM->sWriteOpsCompleteDevVAddr.uiAddr, - psCmdCompleteData->psSrcSync[i].ui32ReadOpsPending, + psCmdCompleteData->psSrcSync[i].ui32ReadOps2Pending, psCmdCompleteData->psSrcSync[i].ui32WriteOpsPending)); } + PVR_TTRACE(PVRSRV_TRACE_GROUP_QUEUE, PVRSRV_TRACE_CLASS_CMD_COMP_END, + QUEUE_TOKEN_COMMAND_COMPLETE); + + if (psCmdCompleteData->pfnCommandComplete) + { + psCmdCompleteData->pfnCommandComplete(psCmdCompleteData->hCallbackData); + } + psCmdCompleteData->bInUse = IMG_FALSE; @@ -972,7 +1096,8 @@ PVRSRV_ERROR PVRSRVRegisterCmdProcListKM(IMG_UINT32 ui32DevIndex, { psDeviceCommandData[ui32CmdTypeCounter].pfnCmdProc = ppfnCmdProcList[ui32CmdTypeCounter]; psDeviceCommandData[ui32CmdTypeCounter].ui32CCBOffset = 0; - + psDeviceCommandData[ui32CmdTypeCounter].ui32MaxDstSyncCount = ui32MaxSyncsPerCmd[ui32CmdTypeCounter][0]; + psDeviceCommandData[ui32CmdTypeCounter].ui32MaxSrcSyncCount = ui32MaxSyncsPerCmd[ui32CmdTypeCounter][1]; for (ui32CmdCounter = 0; ui32CmdCounter < DC_NUM_COMMANDS_PER_TYPE; ui32CmdCounter++) { @@ -1006,7 +1131,7 @@ PVRSRV_ERROR PVRSRVRegisterCmdProcListKM(IMG_UINT32 ui32DevIndex, (((IMG_UINTPTR_T)psCmdCompleteData->psDstSync) + (sizeof(PVRSRV_SYNC_OBJECT) * ui32MaxSyncsPerCmd[ui32CmdTypeCounter][0])); - psCmdCompleteData->ui32AllocSize = ui32AllocSize; + psCmdCompleteData->ui32AllocSize = (IMG_UINT32)ui32AllocSize; } } @@ -1015,14 +1140,13 @@ PVRSRV_ERROR PVRSRVRegisterCmdProcListKM(IMG_UINT32 ui32DevIndex, ErrorExit: - - if (PVRSRVRemoveCmdProcListKM(ui32DevIndex, ui32CmdCount) != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR, - "PVRSRVRegisterCmdProcListKM: Failed to clean up after error, device 0x%x", - ui32DevIndex)); - } - + if (PVRSRVRemoveCmdProcListKM(ui32DevIndex, ui32CmdCount) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, + "PVRSRVRegisterCmdProcListKM: Failed to clean up after error, device 0x%x", + ui32DevIndex)); + } + return eError; } diff --git a/drivers/gpu/pvr/queue.h b/drivers/gpu/pvr/queue.h index 9437f09..d8045b1 100644 --- a/drivers/gpu/pvr/queue.h +++ b/drivers/gpu/pvr/queue.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -45,14 +45,15 @@ extern "C" { PVRSRV_SYNC_OBJECT *psDstSync; PVRSRV_SYNC_OBJECT *psSrcSync; IMG_UINT32 ui32AllocSize; + PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete; + IMG_HANDLE hCallbackData; }COMMAND_COMPLETE_DATA, *PCOMMAND_COMPLETE_DATA; #if !defined(USE_CODE) IMG_VOID QueueDumpDebugInfo(IMG_VOID); IMG_IMPORT -PVRSRV_ERROR PVRSRVProcessQueues (IMG_UINT32 ui32CallerID, - IMG_BOOL bFlush); +PVRSRV_ERROR PVRSRVProcessQueues (IMG_BOOL bFlush); #if defined(__linux__) && defined(__KERNEL__) #include <linux/types.h> @@ -77,7 +78,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, PVRSRV_KERNEL_SYNC_INFO *apsDstSync[], IMG_UINT32 ui32SrcSyncCount, PVRSRV_KERNEL_SYNC_INFO *apsSrcSync[], - IMG_SIZE_T ui32DataByteSize ); + IMG_SIZE_T ui32DataByteSize, + PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete, + IMG_HANDLE hCallbackData); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetQueueSpaceKM(PVRSRV_QUEUE_INFO *psQueue, diff --git a/drivers/gpu/pvr/ra.c b/drivers/gpu/pvr/ra.c index 191be84..84a2162 100644 --- a/drivers/gpu/pvr/ra.c +++ b/drivers/gpu/pvr/ra.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -115,6 +115,8 @@ struct _RA_ARENA_ IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, IMG_UINT32 uFlags, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase); IMG_VOID (*pImportFree) (IMG_VOID *, IMG_UINTPTR_T, @@ -142,7 +144,7 @@ struct _RA_ARENA_ #endif #if defined(CONFIG_PROC_FS) && defined(DEBUG) -#define PROC_NAME_SIZE 32 +#define PROC_NAME_SIZE 64 struct proc_dir_entry* pProcInfo; struct proc_dir_entry* pProcSegs; @@ -191,6 +193,8 @@ _RequestAllocFail (IMG_VOID *_h, IMG_SIZE_T *_pActualSize, BM_MAPPING **_ppsMapping, IMG_UINT32 _uFlags, + IMG_PVOID _pvPrivData, + IMG_UINT32 _ui32PrivDataLength, IMG_UINTPTR_T *_pBase) { PVR_UNREFERENCED_PARAMETER (_h); @@ -199,6 +203,8 @@ _RequestAllocFail (IMG_VOID *_h, PVR_UNREFERENCED_PARAMETER (_ppsMapping); PVR_UNREFERENCED_PARAMETER (_uFlags); PVR_UNREFERENCED_PARAMETER (_pBase); + PVR_UNREFERENCED_PARAMETER (_pvPrivData); + PVR_UNREFERENCED_PARAMETER (_ui32PrivDataLength); return IMG_FALSE; } @@ -847,7 +853,9 @@ RA_Create (IMG_CHAR *name, BM_MAPPING *psMapping, IMG_SIZE_T uQuantum, IMG_BOOL (*imp_alloc)(IMG_VOID *, IMG_SIZE_T uSize, IMG_SIZE_T *pActualSize, - BM_MAPPING **ppsMapping, IMG_UINT32 _flags, IMG_UINTPTR_T *pBase), + BM_MAPPING **ppsMapping, IMG_UINT32 _flags, + IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, + IMG_UINTPTR_T *pBase), IMG_VOID (*imp_free) (IMG_VOID *, IMG_UINTPTR_T, BM_MAPPING *), IMG_VOID (*backingstore_free) (IMG_VOID*, IMG_SIZE_T, IMG_SIZE_T, IMG_HANDLE), IMG_VOID *pImportHandle) @@ -1071,6 +1079,8 @@ RA_Alloc (RA_ARENA *pArena, IMG_UINT32 uFlags, IMG_UINT32 uAlignment, IMG_UINT32 uAlignmentOffset, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *base) { IMG_BOOL bResult; @@ -1124,7 +1134,8 @@ RA_Alloc (RA_ARENA *pArena, bResult = pArena->pImportAlloc (pArena->pImportHandle, uImportSize, &uImportSize, - &psImportMapping, uFlags, &import_base); + &psImportMapping, uFlags, + pvPrivData, ui32PrivDataLength, &import_base); if (bResult) { BT *pBT; diff --git a/drivers/gpu/pvr/ra.h b/drivers/gpu/pvr/ra.h index f28ce4c..d836215 100644 --- a/drivers/gpu/pvr/ra.h +++ b/drivers/gpu/pvr/ra.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -89,6 +89,8 @@ RA_Create (IMG_CHAR *name, IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, IMG_UINT32 uFlags, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase), IMG_VOID (*imp_free) (IMG_VOID *, IMG_UINTPTR_T, @@ -116,6 +118,8 @@ RA_Alloc (RA_ARENA *pArena, IMG_UINT32 uFlags, IMG_UINT32 uAlignment, IMG_UINT32 uAlignmentOffset, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase); IMG_VOID diff --git a/drivers/gpu/pvr/regpaths.h b/drivers/gpu/pvr/regpaths.h index a551eff..9193737 100644 --- a/drivers/gpu/pvr/regpaths.h +++ b/drivers/gpu/pvr/regpaths.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/resman.c b/drivers/gpu/pvr/resman.c index 5d865a7..5088c7f 100644 --- a/drivers/gpu/pvr/resman.c +++ b/drivers/gpu/pvr/resman.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -28,11 +28,14 @@ #include "resman.h" #ifdef __linux__ +#include <linux/version.h> + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #ifndef AUTOCONF_INCLUDED - #include <linux/config.h> +#include <linux/config.h> +#endif #endif -#include <linux/version.h> #include <linux/sched.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9) #include <linux/hardirq.h> @@ -40,22 +43,34 @@ #include <asm/hardirq.h> #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) +#include <linux/mutex.h> +#else #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) #include <linux/semaphore.h> #else #include <asm/semaphore.h> #endif +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) +static DEFINE_MUTEX(lock); +#define DOWN(m) mutex_lock(m) +#define UP(m) mutex_unlock(m) +#else static DECLARE_MUTEX(lock); +#define DOWN(m) down(m) +#define UP(m) up(m) +#endif #define ACQUIRE_SYNC_OBJ do { \ if (in_interrupt()) { \ - printk ("ISR cannot take RESMAN mutex\n"); \ + printk("ISR cannot take RESMAN mutex\n"); \ BUG(); \ } \ - else down (&lock); \ + else DOWN(&lock); \ } while (0) -#define RELEASE_SYNC_OBJ up (&lock) +#define RELEASE_SYNC_OBJ UP(&lock) #else @@ -122,7 +137,7 @@ static IMPLEMENT_LIST_INSERT(RESMAN_CONTEXT) #define PRINT_RESLIST(x, y, z) -static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, IMG_BOOL bExecuteCallback); +static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, IMG_BOOL bExecuteCallback, IMG_BOOL bForceCleanup); static PVRSRV_ERROR FreeResourceByCriteria(PRESMAN_CONTEXT psContext, IMG_UINT32 ui32SearchCriteria, @@ -249,6 +264,9 @@ IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext, FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_OS_USERMODE_MAPPING, 0, 0, IMG_TRUE); + FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DMA_CLIENT_FIFO_DATA, 0, 0, IMG_TRUE); + + FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_EVENT_OBJECT, 0, 0, IMG_TRUE); @@ -264,15 +282,8 @@ IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext, FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_TRANSFER_CONTEXT, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_PB_DESC_CREATE_LOCK, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_PB_DESC, 0, 0, IMG_TRUE); - - - FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_SWAPCHAIN_REF, 0, 0, IMG_TRUE); - FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_DEVICE, 0, 0, IMG_TRUE); - - - FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_BUFFERCLASS_DEVICE, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SYNC_INFO, 0, 0, IMG_TRUE); @@ -283,6 +294,13 @@ IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext, FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_CONTEXT, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_SHARED_MEM_INFO, 0, 0, IMG_TRUE); + + + FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_SWAPCHAIN_REF, 0, 0, IMG_TRUE); + FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DISPLAYCLASS_DEVICE, 0, 0, IMG_TRUE); + + + FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_BUFFERCLASS_DEVICE, 0, 0, IMG_TRUE); } @@ -376,7 +394,7 @@ PRESMAN_ITEM ResManRegisterRes(PRESMAN_CONTEXT psResManContext, return(psNewResItem); } -PVRSRV_ERROR ResManFreeResByPtr(RESMAN_ITEM *psResItem) +PVRSRV_ERROR ResManFreeResByPtr(RESMAN_ITEM *psResItem, IMG_BOOL bForceCleanup) { PVRSRV_ERROR eError; @@ -398,7 +416,7 @@ PVRSRV_ERROR ResManFreeResByPtr(RESMAN_ITEM *psResItem) VALIDATERESLIST(); - eError = FreeResourceByPtr(psResItem, IMG_TRUE); + eError = FreeResourceByPtr(psResItem, IMG_TRUE, bForceCleanup); VALIDATERESLIST(); @@ -475,7 +493,7 @@ PVRSRV_ERROR ResManDissociateRes(RESMAN_ITEM *psResItem, } else { - eError = FreeResourceByPtr(psResItem, IMG_FALSE); + eError = FreeResourceByPtr(psResItem, IMG_FALSE, CLEANUP_WITH_POLL); if(eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "ResManDissociateRes: failed to free resource by pointer")); @@ -551,9 +569,10 @@ IMG_INTERNAL PVRSRV_ERROR ResManFindResourceByPtr(PRESMAN_CONTEXT psResManContex } static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, - IMG_BOOL bExecuteCallback) + IMG_BOOL bExecuteCallback, + IMG_BOOL bForceCleanup) { - PVRSRV_ERROR eError; + PVRSRV_ERROR eError = PVRSRV_OK; PVR_ASSERT(psItem != IMG_NULL); @@ -588,7 +607,7 @@ static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, if (bExecuteCallback) { - eError = psItem->pfnFreeResource(psItem->pvParam, psItem->ui32Param); + eError = psItem->pfnFreeResource(psItem->pvParam, psItem->ui32Param, bForceCleanup); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "FreeResourceByPtr: ERROR calling FreeResource function")); @@ -599,11 +618,7 @@ static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, ACQUIRE_SYNC_OBJ; - eError = OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RESMAN_ITEM), psItem, IMG_NULL); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR, "FreeResourceByPtr: ERROR freeing resource list item memory")); - } + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RESMAN_ITEM), psItem, IMG_NULL); return(eError); } @@ -664,7 +679,7 @@ static PVRSRV_ERROR FreeResourceByCriteria(PRESMAN_CONTEXT psResManContext, ui32Param)) != IMG_NULL && eError == PVRSRV_OK) { - eError = FreeResourceByPtr(psCurItem, bExecuteCallback); + eError = FreeResourceByPtr(psCurItem, bExecuteCallback, CLEANUP_WITH_POLL); } return eError; diff --git a/drivers/gpu/pvr/resman.h b/drivers/gpu/pvr/resman.h index eebec57..648e490 100644 --- a/drivers/gpu/pvr/resman.h +++ b/drivers/gpu/pvr/resman.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -41,6 +41,9 @@ enum { RESMAN_TYPE_TRANSFER_CONTEXT, + RESMAN_TYPE_DMA_CLIENT_FIFO_DATA, + + @@ -73,7 +76,7 @@ enum { #define RESMAN_CRITERIA_PVOID_PARAM 0x00000002 #define RESMAN_CRITERIA_UI32_PARAM 0x00000004 -typedef PVRSRV_ERROR (*RESMAN_FREE_FN)(IMG_PVOID pvParam, IMG_UINT32 ui32Param); +typedef PVRSRV_ERROR (*RESMAN_FREE_FN)(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bForceCleanup); typedef struct _RESMAN_ITEM_ *PRESMAN_ITEM; typedef struct _RESMAN_CONTEXT_ *PRESMAN_CONTEXT; @@ -87,7 +90,8 @@ PRESMAN_ITEM ResManRegisterRes(PRESMAN_CONTEXT hResManContext, IMG_UINT32 ui32Param, RESMAN_FREE_FN pfnFreeResource); -PVRSRV_ERROR ResManFreeResByPtr(PRESMAN_ITEM psResItem); +PVRSRV_ERROR ResManFreeResByPtr(PRESMAN_ITEM psResItem, + IMG_BOOL bForceCleanup); PVRSRV_ERROR ResManFreeResByCriteria(PRESMAN_CONTEXT hResManContext, IMG_UINT32 ui32SearchCriteria, diff --git a/drivers/gpu/pvr/s3c_lcd/s3c_displayclass.c b/drivers/gpu/pvr/s3c_lcd/s3c_displayclass.c index 2e0cd08..47c53ac 100644 --- a/drivers/gpu/pvr/s3c_lcd/s3c_displayclass.c +++ b/drivers/gpu/pvr/s3c_lcd/s3c_displayclass.c @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -22,7 +22,9 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ + */ + +/* Copyright (C) Samsung Electronics System LSI. */ #include <linux/module.h> #include <linux/init.h> @@ -39,6 +41,7 @@ #include <plat/regs-fb.h> #include <linux/console.h> #include <linux/workqueue.h> +#include <linux/version.h> #include "img_defs.h" #include "servicesext.h" @@ -46,15 +49,23 @@ #include "s3c_lcd.h" +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) +#define S3C_CONSOLE_LOCK() console_lock() +#define S3C_CONSOLE_UNLOCK() console_unlock() +#else +#define S3C_CONSOLE_LOCK() acquire_console_sem() +#define S3C_CONSOLE_UNLOCK() release_console_sem() +#endif + static int fb_idx = 0; -#define S3C_MAX_BACKBUFFERS 5 +#define S3C_MAX_BACKBUFFERS 2 #define S3C_MAX_BUFFERS (S3C_MAX_BACKBUFFERS+1) #define S3C_DISPLAY_FORMAT_NUM 1 #define S3C_DISPLAY_DIM_NUM 1 -#define VSYCN_IRQ 0x61 +#define VSYNC_IRQ 0x61 #define DC_S3C_LCD_COMMAND_COUNT 1 @@ -64,7 +75,8 @@ typedef struct S3C_FRAME_BUFFER_TAG IMG_SYS_PHYADDR bufferPAddr; IMG_UINT32 byteSize; IMG_UINT32 yoffset; //y offset from SysBuffer -}S3C_FRAME_BUFFER; + +} S3C_FRAME_BUFFER; typedef void * S3C_HANDLE; @@ -77,26 +89,18 @@ typedef enum tag_s3c_bool typedef struct S3C_SWAPCHAIN_TAG { - unsigned long ulBufferCount; - S3C_FRAME_BUFFER *psBuffer; -}S3C_SWAPCHAIN; +} S3C_SWAPCHAIN; typedef struct S3C_VSYNC_FLIP_ITEM_TAG { - S3C_HANDLE hCmdComplete; - S3C_FRAME_BUFFER *psFb; - unsigned long ulSwapInterval; - S3C_BOOL bValid; - S3C_BOOL bFlipped; - S3C_BOOL bCmdCompleted; } S3C_VSYNC_FLIP_ITEM; @@ -105,7 +109,7 @@ typedef struct fb_info S3C_FB_INFO; typedef struct S3C_LCD_DEVINFO_TAG { - IMG_UINT32 ui32DisplayID; + IMG_UINT32 ui32DeviceID; DISPLAY_INFO sDisplayInfo; S3C_FB_INFO *psFBInfo; @@ -117,24 +121,19 @@ typedef struct S3C_LCD_DEVINFO_TAG IMG_UINT32 ui32NumFrameBuffers; // list of supported display format - DISPLAY_FORMAT asDisplayForamtList[S3C_DISPLAY_FORMAT_NUM]; + DISPLAY_FORMAT asDisplayFormatList[S3C_DISPLAY_FORMAT_NUM]; IMG_UINT32 ui32NumDims; DISPLAY_DIMS asDisplayDimList[S3C_DISPLAY_DIM_NUM]; - // jump table into pvr services - PVRSRV_DC_DISP2SRV_KMJTABLE sPVRJTable; - // jump table into DC PVRSRV_DC_SRV2DISP_KMJTABLE sDCJTable; // backbuffer info S3C_FRAME_BUFFER asBackBuffers[S3C_MAX_BACKBUFFERS]; - S3C_SWAPCHAIN *psSwapChain; - S3C_VSYNC_FLIP_ITEM asVSyncFlips[S3C_MAX_BUFFERS]; unsigned long ulInsertIndex; @@ -145,9 +144,54 @@ typedef struct S3C_LCD_DEVINFO_TAG struct work_struct sWork; struct mutex sVsyncFlipItemMutex; -}S3C_LCD_DEVINFO; +} S3C_LCD_DEVINFO; + +// jump table into pvr services +static PVRSRV_DC_DISP2SRV_KMJTABLE gsPVRJTable; + +static S3C_LCD_DEVINFO *gpsLCDInfo; + +/***************************************************************************** + * Video-decode carveout decls + */ + +#define S3C_MAX_VIDEO_BUFFERS 3 + +/* Y planes + UV planes @ max resolution, page aligned */ +#define S3C_VIDEO_Y_SIZE ALIGN(1280 * 720, PAGE_SIZE) +#define S3C_VIDEO_UV_SIZE ALIGN(1280 * 360, PAGE_SIZE) +#define S3C_VIDEO_CARVEOUT_SIZE \ + S3C_MAX_VIDEO_BUFFERS * (S3C_VIDEO_Y_SIZE + S3C_VIDEO_UV_SIZE) + +typedef struct S3C_VIDBUF_DEVINFO_TAG +{ + IMG_UINT32 ui32DeviceID; + S3C_SWAPCHAIN *psSwapChain; + DISPLAY_INFO sDisplayInfo; + S3C_FRAME_BUFFER asVideoBuffers[S3C_MAX_VIDEO_BUFFERS]; -static S3C_LCD_DEVINFO *g_psLCDInfo = NULL; +} S3C_VIDBUF_DEVINFO; + +static S3C_VIDBUF_DEVINFO gsYBufInfo = +{ + .sDisplayInfo.ui32MaxSwapInterval = 1, + .sDisplayInfo.ui32MaxSwapChains = 1, + .sDisplayInfo.ui32MaxSwapChainBuffers = S3C_MAX_VIDEO_BUFFERS, + .sDisplayInfo.szDisplayName = "s3c_lcd_y", +}; + +static S3C_VIDBUF_DEVINFO gsUVBufInfo = +{ + .sDisplayInfo.ui32MaxSwapInterval = 1, + .sDisplayInfo.ui32MaxSwapChains = 1, + .sDisplayInfo.ui32MaxSwapChainBuffers = S3C_MAX_VIDEO_BUFFERS, + .sDisplayInfo.szDisplayName = "s3c_lcd_uv", +}; + +static int InitVidBufs(IMG_UINT32 ui32FBOffset); +static void DeinitVidBufs(void); + +/****************************************************************************/ extern IMG_BOOL IMG_IMPORT PVRGetDisplayClassJTable(PVRSRV_DC_DISP2SRV_KMJTABLE *psJTable); @@ -169,6 +213,7 @@ static void AdvanceFlipIndex(S3C_LCD_DEVINFO *psDevInfo, *pulIndex = 0; } } + static IMG_VOID ResetVSyncFlipItems(S3C_LCD_DEVINFO* psDevInfo) { unsigned long i; @@ -191,7 +236,7 @@ static IMG_VOID S3C_Flip(S3C_LCD_DEVINFO *psDevInfo, int res; unsigned long ulYResVirtual; - acquire_console_sem(); + S3C_CONSOLE_LOCK(); sFBVar = psDevInfo->psFBInfo->var; @@ -210,7 +255,8 @@ static IMG_VOID S3C_Flip(S3C_LCD_DEVINFO *psDevInfo, res = fb_set_var(psDevInfo->psFBInfo, &sFBVar); if (res != 0) { - printk("%s: fb_set_var failed (Y Offset: %d, Error: %d)\n", __FUNCTION__, fb->yoffset, res); } + printk("%s: fb_set_var failed (Y Offset: %d, Error: %d)\n", __FUNCTION__, fb->yoffset, res); + } } else { @@ -221,7 +267,7 @@ static IMG_VOID S3C_Flip(S3C_LCD_DEVINFO *psDevInfo, } } - release_console_sem(); + S3C_CONSOLE_UNLOCK(); } static void FlushInternalVSyncQueue(S3C_LCD_DEVINFO*psDevInfo) @@ -234,16 +280,14 @@ static void FlushInternalVSyncQueue(S3C_LCD_DEVINFO*psDevInfo) while(psFlipItem->bValid) { - if(psFlipItem->bFlipped ==S3C_FALSE) + if(psFlipItem->bFlipped == S3C_FALSE) { - S3C_Flip (psDevInfo, psFlipItem->psFb); } if(psFlipItem->bCmdCompleted == S3C_FALSE) { - - psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete((IMG_HANDLE)psFlipItem->hCmdComplete, IMG_FALSE); + gsPVRJTable.pfnPVRSRVCmdComplete((IMG_HANDLE)psFlipItem->hCmdComplete, IMG_TRUE); } AdvanceFlipIndex(psDevInfo, &psDevInfo->ulRemoveIndex); @@ -259,12 +303,10 @@ static void FlushInternalVSyncQueue(S3C_LCD_DEVINFO*psDevInfo) psDevInfo->ulRemoveIndex = 0; mutex_unlock(&psDevInfo->sVsyncFlipItemMutex); - } static void VsyncWorkqueueFunc(struct work_struct *psWork) { - S3C_VSYNC_FLIP_ITEM *psFlipItem; S3C_LCD_DEVINFO *psDevInfo = container_of(psWork, S3C_LCD_DEVINFO, sWork); @@ -272,42 +314,28 @@ static void VsyncWorkqueueFunc(struct work_struct *psWork) { return; } + mutex_lock(&psDevInfo->sVsyncFlipItemMutex); psFlipItem = &psDevInfo->asVSyncFlips[psDevInfo->ulRemoveIndex]; - + while(psFlipItem->bValid) { - if(psFlipItem->bFlipped) { - if(!psFlipItem->bCmdCompleted) { - IMG_BOOL bScheduleMISR; - -#if 0 - bScheduleMISR = IMG_TRUE; -#else - bScheduleMISR = IMG_FALSE; -#endif - - psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete((IMG_HANDLE)psFlipItem->hCmdComplete, bScheduleMISR); - + gsPVRJTable.pfnPVRSRVCmdComplete((IMG_HANDLE)psFlipItem->hCmdComplete, IMG_TRUE); psFlipItem->bCmdCompleted = S3C_TRUE; } - psFlipItem->ulSwapInterval--; - + if(psFlipItem->ulSwapInterval == 0) { - AdvanceFlipIndex(psDevInfo, &psDevInfo->ulRemoveIndex); - psFlipItem->bCmdCompleted = S3C_FALSE; psFlipItem->bFlipped = S3C_FALSE; - psFlipItem->bValid = S3C_FALSE; } else @@ -319,18 +347,23 @@ static void VsyncWorkqueueFunc(struct work_struct *psWork) { S3C_Flip (psDevInfo, psFlipItem->psFb); psFlipItem->bFlipped = S3C_TRUE; - break; } - + psFlipItem = &psDevInfo->asVSyncFlips[psDevInfo->ulRemoveIndex]; } + mutex_unlock(&psDevInfo->sVsyncFlipItemMutex); } static S3C_BOOL CreateVsyncWorkQueue(S3C_LCD_DEVINFO *psDevInfo) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) + psDevInfo->psWorkQueue = alloc_workqueue("vsync_workqueue", + WQ_UNBOUND | WQ_HIGHPRI, 1); +#else psDevInfo->psWorkQueue = create_rt_workqueue("vsync_workqueue"); +#endif if (psDevInfo->psWorkQueue == IMG_NULL) { @@ -343,54 +376,68 @@ static S3C_BOOL CreateVsyncWorkQueue(S3C_LCD_DEVINFO *psDevInfo) return S3C_TRUE; } -static void destropyVsyncWorkQueue(S3C_LCD_DEVINFO *psDevInfo) + +static void destroyVsyncWorkQueue(S3C_LCD_DEVINFO *psDevInfo) { destroy_workqueue(psDevInfo->psWorkQueue); mutex_destroy(&psDevInfo->sVsyncFlipItemMutex); } + static irqreturn_t S3C_VSyncISR(int irq, void *dev_id) { - - if( dev_id != g_psLCDInfo) + if( dev_id != gpsLCDInfo) { return IRQ_NONE; } - queue_work(g_psLCDInfo->psWorkQueue, &g_psLCDInfo->sWork); + queue_work(gpsLCDInfo->psWorkQueue, &gpsLCDInfo->sWork); return IRQ_HANDLED; } static IMG_VOID S3C_InstallVsyncISR(void) { - if(request_irq(VSYCN_IRQ, S3C_VSyncISR, IRQF_SHARED , "s3cfb", g_psLCDInfo)) + if(request_irq(VSYNC_IRQ, S3C_VSyncISR, IRQF_SHARED , "s3cfb", gpsLCDInfo)) { - printk("S3C_InstallVsyncISR: Couldn't install system LISR on IRQ %d", VSYCN_IRQ); + printk("S3C_InstallVsyncISR: Couldn't install system LISR on IRQ %d", VSYNC_IRQ); return; } } + static IMG_VOID S3C_UninstallVsyncISR(void) { - free_irq(VSYCN_IRQ, g_psLCDInfo); + free_irq(VSYNC_IRQ, gpsLCDInfo); } static PVRSRV_ERROR OpenDCDevice(IMG_UINT32 ui32DeviceID, IMG_HANDLE *phDevice, PVRSRV_SYNC_DATA* psSystemBufferSyncData) { - PVR_UNREFERENCED_PARAMETER(ui32DeviceID); + PVR_UNREFERENCED_PARAMETER(psSystemBufferSyncData); - *phDevice = (IMG_HANDLE)g_psLCDInfo; + if(ui32DeviceID == gpsLCDInfo->ui32DeviceID) + { + *phDevice = (IMG_HANDLE)gpsLCDInfo; + } + else if(ui32DeviceID == gsYBufInfo.ui32DeviceID) + { + *phDevice = (IMG_HANDLE)&gsYBufInfo; + } + else if(ui32DeviceID == gsUVBufInfo.ui32DeviceID) + { + *phDevice = (IMG_HANDLE)&gsUVBufInfo; + } + else + { + return PVRSRV_ERROR_INVALID_PARAMS; + } return PVRSRV_OK; } static PVRSRV_ERROR CloseDCDevice(IMG_HANDLE hDevice) { - S3C_LCD_DEVINFO *psLCDInfo = (S3C_LCD_DEVINFO*)hDevice; - - PVR_UNREFERENCED_PARAMETER(psLCDInfo); - + PVR_UNREFERENCED_PARAMETER(hDevice); return PVRSRV_OK; } @@ -411,7 +458,7 @@ static PVRSRV_ERROR EnumDCFormats(IMG_HANDLE hDevice, if(psFormat) { for (i = 0 ; i < S3C_DISPLAY_FORMAT_NUM ; i++) - psFormat[i] = psLCDInfo->asDisplayForamtList[i]; + psFormat[i] = psLCDInfo->asDisplayFormatList[i]; } return PVRSRV_OK; @@ -437,7 +484,6 @@ static PVRSRV_ERROR EnumDCDims(IMG_HANDLE hDevice, { for (i = 0 ; i < S3C_DISPLAY_DIM_NUM ; i++) psDim[i] = psLCDInfo->asDisplayDimList[i]; - } return PVRSRV_OK; @@ -445,28 +491,27 @@ static PVRSRV_ERROR EnumDCDims(IMG_HANDLE hDevice, static PVRSRV_ERROR GetDCSystemBuffer(IMG_HANDLE hDevice, IMG_HANDLE *phBuffer) { - S3C_LCD_DEVINFO *psLCDInfo = (S3C_LCD_DEVINFO*)hDevice; + S3C_LCD_DEVINFO *psDevInfo = (S3C_LCD_DEVINFO*)hDevice; if(!hDevice || !phBuffer) { return PVRSRV_ERROR_INVALID_PARAMS; } - *phBuffer=(IMG_HANDLE)(&(psLCDInfo->sSysBuffer)); + *phBuffer = (IMG_HANDLE)&psDevInfo->sSysBuffer; return PVRSRV_OK; } static PVRSRV_ERROR GetDCInfo(IMG_HANDLE hDevice, DISPLAY_INFO *psDCInfo) { - S3C_LCD_DEVINFO *psLCDInfo = (S3C_LCD_DEVINFO*)hDevice; + S3C_LCD_DEVINFO *psDevInfo = (S3C_LCD_DEVINFO*)hDevice; if(!hDevice || !psDCInfo) { return PVRSRV_ERROR_INVALID_PARAMS; } - *psDCInfo = psLCDInfo->sDisplayInfo; - + *psDCInfo = psDevInfo->sDisplayInfo; return PVRSRV_OK; } @@ -479,12 +524,11 @@ static PVRSRV_ERROR GetDCBufferAddr(IMG_HANDLE hDevice, IMG_BOOL *pbIsContiguous, IMG_UINT32 *pui32TilingStride) { - S3C_FRAME_BUFFER *buf = (S3C_FRAME_BUFFER *)hBuffer; - S3C_LCD_DEVINFO *psLCDInfo = (S3C_LCD_DEVINFO*)hDevice; - - PVR_UNREFERENCED_PARAMETER(psLCDInfo); + S3C_FRAME_BUFFER *psBuffer = (S3C_FRAME_BUFFER *)hBuffer; + PVR_UNREFERENCED_PARAMETER(pui32TilingStride); - + PVR_UNREFERENCED_PARAMETER(hDevice); + if(!hDevice || !hBuffer || !ppsSysAddr || !pui32ByteSize) { return PVRSRV_ERROR_INVALID_PARAMS; @@ -493,9 +537,9 @@ static PVRSRV_ERROR GetDCBufferAddr(IMG_HANDLE hDevice, *phOSMapInfo = IMG_NULL; *pbIsContiguous = IMG_TRUE; - *ppvCpuVAddr = (IMG_VOID *)buf->bufferVAddr; - *ppsSysAddr = &(buf->bufferPAddr); - *pui32ByteSize = buf->byteSize; + *ppvCpuVAddr = (IMG_VOID *)psBuffer->bufferVAddr; + *ppsSysAddr = &psBuffer->bufferPAddr; + *pui32ByteSize = psBuffer->byteSize; return PVRSRV_OK; } @@ -515,15 +559,11 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, S3C_FRAME_BUFFER *psBuffer; S3C_SWAPCHAIN *psSwapChain; S3C_LCD_DEVINFO *psDevInfo = (S3C_LCD_DEVINFO*)hDevice; - + PVR_UNREFERENCED_PARAMETER(ui32OEMFlags); PVR_UNREFERENCED_PARAMETER(pui32SwapChainID); - if(!hDevice - || !psDstSurfAttrib - || !psSrcSurfAttrib - || !ppsSyncData - || !phSwapChain) + if(!hDevice || !psDstSurfAttrib || !psSrcSurfAttrib || !ppsSyncData || !phSwapChain) { return PVRSRV_ERROR_INVALID_PARAMS; } @@ -532,7 +572,6 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, { return PVRSRV_ERROR_TOOMANYBUFFERS; } - if(psDevInfo->psSwapChain) { @@ -540,14 +579,18 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, } psSwapChain = (S3C_SWAPCHAIN *)kmalloc(sizeof(S3C_SWAPCHAIN),GFP_KERNEL); + if(!psSwapChain) + { + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + psBuffer = (S3C_FRAME_BUFFER*)kmalloc(sizeof(S3C_FRAME_BUFFER) * ui32BufferCount, GFP_KERNEL); - if(!psBuffer) { kfree(psSwapChain); return (PVRSRV_ERROR_OUT_OF_MEMORY); } - + psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; psSwapChain->psBuffer = psBuffer; @@ -563,10 +606,9 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, psBuffer[i].byteSize = psDevInfo->asBackBuffers[i-1].byteSize; psBuffer[i].yoffset = psDevInfo->asBackBuffers[i-1].yoffset; } - + *phSwapChain = (IMG_HANDLE)psSwapChain; *pui32SwapChainID =(IMG_UINT32)psSwapChain; - psDevInfo->psSwapChain = psSwapChain; @@ -582,8 +624,7 @@ static PVRSRV_ERROR DestroyDCSwapChain(IMG_HANDLE hDevice, S3C_SWAPCHAIN *sc = (S3C_SWAPCHAIN *)hSwapChain; S3C_LCD_DEVINFO *psLCDInfo = (S3C_LCD_DEVINFO*)hDevice; - if(!hDevice - || !hSwapChain) + if(!hDevice || !hSwapChain) { return PVRSRV_ERROR_INVALID_PARAMS; } @@ -591,13 +632,13 @@ static PVRSRV_ERROR DestroyDCSwapChain(IMG_HANDLE hDevice, FlushInternalVSyncQueue(psLCDInfo); S3C_Flip(psLCDInfo, &psLCDInfo->sSysBuffer); - + kfree(sc->psBuffer); kfree(sc); if (psLCDInfo->psSwapChain == sc) psLCDInfo->psSwapChain = NULL; - + ResetVSyncFlipItems(psLCDInfo); S3C_UninstallVsyncISR(); @@ -609,7 +650,6 @@ static PVRSRV_ERROR SetDCDstRect(IMG_HANDLE hDevice, IMG_HANDLE hSwapChain, IMG_RECT *psRect) { - PVR_UNREFERENCED_PARAMETER(hDevice); PVR_UNREFERENCED_PARAMETER(hSwapChain); PVR_UNREFERENCED_PARAMETER(psRect); @@ -681,21 +721,18 @@ static PVRSRV_ERROR GetDCBuffers(IMG_HANDLE hDevice, { S3C_LCD_DEVINFO *psLCDInfo = (S3C_LCD_DEVINFO*)hDevice; int i; - - if(!hDevice - || !hSwapChain - || !pui32BufferCount - || !phBuffer) + if(!hDevice || !hSwapChain || !pui32BufferCount || !phBuffer) { return PVRSRV_ERROR_INVALID_PARAMS; } *pui32BufferCount = psLCDInfo->psSwapChain->ulBufferCount; + phBuffer[0] = (IMG_HANDLE)(&(psLCDInfo->sSysBuffer)); for (i=0; i < (*pui32BufferCount) - 1; i++) { - phBuffer[i+1] = (IMG_HANDLE)(&(psLCDInfo->asBackBuffers[i])); + phBuffer[i+1] = (IMG_HANDLE)&psLCDInfo->asBackBuffers[i]; } return PVRSRV_OK; @@ -708,14 +745,11 @@ static PVRSRV_ERROR SwapToDCBuffer(IMG_HANDLE hDevice, IMG_UINT32 ui32ClipRectCount, IMG_RECT *psClipRect) { - PVR_UNREFERENCED_PARAMETER(ui32SwapInterval); PVR_UNREFERENCED_PARAMETER(hPrivateTag); PVR_UNREFERENCED_PARAMETER(psClipRect); - if(!hDevice - || !hBuffer - || (ui32ClipRectCount != 0)) + if(!hDevice || !hBuffer || ui32ClipRectCount != 0) { return PVRSRV_ERROR_INVALID_PARAMS; } @@ -727,8 +761,7 @@ static PVRSRV_ERROR SwapToDCSystem(IMG_HANDLE hDevice, IMG_HANDLE hSwapChain) { - if(!hDevice - || !hSwapChain) + if(!hDevice || !hSwapChain) { return PVRSRV_ERROR_INVALID_PARAMS; } @@ -736,82 +769,197 @@ static PVRSRV_ERROR SwapToDCSystem(IMG_HANDLE hDevice, return PVRSRV_OK; } -static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie, - IMG_UINT32 ui32DataSize, - IMG_VOID *pvData) +static IMG_BOOL ProcessFlipV1(IMG_HANDLE hCmdCookie, + S3C_LCD_DEVINFO *psDevInfo, + S3C_FRAME_BUFFER *psFb, + IMG_UINT32 ui32SwapInterval) { - DISPLAYCLASS_FLIP_COMMAND *psFlipCmd; - S3C_LCD_DEVINFO *psDevInfo; - S3C_FRAME_BUFFER *fb; - S3C_VSYNC_FLIP_ITEM* psFlipItem; + S3C_VSYNC_FLIP_ITEM *psFlipItem; - if(!hCmdCookie || !pvData) + if(ui32SwapInterval == 0) { - return IMG_FALSE; + S3C_Flip(psDevInfo, psFb); + gsPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_FALSE); + return IMG_TRUE; } - psFlipCmd = (DISPLAYCLASS_FLIP_COMMAND*)pvData; - if (psFlipCmd == IMG_NULL || sizeof(DISPLAYCLASS_FLIP_COMMAND) != ui32DataSize) + mutex_lock(&psDevInfo->sVsyncFlipItemMutex); + + psFlipItem = &psDevInfo->asVSyncFlips[psDevInfo->ulInsertIndex]; + + if(psFlipItem->bValid) { + mutex_unlock(&psDevInfo->sVsyncFlipItemMutex); return IMG_FALSE; } - psDevInfo = (S3C_LCD_DEVINFO*)psFlipCmd->hExtDevice; - fb = (S3C_FRAME_BUFFER*)psFlipCmd->hExtBuffer; - - if (psDevInfo->bFlushCommands) + if(psDevInfo->ulInsertIndex == psDevInfo->ulRemoveIndex) { - psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_FALSE); - return IMG_TRUE; + S3C_Flip(psDevInfo, psFb); + psFlipItem->bFlipped = S3C_TRUE; } - - if(psFlipCmd->ui32SwapInterval == 0) + else { + psFlipItem->bFlipped = S3C_FALSE; + } - - S3C_Flip(psDevInfo, fb); - + psFlipItem->hCmdComplete = hCmdCookie; + psFlipItem->psFb = psFb; + psFlipItem->ulSwapInterval = (unsigned long)ui32SwapInterval; - psDevInfo->sPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_FALSE); - - return IMG_TRUE; + psFlipItem->bValid = S3C_TRUE; - } + AdvanceFlipIndex(psDevInfo, &psDevInfo->ulInsertIndex); - mutex_lock(&psDevInfo->sVsyncFlipItemMutex); + mutex_unlock(&psDevInfo->sVsyncFlipItemMutex); + return IMG_TRUE; +} - psFlipItem = &psDevInfo->asVSyncFlips[psDevInfo->ulInsertIndex]; - - if(!psFlipItem->bValid) +/* FIXME: Shouldn't be using internal interfaces like this */ +#include "servicesint.h" +#include "services.h" +#include "mm.h" + +/************* MUST STAY IN SYNC WITH USER *************/ + +typedef struct s5pc110_hwc_rect +{ + s32 left; + s32 top; + s32 right; + s32 bottom; +} +s5pc110_hwc_rect_t; + +typedef struct s5pc110_hwc_layer +{ + s5pc110_hwc_rect_t sourceCrop; + s5pc110_hwc_rect_t displayFrame; + u32 transform; + u32 skip; +} +s5pc110_hwc_layer_t; + +/*******************************************************/ + +/* Triggered by PVRSRVSwapToDCBuffer2 */ +static IMG_BOOL ProcessFlipV2(IMG_HANDLE hCmdCookie, + S3C_LCD_DEVINFO *psDevInfo, + IMG_UINT32 ui32SwapInterval, + IMG_VOID **ppvMemInfos, + IMG_UINT32 ui32NumMemInfos, + s5pc110_hwc_layer_t *psHwcData) +{ + PVRSRV_KERNEL_MEM_INFO **ppsMemInfos = + (PVRSRV_KERNEL_MEM_INFO **)ppvMemInfos; + S3C_FRAME_BUFFER *psFb = NULL; + LinuxMemArea *psDestArea; + IMG_UINT32 i; + + BUG_ON(psHwcData[0].skip != 1); + psDestArea = ppsMemInfos[0]->sMemBlk.hOSMemHandle; + + /* Reverse-lookup of referenced back buffer */ + + /* Check the system buffer */ + psFb = &psDevInfo->sSysBuffer; + if(psFb->bufferPAddr.uiAddr != LinuxMemAreaToCpuPAddr(psDestArea, 0).uiAddr) { - if(psDevInfo->ulInsertIndex == psDevInfo->ulRemoveIndex) + /* Check the back buffers */ + for(i = 0; i < psDevInfo->ui32NumFrameBuffers; i++) { - - S3C_Flip(psDevInfo, fb); - - psFlipItem->bFlipped = S3C_TRUE; + psFb = &psDevInfo->asBackBuffers[i]; + if(psFb->bufferPAddr.uiAddr == LinuxMemAreaToCpuPAddr(psDestArea, 0).uiAddr) + break; } - else + + if(i == psDevInfo->ui32NumFrameBuffers) { - psFlipItem->bFlipped = S3C_FALSE; + printk("FB reverse-lookup failed for 0x%.8x\n", + LinuxMemAreaToCpuPAddr(psDestArea, 0).uiAddr); + gsPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_FALSE); + return IMG_FALSE; } + } + + /* Now perform FIMC blits */ + for(i = 1; i < ui32NumMemInfos; i++) + { + LinuxMemArea *psSourceArea = ppsMemInfos[i]->sMemBlk.hOSMemHandle; + + BUG_ON(psHwcData[i].skip == 1); + + /* SLSI need to implement this! */ + printk("FIMC blit: 0x%.8x -> 0x%.8x {%d,%d,%d,%d}->{%d,%d,%d,%d}, tr %d\n", + LinuxMemAreaToCpuPAddr(psSourceArea, 0).uiAddr, + LinuxMemAreaToCpuPAddr(psDestArea, 0).uiAddr, + psHwcData[i].sourceCrop.left, + psHwcData[i].sourceCrop.top, + psHwcData[i].sourceCrop.right, + psHwcData[i].sourceCrop.bottom, + psHwcData[i].displayFrame.left, + psHwcData[i].displayFrame.top, + psHwcData[i].displayFrame.right, + psHwcData[i].displayFrame.bottom, + psHwcData[i].transform); + } + + return ProcessFlipV1(hCmdCookie, psDevInfo, psFb, ui32SwapInterval); +} + +static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie, + IMG_UINT32 ui32DataSize, + IMG_VOID *pvData) +{ + DISPLAYCLASS_FLIP_COMMAND *psFlipCmd; + S3C_LCD_DEVINFO *psDevInfo; - psFlipItem->hCmdComplete = hCmdCookie; - psFlipItem->psFb= fb; - psFlipItem->ulSwapInterval = (unsigned long)psFlipCmd->ui32SwapInterval; + /* Check parameters */ + if(!hCmdCookie || !pvData) + { + return IMG_FALSE; + } - psFlipItem->bValid = S3C_TRUE; + /* Validate data packet */ + psFlipCmd = (DISPLAYCLASS_FLIP_COMMAND*)pvData; - AdvanceFlipIndex(psDevInfo, &psDevInfo->ulInsertIndex); + if (psFlipCmd == IMG_NULL) + { + return IMG_FALSE; + } - mutex_unlock(&psDevInfo->sVsyncFlipItemMutex); + psDevInfo = (S3C_LCD_DEVINFO*)psFlipCmd->hExtDevice; + if (psDevInfo->bFlushCommands) + { + gsPVRJTable.pfnPVRSRVCmdComplete(hCmdCookie, IMG_FALSE); return IMG_TRUE; + } + if(psFlipCmd->hExtBuffer) + { + return ProcessFlipV1(hCmdCookie, + psDevInfo, + psFlipCmd->hExtBuffer, + psFlipCmd->ui32SwapInterval); } - mutex_unlock(&psDevInfo->sVsyncFlipItemMutex); + else + { + DISPLAYCLASS_FLIP_COMMAND2 *psFlipCmd2; + psFlipCmd2 = (DISPLAYCLASS_FLIP_COMMAND2 *)pvData; + + WARN_ON(psFlipCmd2->ui32PrivDataLength != + sizeof(s5pc110_hwc_layer_t) * psFlipCmd2->ui32NumMemInfos); - return IMG_FALSE; + BUG_ON(psFlipCmd2->ui32NumMemInfos == 0); + + return ProcessFlipV2(hCmdCookie, + psDevInfo, + psFlipCmd2->ui32SwapInterval, + psFlipCmd2->ppvMemInfos, + psFlipCmd2->ui32NumMemInfos, + psFlipCmd2->pvPrivData); + } } static S3C_BOOL InitDev(struct fb_info **s3c_fb_Info) @@ -819,8 +967,8 @@ static S3C_BOOL InitDev(struct fb_info **s3c_fb_Info) struct fb_info *psLINFBInfo; struct module *psLINFBOwner; S3C_BOOL eError = S3C_TRUE; - - acquire_console_sem(); + + S3C_CONSOLE_LOCK(); if (fb_idx < 0 || fb_idx >= num_registered_fb) { @@ -856,7 +1004,7 @@ static S3C_BOOL InitDev(struct fb_info **s3c_fb_Info) errModPut: module_put(psLINFBOwner); errRelSem: - release_console_sem(); + S3C_CONSOLE_UNLOCK(); return eError; } @@ -866,7 +1014,7 @@ static void DeInitDev(S3C_LCD_DEVINFO *psDevInfo) struct fb_info *psLINFBInfo = psDevInfo->psFBInfo; struct module *psLINFBOwner; - acquire_console_sem(); + S3C_CONSOLE_LOCK(); psLINFBOwner = psLINFBInfo->fbops->owner; @@ -877,25 +1025,26 @@ static void DeInitDev(S3C_LCD_DEVINFO *psDevInfo) module_put(psLINFBOwner); - release_console_sem(); + S3C_CONSOLE_UNLOCK(); } int s3c_displayclass_init(void) { - IMG_UINT32 screen_w, screen_h; - IMG_UINT32 pa_fb, va_fb, fb_size; + IMG_UINT32 aui32SyncCountList[DC_S3C_LCD_COMMAND_COUNT][2]; + PFN_CMD_PROC pfnCmdProcList[DC_S3C_LCD_COMMAND_COUNT]; + int rgb_format, bytes_per_pixel, bits_per_pixel; IMG_UINT32 num_of_fb, num_of_backbuffer; - IMG_UINT32 byteSize; + IMG_UINT32 byteSize, ui32FBOffset = 0; + IMG_UINT32 pa_fb, va_fb, fb_size; struct fb_info *psLINFBInfo = 0; - + IMG_UINT32 screen_w, screen_h; int i; - int rgb_format, bytes_per_pixel, bits_per_pixel; if(InitDev(&psLINFBInfo) == S3C_FALSE) { return 0; } - + pa_fb = psLINFBInfo->fix.smem_start; va_fb = (unsigned long)phys_to_virt(psLINFBInfo->fix.smem_start); screen_w = psLINFBInfo->var.xres; @@ -923,127 +1072,429 @@ int s3c_displayclass_init(void) printk("screen width=%d height=%d va=0x%x pa=0x%x\n", (int)screen_w, (int)screen_h, (unsigned int)va_fb, (unsigned int)pa_fb); printk("xres_virtual = %d, yres_virtual = %d, xoffset = %d, yoffset = %d\n", psLINFBInfo->var.xres_virtual, psLINFBInfo->var.yres_virtual, psLINFBInfo->var.xoffset, psLINFBInfo->var.yoffset); printk("fb_size=%d\n", (int)fb_size); - - num_of_fb = fb_size / (screen_w * screen_h * bytes_per_pixel); + + /* We'll share the framebuffer region with video decode buffers, + * so we need to make sure all the frame buffers are page aligned. + */ + BUG_ON(pa_fb != ALIGN(pa_fb, PAGE_SIZE)); + byteSize = ALIGN(screen_w * screen_h * bytes_per_pixel, PAGE_SIZE); + + num_of_fb = fb_size / byteSize; if(num_of_fb > S3C_MAX_BUFFERS) - { - printk("too many frame buffers\n"); - return 0; - } + num_of_fb = S3C_MAX_BUFFERS; + num_of_backbuffer = num_of_fb - 1; - - if (g_psLCDInfo == NULL) - { - PFN_CMD_PROC pfnCmdProcList[DC_S3C_LCD_COMMAND_COUNT]; - IMG_UINT32 aui32SyncCountList[DC_S3C_LCD_COMMAND_COUNT][2]; - g_psLCDInfo = (S3C_LCD_DEVINFO*)kmalloc(sizeof(S3C_LCD_DEVINFO),GFP_KERNEL); + if (gpsLCDInfo != NULL) + goto exit_out; - g_psLCDInfo->psFBInfo = psLINFBInfo; - g_psLCDInfo->ui32NumFrameBuffers = num_of_fb; + gpsLCDInfo = (S3C_LCD_DEVINFO*)kmalloc(sizeof(S3C_LCD_DEVINFO),GFP_KERNEL); - g_psLCDInfo->ui32NumFormats = S3C_DISPLAY_FORMAT_NUM; + gpsLCDInfo->psFBInfo = psLINFBInfo; + gpsLCDInfo->ui32NumFrameBuffers = num_of_fb; - g_psLCDInfo->asDisplayForamtList[0].pixelformat = rgb_format; - g_psLCDInfo->ui32NumDims = S3C_DISPLAY_DIM_NUM; - g_psLCDInfo->asDisplayDimList[0].ui32ByteStride = (bytes_per_pixel) * screen_w; - g_psLCDInfo->asDisplayDimList[0].ui32Height = screen_h; - g_psLCDInfo->asDisplayDimList[0].ui32Width = screen_w; + gpsLCDInfo->ui32NumFormats = S3C_DISPLAY_FORMAT_NUM; - g_psLCDInfo->sSysBuffer.bufferPAddr.uiAddr = pa_fb; - g_psLCDInfo->sSysBuffer.bufferVAddr = (IMG_CPU_VIRTADDR)va_fb; - g_psLCDInfo->sSysBuffer.yoffset = 0; - byteSize = screen_w * screen_h * bytes_per_pixel; - g_psLCDInfo->sSysBuffer.byteSize = (IMG_UINT32)byteSize; + gpsLCDInfo->asDisplayFormatList[0].pixelformat = rgb_format; + gpsLCDInfo->ui32NumDims = S3C_DISPLAY_DIM_NUM; + gpsLCDInfo->asDisplayDimList[0].ui32ByteStride = (bytes_per_pixel) * screen_w; + gpsLCDInfo->asDisplayDimList[0].ui32Height = screen_h; + gpsLCDInfo->asDisplayDimList[0].ui32Width = screen_w; - for (i=0 ; i < num_of_backbuffer; i++) - { - g_psLCDInfo->asBackBuffers[i].byteSize = g_psLCDInfo->sSysBuffer.byteSize; - g_psLCDInfo->asBackBuffers[i].bufferPAddr.uiAddr = pa_fb + byteSize * (i+1); - g_psLCDInfo->asBackBuffers[i].bufferVAddr = (IMG_CPU_VIRTADDR)phys_to_virt(g_psLCDInfo->asBackBuffers[i].bufferPAddr.uiAddr); - g_psLCDInfo->asBackBuffers[i].yoffset = screen_h * (i + 1); - - printk("Back frameBuffer[%d].VAddr=%p PAddr=%p size=%d\n", - i, - (void*)g_psLCDInfo->asBackBuffers[i].bufferVAddr, - (void*)g_psLCDInfo->asBackBuffers[i].bufferPAddr.uiAddr, - (int)g_psLCDInfo->asBackBuffers[i].byteSize); - } + gpsLCDInfo->sSysBuffer.bufferPAddr.uiAddr = pa_fb; + gpsLCDInfo->sSysBuffer.bufferVAddr = (IMG_CPU_VIRTADDR)va_fb; + gpsLCDInfo->sSysBuffer.yoffset = 0; + gpsLCDInfo->sSysBuffer.byteSize = (IMG_UINT32)byteSize; + ui32FBOffset += byteSize; - g_psLCDInfo->bFlushCommands = S3C_FALSE; - g_psLCDInfo->psSwapChain = NULL; - - PVRGetDisplayClassJTable(&(g_psLCDInfo->sPVRJTable)); - - g_psLCDInfo->sDCJTable.ui32TableSize = sizeof(PVRSRV_DC_SRV2DISP_KMJTABLE); - g_psLCDInfo->sDCJTable.pfnOpenDCDevice = OpenDCDevice; - g_psLCDInfo->sDCJTable.pfnCloseDCDevice = CloseDCDevice; - g_psLCDInfo->sDCJTable.pfnEnumDCFormats = EnumDCFormats; - g_psLCDInfo->sDCJTable.pfnEnumDCDims = EnumDCDims; - g_psLCDInfo->sDCJTable.pfnGetDCSystemBuffer = GetDCSystemBuffer; - g_psLCDInfo->sDCJTable.pfnGetDCInfo = GetDCInfo; - g_psLCDInfo->sDCJTable.pfnGetBufferAddr = GetDCBufferAddr; - g_psLCDInfo->sDCJTable.pfnCreateDCSwapChain = CreateDCSwapChain; - g_psLCDInfo->sDCJTable.pfnDestroyDCSwapChain = DestroyDCSwapChain; - g_psLCDInfo->sDCJTable.pfnSetDCDstRect = SetDCDstRect; - g_psLCDInfo->sDCJTable.pfnSetDCSrcRect = SetDCSrcRect; - g_psLCDInfo->sDCJTable.pfnSetDCDstColourKey = SetDCDstColourKey; - g_psLCDInfo->sDCJTable.pfnSetDCSrcColourKey = SetDCSrcColourKey; - g_psLCDInfo->sDCJTable.pfnGetDCBuffers = GetDCBuffers; - g_psLCDInfo->sDCJTable.pfnSwapToDCBuffer = SwapToDCBuffer; - g_psLCDInfo->sDCJTable.pfnSwapToDCSystem = SwapToDCSystem; - g_psLCDInfo->sDCJTable.pfnSetDCState = S3CSetState; - - g_psLCDInfo->sDisplayInfo.ui32MinSwapInterval=0; - g_psLCDInfo->sDisplayInfo.ui32MaxSwapInterval=1; - g_psLCDInfo->sDisplayInfo.ui32MaxSwapChains=1; - g_psLCDInfo->sDisplayInfo.ui32MaxSwapChainBuffers = num_of_fb; - g_psLCDInfo->sDisplayInfo.ui32PhysicalWidthmm= psLINFBInfo->var.width;// width of lcd in mm - g_psLCDInfo->sDisplayInfo.ui32PhysicalHeightmm= psLINFBInfo->var.height;// height of lcd in mm - - strncpy(g_psLCDInfo->sDisplayInfo.szDisplayName, "s3c_lcd", MAX_DISPLAY_NAME_SIZE); - - if(g_psLCDInfo->sPVRJTable.pfnPVRSRVRegisterDCDevice (&(g_psLCDInfo->sDCJTable), - (IMG_UINT32 *)(&(g_psLCDInfo->ui32DisplayID))) != PVRSRV_OK) - { + for (i=0 ; i < num_of_backbuffer; i++) + { + gpsLCDInfo->asBackBuffers[i].byteSize = gpsLCDInfo->sSysBuffer.byteSize; + gpsLCDInfo->asBackBuffers[i].bufferPAddr.uiAddr = pa_fb + byteSize * (i+1); + gpsLCDInfo->asBackBuffers[i].bufferVAddr = (IMG_CPU_VIRTADDR)phys_to_virt(gpsLCDInfo->asBackBuffers[i].bufferPAddr.uiAddr); + gpsLCDInfo->asBackBuffers[i].yoffset = screen_h * (i + 1); + ui32FBOffset += byteSize; + + printk("Back frameBuffer[%d].VAddr=%p PAddr=%p size=%d\n", + i, + (void*)gpsLCDInfo->asBackBuffers[i].bufferVAddr, + (void*)gpsLCDInfo->asBackBuffers[i].bufferPAddr.uiAddr, + (int)gpsLCDInfo->asBackBuffers[i].byteSize); + } + + gpsLCDInfo->bFlushCommands = S3C_FALSE; + gpsLCDInfo->psSwapChain = NULL; + + PVRGetDisplayClassJTable(&gsPVRJTable); + + gpsLCDInfo->sDCJTable.ui32TableSize = sizeof(PVRSRV_DC_SRV2DISP_KMJTABLE); + gpsLCDInfo->sDCJTable.pfnOpenDCDevice = OpenDCDevice; + gpsLCDInfo->sDCJTable.pfnCloseDCDevice = CloseDCDevice; + gpsLCDInfo->sDCJTable.pfnEnumDCFormats = EnumDCFormats; + gpsLCDInfo->sDCJTable.pfnEnumDCDims = EnumDCDims; + gpsLCDInfo->sDCJTable.pfnGetDCSystemBuffer = GetDCSystemBuffer; + gpsLCDInfo->sDCJTable.pfnGetDCInfo = GetDCInfo; + gpsLCDInfo->sDCJTable.pfnGetBufferAddr = GetDCBufferAddr; + gpsLCDInfo->sDCJTable.pfnCreateDCSwapChain = CreateDCSwapChain; + gpsLCDInfo->sDCJTable.pfnDestroyDCSwapChain = DestroyDCSwapChain; + gpsLCDInfo->sDCJTable.pfnSetDCDstRect = SetDCDstRect; + gpsLCDInfo->sDCJTable.pfnSetDCSrcRect = SetDCSrcRect; + gpsLCDInfo->sDCJTable.pfnSetDCDstColourKey = SetDCDstColourKey; + gpsLCDInfo->sDCJTable.pfnSetDCSrcColourKey = SetDCSrcColourKey; + gpsLCDInfo->sDCJTable.pfnGetDCBuffers = GetDCBuffers; + gpsLCDInfo->sDCJTable.pfnSwapToDCBuffer = SwapToDCBuffer; + gpsLCDInfo->sDCJTable.pfnSwapToDCSystem = SwapToDCSystem; + gpsLCDInfo->sDCJTable.pfnSetDCState = S3CSetState; + + gpsLCDInfo->sDisplayInfo.ui32MinSwapInterval=0; + gpsLCDInfo->sDisplayInfo.ui32MaxSwapInterval=1; + gpsLCDInfo->sDisplayInfo.ui32MaxSwapChains=1; + gpsLCDInfo->sDisplayInfo.ui32MaxSwapChainBuffers = num_of_fb; + gpsLCDInfo->sDisplayInfo.ui32PhysicalWidthmm= psLINFBInfo->var.width;// width of lcd in mm + gpsLCDInfo->sDisplayInfo.ui32PhysicalHeightmm= psLINFBInfo->var.height;// height of lcd in mm + + strncpy(gpsLCDInfo->sDisplayInfo.szDisplayName, "s3c_lcd", MAX_DISPLAY_NAME_SIZE); + + if(ui32FBOffset + S3C_VIDEO_CARVEOUT_SIZE <= fb_size) + { + if(InitVidBufs(ui32FBOffset)) return 1; - } + } + else + { + printk("No space for NV12 video carveout\n"); + } - pfnCmdProcList[DC_FLIP_COMMAND] = ProcessFlip; - aui32SyncCountList[DC_FLIP_COMMAND][0] = 0; - aui32SyncCountList[DC_FLIP_COMMAND][1] = 2; + if(gsPVRJTable.pfnPVRSRVRegisterDCDevice(&gpsLCDInfo->sDCJTable, + &gpsLCDInfo->ui32DeviceID) != PVRSRV_OK) + { + return 1; + } - if (g_psLCDInfo->sPVRJTable.pfnPVRSRVRegisterCmdProcList(g_psLCDInfo->ui32DisplayID, - &pfnCmdProcList[0], aui32SyncCountList, DC_S3C_LCD_COMMAND_COUNT) - != PVRSRV_OK) - { - printk("failing register commmand proc list deviceID:%d\n",(int)g_psLCDInfo->ui32DisplayID); - return PVRSRV_ERROR_CANT_REGISTER_CALLBACK; - } + pfnCmdProcList[DC_FLIP_COMMAND] = ProcessFlip; + aui32SyncCountList[DC_FLIP_COMMAND][0] = 0; + aui32SyncCountList[DC_FLIP_COMMAND][1] = 2; - if(CreateVsyncWorkQueue(g_psLCDInfo) == S3C_FALSE) - { - printk("fail to CreateVsyncWorkQueue\n"); - return 1; - } + if (gsPVRJTable.pfnPVRSRVRegisterCmdProcList(gpsLCDInfo->ui32DeviceID, + &pfnCmdProcList[0], aui32SyncCountList, DC_S3C_LCD_COMMAND_COUNT) != PVRSRV_OK) + { + printk("failing register commmand proc list deviceID:%d\n",(int)gpsLCDInfo->ui32DeviceID); + return PVRSRV_ERROR_CANT_REGISTER_CALLBACK; } - return 0; + if(CreateVsyncWorkQueue(gpsLCDInfo) == S3C_FALSE) + { + printk("fail to CreateVsyncWorkQueue\n"); + return 1; + } +exit_out: + return 0; } void s3c_displayclass_deinit(void) { - destropyVsyncWorkQueue(g_psLCDInfo); - DeInitDev(g_psLCDInfo); - g_psLCDInfo->sPVRJTable.pfnPVRSRVRemoveCmdProcList ((IMG_UINT32)g_psLCDInfo->ui32DisplayID, - DC_S3C_LCD_COMMAND_COUNT); + destroyVsyncWorkQueue(gpsLCDInfo); + DeInitDev(gpsLCDInfo); + + gsPVRJTable.pfnPVRSRVRemoveCmdProcList(gpsLCDInfo->ui32DeviceID, + DC_S3C_LCD_COMMAND_COUNT); + + DeinitVidBufs(); + + gsPVRJTable.pfnPVRSRVRemoveDCDevice(gpsLCDInfo->ui32DeviceID); + + kfree(gpsLCDInfo); + gpsLCDInfo = NULL; +} + +/***************************************************************************** + * Video-decode carveout workaround starts here + */ + +static PVRSRV_ERROR EnumVidBufFormats(IMG_HANDLE hDevice, + IMG_UINT32 *pui32NumFormats, + DISPLAY_FORMAT *psFormat) +{ + DISPLAY_FORMAT sVidBufFormat = { + /* Fake format to keep PVR2D happy */ + .pixelformat = PVRSRV_PIXEL_FORMAT_ARGB8888, + }; + + PVR_UNREFERENCED_PARAMETER(hDevice); + + if(pui32NumFormats) + *pui32NumFormats = 1; + + if(psFormat) + *psFormat = sVidBufFormat; + + return PVRSRV_OK; +} + +static PVRSRV_ERROR EnumVidBufDims(IMG_HANDLE hDevice, + DISPLAY_FORMAT *psFormat, + IMG_UINT32 *pui32NumDims, + DISPLAY_DIMS *psDim) +{ + DISPLAY_DIMS sVidBufDim = { + .ui32Width = 1280, + .ui32Height = 720, + .ui32ByteStride = 1280, + }; + + PVR_UNREFERENCED_PARAMETER(hDevice); + PVR_UNREFERENCED_PARAMETER(psFormat); + + if((S3C_VIDBUF_DEVINFO *)hDevice == &gsUVBufInfo) + sVidBufDim.ui32Height /= 2; + + if(pui32NumDims) + *pui32NumDims = 1; + + if(psDim) + psDim[0] = sVidBufDim; + + return PVRSRV_OK; +} + +static PVRSRV_ERROR GetVidBufSystemBuffer(IMG_HANDLE hDevice, + IMG_HANDLE *phBuffer) +{ + S3C_VIDBUF_DEVINFO *psDevInfo = (S3C_VIDBUF_DEVINFO *)hDevice; + + if(!hDevice || !phBuffer) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + /* FIXME: Is this really necessary? */ + *phBuffer = (IMG_HANDLE)&psDevInfo->asVideoBuffers[0]; + return PVRSRV_OK; +} + +static PVRSRV_ERROR GetVidBufInfo(IMG_HANDLE hDevice, DISPLAY_INFO *psDCInfo) +{ + S3C_VIDBUF_DEVINFO *psDevInfo = (S3C_VIDBUF_DEVINFO*)hDevice; + + if(!hDevice || !psDCInfo) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + *psDCInfo = psDevInfo->sDisplayInfo; + return PVRSRV_OK; +} + +static PVRSRV_ERROR +CreateVidBufSwapChain(IMG_HANDLE hDevice, + IMG_UINT32 ui32Flags, + DISPLAY_SURF_ATTRIBUTES *psDstSurfAttrib, + DISPLAY_SURF_ATTRIBUTES *psSrcSurfAttrib, + IMG_UINT32 ui32BufferCount, + PVRSRV_SYNC_DATA **ppsSyncData, + IMG_UINT32 ui32OEMFlags, + IMG_HANDLE *phSwapChain, + IMG_UINT32 *pui32SwapChainID) +{ + S3C_VIDBUF_DEVINFO *psDevInfo = (S3C_VIDBUF_DEVINFO*)hDevice; + S3C_FRAME_BUFFER *psBuffer; + S3C_SWAPCHAIN *psSwapChain; + IMG_UINT32 i; + + PVR_UNREFERENCED_PARAMETER(pui32SwapChainID); + PVR_UNREFERENCED_PARAMETER(psDstSurfAttrib); + PVR_UNREFERENCED_PARAMETER(psSrcSurfAttrib); + PVR_UNREFERENCED_PARAMETER(ui32OEMFlags); + PVR_UNREFERENCED_PARAMETER(ppsSyncData); + + if(!hDevice || !phSwapChain || (psDevInfo != &gsYBufInfo && + psDevInfo != &gsUVBufInfo)) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if(ui32BufferCount > S3C_MAX_VIDEO_BUFFERS) + { + return PVRSRV_ERROR_TOOMANYBUFFERS; + } + + if(psDevInfo->psSwapChain) + { + return PVRSRV_ERROR_FLIP_CHAIN_EXISTS; + } + + psSwapChain = (S3C_SWAPCHAIN *)kmalloc(sizeof(S3C_SWAPCHAIN), GFP_KERNEL); + if(!psSwapChain) + { + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + + psBuffer = (S3C_FRAME_BUFFER *)kmalloc(sizeof(S3C_FRAME_BUFFER) * ui32BufferCount, GFP_KERNEL); + if(!psBuffer) + { + kfree(psSwapChain); + return PVRSRV_ERROR_OUT_OF_MEMORY; + } + + psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; + psSwapChain->psBuffer = psBuffer; + + for (i = 0; i < ui32BufferCount; i++) + { + psBuffer[i] = psDevInfo->asVideoBuffers[i]; + } + + *phSwapChain = (IMG_HANDLE)psSwapChain; + *pui32SwapChainID =(IMG_UINT32)psSwapChain; + psDevInfo->psSwapChain = psSwapChain; + + return PVRSRV_OK; +} + +static PVRSRV_ERROR DestroyVidBufSwapChain(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain) +{ + S3C_VIDBUF_DEVINFO *psDevInfo = (S3C_VIDBUF_DEVINFO*)hDevice; + + if(!psDevInfo || hSwapChain != (IMG_HANDLE)psDevInfo->psSwapChain) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + kfree(psDevInfo->psSwapChain->psBuffer); + + kfree(psDevInfo->psSwapChain); + psDevInfo->psSwapChain = NULL; + + return PVRSRV_OK; +} + +static IMG_VOID SetVidBufState(IMG_HANDLE hDevice, IMG_UINT32 ui32State) +{ + PVR_UNREFERENCED_PARAMETER(hDevice); + PVR_UNREFERENCED_PARAMETER(ui32State); +} + +static PVRSRV_ERROR GetVidBufBuffers(IMG_HANDLE hDevice, + IMG_HANDLE hSwapChain, + IMG_UINT32 *pui32BufferCount, + IMG_HANDLE *phBuffer) +{ + S3C_VIDBUF_DEVINFO *psDevInfo = (S3C_VIDBUF_DEVINFO*)hDevice; + int i; + + if(!hDevice || !hSwapChain || !pui32BufferCount || !phBuffer) + { + return PVRSRV_ERROR_INVALID_PARAMS; + } + + *pui32BufferCount = psDevInfo->psSwapChain->ulBufferCount; + + for (i = 0; i < *pui32BufferCount; i++) + { + phBuffer[i] = (IMG_HANDLE)&psDevInfo->asVideoBuffers[i]; + } + + return PVRSRV_OK; +} + +static PVRSRV_DC_SRV2DISP_KMJTABLE gsYUVDCJTable = +{ + .ui32TableSize = sizeof(PVRSRV_DC_SRV2DISP_KMJTABLE), + + /* These understand video buffers, or are no-ops */ + .pfnOpenDCDevice = OpenDCDevice, + .pfnCloseDCDevice = CloseDCDevice, + .pfnSetDCDstRect = SetDCDstRect, + .pfnSetDCSrcRect = SetDCSrcRect, + .pfnSetDCDstColourKey = SetDCDstColourKey, + .pfnSetDCSrcColourKey = SetDCSrcColourKey, + .pfnSwapToDCBuffer = SwapToDCBuffer, + .pfnSwapToDCSystem = SwapToDCSystem, + .pfnGetBufferAddr = GetDCBufferAddr, + + /* These return PVRSRV_ERROR_NOT_SUPPORTED */ + .pfnGetDCSystemBuffer = GetVidBufSystemBuffer, + .pfnGetDCInfo = GetVidBufInfo, + + /* These work as documented */ + .pfnEnumDCFormats = EnumVidBufFormats, + .pfnEnumDCDims = EnumVidBufDims, + .pfnCreateDCSwapChain = CreateVidBufSwapChain, + .pfnDestroyDCSwapChain = DestroyVidBufSwapChain, + .pfnGetDCBuffers = GetVidBufBuffers, + .pfnSetDCState = SetVidBufState, +}; + +static int InitVidBufs(IMG_UINT32 ui32FBOffset) +{ + int i; + + if(gsPVRJTable.pfnPVRSRVRegisterDCDevice(&gsYUVDCJTable, + &gsYBufInfo.ui32DeviceID) != PVRSRV_OK) + { + printk("Failed to register YBuf device!\n"); + return 1; + } - g_psLCDInfo->sPVRJTable.pfnPVRSRVRemoveDCDevice(g_psLCDInfo->ui32DisplayID); + if(gsPVRJTable.pfnPVRSRVRegisterDCDevice(&gsYUVDCJTable, + &gsUVBufInfo.ui32DeviceID) != PVRSRV_OK) + { + printk("Failed to register UVBuf device!\n"); + return 1; + } - if (g_psLCDInfo) - kfree(g_psLCDInfo); + for (i = 0; i < S3C_MAX_VIDEO_BUFFERS; i++) + { + gsYBufInfo.asVideoBuffers[i].bufferPAddr.uiAddr = + gpsLCDInfo->sSysBuffer.bufferPAddr.uiAddr + ui32FBOffset + + (i * S3C_VIDEO_Y_SIZE); + gsYBufInfo.asVideoBuffers[i].bufferVAddr = + gpsLCDInfo->sSysBuffer.bufferVAddr + ui32FBOffset + + (i * S3C_VIDEO_Y_SIZE); + gsYBufInfo.asVideoBuffers[i].byteSize = S3C_VIDEO_Y_SIZE; + gsYBufInfo.asVideoBuffers[i].yoffset = 0; + + printk("Video Y Buffer[%d].VAddr=%p PAddr=%p size=%d\n", + i, + (void*)gsYBufInfo.asVideoBuffers[i].bufferVAddr, + (void*)gsYBufInfo.asVideoBuffers[i].bufferPAddr.uiAddr, + (int)gsYBufInfo.asVideoBuffers[i].byteSize); + } - g_psLCDInfo = NULL; + for (i = 0; i < S3C_MAX_VIDEO_BUFFERS; i++) + { + gsUVBufInfo.asVideoBuffers[i].bufferPAddr.uiAddr = + gpsLCDInfo->sSysBuffer.bufferPAddr.uiAddr + ui32FBOffset + + (S3C_MAX_VIDEO_BUFFERS * S3C_VIDEO_Y_SIZE) + + (i * S3C_VIDEO_UV_SIZE); + gsUVBufInfo.asVideoBuffers[i].bufferVAddr = + gpsLCDInfo->sSysBuffer.bufferVAddr + ui32FBOffset + + (S3C_MAX_VIDEO_BUFFERS * S3C_VIDEO_Y_SIZE) + + (i * S3C_VIDEO_UV_SIZE); + gsUVBufInfo.asVideoBuffers[i].byteSize = S3C_VIDEO_UV_SIZE; + gsUVBufInfo.asVideoBuffers[i].yoffset = 0; + + printk("Video UV Buffer[%d].VAddr=%p PAddr=%p size=%d\n", + i, + (void*)gsUVBufInfo.asVideoBuffers[i].bufferVAddr, + (void*)gsUVBufInfo.asVideoBuffers[i].bufferPAddr.uiAddr, + (int)gsUVBufInfo.asVideoBuffers[i].byteSize); + } + + return 0; } +static void DeinitVidBufs(void) +{ + if(gsUVBufInfo.ui32DeviceID) + { + gsPVRJTable.pfnPVRSRVRemoveDCDevice(gsUVBufInfo.ui32DeviceID); + } + + if(gsYBufInfo.ui32DeviceID) + { + gsPVRJTable.pfnPVRSRVRemoveDCDevice(gsYBufInfo.ui32DeviceID); + } +} diff --git a/drivers/gpu/pvr/s3c_lcd/s3c_lcd.c b/drivers/gpu/pvr/s3c_lcd/s3c_lcd.c index fb5f9b4..e9cb9bb 100644 --- a/drivers/gpu/pvr/s3c_lcd/s3c_lcd.c +++ b/drivers/gpu/pvr/s3c_lcd/s3c_lcd.c @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -22,7 +22,9 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ + */ + +/* Copyright (C) Samsung Electronics System LSI. */ #include <linux/module.h> #include <linux/init.h> @@ -32,16 +34,14 @@ #include <asm/uaccess.h> #include <asm/irq.h> #include <asm/uaccess.h> -//#include <asm/hardware.h> #include "img_defs.h" #include "servicesext.h" #include "kerneldisplay.h" +#include "pvrmodule.h" #include "s3c_lcd.h" -MODULE_LICENSE("GPL"); - static int __init S3cLcdBridgeInit(void) { if(s3c_displayclass_init()) diff --git a/drivers/gpu/pvr/s3c_lcd/s3c_lcd.h b/drivers/gpu/pvr/s3c_lcd/s3c_lcd.h index 161bb68..70b4103 100644 --- a/drivers/gpu/pvr/s3c_lcd/s3c_lcd.h +++ b/drivers/gpu/pvr/s3c_lcd/s3c_lcd.h @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -22,7 +22,9 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ + */ + +/* Copyright (C) Samsung Electronics System LSI. */ #ifndef __S3C_LCD_H__ #define __S3C_LCD_H__ @@ -31,8 +33,8 @@ extern "C" { #endif -int s3c_displayclass_init(void); -void s3c_displayclass_deinit(void); +int s3c_displayclass_init(void); +void s3c_displayclass_deinit(void); #if defined(__cplusplus) } diff --git a/drivers/gpu/pvr/s5pc110/oemfuncs.h b/drivers/gpu/pvr/s5pc110/oemfuncs.h index 60ca21b..a4c7cd8 100644 --- a/drivers/gpu/pvr/s5pc110/oemfuncs.h +++ b/drivers/gpu/pvr/s5pc110/oemfuncs.h @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -31,7 +31,7 @@ extern "C" { #endif - +/* function identifiers: */ #define OEM_EXCHANGE_POWER_STATE (1<<0) #define OEM_DEVICE_MEMORY_POWER (1<<1) #define OEM_DISPLAY_POWER (1<<2) @@ -41,13 +41,13 @@ typedef struct OEM_ACCESS_INFO_TAG { IMG_UINT32 ui32Size; IMG_UINT32 ui32FBPhysBaseAddress; - IMG_UINT32 ui32FBMemAvailable; + IMG_UINT32 ui32FBMemAvailable; /* size of usable FB memory */ IMG_UINT32 ui32SysPhysBaseAddress; IMG_UINT32 ui32SysSize; IMG_UINT32 ui32DevIRQ; } OEM_ACCESS_INFO, *POEM_ACCESS_INFO; - +/* function in/out data structures: */ typedef IMG_UINT32 (*PFN_SRV_BRIDGEDISPATCH)( IMG_UINT32 Ioctl, IMG_BYTE *pInBuf, IMG_UINT32 InBufLen, @@ -58,7 +58,9 @@ typedef IMG_UINT32 (*PFN_SRV_BRIDGEDISPATCH)( IMG_UINT32 Ioctl, typedef PVRSRV_ERROR (*PFN_SRV_READREGSTRING)(PPVRSRV_REGISTRY_INFO psRegInfo); - +/* + Function table for kernel 3rd party driver to kernel services +*/ typedef struct PVRSRV_DC_OEM_JTABLE_TAG { PFN_SRV_BRIDGEDISPATCH pfnOEMBridgeDispatch; @@ -70,4 +72,10 @@ typedef struct PVRSRV_DC_OEM_JTABLE_TAG } #endif -#endif +#endif /* __OEMFUNCS_H__ */ + +/***************************************************************************** + End of file (oemfuncs.h) +*****************************************************************************/ + + diff --git a/drivers/gpu/pvr/s5pc110/sysconfig.c b/drivers/gpu/pvr/s5pc110/sysconfig.c index 8c06c85..9a5004d 100644 --- a/drivers/gpu/pvr/s5pc110/sysconfig.c +++ b/drivers/gpu/pvr/s5pc110/sysconfig.c @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -22,7 +22,7 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +******************************************************************************/ #include "sgxdefs.h" #include "services_headers.h" @@ -30,63 +30,49 @@ #include "oemfuncs.h" #include "sgxinfo.h" #include "sgxinfokm.h" -#include "pdump_km.h" -#include "servicesext.h" - -#if defined(SLSI_S5PC110) #include <linux/platform_device.h> #include <linux/regulator/consumer.h> #include <linux/clk.h> #include <linux/err.h> -#endif #define REAL_HARDWARE 1 #define SGX540_BASEADDR 0xf3000000 #define MAPPING_SIZE 0x10000 -//#define IRQ_3D 106 #define SGX540_IRQ IRQ_3D -//static struct resource *mem; -//static void __iomem *io; #define SYS_SGX_CLOCK_SPEED (200000000) - -#if 0 -#define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ (100) // 10ms (100hz) -#define SYS_SGX_PDS_TIMER_FREQ (1000) // 1ms (1000hz) -#define SYS_SGX_ACTIVE_POWER_LATENCY_MS (500) -#else #define SYS_SGX_HWRECOVERY_TIMEOUT_FREQ (100) // 10ms (100hz) #define SYS_SGX_PDS_TIMER_FREQ (1000) // 1ms (1000hz) #ifndef SYS_SGX_ACTIVE_POWER_LATENCY_MS #define SYS_SGX_ACTIVE_POWER_LATENCY_MS (500) #endif -#endif typedef struct _SYS_SPECIFIC_DATA_TAG_ { IMG_UINT32 ui32SysSpecificData; } SYS_SPECIFIC_DATA; + #define SYS_SPECIFIC_DATA_ENABLE_IRQ 0x00000001UL #define SYS_SPECIFIC_DATA_ENABLE_LISR 0x00000002UL #define SYS_SPECIFIC_DATA_ENABLE_MISR 0x00000004UL SYS_SPECIFIC_DATA gsSysSpecificData; - +/* top level system data anchor point*/ SYS_DATA* gpsSysData = (SYS_DATA*)IMG_NULL; SYS_DATA gsSysData; - +/* SGX structures */ static IMG_UINT32 gui32SGXDeviceID; static SGX_DEVICE_MAP gsSGXDeviceMap; - +/* mimic slaveport and register block with contiguous memory */ IMG_CPU_VIRTADDR gsSGXRegsCPUVAddr; IMG_CPU_VIRTADDR gsSGXSPCPUVAddr; -char version_string[] = "SGX540 S5PC110"; +static char gszVersionString[] = "SGX540 S5PC110"; IMG_UINT32 PVRSRV_BridgeDispatchKM( IMG_UINT32 Ioctl, IMG_BYTE *pInBuf, @@ -95,9 +81,11 @@ IMG_UINT32 PVRSRV_BridgeDispatchKM( IMG_UINT32 Ioctl, IMG_UINT32 OutBufLen, IMG_UINT32 *pdwBytesTransferred); -#if defined(SLSI_S5PC110) -static struct clk *g3d_clock; -static struct regulator *g3d_pd_regulator; +#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) + +static struct clk *g3d_clock; +static struct regulator *g3d_pd_regulator; + static PVRSRV_ERROR EnableSGXClocks(void) { regulator_enable(g3d_pd_regulator); @@ -105,7 +93,7 @@ static PVRSRV_ERROR EnableSGXClocks(void) return PVRSRV_OK; } -#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) + static PVRSRV_ERROR DisableSGXClocks(void) { clk_disable(g3d_clock); @@ -113,83 +101,110 @@ static PVRSRV_ERROR DisableSGXClocks(void) return PVRSRV_OK; } -#endif -#endif -static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData) -{ -// PVRSRV_ERROR eError; -// IMG_CPU_PHYADDR sCpuPAddr; +#endif /* defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) */ - PVR_UNREFERENCED_PARAMETER(psSysData); +/*! +****************************************************************************** + @Function SysLocateDevices -#if 0 - - gsSGXDeviceMap.ui32Flags = 0x0; - sCpuPAddr.uiAddr = SGX540_BASEADDR; - gsSGXDeviceMap.sRegsCpuPBase = sCpuPAddr; - gsSGXDeviceMap.sRegsSysPBase = SysCpuPAddrToSysPAddr(gsSGXDeviceMap.sRegsCpuPBase);; - gsSGXDeviceMap.ui32RegsSize = SGX_REG_SIZE; -// gsSGXDeviceMap.pvRegsCpuVBase = (IMG_CPU_VIRTADDR)io; + @Description specifies devices in the systems memory map -#else + @Input psSysData - sys data + + @Return PVRSRV_ERROR : + +******************************************************************************/ +static PVRSRV_ERROR SysLocateDevices(SYS_DATA *psSysData) +{ + PVR_UNREFERENCED_PARAMETER(psSysData); gsSGXDeviceMap.sRegsSysPBase.uiAddr = SGX540_BASEADDR; gsSGXDeviceMap.sRegsCpuPBase = SysSysPAddrToCpuPAddr(gsSGXDeviceMap.sRegsSysPBase); gsSGXDeviceMap.ui32RegsSize = SGX_REG_SIZE; gsSGXDeviceMap.ui32IRQ = SGX540_IRQ; -#endif - #if defined(SGX_FEATURE_HOST_PORT) - + /* HostPort: */ gsSGXDeviceMap.sHPSysPBase.uiAddr = 0; gsSGXDeviceMap.sHPCpuPBase.uiAddr = 0; gsSGXDeviceMap.ui32HPSize = 0; #endif - + /* + Local Device Memory Region: (not present) + Note: the device doesn't need to know about its memory + but keep info here for now + */ gsSGXDeviceMap.sLocalMemSysPBase.uiAddr = 0; gsSGXDeviceMap.sLocalMemDevPBase.uiAddr = 0; gsSGXDeviceMap.sLocalMemCpuPBase.uiAddr = 0; gsSGXDeviceMap.ui32LocalMemSize = 0; - + /* + device interrupt IRQ + Note: no interrupts available on No HW system + */ gsSGXDeviceMap.ui32IRQ = SGX540_IRQ; - +#if defined(PDUMP) + { + /* initialise memory region name for pdumping */ + static IMG_CHAR pszPDumpDevName[] = "SGXMEM"; + gsSGXDeviceMap.pszPDumpDevName = pszPDumpDevName; + } +#endif + + /* add other devices here: */ return PVRSRV_OK; } -PVRSRV_ERROR SysInitialise() +/*! +****************************************************************************** + + @Function SysInitialise + + @Description Initialises kernel services at 'driver load' time + + @Return PVRSRV_ERROR : + +******************************************************************************/ +PVRSRV_ERROR SysInitialise(IMG_VOID) { IMG_UINT32 i; PVRSRV_ERROR eError; PVRSRV_DEVICE_NODE *psDeviceNode; SGX_TIMING_INFORMATION* psTimingInfo; - struct platform_device *pdev; gpsSysData = &gsSysData; OSMemSet(gpsSysData, 0, sizeof(SYS_DATA)); - pdev = gpsPVRLDMDev; - g3d_pd_regulator = regulator_get(&pdev->dev, "pd"); - if (IS_ERR(g3d_pd_regulator)) { - printk("\nG3D failed to find g3d power domain\n"); - return PVRSRV_ERROR_INIT_FAILURE; - } +#if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) + { + extern struct platform_device *gpsPVRLDMDev; - g3d_clock = clk_get(&pdev->dev, "sclk"); - if (IS_ERR(g3d_clock)) { - printk("\n3D failed to find g3d clock source-enable\n"); - return PVRSRV_ERROR_INIT_FAILURE; - } + g3d_pd_regulator = regulator_get(&gpsPVRLDMDev->dev, "pd"); + + if (IS_ERR(g3d_pd_regulator)) + { + PVR_DPF((PVR_DBG_ERROR, "G3D failed to find g3d power domain")); + return PVRSRV_ERROR_INIT_FAILURE; + } + + g3d_clock = clk_get(&gpsPVRLDMDev->dev, "sclk"); + if (IS_ERR(g3d_clock)) + { + PVR_DPF((PVR_DBG_ERROR, "G3D failed to find g3d clock source-enable")); + return PVRSRV_ERROR_INIT_FAILURE; + } - EnableSGXClocks(); + EnableSGXClocks(); + } +#endif eError = OSInitEnvData(&gpsSysData->pvEnvSpecificData); if (eError != PVRSRV_OK) @@ -199,26 +214,11 @@ PVRSRV_ERROR SysInitialise() gpsSysData = IMG_NULL; return eError; } -#if defined(SGX540) -//printk("SGX540 defined\n"); -#endif -//printk("SGX_CORE_REV=%d\n",SGX_CORE_REV); -#if defined(SGX_FEATURE_SYSTEM_CACHE) -//printk("SGX_FEATURE_SYSTEM_CACHE defined!!!!!!!!!!!!!!\n"); -#if defined(FIX_HW_BRN_25659) -//printk("FIX_HW_BRN_25659 defined!!!!!!!!!!!!!!\n"); - -#endif -#endif - -#if defined(SGX_BYPASS_SYSTEM_CACHE) -// printk("SGX_BYPASS_SYSTEM_CACHE defined!!!!!!!!!!!!!!!\n"); -#endif gpsSysData->pvSysSpecificData = (IMG_PVOID)&gsSysSpecificData; OSMemSet(&gsSGXDeviceMap, 0, sizeof(SGX_DEVICE_MAP)); - + /* Set up timing information*/ psTimingInfo = &gsSGXDeviceMap.sTimingInfo; psTimingInfo->ui32CoreClockSpeed = SYS_SGX_CLOCK_SPEED; psTimingInfo->ui32HWRecoveryFreq = SYS_SGX_HWRECOVERY_TIMEOUT_FREQ; @@ -227,12 +227,13 @@ PVRSRV_ERROR SysInitialise() #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) psTimingInfo->bEnableActivePM = IMG_TRUE; -#else +#else psTimingInfo->bEnableActivePM = IMG_FALSE; -#endif +#endif + gpsSysData->ui32NumDevices = SYS_DEVICE_COUNT; - + /* init device ID's */ for(i=0; i<SYS_DEVICE_COUNT; i++) { gpsSysData->sDeviceID[i].uiID = i; @@ -251,7 +252,11 @@ PVRSRV_ERROR SysInitialise() return eError; } - + /* + Locate the devices within the system, specifying + the physical addresses of each devices components + (regs, mem, ports etc.) + */ eError = SysLocateDevices(gpsSysData); if (eError != PVRSRV_OK) { @@ -261,7 +266,10 @@ PVRSRV_ERROR SysInitialise() return eError; } - + /* + Register devices with the system + This also sets up their memory maps/heaps + */ eError = PVRSRVRegisterDevice(gpsSysData, SGXRegisterDevice, 1, &gui32SGXDeviceID); if (eError != PVRSRV_OK) { @@ -271,11 +279,14 @@ PVRSRV_ERROR SysInitialise() return eError; } - + /* + Once all devices are registered, specify the backing store + and, if required, customise the memory heap config + */ psDeviceNode = gpsSysData->psDeviceNodeList; while(psDeviceNode) { - + /* perform any OEM SOC address space customisations here */ switch(psDeviceNode->sDevId.eDeviceType) { case PVRSRV_DEVICE_TYPE_SGX: @@ -286,22 +297,25 @@ PVRSRV_ERROR SysInitialise() if(gpsSysData->apsLocalDevMemArena[0] != IMG_NULL) { - + /* specify the backing store to use for the device's MMU PT/PDs */ psDeviceNode->psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0]; ui32MemConfig = PVRSRV_BACKINGSTORE_LOCALMEM_CONTIG; } else { - + /* + specify the backing store to use for the devices MMU PT/PDs + - the PT/PDs are always UMA in this system + */ psDeviceNode->psLocalDevMemArena = IMG_NULL; ui32MemConfig = PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG; } - + /* useful pointers */ psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; - + /* specify the backing store for all SGX heaps */ for(i=0; i<psDevMemoryInfo->ui32HeapCount; i++) { #if defined(SGX_FEATURE_VARIABLE_MMU_PAGE_SIZE) @@ -366,7 +380,7 @@ PVRSRV_ERROR SysInitialise() } default: { - + /* not interested in other heaps */ pStr = IMG_NULL; break; } @@ -380,10 +394,13 @@ PVRSRV_ERROR SysInitialise() PVR_DPF((PVR_DBG_VERBOSE,"SysInitialise: set Heap %s page size to %d", pStr, psDeviceMemoryHeap[i].ui32DataPageSize)); } #endif - + /* + map the device memory allocator(s) onto + the device memory heaps as required + */ psDeviceMemoryHeap[i].psLocalDevMemArena = gpsSysData->apsLocalDevMemArena[0]; - + /* set the memory config (uma | non-uma) */ psDeviceMemoryHeap[i].ui32Attribs |= ui32MemConfig; } @@ -394,15 +411,13 @@ PVRSRV_ERROR SysInitialise() return PVRSRV_ERROR_INIT_FAILURE; } - + /* advance to next device */ psDeviceNode = psDeviceNode->psNext; } - - - PDUMPINIT(); - - + /* + Initialise all devices 'managed' by services: + */ eError = PVRSRVInitialiseDevice (gui32SGXDeviceID); if (eError != PVRSRV_OK) { @@ -413,7 +428,6 @@ PVRSRV_ERROR SysInitialise() } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) - DisableSGXClocks(); #endif @@ -421,10 +435,21 @@ PVRSRV_ERROR SysInitialise() } +/*! +****************************************************************************** + + @Function SysFinalise + + @Description Final part of initialisation + + + @Return PVRSRV_ERROR : + +******************************************************************************/ PVRSRV_ERROR SysFinalise(IMG_VOID) { - PVRSRV_ERROR eError; - + PVRSRV_ERROR eError; + #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) eError = EnableSGXClocks(); if (eError != PVRSRV_OK) @@ -434,8 +459,7 @@ PVRSRV_ERROR SysFinalise(IMG_VOID) gpsSysData = IMG_NULL; return eError; } -#endif -#if defined(SYS_USING_INTERRUPTS) +#endif eError = OSInstallMISR(gpsSysData); if (eError != PVRSRV_OK) @@ -447,7 +471,8 @@ PVRSRV_ERROR SysFinalise(IMG_VOID) } gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_MISR; - +#if defined(SYS_USING_INTERRUPTS) + /* install a system ISR */ eError = OSInstallSystemLISR(gpsSysData, gsSGXDeviceMap.ui32IRQ); if (eError != PVRSRV_OK) { @@ -457,18 +482,14 @@ PVRSRV_ERROR SysFinalise(IMG_VOID) gpsSysData = IMG_NULL; return eError; } + gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_LISR; - -// SysEnableInterrupts(gpsSysData); gsSysSpecificData.ui32SysSpecificData |= SYS_SPECIFIC_DATA_ENABLE_IRQ; -#endif +#endif /* defined(SYS_USING_INTERRUPTS) */ + + /* Create a human readable version string for this system */ + gpsSysData->pszVersionString = gszVersionString; - -#if 0 - gpsSysData->pszVersionString = SysCreateVersionString(gsSGXDeviceMap.sRegsCpuPBase); -#else - gpsSysData->pszVersionString=version_string; -#endif if (!gpsSysData->pszVersionString) { PVR_DPF((PVR_DBG_ERROR,"SysFinalise: Failed to create a system version string")); @@ -479,37 +500,36 @@ PVRSRV_ERROR SysFinalise(IMG_VOID) } #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) - DisableSGXClocks(); -#endif -// gsSysSpecificData.bSGXInitComplete= IMG_TRUE; don't know - +#endif + return PVRSRV_OK; } +/*! +****************************************************************************** + + @Function SysDeinitialise + @Description De-initialises kernel services at 'driver unload' time + + @Return PVRSRV_ERROR : + +******************************************************************************/ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) { SYS_SPECIFIC_DATA * psSysSpecData; PVRSRV_ERROR eError; - - PVR_UNREFERENCED_PARAMETER(psSysData); - if (psSysData == IMG_NULL) { PVR_DPF((PVR_DBG_ERROR, "SysDeinitialise: Called with NULL SYS_DATA pointer. Probably called before.")); return PVRSRV_OK; } -#if defined(SYS_USING_INTERRUPTS) - psSysSpecData = (SYS_SPECIFIC_DATA *) psSysData->pvSysSpecificData; - if (psSysSpecData->ui32SysSpecificData & SYS_SPECIFIC_DATA_ENABLE_IRQ) - { -// SysDisableInterrupts(psSysData); - } +#if defined(SYS_USING_INTERRUPTS) if (psSysSpecData->ui32SysSpecificData & SYS_SPECIFIC_DATA_ENABLE_LISR) { eError = OSUninstallSystemLISR(psSysData); @@ -519,6 +539,8 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) return eError; } } +#endif + if (psSysSpecData->ui32SysSpecificData & SYS_SPECIFIC_DATA_ENABLE_MISR) { eError = OSUninstallMISR(psSysData); @@ -528,9 +550,8 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) return eError; } } -#endif - + /* de-initialise all services managed devices */ eError = PVRSRVDeinitialiseDevice (gui32SGXDeviceID); if (eError != PVRSRV_OK) { @@ -547,26 +568,25 @@ PVRSRV_ERROR SysDeinitialise (SYS_DATA *psSysData) SysDeinitialiseCommon(gpsSysData); - - #if REAL_HARDWARE -// iounmap(io); -// release_resource(mem); -// kfree(mem); - #else - - OSBaseFreeContigMemory(SGX_REG_SIZE, gsSGXRegsCPUVAddr, gsSGXDeviceMap.sRegsCpuPBase); - OSBaseFreeContigMemory(SGX_SP_SIZE, gsSGXSPCPUVAddr, gsSGXDeviceMap.sSPCpuPBase); - #endif - gpsSysData = IMG_NULL; - PDUMPDEINIT(); - return PVRSRV_OK; } +/*! +****************************************************************************** + + @Function SysGetDeviceMemoryMap + + @Description returns a device address map for the specified device + + @Input eDeviceType - device type + @Input ppvDeviceMap - void ptr to receive device specific info. + @Return PVRSRV_ERROR + +******************************************************************************/ PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType, IMG_VOID **ppvDeviceMap) { @@ -575,7 +595,7 @@ PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType, { case PVRSRV_DEVICE_TYPE_SGX: { - + /* just return a pointer to the structure */ *ppvDeviceMap = (IMG_VOID*)&gsSGXDeviceMap; break; @@ -589,7 +609,21 @@ PVRSRV_ERROR SysGetDeviceMemoryMap(PVRSRV_DEVICE_TYPE eDeviceType, } +/*---------------------------------------------------------------------------- +<function> + FUNCTION: SysCpuPAddrToDevPAddr + + PURPOSE: Compute a device physical address from a cpu physical + address. Relevant when + + PARAMETERS: In: cpu_paddr - cpu physical address. + In: eDeviceType - device type required if DevPAddr + address spaces vary across devices + in the same system + RETURNS: device physical address. +</function> +------------------------------------------------------------------------------*/ IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_CPU_PHYADDR CpuPAddr) { @@ -597,122 +631,249 @@ IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, PVR_UNREFERENCED_PARAMETER(eDeviceType); - + /* Note: for no HW UMA system we assume DevP == CpuP */ DevPAddr.uiAddr = CpuPAddr.uiAddr; return DevPAddr; } +/*---------------------------------------------------------------------------- +<function> + FUNCTION: SysSysPAddrToCpuPAddr + + PURPOSE: Compute a cpu physical address from a system physical + address. + + PARAMETERS: In: sys_paddr - system physical address. + RETURNS: cpu physical address. +</function> +------------------------------------------------------------------------------*/ IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr (IMG_SYS_PHYADDR sys_paddr) { IMG_CPU_PHYADDR cpu_paddr; - + /* This would only be an inequality if the CPU's MMU did not point to sys address 0, + ie. multi CPU system */ cpu_paddr.uiAddr = sys_paddr.uiAddr; return cpu_paddr; } +/*---------------------------------------------------------------------------- +<function> + FUNCTION: SysCpuPAddrToSysPAddr + + PURPOSE: Compute a system physical address from a cpu physical + address. + + PARAMETERS: In: cpu_paddr - cpu physical address. + RETURNS: device physical address. +</function> +------------------------------------------------------------------------------*/ IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr (IMG_CPU_PHYADDR cpu_paddr) { IMG_SYS_PHYADDR sys_paddr; - + /* This would only be an inequality if the CPU's MMU did not point to sys address 0, + ie. multi CPU system */ sys_paddr.uiAddr = cpu_paddr.uiAddr; return sys_paddr; } +/*---------------------------------------------------------------------------- +<function> + FUNCTION: SysSysPAddrToDevPAddr + + PURPOSE: Compute a device physical address from a system physical + address. + + PARAMETERS: In: SysPAddr - system physical address. + In: eDeviceType - device type required if DevPAddr + address spaces vary across devices + in the same system + RETURNS: Device physical address. + +</function> +-----------------------------------------------------------------------------*/ IMG_DEV_PHYADDR SysSysPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PHYADDR SysPAddr) { IMG_DEV_PHYADDR DevPAddr; PVR_UNREFERENCED_PARAMETER(eDeviceType); - + /* Note: for no HW UMA system we assume DevP == CpuP */ DevPAddr.uiAddr = SysPAddr.uiAddr; return DevPAddr; } +/*---------------------------------------------------------------------------- +<function> + FUNCTION: SysDevPAddrToSysPAddr + + PURPOSE: Compute a device physical address from a system physical + address. + PARAMETERS: In: DevPAddr - device physical address. + In: eDeviceType - device type required if DevPAddr + address spaces vary across devices + in the same system + + RETURNS: System physical address. + +</function> +-----------------------------------------------------------------------------*/ IMG_SYS_PHYADDR SysDevPAddrToSysPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_DEV_PHYADDR DevPAddr) { IMG_SYS_PHYADDR SysPAddr; PVR_UNREFERENCED_PARAMETER(eDeviceType); - + /* Note: for no HW UMA system we assume DevP == SysP */ SysPAddr.uiAddr = DevPAddr.uiAddr; return SysPAddr; } +/***************************************************************************** + FUNCTION : SysRegisterExternalDevice + PURPOSE : Called when a 3rd party device registers with services + + PARAMETERS: In: psDeviceNode - the new device node. + + RETURNS : IMG_VOID +*****************************************************************************/ IMG_VOID SysRegisterExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode) { PVR_UNREFERENCED_PARAMETER(psDeviceNode); } +/***************************************************************************** + FUNCTION : SysRemoveExternalDevice + + PURPOSE : Called when a 3rd party device unregisters from services + PARAMETERS: In: psDeviceNode - the device node being removed. + + RETURNS : IMG_VOID +*****************************************************************************/ IMG_VOID SysRemoveExternalDevice(PVRSRV_DEVICE_NODE *psDeviceNode) { PVR_UNREFERENCED_PARAMETER(psDeviceNode); } +/*---------------------------------------------------------------------------- +<function> + FUNCTION: SysGetInterruptSource + + PURPOSE: Returns System specific information about the device(s) that + generated the interrupt in the system + + PARAMETERS: In: psSysData + In: psDeviceNode + RETURNS: System specific information indicating which device(s) + generated the interrupt + +</function> +-----------------------------------------------------------------------------*/ IMG_UINT32 SysGetInterruptSource(SYS_DATA* psSysData, PVRSRV_DEVICE_NODE *psDeviceNode) { PVR_UNREFERENCED_PARAMETER(psSysData); + PVR_UNREFERENCED_PARAMETER(psDeviceNode); + #if defined(NO_HARDWARE) - + /* no interrupts in no_hw system just return all bits */ return 0xFFFFFFFF; #else - - //return psDeviceNode->ui32SOCInterruptBit; return 0x1; #endif } +/*---------------------------------------------------------------------------- +<function> + FUNCTION: SysGetInterruptSource + + PURPOSE: Clears specified system interrupts + PARAMETERS: psSysData + ui32ClearBits + + RETURNS: IMG_VOID + +</function> +-----------------------------------------------------------------------------*/ IMG_VOID SysClearInterrupts(SYS_DATA* psSysData, IMG_UINT32 ui32ClearBits) { PVR_UNREFERENCED_PARAMETER(psSysData); PVR_UNREFERENCED_PARAMETER(ui32ClearBits); - //printk("SysClearInterrupts\n"); -#if !defined(NO_HARDWARE) -// OSReadHWReg(((PVRSRV_SGXDEV_INFO *)gpsSGXDevNode->pvDevice)->pvRegsBaseKM, -// EUR_CR_EVENT_HOST_CLEAR); //do something here -#endif - + /* no interrupts in no_hw system, nothing to do */ } +/*! +****************************************************************************** + + @Function SysSystemPrePowerState + + @Description Perform system-level processing required before a power transition + @Input eNewPowerState : + + @Return PVRSRV_ERROR : + +******************************************************************************/ PVRSRV_ERROR SysSystemPrePowerState(PVRSRV_SYS_POWER_STATE eNewPowerState) { - PVRSRV_ERROR eError = PVRSRV_OK; - return eError; + PVR_UNREFERENCED_PARAMETER(eNewPowerState); + return PVRSRV_OK; } +/*! +****************************************************************************** + @Function SysSystemPostPowerState + + @Description Perform system-level processing required after a power transition + + @Input eNewPowerState : + + @Return PVRSRV_ERROR : + +******************************************************************************/ PVRSRV_ERROR SysSystemPostPowerState(PVRSRV_SYS_POWER_STATE eNewPowerState) { - PVRSRV_ERROR eError = PVRSRV_OK; - return eError; + PVR_UNREFERENCED_PARAMETER(eNewPowerState); + return PVRSRV_OK; } +/*! +****************************************************************************** + + @Function SysDevicePrePowerState + + @Description Perform system-level processing required before a device power + transition + + @Input ui32DeviceIndex : + @Input eNewPowerState : + @Input eCurrentPowerState : + + @Return PVRSRV_ERROR +******************************************************************************/ PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, PVRSRV_DEV_POWER_STATE eNewPowerState, PVRSRV_DEV_POWER_STATE eCurrentPowerState) @@ -723,7 +884,7 @@ PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, { return PVRSRV_OK; } - + #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) if (eNewPowerState == PVRSRV_DEV_POWER_STATE_OFF) { @@ -732,21 +893,36 @@ PVRSRV_ERROR SysDevicePrePowerState(IMG_UINT32 ui32DeviceIndex, DisableSGXClocks(); PVRSRVSetDCState(DC_STATE_NO_FLUSH_COMMANDS); } -#else +#else PVR_UNREFERENCED_PARAMETER(eNewPowerState); -#endif +#endif + return PVRSRV_OK; } +/*! +****************************************************************************** + + @Function SysDevicePostPowerState + @Description Perform system-level processing required after a device power + transition + + @Input ui32DeviceIndex : + @Input eNewPowerState : + @Input eCurrentPowerState : + + @Return PVRSRV_ERROR + +******************************************************************************/ PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, - PVRSRV_DEV_POWER_STATE eNewPowerState, - PVRSRV_DEV_POWER_STATE eCurrentPowerState) + PVRSRV_DEV_POWER_STATE eNewPowerState, + PVRSRV_DEV_POWER_STATE eCurrentPowerState) { PVRSRV_ERROR eError = PVRSRV_OK; - PVR_UNREFERENCED_PARAMETER(eNewPowerState); + PVR_UNREFERENCED_PARAMETER(eCurrentPowerState); if (ui32DeviceIndex != gui32SGXDeviceID) { @@ -760,21 +936,32 @@ PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, eError = EnableSGXClocks(); } #else - PVR_UNREFERENCED_PARAMETER(eCurrentPowerState); + PVR_UNREFERENCED_PARAMETER(eNewPowerState); #endif return eError; } +/***************************************************************************** + FUNCTION : SysOEMFunction + PURPOSE : marshalling function for custom OEM functions + + PARAMETERS : ui32ID - function ID + pvIn - in data + pvOut - out data + + RETURNS : PVRSRV_ERROR +*****************************************************************************/ PVRSRV_ERROR SysOEMFunction(IMG_UINT32 ui32ID, IMG_VOID *pvIn, IMG_UINT32 ulInSize, IMG_VOID *pvOut, IMG_UINT32 ulOutSize) { - if (ulInSize || pvIn); + PVR_UNREFERENCED_PARAMETER(ulInSize); + PVR_UNREFERENCED_PARAMETER(pvIn); if ((ui32ID == OEM_GET_EXT_FUNCS) && (ulOutSize == sizeof(PVRSRV_DC_OEM_JTABLE))) @@ -788,15 +975,18 @@ PVRSRV_ERROR SysOEMFunction(IMG_UINT32 ui32ID, return PVRSRV_ERROR_INVALID_PARAMS; } +PVRSRV_ERROR SysPowerLockWrap(IMG_BOOL bTryLock) +{ + /* FIXME: This should not be empty */ + PVR_UNREFERENCED_PARAMETER(bTryLock); + return PVRSRV_OK; +} -PVRSRV_ERROR SysPowerLockWrap(SYS_DATA unref__ *psSysData) -{ - return PVRSRV_OK; -} - -IMG_VOID SysPowerLockUnwrap(SYS_DATA unref__ *psSysData) -{ -} - - +IMG_VOID SysPowerLockUnwrap(IMG_VOID) +{ + /* FIXME: This should not be empty */ +} +/****************************************************************************** + End of file (sysconfig.c) +******************************************************************************/ diff --git a/drivers/gpu/pvr/s5pc110/sysconfig.h b/drivers/gpu/pvr/s5pc110/sysconfig.h index ab8a44f..af49316 100644 --- a/drivers/gpu/pvr/s5pc110/sysconfig.h +++ b/drivers/gpu/pvr/s5pc110/sysconfig.h @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -22,30 +22,38 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +*****************************************************************************/ #if !defined(__SOCCONFIG_H__) #define __SOCCONFIG_H__ -#include "syscommon.h" - #define VS_PRODUCT_NAME "s5pc110" -extern struct platform_device *gpsPVRLDMDev; - #define SYS_SGX_USSE_COUNT (1) #define SGX_REG_SIZE 0x4000 #define SGX_SP_SIZE (0x10000-SGX_REG_SIZE) +/* Set PCI vendor ID, device ID to 0, the device is not a PCI device ! */ +#define SYS_SGX_DEV_VENDOR_ID 0 +#define SYS_SGX_DEV_DEVICE_ID 0 + #if defined(SGX_FEATURE_HOST_PORT) - + /* FIXME: change these dummy values if host port is needed */ #define SYS_SGX_HP_SIZE 0x0 - + /* device virtual address of host port base */ #define SYS_SGX_HOSTPORT_BASE_DEVVADDR 0x0 #if defined(FIX_HW_BRN_22997) && defined(FIX_HW_BRN_23030) - + /* + SYS_SGX_HOSTPORT_BASE_DEVVADDR + SYS_SGX_HOSTPORT_BRN23030_OFFSET + has to be an invalid SGX virtual address + */ #define SYS_SGX_HOSTPORT_BRN23030_OFFSET 0x0 #endif #endif -#endif + +/***************************************************************************** + * system specific data structures + *****************************************************************************/ + +#endif /* __SOCCONFIG_H__ */ diff --git a/drivers/gpu/pvr/s5pc110/sysinfo.h b/drivers/gpu/pvr/s5pc110/sysinfo.h index 6427371..6743401 100644 --- a/drivers/gpu/pvr/s5pc110/sysinfo.h +++ b/drivers/gpu/pvr/s5pc110/sysinfo.h @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -22,21 +22,18 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +*****************************************************************************/ #if !defined(__SYSINFO_H__) #define __SYSINFO_H__ - -#define MAX_HW_TIME_US (1000000) -#if defined (SLSI_S5PC110) -//#define WAIT_TRY_COUNT (30000) +/*!< System specific poll/timeout details */ +#define MAX_HW_TIME_US (500000) #define WAIT_TRY_COUNT (10000) -#else -#define WAIT_TRY_COUNT (10000) -#endif - +/*! + List of device types present in this system +*/ typedef enum _SYS_DEVICE_TYPE_ { SYS_DEVICE_SGX = 0, @@ -45,17 +42,27 @@ typedef enum _SYS_DEVICE_TYPE_ } SYS_DEVICE_TYPE; -#define SYS_DEVICE_COUNT 3 - +/* SGX, DISPLAY (external), VIDEO Y (external), VIDEO UV (external) */ +#define SYS_DEVICE_COUNT 4 +/* + SGX Slave Port FIFO Size + (in units of `Bits per Write Bus Width') + Includes 5 slot safety factor for fullness register latency +*/ #define SGX_SP_FIFO_DWSIZE 123 - +/* + Set the amount to reserve - currently taken as a 1/4 of the FIFO + (The value in DWORDs is 1/4 the value in BYTEs, rounded down) +*/ #define SGX_SP_FIFO_RESERVEBYTES (SGX_SP_FIFO_DWSIZE & -4) #define SGX_SP_FIFO_MAXALLOWEDBYTES (SGX_SP_FIFO_DWSIZE * 4) - SGX_SP_FIFO_RESERVEBYTES #define SGX_EXTRACT_FIFO_COUNT(x) (((x) & SGX_INT_TA_FREEVCOUNT_MASK) >> SGX_INT_TA_FREEVCOUNT_SHIFT) +/*!< + Macro to extract FIFO space from HW register value +*/ - -#endif +#endif /* __SYSINFO_H__ */ diff --git a/drivers/gpu/pvr/s5pc110/sysutils.c b/drivers/gpu/pvr/s5pc110/sysutils.c index b9ff66f..2adff3f 100644 --- a/drivers/gpu/pvr/s5pc110/sysutils.c +++ b/drivers/gpu/pvr/s5pc110/sysutils.c @@ -1,7 +1,7 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * Samsung Electronics System LSI. modify + * 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. @@ -22,14 +22,14 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +*****************************************************************************/ #include "services_headers.h" #include "sysinfo.h" - +/* SYSTEM SPECIFIC FUNCTIONS */ diff --git a/drivers/gpu/pvr/services.h b/drivers/gpu/pvr/services.h index d1afe28..1619aef 100644 --- a/drivers/gpu/pvr/services.h +++ b/drivers/gpu/pvr/services.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -80,6 +80,9 @@ extern "C" { #define PVRSRV_MEM_BACKINGSTORE_FIELD_SHIFT (24) #define PVRSRV_MAP_NOUSERVIRTUAL (1UL<<27) +#define PVRSRV_MEM_XPROC (1U<<28) +#define PVRSRV_MEM_ION (1U<<29) +#define PVRSRV_MEM_ALLOCATENONCACHEDMEM (1UL<<30) #define PVRSRV_NO_CONTEXT_LOSS 0 #define PVRSRV_SEVERE_LOSS_OF_CONTEXT 1 @@ -96,6 +99,7 @@ extern "C" { #define PVRSRV_MISC_INFO_DDKVERSION_PRESENT (1U<<4) #define PVRSRV_MISC_INFO_CPUCACHEOP_PRESENT (1U<<5) #define PVRSRV_MISC_INFO_FREEMEM_PRESENT (1U<<6) +#define PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT (1U<<7) #define PVRSRV_MISC_INFO_RESET_PRESENT (1U<<31) @@ -162,8 +166,11 @@ typedef enum IMG_VISTAVPBNODE = 0x0000000B, IMG_OPENGL = 0x0000000C, IMG_D3D = 0x0000000D, -#if defined(SUPPORT_GRAPHICS_HAL) - IMG_GRAPHICS_HAL = 0x0000000E +#if defined(SUPPORT_GRAPHICS_HAL) || defined(SUPPORT_COMPOSER_HAL) + IMG_ANDROID_HAL = 0x0000000E, +#endif +#if defined(SUPPORT_OPENCL) + IMG_OPENCL = 0x0000000F, #endif } IMG_MODULE_ID; @@ -207,7 +214,7 @@ typedef struct _PVRSRV_CLIENT_DEV_DATA_ typedef struct _PVRSRV_CONNECTION_ { IMG_HANDLE hServices; - IMG_UINTPTR_T ui32ProcessID; + IMG_UINT32 ui32ProcessID; PVRSRV_CLIENT_DEV_DATA sClientDevData; IMG_UINT32 ui32SrvFlags; }PVRSRV_CONNECTION; @@ -216,13 +223,17 @@ typedef struct _PVRSRV_CONNECTION_ typedef struct _PVRSRV_DEV_DATA_ { IMG_CONST PVRSRV_CONNECTION *psConnection; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif } PVRSRV_DEV_DATA; typedef struct _PVRSRV_MEMUPDATE_ { - IMG_UINTPTR_T ui32UpdateAddr; + IMG_UINT32 ui32UpdateAddr; IMG_UINT32 ui32UpdateVal; } PVRSRV_MEMUPDATE; @@ -272,12 +283,22 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_ IMG_UINT32 ui32ClientFlags; - IMG_SIZE_T ui32AllocSize; + IMG_SIZE_T uAllocSize; struct _PVRSRV_CLIENT_SYNC_INFO_ *psClientSyncInfo; +#if defined (SUPPORT_SID_INTERFACE) + + IMG_SID hMappingInfo; + + + IMG_SID hKernelMemInfo; + + + IMG_SID hResItem; +#else IMG_HANDLE hMappingInfo; @@ -286,6 +307,7 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_ IMG_HANDLE hResItem; +#endif #if defined(SUPPORT_MEMINFO_IDS) #if !defined(USE_CODE) @@ -309,7 +331,11 @@ typedef struct _PVRSRV_CLIENT_MEM_INFO_ typedef struct _PVRSRV_HEAP_INFO_ { IMG_UINT32 ui32HeapID; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeap; +#else IMG_HANDLE hDevMemHeap; +#endif IMG_DEV_VIRTADDR sDevVAddrBase; IMG_UINT32 ui32HeapByteSize; IMG_UINT32 ui32Attribs; @@ -324,7 +350,11 @@ typedef struct _PVRSRV_EVENTOBJECT_ IMG_CHAR szName[EVENTOBJNAME_MAXLENGTH]; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hOSEventKM; +#else IMG_HANDLE hOSEventKM; +#endif } PVRSRV_EVENTOBJECT; @@ -343,8 +373,13 @@ typedef struct _PVRSRV_MISC_INFO_ IMG_VOID *pvSOCTimerRegisterKM; IMG_VOID *pvSOCTimerRegisterUM; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSOCTimerRegisterOSMemHandle; + IMG_SID hSOCTimerRegisterMappingInfo; +#else IMG_HANDLE hSOCTimerRegisterOSMemHandle; IMG_HANDLE hSOCTimerRegisterMappingInfo; +#endif IMG_VOID *pvSOCClockGateRegs; @@ -356,7 +391,11 @@ typedef struct _PVRSRV_MISC_INFO_ PVRSRV_EVENTOBJECT sGlobalEventObject; +#if defined (SUPPORT_SID_INTERFACE) + IMG_EVENTSID hOSGlobalEvent; +#else IMG_HANDLE hOSGlobalEvent; +#endif IMG_UINT32 aui32DDKVersion[4]; @@ -371,6 +410,7 @@ typedef struct _PVRSRV_MISC_INFO_ PVRSRV_MISC_INFO_CPUCACHEOP_TYPE eCacheOpType; +#if !defined (SUPPORT_SID_INTERFACE) union { @@ -379,6 +419,7 @@ typedef struct _PVRSRV_MISC_INFO_ struct _PVRSRV_KERNEL_MEM_INFO_ *psKernelMemInfo; } u; +#endif IMG_VOID *pvBaseVAddr; @@ -386,14 +427,52 @@ typedef struct _PVRSRV_MISC_INFO_ IMG_UINT32 ui32Length; } sCacheOpCtl; + + + struct + { + +#if !defined(SUPPORT_SID_INTERFACE) + union + { + + PVRSRV_CLIENT_MEM_INFO *psClientMemInfo; + + + struct _PVRSRV_KERNEL_MEM_INFO_ *psKernelMemInfo; + } u; +#endif + + + IMG_UINT32 ui32RefCount; + } sGetRefCountCtl; } PVRSRV_MISC_INFO; +typedef struct _PVRSRV_SYNC_TOKEN_ +{ + + + struct + { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo; +#else + IMG_HANDLE hKernelSyncInfo; +#endif + IMG_UINT32 ui32ReadOpsPendingSnapshot; + IMG_UINT32 ui32WriteOpsPendingSnapshot; + IMG_UINT32 ui32ReadOps2PendingSnapshot; + } sPrivate; +} PVRSRV_SYNC_TOKEN; + typedef enum _PVRSRV_CLIENT_EVENT_ { PVRSRV_CLIENT_EVENT_HWTIMEOUT = 0, } PVRSRV_CLIENT_EVENT; +typedef IMG_VOID (*PFN_QUEUE_COMMAND_COMPLETE)(IMG_HANDLE hCallbackData); + IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVClientEvent(IMG_CONST PVRSRV_CLIENT_EVENT eEvent, PVRSRV_DEV_DATA *psDevData, @@ -432,7 +511,11 @@ IMG_IMPORT IMG_VOID WriteHWRegs(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Count IMG_IMPORT PVRSRV_ERROR PVRSRVPollForValue ( const PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hOSEvent, +#else IMG_HANDLE hOSEvent, +#endif volatile IMG_UINT32 *pui32LinMemAddr, IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask, @@ -441,17 +524,30 @@ PVRSRV_ERROR PVRSRVPollForValue ( const PVRSRV_CONNECTION *psConnection, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContext(IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *phDevMemContext, +#else IMG_HANDLE *phDevMemContext, +#endif IMG_UINT32 *pui32SharedHeapCount, PVRSRV_HEAP_INFO *psHeapInfo); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyDeviceMemContext(IMG_CONST PVRSRV_DEV_DATA *psDevData, - IMG_HANDLE hDevMemContext); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext +#else + IMG_HANDLE hDevMemContext +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfo(IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext, +#else IMG_HANDLE hDevMemContext, +#endif IMG_UINT32 *pui32SharedHeapCount, PVRSRV_HEAP_INFO *psHeapInfo); @@ -467,8 +563,26 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfo(IMG_CONST PVRSRV_DEV_DATA * IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem2(IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeap, +#else + IMG_HANDLE hDevMemHeap, +#endif + IMG_UINT32 ui32Attribs, + IMG_SIZE_T ui32Size, + IMG_SIZE_T ui32Alignment, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength, + PVRSRV_CLIENT_MEM_INFO **ppsMemInfo); + +IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeap, +#else IMG_HANDLE hDevMemHeap, +#endif IMG_UINT32 ui32Attribs, IMG_SIZE_T ui32Size, IMG_SIZE_T ui32Alignment, @@ -481,11 +595,20 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMem(IMG_CONST PVRSRV_DEV_DATA *psDevDa IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVExportDeviceMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, PVRSRV_CLIENT_MEM_INFO *psMemInfo, - IMG_HANDLE *phMemInfo); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *phMemInfo +#else + IMG_HANDLE *phMemInfo +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVReserveDeviceVirtualMem(IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemHeap, +#else IMG_HANDLE hDevMemHeap, +#endif IMG_DEV_VIRTADDR *psDevVAddr, IMG_SIZE_T ui32Size, IMG_SIZE_T ui32Alignment, @@ -496,8 +619,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceVirtualMem(IMG_CONST PVRSRV_DEV_DATA * IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo, + IMG_SID hDstDevMemHeap, +#else IMG_HANDLE hKernelMemInfo, IMG_HANDLE hDstDevMemHeap, +#endif PVRSRV_CLIENT_MEM_INFO **ppsDstMemInfo); IMG_IMPORT @@ -516,7 +644,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapExtMemory (IMG_CONST PVRSRV_DEV_DATA *psDev IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemory(IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext, +#else IMG_HANDLE hDevMemContext, +#endif IMG_SIZE_T ui32ByteSize, IMG_SIZE_T ui32PageOffset, IMG_BOOL bPhysContig, @@ -534,8 +666,13 @@ PVRSRV_ERROR PVRSRVChangeDeviceMemoryAttributes(IMG_CONST PVRSRV_DEV_DATA *psD IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext, + IMG_SID hDeviceClassBuffer, +#else IMG_HANDLE hDevMemContext, IMG_HANDLE hDeviceClassBuffer, +#endif PVRSRV_CLIENT_MEM_INFO **ppsMemInfo); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData, @@ -554,6 +691,39 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapPhysToUserSpace(IMG_CONST PVRSRV_DEV_DATA * IMG_PVOID pvUserAddr, IMG_PVOID pvProcess); +#if defined(LINUX) +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVExportDeviceMem2(IMG_CONST PVRSRV_DEV_DATA *psDevData, + PVRSRV_CLIENT_MEM_INFO *psMemInfo, + IMG_INT *iFd); + +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory2(IMG_CONST PVRSRV_DEV_DATA *psDevData, + IMG_INT iFd, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDstDevMemHeap, +#else + IMG_HANDLE hDstDevMemHeap, +#endif + PVRSRV_CLIENT_MEM_INFO **ppsDstMemInfo); +#endif + +#if defined(SUPPORT_ION) +PVRSRV_ERROR PVRSRVMapIonHandle(const PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext, +#else + IMG_HANDLE hDevMemContext, +#endif + IMG_INT32 uiFD, + IMG_UINT32 uiSize, + IMG_UINT32 ui32Attribs, + PVRSRV_CLIENT_MEM_INFO **ppsMemInfo); + +PVRSRV_ERROR PVRSRVUnmapIonHandle(const PVRSRV_DEV_DATA *psDevData, + PVRSRV_CLIENT_MEM_INFO *psMemInfo); +#endif + typedef enum _PVRSRV_SYNCVAL_MODE_ { PVRSRV_SYNCVAL_READ = IMG_TRUE, @@ -611,7 +781,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumDCDims (IMG_HANDLE hDevice, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCSystemBuffer(IMG_HANDLE hDevice, - IMG_HANDLE *phBuffer); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *phBuffer +#else + IMG_HANDLE *phBuffer +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCInfo(IMG_HANDLE hDevice, @@ -625,49 +800,118 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDCSwapChain (IMG_HANDLE hDevice, IMG_UINT32 ui32BufferCount, IMG_UINT32 ui32OEMFlags, IMG_UINT32 *pui32SwapChainID, - IMG_HANDLE *phSwapChain); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *phSwapChain +#else + IMG_HANDLE *phSwapChain +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyDCSwapChain (IMG_HANDLE hDevice, - IMG_HANDLE hSwapChain); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain +#else + IMG_HANDLE hSwapChain +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCDstRect (IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain, +#else IMG_HANDLE hSwapChain, +#endif IMG_RECT *psDstRect); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCSrcRect (IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain, +#else IMG_HANDLE hSwapChain, +#endif IMG_RECT *psSrcRect); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCDstColourKey (IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain, +#else IMG_HANDLE hSwapChain, +#endif IMG_UINT32 ui32CKColour); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCSrcColourKey (IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain, +#else IMG_HANDLE hSwapChain, +#endif IMG_UINT32 ui32CKColour); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCBuffers(IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain, + IMG_SID *phBuffer +#else IMG_HANDLE hSwapChain, - IMG_HANDLE *phBuffer); + IMG_HANDLE *phBuffer +#endif + ); + +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCBuffers2(IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain, + IMG_SID *phBuffer, +#else + IMG_HANDLE hSwapChain, + IMG_HANDLE *phBuffer, +#endif + IMG_SYS_PHYADDR *psPhyAddr); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCBuffer (IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hBuffer, +#else IMG_HANDLE hBuffer, +#endif IMG_UINT32 ui32ClipRectCount, - IMG_RECT *psClipRect, + IMG_RECT *psClipRect, IMG_UINT32 ui32SwapInterval, - IMG_HANDLE hPrivateTag); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hPrivateTag +#else + IMG_HANDLE hPrivateTag +#endif + ); IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCSystem (IMG_HANDLE hDevice, - IMG_HANDLE hSwapChain); +PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCBuffer2 (IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hBuffer, +#else + IMG_HANDLE hBuffer, +#endif + IMG_UINT32 ui32SwapInterval, + PVRSRV_CLIENT_MEM_INFO **ppsMemInfos, + IMG_UINT32 ui32NumMemInfos, + IMG_PVOID pvPrivData, + IMG_UINT32 ui32PrivDataLength); +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCSystem (IMG_HANDLE hDevice, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSwapChain +#else + IMG_HANDLE hSwapChain +#endif + ); IMG_IMPORT IMG_HANDLE IMG_CALLCONV PVRSRVOpenBCDevice(IMG_CONST PVRSRV_DEV_DATA *psDevData, @@ -684,7 +928,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetBCBufferInfo(IMG_HANDLE hDevice, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetBCBuffer(IMG_HANDLE hDevice, IMG_UINT32 ui32BufferIndex, - IMG_HANDLE *phBuffer); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *phBuffer +#else + IMG_HANDLE *phBuffer +#endif + ); IMG_IMPORT @@ -698,7 +947,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpStopInitPhase(IMG_CONST PVRSRV_CONNECTION * IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPol(IMG_CONST PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo, +#else PVRSRV_CLIENT_MEM_INFO *psMemInfo, +#endif IMG_UINT32 ui32Offset, IMG_UINT32 ui32Value, IMG_UINT32 ui32Mask, @@ -707,10 +960,23 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPol(IMG_CONST PVRSRV_CONNECTION *psConne IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSyncPol(IMG_CONST PVRSRV_CONNECTION *psConnection, - PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo, - IMG_BOOL bIsRead, - IMG_UINT32 ui32Value, - IMG_UINT32 ui32Mask); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo, +#else + PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo, +#endif + IMG_BOOL bIsRead, + IMG_UINT32 ui32Value, + IMG_UINT32 ui32Mask); + +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSyncPol2(IMG_CONST PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfo, +#else + PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo, +#endif + IMG_BOOL bIsRead); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMem(IMG_CONST PVRSRV_CONNECTION *psConnection, @@ -758,15 +1024,21 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpPDDevPAddr(IMG_CONST PVRSRV_CONNECTION *psC IMG_UINT32 ui32Offset, IMG_DEV_PHYADDR sPDDevPAddr); +#if !defined(USE_CODE) IMG_IMPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPages(IMG_CONST PVRSRV_CONNECTION *psConnection, - IMG_HANDLE hKernelMemInfo, - IMG_DEV_PHYADDR *pPages, - IMG_UINT32 ui32NumPages, - IMG_DEV_VIRTADDR sDevAddr, - IMG_UINT32 ui32Start, - IMG_UINT32 ui32Length, - IMG_BOOL bContinuous); +PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPages(IMG_CONST PVRSRV_DEV_DATA *psDevData, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo, +#else + IMG_HANDLE hKernelMemInfo, +#endif + IMG_DEV_PHYADDR *pPages, + IMG_UINT32 ui32NumPages, + IMG_DEV_VIRTADDR sDevVAddr, + IMG_UINT32 ui32Start, + IMG_UINT32 ui32Length, + IMG_UINT32 ui32Flags); +#endif IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSetFrame(IMG_CONST PVRSRV_CONNECTION *psConnection, @@ -812,7 +1084,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpBitmap(IMG_CONST PVRSRV_DEV_DATA *psDevData IMG_UINT32 ui32Height, IMG_UINT32 ui32StrideInBytes, IMG_DEV_VIRTADDR sDevBaseAddr, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext, +#else IMG_HANDLE hDevMemContext, +#endif IMG_UINT32 ui32Size, PDUMP_PIXEL_FORMAT ePixelFormat, PDUMP_MEM_FORMAT eMemFormat, @@ -843,7 +1119,7 @@ IMG_IMPORT PVRSRV_ERROR PVRSRVGetLibFuncAddr(IMG_HANDLE hExtDrv, const IMG_CHAR IMG_IMPORT IMG_UINT32 PVRSRVClockus (void); IMG_IMPORT IMG_VOID PVRSRVWaitus (IMG_UINT32 ui32Timeus); IMG_IMPORT IMG_VOID PVRSRVReleaseThreadQuanta (void); -IMG_IMPORT IMG_UINTPTR_T IMG_CALLCONV PVRSRVGetCurrentProcessID(void); +IMG_IMPORT IMG_UINT32 IMG_CALLCONV PVRSRVGetCurrentProcessID(void); IMG_IMPORT IMG_CHAR * IMG_CALLCONV PVRSRVSetLocale(const IMG_CHAR *pszLocale); @@ -872,11 +1148,17 @@ IMG_IMPORT IMG_VOID PVRSRVMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_ struct _PVRSRV_MUTEX_OPAQUE_STRUCT_; typedef struct _PVRSRV_MUTEX_OPAQUE_STRUCT_ *PVRSRV_MUTEX_HANDLE; + + IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateMutex(PVRSRV_MUTEX_HANDLE *phMutex); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyMutex(PVRSRV_MUTEX_HANDLE hMutex); IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockMutex(PVRSRV_MUTEX_HANDLE hMutex); IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockMutex(PVRSRV_MUTEX_HANDLE hMutex); +IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockProcessGlobalMutex(void); +IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockProcessGlobalMutex(void); + + struct _PVRSRV_SEMAPHORE_OPAQUE_STRUCT_; typedef struct _PVRSRV_SEMAPHORE_OPAQUE_STRUCT_ *PVRSRV_SEMAPHORE_HANDLE; @@ -939,21 +1221,40 @@ IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMemTracking(IMG_VOID *pvM #endif IMG_IMPORT PVRSRV_ERROR PVRSRVEventObjectWait(const PVRSRV_CONNECTION *psConnection, - IMG_HANDLE hOSEvent); +#if defined (SUPPORT_SID_INTERFACE) + IMG_EVENTSID hOSEvent +#else + IMG_HANDLE hOSEvent +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateSyncInfoModObj(const PVRSRV_CONNECTION *psConnection, - IMG_HANDLE *phKernelSyncInfoModObj); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *phKernelSyncInfoModObj +#else + IMG_HANDLE *phKernelSyncInfoModObj +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroySyncInfoModObj(const PVRSRV_CONNECTION *psConnection, - IMG_HANDLE hKernelSyncInfoModObj); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj +#else + IMG_HANDLE hKernelSyncInfoModObj +#endif + ); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyPendingSyncOps(const PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj, +#else IMG_HANDLE hKernelSyncInfoModObj, +#endif PVRSRV_CLIENT_SYNC_INFO *psSyncInfo, IMG_UINT32 ui32ModifyFlags, IMG_UINT32 *pui32ReadOpsPending, @@ -961,11 +1262,37 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyPendingSyncOps(const PVRSRV_CONNECTION *ps IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyCompleteSyncOps(const PVRSRV_CONNECTION *psConnection, - IMG_HANDLE hKernelSyncInfoModObj); +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj +#else + IMG_HANDLE hKernelSyncInfoModObj +#endif + ); IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsTakeToken(const PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + const IMG_SID hKernelSyncInfo, +#else + const PVRSRV_CLIENT_SYNC_INFO *psSyncInfo, +#endif + PVRSRV_SYNC_TOKEN *psSyncToken); +IMG_IMPORT +PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToToken(const PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + const IMG_SID hKernelSyncInfo, +#else + const PVRSRV_CLIENT_SYNC_INFO *psSyncInfo, +#endif + const PVRSRV_SYNC_TOKEN *psSyncToken, + IMG_BOOL bWait); +IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToModObj(const PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelSyncInfoModObj, +#else IMG_HANDLE hKernelSyncInfoModObj, +#endif IMG_BOOL bWait); IMG_IMPORT diff --git a/drivers/gpu/pvr/services_headers.h b/drivers/gpu/pvr/services_headers.h index eb00dbb..2b5f197 100644 --- a/drivers/gpu/pvr/services_headers.h +++ b/drivers/gpu/pvr/services_headers.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/servicesext.h b/drivers/gpu/pvr/servicesext.h index 2f81b11..af3e4aa 100644 --- a/drivers/gpu/pvr/servicesext.h +++ b/drivers/gpu/pvr/servicesext.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -86,6 +86,8 @@ typedef enum _PVRSRV_ERROR_ PVRSRV_ERROR_REGISTER_BASE_NOT_SET, + PVRSRV_ERROR_BM_BAD_SHAREMEM_HANDLE, + PVRSRV_ERROR_FAILED_TO_ALLOC_USER_MEM, PVRSRV_ERROR_FAILED_TO_ALLOC_VP_MEMORY, PVRSRV_ERROR_FAILED_TO_MAP_SHARED_PBDESC, @@ -149,6 +151,7 @@ typedef enum _PVRSRV_ERROR_ PVRSRV_ERROR_UNABLE_TO_CLOSE_SERVICES, PVRSRV_ERROR_UNABLE_TO_REGISTER_CONTEXT, PVRSRV_ERROR_UNABLE_TO_REGISTER_RESOURCE, + PVRSRV_ERROR_UNABLE_TO_CLOSE_HANDLE, PVRSRV_ERROR_INVALID_CCB_COMMAND, @@ -578,6 +581,20 @@ typedef enum _PVRSRV_PIXEL_FORMAT_ { PVRSRV_PIXEL_FORMAT_ABGR1555 = 213, PVRSRV_PIXEL_FORMAT_BGR565 = 214, + + PVRSRV_PIXEL_FORMAT_C0_4KYUV420_2P_UV = 215, + PVRSRV_PIXEL_FORMAT_C0_4KYUV420_2P_VU = 216, + PVRSRV_PIXEL_FORMAT_C1_4KYUV420_2P_UV = 217, + PVRSRV_PIXEL_FORMAT_C1_4KYUV420_2P_VU = 218, + PVRSRV_PIXEL_FORMAT_P208 = 219, + PVRSRV_PIXEL_FORMAT_A8P8 = 220, + + PVRSRV_PIXEL_FORMAT_A4 = 221, + PVRSRV_PIXEL_FORMAT_AYUV8888 = 222, + PVRSRV_PIXEL_FORMAT_RAW256 = 223, + PVRSRV_PIXEL_FORMAT_RAW512 = 224, + PVRSRV_PIXEL_FORMAT_RAW1024 = 225, + PVRSRV_PIXEL_FORMAT_FORCE_I32 = 0x7fffffff } PVRSRV_PIXEL_FORMAT; @@ -621,6 +638,10 @@ typedef struct _PVRSRV_SYNC_DATA_ volatile IMG_UINT32 ui32ReadOpsComplete; + IMG_UINT32 ui32ReadOps2Pending; + volatile IMG_UINT32 ui32ReadOps2Complete; + + IMG_UINT32 ui32LastOpDumpVal; IMG_UINT32 ui32LastReadOpDumpVal; @@ -629,7 +650,7 @@ typedef struct _PVRSRV_SYNC_DATA_ typedef struct _PVRSRV_CLIENT_SYNC_INFO_ { - PVRSRV_SYNC_DATA *psSyncData; + PVRSRV_SYNC_DATA *psSyncData; @@ -641,10 +662,20 @@ typedef struct _PVRSRV_CLIENT_SYNC_INFO_ IMG_DEV_VIRTADDR sReadOpsCompleteDevVAddr; + IMG_DEV_VIRTADDR sReadOps2CompleteDevVAddr; + + +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hMappingInfo; + + + IMG_SID hKernelSyncInfo; +#else IMG_HANDLE hMappingInfo; IMG_HANDLE hKernelSyncInfo; +#endif } PVRSRV_CLIENT_SYNC_INFO, *PPVRSRV_CLIENT_SYNC_INFO; @@ -762,47 +793,17 @@ typedef struct ACCESS_INFO_TAG }ACCESS_INFO; -typedef struct PVRSRV_CURSOR_SHAPE_TAG -{ - IMG_UINT16 ui16Width; - IMG_UINT16 ui16Height; - IMG_INT16 i16XHot; - IMG_INT16 i16YHot; - - IMG_VOID* pvMask; - IMG_INT16 i16MaskByteStride; +#if defined(PDUMP_SUSPEND_IS_PER_THREAD) +typedef struct { + IMG_UINT32 threadId; + IMG_INT suspendCount; +} PVRSRV_THREAD_SUSPEND_COUNT; - - IMG_VOID* pvColour; - IMG_INT16 i16ColourByteStride; - PVRSRV_PIXEL_FORMAT eColourPixelFormat; -} PVRSRV_CURSOR_SHAPE; +#define PVRSRV_PDUMP_SUSPEND_Q_NAME "PVRSRVPDumpSuspendMsgQ" +#define PVRSRV_PDUMP_SUSPEND_Q_LENGTH 8 -#define PVRSRV_SET_CURSOR_VISIBILITY (1<<0) -#define PVRSRV_SET_CURSOR_POSITION (1<<1) -#define PVRSRV_SET_CURSOR_SHAPE (1<<2) -#define PVRSRV_SET_CURSOR_ROTATION (1<<3) - -typedef struct PVRSRV_CURSOR_INFO_TAG -{ - - IMG_UINT32 ui32Flags; - - - IMG_BOOL bVisible; - - - IMG_INT16 i16XPos; - IMG_INT16 i16YPos; - - - PVRSRV_CURSOR_SHAPE sCursorShape; - - - IMG_UINT32 ui32Rotation; - -} PVRSRV_CURSOR_INFO; +#endif typedef struct _PVRSRV_REGISTRY_INFO_ diff --git a/drivers/gpu/pvr/servicesint.h b/drivers/gpu/pvr/servicesint.h index bc5aeb8..c9b565e 100644 --- a/drivers/gpu/pvr/servicesint.h +++ b/drivers/gpu/pvr/servicesint.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -68,7 +68,7 @@ typedef struct _PVRSRV_KERNEL_MEM_INFO_ IMG_UINT32 ui32Flags; - IMG_SIZE_T ui32AllocSize; + IMG_SIZE_T uAllocSize; PVRSRV_MEMBLK sMemBlk; @@ -97,6 +97,31 @@ typedef struct _PVRSRV_KERNEL_MEM_INFO_ struct _PVRSRV_KERNEL_SYNC_INFO_ *psKernelSyncInfo; PVRSRV_MEMTYPE memType; + + + + + + + + + struct { + + + IMG_BOOL bInUse; + + + IMG_HANDLE hDevCookieInt; + + + IMG_UINT32 ui32ShareIndex; + + + + IMG_UINT32 ui32OrigReqAttribs; + IMG_UINT32 ui32OrigReqSize; + IMG_UINT32 ui32OrigReqAlignment; + } sShareMemWorkaround; } PVRSRV_KERNEL_MEM_INFO; @@ -112,6 +137,9 @@ typedef struct _PVRSRV_KERNEL_SYNC_INFO_ IMG_DEV_VIRTADDR sReadOpsCompleteDevVAddr; + IMG_DEV_VIRTADDR sReadOps2CompleteDevVAddr; + + PVRSRV_KERNEL_MEM_INFO *psSyncDataMemInfoKM; @@ -120,6 +148,9 @@ typedef struct _PVRSRV_KERNEL_SYNC_INFO_ IMG_HANDLE hResItem; + + + IMG_UINT32 ui32UID; } PVRSRV_KERNEL_SYNC_INFO; typedef struct _PVRSRV_DEVICE_SYNC_OBJECT_ @@ -129,6 +160,8 @@ typedef struct _PVRSRV_DEVICE_SYNC_OBJECT_ IMG_DEV_VIRTADDR sReadOpsCompleteDevVAddr; IMG_UINT32 ui32WriteOpsPendingVal; IMG_DEV_VIRTADDR sWriteOpsCompleteDevVAddr; + IMG_UINT32 ui32ReadOps2PendingVal; + IMG_DEV_VIRTADDR sReadOps2CompleteDevVAddr; } PVRSRV_DEVICE_SYNC_OBJECT; typedef struct _PVRSRV_SYNC_OBJECT @@ -136,21 +169,24 @@ typedef struct _PVRSRV_SYNC_OBJECT PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfoKM; IMG_UINT32 ui32WriteOpsPending; IMG_UINT32 ui32ReadOpsPending; + IMG_UINT32 ui32ReadOps2Pending; }PVRSRV_SYNC_OBJECT, *PPVRSRV_SYNC_OBJECT; typedef struct _PVRSRV_COMMAND { - IMG_SIZE_T ui32CmdSize; + IMG_SIZE_T uCmdSize; IMG_UINT32 ui32DevIndex; IMG_UINT32 CommandType; IMG_UINT32 ui32DstSyncCount; IMG_UINT32 ui32SrcSyncCount; PVRSRV_SYNC_OBJECT *psDstSync; PVRSRV_SYNC_OBJECT *psSrcSync; - IMG_SIZE_T ui32DataSize; + IMG_SIZE_T uDataSize; IMG_UINT32 ui32ProcessID; IMG_VOID *pvData; + PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete; + IMG_HANDLE hCallbackData; }PVRSRV_COMMAND, *PPVRSRV_COMMAND; @@ -171,6 +207,86 @@ typedef struct _PVRSRV_QUEUE_INFO_ struct _PVRSRV_QUEUE_INFO_ *psNextKM; }PVRSRV_QUEUE_INFO; + +typedef struct _PVRSRV_HEAP_INFO_KM_ +{ + IMG_UINT32 ui32HeapID; + IMG_DEV_VIRTADDR sDevVAddrBase; + + IMG_HANDLE hDevMemHeap; + IMG_UINT32 ui32HeapByteSize; + IMG_UINT32 ui32Attribs; + IMG_UINT32 ui32XTileStride; +}PVRSRV_HEAP_INFO_KM; + + +typedef struct _PVRSRV_EVENTOBJECT_KM_ +{ + + IMG_CHAR szName[EVENTOBJNAME_MAXLENGTH]; + + IMG_HANDLE hOSEventKM; + +} PVRSRV_EVENTOBJECT_KM; + + +typedef struct _PVRSRV_MISC_INFO_KM_ +{ + IMG_UINT32 ui32StateRequest; + IMG_UINT32 ui32StatePresent; + + + IMG_VOID *pvSOCTimerRegisterKM; + IMG_VOID *pvSOCTimerRegisterUM; + IMG_HANDLE hSOCTimerRegisterOSMemHandle; + IMG_HANDLE hSOCTimerRegisterMappingInfo; + + + IMG_VOID *pvSOCClockGateRegs; + IMG_UINT32 ui32SOCClockGateRegsSize; + + + IMG_CHAR *pszMemoryStr; + IMG_UINT32 ui32MemoryStrLen; + + + PVRSRV_EVENTOBJECT_KM sGlobalEventObject; + IMG_HANDLE hOSGlobalEvent; + + + IMG_UINT32 aui32DDKVersion[4]; + + + struct + { + + IMG_BOOL bDeferOp; + + + PVRSRV_MISC_INFO_CPUCACHEOP_TYPE eCacheOpType; + + + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + + + IMG_VOID *pvBaseVAddr; + + + IMG_UINT32 ui32Length; + } sCacheOpCtl; + + + struct + { + + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo; + + + IMG_UINT32 ui32RefCount; + } sGetRefCountCtl; +} PVRSRV_MISC_INFO_KM; + + typedef PVRSRV_ERROR (*PFN_INSERT_CMD) (PVRSRV_QUEUE_INFO*, PVRSRV_COMMAND**, IMG_UINT32, @@ -190,59 +306,35 @@ typedef struct PVRSRV_DEVICECLASS_BUFFER_TAG IMG_HANDLE hExtDevice; IMG_HANDLE hExtBuffer; PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo; - + IMG_UINT32 ui32MemMapRefCount; } PVRSRV_DEVICECLASS_BUFFER; typedef struct PVRSRV_CLIENT_DEVICECLASS_INFO_TAG { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDeviceKM; +#else IMG_HANDLE hDeviceKM; +#endif IMG_HANDLE hServices; } PVRSRV_CLIENT_DEVICECLASS_INFO; -#ifdef INLINE_IS_PRAGMA -#pragma inline(PVRSRVGetWriteOpsPending) -#endif -static INLINE -IMG_UINT32 PVRSRVGetWriteOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL bIsReadOp) +typedef enum { - IMG_UINT32 ui32WriteOpsPending; - - if(bIsReadOp) - { - ui32WriteOpsPending = psSyncInfo->psSyncData->ui32WriteOpsPending; - } - else - { - - - - ui32WriteOpsPending = psSyncInfo->psSyncData->ui32WriteOpsPending++; - } - - return ui32WriteOpsPending; + PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR, + PVRSRV_FREE_CALLBACK_ORIGIN_IMPORTER, + PVRSRV_FREE_CALLBACK_ORIGIN_EXTERNAL, } +PVRSRV_FREE_CALLBACK_ORIGIN; -#ifdef INLINE_IS_PRAGMA -#pragma inline(PVRSRVGetReadOpsPending) -#endif -static INLINE -IMG_UINT32 PVRSRVGetReadOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL bIsReadOp) -{ - IMG_UINT32 ui32ReadOpsPending; - if(bIsReadOp) - { - ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOpsPending++; - } - else - { - ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOpsPending; - } +IMG_IMPORT +PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, + IMG_UINT32 ui32Param, + PVRSRV_FREE_CALLBACK_ORIGIN eCallbackOrigin); - return ui32ReadOpsPending; -} IMG_IMPORT PVRSRV_ERROR PVRSRVQueueCommand(IMG_HANDLE hQueueInfo, @@ -252,7 +344,11 @@ PVRSRV_ERROR PVRSRVQueueCommand(IMG_HANDLE hQueueInfo, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMMUContextPDDevPAddr(const PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevMemContext, +#else IMG_HANDLE hDevMemContext, +#endif IMG_DEV_PHYADDR *sPDDevPAddr); IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV @@ -271,7 +367,11 @@ PVRSRVUnrefSharedSysMem(const PVRSRV_CONNECTION *psConnection, IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVMapMemInfoMem(const PVRSRV_CONNECTION *psConnection, +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo, +#else IMG_HANDLE hKernelMemInfo, +#endif PVRSRV_CLIENT_MEM_INFO **ppsClientMemInfo); diff --git a/drivers/gpu/pvr/sgx/bridged_sgx_bridge.c b/drivers/gpu/pvr/sgx/bridged_sgx_bridge.c index e1b7320..f616d83 100644 --- a/drivers/gpu/pvr/sgx/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/sgx/bridged_sgx_bridge.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -40,6 +40,7 @@ #include "power.h" #include "pvr_bridge_km.h" #include "sgx_bridge_km.h" +#include "sgx_options.h" #if defined(SUPPORT_MSVDX) #include "msvdx_bridge.h" @@ -48,6 +49,7 @@ #include "bridged_pvr_bridge.h" #include "bridged_sgx_bridge.h" #include "sgxutils.h" +#include "buffer_manager.h" #include "pdump_km.h" static IMG_INT @@ -61,7 +63,8 @@ SGXGetClientInfoBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_GETCLIENTINFO); psGetClientInfoOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDevCookieInt, psGetClientInfoIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psGetClientInfoOUT->eError != PVRSRV_OK) @@ -87,7 +90,8 @@ SGXReleaseClientInfoBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_RELEASECLIENTINFO); psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDevCookieInt, psReleaseClientInfoIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRetOUT->eError != PVRSRV_OK) @@ -99,8 +103,12 @@ SGXReleaseClientInfoBW(IMG_UINT32 ui32BridgeID, PVR_ASSERT(psDevInfo->ui32ClientRefCount > 0); - psDevInfo->ui32ClientRefCount--; - + + if (psDevInfo->ui32ClientRefCount > 0) + { + psDevInfo->ui32ClientRefCount--; + } + psRetOUT->eError = PVRSRV_OK; return 0; @@ -114,11 +122,15 @@ SGXGetInternalDevInfoBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hDevCookieInt; +#if defined (SUPPORT_SID_INTERFACE) + SGX_INTERNAL_DEVINFO_KM sSGXInternalDevInfo; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_GETINTERNALDEVINFO); psSGXGetInternalDevInfoOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDevCookieInt, psSGXGetInternalDevInfoIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psSGXGetInternalDevInfoOUT->eError != PVRSRV_OK) @@ -128,13 +140,21 @@ SGXGetInternalDevInfoBW(IMG_UINT32 ui32BridgeID, psSGXGetInternalDevInfoOUT->eError = SGXGetInternalDevInfoKM(hDevCookieInt, +#if defined (SUPPORT_SID_INTERFACE) + &sSGXInternalDevInfo); +#else &psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo); +#endif psSGXGetInternalDevInfoOUT->eError = PVRSRVAllocHandle(psPerProc->psHandleBase, &psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle, +#if defined (SUPPORT_SID_INTERFACE) + sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle, +#else psSGXGetInternalDevInfoOUT->sSGXInternalDevInfo.hHostCtlKernelMemInfoHandle, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO, PVRSRV_HANDLE_ALLOC_FLAG_SHARED); @@ -152,7 +172,12 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, IMG_UINT32 i; IMG_INT ret = 0; IMG_UINT32 ui32NumDstSyncs; +#if defined (SUPPORT_SID_INTERFACE) + SGX_CCB_KICK_KM sCCBKickKM = {{0}}; + IMG_HANDLE ahSyncInfoHandles[16]; +#else IMG_HANDLE *phKernelSyncInfoHandles = IMG_NULL; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DOKICK); @@ -169,7 +194,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.hCCBKernelMemInfo, +#else &psDoKickIN->sCCBKick.hCCBKernelMemInfo, +#endif psDoKickIN->sCCBKick.hCCBKernelMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); @@ -178,11 +207,24 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + if (psDoKickIN->sCCBKick.ui32NumDstSyncObjects > 16) + { + return 0; + } + + if(psDoKickIN->sCCBKick.hTA3DSyncInfo != 0) +#else if(psDoKickIN->sCCBKick.hTA3DSyncInfo != IMG_NULL) +#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.hTA3DSyncInfo, +#else &psDoKickIN->sCCBKick.hTA3DSyncInfo, +#endif psDoKickIN->sCCBKick.hTA3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -192,11 +234,19 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, } } +#if defined (SUPPORT_SID_INTERFACE) + if(psDoKickIN->sCCBKick.hTASyncInfo != 0) +#else if(psDoKickIN->sCCBKick.hTASyncInfo != IMG_NULL) +#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.hTASyncInfo, +#else &psDoKickIN->sCCBKick.hTASyncInfo, +#endif psDoKickIN->sCCBKick.hTASyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -206,11 +256,33 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, } } +#if defined(FIX_HW_BRN_31620) + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + &psDoKickIN->sCCBKick.hDevMemContext, + psDoKickIN->sCCBKick.hDevMemContext, + PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } +#endif + +#if defined (SUPPORT_SID_INTERFACE) + if(psDoKickIN->sCCBKick.h3DSyncInfo != 0) +#else if(psDoKickIN->sCCBKick.h3DSyncInfo != IMG_NULL) +#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.h3DSyncInfo, +#else &psDoKickIN->sCCBKick.h3DSyncInfo, +#endif psDoKickIN->sCCBKick.h3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -229,11 +301,18 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + sCCBKickKM.ui32NumTASrcSyncs = psDoKickIN->sCCBKick.ui32NumTASrcSyncs; +#endif for(i=0; i<psDoKickIN->sCCBKick.ui32NumTASrcSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.ahTASrcKernelSyncInfo[i], +#else &psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i], +#endif psDoKickIN->sCCBKick.ahTASrcKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -249,11 +328,18 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + sCCBKickKM.ui32NumTADstSyncs = psDoKickIN->sCCBKick.ui32NumTADstSyncs; +#endif for(i=0; i<psDoKickIN->sCCBKick.ui32NumTADstSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.ahTADstKernelSyncInfo[i], +#else &psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i], +#endif psDoKickIN->sCCBKick.ahTADstKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -269,11 +355,18 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + sCCBKickKM.ui32Num3DSrcSyncs = psDoKickIN->sCCBKick.ui32Num3DSrcSyncs; +#endif for(i=0; i<psDoKickIN->sCCBKick.ui32Num3DSrcSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.ah3DSrcKernelSyncInfo[i], +#else &psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i], +#endif psDoKickIN->sCCBKick.ah3DSrcKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -289,11 +382,19 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; return 0; } + +#if defined (SUPPORT_SID_INTERFACE) + sCCBKickKM.ui32NumSrcSyncs = psDoKickIN->sCCBKick.ui32NumSrcSyncs; +#endif for(i=0; i<psDoKickIN->sCCBKick.ui32NumSrcSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.ahSrcKernelSyncInfo[i], +#else &psDoKickIN->sCCBKick.ahSrcKernelSyncInfo[i], +#endif psDoKickIN->sCCBKick.ahSrcKernelSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -314,12 +415,25 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = #if defined(SUPPORT_SGX_NEW_STATUS_VALS) PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.asTAStatusUpdate[i].hKernelMemInfo, +#else &psDoKickIN->sCCBKick.asTAStatusUpdate[i].hKernelMemInfo, +#endif psDoKickIN->sCCBKick.asTAStatusUpdate[i].hKernelMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); + +#if defined (SUPPORT_SID_INTERFACE) + sCCBKickKM.asTAStatusUpdate[i].sCtlStatus = psDoKickIN->sCCBKick.asTAStatusUpdate[i].sCtlStatus; +#endif + #else PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.ahTAStatusSyncInfo[i], +#else &psDoKickIN->sCCBKick.ahTAStatusSyncInfo[i], +#endif psDoKickIN->sCCBKick.ahTAStatusSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); #endif @@ -339,12 +453,24 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = #if defined(SUPPORT_SGX_NEW_STATUS_VALS) PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.as3DStatusUpdate[i].hKernelMemInfo, +#else &psDoKickIN->sCCBKick.as3DStatusUpdate[i].hKernelMemInfo, +#endif psDoKickIN->sCCBKick.as3DStatusUpdate[i].hKernelMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); + +#if defined (SUPPORT_SID_INTERFACE) + sCCBKickKM.as3DStatusUpdate[i].sCtlStatus = psDoKickIN->sCCBKick.as3DStatusUpdate[i].sCtlStatus; +#endif #else PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.ah3DStatusSyncInfo[i], +#else &psDoKickIN->sCCBKick.ah3DStatusSyncInfo[i], +#endif psDoKickIN->sCCBKick.ah3DStatusSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); #endif @@ -378,6 +504,9 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + sCCBKickKM.pahDstSyncHandles = phKernelSyncInfoHandles; +#else if(CopyFromUserWrapper(psPerProc, ui32BridgeID, phKernelSyncInfoHandles, @@ -390,12 +519,17 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psDoKickIN->sCCBKick.pahDstSyncHandles = phKernelSyncInfoHandles; +#endif for( i = 0; i < ui32NumDstSyncs; i++) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.pahDstSyncHandles[i], +#else &psDoKickIN->sCCBKick.pahDstSyncHandles[i], +#endif psDoKickIN->sCCBKick.pahDstSyncHandles[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); @@ -408,7 +542,11 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM.hKernelHWSyncListMemInfo, +#else &psDoKickIN->sCCBKick.hKernelHWSyncListMemInfo, +#endif psDoKickIN->sCCBKick.hKernelHWSyncListMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); @@ -418,9 +556,34 @@ SGXDoKickBW(IMG_UINT32 ui32BridgeID, } } +#if defined (SUPPORT_SID_INTERFACE) + OSMemCopy(&sCCBKickKM.sCommand, &psDoKickIN->sCCBKick.sCommand, sizeof(sCCBKickKM.sCommand)); + + sCCBKickKM.ui32NumDstSyncObjects = psDoKickIN->sCCBKick.ui32NumDstSyncObjects; + sCCBKickKM.ui32NumTAStatusVals = psDoKickIN->sCCBKick.ui32NumTAStatusVals; + sCCBKickKM.ui32Num3DStatusVals = psDoKickIN->sCCBKick.ui32Num3DStatusVals; + sCCBKickKM.bFirstKickOrResume = psDoKickIN->sCCBKick.bFirstKickOrResume; + sCCBKickKM.ui32CCBOffset = psDoKickIN->sCCBKick.ui32CCBOffset; + sCCBKickKM.bTADependency = psDoKickIN->sCCBKick.bTADependency; + +#if (defined(NO_HARDWARE) || defined(PDUMP)) + sCCBKickKM.bTerminateOrAbort = psDoKickIN->sCCBKick.bTerminateOrAbort; +#endif +#if defined(PDUMP) + sCCBKickKM.ui32CCBDumpWOff = psDoKickIN->sCCBKick.ui32CCBDumpWOff; +#endif + +#if defined(NO_HARDWARE) + sCCBKickKM.ui32WriteOpsPendingVal = psDoKickIN->sCCBKick.ui32WriteOpsPendingVal; +#endif +#endif psRetOUT->eError = SGXDoKickKM(hDevCookieInt, +#if defined (SUPPORT_SID_INTERFACE) + &sCCBKickKM); +#else &psDoKickIN->sCCBKick); +#endif PVRSRV_BRIDGE_SGX_DOKICK_RETURN_RESULT: @@ -472,6 +635,9 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { IMG_HANDLE hDevCookieInt; PVRSRV_TRANSFER_SGX_KICK *psKick; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_TRANSFER_SGX_KICK_KM sKickKM = {0}; +#endif IMG_UINT32 i; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SUBMITTRANSFER); @@ -479,6 +645,20 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, psKick = &psSubmitTransferIN->sKick; +#if defined(FIX_HW_BRN_31620) + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + &psKick->hDevMemContext, + psKick->hDevMemContext, + PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } +#endif + psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, @@ -491,7 +671,11 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.hCCBMemInfo, +#else &psKick->hCCBMemInfo, +#endif psKick->hCCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -503,7 +687,11 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.hTASyncInfo, +#else &psKick->hTASyncInfo, +#endif psKick->hTASyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -516,7 +704,11 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.h3DSyncInfo, +#else &psKick->h3DSyncInfo, +#endif psKick->h3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -534,7 +726,11 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.ahSrcSyncInfo[i], +#else &psKick->ahSrcSyncInfo[i], +#endif psKick->ahSrcSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -552,7 +748,11 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.ahDstSyncInfo[i], +#else &psKick->ahDstSyncInfo[i], +#endif psKick->ahDstSyncInfo[i], PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -561,7 +761,21 @@ SGXSubmitTransferBW(IMG_UINT32 ui32BridgeID, } } +#if defined (SUPPORT_SID_INTERFACE) + sKickKM.sHWTransferContextDevVAddr = psKick->sHWTransferContextDevVAddr; + sKickKM.ui32SharedCmdCCBOffset = psKick->ui32SharedCmdCCBOffset; + sKickKM.ui32NumSrcSync = psKick->ui32NumSrcSync; + sKickKM.ui32NumDstSync = psKick->ui32NumDstSync; + sKickKM.ui32Flags = psKick->ui32Flags; + sKickKM.ui32PDumpFlags = psKick->ui32PDumpFlags; +#if defined(PDUMP) + sKickKM.ui32CCBDumpWOff = psKick->ui32CCBDumpWOff; +#endif + + psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, &sKickKM); +#else psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, psKick); +#endif return 0; } @@ -575,12 +789,32 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hDevCookieInt; - PVRSRV_2D_SGX_KICK *psKick; + PVRSRV_2D_SGX_KICK *psKick; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_2D_SGX_KICK_KM sKickKM; +#endif IMG_UINT32 i; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_SUBMIT2D); PVR_UNREFERENCED_PARAMETER(ui32BridgeID); + psKick = &psSubmit2DIN->sKick; + +#if defined(FIX_HW_BRN_31620) + + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + &psKick->hDevMemContext, + psKick->hDevMemContext, + PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } +#endif + + psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, @@ -592,11 +826,14 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } - psKick = &psSubmit2DIN->sKick; psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.hCCBMemInfo, +#else &psKick->hCCBMemInfo, +#endif psKick->hCCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -604,11 +841,19 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } +#if defined (SUPPORT_SID_INTERFACE) + if (psKick->hTASyncInfo != 0) +#else if (psKick->hTASyncInfo != IMG_NULL) +#endif { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.hTASyncInfo, +#else &psKick->hTASyncInfo, +#endif psKick->hTASyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -616,12 +861,22 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } +#if defined (SUPPORT_SID_INTERFACE) + else + { + sKickKM.hTASyncInfo = IMG_NULL; + } +#endif if (psKick->h3DSyncInfo != IMG_NULL) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.h3DSyncInfo, +#else &psKick->h3DSyncInfo, +#endif psKick->h3DSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -629,12 +884,39 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } +#if defined (SUPPORT_SID_INTERFACE) + else + { + sKickKM.h3DSyncInfo = IMG_NULL; + } +#endif if (psKick->ui32NumSrcSync > SGX_MAX_2D_SRC_SYNC_OPS) { psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; return 0; } +#if defined (SUPPORT_SID_INTERFACE) + for (i = 0; i < SGX_MAX_2D_SRC_SYNC_OPS; i++) + { + if (i < psKick->ui32NumSrcSync) + { + psRetOUT->eError = + PVRSRVLookupHandle(psPerProc->psHandleBase, + &sKickKM.ahSrcSyncInfo[i], + psKick->ahSrcSyncInfo[i], + PVRSRV_HANDLE_TYPE_SYNC_INFO); + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } + } + else + { + sKickKM.ahSrcSyncInfo[i] = IMG_NULL; + } + } +#else for (i = 0; i < psKick->ui32NumSrcSync; i++) { psRetOUT->eError = @@ -647,12 +929,17 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } +#endif if (psKick->hDstSyncInfo != IMG_NULL) { psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &sKickKM.hDstSyncInfo, +#else &psKick->hDstSyncInfo, +#endif psKick->hDstSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -660,9 +947,28 @@ SGXSubmit2DBW(IMG_UINT32 ui32BridgeID, return 0; } } +#if defined (SUPPORT_SID_INTERFACE) + else + { + sKickKM.hDstSyncInfo = IMG_NULL; + } + + + sKickKM.ui32SharedCmdCCBOffset = psKick->ui32SharedCmdCCBOffset; + sKickKM.ui32NumSrcSync = psKick->ui32NumSrcSync; + sKickKM.ui32PDumpFlags = psKick->ui32PDumpFlags; + sKickKM.sHW2DContextDevVAddr = psKick->sHW2DContextDevVAddr; +#if defined(PDUMP) + sKickKM.ui32CCBDumpWOff = psKick->ui32CCBDumpWOff; +#endif +#endif psRetOUT->eError = +#if defined (SUPPORT_SID_INTERFACE) + SGXSubmit2DKM(hDevCookieInt, &sKickKM); +#else SGXSubmit2DKM(hDevCookieInt, psKick); +#endif return 0; } @@ -767,7 +1073,7 @@ SGXReadHWPerfCBBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_READ_HWPERF_CB); - psSGXReadHWPerfCBOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + psSGXReadHWPerfCBOUT->eError =PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, psSGXReadHWPerfCBIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); @@ -814,31 +1120,41 @@ SGXReadHWPerfCBBW(IMG_UINT32 ui32BridgeID, static IMG_INT SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *psSGXDevInitPart2IN, - PVRSRV_BRIDGE_RETURN *psRetOUT, + PVRSRV_BRIDGE_OUT_SGXDEVINITPART2 *psSGXDevInitPart2OUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_HANDLE hDevCookieInt; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_ERROR eError = PVRSRV_OK; +#else PVRSRV_ERROR eError; +#endif IMG_BOOL bDissociateFailed = IMG_FALSE; IMG_BOOL bLookupFailed = IMG_FALSE; IMG_BOOL bReleaseFailed = IMG_FALSE; IMG_HANDLE hDummy; IMG_UINT32 i; +#if defined (SUPPORT_SID_INTERFACE) + SGX_BRIDGE_INIT_INFO_KM asInitInfoKM = {0}; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DEVINITPART2); + + psSGXDevInitPart2OUT->ui32KMBuildOptions = SGX_BUILD_OPTIONS; + if(!psPerProc->bInitProcess) { - psRetOUT->eError = PVRSRV_ERROR_PROCESS_NOT_INITIALISED; + psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_PROCESS_NOT_INITIALISED; return 0; } - psRetOUT->eError = + psSGXDevInitPart2OUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, psSGXDevInitPart2IN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); - if(psRetOUT->eError != PVRSRV_OK) + if(psSGXDevInitPart2OUT->eError != PVRSRV_OK) { return 0; } @@ -889,6 +1205,16 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bLookupFailed = IMG_TRUE; } +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } +#endif eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDummy, @@ -961,10 +1287,99 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } #endif -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) + +#if defined(FIX_HW_BRN_31542) eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDummy, - psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } +#endif + +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31425) + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } + + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bLookupFailed = IMG_TRUE; + } +#endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ + defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDummy, + psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) { @@ -972,10 +1387,10 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } #endif -#if defined(SGX_FEATURE_SPM_MODE_0) +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDummy, - psSGXDevInitPart2IN->sInitInfo.hKernelTmpDPMStateMemInfo, + psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) { @@ -985,9 +1400,17 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; +#else IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; +#endif +#if defined (SUPPORT_SID_INTERFACE) + if (hHandle == 0) +#else if (hHandle == IMG_NULL) +#endif { continue; } @@ -1005,13 +1428,17 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, if (bLookupFailed) { PVR_DPF((PVR_DBG_ERROR, "DevInitSGXPart2BW: A handle lookup failed")); - psRetOUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED; + psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED; return 0; } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelCCBMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1020,7 +1447,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelCCBCtlMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1029,7 +1460,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelCCBEventKickerMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1039,7 +1474,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelSGXHostCtlMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1048,7 +1487,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelSGXTA3DCtlMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1056,8 +1499,27 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, bReleaseFailed = IMG_TRUE; } +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } +#endif + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelSGXMiscMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1066,9 +1528,13 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } - #if defined(SGX_SUPPORT_HWPROFILING) +#if defined(SGX_SUPPORT_HWPROFILING) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelHWProfilingMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1079,7 +1545,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(SUPPORT_SGX_HWPERF) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelHWPerfCBMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1089,7 +1559,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #endif eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelTASigBufferMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1098,7 +1572,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernel3DSigBufferMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1108,7 +1586,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(FIX_HW_BRN_29702) eError = PVRSRVLookupHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelCFIMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1119,7 +1601,11 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(FIX_HW_BRN_29823) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelDummyTermStreamMemInfo, +#else &psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo, +#endif psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) @@ -1128,21 +1614,129 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } #endif -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) + +#if defined(FIX_HW_BRN_31542) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, - &psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, - psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWAVDMStreamMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWAIndexStreamMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) { bReleaseFailed = IMG_TRUE; } + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWAPDSMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo, #endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWAUSEMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWAParamMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWAPMPTMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWATPCMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelClearClipWAPSGRgnHdrMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } +#endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31425) + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, + &psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo, + psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } -#if defined(SGX_FEATURE_SPM_MODE_0) eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, - &psSGXDevInitPart2IN->sInitInfo.hKernelTmpDPMStateMemInfo, - psSGXDevInitPart2IN->sInitInfo.hKernelTmpDPMStateMemInfo, + &psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo, + psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } +#endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ + defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, + &psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo, + psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo, PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) { @@ -1150,17 +1744,43 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, } #endif +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + &asInitInfoKM.hKernelEDMStatusBufferMemInfo, +#else + &psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, +#endif + psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo, + PVRSRV_HANDLE_TYPE_MEM_INFO); + if (eError != PVRSRV_OK) + { + bReleaseFailed = IMG_TRUE; + } +#endif for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; + IMG_HANDLE *phHandleKM = &asInitInfoKM.asInitMemHandles[i]; + + if (hHandle == 0) +#else IMG_HANDLE *phHandle = &psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; if (*phHandle == IMG_NULL) +#endif continue; eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, +#if defined (SUPPORT_SID_INTERFACE) + phHandleKM, + hHandle, +#else phHandle, *phHandle, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if (eError != PVRSRV_OK) { @@ -1171,45 +1791,81 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, if (bReleaseFailed) { PVR_DPF((PVR_DBG_ERROR, "DevInitSGXPart2BW: A handle release failed")); - psRetOUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED; + psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED; PVR_DBG_BREAK; return 0; } +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBCtlMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBEventKickerMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBEventKickerMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXHostCtlMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXTA3DCtlMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo); +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo); +#endif + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#endif + +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXMiscMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; @@ -1217,56 +1873,192 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, #if defined(SGX_SUPPORT_HWPROFILING) +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelHWProfilingMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelHWProfilingMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); #endif +#endif #if defined(SUPPORT_SGX_HWPERF) +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelHWPerfCBMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelHWPerfCBMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } #endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelTASigBufferMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelTASigBufferMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernel3DSigBufferMemInfo); +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernel3DSigBufferMemInfo); +#endif if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } #if defined(FIX_HW_BRN_29702) +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCFIMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCFIMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); #endif +#endif #if defined(FIX_HW_BRN_29823) +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelDummyTermStreamMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelDummyTermStreamMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); #endif +#endif -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo); +#if defined(FIX_HW_BRN_31542) +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAVDMStreamMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAVDMStreamMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAIndexStreamMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAIndexStreamMemInfo); bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); #endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPDSMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPDSMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAUSEMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAUSEMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAParamMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAParamMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPMPTMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPMPTMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWATPCMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWATPCMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelClearClipWAPSGRgnHdrMemInfo); + if (eError != PVRSRV_OK) + { + bDissociateFailed = IMG_TRUE; + } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelClearClipWAPSGRgnHdrMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#endif -#if defined(SGX_FEATURE_SPM_MODE_0) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelTmpDPMStateMemInfo); +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31425) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMSnapShotBufferMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); + + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMCtrlStreamBufferMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ + defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelVDMStateUpdateBufferMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif + +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) +#if defined (SUPPORT_SID_INTERFACE) + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelEDMStatusBufferMemInfo); if (eError != PVRSRV_OK) { bDissociateFailed = IMG_TRUE; } +#else + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo); + bDissociateFailed |= (IMG_BOOL)(eError != PVRSRV_OK); +#endif #endif for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_HANDLE hHandle = asInitInfoKM.asInitMemHandles[i]; +#else IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; +#endif if (hHandle == IMG_NULL) continue; @@ -1281,17 +2073,37 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, if(bDissociateFailed) { +#if defined (SUPPORT_SID_INTERFACE) + PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBMemInfo); + PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelCCBCtlMemInfo); + PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXHostCtlMemInfo); + PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXTA3DCtlMemInfo); +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXPTLAWriteBackMemInfo); +#endif + PVRSRVFreeDeviceMemKM(hDevCookieInt, asInitInfoKM.hKernelSGXMiscMemInfo); +#else PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBMemInfo); PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelCCBCtlMemInfo); PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXHostCtlMemInfo); PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXTA3DCtlMemInfo); +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXPTLAWriteBackMemInfo); +#endif PVRSRVFreeDeviceMemKM(hDevCookieInt, psSGXDevInitPart2IN->sInitInfo.hKernelSGXMiscMemInfo); +#endif for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_HANDLE hHandle = asInitInfoKM.asInitMemHandles[i]; + + if (hHandle == 0) +#else IMG_HANDLE hHandle = psSGXDevInitPart2IN->sInitInfo.asInitMemHandles[i]; if (hHandle == IMG_NULL) +#endif continue; PVRSRVFreeDeviceMemKM(hDevCookieInt, (PVRSRV_KERNEL_MEM_INFO *)hHandle); @@ -1300,17 +2112,40 @@ SGXDevInitPart2BW(IMG_UINT32 ui32BridgeID, PVR_DPF((PVR_DBG_ERROR, "DevInitSGXPart2BW: A dissociate failed")); - psRetOUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED; + psSGXDevInitPart2OUT->eError = PVRSRV_ERROR_INIT2_PHASE_FAILED; PVR_DBG_BREAK; return 0; } - psRetOUT->eError = +#if defined (SUPPORT_SID_INTERFACE) + asInitInfoKM.sScripts = psSGXDevInitPart2IN->sInitInfo.sScripts; + asInitInfoKM.ui32ClientBuildOptions = psSGXDevInitPart2IN->sInitInfo.ui32ClientBuildOptions; + asInitInfoKM.sSGXStructSizes = psSGXDevInitPart2IN->sInitInfo.sSGXStructSizes; + asInitInfoKM.ui32CacheControl = psSGXDevInitPart2IN->sInitInfo.ui32CacheControl; + asInitInfoKM.ui32EDMTaskReg0 = psSGXDevInitPart2IN->sInitInfo.ui32EDMTaskReg0; + asInitInfoKM.ui32EDMTaskReg1 = psSGXDevInitPart2IN->sInitInfo.ui32EDMTaskReg1; + asInitInfoKM.ui32ClkGateStatusReg = psSGXDevInitPart2IN->sInitInfo.ui32ClkGateStatusReg; + asInitInfoKM.ui32ClkGateStatusMask = psSGXDevInitPart2IN->sInitInfo.ui32ClkGateStatusMask; + + OSMemCopy(&asInitInfoKM.asInitDevData , + &psSGXDevInitPart2IN->sInitInfo.asInitDevData, + sizeof(asInitInfoKM.asInitDevData)); + OSMemCopy(&asInitInfoKM.aui32HostKickAddr, + &psSGXDevInitPart2IN->sInitInfo.aui32HostKickAddr, + sizeof(asInitInfoKM.aui32HostKickAddr)); + + psSGXDevInitPart2OUT->eError = + DevInitSGXPart2KM(psPerProc, + hDevCookieInt, + &asInitInfoKM); +#else + psSGXDevInitPart2OUT->eError = DevInitSGXPart2KM(psPerProc, hDevCookieInt, &psSGXDevInitPart2IN->sInitInfo); +#endif return 0; } @@ -1382,7 +2217,8 @@ SGXUnregisterHWRenderContextBW(IMG_UINT32 ui32BridgeID, return 0; } - psRetOUT->eError = SGXUnregisterHWRenderContextKM(hHWRenderContextInt); + psRetOUT->eError = SGXUnregisterHWRenderContextKM(hHWRenderContextInt, + psSGXUnregHWRenderContextIN->bForceCleanup); if(psRetOUT->eError != PVRSRV_OK) { return 0; @@ -1449,7 +2285,11 @@ SGXUnregisterHWTransferContextBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_RETURN *psRetOUT, PVRSRV_PER_PROCESS_DATA *psPerProc) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_HANDLE hHWTransferContextInt = 0; +#else IMG_HANDLE hHWTransferContextInt; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_UNREGISTER_HW_TRANSFER_CONTEXT); @@ -1463,7 +2303,8 @@ SGXUnregisterHWTransferContextBW(IMG_UINT32 ui32BridgeID, return 0; } - psRetOUT->eError = SGXUnregisterHWTransferContextKM(hHWTransferContextInt); + psRetOUT->eError = SGXUnregisterHWTransferContextKM(hHWTransferContextInt, + psSGXUnregHWTransferContextIN->bForceCleanup); if(psRetOUT->eError != PVRSRV_OK) { return 0; @@ -1545,7 +2386,8 @@ SGXUnregisterHW2DContextBW(IMG_UINT32 ui32BridgeID, return 0; } - psRetOUT->eError = SGXUnregisterHW2DContextKM(hHW2DContextInt); + psRetOUT->eError = SGXUnregisterHW2DContextKM(hHW2DContextInt, + psSGXUnregHW2DContextIN->bForceCleanup); if(psRetOUT->eError != PVRSRV_OK) { return 0; @@ -1579,7 +2421,7 @@ SGXFlushHWRenderTargetBW(IMG_UINT32 ui32BridgeID, return 0; } - SGXFlushHWRenderTargetKM(hDevCookieInt, psSGXFlushHWRenderTargetIN->sHWRTDataSetDevVAddr); + psRetOUT->eError = SGXFlushHWRenderTargetKM(hDevCookieInt, psSGXFlushHWRenderTargetIN->sHWRTDataSetDevVAddr, IMG_FALSE); return 0; } @@ -1598,7 +2440,8 @@ SGX2DQueryBlitsCompleteBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_2DQUERYBLTSCOMPLETE); psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &hDevCookieInt, ps2DQueryBltsCompleteIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRetOUT->eError != PVRSRV_OK) @@ -1607,7 +2450,8 @@ SGX2DQueryBlitsCompleteBW(IMG_UINT32 ui32BridgeID, } psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, &pvSyncInfo, + PVRSRVLookupHandle(psPerProc->psHandleBase, + &pvSyncInfo, ps2DQueryBltsCompleteIN->hKernSyncInfo, PVRSRV_HANDLE_TYPE_SYNC_INFO); if(psRetOUT->eError != PVRSRV_OK) @@ -1808,7 +2652,11 @@ SGXAddSharedPBDescBW(IMG_UINT32 ui32BridgeID, IMG_UINT32 ui32KernelMemInfoHandlesCount = psSGXAddSharedPBDescIN->ui32KernelMemInfoHandlesCount; IMG_INT ret = 0; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *phKernelMemInfoHandles = 0; +#else IMG_HANDLE *phKernelMemInfoHandles = IMG_NULL; +#endif PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfos = IMG_NULL; IMG_UINT32 i; PVRSRV_ERROR eError; @@ -1964,7 +2812,8 @@ SGXAddSharedPBDescBW(IMG_UINT32 ui32BridgeID, psSGXAddSharedPBDescIN->ui32TotalPBSize, &hSharedPBDesc, ppsKernelMemInfos, - ui32KernelMemInfoHandlesCount); + ui32KernelMemInfoHandlesCount, + psSGXAddSharedPBDescIN->sHWPBDescDevVAddr); if (eError != PVRSRV_OK) @@ -2013,6 +2862,9 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, { IMG_HANDLE hDevCookieInt; IMG_UINT32 i; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM asHeapInfo[PVRSRV_MAX_CLIENT_HEAPS]; +#endif PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGXINFO_FOR_SRVINIT); NEW_HANDLE_BATCH_OR_ERROR(psSGXInfoForSrvinitOUT->eError, psPerProc, PVRSRV_MAX_CLIENT_HEAPS); @@ -2035,7 +2887,12 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, psSGXInfoForSrvinitOUT->eError = SGXGetInfoForSrvinitKM(hDevCookieInt, +#if defined (SUPPORT_SID_INTERFACE) + &asHeapInfo[0], + &psSGXInfoForSrvinitOUT->sInitInfo.sPDDevPAddr); +#else &psSGXInfoForSrvinitOUT->sInitInfo); +#endif if(psSGXInfoForSrvinitOUT->eError != PVRSRV_OK) { @@ -2048,6 +2905,28 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, psHeapInfo = &psSGXInfoForSrvinitOUT->sInitInfo.asHeapInfo[i]; +#if defined (SUPPORT_SID_INTERFACE) + if ((asHeapInfo[i].ui32HeapID != (IMG_UINT32)SGX_UNDEFINED_HEAP_ID) && + (asHeapInfo[i].hDevMemHeap != IMG_NULL)) + { + + PVRSRVAllocHandleNR(psPerProc->psHandleBase, + &psHeapInfo->hDevMemHeap, + asHeapInfo[i].hDevMemHeap, + PVRSRV_HANDLE_TYPE_DEV_MEM_HEAP, + PVRSRV_HANDLE_ALLOC_FLAG_SHARED); + } + else + { + psHeapInfo->hDevMemHeap = 0; + } + + psHeapInfo->ui32HeapID = asHeapInfo[i].ui32HeapID; + psHeapInfo->sDevVAddrBase = asHeapInfo[i].sDevVAddrBase; + psHeapInfo->ui32HeapByteSize = asHeapInfo[i].ui32HeapByteSize; + psHeapInfo->ui32Attribs = asHeapInfo[i].ui32Attribs; + psHeapInfo->ui32XTileStride = asHeapInfo[i].ui32XTileStride; +#else if (psHeapInfo->ui32HeapID != (IMG_UINT32)SGX_UNDEFINED_HEAP_ID) { IMG_HANDLE hDevMemHeapExt; @@ -2063,6 +2942,7 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, psHeapInfo->hDevMemHeap = hDevMemHeapExt; } } +#endif } COMMIT_HANDLE_BATCH_OR_ERROR(psSGXInfoForSrvinitOUT->eError, psPerProc); @@ -2072,17 +2952,25 @@ SGXGetInfoForSrvinitBW(IMG_UINT32 ui32BridgeID, #if defined(PDUMP) static IMG_VOID -DumpBufferArray(PVRSRV_PER_PROCESS_DATA *psPerProc, +DumpBufferArray(PVRSRV_PER_PROCESS_DATA *psPerProc, +#if defined (SUPPORT_SID_INTERFACE) + PSGX_KICKTA_DUMP_BUFFER_KM psBufferArray, +#else PSGX_KICKTA_DUMP_BUFFER psBufferArray, - IMG_UINT32 ui32BufferArrayLength, - IMG_BOOL bDumpPolls) +#endif + IMG_UINT32 ui32BufferArrayLength, + IMG_BOOL bDumpPolls) { IMG_UINT32 i; for (i=0; i<ui32BufferArrayLength; i++) { +#if defined (SUPPORT_SID_INTERFACE) + PSGX_KICKTA_DUMP_BUFFER_KM psBuffer; +#else PSGX_KICKTA_DUMP_BUFFER psBuffer; - PVRSRV_KERNEL_MEM_INFO *psCtrlMemInfoKM; +#endif + PVRSRV_KERNEL_MEM_INFO *psCtrlMemInfoKM; IMG_CHAR * pszName; IMG_HANDLE hUniqueTag; IMG_UINT32 ui32Offset; @@ -2191,7 +3079,12 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { IMG_UINT32 i; +#if defined (SUPPORT_SID_INTERFACE) + SGX_KICKTA_DUMP_BUFFER *psUMPtr; + SGX_KICKTA_DUMP_BUFFER_KM *psKickTADumpBufferKM, *psKMPtr; +#else SGX_KICKTA_DUMP_BUFFER *psKickTADumpBuffer; +#endif IMG_UINT32 ui32BufferArrayLength = psPDumpBufferArrayIN->ui32BufferArrayLength; IMG_UINT32 ui32BufferArraySize = @@ -2202,14 +3095,22 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY); +#if defined (SUPPORT_SID_INTERFACE) + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + ui32BufferArraySize, + (IMG_PVOID *)&psKickTADumpBufferKM, 0, + "Array of Kick Tile Accelerator Dump Buffer") != PVRSRV_OK) +#else if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, (IMG_PVOID *)&psKickTADumpBuffer, 0, "Array of Kick Tile Accelerator Dump Buffer") != PVRSRV_OK) +#endif { return -ENOMEM; } +#if !defined (SUPPORT_SID_INTERFACE) if(CopyFromUserWrapper(psPerProc, ui32BridgeID, psKickTADumpBuffer, @@ -2220,14 +3121,25 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, return -EFAULT; } +#endif for(i = 0; i < ui32BufferArrayLength; i++) { +#if defined (SUPPORT_SID_INTERFACE) + IMG_VOID *pvMemInfo = IMG_NULL; + psUMPtr = &psPDumpBufferArrayIN->psBufferArray[i]; + psKMPtr = &psKickTADumpBufferKM[i]; +#else IMG_VOID *pvMemInfo; +#endif eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psUMPtr->hKernelMemInfo, +#else psKickTADumpBuffer[i].hKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(eError != PVRSRV_OK) @@ -2236,12 +3148,20 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, "PVRSRVLookupHandle failed (%d)", eError)); break; } +#if defined (SUPPORT_SID_INTERFACE) + psKMPtr->hKernelMemInfo = pvMemInfo; +#else psKickTADumpBuffer[i].hKernelMemInfo = pvMemInfo; +#endif #if defined(SUPPORT_SGX_NEW_STATUS_VALS) eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &pvMemInfo, +#if defined (SUPPORT_SID_INTERFACE) + psUMPtr->hCtrlKernelMemInfo, +#else psKickTADumpBuffer[i].hCtrlKernelMemInfo, +#endif PVRSRV_HANDLE_TYPE_MEM_INFO); if(eError != PVRSRV_OK) @@ -2250,19 +3170,43 @@ SGXPDumpBufferArrayBW(IMG_UINT32 ui32BridgeID, "PVRSRVLookupHandle failed (%d)", eError)); break; } +#if defined (SUPPORT_SID_INTERFACE) + psKMPtr->hCtrlKernelMemInfo = pvMemInfo; + psKMPtr->sCtrlDevVAddr = psUMPtr->sCtrlDevVAddr; +#else psKickTADumpBuffer[i].hCtrlKernelMemInfo = pvMemInfo; #endif +#endif + +#if defined (SUPPORT_SID_INTERFACE) + psKMPtr->ui32SpaceUsed = psUMPtr->ui32SpaceUsed; + psKMPtr->ui32Start = psUMPtr->ui32Start; + psKMPtr->ui32End = psUMPtr->ui32End; + psKMPtr->ui32BufferSize = psUMPtr->ui32BufferSize; + psKMPtr->ui32BackEndLength = psUMPtr->ui32BackEndLength; + psKMPtr->uiAllocIndex = psUMPtr->uiAllocIndex; + psKMPtr->pvLinAddr = psUMPtr->pvLinAddr; + psKMPtr->pszName = psUMPtr->pszName; +#endif } if(eError == PVRSRV_OK) { DumpBufferArray(psPerProc, +#if defined (SUPPORT_SID_INTERFACE) + psKickTADumpBufferKM, +#else psKickTADumpBuffer, +#endif ui32BufferArrayLength, psPDumpBufferArrayIN->bDumpPolls); } +#if defined (SUPPORT_SID_INTERFACE) + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBufferKM, 0); +#else OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32BufferArraySize, psKickTADumpBuffer, 0); +#endif return 0; @@ -2276,11 +3220,13 @@ SGXPDump3DSignatureRegistersBW(IMG_UINT32 ui32BridgeID, { IMG_UINT32 ui32RegisterArraySize = psPDump3DSignatureRegistersIN->ui32NumRegisters * sizeof(IMG_UINT32); IMG_UINT32 *pui32Registers = IMG_NULL; - PVRSRV_SGXDEV_INFO *psDevInfo = IMG_NULL; + PVRSRV_SGXDEV_INFO *psDevInfo; #if defined(SGX_FEATURE_MP) && defined(FIX_HW_BRN_27270) IMG_UINT32 ui32RegVal = 0; #endif PVRSRV_DEVICE_NODE *psDeviceNode; + IMG_HANDLE hDevMemContextInt = 0; + IMG_UINT32 ui32MMUContextID; IMG_INT ret = -EFAULT; PVR_UNREFERENCED_PARAMETER(psRetOUT); @@ -2293,7 +3239,8 @@ SGXPDump3DSignatureRegistersBW(IMG_UINT32 ui32BridgeID, } psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID**)&psDeviceNode, + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID**)&psDeviceNode, psPDump3DSignatureRegistersIN->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRetOUT->eError != PVRSRV_OK) @@ -2339,17 +3286,33 @@ SGXPDump3DSignatureRegistersBW(IMG_UINT32 ui32BridgeID, pui32Registers, psPDump3DSignatureRegistersIN->ui32NumRegisters); + psRetOUT->eError = + PVRSRVLookupHandle( psPerProc->psHandleBase, + &hDevMemContextInt, + psPDump3DSignatureRegistersIN->hDevMemContext, + PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } + + + PVR_ASSERT(psDeviceNode->pfnMMUGetContextID != IMG_NULL) + ui32MMUContextID = psDeviceNode->pfnMMUGetContextID((IMG_HANDLE)psDeviceNode->sDevMemoryInfo.pBMKernelContext); + PDumpSignatureBuffer(&psDeviceNode->sDevId, - "out.tasig", "TA", 0, + "out.tasig", "TA", 0, psDevInfo->psKernelTASigBufferMemInfo->sDevVAddr, - psDevInfo->psKernelTASigBufferMemInfo->ui32AllocSize, + (IMG_UINT32)psDevInfo->psKernelTASigBufferMemInfo->uAllocSize, + ui32MMUContextID, 0 ); PDumpSignatureBuffer(&psDeviceNode->sDevId, - "out.3dsig", "3D", 0, + "out.3dsig", "3D", 0, psDevInfo->psKernel3DSigBufferMemInfo->sDevVAddr, - psDevInfo->psKernel3DSigBufferMemInfo->ui32AllocSize, + (IMG_UINT32)psDevInfo->psKernel3DSigBufferMemInfo->uAllocSize, + ui32MMUContextID, 0 ); - + ExitNoError: psRetOUT->eError = PVRSRV_OK; ret = 0; @@ -2381,7 +3344,7 @@ SGXPDumpCounterRegistersBW(IMG_UINT32 ui32BridgeID, { IMG_UINT32 ui32RegisterArraySize = psPDumpCounterRegistersIN->ui32NumRegisters * sizeof(IMG_UINT32); IMG_UINT32 *pui32Registers = IMG_NULL; - PVRSRV_DEVICE_NODE *psDeviceNode; + PVRSRV_DEVICE_NODE *psDeviceNode ; IMG_INT ret = -EFAULT; PVR_UNREFERENCED_PARAMETER(psBridgeOut); @@ -2393,9 +3356,10 @@ SGXPDumpCounterRegistersBW(IMG_UINT32 ui32BridgeID, goto ExitNoError; } - if(PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID**)&psDeviceNode, - psPDumpCounterRegistersIN->hDevCookie, - PVRSRV_HANDLE_TYPE_DEV_NODE) != PVRSRV_OK) + if(PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID**)&psDeviceNode, + psPDumpCounterRegistersIN->hDevCookie, + PVRSRV_HANDLE_TYPE_DEV_NODE) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "SGXPDumpCounterRegistersBW: hDevCookie lookup failed")); ret = -ENOMEM; @@ -2545,6 +3509,8 @@ SGXPDumpHWPerfCBBW(IMG_UINT32 ui32BridgeID, #if defined(__linux__) PVRSRV_SGXDEV_INFO *psDevInfo; PVRSRV_DEVICE_NODE *psDeviceNode; + IMG_HANDLE hDevMemContextInt = 0; + IMG_UINT32 ui32MMUContextID = 0; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_HWPERFCB); @@ -2559,11 +3525,26 @@ SGXPDumpHWPerfCBBW(IMG_UINT32 ui32BridgeID, psDevInfo = psDeviceNode->pvDevice; + psRetOUT->eError = + PVRSRVLookupHandle( psPerProc->psHandleBase, + &hDevMemContextInt, + psPDumpHWPerfCBIN->hDevMemContext, + PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } + + + PVR_ASSERT(psDeviceNode->pfnMMUGetContextID != IMG_NULL) + ui32MMUContextID = psDeviceNode->pfnMMUGetContextID(hDevMemContextInt); + PDumpHWPerfCBKM(&psDeviceNode->sDevId, &psPDumpHWPerfCBIN->szFileName[0], psPDumpHWPerfCBIN->ui32FileOffset, psDevInfo->psKernelHWPerfCBMemInfo->sDevVAddr, - psDevInfo->psKernelHWPerfCBMemInfo->ui32AllocSize, + psDevInfo->psKernelHWPerfCBMemInfo->uAllocSize, + ui32MMUContextID, psPDumpHWPerfCBIN->ui32PDumpFlags); return 0; @@ -2591,11 +3572,14 @@ SGXPDumpSaveMemBW(IMG_UINT32 ui32BridgeID, PVRSRV_PER_PROCESS_DATA *psPerProc) { PVRSRV_DEVICE_NODE *psDeviceNode; + IMG_HANDLE hDevMemContextInt = 0; + IMG_UINT32 ui32MMUContextID; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_PDUMP_SAVEMEM); psRetOUT->eError = - PVRSRVLookupHandle(psPerProc->psHandleBase, (IMG_VOID**)&psDeviceNode, + PVRSRVLookupHandle(psPerProc->psHandleBase, + (IMG_VOID**)&psDeviceNode, psPDumpSaveMem->hDevCookie, PVRSRV_HANDLE_TYPE_DEV_NODE); if(psRetOUT->eError != PVRSRV_OK) @@ -2603,12 +3587,26 @@ SGXPDumpSaveMemBW(IMG_UINT32 ui32BridgeID, return 0; } + psRetOUT->eError = + PVRSRVLookupHandle( psPerProc->psHandleBase, + &hDevMemContextInt, + psPDumpSaveMem->hDevMemContext, + PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + if(psRetOUT->eError != PVRSRV_OK) + { + return 0; + } + + + PVR_ASSERT(psDeviceNode->pfnMMUGetContextID != IMG_NULL) + ui32MMUContextID = psDeviceNode->pfnMMUGetContextID(hDevMemContextInt); + PDumpSaveMemKM(&psDeviceNode->sDevId, &psPDumpSaveMem->szFileName[0], psPDumpSaveMem->ui32FileOffset, psPDumpSaveMem->sDevVAddr, psPDumpSaveMem->ui32Size, - psPDumpSaveMem->ui32DataMaster, + ui32MMUContextID, psPDumpSaveMem->ui32PDumpFlags); return 0; } @@ -2616,7 +3614,7 @@ SGXPDumpSaveMemBW(IMG_UINT32 ui32BridgeID, #endif - + IMG_VOID SetSGXDispatchTableEntry(IMG_VOID) { diff --git a/drivers/gpu/pvr/sgx/bridged_sgx_bridge.h b/drivers/gpu/pvr/sgx/bridged_sgx_bridge.h index de6cfd1..204450c 100644 --- a/drivers/gpu/pvr/sgx/bridged_sgx_bridge.h +++ b/drivers/gpu/pvr/sgx/bridged_sgx_bridge.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/sgx/mmu.c b/drivers/gpu/pvr/sgx/mmu.c index e7d19fe..fbda31c 100644 --- a/drivers/gpu/pvr/sgx/mmu.c +++ b/drivers/gpu/pvr/sgx/mmu.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -37,16 +37,51 @@ #include "mmu.h" #include "sgxconfig.h" #include "sgx_bridge_km.h" +#include "pdump_osfunc.h" #define UINT32_MAX_VALUE 0xFFFFFFFFUL #define SGX_MAX_PD_ENTRIES (1<<(SGX_FEATURE_ADDRESS_SPACE_SIZE - SGX_MMU_PT_SHIFT - SGX_MMU_PAGE_SHIFT)) +#if defined(FIX_HW_BRN_31620) +#define SGX_MMU_PDE_DUMMY_PAGE (0) +#define SGX_MMU_PTE_DUMMY_PAGE (0) + +#define BRN31620_PT_ADDRESS_RANGE_SHIFT 22 +#define BRN31620_PT_ADDRESS_RANGE_SIZE (1 << BRN31620_PT_ADDRESS_RANGE_SHIFT) + +#define BRN31620_PDE_CACHE_FILL_SHIFT 26 +#define BRN31620_PDE_CACHE_FILL_SIZE (1 << BRN31620_PDE_CACHE_FILL_SHIFT) +#define BRN31620_PDE_CACHE_FILL_MASK (BRN31620_PDE_CACHE_FILL_SIZE - 1) + +#define BRN31620_PDES_PER_CACHE_LINE_SHIFT (BRN31620_PDE_CACHE_FILL_SHIFT - BRN31620_PT_ADDRESS_RANGE_SHIFT) +#define BRN31620_PDES_PER_CACHE_LINE_SIZE (1 << BRN31620_PDES_PER_CACHE_LINE_SHIFT) +#define BRN31620_PDES_PER_CACHE_LINE_MASK (BRN31620_PDES_PER_CACHE_LINE_SIZE - 1) + +#define BRN31620_DUMMY_PAGE_OFFSET (1 * SGX_MMU_PAGE_SIZE) +#define BRN31620_DUMMY_PDE_INDEX (BRN31620_DUMMY_PAGE_OFFSET / BRN31620_PT_ADDRESS_RANGE_SIZE) +#define BRN31620_DUMMY_PTE_INDEX ((BRN31620_DUMMY_PAGE_OFFSET - (BRN31620_DUMMY_PDE_INDEX * BRN31620_PT_ADDRESS_RANGE_SIZE))/SGX_MMU_PAGE_SIZE) + +#define BRN31620_CACHE_FLUSH_SHIFT (32 - BRN31620_PDE_CACHE_FILL_SHIFT) +#define BRN31620_CACHE_FLUSH_SIZE (1 << BRN31620_CACHE_FLUSH_SHIFT) + +#define BRN31620_CACHE_FLUSH_BITS_SHIFT 5 +#define BRN31620_CACHE_FLUSH_BITS_SIZE (1 << BRN31620_CACHE_FLUSH_BITS_SHIFT) +#define BRN31620_CACHE_FLUSH_BITS_MASK (BRN31620_CACHE_FLUSH_BITS_SIZE - 1) + +#define BRN31620_CACHE_FLUSH_INDEX_BITS (BRN31620_CACHE_FLUSH_SHIFT - BRN31620_CACHE_FLUSH_BITS_SHIFT) +#define BRN31620_CACHE_FLUSH_INDEX_SIZE (1 << BRN31620_CACHE_FLUSH_INDEX_BITS) + +#define BRN31620_DUMMY_PAGE_SIGNATURE 0xFEEBEE01 +#endif + typedef struct _MMU_PT_INFO_ { IMG_VOID *hPTPageOSMemHandle; IMG_CPU_VIRTADDR PTPageCpuVAddr; + + IMG_UINT32 ui32ValidPTECount; } MMU_PT_INFO; @@ -73,6 +108,11 @@ struct _MMU_CONTEXT_ #endif #endif +#if defined (FIX_HW_BRN_31620) + IMG_UINT32 ui32PDChangeMask[BRN31620_CACHE_FLUSH_INDEX_SIZE]; + IMG_UINT32 ui32PDCacheRangeRefCount[BRN31620_CACHE_FLUSH_SIZE]; + MMU_PT_INFO *apsPTInfoListSave[SGX_MAX_PD_ENTRIES]; +#endif struct _MMU_CONTEXT_ *psNext; }; @@ -88,7 +128,7 @@ struct _MMU_HEAP_ IMG_UINT32 ui32PageTableCount; - IMG_UINT32 ui32PTETotal; + IMG_UINT32 ui32PTETotalUsable; IMG_UINT32 ui32PDEPageSizeCtrl; @@ -112,7 +152,9 @@ struct _MMU_HEAP_ IMG_UINT32 ui32PTSize; - IMG_UINT32 ui32PTECount; + IMG_UINT32 ui32PTNumEntriesAllocated; + + IMG_UINT32 ui32PTNumEntriesUsable; @@ -138,6 +180,9 @@ struct _MMU_HEAP_ #define DUMMY_DATA_PAGE_SIGNATURE 0xDEADBEEF #endif +static IMG_VOID +_DeferredFreePageTable (MMU_HEAP *pMMUHeap, IMG_UINT32 ui32PTIndex, IMG_BOOL bOSFreePT); + #if defined(PDUMP) static IMG_VOID MMU_PDumpPageTables (MMU_HEAP *pMMUHeap, @@ -285,6 +330,105 @@ static IMG_VOID MMU_InvalidatePageTableCache(PVRSRV_SGXDEV_INFO *psDevInfo) #endif } +#if defined(FIX_HW_BRN_31620) +static IMG_VOID BRN31620InvalidatePageTableEntry(MMU_CONTEXT *psMMUContext, IMG_UINT32 ui32PDIndex, IMG_UINT32 ui32PTIndex, IMG_UINT32 *pui32PTE) +{ + PVRSRV_SGXDEV_INFO *psDevInfo = psMMUContext->psDevInfo; + + + if (((ui32PDIndex % (BRN31620_PDE_CACHE_FILL_SIZE/BRN31620_PT_ADDRESS_RANGE_SIZE)) == BRN31620_DUMMY_PDE_INDEX) + && (ui32PTIndex == BRN31620_DUMMY_PTE_INDEX)) + { + *pui32PTE = (psDevInfo->sBRN31620DummyPageDevPAddr.uiAddr>>SGX_MMU_PTE_ADDR_ALIGNSHIFT) + | SGX_MMU_PTE_DUMMY_PAGE + | SGX_MMU_PTE_READONLY + | SGX_MMU_PTE_VALID; + } + else + { + *pui32PTE = 0; + } +} + +static IMG_BOOL BRN31620FreePageTable(MMU_HEAP *psMMUHeap, IMG_UINT32 ui32PDIndex) +{ + MMU_CONTEXT *psMMUContext = psMMUHeap->psMMUContext; + PVRSRV_SGXDEV_INFO *psDevInfo = psMMUContext->psDevInfo; + IMG_UINT32 ui32PDCacheLine = ui32PDIndex >> BRN31620_PDES_PER_CACHE_LINE_SHIFT; + IMG_UINT32 bFreePTs = IMG_FALSE; + IMG_UINT32 *pui32Tmp; + + PVR_ASSERT(psMMUHeap != IMG_NULL); + + + PVR_ASSERT(psMMUContext->apsPTInfoListSave[ui32PDIndex] == IMG_NULL); + + psMMUContext->apsPTInfoListSave[ui32PDIndex] = psMMUContext->apsPTInfoList[ui32PDIndex]; + psMMUContext->apsPTInfoList[ui32PDIndex] = IMG_NULL; + + + if (--psMMUContext->ui32PDCacheRangeRefCount[ui32PDCacheLine] == 0) + { + IMG_UINT32 i; + IMG_UINT32 ui32PDIndexStart = ui32PDCacheLine * BRN31620_PDES_PER_CACHE_LINE_SIZE; + IMG_UINT32 ui32PDIndexEnd = ui32PDIndexStart + BRN31620_PDES_PER_CACHE_LINE_SIZE; + IMG_UINT32 ui32PDBitMaskIndex, ui32PDBitMaskShift; + + + for (i=ui32PDIndexStart;i<ui32PDIndexEnd;i++) + { + + psMMUContext->apsPTInfoList[i] = psMMUContext->apsPTInfoListSave[i]; + psMMUContext->apsPTInfoListSave[i] = IMG_NULL; + _DeferredFreePageTable(psMMUHeap, i - psMMUHeap->ui32PDBaseIndex, IMG_TRUE); + } + + ui32PDBitMaskIndex = ui32PDCacheLine >> BRN31620_CACHE_FLUSH_BITS_SHIFT; + ui32PDBitMaskShift = ui32PDCacheLine & BRN31620_CACHE_FLUSH_BITS_MASK; + + + if (MMU_IsHeapShared(psMMUHeap)) + { + + MMU_CONTEXT *psMMUContextWalker = (MMU_CONTEXT*) psMMUHeap->psMMUContext->psDevInfo->pvMMUContextList; + + while(psMMUContextWalker) + { + psMMUContextWalker->ui32PDChangeMask[ui32PDBitMaskIndex] |= 1 << ui32PDBitMaskShift; + + + pui32Tmp = (IMG_UINT32 *) psMMUContextWalker->pvPDCpuVAddr; + pui32Tmp[ui32PDIndexStart + BRN31620_DUMMY_PDE_INDEX] = (psDevInfo->sBRN31620DummyPTDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) + | SGX_MMU_PDE_PAGE_SIZE_4K + | SGX_MMU_PDE_DUMMY_PAGE + | SGX_MMU_PDE_VALID; + + PDUMPCOMMENT("BRN31620 Re-wire dummy PT due to releasing PT allocation block"); + PDUMPPDENTRIES(&psMMUHeap->sMMUAttrib, psMMUContextWalker->hPDOSMemHandle, (IMG_VOID*)&pui32Tmp[ui32PDIndexStart + BRN31620_DUMMY_PDE_INDEX], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); + psMMUContextWalker = psMMUContextWalker->psNext; + } + } + else + { + psMMUContext->ui32PDChangeMask[ui32PDBitMaskIndex] |= 1 << ui32PDBitMaskShift; + + + pui32Tmp = (IMG_UINT32 *) psMMUContext->pvPDCpuVAddr; + pui32Tmp[ui32PDIndexStart + BRN31620_DUMMY_PDE_INDEX] = (psDevInfo->sBRN31620DummyPTDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) + | SGX_MMU_PDE_PAGE_SIZE_4K + | SGX_MMU_PDE_DUMMY_PAGE + | SGX_MMU_PDE_VALID; + + PDUMPCOMMENT("BRN31620 Re-wire dummy PT due to releasing PT allocation block"); + PDUMPPDENTRIES(&psMMUHeap->sMMUAttrib, psMMUContext->hPDOSMemHandle, (IMG_VOID*)&pui32Tmp[ui32PDIndexStart + BRN31620_DUMMY_PDE_INDEX], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); + } + + bFreePTs = IMG_TRUE; + } + + return bFreePTs; +} +#endif static IMG_BOOL _AllocPageTableMemory (MMU_HEAP *pMMUHeap, @@ -301,10 +445,12 @@ _AllocPageTableMemory (MMU_HEAP *pMMUHeap, { if (OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - pMMUHeap->ui32PTSize, - SGX_MMU_PAGE_SIZE, - (IMG_VOID **)&psPTInfoList->PTPageCpuVAddr, - &psPTInfoList->hPTPageOSMemHandle) != PVRSRV_OK) + pMMUHeap->ui32PTSize, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + (IMG_VOID **)&psPTInfoList->PTPageCpuVAddr, + &psPTInfoList->hPTPageOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "_AllocPageTableMemory: ERROR call to OSAllocPages failed")); return IMG_FALSE; @@ -339,6 +485,8 @@ _AllocPageTableMemory (MMU_HEAP *pMMUHeap, 0, SGX_MMU_PAGE_SIZE, 0, + IMG_NULL, + 0, &(sSysPAddr.uiAddr))!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "_AllocPageTableMemory: ERROR call to RA_Alloc failed")); @@ -373,11 +521,16 @@ _AllocPageTableMemory (MMU_HEAP *pMMUHeap, pui32Tmp = (IMG_UINT32*)psPTInfoList->PTPageCpuVAddr; - for(i=0; i<pMMUHeap->ui32PTECount; i++) + for(i=0; i<pMMUHeap->ui32PTNumEntriesUsable; i++) { pui32Tmp[i] = (pMMUHeap->psMMUContext->psDevInfo->sDummyDataDevPAddr.uiAddr>>SGX_MMU_PTE_ADDR_ALIGNSHIFT) | SGX_MMU_PTE_VALID; } + + for(; i<pMMUHeap->ui32PTNumEntriesAllocated; i++) + { + pui32Tmp[i] = 0; + } } #else @@ -575,9 +728,10 @@ _DeferredFreePageTable (MMU_HEAP *pMMUHeap, IMG_UINT32 ui32PTIndex, IMG_BOOL bOS for(i=0; - (i<pMMUHeap->ui32PTETotal) && (i<pMMUHeap->ui32PTECount); + (i<pMMUHeap->ui32PTETotalUsable) && (i<pMMUHeap->ui32PTNumEntriesUsable); i++) { + pui32Tmp[i] = 0; } @@ -591,12 +745,12 @@ _DeferredFreePageTable (MMU_HEAP *pMMUHeap, IMG_UINT32 ui32PTIndex, IMG_BOOL bOS - pMMUHeap->ui32PTETotal -= i; + pMMUHeap->ui32PTETotalUsable -= i; } else { - pMMUHeap->ui32PTETotal -= pMMUHeap->ui32PTECount; + pMMUHeap->ui32PTETotalUsable -= pMMUHeap->ui32PTNumEntriesUsable; } if(bOSFreePT) @@ -612,7 +766,7 @@ _DeferredFreePageTable (MMU_HEAP *pMMUHeap, IMG_UINT32 ui32PTIndex, IMG_BOOL bOS else { - pMMUHeap->ui32PTETotal -= pMMUHeap->ui32PTECount; + pMMUHeap->ui32PTETotalUsable -= pMMUHeap->ui32PTNumEntriesUsable; } PDUMPCOMMENT("Finished free page table (page count == %08X)", pMMUHeap->ui32PageTableCount); @@ -622,17 +776,59 @@ static IMG_VOID _DeferredFreePageTables (MMU_HEAP *pMMUHeap) { IMG_UINT32 i; +#if defined(FIX_HW_BRN_31620) + MMU_CONTEXT *psMMUContext = pMMUHeap->psMMUContext; + IMG_BOOL bInvalidateDirectoryCache = IMG_FALSE; + IMG_UINT32 ui32PDIndex; + IMG_UINT32 *pui32Tmp; + IMG_UINT32 j; +#endif #if defined(PDUMP) PDUMPCOMMENT("Free PTs (MMU Context ID == %u, PDBaseIndex == %u, PT count == 0x%x)", pMMUHeap->psMMUContext->ui32PDumpMMUContextID, pMMUHeap->ui32PDBaseIndex, pMMUHeap->ui32PageTableCount); #endif +#if defined(FIX_HW_BRN_31620) + for(i=0; i<pMMUHeap->ui32PageTableCount; i++) + { + ui32PDIndex = (pMMUHeap->ui32PDBaseIndex + i); + + if (psMMUContext->apsPTInfoList[ui32PDIndex]) + { + if (psMMUContext->apsPTInfoList[ui32PDIndex]->PTPageCpuVAddr) + { + + for (j=0;j<SGX_MMU_PT_SIZE;j++) + { + pui32Tmp = (IMG_UINT32 *) psMMUContext->apsPTInfoList[ui32PDIndex]->PTPageCpuVAddr; + BRN31620InvalidatePageTableEntry(psMMUContext, ui32PDIndex, j, &pui32Tmp[j]); + } + } + + if (BRN31620FreePageTable(pMMUHeap, ui32PDIndex) == IMG_TRUE) + { + bInvalidateDirectoryCache = IMG_TRUE; + } + } + } + + + if (bInvalidateDirectoryCache) + { + MMU_InvalidateDirectoryCache(pMMUHeap->psMMUContext->psDevInfo); + } + else + { + MMU_InvalidatePageTableCache(pMMUHeap->psMMUContext->psDevInfo); + } +#else for(i=0; i<pMMUHeap->ui32PageTableCount; i++) { _DeferredFreePageTable(pMMUHeap, i, IMG_TRUE); } MMU_InvalidateDirectoryCache(pMMUHeap->psMMUContext->psDevInfo); +#endif } @@ -646,6 +842,15 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT MMU_PT_INFO **ppsPTInfoList; SYS_DATA *psSysData; IMG_DEV_VIRTADDR sHighDevVAddr; +#if defined(FIX_HW_BRN_31620) + IMG_BOOL bFlushSystemCache = IMG_FALSE; + IMG_BOOL bSharedPT = IMG_FALSE; + IMG_DEV_VIRTADDR sDevVAddrRequestStart; + IMG_DEV_VIRTADDR sDevVAddrRequestEnd; + IMG_UINT32 ui32PDRequestStart; + IMG_UINT32 ui32PDRequestEnd; + IMG_UINT32 ui32ModifiedCachelines[BRN31620_CACHE_FLUSH_INDEX_SIZE]; +#endif #if SGX_FEATURE_ADDRESS_SPACE_SIZE < 32 @@ -676,6 +881,38 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT ui32PageTableCount = sHighDevVAddr.uiAddr >> pMMUHeap->ui32PDShift; + + if (ui32PageTableCount == 0) + ui32PageTableCount = 1024; + +#if defined(FIX_HW_BRN_31620) + for (i=0;i<BRN31620_CACHE_FLUSH_INDEX_SIZE;i++) + { + ui32ModifiedCachelines[i] = 0; + } + + + + + sDevVAddrRequestStart = DevVAddr; + ui32PDRequestStart = ui32PDIndex; + sDevVAddrRequestEnd = sHighDevVAddr; + ui32PDRequestEnd = ui32PageTableCount - 1; + + + DevVAddr.uiAddr = DevVAddr.uiAddr & (~BRN31620_PDE_CACHE_FILL_MASK); + + + sHighDevVAddr.uiAddr = ((sHighDevVAddr.uiAddr + (BRN31620_PDE_CACHE_FILL_SIZE - 1)) & (~BRN31620_PDE_CACHE_FILL_MASK)); + + ui32PDIndex = DevVAddr.uiAddr >> pMMUHeap->ui32PDShift; + ui32PageTableCount = sHighDevVAddr.uiAddr >> pMMUHeap->ui32PDShift; + + + if (ui32PageTableCount == 0) + ui32PageTableCount = 1024; +#endif + ui32PageTableCount -= ui32PDIndex; @@ -686,18 +923,45 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT ppsPTInfoList = &pMMUHeap->psMMUContext->apsPTInfoList[ui32PDIndex]; #if defined(PDUMP) - PDUMPCOMMENT("Alloc PTs (MMU Context ID == %u, PDBaseIndex == %u, Size == 0x%x)", - pMMUHeap->psMMUContext->ui32PDumpMMUContextID, - pMMUHeap->ui32PDBaseIndex, - ui32Size); - PDUMPCOMMENT("Alloc page table (page count == %08X)", ui32PageTableCount); - PDUMPCOMMENT("Page directory mods (page count == %08X)", ui32PageTableCount); + { + IMG_UINT32 ui32Flags = 0; + + + if( MMU_IsHeapShared(pMMUHeap) ) + { + ui32Flags |= PDUMP_FLAGS_CONTINUOUS; + } + PDUMPCOMMENTWITHFLAGS(ui32Flags, "Alloc PTs (MMU Context ID == %u, PDBaseIndex == %u, Size == 0x%x)", + pMMUHeap->psMMUContext->ui32PDumpMMUContextID, + pMMUHeap->ui32PDBaseIndex, + ui32Size); + PDUMPCOMMENTWITHFLAGS(ui32Flags, "Alloc page table (page count == %08X)", ui32PageTableCount); + PDUMPCOMMENTWITHFLAGS(ui32Flags, "Page directory mods (page count == %08X)", ui32PageTableCount); + } #endif for(i=0; i<ui32PageTableCount; i++) { if(ppsPTInfoList[i] == IMG_NULL) { +#if defined(FIX_HW_BRN_31620) + + if (pMMUHeap->psMMUContext->apsPTInfoListSave[ui32PDIndex + i]) + { + + if (((ui32PDIndex + i) >= ui32PDRequestStart) && ((ui32PDIndex + i) <= ui32PDRequestEnd)) + { + IMG_UINT32 ui32PDCacheLine = (ui32PDIndex + i) >> BRN31620_PDES_PER_CACHE_LINE_SHIFT; + + ppsPTInfoList[i] = pMMUHeap->psMMUContext->apsPTInfoListSave[ui32PDIndex + i]; + pMMUHeap->psMMUContext->apsPTInfoListSave[ui32PDIndex + i] = IMG_NULL; + + pMMUHeap->psMMUContext->ui32PDCacheRangeRefCount[ui32PDCacheLine]++; + } + } + else + { +#endif OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof (MMU_PT_INFO), (IMG_VOID **)&ppsPTInfoList[i], IMG_NULL, @@ -708,8 +972,15 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT return IMG_FALSE; } OSMemSet (ppsPTInfoList[i], 0, sizeof(MMU_PT_INFO)); +#if defined(FIX_HW_BRN_31620) + } +#endif } - +#if defined(FIX_HW_BRN_31620) + + if (ppsPTInfoList[i]) + { +#endif if(ppsPTInfoList[i]->hPTPageOSMemHandle == IMG_NULL && ppsPTInfoList[i]->PTPageCpuVAddr == IMG_NULL) { @@ -718,16 +989,43 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT IMG_UINT32 *pui32Tmp; IMG_UINT32 j; #else +#if !defined(FIX_HW_BRN_31620) PVR_ASSERT(pui32PDEntry[i] == 0); #endif - +#endif if(_AllocPageTableMemory (pMMUHeap, ppsPTInfoList[i], &sDevPAddr) != IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "_DeferredAllocPagetables: ERROR call to _AllocPageTableMemory failed")); return IMG_FALSE; } +#if defined(FIX_HW_BRN_31620) + bFlushSystemCache = IMG_TRUE; + + { + IMG_UINT32 ui32PD; + IMG_UINT32 ui32PDCacheLine; + IMG_UINT32 ui32PDBitMaskIndex; + IMG_UINT32 ui32PDBitMaskShift; + + ui32PD = ui32PDIndex + i; + ui32PDCacheLine = ui32PD >> BRN31620_PDES_PER_CACHE_LINE_SHIFT; + ui32PDBitMaskIndex = ui32PDCacheLine >> BRN31620_CACHE_FLUSH_BITS_SHIFT; + ui32PDBitMaskShift = ui32PDCacheLine & BRN31620_CACHE_FLUSH_BITS_MASK; + ui32ModifiedCachelines[ui32PDBitMaskIndex] |= 1 << ui32PDBitMaskShift; + + if ((pMMUHeap->ui32PDBaseIndex + pMMUHeap->ui32PageTableCount) < (ui32PD + 1)) + { + pMMUHeap->ui32PageTableCount = (ui32PD + 1) - pMMUHeap->ui32PDBaseIndex; + } + + if (((ui32PDIndex + i) >= ui32PDRequestStart) && ((ui32PDIndex + i) <= ui32PDRequestEnd)) + { + pMMUHeap->psMMUContext->ui32PDCacheRangeRefCount[ui32PDCacheLine]++; + } + } +#endif switch(pMMUHeap->psDevArena->DevMemHeapType) { case DEVICE_MEMORY_HEAP_SHARED : @@ -746,7 +1044,6 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT pui32PDEntry[i] = (sDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) | pMMUHeap->ui32PDEPageSizeCtrl | SGX_MMU_PDE_VALID; - #if defined(PDUMP) #if defined(SUPPORT_PDUMP_MULTI_PROCESS) @@ -757,10 +1054,12 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT PDUMPPDENTRIES(&pMMUHeap->sMMUAttrib, psMMUContext->hPDOSMemHandle, (IMG_VOID*)&pui32PDEntry[i], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); } #endif - psMMUContext = psMMUContext->psNext; } +#if defined(FIX_HW_BRN_31620) + bSharedPT = IMG_TRUE; +#endif break; } case DEVICE_MEMORY_HEAP_PERCONTEXT : @@ -772,6 +1071,7 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT | SGX_MMU_PDE_VALID; + PDUMPPDENTRIES(&pMMUHeap->sMMUAttrib, pMMUHeap->psMMUContext->hPDOSMemHandle, (IMG_VOID*)&pui32PDEntry[i], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); break; } @@ -789,17 +1089,112 @@ _DeferredAllocPagetables(MMU_HEAP *pMMUHeap, IMG_DEV_VIRTADDR DevVAddr, IMG_UINT MMU_InvalidateDirectoryCache(pMMUHeap->psMMUContext->psDevInfo); #endif +#if defined(FIX_HW_BRN_31620) + + if (((ui32PDIndex + i) < ui32PDRequestStart) || ((ui32PDIndex + i) > ui32PDRequestEnd)) + { + pMMUHeap->psMMUContext->apsPTInfoListSave[ui32PDIndex + i] = ppsPTInfoList[i]; + ppsPTInfoList[i] = IMG_NULL; + } +#endif } else { +#if !defined(FIX_HW_BRN_31620) PVR_ASSERT(pui32PDEntry[i] != 0); +#endif + } +#if defined(FIX_HW_BRN_31620) } +#endif } #if defined(SGX_FEATURE_SYSTEM_CACHE) + #if defined(FIX_HW_BRN_31620) + + if (bFlushSystemCache) + { + #endif + MMU_InvalidateSystemLevelCache(pMMUHeap->psMMUContext->psDevInfo); #endif + #if defined(FIX_HW_BRN_31620) + } + + + sHighDevVAddr.uiAddr = sHighDevVAddr.uiAddr - 1; + + + if (bFlushSystemCache) + { + MMU_CONTEXT *psMMUContext; + + if (bSharedPT) + { + MMU_CONTEXT *psMMUContext = (MMU_CONTEXT*)pMMUHeap->psMMUContext->psDevInfo->pvMMUContextList; + + while(psMMUContext) + { + for (i=0;i<BRN31620_CACHE_FLUSH_INDEX_SIZE;i++) + { + psMMUContext->ui32PDChangeMask[i] |= ui32ModifiedCachelines[i]; + } + + + psMMUContext = psMMUContext->psNext; + } + } + else + { + for (i=0;i<BRN31620_CACHE_FLUSH_INDEX_SIZE;i++) + { + pMMUHeap->psMMUContext->ui32PDChangeMask[i] |= ui32ModifiedCachelines[i]; + } + } + + + psMMUContext = pMMUHeap->psMMUContext; + for (i=0;i<BRN31620_CACHE_FLUSH_INDEX_SIZE;i++) + { + IMG_UINT32 j; + + for(j=0;j<BRN31620_CACHE_FLUSH_BITS_SIZE;j++) + { + if (ui32ModifiedCachelines[i] & (1 << j)) + { + PVRSRV_SGXDEV_INFO *psDevInfo = psMMUContext->psDevInfo; + MMU_PT_INFO *psTempPTInfo = IMG_NULL; + IMG_UINT32 *pui32Tmp; + + ui32PDIndex = (((i * BRN31620_CACHE_FLUSH_BITS_SIZE) + j) * BRN31620_PDES_PER_CACHE_LINE_SIZE) + BRN31620_DUMMY_PDE_INDEX; + + + if (psMMUContext->apsPTInfoList[ui32PDIndex]) + { + psTempPTInfo = psMMUContext->apsPTInfoList[ui32PDIndex]; + } + else + { + psTempPTInfo = psMMUContext->apsPTInfoListSave[ui32PDIndex]; + } + + PVR_ASSERT(psTempPTInfo != IMG_NULL); + + pui32Tmp = (IMG_UINT32 *) psTempPTInfo->PTPageCpuVAddr; + PVR_ASSERT(pui32Tmp != IMG_NULL); + pui32Tmp[BRN31620_DUMMY_PTE_INDEX] = (psDevInfo->sBRN31620DummyPageDevPAddr.uiAddr>>SGX_MMU_PTE_ADDR_ALIGNSHIFT) + | SGX_MMU_PTE_DUMMY_PAGE + | SGX_MMU_PTE_READONLY + | SGX_MMU_PTE_VALID; + + PDUMPCOMMENT("BRN31620 Dump PTE for dummy page after wireing up new PT"); + PDUMPMEMPTENTRIES(&pMMUHeap->sMMUAttrib, psTempPTInfo->hPTPageOSMemHandle, (IMG_VOID *) &pui32Tmp[BRN31620_DUMMY_PTE_INDEX], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); + } + } + } + } + #endif return IMG_TRUE; } @@ -810,6 +1205,7 @@ IMG_UINT32 MMU_GetPDumpContextID(IMG_HANDLE hDevMemContext) { BM_CONTEXT *pBMContext = hDevMemContext; PVR_ASSERT(pBMContext); + return pBMContext->psMMUContext->ui32PDumpMMUContextID; } @@ -881,10 +1277,12 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I if(psDeviceNode->psLocalDevMemArena == IMG_NULL) { if (OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, - &pvPDCpuVAddr, - &hPDOSMemHandle) != PVRSRV_OK) + SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + &pvPDCpuVAddr, + &hPDOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; @@ -912,10 +1310,12 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I { if (OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, - &psDevInfo->pvDummyPTPageCpuVAddr, - &psDevInfo->hDummyPTPageOSMemHandle) != PVRSRV_OK) + SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + &psDevInfo->pvDummyPTPageCpuVAddr, + &psDevInfo->hDummyPTPageOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; @@ -935,10 +1335,12 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I if (OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, - &psDevInfo->pvDummyDataPageCpuVAddr, - &psDevInfo->hDummyDataPageOSMemHandle) != PVRSRV_OK) + SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + &psDevInfo->pvDummyDataPageCpuVAddr, + &psDevInfo->hDummyDataPageOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; @@ -956,6 +1358,73 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I psDevInfo->sDummyDataDevPAddr = SysCpuPAddrToDevPAddr (PVRSRV_DEVICE_TYPE_SGX, sCpuPAddr); } #endif +#if defined(FIX_HW_BRN_31620) + + if(!psDevInfo->pvMMUContextList) + { + IMG_UINT32 j; + + if (OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, + SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + &psDevInfo->pvBRN31620DummyPageCpuVAddr, + &psDevInfo->hBRN31620DummyPageOSMemHandle) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); + return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; + } + + + if(psDevInfo->pvBRN31620DummyPageCpuVAddr) + { + sCpuPAddr = OSMapLinToCPUPhys(psDevInfo->hBRN31620DummyPageOSMemHandle, + psDevInfo->pvBRN31620DummyPageCpuVAddr); + } + else + { + sCpuPAddr = OSMemHandleToCpuPAddr(psDevInfo->hBRN31620DummyPageOSMemHandle, 0); + } + + pui32Tmp = (IMG_UINT32 *)psDevInfo->pvBRN31620DummyPageCpuVAddr; + for(j=0; j<(SGX_MMU_PAGE_SIZE/4); j++) + { + pui32Tmp[j] = BRN31620_DUMMY_PAGE_SIGNATURE; + } + + psDevInfo->sBRN31620DummyPageDevPAddr = SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sCpuPAddr); + PDUMPMALLOCPAGETABLE(&psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPageOSMemHandle, 0, psDevInfo->pvBRN31620DummyPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + + + if (OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, + SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + &psDevInfo->pvBRN31620DummyPTCpuVAddr, + &psDevInfo->hBRN31620DummyPTOSMemHandle) != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to OSAllocPages failed")); + return PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES; + } + + + if(psDevInfo->pvBRN31620DummyPTCpuVAddr) + { + sCpuPAddr = OSMapLinToCPUPhys(psDevInfo->hBRN31620DummyPTOSMemHandle, + psDevInfo->pvBRN31620DummyPTCpuVAddr); + } + else + { + sCpuPAddr = OSMemHandleToCpuPAddr(psDevInfo->hBRN31620DummyPTOSMemHandle, 0); + } + + OSMemSet(psDevInfo->pvBRN31620DummyPTCpuVAddr,0,SGX_MMU_PAGE_SIZE); + psDevInfo->sBRN31620DummyPTDevPAddr = SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sCpuPAddr); + PDUMPMALLOCPAGETABLE(&psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPTOSMemHandle, 0, psDevInfo->pvBRN31620DummyPTCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + } +#endif } else { @@ -969,6 +1438,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, SGX_MMU_PAGE_SIZE, 0, + IMG_NULL, + 0, &(sSysPAddr.uiAddr))!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); @@ -1004,6 +1475,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, SGX_MMU_PAGE_SIZE, 0, + IMG_NULL, + 0, &(sSysPAddr.uiAddr))!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); @@ -1031,6 +1504,8 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I 0, SGX_MMU_PAGE_SIZE, 0, + IMG_NULL, + 0, &(sSysPAddr.uiAddr))!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); @@ -1051,8 +1526,92 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I } } #endif +#if defined(FIX_HW_BRN_31620) + + if(!psDevInfo->pvMMUContextList) + { + IMG_UINT32 j; + + if(RA_Alloc(psDeviceNode->psLocalDevMemArena, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + IMG_NULL, + 0, + SGX_MMU_PAGE_SIZE, + 0, + IMG_NULL, + 0, + &(sSysPAddr.uiAddr))!= IMG_TRUE) + { + PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); + return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; + } + + + sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); + psDevInfo->sBRN31620DummyPageDevPAddr = SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sSysPAddr); + psDevInfo->pvBRN31620DummyPageCpuVAddr = OSMapPhysToLin(sCpuPAddr, + SGX_MMU_PAGE_SIZE, + PVRSRV_HAP_WRITECOMBINE|PVRSRV_HAP_KERNEL_ONLY, + &psDevInfo->hBRN31620DummyPageOSMemHandle); + if(!psDevInfo->pvBRN31620DummyPageCpuVAddr) + { + PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables")); + return PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE; + } + + pui32Tmp = (IMG_UINT32 *)psDevInfo->pvBRN31620DummyPageCpuVAddr; + for(j=0; j<(SGX_MMU_PAGE_SIZE/4); j++) + { + pui32Tmp[j] = BRN31620_DUMMY_PAGE_SIGNATURE; + } + PDUMPMALLOCPAGETABLE(&psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPageOSMemHandle, 0, psDevInfo->pvBRN31620DummyPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + + + if(RA_Alloc(psDeviceNode->psLocalDevMemArena, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + IMG_NULL, + 0, + SGX_MMU_PAGE_SIZE, + 0, + IMG_NULL, + 0, + &(sSysPAddr.uiAddr))!= IMG_TRUE) + { + PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR call to RA_Alloc failed")); + return PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY; + } + + + sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); + psDevInfo->sBRN31620DummyPTDevPAddr = SysSysPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sSysPAddr); + psDevInfo->pvBRN31620DummyPTCpuVAddr = OSMapPhysToLin(sCpuPAddr, + SGX_MMU_PAGE_SIZE, + PVRSRV_HAP_WRITECOMBINE|PVRSRV_HAP_KERNEL_ONLY, + &psDevInfo->hBRN31620DummyPTOSMemHandle); + + if(!psDevInfo->pvBRN31620DummyPTCpuVAddr) + { + PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: ERROR failed to map page tables")); + return PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE; + } + + OSMemSet(psDevInfo->pvBRN31620DummyPTCpuVAddr,0,SGX_MMU_PAGE_SIZE); + PDUMPMALLOCPAGETABLE(&psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPTOSMemHandle, 0, psDevInfo->pvBRN31620DummyPTCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + } +#endif } +#if defined(FIX_HW_BRN_31620) + if (!psDevInfo->pvMMUContextList) + { + + psDevInfo->hKernelMMUContext = psMMUContext; + PVR_DPF((PVR_DBG_ERROR, "MMU_Initialise: saving kernel mmu context: %p", psMMUContext)); + } +#endif + #if defined(PDUMP) #if defined(SUPPORT_PDUMP_MULTI_PROCESS) @@ -1079,6 +1638,7 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I #endif PDUMPMALLOCPAGETABLE(&psDeviceNode->sDevId, hPDOSMemHandle, 0, pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PD_UNIQUETAG); #endif + #ifdef SUPPORT_SGX_MMU_BYPASS EnableHostAccess(psMMUContext); #endif @@ -1093,6 +1653,7 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I return PVRSRV_ERROR_INVALID_CPU_ADDR; } + #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) for(i=0; i<SGX_MMU_PD_SIZE; i++) @@ -1146,7 +1707,65 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I PDUMPCOMMENT("Page directory contents"); PDUMPPDENTRIES(&sMMUAttrib, hPDOSMemHandle, pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); } - +#endif +#if defined(FIX_HW_BRN_31620) + { + IMG_UINT32 i; + IMG_UINT32 ui32PDCount = 0; + IMG_UINT32 *pui32PT; + pui32Tmp = (IMG_UINT32 *)pvPDCpuVAddr; + + PDUMPCOMMENT("BRN31620 Set up dummy PT"); + + pui32PT = (IMG_UINT32 *) psDevInfo->pvBRN31620DummyPTCpuVAddr; + pui32PT[BRN31620_DUMMY_PTE_INDEX] = (psDevInfo->sBRN31620DummyPageDevPAddr.uiAddr>>SGX_MMU_PTE_ADDR_ALIGNSHIFT) + | SGX_MMU_PTE_DUMMY_PAGE + | SGX_MMU_PTE_READONLY + | SGX_MMU_PTE_VALID; + + +#if defined(PDUMP) + + PDUMPCOMMENT("BRN31620 Dump dummy PT contents"); + PDUMPMEMPTENTRIES(&sMMUAttrib, psDevInfo->hBRN31620DummyPTOSMemHandle, psDevInfo->pvBRN31620DummyPTCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + PDUMPCOMMENT("BRN31620 Dump dummy page contents"); + PDUMPMEMPTENTRIES(&sMMUAttrib, psDevInfo->hBRN31620DummyPageOSMemHandle, psDevInfo->pvBRN31620DummyPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + + + for(i=0;i<SGX_MMU_PT_SIZE;i++) + { + PDUMPMEMPTENTRIES(&sMMUAttrib, psDevInfo->hBRN31620DummyPTOSMemHandle, &pui32PT[i], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + } +#endif + PDUMPCOMMENT("BRN31620 Dump PDE wire up"); + + for(i=0;i<SGX_MMU_PD_SIZE;i++) + { + pui32Tmp[i] = 0; + + if (ui32PDCount == BRN31620_DUMMY_PDE_INDEX) + { + pui32Tmp[i] = (psDevInfo->sBRN31620DummyPTDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) + | SGX_MMU_PDE_PAGE_SIZE_4K + | SGX_MMU_PDE_DUMMY_PAGE + | SGX_MMU_PDE_VALID; + } + PDUMPMEMPTENTRIES(&sMMUAttrib, hPDOSMemHandle, (IMG_VOID *) &pui32Tmp[i], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); + ui32PDCount++; + if (ui32PDCount == BRN31620_PDES_PER_CACHE_LINE_SIZE) + { + + ui32PDCount = 0; + } + } + + + + PDUMPCOMMENT("BRN31620 dummy Page table contents"); + PDUMPMEMPTENTRIES(&sMMUAttrib, psDevInfo->hBRN31620DummyPageOSMemHandle, psDevInfo->pvBRN31620DummyPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + } +#endif +#if defined(PDUMP) { PVRSRV_ERROR eError; @@ -1179,6 +1798,22 @@ MMU_Initialise (PVRSRV_DEVICE_NODE *psDeviceNode, MMU_CONTEXT **ppsMMUContext, I PDUMPCOMMENT("Set MMU context complete (MMU Context ID == %u)", psMMUContext->ui32PDumpMMUContextID); #endif +#if defined(FIX_HW_BRN_31620) + for(i=0;i<BRN31620_CACHE_FLUSH_INDEX_SIZE;i++) + { + psMMUContext->ui32PDChangeMask[i] = 0; + } + + for(i=0;i<BRN31620_CACHE_FLUSH_SIZE;i++) + { + psMMUContext->ui32PDCacheRangeRefCount[i] = 0; + } + + for(i=0;i<SGX_MAX_PD_ENTRIES;i++) + { + psMMUContext->apsPTInfoListSave[i] = IMG_NULL; + } +#endif psMMUContext->pvPDCpuVAddr = pvPDCpuVAddr; psMMUContext->sPDDevPAddr = sPDDevPAddr; @@ -1207,7 +1842,7 @@ MMU_Finalise (MMU_CONTEXT *psMMUContext) IMG_UINT32 *pui32Tmp, i; SYS_DATA *psSysData; MMU_CONTEXT **ppsMMUContext; -#if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) +#if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) || defined(FIX_HW_BRN_31620) PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO*)psMMUContext->psDevInfo; MMU_CONTEXT *psMMUContextList = (MMU_CONTEXT*)psDevInfo->pvMMUContextList; #endif @@ -1250,11 +1885,32 @@ MMU_Finalise (MMU_CONTEXT *psMMUContext) if(psMMUContext->psDeviceNode->psLocalDevMemArena == IMG_NULL) { +#if defined(FIX_HW_BRN_31620) + PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO*)psMMUContext->psDevInfo; +#endif OSFreePages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, SGX_MMU_PAGE_SIZE, psMMUContext->pvPDCpuVAddr, psMMUContext->hPDOSMemHandle); +#if defined(FIX_HW_BRN_31620) + + if (!psMMUContextList->psNext) + { + PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPageOSMemHandle, psDevInfo->pvBRN31620DummyPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + OSFreePages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, + SGX_MMU_PAGE_SIZE, + psDevInfo->pvBRN31620DummyPageCpuVAddr, + psDevInfo->hBRN31620DummyPageOSMemHandle); + + PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPTOSMemHandle, psDevInfo->pvBRN31620DummyPTCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + OSFreePages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, + SGX_MMU_PAGE_SIZE, + psDevInfo->pvBRN31620DummyPTCpuVAddr, + psDevInfo->hBRN31620DummyPTOSMemHandle); + + } +#endif #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) if(!psMMUContextList->psNext) @@ -1319,6 +1975,41 @@ MMU_Finalise (MMU_CONTEXT *psMMUContext) RA_Free (psMMUContext->psDeviceNode->psLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); } #endif +#if defined(FIX_HW_BRN_31620) + + if(!psMMUContextList->psNext) + { + + PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPageOSMemHandle, psDevInfo->pvBRN31620DummyPageCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + + sCpuPAddr = OSMapLinToCPUPhys(psDevInfo->hBRN31620DummyPageOSMemHandle, + psDevInfo->pvBRN31620DummyPageCpuVAddr); + sSysPAddr = SysCpuPAddrToSysPAddr(sCpuPAddr); + + + OSUnMapPhysToLin(psDevInfo->pvBRN31620DummyPageCpuVAddr, + SGX_MMU_PAGE_SIZE, + PVRSRV_HAP_WRITECOMBINE|PVRSRV_HAP_KERNEL_ONLY, + psDevInfo->hBRN31620DummyPageOSMemHandle); + + RA_Free (psMMUContext->psDeviceNode->psLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + + + PDUMPFREEPAGETABLE(&psMMUContext->psDeviceNode->sDevId, psDevInfo->hBRN31620DummyPTOSMemHandle, psDevInfo->pvBRN31620DummyPTCpuVAddr, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + + sCpuPAddr = OSMapLinToCPUPhys(psDevInfo->hBRN31620DummyPTOSMemHandle, + psDevInfo->pvBRN31620DummyPTCpuVAddr); + sSysPAddr = SysCpuPAddrToSysPAddr(sCpuPAddr); + + + OSUnMapPhysToLin(psDevInfo->pvBRN31620DummyPTCpuVAddr, + SGX_MMU_PAGE_SIZE, + PVRSRV_HAP_WRITECOMBINE|PVRSRV_HAP_KERNEL_ONLY, + psDevInfo->hBRN31620DummyPTOSMemHandle); + + RA_Free (psMMUContext->psDeviceNode->psLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + } +#endif } PVR_DPF ((PVR_DBG_MESSAGE, "MMU_Finalise")); @@ -1374,7 +2065,7 @@ MMU_InsertHeap(MMU_CONTEXT *psMMUContext, MMU_HEAP *psMMUHeap) for (ui32PDEntry = 0; ui32PDEntry < psMMUHeap->ui32PageTableCount; ui32PDEntry++) { -#if !defined(SUPPORT_SGX_MMU_DUMMY_PAGE) +#if (!defined(SUPPORT_SGX_MMU_DUMMY_PAGE)) && (!defined(FIX_HW_BRN_31620)) PVR_ASSERT(pui32PDCpuVAddr[ui32PDEntry] == 0); #endif @@ -1491,18 +2182,30 @@ MMU_UnmapPagesAndFreePTs (MMU_HEAP *psMMUHeap, | SGX_MMU_PTE_VALID; #else +#if defined(FIX_HW_BRN_31620) + BRN31620InvalidatePageTableEntry(psMMUHeap->psMMUContext, ui32PDIndex, ui32PTIndex, &pui32Tmp[ui32PTIndex]); +#else pui32Tmp[ui32PTIndex] = 0; #endif +#endif CheckPT(ppsPTInfoList[0]); } - if (ppsPTInfoList[0] && ppsPTInfoList[0]->ui32ValidPTECount == 0) + if (ppsPTInfoList[0] && (ppsPTInfoList[0]->ui32ValidPTECount == 0) + ) { +#if defined(FIX_HW_BRN_31620) + if (BRN31620FreePageTable(psMMUHeap, ui32PDIndex) == IMG_TRUE) + { + bInvalidateDirectoryCache = IMG_TRUE; + } +#else _DeferredFreePageTable(psMMUHeap, ui32PDIndex - psMMUHeap->ui32PDBaseIndex, IMG_TRUE); bInvalidateDirectoryCache = IMG_TRUE; +#endif } @@ -1536,9 +2239,9 @@ static IMG_VOID MMU_FreePageTables(IMG_PVOID pvMMUHeap, MMU_HEAP *pMMUHeap = (MMU_HEAP*)pvMMUHeap; IMG_DEV_VIRTADDR Start; - Start.uiAddr = ui32Start; + Start.uiAddr = (IMG_UINT32)ui32Start; - MMU_UnmapPagesAndFreePTs(pMMUHeap, Start, (ui32End - ui32Start) >> pMMUHeap->ui32PTShift, hUniqueTag); + MMU_UnmapPagesAndFreePTs(pMMUHeap, Start, (IMG_UINT32)((ui32End - ui32Start) >> pMMUHeap->ui32PTShift), hUniqueTag); } MMU_HEAP * @@ -1618,12 +2321,16 @@ MMU_Create (MMU_CONTEXT *psMMUContext, pMMUHeap->ui32PTBitWidth = SGX_MMU_PT_SHIFT - ui32ScaleSize; pMMUHeap->ui32PTMask = SGX_MMU_PT_MASK & (SGX_MMU_PT_MASK<<ui32ScaleSize); pMMUHeap->ui32PTSize = (IMG_UINT32)(1UL<<pMMUHeap->ui32PTBitWidth) * sizeof(IMG_UINT32); + if(pMMUHeap->ui32PTSize < 4 * sizeof(IMG_UINT32)) { pMMUHeap->ui32PTSize = 4 * sizeof(IMG_UINT32); } - pMMUHeap->ui32PTECount = pMMUHeap->ui32PTSize >> 2; + pMMUHeap->ui32PTNumEntriesAllocated = pMMUHeap->ui32PTSize >> 2; + + + pMMUHeap->ui32PTNumEntriesUsable = (IMG_UINT32)(1UL << pMMUHeap->ui32PTBitWidth); pMMUHeap->ui32PDShift = pMMUHeap->ui32PTBitWidth + pMMUHeap->ui32PTShift; @@ -1631,6 +2338,8 @@ MMU_Create (MMU_CONTEXT *psMMUContext, pMMUHeap->ui32PDMask = SGX_MMU_PD_MASK & (SGX_MMU_PD_MASK>>(32-SGX_FEATURE_ADDRESS_SPACE_SIZE)); +#if !defined (SUPPORT_EXTERNAL_SYSTEM_CACHE) + @@ -1643,9 +2352,9 @@ MMU_Create (MMU_CONTEXT *psMMUContext, & (pMMUHeap->ui32DataPageMask | pMMUHeap->ui32PTMask)) == 0); } - +#endif - pMMUHeap->ui32PTETotal = pMMUHeap->psDevArena->ui32Size >> pMMUHeap->ui32PTShift; + pMMUHeap->ui32PTETotalUsable = pMMUHeap->psDevArena->ui32Size >> pMMUHeap->ui32PTShift; pMMUHeap->ui32PDBaseIndex = (pMMUHeap->psDevArena->BaseDevVAddr.uiAddr & pMMUHeap->ui32PDMask) >> pMMUHeap->ui32PDShift; @@ -1653,8 +2362,9 @@ MMU_Create (MMU_CONTEXT *psMMUContext, - pMMUHeap->ui32PageTableCount = (pMMUHeap->ui32PTETotal + pMMUHeap->ui32PTECount - 1) + pMMUHeap->ui32PageTableCount = (pMMUHeap->ui32PTETotalUsable + pMMUHeap->ui32PTNumEntriesUsable - 1) >> pMMUHeap->ui32PTBitWidth; + PVR_ASSERT(pMMUHeap->ui32PageTableCount > 0); pMMUHeap->psVMArena = RA_Create(psDevArena->pszName, @@ -1790,6 +2500,8 @@ MMU_Alloc (MMU_HEAP *pMMUHeap, 0, uDevVAddrAlignment, 0, + IMG_NULL, + 0, &uiAddr); if(!bStatus) { @@ -1808,7 +2520,7 @@ MMU_Alloc (MMU_HEAP *pMMUHeap, #endif - bStatus = _DeferredAllocPagetables(pMMUHeap, *psDevVAddr, uSize); + bStatus = _DeferredAllocPagetables(pMMUHeap, *psDevVAddr, (IMG_UINT32)uSize); #ifdef SUPPORT_SGX_MMU_BYPASS DisableHostAccess(pMMUHeap->psMMUContext); @@ -1874,6 +2586,26 @@ MMU_Disable (MMU_HEAP *pMMUHeap) } +#if defined(FIX_HW_BRN_31620) +IMG_VOID MMU_GetCacheFlushRange(MMU_CONTEXT *pMMUContext, IMG_UINT32 *pui32RangeMask) +{ + IMG_UINT32 i; + + for (i=0;i<BRN31620_CACHE_FLUSH_INDEX_SIZE;i++) + { + pui32RangeMask[i] = pMMUContext->ui32PDChangeMask[i]; + + + pMMUContext->ui32PDChangeMask[i] = 0; + } +} + +IMG_VOID MMU_GetPDPhysAddr(MMU_CONTEXT *pMMUContext, IMG_DEV_PHYADDR *psDevPAddr) +{ + *psDevPAddr = pMMUContext->sPDDevPAddr; +} + +#endif #if defined(PDUMP) static IMG_VOID MMU_PDumpPageTables (MMU_HEAP *pMMUHeap, @@ -1891,7 +2623,7 @@ MMU_PDumpPageTables (MMU_HEAP *pMMUHeap, IMG_UINT32 ui32PTDumpCount; - ui32NumPTEntries = (uSize + pMMUHeap->ui32DataPageMask) >> pMMUHeap->ui32PTShift; + ui32NumPTEntries = (IMG_UINT32)((uSize + pMMUHeap->ui32DataPageMask) >> pMMUHeap->ui32PTShift); ui32PDIndex = DevVAddr.uiAddr >> pMMUHeap->ui32PDShift; @@ -1910,13 +2642,13 @@ MMU_PDumpPageTables (MMU_HEAP *pMMUHeap, { MMU_PT_INFO* psPTInfo = *ppsPTInfoList++; - if(ui32NumPTEntries <= pMMUHeap->ui32PTECount - ui32PTIndex) + if(ui32NumPTEntries <= pMMUHeap->ui32PTNumEntriesUsable - ui32PTIndex) { ui32PTDumpCount = ui32NumPTEntries; } else { - ui32PTDumpCount = pMMUHeap->ui32PTECount - ui32PTIndex; + ui32PTDumpCount = pMMUHeap->ui32PTNumEntriesUsable - ui32PTIndex; } if (psPTInfo) @@ -2009,7 +2741,12 @@ MMU_MapPage (MMU_HEAP *pMMUHeap, IMG_UINT32 uTmp = pui32Tmp[ui32Index]; - if (uTmp & SGX_MMU_PTE_VALID) +#if defined(FIX_HW_BRN_31620) + if ((uTmp & SGX_MMU_PTE_VALID) && ((DevVAddr.uiAddr & BRN31620_PDE_CACHE_FILL_MASK) != BRN31620_DUMMY_PAGE_OFFSET)) +#else + if ((uTmp & SGX_MMU_PTE_VALID) != 0) +#endif + { PVR_DPF((PVR_DBG_ERROR, "MMU_MapPage: Page is already valid for alloc at VAddr:0x%08X PDIdx:%u PTIdx:%u", DevVAddr.uiAddr, @@ -2018,8 +2755,9 @@ MMU_MapPage (MMU_HEAP *pMMUHeap, PVR_DPF((PVR_DBG_ERROR, "MMU_MapPage: Page table entry value: 0x%08X", uTmp)); PVR_DPF((PVR_DBG_ERROR, "MMU_MapPage: Physical page to map: 0x%08X", DevPAddr.uiAddr)); } - +#if !defined(FIX_HW_BRN_31620) PVR_ASSERT((uTmp & SGX_MMU_PTE_VALID) == 0); +#endif } #endif @@ -2322,8 +3060,12 @@ MMU_UnmapPages (MMU_HEAP *psMMUHeap, | SGX_MMU_PTE_VALID; #else +#if defined(FIX_HW_BRN_31620) + BRN31620InvalidatePageTableEntry(psMMUHeap->psMMUContext, ui32PDIndex, ui32PTIndex, &pui32Tmp[ui32PTIndex]); +#else pui32Tmp[ui32PTIndex] = 0; #endif +#endif CheckPT(ppsPTInfoList[0]); @@ -2441,6 +3183,8 @@ PVRSRV_ERROR MMU_BIFResetPDAlloc(PVRSRV_SGXDEV_INFO *psDevInfo) eError = OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, 3 * SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, (IMG_VOID **)&pui8MemBlock, &hOSMemHandle); if (eError != PVRSRV_OK) @@ -2472,6 +3216,8 @@ PVRSRV_ERROR MMU_BIFResetPDAlloc(PVRSRV_SGXDEV_INFO *psDevInfo) 0, SGX_MMU_PAGE_SIZE, 0, + IMG_NULL, + 0, &(sMemBlockSysPAddr.uiAddr)) != IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "MMU_BIFResetPDAlloc: ERROR call to RA_Alloc failed")); @@ -2568,10 +3314,12 @@ PVRSRV_ERROR WorkaroundBRN22997Alloc(PVRSRV_DEVICE_NODE *psDeviceNode) { eError = OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, - (IMG_VOID **)&pui32PT, - &hPTPageOSMemHandle); + SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + (IMG_VOID **)&pui32PT, + &hPTPageOSMemHandle); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "WorkaroundBRN22997: ERROR call to OSAllocPages failed")); @@ -2580,10 +3328,12 @@ PVRSRV_ERROR WorkaroundBRN22997Alloc(PVRSRV_DEVICE_NODE *psDeviceNode) ui32PTOffset = 0; eError = OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, - (IMG_VOID **)&pui32PD, - &hPDPageOSMemHandle); + SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, + IMG_NULL, + 0, + (IMG_VOID **)&pui32PD, + &hPDPageOSMemHandle); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "WorkaroundBRN22997: ERROR call to OSAllocPages failed")); @@ -2628,6 +3378,8 @@ PVRSRV_ERROR WorkaroundBRN22997Alloc(PVRSRV_DEVICE_NODE *psDeviceNode) 0, SGX_MMU_PAGE_SIZE, 0, + IMG_NULL, + 0, &(psDevInfo->sBRN22997SysPAddr.uiAddr))!= IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "WorkaroundBRN22997: ERROR call to RA_Alloc failed")); @@ -2809,110 +3561,73 @@ IMG_VOID WorkaroundBRN22997Free(PVRSRV_DEVICE_NODE *psDeviceNode) #if defined(SUPPORT_EXTERNAL_SYSTEM_CACHE) PVRSRV_ERROR MMU_MapExtSystemCacheRegs(PVRSRV_DEVICE_NODE *psDeviceNode) { - PVRSRV_ERROR eError; - SYS_DATA *psSysData; - RA_ARENA *psLocalDevMemArena; - IMG_HANDLE hPTPageOSMemHandle = IMG_NULL; - IMG_UINT32 *pui32PD; - IMG_UINT32 *pui32PT = IMG_NULL; - IMG_CPU_PHYADDR sCpuPAddr; - IMG_DEV_PHYADDR sPTDevPAddr; + IMG_UINT32 *pui32PT; PVRSRV_SGXDEV_INFO *psDevInfo; IMG_UINT32 ui32PDIndex; IMG_UINT32 ui32PTIndex; + PDUMP_MMU_ATTRIB sMMUAttrib; psDevInfo = (PVRSRV_SGXDEV_INFO*)psDeviceNode->pvDevice; - pui32PD = (IMG_UINT32*)psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->pvPDCpuVAddr; - - SysAcquireData(&psSysData); - - psLocalDevMemArena = psSysData->apsLocalDevMemArena[0]; - - if(psLocalDevMemArena == IMG_NULL) - { - - eError = OSAllocPages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, - (IMG_VOID **)&pui32PT, - &hPTPageOSMemHandle); - if (eError != PVRSRV_OK) - { - PVR_DPF((PVR_DBG_ERROR, "MMU_MapExtSystemCacheRegs: ERROR call to OSAllocPages failed")); - return eError; - } + sMMUAttrib = psDevInfo->sMMUAttrib; +#if defined(PDUMP) + MMU_SetPDumpAttribs(&sMMUAttrib, psDeviceNode, + SGX_MMU_PAGE_MASK, + SGX_MMU_PT_SIZE * sizeof(IMG_UINT32)); +#endif - - if(pui32PT) - { - sCpuPAddr = OSMapLinToCPUPhys(hPTPageOSMemHandle, - pui32PT); - } - else - { - - sCpuPAddr = OSMemHandleToCpuPAddr(hPTPageOSMemHandle, 0); - } - sPTDevPAddr = SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sCpuPAddr); - } - else +#if defined(PDUMP) { - IMG_SYS_PHYADDR sSysPAddr; - - - if(RA_Alloc(psLocalDevMemArena, - SGX_MMU_PAGE_SIZE, - IMG_NULL, - IMG_NULL, - 0, - SGX_MMU_PAGE_SIZE, - 0, - &(sSysPAddr.uiAddr))!= IMG_TRUE) - { - PVR_DPF((PVR_DBG_ERROR, "MMU_MapExtSystemCacheRegs: ERROR call to RA_Alloc failed")); - return PVRSRV_ERROR_OUT_OF_MEMORY; - } + IMG_CHAR szScript[128]; - - sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); - pui32PT = OSMapPhysToLin(sCpuPAddr, - SGX_MMU_PAGE_SIZE, - PVRSRV_HAP_WRITECOMBINE|PVRSRV_HAP_KERNEL_ONLY, - &hPTPageOSMemHandle); - if(!pui32PT) - { - PVR_DPF((PVR_DBG_ERROR, "MMU_MapExtSystemCacheRegs: ERROR failed to map page tables")); - return PVRSRV_ERROR_BAD_MAPPING; - } - - - sPTDevPAddr = SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sCpuPAddr); - - - psDevInfo->sExtSystemCacheRegsPTSysPAddr = sSysPAddr; + sprintf(szScript, "MALLOC :EXTSYSCACHE:PA_%08X%08X %u %u 0x%08X\r\n", 0, psDevInfo->sExtSysCacheRegsDevPBase.uiAddr, SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, psDevInfo->sExtSysCacheRegsDevPBase.uiAddr); + PDumpOSWriteString2(szScript, PDUMP_FLAGS_CONTINUOUS); } - - OSMemSet(pui32PT, 0, SGX_MMU_PAGE_SIZE); +#endif ui32PDIndex = (SGX_EXT_SYSTEM_CACHE_REGS_DEVVADDR_BASE & SGX_MMU_PD_MASK) >> (SGX_MMU_PAGE_SHIFT + SGX_MMU_PT_SHIFT); ui32PTIndex = (SGX_EXT_SYSTEM_CACHE_REGS_DEVVADDR_BASE & SGX_MMU_PT_MASK) >> SGX_MMU_PAGE_SHIFT; - - pui32PD[ui32PDIndex] = (sPTDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT) - | SGX_MMU_PDE_VALID; + pui32PT = (IMG_UINT32 *) psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->apsPTInfoList[ui32PDIndex]->PTPageCpuVAddr; + pui32PT[ui32PTIndex] = (psDevInfo->sExtSysCacheRegsDevPBase.uiAddr>>SGX_MMU_PTE_ADDR_ALIGNSHIFT) | SGX_MMU_PTE_VALID; +#if defined(PDUMP) - PDUMPMALLOCPAGETABLE(&psDeviceNode->sDevID, hPTPageOSMemHandle, 0, pui32PT, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); - PDUMPMEMPTENTRIES(PVRSRV_DEVICE_TYPE_SGX, hPDPageOSMemHandle, pui32PD, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); - PDUMPMEMPTENTRIES(PVRSRV_DEVICE_TYPE_SGX, hPTPageOSMemHandle, pui32PT, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PT_UNIQUETAG, PDUMP_PD_UNIQUETAG); - - - psDevInfo->pui32ExtSystemCacheRegsPT = pui32PT; - psDevInfo->hExtSystemCacheRegsPTPageOSMemHandle = hPTPageOSMemHandle; + { + IMG_DEV_PHYADDR sDevPAddr; + IMG_CPU_PHYADDR sCpuPAddr; + IMG_UINT32 ui32PageMask; + IMG_UINT32 ui32PTE; + PVRSRV_ERROR eErr; + + PDUMP_GET_SCRIPT_AND_FILE_STRING(); + + ui32PageMask = sMMUAttrib.ui32PTSize - 1; + sCpuPAddr = OSMapLinToCPUPhys(psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->apsPTInfoList[ui32PDIndex]->hPTPageOSMemHandle, &pui32PT[ui32PTIndex]); + sDevPAddr = SysCpuPAddrToDevPAddr(sMMUAttrib.sDevId.eDeviceType, sCpuPAddr); + ui32PTE = *((IMG_UINT32 *) (&pui32PT[ui32PTIndex])); + + eErr = PDumpOSBufprintf(hScript, + ui32MaxLenScript, + "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", + sMMUAttrib.sDevId.pszPDumpDevName, + (IMG_UINT32)(IMG_UINTPTR_T)PDUMP_PT_UNIQUETAG, + (sDevPAddr.uiAddr) & ~ui32PageMask, + (sDevPAddr.uiAddr) & ui32PageMask, + "EXTSYSCACHE", + (IMG_UINT32)(IMG_UINTPTR_T)PDUMP_PD_UNIQUETAG, + (ui32PTE & sMMUAttrib.ui32PDEMask) << sMMUAttrib.ui32PTEAlignShift, + ui32PTE & ~sMMUAttrib.ui32PDEMask); + if(eErr != PVRSRV_OK) + { + return eErr; + } + PDumpOSWriteString2(hScript, PDUMP_FLAGS_CONTINUOUS); + } +#endif return PVRSRV_OK; } @@ -2924,45 +3639,39 @@ PVRSRV_ERROR MMU_UnmapExtSystemCacheRegs(PVRSRV_DEVICE_NODE *psDeviceNode) RA_ARENA *psLocalDevMemArena; PVRSRV_SGXDEV_INFO *psDevInfo; IMG_UINT32 ui32PDIndex; - IMG_UINT32 *pui32PD; + IMG_UINT32 ui32PTIndex; + IMG_UINT32 *pui32PT; + PDUMP_MMU_ATTRIB sMMUAttrib; psDevInfo = (PVRSRV_SGXDEV_INFO*)psDeviceNode->pvDevice; - pui32PD = (IMG_UINT32*)psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->pvPDCpuVAddr; + sMMUAttrib = psDevInfo->sMMUAttrib; + +#if defined(PDUMP) + MMU_SetPDumpAttribs(&sMMUAttrib, psDeviceNode, + SGX_MMU_PAGE_MASK, + SGX_MMU_PT_SIZE * sizeof(IMG_UINT32)); +#endif SysAcquireData(&psSysData); psLocalDevMemArena = psSysData->apsLocalDevMemArena[0]; ui32PDIndex = (SGX_EXT_SYSTEM_CACHE_REGS_DEVVADDR_BASE & SGX_MMU_PD_MASK) >> (SGX_MMU_PAGE_SHIFT + SGX_MMU_PT_SHIFT); - pui32PD[ui32PDIndex] = 0; - - PDUMPMEMPTENTRIES(PVRSRV_DEVICE_TYPE_SGX, psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->hPDOSMemHandle, pui32PD, SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); - PDUMPFREEPAGETABLE(&psDeviceNode->sDevId, psDevInfo->hExtSystemCacheRegsPTPageOSMemHandle, psDevInfo->pui32ExtSystemCacheRegsPT, SGX_MMU_PAGE_SIZE, 0, PDUMP_PT_UNIQUETAG); + ui32PTIndex = (SGX_EXT_SYSTEM_CACHE_REGS_DEVVADDR_BASE & SGX_MMU_PT_MASK) >> SGX_MMU_PAGE_SHIFT; - if(psLocalDevMemArena == IMG_NULL) + if (psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->apsPTInfoList[ui32PDIndex]) { - if (psDevInfo->pui32ExtSystemCacheRegsPT != IMG_NULL) + if (psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->apsPTInfoList[ui32PDIndex]->PTPageCpuVAddr) { - OSFreePages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, - SGX_MMU_PAGE_SIZE, - psDevInfo->pui32ExtSystemCacheRegsPT, - psDevInfo->hExtSystemCacheRegsPTPageOSMemHandle); + pui32PT = (IMG_UINT32 *) psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->apsPTInfoList[ui32PDIndex]->PTPageCpuVAddr; } } - else - { - if (psDevInfo->pui32ExtSystemCacheRegsPT != IMG_NULL) - { - OSUnMapPhysToLin(psDevInfo->pui32ExtSystemCacheRegsPT, - SGX_MMU_PAGE_SIZE, - PVRSRV_HAP_WRITECOMBINE|PVRSRV_HAP_KERNEL_ONLY, - psDevInfo->hExtSystemCacheRegsPTPageOSMemHandle); - RA_Free(psLocalDevMemArena, psDevInfo->sExtSystemCacheRegsPTSysPAddr.uiAddr, IMG_FALSE); - } - } + pui32PT[ui32PTIndex] = 0; + + PDUMPMEMPTENTRIES(&sMMUAttrib, psDeviceNode->sDevMemoryInfo.pBMKernelContext->psMMUContext->hPDOSMemHandle, &pui32PT[ui32PTIndex], sizeof(IMG_UINT32), 0, IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); return PVRSRV_OK; } diff --git a/drivers/gpu/pvr/sgx/mmu.h b/drivers/gpu/pvr/sgx/mmu.h index e92b4e0..59b24c4 100644 --- a/drivers/gpu/pvr/sgx/mmu.h +++ b/drivers/gpu/pvr/sgx/mmu.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -139,6 +139,14 @@ PVRSRV_ERROR MMU_UnmapExtSystemCacheRegs(PVRSRV_DEVICE_NODE *psDeviceNode); IMG_BOOL MMU_IsHeapShared(MMU_HEAP* pMMU_Heap); +#if defined(FIX_HW_BRN_31620) +IMG_VOID MMU_GetCacheFlushRange(MMU_CONTEXT *pMMUContext, IMG_UINT32 *pui32RangeMask); + +IMG_VOID MMU_GetPDPhysAddr(MMU_CONTEXT *pMMUContext, IMG_DEV_PHYADDR *psDevPAddr); + +#endif + + #if defined(PDUMP) IMG_UINT32 MMU_GetPDumpContextID(IMG_HANDLE hDevMemContext); #endif diff --git a/drivers/gpu/pvr/sgx/pb.c b/drivers/gpu/pvr/sgx/pb.c index f9e8b19..ab6523a 100644 --- a/drivers/gpu/pvr/sgx/pb.c +++ b/drivers/gpu/pvr/sgx/pb.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -47,8 +47,8 @@ static IMPLEMENT_LIST_REMOVE(PVRSRV_STUB_PBDESC) static PRESMAN_ITEM psResItemCreateSharedPB = IMG_NULL; static PVRSRV_PER_PROCESS_DATA *psPerProcCreateSharedPB = IMG_NULL; -static PVRSRV_ERROR SGXCleanupSharedPBDescCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param); -static PVRSRV_ERROR SGXCleanupSharedPBDescCreateLockCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param); +static PVRSRV_ERROR SGXCleanupSharedPBDescCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy); +static PVRSRV_ERROR SGXCleanupSharedPBDescCreateLockCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy); IMG_EXPORT PVRSRV_ERROR SGXFindSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, @@ -185,6 +185,7 @@ SGXCleanupSharedPBDescKM(PVRSRV_STUB_PBDESC *psStubPBDescIn) psStubPBDescIn->ui32RefCount--; if (psStubPBDescIn->ui32RefCount == 0) { + IMG_DEV_VIRTADDR sHWPBDescDevVAddr = psStubPBDescIn->sHWPBDescDevVAddr; List_PVRSRV_STUB_PBDESC_Remove(psStubPBDescIn); for(i=0 ; i<psStubPBDescIn->ui32SubKernelMemInfosCount; i++) { @@ -215,23 +216,25 @@ SGXCleanupSharedPBDescKM(PVRSRV_STUB_PBDESC *psStubPBDescIn) SGXCleanupRequest(psDeviceNode, - IMG_NULL, - PVRSRV_CLEANUPCMD_PB); + &sHWPBDescDevVAddr, + PVRSRV_CLEANUPCMD_PB, + CLEANUP_WITH_POLL); } return PVRSRV_OK; } -static PVRSRV_ERROR SGXCleanupSharedPBDescCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param) +static PVRSRV_ERROR SGXCleanupSharedPBDescCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy) { PVRSRV_STUB_PBDESC *psStubPBDesc = (PVRSRV_STUB_PBDESC *)pvParam; PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); return SGXCleanupSharedPBDescKM(psStubPBDesc); } -static PVRSRV_ERROR SGXCleanupSharedPBDescCreateLockCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param) +static PVRSRV_ERROR SGXCleanupSharedPBDescCreateLockCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param, IMG_BOOL bDummy) { #ifdef DEBUG PVRSRV_PER_PROCESS_DATA *psPerProc = (PVRSRV_PER_PROCESS_DATA *)pvParam; @@ -241,6 +244,7 @@ static PVRSRV_ERROR SGXCleanupSharedPBDescCreateLockCallback(IMG_PVOID pvParam, #endif PVR_UNREFERENCED_PARAMETER(ui32Param); + PVR_UNREFERENCED_PARAMETER(bDummy); psPerProcCreateSharedPB = IMG_NULL; psResItemCreateSharedPB = IMG_NULL; @@ -254,7 +258,7 @@ SGXUnrefSharedPBDescKM(IMG_HANDLE hSharedPBDesc) { PVR_ASSERT(hSharedPBDesc != IMG_NULL); - return ResManFreeResByPtr(hSharedPBDesc); + return ResManFreeResByPtr(hSharedPBDesc, CLEANUP_WITH_POLL); } @@ -268,7 +272,8 @@ SGXAddSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_UINT32 ui32TotalPBSize, IMG_HANDLE *phSharedPBDesc, PVRSRV_KERNEL_MEM_INFO **ppsSharedPBDescSubKernelMemInfos, - IMG_UINT32 ui32SharedPBDescSubKernelMemInfosCount) + IMG_UINT32 ui32SharedPBDescSubKernelMemInfosCount, + IMG_DEV_VIRTADDR sHWPBDescDevVAddr) { PVRSRV_STUB_PBDESC *psStubPBDesc=IMG_NULL; PVRSRV_ERROR eRet = PVRSRV_ERROR_INVALID_PERPROC; @@ -285,7 +290,7 @@ SGXAddSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, { PVR_ASSERT(psResItemCreateSharedPB != IMG_NULL); - ResManFreeResByPtr(psResItemCreateSharedPB); + ResManFreeResByPtr(psResItemCreateSharedPB, CLEANUP_WITH_POLL); PVR_ASSERT(psResItemCreateSharedPB == IMG_NULL); PVR_ASSERT(psPerProcCreateSharedPB == IMG_NULL); @@ -402,6 +407,8 @@ SGXAddSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, } } + psStubPBDesc->sHWPBDescDevVAddr = sHWPBDescDevVAddr; + psResItem = ResManRegisterRes(psPerProc->hResManContext, RESMAN_TYPE_SHARED_PB_DESC, psStubPBDesc, diff --git a/drivers/gpu/pvr/sgx/sgx_bridge_km.h b/drivers/gpu/pvr/sgx/sgx_bridge_km.h index 7738be1..8fb3002 100644 --- a/drivers/gpu/pvr/sgx/sgx_bridge_km.h +++ b/drivers/gpu/pvr/sgx/sgx_bridge_km.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -39,16 +39,28 @@ extern "C" { #endif IMG_IMPORT +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK_KM *psKick); +#else PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK *psKick); +#endif #if defined(SGX_FEATURE_2D_HARDWARE) IMG_IMPORT +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK_KM *psKick); +#else PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK *psKick); #endif +#endif IMG_IMPORT PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, +#if defined (SUPPORT_SID_INTERFACE) + SGX_CCB_KICK_KM *psCCBKick); +#else SGX_CCB_KICK *psCCBKick); +#endif IMG_IMPORT PVRSRV_ERROR SGXGetPhysPageAddrKM(IMG_HANDLE hDevMemHeap, @@ -86,12 +98,21 @@ PVRSRV_ERROR SGX2DQueryBlitsCompleteKM(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_IMPORT PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_HEAP_INFO_KM *pasHeapInfo, + IMG_DEV_PHYADDR *psPDDevPAddr); +#else SGX_BRIDGE_INFO_FOR_SRVINIT *psInitInfo); +#endif IMG_IMPORT PVRSRV_ERROR DevInitSGXPart2KM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevHandle, +#if defined (SUPPORT_SID_INTERFACE) + SGX_BRIDGE_INIT_INFO_KM *psInitInfo); +#else SGX_BRIDGE_INIT_INFO *psInitInfo); +#endif IMG_IMPORT PVRSRV_ERROR SGXFindSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, @@ -119,12 +140,17 @@ SGXAddSharedPBDescKM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_UINT32 ui32TotalPBSize, IMG_HANDLE *phSharedPBDesc, PVRSRV_KERNEL_MEM_INFO **psSharedPBDescSubKernelMemInfos, - IMG_UINT32 ui32SharedPBDescSubKernelMemInfosCount); + IMG_UINT32 ui32SharedPBDescSubKernelMemInfosCount, + IMG_DEV_VIRTADDR sHWPBDescDevVAddr); IMG_IMPORT PVRSRV_ERROR SGXGetInternalDevInfoKM(IMG_HANDLE hDevCookie, +#if defined (SUPPORT_SID_INTERFACE) + SGX_INTERNAL_DEVINFO_KM *psSGXInternalDevInfo); +#else SGX_INTERNAL_DEVINFO *psSGXInternalDevInfo); +#endif #if defined (__cplusplus) } diff --git a/drivers/gpu/pvr/sgx/sgxconfig.h b/drivers/gpu/pvr/sgx/sgxconfig.h index a0ca3e9..c5cb093 100644 --- a/drivers/gpu/pvr/sgx/sgxconfig.h +++ b/drivers/gpu/pvr/sgx/sgxconfig.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -35,7 +35,77 @@ #define DEV_MAJOR_VERSION 1 #define DEV_MINOR_VERSION 0 +#if defined(SUPPORT_EXTERNAL_SYSTEM_CACHE) +#define SGX_KERNEL_DATA_HEAP_OFFSET 0x00001000 +#else +#define SGX_KERNEL_DATA_HEAP_OFFSET 0x00000000 +#endif + #if SGX_FEATURE_ADDRESS_SPACE_SIZE == 32 +#if defined(FIX_HW_BRN_31620) + #if defined(SGX_FEATURE_2D_HARDWARE) + #define SGX_2D_HEAP_BASE 0x04000000 + #define SGX_2D_HEAP_SIZE (0x08000000-0x04000000-0x00001000) + #endif + + #define SGX_GENERAL_HEAP_BASE 0x08000000 + #define SGX_GENERAL_HEAP_SIZE (0xB8000000-0x00001000) + + + #define SGX_3DPARAMETERS_HEAP_SIZE 0x10000000 + + +#if !defined(HYBRID_SHARED_PB_SIZE) + #define HYBRID_SHARED_PB_SIZE (SGX_3DPARAMETERS_HEAP_SIZE >> 1) +#endif +#if defined(SUPPORT_HYBRID_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE (HYBRID_SHARED_PB_SIZE) + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (HYBRID_SHARED_PB_SIZE-0x00001000) + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - SGX_SHARED_3DPARAMETERS_SIZE - 0x00001000) +#else +#if defined(SUPPORT_PERCONTEXT_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE 0 + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE 0 + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000) +#endif +#if defined(SUPPORT_SHARED_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE SGX_3DPARAMETERS_HEAP_SIZE + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000) + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE 0 +#endif +#endif + + #define SGX_SHARED_3DPARAMETERS_HEAP_BASE 0xC0000000 + + + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE (SGX_SHARED_3DPARAMETERS_HEAP_BASE + SGX_SHARED_3DPARAMETERS_SIZE) + + + #define SGX_TADATA_HEAP_BASE 0xD0000000 + #define SGX_TADATA_HEAP_SIZE (0x0D000000-0x00001000) + + #define SGX_SYNCINFO_HEAP_BASE 0xE0000000 + #define SGX_SYNCINFO_HEAP_SIZE (0x01000000-0x00001000) + + #define SGX_PDSPIXEL_CODEDATA_HEAP_BASE 0xE4000000 + #define SGX_PDSPIXEL_CODEDATA_HEAP_SIZE (0x02000000-0x00001000) + + #define SGX_KERNEL_CODE_HEAP_BASE 0xE8000000 + #define SGX_KERNEL_CODE_HEAP_SIZE (0x00080000-0x00001000) + + #define SGX_PDSVERTEX_CODEDATA_HEAP_BASE 0xEC000000 + #define SGX_PDSVERTEX_CODEDATA_HEAP_SIZE (0x01C00000-0x00001000) + + #define SGX_KERNEL_DATA_HEAP_BASE (0xF0000000+SGX_KERNEL_DATA_HEAP_OFFSET) + #define SGX_KERNEL_DATA_HEAP_SIZE (0x03000000-(0x00001000+SGX_KERNEL_DATA_HEAP_OFFSET)) + + + #define SGX_PIXELSHADER_HEAP_BASE 0xF4000000 + #define SGX_PIXELSHADER_HEAP_SIZE (0x05000000-0x00001000) + + #define SGX_VERTEXSHADER_HEAP_BASE 0xFC000000 + #define SGX_VERTEXSHADER_HEAP_SIZE (0x02000000-0x00001000) +#else #if defined(SGX_FEATURE_2D_HARDWARE) #define SGX_2D_HEAP_BASE 0x00100000 #define SGX_2D_HEAP_SIZE (0x08000000-0x00100000-0x00001000) @@ -51,11 +121,56 @@ #define SGX_GENERAL_MAPPING_HEAP_SIZE (0x08000000-0x00001000) #endif + #if !defined(SUPPORT_MEMORY_TILING) #define SGX_GENERAL_HEAP_BASE 0x10000000 #define SGX_GENERAL_HEAP_SIZE (0xC2000000-0x00001000) + #else + #include <sgx_msvdx_defs.h> + + + #define SGX_GENERAL_HEAP_BASE 0x10000000 + #define SGX_GENERAL_HEAP_SIZE (0xB5000000-0x00001000) + + #define SGX_VPB_TILED_HEAP_STRIDE TILING_TILE_STRIDE_2K + #define SGX_VPB_TILED_HEAP_BASE 0xC5000000 + #define SGX_VPB_TILED_HEAP_SIZE (0x0D000000-0x00001000) + + + #if((SGX_VPB_TILED_HEAP_BASE & SGX_BIF_TILING_ADDR_INV_MASK) != 0) + #error "sgxconfig.h: SGX_VPB_TILED_HEAP has insufficient alignment" + #endif + + #endif + + + #define SGX_3DPARAMETERS_HEAP_SIZE 0x10000000 + + +#if !defined(HYBRID_SHARED_PB_SIZE) + #define HYBRID_SHARED_PB_SIZE (SGX_3DPARAMETERS_HEAP_SIZE >> 1) +#endif +#if defined(SUPPORT_HYBRID_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE (HYBRID_SHARED_PB_SIZE) + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (HYBRID_SHARED_PB_SIZE-0x00001000) + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - SGX_SHARED_3DPARAMETERS_SIZE - 0x00001000) +#else +#if defined(SUPPORT_PERCONTEXT_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE 0 + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE 0 + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000) +#endif +#if defined(SUPPORT_SHARED_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE SGX_3DPARAMETERS_HEAP_SIZE + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000) + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE 0 +#endif +#endif - #define SGX_3DPARAMETERS_HEAP_BASE 0xD2000000 - #define SGX_3DPARAMETERS_HEAP_SIZE (0x10000000-0x00001000) + #define SGX_SHARED_3DPARAMETERS_HEAP_BASE 0xD2000000 + + + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE (SGX_SHARED_3DPARAMETERS_HEAP_BASE + SGX_SHARED_3DPARAMETERS_SIZE) + #define SGX_TADATA_HEAP_BASE 0xE2000000 #define SGX_TADATA_HEAP_SIZE (0x0D000000-0x00001000) @@ -72,8 +187,8 @@ #define SGX_PDSVERTEX_CODEDATA_HEAP_BASE 0xF2400000 #define SGX_PDSVERTEX_CODEDATA_HEAP_SIZE (0x01C00000-0x00001000) - #define SGX_KERNEL_DATA_HEAP_BASE 0xF4000000 - #define SGX_KERNEL_DATA_HEAP_SIZE (0x05000000-0x00001000) + #define SGX_KERNEL_DATA_HEAP_BASE (0xF4000000+SGX_KERNEL_DATA_HEAP_OFFSET) + #define SGX_KERNEL_DATA_HEAP_SIZE (0x05000000-(0x00001000+SGX_KERNEL_DATA_HEAP_OFFSET)) #define SGX_PIXELSHADER_HEAP_BASE 0xF9000000 @@ -81,22 +196,66 @@ #define SGX_VERTEXSHADER_HEAP_BASE 0xFE000000 #define SGX_VERTEXSHADER_HEAP_SIZE (0x02000000-0x00001000) - +#endif #define SGX_CORE_IDENTIFIED #endif #if SGX_FEATURE_ADDRESS_SPACE_SIZE == 28 - #if defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP) + +#if defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP) #define SGX_GENERAL_MAPPING_HEAP_BASE 0x00001000 #define SGX_GENERAL_MAPPING_HEAP_SIZE (0x01800000-0x00001000-0x00001000) - #endif - + #define SGX_GENERAL_HEAP_BASE 0x01800000 #define SGX_GENERAL_HEAP_SIZE (0x07000000-0x00001000) - #define SGX_3DPARAMETERS_HEAP_BASE 0x08800000 - #define SGX_3DPARAMETERS_HEAP_SIZE (0x04000000-0x00001000) +#else + #define SGX_GENERAL_HEAP_BASE 0x00001000 +#if defined(SUPPORT_LARGE_GENERAL_HEAP) + #define SGX_GENERAL_HEAP_SIZE (0x0B800000-0x00001000-0x00001000) +#else + #define SGX_GENERAL_HEAP_SIZE (0x08800000-0x00001000-0x00001000) +#endif +#endif + +#if defined(SUPPORT_LARGE_GENERAL_HEAP) + #define SGX_3DPARAMETERS_HEAP_SIZE 0x01000000 +#else + #define SGX_3DPARAMETERS_HEAP_SIZE 0x04000000 +#endif + + +#if !defined(HYBRID_SHARED_PB_SIZE) + #define HYBRID_SHARED_PB_SIZE (SGX_3DPARAMETERS_HEAP_SIZE >> 1) +#endif +#if defined(SUPPORT_HYBRID_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE (HYBRID_SHARED_PB_SIZE) + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (HYBRID_SHARED_PB_SIZE-0x00001000) + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - SGX_SHARED_3DPARAMETERS_SIZE - 0x00001000) +#else +#if defined(SUPPORT_PERCONTEXT_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE 0 + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE 0 + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000) +#endif +#if defined(SUPPORT_SHARED_PB) + #define SGX_SHARED_3DPARAMETERS_SIZE SGX_3DPARAMETERS_HEAP_SIZE + #define SGX_SHARED_3DPARAMETERS_HEAP_SIZE (SGX_3DPARAMETERS_HEAP_SIZE - 0x00001000) + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE 0 +#endif +#endif + +#if defined(SUPPORT_LARGE_GENERAL_HEAP) + #define SGX_SHARED_3DPARAMETERS_HEAP_BASE 0x0B800000 +#else + #define SGX_SHARED_3DPARAMETERS_HEAP_BASE 0x08800000 +#endif + + + + #define SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE (SGX_SHARED_3DPARAMETERS_HEAP_BASE + SGX_SHARED_3DPARAMETERS_SIZE) + #define SGX_TADATA_HEAP_BASE 0x0C800000 #define SGX_TADATA_HEAP_SIZE (0x01000000-0x00001000) @@ -113,8 +272,8 @@ #define SGX_PDSVERTEX_CODEDATA_HEAP_BASE 0x0E800000 #define SGX_PDSVERTEX_CODEDATA_HEAP_SIZE (0x00800000-0x00001000) - #define SGX_KERNEL_DATA_HEAP_BASE 0x0F000000 - #define SGX_KERNEL_DATA_HEAP_SIZE (0x00400000-0x00001000) + #define SGX_KERNEL_DATA_HEAP_BASE (0x0F000000+SGX_KERNEL_DATA_HEAP_OFFSET) + #define SGX_KERNEL_DATA_HEAP_SIZE (0x00400000-(0x00001000+SGX_KERNEL_DATA_HEAP_OFFSET)) #define SGX_PIXELSHADER_HEAP_BASE 0x0F400000 #define SGX_PIXELSHADER_HEAP_SIZE (0x00500000-0x00001000) @@ -183,12 +342,27 @@ #endif #endif -#if ((SGX_GENERAL_HEAP_BASE + SGX_GENERAL_HEAP_SIZE) >= SGX_3DPARAMETERS_HEAP_BASE) - #error "sgxconfig.h: ERROR: SGX_GENERAL_HEAP overlaps SGX_3DPARAMETERS_HEAP" +#if defined(SUPPORT_HYBRID_PB) + #if ((HYBRID_SHARED_PB_SIZE + 0x000001000) > SGX_3DPARAMETERS_HEAP_SIZE) + #error "sgxconfig.h: ERROR: HYBRID_SHARED_PB_SIZE too large" + #endif +#endif + +#if defined(SUPPORT_MEMORY_TILING) + #if ((SGX_GENERAL_HEAP_BASE + SGX_GENERAL_HEAP_SIZE) >= SGX_VPB_TILED_HEAP_BASE) + #error "sgxconfig.h: ERROR: SGX_GENERAL_HEAP overlaps SGX_VPB_TILED_HEAP" + #endif + #if ((SGX_VPB_TILED_HEAP_BASE + SGX_VPB_TILED_HEAP_SIZE) >= SGX_SHARED_3DPARAMETERS_HEAP_BASE) + #error "sgxconfig.h: ERROR: SGX_VPB_TILED_HEAP overlaps SGX_3DPARAMETERS_HEAP" + #endif +#else + #if ((SGX_GENERAL_HEAP_BASE + SGX_GENERAL_HEAP_SIZE) >= SGX_SHARED_3DPARAMETERS_HEAP_BASE) + #error "sgxconfig.h: ERROR: SGX_GENERAL_HEAP overlaps SGX_3DPARAMETERS_HEAP" + #endif #endif -#if ((SGX_3DPARAMETERS_HEAP_BASE + SGX_3DPARAMETERS_HEAP_SIZE) >= SGX_TADATA_HEAP_BASE) - #error "sgxconfig.h: ERROR: SGX_3DPARAMETERS_HEAP overlaps SGX_TADATA_HEAP" +#if (((SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE + SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE) >= SGX_TADATA_HEAP_BASE) && (SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE > 0)) + #error "sgxconfig.h: ERROR: SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE overlaps SGX_TADATA_HEAP" #endif #if ((SGX_TADATA_HEAP_BASE + SGX_TADATA_HEAP_SIZE) >= SGX_SYNCINFO_HEAP_BASE) diff --git a/drivers/gpu/pvr/sgx/sgxinfokm.h b/drivers/gpu/pvr/sgx/sgxinfokm.h index 056db35..2f25a87 100644 --- a/drivers/gpu/pvr/sgx/sgxinfokm.h +++ b/drivers/gpu/pvr/sgx/sgxinfokm.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -94,6 +94,7 @@ typedef struct _PVRSRV_SGXDEV_INFO_ IMG_UINT32 ui32CoreClockSpeed; IMG_UINT32 ui32uKernelTimerClock; + IMG_BOOL bSGXIdle; PVRSRV_STUB_PBDESC *psStubPBDescListKM; @@ -101,6 +102,7 @@ typedef struct _PVRSRV_SGXDEV_INFO_ IMG_DEV_PHYADDR sKernelPDDevPAddr; + IMG_UINT32 ui32HeapCount; IMG_VOID *pvDeviceMemoryHeap; PPVRSRV_KERNEL_MEM_INFO psKernelCCBMemInfo; PVRSRV_SGX_KERNEL_CCB *psKernelCCB; @@ -126,16 +128,20 @@ typedef struct _PVRSRV_SGXDEV_INFO_ #if defined(FIX_HW_BRN_29823) PPVRSRV_KERNEL_MEM_INFO psKernelDummyTermStreamMemInfo; #endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31425) + PPVRSRV_KERNEL_MEM_INFO psKernelVDMSnapShotBufferMemInfo; + PPVRSRV_KERNEL_MEM_INFO psKernelVDMCtrlStreamBufferMemInfo; +#endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ + defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) + PPVRSRV_KERNEL_MEM_INFO psKernelVDMStateUpdateBufferMemInfo; +#endif #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) PPVRSRV_KERNEL_MEM_INFO psKernelEDMStatusBufferMemInfo; #endif #if defined(SGX_FEATURE_OVERLAPPED_SPM) PPVRSRV_KERNEL_MEM_INFO psKernelTmpRgnHeaderMemInfo; #endif -#if defined(SGX_FEATURE_SPM_MODE_0) - PPVRSRV_KERNEL_MEM_INFO psKernelTmpDPMStateMemInfo; -#endif - IMG_UINT32 ui32ClientRefCount; @@ -159,6 +165,8 @@ typedef struct _PVRSRV_SGXDEV_INFO_ IMG_UINT32 ui32EDMTaskReg0; IMG_UINT32 ui32EDMTaskReg1; + IMG_UINT32 ui32ClkGateCtl; + IMG_UINT32 ui32ClkGateCtl2; IMG_UINT32 ui32ClkGateStatusReg; IMG_UINT32 ui32ClkGateStatusMask; #if defined(SGX_FEATURE_MP) @@ -205,6 +213,10 @@ typedef struct _PVRSRV_SGXDEV_INFO_ PVRSRV_KERNEL_MEM_INFO *psKernelSGXTA3DCtlMemInfo; +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + PVRSRV_KERNEL_MEM_INFO *psKernelSGXPTLAWriteBackMemInfo; +#endif + IMG_UINT32 ui32Flags; @@ -228,6 +240,20 @@ typedef struct _PVRSRV_SGXDEV_INFO_ #endif IMG_UINT32 asSGXDevData[SGX_MAX_DEV_DATA]; +#if defined(FIX_HW_BRN_31620) + + IMG_VOID *pvBRN31620DummyPageCpuVAddr; + IMG_HANDLE hBRN31620DummyPageOSMemHandle; + IMG_DEV_PHYADDR sBRN31620DummyPageDevPAddr; + + + IMG_VOID *pvBRN31620DummyPTCpuVAddr; + IMG_HANDLE hBRN31620DummyPTOSMemHandle; + IMG_DEV_PHYADDR sBRN31620DummyPTDevPAddr; + + IMG_HANDLE hKernelMMUContext; +#endif + } PVRSRV_SGXDEV_INFO; @@ -292,6 +318,7 @@ struct _PVRSRV_STUB_PBDESC_ IMG_HANDLE hDevCookie; PVRSRV_KERNEL_MEM_INFO *psBlockKernelMemInfo; PVRSRV_KERNEL_MEM_INFO *psHWBlockKernelMemInfo; + IMG_DEV_VIRTADDR sHWPBDescDevVAddr; PVRSRV_STUB_PBDESC *psNext; PVRSRV_STUB_PBDESC **ppsThis; }; @@ -308,6 +335,183 @@ typedef struct _PVRSRV_SGX_CCB_INFO_ #endif } PVRSRV_SGX_CCB_INFO; + +typedef struct _SGX_BRIDGE_INIT_INFO_KM_ +{ + IMG_HANDLE hKernelCCBMemInfo; + IMG_HANDLE hKernelCCBCtlMemInfo; + IMG_HANDLE hKernelCCBEventKickerMemInfo; + IMG_HANDLE hKernelSGXHostCtlMemInfo; + IMG_HANDLE hKernelSGXTA3DCtlMemInfo; +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + IMG_HANDLE hKernelSGXPTLAWriteBackMemInfo; +#endif + IMG_HANDLE hKernelSGXMiscMemInfo; + + IMG_UINT32 aui32HostKickAddr[SGXMKIF_CMD_MAX]; + + SGX_INIT_SCRIPTS sScripts; + + IMG_UINT32 ui32ClientBuildOptions; + SGX_MISCINFO_STRUCT_SIZES sSGXStructSizes; + +#if defined(SGX_SUPPORT_HWPROFILING) + IMG_HANDLE hKernelHWProfilingMemInfo; +#endif +#if defined(SUPPORT_SGX_HWPERF) + IMG_HANDLE hKernelHWPerfCBMemInfo; +#endif + IMG_HANDLE hKernelTASigBufferMemInfo; + IMG_HANDLE hKernel3DSigBufferMemInfo; + +#if defined(FIX_HW_BRN_29702) + IMG_HANDLE hKernelCFIMemInfo; +#endif +#if defined(FIX_HW_BRN_29823) + IMG_HANDLE hKernelDummyTermStreamMemInfo; +#endif +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) + IMG_HANDLE hKernelEDMStatusBufferMemInfo; +#endif +#if defined(SGX_FEATURE_OVERLAPPED_SPM) + IMG_HANDLE hKernelTmpRgnHeaderMemInfo; +#endif + + IMG_UINT32 ui32EDMTaskReg0; + IMG_UINT32 ui32EDMTaskReg1; + + IMG_UINT32 ui32ClkGateStatusReg; + IMG_UINT32 ui32ClkGateStatusMask; +#if defined(SGX_FEATURE_MP) +#endif + + IMG_UINT32 ui32CacheControl; + + IMG_UINT32 asInitDevData[SGX_MAX_DEV_DATA]; + IMG_HANDLE asInitMemHandles[SGX_MAX_INIT_MEM_HANDLES]; + +} SGX_BRIDGE_INIT_INFO_KM; + + +typedef struct _SGX_INTERNEL_STATUS_UPDATE_KM_ +{ + CTL_STATUS sCtlStatus; + IMG_HANDLE hKernelMemInfo; +} SGX_INTERNEL_STATUS_UPDATE_KM; + + +typedef struct _SGX_CCB_KICK_KM_ +{ + SGXMKIF_COMMAND sCommand; + IMG_HANDLE hCCBKernelMemInfo; + + IMG_UINT32 ui32NumDstSyncObjects; + IMG_HANDLE hKernelHWSyncListMemInfo; + + + IMG_HANDLE *pahDstSyncHandles; + + IMG_UINT32 ui32NumTAStatusVals; + IMG_UINT32 ui32Num3DStatusVals; + +#if defined(SUPPORT_SGX_NEW_STATUS_VALS) + SGX_INTERNEL_STATUS_UPDATE_KM asTAStatusUpdate[SGX_MAX_TA_STATUS_VALS]; + SGX_INTERNEL_STATUS_UPDATE_KM as3DStatusUpdate[SGX_MAX_3D_STATUS_VALS]; +#else + IMG_HANDLE ahTAStatusSyncInfo[SGX_MAX_TA_STATUS_VALS]; + IMG_HANDLE ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS]; +#endif + + IMG_BOOL bFirstKickOrResume; +#if (defined(NO_HARDWARE) || defined(PDUMP)) + IMG_BOOL bTerminateOrAbort; +#endif + + + IMG_UINT32 ui32CCBOffset; + +#if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) + + IMG_UINT32 ui32NumTASrcSyncs; + IMG_HANDLE ahTASrcKernelSyncInfo[SGX_MAX_TA_SRC_SYNCS]; + IMG_UINT32 ui32NumTADstSyncs; + IMG_HANDLE ahTADstKernelSyncInfo[SGX_MAX_TA_DST_SYNCS]; + IMG_UINT32 ui32Num3DSrcSyncs; + IMG_HANDLE ah3DSrcKernelSyncInfo[SGX_MAX_3D_SRC_SYNCS]; +#else + + IMG_UINT32 ui32NumSrcSyncs; + IMG_HANDLE ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS]; +#endif + + + IMG_BOOL bTADependency; + IMG_HANDLE hTA3DSyncInfo; + + IMG_HANDLE hTASyncInfo; + IMG_HANDLE h3DSyncInfo; +#if defined(PDUMP) + IMG_UINT32 ui32CCBDumpWOff; +#endif +#if defined(NO_HARDWARE) + IMG_UINT32 ui32WriteOpsPendingVal; +#endif +} SGX_CCB_KICK_KM; + + +#if defined(TRANSFER_QUEUE) +typedef struct _PVRSRV_TRANSFER_SGX_KICK_KM_ +{ + IMG_HANDLE hCCBMemInfo; + IMG_UINT32 ui32SharedCmdCCBOffset; + + IMG_DEV_VIRTADDR sHWTransferContextDevVAddr; + + IMG_HANDLE hTASyncInfo; + IMG_HANDLE h3DSyncInfo; + + IMG_UINT32 ui32NumSrcSync; + IMG_HANDLE ahSrcSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; + + IMG_UINT32 ui32NumDstSync; + IMG_HANDLE ahDstSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; + + IMG_UINT32 ui32Flags; + + IMG_UINT32 ui32PDumpFlags; +#if defined(PDUMP) + IMG_UINT32 ui32CCBDumpWOff; +#endif +} PVRSRV_TRANSFER_SGX_KICK_KM, *PPVRSRV_TRANSFER_SGX_KICK_KM; + +#if defined(SGX_FEATURE_2D_HARDWARE) +typedef struct _PVRSRV_2D_SGX_KICK_KM_ +{ + IMG_HANDLE hCCBMemInfo; + IMG_UINT32 ui32SharedCmdCCBOffset; + + IMG_DEV_VIRTADDR sHW2DContextDevVAddr; + + IMG_UINT32 ui32NumSrcSync; + IMG_HANDLE ahSrcSyncInfo[SGX_MAX_2D_SRC_SYNC_OPS]; + + + IMG_HANDLE hDstSyncInfo; + + + IMG_HANDLE hTASyncInfo; + + + IMG_HANDLE h3DSyncInfo; + + IMG_UINT32 ui32PDumpFlags; +#if defined(PDUMP) + IMG_UINT32 ui32CCBDumpWOff; +#endif +} PVRSRV_2D_SGX_KICK_KM, *PPVRSRV_2D_SGX_KICK_KM; +#endif +#endif + PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode); IMG_VOID SGXOSTimer(IMG_VOID *pvData); @@ -316,6 +520,9 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bHardwareRecovery, IMG_UINT32 ui32PDUMPFlags); +IMG_VOID SGXInitClocks(PVRSRV_SGXDEV_INFO *psDevInfo, + IMG_UINT32 ui32PDUMPFlags); + PVRSRV_ERROR SGXInitialise(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bHardwareRecovery); PVRSRV_ERROR SGXDeinitialise(IMG_HANDLE hDevCookie); diff --git a/drivers/gpu/pvr/sgx/sgxinit.c b/drivers/gpu/pvr/sgx/sgxinit.c index c223c53..c13dbda 100644 --- a/drivers/gpu/pvr/sgx/sgxinit.c +++ b/drivers/gpu/pvr/sgx/sgxinit.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -51,6 +51,7 @@ #include "lists.h" #include "srvkm.h" +#include "ttrace.h" #define VAR(x) #x @@ -74,7 +75,8 @@ IMG_BOOL SGX_ISRHandler(IMG_VOID *pvData); static PVRSRV_ERROR SGXGetMiscInfoUkernel(PVRSRV_SGXDEV_INFO *psDevInfo, - PVRSRV_DEVICE_NODE *psDeviceNode); + PVRSRV_DEVICE_NODE *psDeviceNode, + IMG_HANDLE hDevMemContext); #if defined(PDUMP) static PVRSRV_ERROR SGXResetPDump(PVRSRV_DEVICE_NODE *psDeviceNode); @@ -111,7 +113,11 @@ static IMG_UINT32 DeinitDevInfo(PVRSRV_SGXDEV_INFO *psDevInfo) static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc, PVRSRV_DEVICE_NODE *psDeviceNode, +#if defined (SUPPORT_SID_INTERFACE) + SGX_BRIDGE_INIT_INFO_KM *psInitInfo) +#else SGX_BRIDGE_INIT_INFO *psInitInfo) +#endif { PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; PVRSRV_ERROR eError; @@ -135,7 +141,11 @@ static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc, psDevInfo->psKernelSGXTA3DCtlMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelSGXTA3DCtlMemInfo; - psDevInfo->psKernelSGXMiscMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelSGXMiscMemInfo; +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + psDevInfo->psKernelSGXPTLAWriteBackMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelSGXPTLAWriteBackMemInfo; +#endif + + psDevInfo->psKernelSGXMiscMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelSGXMiscMemInfo; #if defined(SGX_SUPPORT_HWPROFILING) psDevInfo->psKernelHWProfilingMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelHWProfilingMemInfo; @@ -151,15 +161,20 @@ static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc, #if defined(FIX_HW_BRN_29823) psDevInfo->psKernelDummyTermStreamMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelDummyTermStreamMemInfo; #endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31425) + psDevInfo->psKernelVDMSnapShotBufferMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelVDMSnapShotBufferMemInfo; + psDevInfo->psKernelVDMCtrlStreamBufferMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelVDMCtrlStreamBufferMemInfo; +#endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ + defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) + psDevInfo->psKernelVDMStateUpdateBufferMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelVDMStateUpdateBufferMemInfo; +#endif #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) psDevInfo->psKernelEDMStatusBufferMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelEDMStatusBufferMemInfo; #endif #if defined(SGX_FEATURE_OVERLAPPED_SPM) psDevInfo->psKernelTmpRgnHeaderMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelTmpRgnHeaderMemInfo; #endif -#if defined(SGX_FEATURE_SPM_MODE_0) - psDevInfo->psKernelTmpDPMStateMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelTmpDPMStateMemInfo; -#endif psDevInfo->ui32ClientBuildOptions = psInitInfo->ui32ClientBuildOptions; @@ -168,7 +183,7 @@ static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc, - eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, sizeof(PVRSRV_SGX_CCB_INFO), (IMG_VOID **)&psKernelCCBInfo, 0, "SGX Circular Command Buffer Info"); @@ -198,6 +213,8 @@ static PVRSRV_ERROR InitDevInfo(PVRSRV_PER_PROCESS_DATA *psPerProc, psDevInfo->ui32EDMTaskReg0 = psInitInfo->ui32EDMTaskReg0; psDevInfo->ui32EDMTaskReg1 = psInitInfo->ui32EDMTaskReg1; + psDevInfo->ui32ClkGateCtl = psInitInfo->ui32ClkGateCtl; + psDevInfo->ui32ClkGateCtl2 = psInitInfo->ui32ClkGateCtl2; psDevInfo->ui32ClkGateStatusReg = psInitInfo->ui32ClkGateStatusReg; psDevInfo->ui32ClkGateStatusMask = psInitInfo->ui32ClkGateStatusMask; #if defined(SGX_FEATURE_MP) @@ -266,6 +283,75 @@ static PVRSRV_ERROR SGXRunScript(PVRSRV_SGXDEV_INFO *psDevInfo, SGX_INIT_COMMAND return PVRSRV_ERROR_UNKNOWN_SCRIPT_OPERATION; } +#if defined(SUPPORT_MEMORY_TILING) +static PVRSRV_ERROR SGX_AllocMemTilingRangeInt(PVRSRV_SGXDEV_INFO *psDevInfo, + IMG_UINT32 ui32Start, + IMG_UINT32 ui32End, + IMG_UINT32 ui32TilingStride, + IMG_UINT32 *pui32RangeIndex) +{ + IMG_UINT32 i; + IMG_UINT32 ui32Offset; + IMG_UINT32 ui32Val; + + + for(i=0; i < SGX_BIF_NUM_TILING_RANGES; i++) + { + if((psDevInfo->ui32MemTilingUsage & (1U << i)) == 0) + { + + psDevInfo->ui32MemTilingUsage |= 1U << i; + + if(pui32RangeIndex != IMG_NULL) + { + *pui32RangeIndex = i; + } + goto RangeAllocated; + } + } + + PVR_DPF((PVR_DBG_ERROR,"SGX_AllocMemTilingRange: all tiling ranges in use")); + return PVRSRV_ERROR_EXCEEDED_HW_LIMITS; + +RangeAllocated: + + + if(ui32Start & ~SGX_BIF_TILING_ADDR_MASK) + { + PVR_DPF((PVR_DBG_WARNING,"SGX_AllocMemTilingRangeInt: Tiling range start (0x%08X) fails" + "alignment test", ui32Start)); + } + if((ui32End + 0x00001000) & ~SGX_BIF_TILING_ADDR_MASK) + { + PVR_DPF((PVR_DBG_WARNING,"SGX_AllocMemTilingRangeInt: Tiling range end (0x%08X) fails" + "alignment test", ui32End)); + } + + ui32Offset = EUR_CR_BIF_TILE0 + (i<<2); + + ui32Val = ((ui32TilingStride << EUR_CR_BIF_TILE0_CFG_SHIFT) & EUR_CR_BIF_TILE0_CFG_MASK) + | (((ui32End>>SGX_BIF_TILING_ADDR_LSB) << EUR_CR_BIF_TILE0_MAX_ADDRESS_SHIFT) & EUR_CR_BIF_TILE0_MAX_ADDRESS_MASK) + | (((ui32Start>>SGX_BIF_TILING_ADDR_LSB) << EUR_CR_BIF_TILE0_MIN_ADDRESS_SHIFT) & EUR_CR_BIF_TILE0_MIN_ADDRESS_MASK) + | (EUR_CR_BIF_TILE0_ENABLE << EUR_CR_BIF_TILE0_CFG_SHIFT); + + OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32Offset, ui32Val); + PDUMPREG(SGX_PDUMPREG_NAME, ui32Offset, ui32Val); + +#if defined(SGX_FEATURE_BIF_WIDE_TILING_AND_4K_ADDRESS) + ui32Offset = EUR_CR_BIF_TILE0_ADDR_EXT + (i<<2); + + ui32Val = (((ui32End>>SGX_BIF_TILING_EXT_ADDR_LSB) << EUR_CR_BIF_TILE0_ADDR_EXT_MAX_SHIFT) & EUR_CR_BIF_TILE0_ADDR_EXT_MAX_MASK) + | (((ui32Start>>SGX_BIF_TILING_EXT_ADDR_LSB) << EUR_CR_BIF_TILE0_ADDR_EXT_MIN_SHIFT) & EUR_CR_BIF_TILE0_ADDR_EXT_MIN_MASK); + + OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32Offset, ui32Val); + PDUMPREG(SGX_PDUMPREG_NAME, ui32Offset, ui32Val); +#endif + + return PVRSRV_OK; +} + +#endif + PVRSRV_ERROR SGXInitialise(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bHardwareRecovery) { @@ -277,6 +363,12 @@ PVRSRV_ERROR SGXInitialise(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bPDumpIsSuspended = PDumpIsSuspended(); #endif +#if defined(SGX_FEATURE_MP) + +#else + SGXInitClocks(psDevInfo, PDUMP_FLAGS_CONTINUOUS); +#endif + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "SGX initialisation script part 1\n"); @@ -289,6 +381,7 @@ PVRSRV_ERROR SGXInitialise(PVRSRV_SGXDEV_INFO *psDevInfo, PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "End of SGX initialisation script part 1\n"); + psDevInfo->ui32NumResets++; SGXReset(psDevInfo, bFirstTime || bHardwareRecovery, PDUMP_FLAGS_CONTINUOUS); #if defined(EUR_CR_POWER) @@ -320,6 +413,37 @@ PVRSRV_ERROR SGXInitialise(PVRSRV_SGXDEV_INFO *psDevInfo, } #endif +#if defined(SUPPORT_MEMORY_TILING) + { + + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap = psDevInfo->pvDeviceMemoryHeap; + IMG_UINT32 i; + + psDevInfo->ui32MemTilingUsage = 0; + + for(i=0; i<psDevInfo->ui32HeapCount; i++) + { + if(psDeviceMemoryHeap[i].ui32XTileStride > 0) + { + + eError = SGX_AllocMemTilingRangeInt( + psDevInfo, + psDeviceMemoryHeap[i].sDevVAddrBase.uiAddr, + psDeviceMemoryHeap[i].sDevVAddrBase.uiAddr + + psDeviceMemoryHeap[i].ui32HeapSize, + psDeviceMemoryHeap[i].ui32XTileStride, + NULL); + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR, "Unable to allocate SGX BIF tiling range for heap: %s", + psDeviceMemoryHeap[i].pszName)); + break; + } + } + } + } +#endif + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "SGX initialisation script part 2\n"); @@ -389,8 +513,9 @@ PVRSRV_ERROR SGXInitialise(PVRSRV_SGXDEV_INFO *psDevInfo, if (PollForValueKM(&psSGXHostCtl->ui32InitStatus, PVRSRV_USSE_EDM_INIT_COMPLETE, PVRSRV_USSE_EDM_INIT_COMPLETE, + MAX_HW_TIME_US, MAX_HW_TIME_US/WAIT_TRY_COUNT, - WAIT_TRY_COUNT) != PVRSRV_OK) + IMG_FALSE) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "SGXInitialise: Wait for uKernel initialisation failed")); #if !defined(FIX_HW_BRN_23281) @@ -464,7 +589,11 @@ static PVRSRV_ERROR DevInitSGXPart1 (IMG_VOID *pvDeviceNode) PDUMPCOMMENT("SGX Core Version Information: %s", SGX_CORE_FRIENDLY_NAME); #if defined(SGX_FEATURE_MP) + #if !defined(SGX_FEATURE_MP_PLUS) PDUMPCOMMENT("SGX Multi-processor: %d cores", SGX_FEATURE_MP_CORE_COUNT); + #else + PDUMPCOMMENT("SGX Multi-processor: %d TA cores, %d 3D cores", SGX_FEATURE_MP_CORE_COUNT_TA, SGX_FEATURE_MP_CORE_COUNT_3D); + #endif #endif #if (SGX_CORE_REV == 0) @@ -501,6 +630,7 @@ static PVRSRV_ERROR DevInitSGXPart1 (IMG_VOID *pvDeviceNode) psDeviceNode->pvDevice = (IMG_PVOID)psDevInfo; + psDevInfo->ui32HeapCount = psDeviceNode->sDevMemoryInfo.ui32HeapCount; psDevInfo->pvDeviceMemoryHeap = (IMG_VOID*)psDeviceMemoryHeap; @@ -525,12 +655,16 @@ static PVRSRV_ERROR DevInitSGXPart1 (IMG_VOID *pvDeviceNode) case DEVICE_MEMORY_HEAP_SHARED: case DEVICE_MEMORY_HEAP_SHARED_EXPORTED: { - hDevMemHeap = BM_CreateHeap (hKernelDevMemContext, - &psDeviceMemoryHeap[i]); + if (psDeviceMemoryHeap[i].ui32HeapSize > 0) + { + hDevMemHeap = BM_CreateHeap (hKernelDevMemContext, + &psDeviceMemoryHeap[i]); + - psDeviceMemoryHeap[i].hDevMemHeap = hDevMemHeap; + psDeviceMemoryHeap[i].hDevMemHeap = hDevMemHeap; + } break; } } @@ -553,7 +687,11 @@ static PVRSRV_ERROR DevInitSGXPart1 (IMG_VOID *pvDeviceNode) } IMG_EXPORT +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, PVRSRV_HEAP_INFO_KM *pasHeapInfo, IMG_DEV_PHYADDR *psPDDevPAddr) +#else PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, SGX_BRIDGE_INFO_FOR_SRVINIT *psInitInfo) +#endif { PVRSRV_DEVICE_NODE *psDeviceNode; PVRSRV_SGXDEV_INFO *psDevInfo; @@ -564,9 +702,15 @@ PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, SGX_BRIDGE_INFO_FOR_S psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevHandle; psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; +#if defined (SUPPORT_SID_INTERFACE) + *psPDDevPAddr = psDevInfo->sKernelPDDevPAddr; + + eError = PVRSRVGetDeviceMemHeapsKM(hDevHandle, pasHeapInfo); +#else psInitInfo->sPDDevPAddr = psDevInfo->sKernelPDDevPAddr; eError = PVRSRVGetDeviceMemHeapsKM(hDevHandle, &psInitInfo->asHeapInfo[0]); +#endif if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXGetInfoForSrvinit: PVRSRVGetDeviceMemHeapsKM failed (%d)", eError)); @@ -579,7 +723,11 @@ PVRSRV_ERROR SGXGetInfoForSrvinitKM(IMG_HANDLE hDevHandle, SGX_BRIDGE_INFO_FOR_S IMG_EXPORT PVRSRV_ERROR DevInitSGXPart2KM (PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevHandle, +#if defined (SUPPORT_SID_INTERFACE) + SGX_BRIDGE_INIT_INFO_KM *psInitInfo) +#else SGX_BRIDGE_INIT_INFO *psInitInfo) +#endif { PVRSRV_DEVICE_NODE *psDeviceNode; PVRSRV_SGXDEV_INFO *psDevInfo; @@ -876,9 +1024,12 @@ static IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, PVR_DPF((PVR_DBG_ERROR,"SGX Register Base Address (Linear): 0x%08X", (IMG_UINTPTR_T)psDevInfo->pvRegsBaseKM)); PVR_DPF((PVR_DBG_ERROR,"SGX Register Base Address (Physical): 0x%08X", psDevInfo->sRegsPhysBase.uiAddr)); - for (ui32CoreNum = 0; ui32CoreNum < SGX_FEATURE_MP_CORE_COUNT; ui32CoreNum++) + SGXDumpDebugReg(psDevInfo, 0, "EUR_CR_CORE_ID: ", EUR_CR_CORE_ID); + SGXDumpDebugReg(psDevInfo, 0, "EUR_CR_CORE_REVISION: ", EUR_CR_CORE_REVISION); + + for (ui32CoreNum = 0; ui32CoreNum < SGX_FEATURE_MP_CORE_COUNT_3D; ui32CoreNum++) { - + SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_EVENT_STATUS: ", EUR_CR_EVENT_STATUS); SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_EVENT_STATUS2: ", EUR_CR_EVENT_STATUS2); SGXDumpDebugReg(psDevInfo, ui32CoreNum, "EUR_CR_BIF_CTRL: ", EUR_CR_BIF_CTRL); @@ -902,8 +1053,15 @@ static IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, { - IMG_UINT32 *pui32HostCtlBuffer = (IMG_UINT32 *)psDevInfo->psSGXHostCtl; - IMG_UINT32 ui32LoopCounter; + SGXMKIF_HOST_CTL *psSGXHostCtl = psDevInfo->psSGXHostCtl; + IMG_UINT32 *pui32HostCtlBuffer = (IMG_UINT32 *)psSGXHostCtl; + IMG_UINT32 ui32LoopCounter; + + if (psSGXHostCtl->ui32AssertFail != 0) + { + PVR_LOG(("SGX Microkernel assert fail: 0x%08X", psSGXHostCtl->ui32AssertFail)); + psSGXHostCtl->ui32AssertFail = 0; + } PVR_LOG(("SGX Host control:")); @@ -926,7 +1084,7 @@ static IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, PVR_LOG(("SGX TA/3D control:")); for (ui32LoopCounter = 0; - ui32LoopCounter < psDevInfo->psKernelSGXTA3DCtlMemInfo->ui32AllocSize / sizeof(*pui32TA3DCtlBuffer); + ui32LoopCounter < psDevInfo->psKernelSGXTA3DCtlMemInfo->uAllocSize / sizeof(*pui32TA3DCtlBuffer); ui32LoopCounter += 4) { PVR_LOG(("\t(T3C-%X) 0x%08X 0x%08X 0x%08X 0x%08X", ui32LoopCounter * sizeof(*pui32TA3DCtlBuffer), @@ -994,6 +1152,10 @@ static IMG_VOID SGXDumpDebugInfo (PVRSRV_SGXDEV_INFO *psDevInfo, } #endif } + #if defined (TTRACE) + PVRSRVDumpTimeTraceBuffers(); + #endif + } @@ -1036,9 +1198,8 @@ IMG_VOID HWRecoveryResetSGX (PVRSRV_DEVICE_NODE *psDeviceNode, for (eError = PVRSRV_ERROR_RETRY; eError == PVRSRV_ERROR_RETRY;) #endif { - eError = SGXInitialise(psDevInfo, IMG_TRUE); + eError = SGXInitialise(psDevInfo, IMG_TRUE); } - if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"HWRecoveryResetSGX: SGXInitialise failed (%d)", eError)); @@ -1054,7 +1215,7 @@ IMG_VOID HWRecoveryResetSGX (PVRSRV_DEVICE_NODE *psDeviceNode, - PVRSRVProcessQueues(ui32CallerID, IMG_TRUE); + PVRSRVProcessQueues(IMG_TRUE); } #endif @@ -1066,11 +1227,13 @@ IMG_VOID SGXOSTimer(IMG_VOID *pvData) PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; static IMG_UINT32 ui32EDMTasks = 0; static IMG_UINT32 ui32LockupCounter = 0; + static IMG_UINT32 ui32OpenCLDelayCounter = 0; static IMG_UINT32 ui32NumResets = 0; #if defined(FIX_HW_BRN_31093) static IMG_BOOL bBRN31093Inval = IMG_FALSE; #endif IMG_UINT32 ui32CurrentEDMTasks; + IMG_UINT32 ui32CurrentOpenCLDelayCounter=0; IMG_BOOL bLockup = IMG_FALSE; IMG_BOOL bPoweredDown; @@ -1107,14 +1270,26 @@ IMG_VOID SGXOSTimer(IMG_VOID *pvData) if (ui32LockupCounter == 3) { ui32LockupCounter = 0; - + ui32CurrentOpenCLDelayCounter = (psDevInfo->psSGXHostCtl)->ui32OpenCLDelayCount; + if(0 != ui32CurrentOpenCLDelayCounter) + { + if(ui32OpenCLDelayCounter != ui32CurrentOpenCLDelayCounter){ + ui32OpenCLDelayCounter = ui32CurrentOpenCLDelayCounter; + }else{ + ui32OpenCLDelayCounter -= 1; + (psDevInfo->psSGXHostCtl)->ui32OpenCLDelayCount = ui32OpenCLDelayCounter; + } + goto SGX_NoUKernel_LockUp; + } + + #if defined(FIX_HW_BRN_31093) if (bBRN31093Inval == IMG_FALSE) { #if defined(FIX_HW_BRN_29997) IMG_UINT32 ui32BIFCtrl; - + ui32BIFCtrl = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_CTRL); OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_CTRL, ui32BIFCtrl | EUR_CR_BIF_CTRL_PAUSE_MASK); @@ -1138,6 +1313,7 @@ IMG_VOID SGXOSTimer(IMG_VOID *pvData) PVR_DPF((PVR_DBG_ERROR, "SGXOSTimer() detected SGX lockup (0x%x tasks)", ui32EDMTasks)); bLockup = IMG_TRUE; + (psDevInfo->psSGXHostCtl)->ui32OpenCLDelayCount = 0; } } } @@ -1151,6 +1327,7 @@ IMG_VOID SGXOSTimer(IMG_VOID *pvData) ui32NumResets = psDevInfo->ui32NumResets; } } +SGX_NoUKernel_LockUp: if (bLockup) { @@ -1160,12 +1337,13 @@ IMG_VOID SGXOSTimer(IMG_VOID *pvData) psSGXHostCtl->ui32HostDetectedLockups ++; - HWRecoveryResetSGX(psDeviceNode, 0, KERNEL_ID); + HWRecoveryResetSGX(psDeviceNode, 0, ISR_ID); } } #endif + #if defined(SYS_USING_INTERRUPTS) IMG_BOOL SGX_ISRHandler (IMG_VOID *pvData) @@ -1267,78 +1445,25 @@ static IMG_VOID SGX_MISRHandler (IMG_VOID *pvData) } #endif - - #if defined(SUPPORT_MEMORY_TILING) + +IMG_INTERNAL PVRSRV_ERROR SGX_AllocMemTilingRange(PVRSRV_DEVICE_NODE *psDeviceNode, - PVRSRV_KERNEL_MEM_INFO *psMemInfo, - IMG_UINT32 ui32TilingStride, - IMG_UINT32 *pui32RangeIndex) + PVRSRV_KERNEL_MEM_INFO *psMemInfo, + IMG_UINT32 ui32XTileStride, + IMG_UINT32 *pui32RangeIndex) { -#if defined(SGX_FEATURE_BIF_WIDE_TILING_AND_4K_ADDRESS) - PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; - IMG_UINT32 i; - IMG_UINT32 ui32Start; - IMG_UINT32 ui32End; - IMG_UINT32 ui32Offset; - IMG_UINT32 ui32Val; - - - for(i=0; i<10; i++) - { - if((psDevInfo->ui32MemTilingUsage & (1U << i)) == 0) - { - - psDevInfo->ui32MemTilingUsage |= 1U << i; - - *pui32RangeIndex = i; - goto RangeAllocated; - } - } - - PVR_DPF((PVR_DBG_ERROR,"SGX_AllocMemTilingRange: all tiling ranges in use")); - return PVRSRV_ERROR_EXCEEDED_HW_LIMITS; - -RangeAllocated: - ui32Offset = EUR_CR_BIF_TILE0 + (i<<2); - - ui32Start = psMemInfo->sDevVAddr.uiAddr; - ui32End = ui32Start + psMemInfo->ui32AllocSize + SGX_MMU_PAGE_SIZE - 1; - - ui32Val = ((ui32TilingStride << EUR_CR_BIF_TILE0_CFG_SHIFT) & EUR_CR_BIF_TILE0_CFG_MASK) - | (((ui32End>>20) << EUR_CR_BIF_TILE0_MAX_ADDRESS_SHIFT) & EUR_CR_BIF_TILE0_MAX_ADDRESS_MASK) - | (((ui32Start>>20) << EUR_CR_BIF_TILE0_MIN_ADDRESS_SHIFT) & EUR_CR_BIF_TILE0_MIN_ADDRESS_MASK) - | (0x8 << EUR_CR_BIF_TILE0_CFG_SHIFT); - - - OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32Offset, ui32Val); - PDUMPREG(SGX_PDUMPREG_NAME, ui32Offset, ui32Val); - - ui32Offset = EUR_CR_BIF_TILE0_ADDR_EXT + (i<<2); - - ui32Val = (((ui32End>>12) << EUR_CR_BIF_TILE0_ADDR_EXT_MAX_SHIFT) & EUR_CR_BIF_TILE0_ADDR_EXT_MAX_MASK) - | (((ui32Start>>12) << EUR_CR_BIF_TILE0_ADDR_EXT_MIN_SHIFT) & EUR_CR_BIF_TILE0_ADDR_EXT_MIN_MASK); - - - OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32Offset, ui32Val); - PDUMPREG(SGX_PDUMPREG_NAME, ui32Offset, ui32Val); - - return PVRSRV_OK; -#else - PVR_UNREFERENCED_PARAMETER(psDeviceNode); - PVR_UNREFERENCED_PARAMETER(psMemInfo); - PVR_UNREFERENCED_PARAMETER(ui32TilingStride); - PVR_UNREFERENCED_PARAMETER(pui32RangeIndex); - - PVR_DPF((PVR_DBG_ERROR,"SGX_AllocMemTilingRange: device does not support memory tiling")); - return PVRSRV_ERROR_NOT_SUPPORTED; -#endif + return SGX_AllocMemTilingRangeInt(psDeviceNode->pvDevice, + psMemInfo->sDevVAddr.uiAddr, + psMemInfo->sDevVAddr.uiAddr + ((IMG_UINT32) psMemInfo->uAllocSize) + SGX_MMU_PAGE_SIZE - 1, + ui32XTileStride, + pui32RangeIndex); } +IMG_INTERNAL PVRSRV_ERROR SGX_FreeMemTilingRange(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_UINT32 ui32RangeIndex) { -#if defined(SGX_FEATURE_BIF_WIDE_TILING_AND_4K_ADDRESS) PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; IMG_UINT32 ui32Offset; IMG_UINT32 ui32Val; @@ -1361,16 +1486,21 @@ PVRSRV_ERROR SGX_FreeMemTilingRange(PVRSRV_DEVICE_NODE *psDeviceNode, PDUMPREG(SGX_PDUMPREG_NAME, ui32Offset, ui32Val); return PVRSRV_OK; -#else - PVR_UNREFERENCED_PARAMETER(psDeviceNode); - PVR_UNREFERENCED_PARAMETER(ui32RangeIndex); - - PVR_DPF((PVR_DBG_ERROR,"SGX_FreeMemTilingRange: device does not support memory tiling")); - return PVRSRV_ERROR_NOT_SUPPORTED; -#endif } -#endif +#endif + + +static IMG_VOID SGXCacheInvalidate(PVRSRV_DEVICE_NODE *psDeviceNode) +{ + PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; + + #if defined(SGX_FEATURE_MP) + psDevInfo->ui32CacheControl |= SGXMKIF_CC_INVAL_BIF_SL; + #else + PVR_UNREFERENCED_PARAMETER(psDevInfo); + #endif +} PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode) { @@ -1420,7 +1550,13 @@ PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode) #if defined(SUPPORT_PDUMP_MULTI_PROCESS) psDeviceNode->pfnMMUIsHeapShared = &MMU_IsHeapShared; #endif - +#if defined(FIX_HW_BRN_31620) + psDeviceNode->pfnMMUGetCacheFlushRange = &MMU_GetCacheFlushRange; + psDeviceNode->pfnMMUGetPDPhysAddr = &MMU_GetPDPhysAddr; +#else + psDeviceNode->pfnMMUGetCacheFlushRange = IMG_NULL; + psDeviceNode->pfnMMUGetPDPhysAddr = IMG_NULL; +#endif #if defined (SYS_USING_INTERRUPTS) @@ -1437,6 +1573,8 @@ PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode) psDeviceNode->pfnDeviceCommandComplete = &SGXCommandComplete; + psDeviceNode->pfnCacheInvalidate = SGXCacheInvalidate; + psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; @@ -1480,6 +1618,23 @@ PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode) #endif psDeviceMemoryHeap++; +#if defined(SUPPORT_MEMORY_TILING) + + psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_VPB_TILED_HEAP_ID); + psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_VPB_TILED_HEAP_BASE; + psDeviceMemoryHeap->ui32HeapSize = SGX_VPB_TILED_HEAP_SIZE; + psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE + | PVRSRV_MEM_RAM_BACKED_ALLOCATION + | PVRSRV_HAP_SINGLE_PROCESS; + psDeviceMemoryHeap->pszName = "VPB Tiled"; + psDeviceMemoryHeap->pszBSName = "VPB Tiled BS"; + psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_PERCONTEXT; + + psDeviceMemoryHeap->ui32DataPageSize = SGX_MMU_PAGE_SIZE; + psDeviceMemoryHeap->ui32XTileStride = SGX_VPB_TILED_HEAP_STRIDE; + PVR_DPF((PVR_DBG_WARNING, "VPB tiling heap tiling stride = 0x%x", psDeviceMemoryHeap->ui32XTileStride)); + psDeviceMemoryHeap++; +#endif psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_TADATA_HEAP_ID); @@ -1613,22 +1768,30 @@ PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode) - psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_3DPARAMETERS_HEAP_ID); - psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_3DPARAMETERS_HEAP_BASE; - psDeviceMemoryHeap->ui32HeapSize = SGX_3DPARAMETERS_HEAP_SIZE; - psDeviceMemoryHeap->pszName = "3DParameters"; - psDeviceMemoryHeap->pszBSName = "3DParameters BS"; -#if defined(SUPPORT_PERCONTEXT_PB) - psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE - | PVRSRV_MEM_RAM_BACKED_ALLOCATION - | PVRSRV_HAP_SINGLE_PROCESS; - psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_PERCONTEXT; -#else + psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_SHARED_3DPARAMETERS_HEAP_ID); + psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_SHARED_3DPARAMETERS_HEAP_BASE; + psDeviceMemoryHeap->ui32HeapSize = SGX_SHARED_3DPARAMETERS_HEAP_SIZE; + psDeviceMemoryHeap->pszName = "Shared 3DParameters"; + psDeviceMemoryHeap->pszBSName = "Shared 3DParameters BS"; psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE | PVRSRV_MEM_RAM_BACKED_ALLOCATION | PVRSRV_HAP_MULTI_PROCESS; psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_SHARED_EXPORTED; -#endif + + + psDeviceMemoryHeap->ui32DataPageSize = SGX_MMU_PAGE_SIZE; + psDeviceMemoryHeap++; + + + psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_PERCONTEXT_3DPARAMETERS_HEAP_ID); + psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_PERCONTEXT_3DPARAMETERS_HEAP_BASE; + psDeviceMemoryHeap->ui32HeapSize = SGX_PERCONTEXT_3DPARAMETERS_HEAP_SIZE; + psDeviceMemoryHeap->pszName = "Percontext 3DParameters"; + psDeviceMemoryHeap->pszBSName = "Percontext 3DParameters BS"; + psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE + | PVRSRV_MEM_RAM_BACKED_ALLOCATION + | PVRSRV_HAP_SINGLE_PROCESS; + psDeviceMemoryHeap->DevMemHeapType = DEVICE_MEMORY_HEAP_PERCONTEXT; psDeviceMemoryHeap->ui32DataPageSize = SGX_MMU_PAGE_SIZE; psDeviceMemoryHeap++; @@ -1639,7 +1802,9 @@ PVRSRV_ERROR SGXRegisterDevice (PVRSRV_DEVICE_NODE *psDeviceNode) psDeviceMemoryHeap->ui32HeapID = HEAP_ID( PVRSRV_DEVICE_TYPE_SGX, SGX_GENERAL_MAPPING_HEAP_ID); psDeviceMemoryHeap->sDevVAddrBase.uiAddr = SGX_GENERAL_MAPPING_HEAP_BASE; psDeviceMemoryHeap->ui32HeapSize = SGX_GENERAL_MAPPING_HEAP_SIZE; - psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_MULTI_PROCESS; + psDeviceMemoryHeap->ui32Attribs = PVRSRV_HAP_WRITECOMBINE + | PVRSRV_MEM_RAM_BACKED_ALLOCATION + | PVRSRV_HAP_MULTI_PROCESS; psDeviceMemoryHeap->pszName = "GeneralMapping"; psDeviceMemoryHeap->pszBSName = "GeneralMapping BS"; #if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) && defined(FIX_HW_BRN_23410) @@ -1815,7 +1980,7 @@ PVRSRV_ERROR SGXDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode) psSGXMiscInfoInt = psMemInfo->pvLinAddrKM; psSGXMiscInfoInt->ui32MiscInfoFlags = 0; psSGXMiscInfoInt->ui32MiscInfoFlags |= PVRSRV_USSE_MISCINFO_GET_STRUCT_SIZES; - eError = SGXGetMiscInfoUkernel(psDevInfo, psDeviceNode); + eError = SGXGetMiscInfoUkernel(psDevInfo, psDeviceNode, IMG_NULL); if(eError != PVRSRV_OK) @@ -1833,7 +1998,6 @@ PVRSRV_ERROR SGXDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode) PVR_LOG(("(FAIL) SGXInit: Incompatible driver DDK revision (%d)/device DDK revision (%d).", PVRVERSION_BUILD, psSGXFeatures->ui32DDKBuild)); eError = PVRSRV_ERROR_DDK_VERSION_MISMATCH; - PVR_DBG_BREAK; goto chk_exit; } else @@ -1956,7 +2120,8 @@ chk_exit: static PVRSRV_ERROR SGXGetMiscInfoUkernel(PVRSRV_SGXDEV_INFO *psDevInfo, - PVRSRV_DEVICE_NODE *psDeviceNode) + PVRSRV_DEVICE_NODE *psDeviceNode, + IMG_HANDLE hDevMemContext) { PVRSRV_ERROR eError; SGXMKIF_COMMAND sCommandData; @@ -1990,6 +2155,7 @@ PVRSRV_ERROR SGXGetMiscInfoUkernel(PVRSRV_SGXDEV_INFO *psDevInfo, &sCommandData, KERNEL_ID, 0, + hDevMemContext, IMG_FALSE); if (eError != PVRSRV_OK) @@ -2101,6 +2267,7 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, &sCommandData, KERNEL_ID, 0, + hDevMemContext, IMG_FALSE); if (eError != PVRSRV_OK) @@ -2140,37 +2307,6 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, return PVRSRV_OK; } - case SGX_MISC_INFO_REQUEST_WAIT_FOR_BREAKPOINT: - { - - - PDUMPCOMMENT("Wait for data breakpoint hit"); - -#if defined(NO_HARDWARE) && defined(PDUMP) - { - PDUMPREGPOL(SGX_PDUMPREG_NAME, - EUR_CR_EVENT_STATUS2, - EUR_CR_EVENT_STATUS2_DATA_BREAKPOINT_TRAPPED_MASK, - EUR_CR_EVENT_STATUS2_DATA_BREAKPOINT_TRAPPED_MASK); - - PDUMPREG(SGX_PDUMPREG_NAME, - EUR_CR_EVENT_HOST_CLEAR2, - EUR_CR_EVENT_HOST_CLEAR2_DATA_BREAKPOINT_TRAPPED_MASK); - - PDUMPCOMMENT("Breakpoint detected. Wait a bit to show that pipeline stops in simulation"); - PDUMPIDL(2000); - - PDUMPCOMMENT("Now we can resume"); - PDUMPREG(SGX_PDUMPREG_NAME, EUR_CR_BREAKPOINT_TRAP, EUR_CR_BREAKPOINT_TRAP_WRNOTIFY_MASK | EUR_CR_BREAKPOINT_TRAP_CONTINUE_MASK); - } -#else - { - - } -#endif - return PVRSRV_OK; - } - case SGX_MISC_INFO_REQUEST_POLL_BREAKPOINT: { @@ -2181,40 +2317,114 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, #if !defined(NO_HARDWARE) +#if defined(SGX_FEATURE_MP) IMG_BOOL bTrappedBPMaster; - IMG_BOOL abTrappedBPPerCore[SGX_FEATURE_MP_CORE_COUNT]; IMG_UINT32 ui32CoreNum, ui32TrappedBPCoreNum; +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + IMG_UINT32 ui32PipeNum, ui32TrappedBPPipeNum; +#define NUM_PIPES_PLUS_ONE (SGX_FEATURE_PERPIPE_BKPT_REGS_NUMPIPES+1) +#endif IMG_BOOL bTrappedBPAny; +#endif + IMG_BOOL bFoundOne; +#if defined(SGX_FEATURE_MP) ui32TrappedBPCoreNum = 0; bTrappedBPMaster = !!(EUR_CR_MASTER_BREAKPOINT_TRAPPED_MASK & OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_BREAKPOINT)); bTrappedBPAny = bTrappedBPMaster; - for (ui32CoreNum = 0; ui32CoreNum < SGX_FEATURE_MP_CORE_COUNT; ui32CoreNum++) +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + ui32TrappedBPPipeNum = 0; +#endif + for (ui32CoreNum = 0; ui32CoreNum < SGX_FEATURE_MP_CORE_COUNT_3D; ui32CoreNum++) { - abTrappedBPPerCore[ui32CoreNum] = !!(EUR_CR_BREAKPOINT_TRAPPED_MASK & OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BREAKPOINT, ui32CoreNum))); - if (abTrappedBPPerCore[ui32CoreNum]) +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + + + +#define SGX_MP_CORE_PIPE_SELECT(r,c,p) \ + ((SGX_MP_CORE_SELECT(EUR_CR_PARTITION_##r,c) + p*(EUR_CR_PIPE0_##r-EUR_CR_PARTITION_##r))) + for (ui32PipeNum = 0; ui32PipeNum < NUM_PIPES_PLUS_ONE; ui32PipeNum++) + { + bFoundOne = + 0 != (EUR_CR_PARTITION_BREAKPOINT_TRAPPED_MASK & + OSReadHWReg(psDevInfo->pvRegsBaseKM, + SGX_MP_CORE_PIPE_SELECT(BREAKPOINT, + ui32CoreNum, + ui32PipeNum))); + if (bFoundOne) + { + bTrappedBPAny = IMG_TRUE; + ui32TrappedBPCoreNum = ui32CoreNum; + ui32TrappedBPPipeNum = ui32PipeNum; + } + } +#else + bFoundOne = !!(EUR_CR_BREAKPOINT_TRAPPED_MASK & OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BREAKPOINT, ui32CoreNum))); + if (bFoundOne) { bTrappedBPAny = IMG_TRUE; ui32TrappedBPCoreNum = ui32CoreNum; } +#endif } psMiscInfo->uData.sSGXBreakpointInfo.bTrappedBP = bTrappedBPAny; +#else +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + #error Not yet considered the case for per-pipe regs in non-mp case +#endif + psMiscInfo->uData.sSGXBreakpointInfo.bTrappedBP = 0 != (EUR_CR_BREAKPOINT_TRAPPED_MASK & OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BREAKPOINT)); +#endif if (psMiscInfo->uData.sSGXBreakpointInfo.bTrappedBP) { IMG_UINT32 ui32Info0, ui32Info1; +#if defined(SGX_FEATURE_MP) +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + ui32Info0 = OSReadHWReg(psDevInfo->pvRegsBaseKM, bTrappedBPMaster?EUR_CR_MASTER_BREAKPOINT_TRAP_INFO0:SGX_MP_CORE_PIPE_SELECT(BREAKPOINT_TRAP_INFO0, ui32TrappedBPCoreNum, ui32TrappedBPPipeNum)); + ui32Info1 = OSReadHWReg(psDevInfo->pvRegsBaseKM, bTrappedBPMaster?EUR_CR_MASTER_BREAKPOINT_TRAP_INFO1:SGX_MP_CORE_PIPE_SELECT(BREAKPOINT_TRAP_INFO1, ui32TrappedBPCoreNum, ui32TrappedBPPipeNum)); +#else ui32Info0 = OSReadHWReg(psDevInfo->pvRegsBaseKM, bTrappedBPMaster?EUR_CR_MASTER_BREAKPOINT_TRAP_INFO0:SGX_MP_CORE_SELECT(EUR_CR_BREAKPOINT_TRAP_INFO0, ui32TrappedBPCoreNum)); ui32Info1 = OSReadHWReg(psDevInfo->pvRegsBaseKM, bTrappedBPMaster?EUR_CR_MASTER_BREAKPOINT_TRAP_INFO1:SGX_MP_CORE_SELECT(EUR_CR_BREAKPOINT_TRAP_INFO1, ui32TrappedBPCoreNum)); +#endif +#else + ui32Info0 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BREAKPOINT_TRAP_INFO0); + ui32Info1 = OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BREAKPOINT_TRAP_INFO1); +#endif +#ifdef SGX_FEATURE_PERPIPE_BKPT_REGS + psMiscInfo->uData.sSGXBreakpointInfo.ui32BPIndex = (ui32Info1 & EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_NUMBER_MASK) >> EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_NUMBER_SHIFT; + psMiscInfo->uData.sSGXBreakpointInfo.sTrappedBPDevVAddr.uiAddr = ui32Info0 & EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO0_ADDRESS_MASK; + psMiscInfo->uData.sSGXBreakpointInfo.ui32TrappedBPBurstLength = (ui32Info1 & EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_SIZE_MASK) >> EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_SIZE_SHIFT; + psMiscInfo->uData.sSGXBreakpointInfo.bTrappedBPRead = !!(ui32Info1 & EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_RNW_MASK); + psMiscInfo->uData.sSGXBreakpointInfo.ui32TrappedBPDataMaster = (ui32Info1 & EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_DATA_MASTER_MASK) >> EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_DATA_MASTER_SHIFT; + psMiscInfo->uData.sSGXBreakpointInfo.ui32TrappedBPTag = (ui32Info1 & EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_TAG_MASK) >> EUR_CR_PARTITION_BREAKPOINT_TRAP_INFO1_TAG_SHIFT; +#else psMiscInfo->uData.sSGXBreakpointInfo.ui32BPIndex = (ui32Info1 & EUR_CR_BREAKPOINT_TRAP_INFO1_NUMBER_MASK) >> EUR_CR_BREAKPOINT_TRAP_INFO1_NUMBER_SHIFT; psMiscInfo->uData.sSGXBreakpointInfo.sTrappedBPDevVAddr.uiAddr = ui32Info0 & EUR_CR_BREAKPOINT_TRAP_INFO0_ADDRESS_MASK; psMiscInfo->uData.sSGXBreakpointInfo.ui32TrappedBPBurstLength = (ui32Info1 & EUR_CR_BREAKPOINT_TRAP_INFO1_SIZE_MASK) >> EUR_CR_BREAKPOINT_TRAP_INFO1_SIZE_SHIFT; psMiscInfo->uData.sSGXBreakpointInfo.bTrappedBPRead = !!(ui32Info1 & EUR_CR_BREAKPOINT_TRAP_INFO1_RNW_MASK); psMiscInfo->uData.sSGXBreakpointInfo.ui32TrappedBPDataMaster = (ui32Info1 & EUR_CR_BREAKPOINT_TRAP_INFO1_DATA_MASTER_MASK) >> EUR_CR_BREAKPOINT_TRAP_INFO1_DATA_MASTER_SHIFT; psMiscInfo->uData.sSGXBreakpointInfo.ui32TrappedBPTag = (ui32Info1 & EUR_CR_BREAKPOINT_TRAP_INFO1_TAG_MASK) >> EUR_CR_BREAKPOINT_TRAP_INFO1_TAG_SHIFT; +#endif +#if defined(SGX_FEATURE_MP) +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + + psMiscInfo->uData.sSGXBreakpointInfo.ui32CoreNum = bTrappedBPMaster?65535:(ui32TrappedBPCoreNum + (ui32TrappedBPPipeNum<<10)); +#else + psMiscInfo->uData.sSGXBreakpointInfo.ui32CoreNum = bTrappedBPMaster?65535:ui32TrappedBPCoreNum; +#endif +#else +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + +#error non-mp perpipe regs not yet supported +#else + + psMiscInfo->uData.sSGXBreakpointInfo.ui32CoreNum = 65534; +#endif +#endif } #endif return PVRSRV_OK; @@ -2226,12 +2436,24 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, #if !defined(NO_HARDWARE) +#if defined(SGX_FEATURE_MP) IMG_UINT32 ui32CoreNum; IMG_BOOL bMaster; +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + IMG_UINT32 ui32PipeNum; +#endif +#endif IMG_UINT32 ui32OldSeqNum, ui32NewSeqNum; +#if defined(SGX_FEATURE_MP) +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + ui32PipeNum = psMiscInfo->uData.sSGXBreakpointInfo.ui32CoreNum >> 10; + ui32CoreNum = psMiscInfo->uData.sSGXBreakpointInfo.ui32CoreNum & 1023; + bMaster = psMiscInfo->uData.sSGXBreakpointInfo.ui32CoreNum > 32767; +#else ui32CoreNum = psMiscInfo->uData.sSGXBreakpointInfo.ui32CoreNum; - bMaster = ui32CoreNum > SGX_FEATURE_MP_CORE_COUNT; + bMaster = ui32CoreNum > SGX_FEATURE_MP_CORE_COUNT_3D; +#endif if (bMaster) { @@ -2245,8 +2467,18 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, while (ui32OldSeqNum == ui32NewSeqNum); } else +#endif { +#if defined(SGX_FEATURE_PERPIPE_BKPT_REGS) + ui32OldSeqNum = 0x1c & OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_PIPE_SELECT(BREAKPOINT, ui32CoreNum, ui32PipeNum)); + OSWriteHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_PIPE_SELECT(BREAKPOINT_TRAP, ui32CoreNum, ui32PipeNum), EUR_CR_PARTITION_BREAKPOINT_TRAP_WRNOTIFY_MASK | EUR_CR_PARTITION_BREAKPOINT_TRAP_CONTINUE_MASK); + do + { + ui32NewSeqNum = 0x1c & OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_PIPE_SELECT(BREAKPOINT, ui32CoreNum, ui32PipeNum)); + } + while (ui32OldSeqNum == ui32NewSeqNum); +#else ui32OldSeqNum = 0x1c & OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BREAKPOINT, ui32CoreNum)); OSWriteHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BREAKPOINT_TRAP, ui32CoreNum), EUR_CR_BREAKPOINT_TRAP_WRNOTIFY_MASK | EUR_CR_BREAKPOINT_TRAP_CONTINUE_MASK); do @@ -2254,6 +2486,7 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, ui32NewSeqNum = 0x1c & OSReadHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BREAKPOINT, ui32CoreNum)); } while (ui32OldSeqNum == ui32NewSeqNum); +#endif } #endif return PVRSRV_OK; @@ -2293,7 +2526,7 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, case SGX_MISC_INFO_REQUEST_SGXREV: { PVRSRV_SGX_MISCINFO_FEATURES *psSGXFeatures; - eError = SGXGetMiscInfoUkernel(psDevInfo, psDeviceNode); + eError = SGXGetMiscInfoUkernel(psDevInfo, psDeviceNode, hDevMemContext); if(eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "An error occurred in SGXGetMiscInfoUkernel: %d\n", @@ -2483,6 +2716,7 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, &sCommandData, KERNEL_ID, 0, + hDevMemContext, IMG_FALSE); return eError; } @@ -2498,6 +2732,8 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, return PVRSRV_OK; } +#if defined(DEBUG) + case SGX_MISC_INFO_PANIC: { PVR_LOG(("User requested SGX panic")); @@ -2506,6 +2742,7 @@ PVRSRV_ERROR SGXGetMiscInfoKM(PVRSRV_SGXDEV_INFO *psDevInfo, return PVRSRV_OK; } +#endif default: { @@ -2537,6 +2774,8 @@ PVRSRV_ERROR SGXReadHWPerfCBKM(IMG_HANDLE hDevHandle, SGXMKIF_HWPERF_CB_ENTRY *psMKPerfEntry = &psHWPerfCB->psHWPerfCBData[psHWPerfCB->ui32Roff]; psClientHWPerfEntry[i].ui32FrameNo = psMKPerfEntry->ui32FrameNo; + psClientHWPerfEntry[i].ui32PID = psMKPerfEntry->ui32PID; + psClientHWPerfEntry[i].ui32RTData = psMKPerfEntry->ui32RTData; psClientHWPerfEntry[i].ui32Type = psMKPerfEntry->ui32Type; psClientHWPerfEntry[i].ui32Ordinal = psMKPerfEntry->ui32Ordinal; psClientHWPerfEntry[i].ui32Info = psMKPerfEntry->ui32Info; @@ -2547,6 +2786,10 @@ PVRSRV_ERROR SGXReadHWPerfCBKM(IMG_HANDLE hDevHandle, &psMKPerfEntry->ui32Counters[0][0], sizeof(psMKPerfEntry->ui32Counters)); + OSMemCopy(&psClientHWPerfEntry[i].ui32MiscCounters[0][0], + &psMKPerfEntry->ui32MiscCounters[0][0], + sizeof(psMKPerfEntry->ui32MiscCounters)); + psHWPerfCB->ui32Roff = (psHWPerfCB->ui32Roff + 1) & (SGXMKIF_HWPERF_CB_SIZE - 1); } diff --git a/drivers/gpu/pvr/sgx/sgxkick.c b/drivers/gpu/pvr/sgx/sgxkick.c index 581640b..cbac38e 100644 --- a/drivers/gpu/pvr/sgx/sgxkick.c +++ b/drivers/gpu/pvr/sgx/sgxkick.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -36,29 +36,48 @@ #include "osfunc.h" #include "pvr_debug.h" #include "sgxutils.h" +#include "ttrace.h" IMG_EXPORT +#if defined (SUPPORT_SID_INTERFACE) +PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK_KM *psCCBKick) +#else PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) +#endif { PVRSRV_ERROR eError; PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *) psCCBKick->hCCBKernelMemInfo; SGXMKIF_CMDTA_SHARED *psTACmd; IMG_UINT32 i; + IMG_HANDLE hDevMemContext = IMG_NULL; +#if defined(FIX_HW_BRN_31620) + hDevMemContext = psCCBKick->hDevMemContext; +#endif + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_ENTER, KICK_TOKEN_DOKICK); if (!CCB_OFFSET_IS_VALID(SGXMKIF_CMDTA_SHARED, psCCBMemInfo, psCCBKick, ui32CCBOffset)) { PVR_DPF((PVR_DBG_ERROR, "SGXDoKickKM: Invalid CCB offset")); + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, KICK_TOKEN_DOKICK); return PVRSRV_ERROR_INVALID_PARAMS; } psTACmd = CCB_DATA_FROM_OFFSET(SGXMKIF_CMDTA_SHARED, psCCBMemInfo, psCCBKick, ui32CCBOffset); + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_CMD_START, KICK_TOKEN_DOKICK); + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_CCB, + KICK_TOKEN_CCB_OFFSET, psCCBKick->ui32CCBOffset); + if (psCCBKick->hTA3DSyncInfo) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTA3DSyncInfo; + + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_KICK, KICK_TOKEN_TA3D_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + psTACmd->sTA3DDependency.sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; psTACmd->sTA3DDependency.ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; @@ -73,6 +92,9 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTASyncInfo; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_KICK, KICK_TOKEN_TA_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + psTACmd->sTATQSyncReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; psTACmd->sTATQSyncWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; @@ -84,6 +106,9 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->h3DSyncInfo; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_KICK, KICK_TOKEN_3D_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + psTACmd->s3DTQSyncReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; psTACmd->s3DTQSyncWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; @@ -174,6 +199,9 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *) psCCBKick->ahSrcKernelSyncInfo[i]; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_KICK, KICK_TOKEN_SRC_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + psTACmd->asSrcSyncs[i].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; psTACmd->asSrcSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; @@ -191,7 +219,7 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) SGXMKIF_HWDEVICE_SYNC_LIST *psHWDeviceSyncList = psHWDstSyncListMemInfo->pvLinAddrKM; IMG_UINT32 ui32NumDstSyncs = psCCBKick->ui32NumDstSyncObjects; - PVR_ASSERT(((PVRSRV_KERNEL_MEM_INFO *)psCCBKick->hKernelHWSyncListMemInfo)->ui32AllocSize >= (sizeof(SGXMKIF_HWDEVICE_SYNC_LIST) + + PVR_ASSERT(((PVRSRV_KERNEL_MEM_INFO *)psCCBKick->hKernelHWSyncListMemInfo)->uAllocSize >= (sizeof(SGXMKIF_HWDEVICE_SYNC_LIST) + (sizeof(PVRSRV_DEVICE_SYNC_OBJECT) * ui32NumDstSyncs))); psHWDeviceSyncList->ui32NumSyncObjects = ui32NumDstSyncs; @@ -214,11 +242,17 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) if (psSyncInfo) { + + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_KICK, KICK_TOKEN_DST_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + psHWDeviceSyncList->asSyncData[i].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; psHWDeviceSyncList->asSyncData[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + psHWDeviceSyncList->asSyncData[i].sReadOps2CompleteDevVAddr = psSyncInfo->sReadOps2CompleteDevVAddr; psHWDeviceSyncList->asSyncData[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; psHWDeviceSyncList->asSyncData[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; + psHWDeviceSyncList->asSyncData[i].ui32ReadOps2PendingVal = psSyncInfo->psSyncData->ui32ReadOps2Pending; #if defined(PDUMP) if (PDumpIsCaptureFrameKM()) @@ -230,6 +264,8 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal); IMG_UINT32 ui32ROpsOffset = ui32SyncOffset + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal); + IMG_UINT32 ui32ROps2Offset = ui32SyncOffset + + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOps2PendingVal); PDUMPCOMMENT("HWDeviceSyncObject for RT: %i\r\n", i); @@ -283,6 +319,15 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psHWDstSyncListMemInfo)); + + + PDUMPCOMMENT("Modify RT %d ROps2PendingVal in HWDevSyncList\r\n", i); + PDUMPMEM(&ui32ModifiedValue, + psHWDstSyncListMemInfo, + ui32ROps2Offset, + sizeof(IMG_UINT32), + 0, + MAKEUNIQUETAG(psHWDstSyncListMemInfo)); } #endif } @@ -290,8 +335,10 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) { psHWDeviceSyncList->asSyncData[i].sWriteOpsCompleteDevVAddr.uiAddr = 0; psHWDeviceSyncList->asSyncData[i].sReadOpsCompleteDevVAddr.uiAddr = 0; + psHWDeviceSyncList->asSyncData[i].sReadOps2CompleteDevVAddr.uiAddr = 0; psHWDeviceSyncList->asSyncData[i].ui32ReadOpsPendingVal = 0; + psHWDeviceSyncList->asSyncData[i].ui32ReadOps2PendingVal = 0; psHWDeviceSyncList->asSyncData[i].ui32WriteOpsPendingVal = 0; } } @@ -492,6 +539,14 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) sizeof(psSyncInfo->psSyncData->ui32WriteOpsComplete), 0, MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); + + PDUMPCOMMENT("Init RT WOpsComplete\r\n"); + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, + psSyncInfo->psSyncDataMemInfoKM, + offsetof(PVRSRV_SYNC_DATA, ui32ReadOps2Complete), + sizeof(psSyncInfo->psSyncData->ui32ReadOps2Complete), + 0, + MAKEUNIQUETAG(psSyncInfo->psSyncDataMemInfoKM)); } psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; @@ -550,7 +605,10 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) } #endif - eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_TA, &psCCBKick->sCommand, KERNEL_ID, 0, psCCBKick->bLastInScene); + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_CMD_END, + KICK_TOKEN_DOKICK); + + eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_TA, &psCCBKick->sCommand, KERNEL_ID, 0, hDevMemContext, psCCBKick->bLastInScene); if (eError == PVRSRV_ERROR_RETRY) { if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0) @@ -597,11 +655,15 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) } #endif + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + KICK_TOKEN_DOKICK); return eError; } else if (PVRSRV_OK != eError) { PVR_DPF((PVR_DBG_ERROR, "SGXDoKickKM: SGXScheduleCCBCommandKM failed.")); + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + KICK_TOKEN_DOKICK); return eError; } @@ -707,7 +769,8 @@ PVRSRV_ERROR SGXDoKickKM(IMG_HANDLE hDevHandle, SGX_CCB_KICK *psCCBKick) } } #endif - + PVR_TTRACE(PVRSRV_TRACE_GROUP_KICK, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + KICK_TOKEN_DOKICK); return eError; } diff --git a/drivers/gpu/pvr/sgx/sgxpower.c b/drivers/gpu/pvr/sgx/sgxpower.c index cd995c4..3947cdd 100644 --- a/drivers/gpu/pvr/sgx/sgxpower.c +++ b/drivers/gpu/pvr/sgx/sgxpower.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -192,18 +192,14 @@ static IMG_VOID SGXPollForClockGating (PVRSRV_SGXDEV_INFO *psDevInfo, #if !defined(NO_HARDWARE) PVR_ASSERT(psDevInfo != IMG_NULL); - /* + + if (PollForValueKM((IMG_UINT32 *)psDevInfo->pvRegsBaseKM + (ui32Register >> 2), 0, ui32RegisterValue, + MAX_HW_TIME_US, MAX_HW_TIME_US/WAIT_TRY_COUNT, - WAIT_TRY_COUNT) != PVRSRV_OK) - */ - if (PollForValueKM((IMG_UINT32 *)psDevInfo->pvRegsBaseKM + (ui32Register >> 2), - 0, - ui32RegisterValue, - 1000, - 500) != PVRSRV_OK) // for using msleep + IMG_FALSE) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXPollForClockGating: %s failed.", pszComment)); PVR_DBG_BREAK; @@ -211,7 +207,7 @@ static IMG_VOID SGXPollForClockGating (PVRSRV_SGXDEV_INFO *psDevInfo, #endif PDUMPCOMMENT("%s", pszComment); - PDUMPREGPOL(SGX_PDUMPREG_NAME, ui32Register, 0, ui32RegisterValue); + PDUMPREGPOL(SGX_PDUMPREG_NAME, ui32Register, 0, ui32RegisterValue, PDUMP_POLL_OPERATOR_EQUAL); } @@ -228,6 +224,7 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, IMG_UINT32 ui32PowerCmd, ui32CompleteStatus; SGXMKIF_COMMAND sCommand = {0}; IMG_UINT32 ui32Core; + IMG_UINT32 ui32CoresEnabled; #if defined(SUPPORT_HW_RECOVERY) @@ -256,7 +253,7 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, sCommand.ui32Data[1] = ui32PowerCmd; - eError = SGXScheduleCCBCommand(psDevInfo, SGXMKIF_CMD_POWER, &sCommand, KERNEL_ID, 0, IMG_FALSE); + eError = SGXScheduleCCBCommand(psDeviceNode, SGXMKIF_CMD_POWER, &sCommand, KERNEL_ID, 0, IMG_NULL, IMG_FALSE); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXPrePowerState: Failed to submit power down command")); @@ -268,8 +265,9 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, if (PollForValueKM(&psDevInfo->psSGXHostCtl->ui32PowerStatus, ui32CompleteStatus, ui32CompleteStatus, + MAX_HW_TIME_US, MAX_HW_TIME_US/WAIT_TRY_COUNT, - WAIT_TRY_COUNT) != PVRSRV_OK) + IMG_FALSE) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXPrePowerState: Wait for SGX ukernel power transition failed.")); PVR_DBG_BREAK; @@ -287,7 +285,13 @@ PVRSRV_ERROR SGXPrePowerState (IMG_HANDLE hDevHandle, MAKEUNIQUETAG(psDevInfo->psKernelSGXHostCtlMemInfo)); #endif - for (ui32Core = 0; ui32Core < SGX_FEATURE_MP_CORE_COUNT; ui32Core++) +#if defined(SGX_FEATURE_MP) + ui32CoresEnabled = ((OSReadHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_CORE) & EUR_CR_MASTER_CORE_ENABLE_MASK) >> EUR_CR_MASTER_CORE_ENABLE_SHIFT) + 1; +#else + ui32CoresEnabled = 1; +#endif + + for (ui32Core = 0; ui32Core < ui32CoresEnabled; ui32Core++) { SGXPollForClockGating(psDevInfo, @@ -376,7 +380,7 @@ PVRSRV_ERROR SGXPostPowerState (IMG_HANDLE hDevHandle, SGXMKIF_COMMAND sCommand = {0}; sCommand.ui32Data[1] = PVRSRV_POWERCMD_RESUME; - eError = SGXScheduleCCBCommand(psDevInfo, SGXMKIF_CMD_POWER, &sCommand, ISR_ID, 0, IMG_FALSE); + eError = SGXScheduleCCBCommand(psDeviceNode, SGXMKIF_CMD_POWER, &sCommand, ISR_ID, 0, IMG_NULL, IMG_FALSE); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXPostPowerState failed to schedule CCB command: %u", eError)); diff --git a/drivers/gpu/pvr/sgx/sgxreset.c b/drivers/gpu/pvr/sgx/sgxreset.c index 68d0e79..0baa11f 100644 --- a/drivers/gpu/pvr/sgx/sgxreset.c +++ b/drivers/gpu/pvr/sgx/sgxreset.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -33,38 +33,167 @@ #include "pdump_km.h" -static IMG_VOID SGXResetSoftReset(PVRSRV_SGXDEV_INFO *psDevInfo, - IMG_BOOL bResetBIF, - IMG_UINT32 ui32PDUMPFlags, - IMG_BOOL bPDump) +IMG_VOID SGXInitClocks(PVRSRV_SGXDEV_INFO *psDevInfo, + IMG_UINT32 ui32PDUMPFlags) { - IMG_UINT32 ui32SoftResetRegVal; + IMG_UINT32 ui32RegVal; + +#if !defined(PDUMP) + PVR_UNREFERENCED_PARAMETER(ui32PDUMPFlags); +#endif + + ui32RegVal = psDevInfo->ui32ClkGateCtl; + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_CLKGATECTL, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_CLKGATECTL, ui32RegVal, ui32PDUMPFlags); + +#if defined(EUR_CR_CLKGATECTL2) + ui32RegVal = psDevInfo->ui32ClkGateCtl2; + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_CLKGATECTL2, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_CLKGATECTL2, ui32RegVal, ui32PDUMPFlags); +#endif +} -#if defined(SGX_FEATURE_MP) - ui32SoftResetRegVal = - EUR_CR_MASTER_SOFT_RESET_IPF_RESET_MASK | - EUR_CR_MASTER_SOFT_RESET_DPM_RESET_MASK | - EUR_CR_MASTER_SOFT_RESET_VDM_RESET_MASK; -#if defined(SGX_FEATURE_PTLA) - ui32SoftResetRegVal |= EUR_CR_MASTER_SOFT_RESET_PTLA_RESET_MASK; -#endif -#if defined(SGX_FEATURE_SYSTEM_CACHE) - ui32SoftResetRegVal |= EUR_CR_MASTER_SOFT_RESET_SLC_RESET_MASK; -#endif +static IMG_VOID SGXResetInitBIFContexts(PVRSRV_SGXDEV_INFO *psDevInfo, + IMG_UINT32 ui32PDUMPFlags) +{ + IMG_UINT32 ui32RegVal; - if (bResetBIF) +#if !defined(PDUMP) + PVR_UNREFERENCED_PARAMETER(ui32PDUMPFlags); +#endif + + ui32RegVal = 0; + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_CTRL, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_CTRL, ui32RegVal, ui32PDUMPFlags); + +#if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Initialise the BIF bank settings\r\n"); + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK_SET, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_BANK_SET, ui32RegVal, ui32PDUMPFlags); + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK0, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_BANK0, ui32RegVal, ui32PDUMPFlags); +#endif + + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Initialise the BIF directory list\r\n"); + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_DIR_LIST_BASE0, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_DIR_LIST_BASE0, ui32RegVal, ui32PDUMPFlags); + +#if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) { - ui32SoftResetRegVal |= EUR_CR_MASTER_SOFT_RESET_BIF_RESET_MASK; + IMG_UINT32 ui32DirList, ui32DirListReg; + + for (ui32DirList = 1; + ui32DirList < SGX_FEATURE_BIF_NUM_DIRLISTS; + ui32DirList++) + { + ui32DirListReg = EUR_CR_BIF_DIR_LIST_BASE1 + 4 * (ui32DirList - 1); + OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32DirListReg, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, ui32DirListReg, ui32RegVal, ui32PDUMPFlags); + } } +#endif +} + + +static IMG_VOID SGXResetSetupBIFContexts(PVRSRV_SGXDEV_INFO *psDevInfo, + IMG_UINT32 ui32PDUMPFlags) +{ + IMG_UINT32 ui32RegVal; + +#if !defined(PDUMP) + PVR_UNREFERENCED_PARAMETER(ui32PDUMPFlags); +#endif + + #if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) + + ui32RegVal = (SGX_BIF_DIR_LIST_INDEX_EDM << EUR_CR_BIF_BANK0_INDEX_EDM_SHIFT); + + #if defined(SGX_FEATURE_2D_HARDWARE) && !defined(SGX_FEATURE_PTLA) + + ui32RegVal |= (SGX_BIF_DIR_LIST_INDEX_EDM << EUR_CR_BIF_BANK0_INDEX_2D_SHIFT); + #endif + + #if defined(FIX_HW_BRN_23410) + + ui32RegVal |= (SGX_BIF_DIR_LIST_INDEX_EDM << EUR_CR_BIF_BANK0_INDEX_TA_SHIFT); + #endif + + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK0, ui32RegVal); + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Set up EDM requestor page table in BIF\r\n"); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_BANK0, ui32RegVal, ui32PDUMPFlags); + #endif - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SOFT_RESET, ui32SoftResetRegVal); - if (bPDump) { - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SOFT_RESET, ui32SoftResetRegVal, ui32PDUMPFlags); + IMG_UINT32 ui32EDMDirListReg; + + + #if (SGX_BIF_DIR_LIST_INDEX_EDM == 0) + ui32EDMDirListReg = EUR_CR_BIF_DIR_LIST_BASE0; + #else + + ui32EDMDirListReg = EUR_CR_BIF_DIR_LIST_BASE1 + 4 * (SGX_BIF_DIR_LIST_INDEX_EDM - 1); + #endif + + ui32RegVal = psDevInfo->sKernelPDDevPAddr.uiAddr >> SGX_MMU_PDE_ADDR_ALIGNSHIFT; + +#if defined(FIX_HW_BRN_28011) + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_DIR_LIST_BASE0, ui32RegVal); + PDUMPPDREGWITHFLAGS(&psDevInfo->sMMUAttrib, EUR_CR_BIF_DIR_LIST_BASE0, ui32RegVal, ui32PDUMPFlags, PDUMP_PD_UNIQUETAG); +#endif + + OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32EDMDirListReg, ui32RegVal); + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Initialise the EDM's directory list base\r\n"); + PDUMPPDREGWITHFLAGS(&psDevInfo->sMMUAttrib, ui32EDMDirListReg, ui32RegVal, ui32PDUMPFlags, PDUMP_PD_UNIQUETAG); } +} + + +static IMG_VOID SGXResetSleep(PVRSRV_SGXDEV_INFO *psDevInfo, + IMG_UINT32 ui32PDUMPFlags, + IMG_BOOL bPDump) +{ +#if defined(PDUMP) || defined(EMULATOR) + IMG_UINT32 ui32ReadRegister; + + #if defined(SGX_FEATURE_MP) + ui32ReadRegister = EUR_CR_MASTER_SOFT_RESET; + #else + ui32ReadRegister = EUR_CR_SOFT_RESET; + #endif +#endif + +#if !defined(PDUMP) + PVR_UNREFERENCED_PARAMETER(ui32PDUMPFlags); #endif + + OSWaitus(100 * 1000000 / psDevInfo->ui32CoreClockSpeed); + if (bPDump) + { + PDUMPIDLWITHFLAGS(30, ui32PDUMPFlags); +#if defined(PDUMP) + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Read back to flush the register writes\r\n"); + PDumpRegRead(SGX_PDUMPREG_NAME, ui32ReadRegister, ui32PDUMPFlags); +#endif + } + +#if defined(EMULATOR) + + + OSReadHWReg(psDevInfo->pvRegsBaseKM, ui32ReadRegister); +#endif +} + + +#if !defined(SGX_FEATURE_MP) +static IMG_VOID SGXResetSoftReset(PVRSRV_SGXDEV_INFO *psDevInfo, + IMG_BOOL bResetBIF, + IMG_UINT32 ui32PDUMPFlags, + IMG_BOOL bPDump) +{ + IMG_UINT32 ui32SoftResetRegVal; + ui32SoftResetRegVal = EUR_CR_SOFT_RESET_DPM_RESET_MASK | @@ -139,27 +268,6 @@ static IMG_VOID SGXResetSoftReset(PVRSRV_SGXDEV_INFO *psDevInfo, } -static IMG_VOID SGXResetSleep(PVRSRV_SGXDEV_INFO *psDevInfo, - IMG_UINT32 ui32PDUMPFlags, - IMG_BOOL bPDump) -{ -#if !defined(PDUMP) - PVR_UNREFERENCED_PARAMETER(ui32PDUMPFlags); -#endif - - - OSWaitus(100 * 1000000 / psDevInfo->ui32CoreClockSpeed); - if (bPDump) - { - PDUMPIDLWITHFLAGS(30, ui32PDUMPFlags); -#if defined(PDUMP) - PDumpRegRead(SGX_PDUMPREG_NAME, EUR_CR_SOFT_RESET, ui32PDUMPFlags); -#endif - } - -} - - static IMG_VOID SGXResetInvalDC(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_UINT32 ui32PDUMPFlags, IMG_BOOL bPDump) @@ -199,8 +307,9 @@ static IMG_VOID SGXResetInvalDC(PVRSRV_SGXDEV_INFO *psDevInfo, if (PollForValueKM((IMG_UINT32 *)((IMG_UINT8*)psDevInfo->pvRegsBaseKM + EUR_CR_BIF_MEM_REQ_STAT), 0, EUR_CR_BIF_MEM_REQ_STAT_READS_MASK, + MAX_HW_TIME_US, MAX_HW_TIME_US/WAIT_TRY_COUNT, - WAIT_TRY_COUNT) != PVRSRV_OK) + IMG_FALSE) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"Wait for DC invalidate failed.")); PVR_DBG_BREAK; @@ -208,16 +317,18 @@ static IMG_VOID SGXResetInvalDC(PVRSRV_SGXDEV_INFO *psDevInfo, if (bPDump) { - PDUMPREGPOLWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_MEM_REQ_STAT, 0, EUR_CR_BIF_MEM_REQ_STAT_READS_MASK, ui32PDUMPFlags); + PDUMPREGPOLWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_MEM_REQ_STAT, 0, EUR_CR_BIF_MEM_REQ_STAT_READS_MASK, ui32PDUMPFlags, PDUMP_POLL_OPERATOR_EQUAL); } } #endif } +#endif IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bHardwareRecovery, IMG_UINT32 ui32PDUMPFlags) +#if !defined(SGX_FEATURE_MP) { IMG_UINT32 ui32RegVal; #if defined(EUR_CR_BIF_INT_STAT_FAULT_REQ_MASK) @@ -226,12 +337,10 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, const IMG_UINT32 ui32BifFaultMask = EUR_CR_BIF_INT_STAT_FAULT_MASK; #endif -#ifndef PDUMP +#if !defined(PDUMP) PVR_UNREFERENCED_PARAMETER(ui32PDUMPFlags); #endif - psDevInfo->ui32NumResets++; - PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Start of SGX reset sequence\r\n"); #if defined(FIX_HW_BRN_23944) @@ -273,37 +382,7 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_36BIT_ADDRESSING, EUR_CR_BIF_36BIT_ADDRESSING_ENABLE_MASK, ui32PDUMPFlags); #endif - ui32RegVal = 0; - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_CTRL, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_CTRL, ui32RegVal, ui32PDUMPFlags); -#if defined(SGX_FEATURE_MP) - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_BIF_CTRL, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_BIF_CTRL, ui32RegVal, ui32PDUMPFlags); -#endif -#if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK_SET, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_BANK_SET, ui32RegVal, ui32PDUMPFlags); - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK0, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_BANK0, ui32RegVal, ui32PDUMPFlags); -#endif - - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_DIR_LIST_BASE0, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_DIR_LIST_BASE0, ui32RegVal, ui32PDUMPFlags); - -#if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) - { - IMG_UINT32 ui32DirList, ui32DirListReg; - - for (ui32DirList = 1; - ui32DirList < SGX_FEATURE_BIF_NUM_DIRLISTS; - ui32DirList++) - { - ui32DirListReg = EUR_CR_BIF_DIR_LIST_BASE1 + 4 * (ui32DirList - 1); - OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32DirListReg, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, ui32DirListReg, ui32RegVal, ui32PDUMPFlags); - } - } -#endif + SGXResetInitBIFContexts(psDevInfo, ui32PDUMPFlags); #if defined(EUR_CR_BIF_MEM_ARB_CONFIG) @@ -316,30 +395,6 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, #endif #if defined(SGX_FEATURE_SYSTEM_CACHE) -#if defined(SGX_FEATURE_MP) - #if defined(SGX_BYPASS_SYSTEM_CACHE) - #error SGX_BYPASS_SYSTEM_CACHE not supported - #else - ui32RegVal = EUR_CR_MASTER_SLC_CTRL_USSE_INVAL_REQ0_MASK | - #if defined(FIX_HW_BRN_30954) - EUR_CR_MASTER_SLC_CTRL_DISABLE_REORDERING_MASK | - #endif - (0xC << EUR_CR_MASTER_SLC_CTRL_ARB_PAGE_SIZE_SHIFT); - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SLC_CTRL, ui32RegVal); - PDUMPREG(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SLC_CTRL, ui32RegVal); - - ui32RegVal = EUR_CR_MASTER_SLC_CTRL_BYPASS_BYP_CC_MASK; - #if defined(FIX_HW_BRN_31195) - ui32RegVal |= EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE0_MASK | - EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE1_MASK | - EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE2_MASK | - EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE3_MASK | - EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_TA_MASK; - #endif - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SLC_CTRL_BYPASS, ui32RegVal); - PDUMPREG(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SLC_CTRL_BYPASS, ui32RegVal); - #endif -#else #if defined(SGX_BYPASS_SYSTEM_CACHE) ui32RegVal = MNE_CR_CTRL_BYPASS_ALL_MASK; @@ -350,11 +405,14 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, ui32RegVal = MNE_CR_CTRL_BYP_CC_MASK; #endif + #if defined(FIX_HW_BRN_34028) + + ui32RegVal |= (8 << MNE_CR_CTRL_BYPASS_SHIFT); + #endif #endif OSWriteHWReg(psDevInfo->pvRegsBaseKM, MNE_CR_CTRL, ui32RegVal); PDUMPREG(SGX_PDUMPREG_NAME, MNE_CR_CTRL, ui32RegVal); #endif -#endif if (bHardwareRecovery) { @@ -438,43 +496,7 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, - #if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) - - ui32RegVal = (SGX_BIF_DIR_LIST_INDEX_EDM << EUR_CR_BIF_BANK0_INDEX_EDM_SHIFT); - - #if defined(SGX_FEATURE_2D_HARDWARE) && !defined(SGX_FEATURE_PTLA) - - ui32RegVal |= (SGX_BIF_DIR_LIST_INDEX_EDM << EUR_CR_BIF_BANK0_INDEX_2D_SHIFT); - #endif - - #if defined(FIX_HW_BRN_23410) - - ui32RegVal |= (SGX_BIF_DIR_LIST_INDEX_EDM << EUR_CR_BIF_BANK0_INDEX_TA_SHIFT); - #endif - - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_BANK0, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_BIF_BANK0, ui32RegVal, ui32PDUMPFlags); - #endif - - { - IMG_UINT32 ui32EDMDirListReg; - - - #if (SGX_BIF_DIR_LIST_INDEX_EDM == 0) - ui32EDMDirListReg = EUR_CR_BIF_DIR_LIST_BASE0; - #else - - ui32EDMDirListReg = EUR_CR_BIF_DIR_LIST_BASE1 + 4 * (SGX_BIF_DIR_LIST_INDEX_EDM - 1); - #endif - -#if defined(FIX_HW_BRN_28011) - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_BIF_DIR_LIST_BASE0, psDevInfo->sKernelPDDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT); - PDUMPPDREGWITHFLAGS(&psDevInfo->sMMUAttrib, EUR_CR_BIF_DIR_LIST_BASE0, psDevInfo->sKernelPDDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT, ui32PDUMPFlags, PDUMP_PD_UNIQUETAG); -#endif - - OSWriteHWReg(psDevInfo->pvRegsBaseKM, ui32EDMDirListReg, psDevInfo->sKernelPDDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT); - PDUMPPDREGWITHFLAGS(&psDevInfo->sMMUAttrib, ui32EDMDirListReg, psDevInfo->sKernelPDDevPAddr.uiAddr>>SGX_MMU_PDE_ADDR_ALIGNSHIFT, ui32PDUMPFlags, PDUMP_PD_UNIQUETAG); - } + SGXResetSetupBIFContexts(psDevInfo, ui32PDUMPFlags); #if defined(SGX_FEATURE_2D_HARDWARE) && !defined(SGX_FEATURE_PTLA) @@ -493,10 +515,6 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, ui32RegVal = 0; -#if defined(SGX_FEATURE_MP) - OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SOFT_RESET, ui32RegVal); - PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SOFT_RESET, ui32RegVal, ui32PDUMPFlags); -#endif OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_SOFT_RESET, ui32RegVal); PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_SOFT_RESET, ui32RegVal, ui32PDUMPFlags); @@ -506,4 +524,146 @@ IMG_VOID SGXReset(PVRSRV_SGXDEV_INFO *psDevInfo, PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "End of SGX reset sequence\r\n"); } +#else + +{ + IMG_UINT32 ui32RegVal; + + PVR_UNREFERENCED_PARAMETER(bHardwareRecovery); + +#if !defined(PDUMP) + PVR_UNREFERENCED_PARAMETER(ui32PDUMPFlags); +#endif + + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Start of SGX MP reset sequence\r\n"); + + + ui32RegVal = EUR_CR_MASTER_SOFT_RESET_BIF_RESET_MASK | + EUR_CR_MASTER_SOFT_RESET_IPF_RESET_MASK | + EUR_CR_MASTER_SOFT_RESET_DPM_RESET_MASK | + EUR_CR_MASTER_SOFT_RESET_VDM_RESET_MASK; + +#if defined(SGX_FEATURE_PTLA) + ui32RegVal |= EUR_CR_MASTER_SOFT_RESET_PTLA_RESET_MASK; +#endif +#if defined(SGX_FEATURE_SYSTEM_CACHE) + ui32RegVal |= EUR_CR_MASTER_SOFT_RESET_SLC_RESET_MASK; +#endif + + + ui32RegVal |= EUR_CR_MASTER_SOFT_RESET_CORE_RESET_MASK(0) | + EUR_CR_MASTER_SOFT_RESET_CORE_RESET_MASK(1) | + EUR_CR_MASTER_SOFT_RESET_CORE_RESET_MASK(2) | + EUR_CR_MASTER_SOFT_RESET_CORE_RESET_MASK(3); + + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SOFT_RESET, ui32RegVal); + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Soft reset hydra partition, hard reset the cores\r\n"); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SOFT_RESET, ui32RegVal, ui32PDUMPFlags); + + SGXResetSleep(psDevInfo, ui32PDUMPFlags, IMG_TRUE); + + ui32RegVal = 0; + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_BIF_CTRL, ui32RegVal); + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Initialise the hydra BIF control\r\n"); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_BIF_CTRL, ui32RegVal, ui32PDUMPFlags); + +#if defined(SGX_FEATURE_SYSTEM_CACHE) + #if defined(SGX_BYPASS_SYSTEM_CACHE) + #error SGX_BYPASS_SYSTEM_CACHE not supported + #else + ui32RegVal = EUR_CR_MASTER_SLC_CTRL_USSE_INVAL_REQ0_MASK | + #if defined(FIX_HW_BRN_30954) + EUR_CR_MASTER_SLC_CTRL_DISABLE_REORDERING_MASK | + #endif + #if defined(PVR_SLC_8KB_ADDRESS_MODE) + (4 << EUR_CR_MASTER_SLC_CTRL_ADDR_DECODE_MODE_SHIFT) | + #endif + #if defined(FIX_HW_BRN_33809) + (2 << EUR_CR_MASTER_SLC_CTRL_ADDR_DECODE_MODE_SHIFT) | + #endif + (0xC << EUR_CR_MASTER_SLC_CTRL_ARB_PAGE_SIZE_SHIFT); + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SLC_CTRL, ui32RegVal); + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Initialise the hydra SLC control\r\n"); + PDUMPREG(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SLC_CTRL, ui32RegVal); + + ui32RegVal = EUR_CR_MASTER_SLC_CTRL_BYPASS_BYP_CC_MASK; + #if defined(FIX_HW_BRN_31620) + ui32RegVal |= EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_MMU_MASK; + #endif + #if defined(FIX_HW_BRN_31195) + ui32RegVal |= EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE0_MASK | + EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE1_MASK | + EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE2_MASK | + EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_USE3_MASK | + EUR_CR_MASTER_SLC_CTRL_BYPASS_REQ_TA_MASK; + #endif + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SLC_CTRL_BYPASS, ui32RegVal); + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Initialise the hydra SLC bypass control\r\n"); + PDUMPREG(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SLC_CTRL_BYPASS, ui32RegVal); + #endif +#endif + + SGXResetSleep(psDevInfo, ui32PDUMPFlags, IMG_TRUE); + + + ui32RegVal = 0; + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_SOFT_RESET, ui32RegVal); + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Remove the resets from all of SGX\r\n"); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_SOFT_RESET, ui32RegVal, ui32PDUMPFlags); + + SGXResetSleep(psDevInfo, ui32PDUMPFlags, IMG_TRUE); + + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Turn on the slave cores' clock gating\r\n"); + SGXInitClocks(psDevInfo, ui32PDUMPFlags); + + SGXResetSleep(psDevInfo, ui32PDUMPFlags, IMG_TRUE); + + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "Initialise the slave BIFs\r\n"); + +#if defined(FIX_HW_BRN_31278) || defined(FIX_HW_BRN_31620) || defined(FIX_HW_BRN_31671) || defined(FIX_HW_BRN_32085) + #if defined(FIX_HW_BRN_31278) || defined(FIX_HW_BRN_32085) + + ui32RegVal = (1<<EUR_CR_MASTER_BIF_MMU_CTRL_ADDR_HASH_MODE_SHIFT); + #else + ui32RegVal = (1<<EUR_CR_MASTER_BIF_MMU_CTRL_ADDR_HASH_MODE_SHIFT) | EUR_CR_MASTER_BIF_MMU_CTRL_PREFETCHING_ON_MASK; + #endif + #if !defined(FIX_HW_BRN_31620) && !defined(FIX_HW_BRN_31671) + + ui32RegVal |= EUR_CR_MASTER_BIF_MMU_CTRL_ENABLE_DC_TLB_MASK; + #endif + + + OSWriteHWReg(psDevInfo->pvRegsBaseKM, EUR_CR_MASTER_BIF_MMU_CTRL, ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, EUR_CR_MASTER_BIF_MMU_CTRL, ui32RegVal, ui32PDUMPFlags); + + #if defined(FIX_HW_BRN_31278) || defined(FIX_HW_BRN_32085) + + ui32RegVal = (1<<EUR_CR_BIF_MMU_CTRL_ADDR_HASH_MODE_SHIFT); + #else + ui32RegVal = (1<<EUR_CR_BIF_MMU_CTRL_ADDR_HASH_MODE_SHIFT) | EUR_CR_BIF_MMU_CTRL_PREFETCHING_ON_MASK; + #endif + #if !defined(FIX_HW_BRN_31620) && !defined(FIX_HW_BRN_31671) + + ui32RegVal |= EUR_CR_BIF_MMU_CTRL_ENABLE_DC_TLB_MASK; + #endif + + + { + IMG_UINT32 ui32Core; + + for (ui32Core=0;ui32Core<SGX_FEATURE_MP_CORE_COUNT;ui32Core++) + { + OSWriteHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_BIF_MMU_CTRL, ui32Core), ui32RegVal); + PDUMPREGWITHFLAGS(SGX_PDUMPREG_NAME, SGX_MP_CORE_SELECT(EUR_CR_BIF_MMU_CTRL, ui32Core), ui32RegVal, ui32PDUMPFlags); + } + } +#endif + + SGXResetInitBIFContexts(psDevInfo, ui32PDUMPFlags); + SGXResetSetupBIFContexts(psDevInfo, ui32PDUMPFlags); + + PDUMPCOMMENTWITHFLAGS(ui32PDUMPFlags, "End of SGX MP reset sequence\r\n"); +} +#endif + diff --git a/drivers/gpu/pvr/sgx/sgxtransfer.c b/drivers/gpu/pvr/sgx/sgxtransfer.c index 6d940be..92ee0bc 100644 --- a/drivers/gpu/pvr/sgx/sgxtransfer.c +++ b/drivers/gpu/pvr/sgx/sgxtransfer.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -33,7 +33,6 @@ #include "buffer_manager.h" #include "sgxinfo.h" #include "sysconfig.h" -#include "regpaths.h" #include "pdump_km.h" #include "mmu.h" #include "pvr_bridge.h" @@ -42,15 +41,27 @@ #include "osfunc.h" #include "pvr_debug.h" #include "sgxutils.h" +#include "ttrace.h" +#if defined (SUPPORT_SID_INTERFACE) +IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK_KM *psKick) +#else IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSFER_SGX_KICK *psKick) +#endif { - PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo; - SGXMKIF_COMMAND sCommand = {0}; + PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo; + SGXMKIF_COMMAND sCommand = {0}; SGXMKIF_TRANSFERCMD_SHARED *psSharedTransferCmd; - PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; - PVRSRV_ERROR eError; - IMG_UINT32 loop; + PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; + PVRSRV_ERROR eError; + IMG_UINT32 loop; + IMG_HANDLE hDevMemContext = IMG_NULL; + IMG_BOOL abSrcSyncEnable[SGX_MAX_TRANSFER_SYNC_OPS]; + IMG_UINT32 ui32RealSrcSyncNum = 0; + IMG_BOOL abDstSyncEnable[SGX_MAX_TRANSFER_SYNC_OPS]; + IMG_UINT32 ui32RealDstSyncNum = 0; + + #if defined(PDUMP) IMG_BOOL bPersistentProcess = IMG_FALSE; @@ -62,20 +73,39 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF } } #endif +#if defined(FIX_HW_BRN_31620) + hDevMemContext = psKick->hDevMemContext; +#endif + PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_FUNCTION_ENTER, TRANSFER_TOKEN_SUBMIT); + + for (loop = 0; loop < SGX_MAX_TRANSFER_SYNC_OPS; loop++) + { + abSrcSyncEnable[loop] = IMG_TRUE; + abDstSyncEnable[loop] = IMG_TRUE; + } if (!CCB_OFFSET_IS_VALID(SGXMKIF_TRANSFERCMD_SHARED, psCCBMemInfo, psKick, ui32SharedCmdCCBOffset)) { PVR_DPF((PVR_DBG_ERROR, "SGXSubmitTransferKM: Invalid CCB offset")); + PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + TRANSFER_TOKEN_SUBMIT); return PVRSRV_ERROR_INVALID_PARAMS; } psSharedTransferCmd = CCB_DATA_FROM_OFFSET(SGXMKIF_TRANSFERCMD_SHARED, psCCBMemInfo, psKick, ui32SharedCmdCCBOffset); + PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_CMD_START, TRANSFER_TOKEN_SUBMIT); + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_CCB, + TRANSFER_TOKEN_CCB_OFFSET, psKick->ui32SharedCmdCCBOffset); + if (psKick->hTASyncInfo != IMG_NULL) { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->hTASyncInfo; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_TRANSFER, TRANSFER_TOKEN_TA_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + psSharedTransferCmd->ui32TASyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; psSharedTransferCmd->ui32TASyncReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; @@ -92,6 +122,9 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF { psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->h3DSyncInfo; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_TRANSFER, TRANSFER_TOKEN_3D_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); + psSharedTransferCmd->ui323DSyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending++; psSharedTransferCmd->ui323DSyncReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; @@ -104,43 +137,122 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF psSharedTransferCmd->s3DSyncReadOpsCompleteDevVAddr.uiAddr = 0; } - psSharedTransferCmd->ui32NumSrcSyncs = psKick->ui32NumSrcSync; - psSharedTransferCmd->ui32NumDstSyncs = psKick->ui32NumDstSync; + + for (loop = 0; loop < MIN(SGX_MAX_TRANSFER_SYNC_OPS, psKick->ui32NumSrcSync); loop++) + { + IMG_UINT32 i; + + PVRSRV_KERNEL_SYNC_INFO * psMySyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; + + for (i = 0; i < loop; i++) + { + if (abSrcSyncEnable[i]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[i]; + + if (psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr == psMySyncInfo->sWriteOpsCompleteDevVAddr.uiAddr) + { + PVR_DPF((PVR_DBG_WARNING, "SGXSubmitTransferKM : Same src synchronized multiple times!")); + abSrcSyncEnable[loop] = IMG_FALSE; + break; + } + } + } + if (abSrcSyncEnable[loop]) + { + ui32RealSrcSyncNum++; + } + } + for (loop = 0; loop < MIN(SGX_MAX_TRANSFER_SYNC_OPS, psKick->ui32NumDstSync); loop++) + { + IMG_UINT32 i; + + PVRSRV_KERNEL_SYNC_INFO * psMySyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; + + for (i = 0; i < loop; i++) + { + if (abDstSyncEnable[i]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[i]; + + if (psSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr == psMySyncInfo->sWriteOpsCompleteDevVAddr.uiAddr) + { + PVR_DPF((PVR_DBG_WARNING, "SGXSubmitTransferKM : Same dst synchronized multiple times!")); + abDstSyncEnable[loop] = IMG_FALSE; + break; + } + } + } + if (abDstSyncEnable[loop]) + { + ui32RealDstSyncNum++; + } + } + + psSharedTransferCmd->ui32NumSrcSyncs = ui32RealSrcSyncNum; + psSharedTransferCmd->ui32NumDstSyncs = ui32RealDstSyncNum; + if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) { - for (loop=0; loop<psKick->ui32NumSrcSync; loop++) + IMG_UINT32 i = 0; + + for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; + if (abSrcSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; - psSharedTransferCmd->asSrcSyncs[loop].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; - psSharedTransferCmd->asSrcSyncs[loop].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_TRANSFER, TRANSFER_TOKEN_SRC_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); - psSharedTransferCmd->asSrcSyncs[loop].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; - psSharedTransferCmd->asSrcSyncs[loop].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + psSharedTransferCmd->asSrcSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; + psSharedTransferCmd->asSrcSyncs[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; + psSharedTransferCmd->asSrcSyncs[i].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; + psSharedTransferCmd->asSrcSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + i++; + } } - for (loop=0; loop<psKick->ui32NumDstSync; loop++) + PVR_ASSERT(i == ui32RealSrcSyncNum); + + i = 0; + for (loop = 0; loop < psKick->ui32NumDstSync; loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; + if (abDstSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; - psSharedTransferCmd->asDstSyncs[loop].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; - psSharedTransferCmd->asDstSyncs[loop].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; + PVR_TTRACE_SYNC_OBJECT(PVRSRV_TRACE_GROUP_TRANSFER, TRANSFER_TOKEN_DST_SYNC, + psSyncInfo, PVRSRV_SYNCOP_SAMPLE); - psSharedTransferCmd->asDstSyncs[loop].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; - psSharedTransferCmd->asDstSyncs[loop].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + psSharedTransferCmd->asDstSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; + psSharedTransferCmd->asDstSyncs[i].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; + psSharedTransferCmd->asDstSyncs[i].ui32ReadOps2PendingVal = psSyncInfo->psSyncData->ui32ReadOps2Pending; + psSharedTransferCmd->asDstSyncs[i].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; + psSharedTransferCmd->asDstSyncs[i].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + psSharedTransferCmd->asDstSyncs[i].sReadOps2CompleteDevVAddr = psSyncInfo->sReadOps2CompleteDevVAddr; + i++; + } } + PVR_ASSERT(i == ui32RealDstSyncNum); - for (loop=0; loop<psKick->ui32NumSrcSync; loop++) + for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; - psSyncInfo->psSyncData->ui32ReadOpsPending++; + if (abSrcSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; + psSyncInfo->psSyncData->ui32ReadOpsPending++; + } } - for (loop=0; loop<psKick->ui32NumDstSync; loop++) + for (loop = 0; loop < psKick->ui32NumDstSync; loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; - psSyncInfo->psSyncData->ui32WriteOpsPending++; + if (abDstSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; + psSyncInfo->psSyncData->ui32WriteOpsPending++; + } } } @@ -159,69 +271,85 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) { - for (loop=0; loop<psKick->ui32NumSrcSync ; loop++) + IMG_UINT32 i = 0; + + for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) { - psSyncInfo = psKick->ahSrcSyncInfo[loop]; - - PDUMPCOMMENT("Hack src surface write op in transfer cmd\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, - psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_TRANSFERCMD_SHARED, asSrcSyncs) + loop * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal), - sizeof(psSyncInfo->psSyncData->ui32LastOpDumpVal), - psKick->ui32PDumpFlags, - MAKEUNIQUETAG(psCCBMemInfo)); - - PDUMPCOMMENT("Hack src surface read op in transfer cmd\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_TRANSFERCMD_SHARED, asSrcSyncs) + loop * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal), - sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), - psKick->ui32PDumpFlags, - MAKEUNIQUETAG(psCCBMemInfo)); - + if (abSrcSyncEnable[loop]) + { + psSyncInfo = psKick->ahSrcSyncInfo[loop]; + + PDUMPCOMMENT("Hack src surface write op in transfer cmd\r\n"); + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asSrcSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal)), + sizeof(psSyncInfo->psSyncData->ui32LastOpDumpVal), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); + + PDUMPCOMMENT("Hack src surface read op in transfer cmd\r\n"); + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asSrcSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal)), + sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); + i++; + } } - } - if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) - { - for (loop=0; loop< psKick->ui32NumDstSync; loop++) + + i = 0; + for (loop = 0; loop < psKick->ui32NumDstSync; loop++) { - psSyncInfo = psKick->ahDstSyncInfo[loop]; - - PDUMPCOMMENT("Hack dest surface write op in transfer cmd\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, - psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_TRANSFERCMD_SHARED, asDstSyncs) + loop * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal) , - sizeof(psSyncInfo->psSyncData->ui32LastOpDumpVal), - psKick->ui32PDumpFlags, - MAKEUNIQUETAG(psCCBMemInfo)); - - PDUMPCOMMENT("Hack dest surface read op in transfer cmd\r\n"); - PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, - psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_TRANSFERCMD_SHARED, asDstSyncs) + loop * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal), - sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), - psKick->ui32PDumpFlags, - MAKEUNIQUETAG(psCCBMemInfo)); - + if (abDstSyncEnable[i]) + { + IMG_UINT32 ui32PDumpReadOp2 = 0; + psSyncInfo = psKick->ahDstSyncInfo[loop]; + + PDUMPCOMMENT("Hack dest surface write op in transfer cmd\r\n"); + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asDstSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32WriteOpsPendingVal)), + sizeof(psSyncInfo->psSyncData->ui32LastOpDumpVal), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); + + PDUMPCOMMENT("Hack dest surface read op in transfer cmd\r\n"); + PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asDstSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOpsPendingVal)), + sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); + + PDUMPCOMMENT("Hack dest surface read op2 in transfer cmd\r\n"); + PDUMPMEM(&ui32PDumpReadOp2, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)(offsetof(SGXMKIF_TRANSFERCMD_SHARED, asDstSyncs) + i * sizeof(PVRSRV_DEVICE_SYNC_OBJECT) + offsetof(PVRSRV_DEVICE_SYNC_OBJECT, ui32ReadOps2PendingVal)), + sizeof(ui32PDumpReadOp2), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); + i++; + } } - } - - if((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING)== 0UL) - { - for (loop=0; loop<(psKick->ui32NumSrcSync); loop++) + + for (loop = 0; loop < (psKick->ui32NumSrcSync); loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; - psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; + if (abSrcSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; + psSyncInfo->psSyncData->ui32LastReadOpDumpVal++; + } } - } - if((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) - { - for (loop=0; loop<(psKick->ui32NumDstSync); loop++) + for (loop = 0; loop < (psKick->ui32NumDstSync); loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[0]; - psSyncInfo->psSyncData->ui32LastOpDumpVal++; + if (abDstSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[0]; + psSyncInfo->psSyncData->ui32LastOpDumpVal++; + } } } } @@ -229,39 +357,46 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF sCommand.ui32Data[1] = psKick->sHWTransferContextDevVAddr.uiAddr; - eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_TRANSFER, &sCommand, KERNEL_ID, psKick->ui32PDumpFlags, IMG_FALSE); + PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_CMD_END, + TRANSFER_TOKEN_SUBMIT); + + eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_TRANSFER, &sCommand, KERNEL_ID, psKick->ui32PDumpFlags, hDevMemContext, IMG_FALSE); if (eError == PVRSRV_ERROR_RETRY) { if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) { - if (psKick->ui32NumSrcSync > 0) + for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[0]; - psSyncInfo->psSyncData->ui32ReadOpsPending--; - } - if (psKick->ui32NumDstSync > 0) - { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[0]; - psSyncInfo->psSyncData->ui32WriteOpsPending--; - } -#if defined(PDUMP) - if (PDumpIsCaptureFrameKM() - || ((psKick->ui32PDumpFlags & PDUMP_FLAGS_CONTINUOUS) != 0)) - { - if (psKick->ui32NumSrcSync > 0) + if (abSrcSyncEnable[loop]) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[0]; - psSyncInfo->psSyncData->ui32LastReadOpDumpVal--; + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; + psSyncInfo->psSyncData->ui32ReadOpsPending--; +#if defined(PDUMP) + if (PDumpIsCaptureFrameKM() + || ((psKick->ui32PDumpFlags & PDUMP_FLAGS_CONTINUOUS) != 0)) + { + psSyncInfo->psSyncData->ui32LastReadOpDumpVal--; + } +#endif } - if (psKick->ui32NumDstSync > 0) + } + for (loop = 0; loop < psKick->ui32NumDstSync; loop++) + { + if (abDstSyncEnable[loop]) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[0]; - psSyncInfo->psSyncData->ui32LastOpDumpVal--; + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; + psSyncInfo->psSyncData->ui32WriteOpsPending--; +#if defined(PDUMP) + if (PDumpIsCaptureFrameKM() + || ((psKick->ui32PDumpFlags & PDUMP_FLAGS_CONTINUOUS) != 0)) + { + psSyncInfo->psSyncData->ui32LastOpDumpVal--; + } +#endif } } -#endif } @@ -282,6 +417,8 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF else if (PVRSRV_OK != eError) { PVR_DPF((PVR_DBG_ERROR, "SGXSubmitTransferKM: SGXScheduleCCBCommandKM failed.")); + PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + TRANSFER_TOKEN_SUBMIT); return eError; } @@ -289,20 +426,23 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF #if defined(NO_HARDWARE) if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_NOSYNCUPDATE) == 0) { - IMG_UINT32 i; - - for(i = 0; i < psKick->ui32NumSrcSync; i++) + for (loop = 0; loop < psKick->ui32NumSrcSync; loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[i]; - psSyncInfo->psSyncData->ui32ReadOpsComplete = psSyncInfo->psSyncData->ui32ReadOpsPending; + if (abSrcSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahSrcSyncInfo[loop]; + psSyncInfo->psSyncData->ui32ReadOpsComplete = psSyncInfo->psSyncData->ui32ReadOpsPending; + } } - for(i = 0; i < psKick->ui32NumDstSync; i++) + for (loop = 0; loop < psKick->ui32NumDstSync; loop++) { - psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[i]; - psSyncInfo->psSyncData->ui32WriteOpsComplete = psSyncInfo->psSyncData->ui32WriteOpsPending; - + if (abDstSyncEnable[loop]) + { + psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)psKick->ahDstSyncInfo[loop]; + psSyncInfo->psSyncData->ui32WriteOpsComplete = psSyncInfo->psSyncData->ui32WriteOpsPending; + } } if (psKick->hTASyncInfo != IMG_NULL) @@ -320,12 +460,17 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmitTransferKM(IMG_HANDLE hDevHandle, PVRSRV_TRANSF } } #endif - + PVR_TTRACE(PVRSRV_TRACE_GROUP_TRANSFER, PVRSRV_TRACE_CLASS_FUNCTION_EXIT, + TRANSFER_TOKEN_SUBMIT); return eError; } #if defined(SGX_FEATURE_2D_HARDWARE) +#if defined (SUPPORT_SID_INTERFACE) +IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK_KM *psKick) +#else IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK *psKick) +#endif { PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo; @@ -334,6 +479,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; PVRSRV_ERROR eError; IMG_UINT32 i; + IMG_HANDLE hDevMemContext = IMG_NULL; #if defined(PDUMP) IMG_BOOL bPersistentProcess = IMG_FALSE; @@ -345,6 +491,9 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK } } #endif +#if defined(FIX_HW_BRN_31620) + hDevMemContext = psKick->hDevMemContext; +#endif if (!CCB_OFFSET_IS_VALID(SGXMKIF_2DCMD_SHARED, psCCBMemInfo, psKick, ui32SharedCmdCCBOffset)) { @@ -400,9 +549,11 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK ps2DCmd->sDstSyncData.ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; ps2DCmd->sDstSyncData.ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending; + ps2DCmd->sDstSyncData.ui32ReadOps2PendingVal = psSyncInfo->psSyncData->ui32ReadOps2Pending; ps2DCmd->sDstSyncData.sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; ps2DCmd->sDstSyncData.sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + ps2DCmd->sDstSyncData.sReadOps2CompleteDevVAddr = psSyncInfo->sReadOps2CompleteDevVAddr; } @@ -439,7 +590,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK PDUMPCOMMENT("Hack src surface write op in 2D cmd\r\n"); PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_2DCMD_SHARED, sSrcSyncData[i].ui32WriteOpsPendingVal), + psKick->ui32CCBDumpWOff + (IMG_UINT32)offsetof(SGXMKIF_2DCMD_SHARED, sSrcSyncData[i].ui32WriteOpsPendingVal), sizeof(psSyncInfo->psSyncData->ui32LastOpDumpVal), psKick->ui32PDumpFlags, MAKEUNIQUETAG(psCCBMemInfo)); @@ -447,7 +598,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK PDUMPCOMMENT("Hack src surface read op in 2D cmd\r\n"); PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_2DCMD_SHARED, sSrcSyncData[i].ui32ReadOpsPendingVal), + psKick->ui32CCBDumpWOff + (IMG_UINT32)offsetof(SGXMKIF_2DCMD_SHARED, sSrcSyncData[i].ui32ReadOpsPendingVal), sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), psKick->ui32PDumpFlags, MAKEUNIQUETAG(psCCBMemInfo)); @@ -455,12 +606,13 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK if (psKick->hDstSyncInfo != IMG_NULL) { + IMG_UINT32 ui32PDumpReadOp2 = 0; psSyncInfo = psKick->hDstSyncInfo; PDUMPCOMMENT("Hack dest surface write op in 2D cmd\r\n"); PDUMPMEM(&psSyncInfo->psSyncData->ui32LastOpDumpVal, psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_2DCMD_SHARED, sDstSyncData.ui32WriteOpsPendingVal), + psKick->ui32CCBDumpWOff + (IMG_UINT32)offsetof(SGXMKIF_2DCMD_SHARED, sDstSyncData.ui32WriteOpsPendingVal), sizeof(psSyncInfo->psSyncData->ui32LastOpDumpVal), psKick->ui32PDumpFlags, MAKEUNIQUETAG(psCCBMemInfo)); @@ -468,10 +620,17 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK PDUMPCOMMENT("Hack dest surface read op in 2D cmd\r\n"); PDUMPMEM(&psSyncInfo->psSyncData->ui32LastReadOpDumpVal, psCCBMemInfo, - psKick->ui32CCBDumpWOff + offsetof(SGXMKIF_2DCMD_SHARED, sDstSyncData.ui32ReadOpsPendingVal), + psKick->ui32CCBDumpWOff + (IMG_UINT32)offsetof(SGXMKIF_2DCMD_SHARED, sDstSyncData.ui32ReadOpsPendingVal), sizeof(psSyncInfo->psSyncData->ui32LastReadOpDumpVal), psKick->ui32PDumpFlags, MAKEUNIQUETAG(psCCBMemInfo)); + PDUMPCOMMENT("Hack dest surface read op2 in 2D cmd\r\n"); + PDUMPMEM(&ui32PDumpReadOp2, + psCCBMemInfo, + psKick->ui32CCBDumpWOff + (IMG_UINT32)offsetof(SGXMKIF_2DCMD_SHARED, sDstSyncData.ui32ReadOps2PendingVal), + sizeof(ui32PDumpReadOp2), + psKick->ui32PDumpFlags, + MAKEUNIQUETAG(psCCBMemInfo)); } @@ -491,7 +650,7 @@ IMG_EXPORT PVRSRV_ERROR SGXSubmit2DKM(IMG_HANDLE hDevHandle, PVRSRV_2D_SGX_KICK sCommand.ui32Data[1] = psKick->sHW2DContextDevVAddr.uiAddr; - eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_2D, &sCommand, KERNEL_ID, psKick->ui32PDumpFlags); + eError = SGXScheduleCCBCommandKM(hDevHandle, SGXMKIF_CMD_2D, &sCommand, KERNEL_ID, psKick->ui32PDumpFlags, hDevMemContext, IMG_FALSE); if (eError == PVRSRV_ERROR_RETRY) { diff --git a/drivers/gpu/pvr/sgx/sgxutils.c b/drivers/gpu/pvr/sgx/sgxutils.c index 0f464cd..84cf702f 100644 --- a/drivers/gpu/pvr/sgx/sgxutils.c +++ b/drivers/gpu/pvr/sgx/sgxutils.c @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -40,6 +40,7 @@ #include "osfunc.h" #include "pvr_debug.h" #include "sgxutils.h" +#include "ttrace.h" #ifdef __linux__ #include <linux/kernel.h> @@ -88,6 +89,21 @@ IMG_VOID SGXTestActivePowerEvent (PVRSRV_DEVICE_NODE *psDeviceNode, PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; SGXMKIF_HOST_CTL *psSGXHostCtl = psDevInfo->psSGXHostCtl; +#if defined(SYS_SUPPORTS_SGX_IDLE_CALLBACK) + if (!psDevInfo->bSGXIdle && + ((psSGXHostCtl->ui32InterruptFlags & PVRSRV_USSE_EDM_INTERRUPT_IDLE) != 0)) + { + psDevInfo->bSGXIdle = IMG_TRUE; + SysSGXIdleTransition(psDevInfo->bSGXIdle); + } + else if (psDevInfo->bSGXIdle && + ((psSGXHostCtl->ui32InterruptFlags & PVRSRV_USSE_EDM_INTERRUPT_IDLE) == 0)) + { + psDevInfo->bSGXIdle = IMG_FALSE; + SysSGXIdleTransition(psDevInfo->bSGXIdle); + } +#endif + if (((psSGXHostCtl->ui32InterruptFlags & PVRSRV_USSE_EDM_INTERRUPT_ACTIVE_POWER) != 0) && ((psSGXHostCtl->ui32InterruptClearFlags & PVRSRV_USSE_EDM_INTERRUPT_ACTIVE_POWER) == 0)) { @@ -142,23 +158,30 @@ static INLINE SGXMKIF_COMMAND * SGXAcquireKernelCCBSlot(PVRSRV_SGX_CCB_INFO *psC return &psCCB->psCommands[*psCCB->pui32WriteOffset]; } - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); + OSSleepms(1); } END_LOOP_UNTIL_TIMEOUT(); return IMG_NULL; } -PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, +PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_DEVICE_NODE *psDeviceNode, SGXMKIF_CMD_TYPE eCmdType, SGXMKIF_COMMAND *psCommandData, IMG_UINT32 ui32CallerID, IMG_UINT32 ui32PDumpFlags, + IMG_HANDLE hDevMemContext, IMG_BOOL bLastInScene) { PVRSRV_SGX_CCB_INFO *psKernelCCB; PVRSRV_ERROR eError = PVRSRV_OK; SGXMKIF_COMMAND *psSGXCommand; + PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; +#if defined(FIX_HW_BRN_31620) + IMG_UINT32 ui32CacheMasks[4]; + IMG_UINT32 i; + MMU_CONTEXT *psMMUContext; +#endif #if defined(PDUMP) IMG_VOID *pvDumpCommand; IMG_BOOL bPDumpIsSuspended = PDumpIsSuspended(); @@ -168,12 +191,37 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags); #endif +#if defined(FIX_HW_BRN_31620) + for(i=0;i<4;i++) + { + ui32CacheMasks[i] = 0; + } + + psMMUContext = psDevInfo->hKernelMMUContext; + psDeviceNode->pfnMMUGetCacheFlushRange(psMMUContext, &ui32CacheMasks[0]); + + + if (hDevMemContext) + { + BM_CONTEXT *psBMContext = (BM_CONTEXT *) hDevMemContext; + + psMMUContext = psBMContext->psMMUContext; + psDeviceNode->pfnMMUGetCacheFlushRange(psMMUContext, &ui32CacheMasks[2]); + } + + + if (ui32CacheMasks[0] || ui32CacheMasks[1] || ui32CacheMasks[2] || ui32CacheMasks[3]) + { + psDevInfo->ui32CacheControl |= SGXMKIF_CC_INVAL_BIF_PD; + } +#endif + #if defined(FIX_HW_BRN_28889) - if ( (eCmdType != SGXMKIF_CMD_PROCESS_QUEUES) && + if ( (eCmdType != SGXMKIF_CMD_PROCESS_QUEUES) && ((psDevInfo->ui32CacheControl & SGXMKIF_CC_INVAL_DATA) != 0) && ((psDevInfo->ui32CacheControl & (SGXMKIF_CC_INVAL_BIF_PT | SGXMKIF_CC_INVAL_BIF_PD)) != 0)) { @@ -183,30 +231,32 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, SGXMKIF_HOST_CTL *psSGXHostCtl = psDevInfo->psSGXHostCtl; SGXMKIF_COMMAND sCacheCommand = {0}; - eError = SGXScheduleCCBCommand(psDevInfo, + eError = SGXScheduleCCBCommand(psDeviceNode, SGXMKIF_CMD_PROCESS_QUEUES, &sCacheCommand, ui32CallerID, ui32PDumpFlags, + hDevMemContext, bLastInScene); if (eError != PVRSRV_OK) { goto Exit; } - + #if !defined(NO_HARDWARE) if(PollForValueKM(&psSGXHostCtl->ui32InvalStatus, PVRSRV_USSE_EDM_BIF_INVAL_COMPLETE, PVRSRV_USSE_EDM_BIF_INVAL_COMPLETE, - 2 * MAX_HW_TIME_US/WAIT_TRY_COUNT, - WAIT_TRY_COUNT) != PVRSRV_OK) + 2 * MAX_HW_TIME_US, + MAX_HW_TIME_US/WAIT_TRY_COUNT, + IMG_FALSE) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXScheduleCCBCommand: Wait for uKernel to Invalidate BIF cache failed")); PVR_DBG_BREAK; } #endif - + #if defined(PDUMP) PDUMPCOMMENTWITHFLAGS(0, "Host Control - Poll for BIF cache invalidate request to complete"); @@ -218,12 +268,60 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, 0, MAKEUNIQUETAG(psSGXHostCtlMemInfo)); #endif - + psSGXHostCtl->ui32InvalStatus &= ~(PVRSRV_USSE_EDM_BIF_INVAL_COMPLETE); PDUMPMEM(IMG_NULL, psSGXHostCtlMemInfo, offsetof(SGXMKIF_HOST_CTL, ui32CleanupStatus), sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psSGXHostCtlMemInfo)); } +#else + PVR_UNREFERENCED_PARAMETER(hDevMemContext); +#endif + +#if defined(FIX_HW_BRN_31620) + if ((eCmdType != SGXMKIF_CMD_FLUSHPDCACHE) && (psDevInfo->ui32CacheControl & SGXMKIF_CC_INVAL_BIF_PD)) + { + SGXMKIF_COMMAND sPDECacheCommand = {0}; + IMG_DEV_PHYADDR sDevPAddr; + + + psMMUContext = psDevInfo->hKernelMMUContext; + + psDeviceNode->pfnMMUGetPDPhysAddr(psMMUContext, &sDevPAddr); + sPDECacheCommand.ui32Data[0] = sDevPAddr.uiAddr | 1; + sPDECacheCommand.ui32Data[1] = ui32CacheMasks[0]; + sPDECacheCommand.ui32Data[2] = ui32CacheMasks[1]; + + + if (hDevMemContext) + { + BM_CONTEXT *psBMContext = (BM_CONTEXT *) hDevMemContext; + + psMMUContext = psBMContext->psMMUContext; + + psDeviceNode->pfnMMUGetPDPhysAddr(psMMUContext, &sDevPAddr); + + sPDECacheCommand.ui32Data[3] = sDevPAddr.uiAddr | 1; + sPDECacheCommand.ui32Data[4] = ui32CacheMasks[2]; + sPDECacheCommand.ui32Data[5] = ui32CacheMasks[3]; + } + + + if (sPDECacheCommand.ui32Data[1] | sPDECacheCommand.ui32Data[2] | sPDECacheCommand.ui32Data[4] | + sPDECacheCommand.ui32Data[5]) + { + eError = SGXScheduleCCBCommand(psDeviceNode, + SGXMKIF_CMD_FLUSHPDCACHE, + &sPDECacheCommand, + ui32CallerID, + ui32PDumpFlags, + hDevMemContext, + bLastInScene); + if (eError != PVRSRV_OK) + { + goto Exit; + } + } + } #endif - #if defined(PDUMP) { @@ -241,6 +339,7 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, if(!psSGXCommand) { + PVR_DPF((PVR_DBG_ERROR, "SGXScheduleCCBCommand: Wait for CCB space timed out")) ; eError = PVRSRV_ERROR_TIMEOUT; goto Exit; } @@ -261,16 +360,16 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, if (eCmdType >= SGXMKIF_CMD_MAX) { - PVR_DPF((PVR_DBG_ERROR,"SGXScheduleCCBCommandKM: Unknown command type: %d", eCmdType)) ; + PVR_DPF((PVR_DBG_ERROR, "SGXScheduleCCBCommand: Unknown command type: %d", eCmdType)) ; eError = PVRSRV_ERROR_INVALID_CCB_COMMAND; goto Exit; } - - if((eCmdType == SGXMKIF_CMD_TA) && bLastInScene) + if ((eCmdType == SGXMKIF_CMD_TA) && bLastInScene) { SYS_DATA *psSysData; + SysAcquireData(&psSysData); if(psSysData->ePendingCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_FLUSH) @@ -281,7 +380,8 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, { OSCleanCPUCacheKM(); } - + + psSysData->ePendingCacheOpType = PVRSRV_MISC_INFO_CPUCACHEOP_NONE; } @@ -335,10 +435,12 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, eError = PollForValueKM (psKernelCCB->pui32ReadOffset, *psKernelCCB->pui32WriteOffset, 0xFF, + MAX_HW_TIME_US, MAX_HW_TIME_US/WAIT_TRY_COUNT, - WAIT_TRY_COUNT); + IMG_FALSE); if (eError != PVRSRV_OK) { + PVR_DPF((PVR_DBG_ERROR, "SGXScheduleCCBCommand: Timeout waiting for previous command to be read")) ; eError = PVRSRV_ERROR_TIMEOUT; goto Exit; } @@ -397,6 +499,15 @@ PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, OSWriteMemoryBarrier(); + + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_MKSYNC, PVRSRV_TRACE_CLASS_NONE, + MKSYNC_TOKEN_KERNEL_CCB_OFFSET, *psKernelCCB->pui32WriteOffset); + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_MKSYNC, PVRSRV_TRACE_CLASS_NONE, + MKSYNC_TOKEN_CORE_CLK, psDevInfo->ui32CoreClockSpeed); + PVR_TTRACE_UI32(PVRSRV_TRACE_GROUP_MKSYNC, PVRSRV_TRACE_CLASS_NONE, + MKSYNC_TOKEN_UKERNEL_CLK, psDevInfo->ui32uKernelTimerClock); + + #if defined(FIX_HW_BRN_26620) && defined(SGX_FEATURE_SYSTEM_CACHE) && !defined(SGX_BYPASS_SYSTEM_CACHE) OSWriteHWReg(psDevInfo->pvRegsBaseKM, SGX_MP_CORE_SELECT(EUR_CR_EVENT_KICK2, 0), @@ -424,10 +535,10 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode, SGXMKIF_COMMAND *psCommandData, IMG_UINT32 ui32CallerID, IMG_UINT32 ui32PDumpFlags, + IMG_HANDLE hDevMemContext, IMG_BOOL bLastInScene) { PVRSRV_ERROR eError; - PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; PDUMPSUSPEND(); @@ -471,19 +582,9 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode, return eError; } - eError = SGXScheduleCCBCommand(psDevInfo, eCmdType, psCommandData, ui32CallerID, ui32PDumpFlags, bLastInScene); + eError = SGXScheduleCCBCommand(psDeviceNode, eCmdType, psCommandData, ui32CallerID, ui32PDumpFlags, hDevMemContext, bLastInScene); PVRSRVPowerUnlock(ui32CallerID); - - - if (ui32CallerID != ISR_ID) - { - - - - SGXTestActivePowerEvent(psDeviceNode, ui32CallerID); - } - return eError; } @@ -493,7 +594,7 @@ PVRSRV_ERROR SGXScheduleProcessQueuesKM(PVRSRV_DEVICE_NODE *psDeviceNode) PVRSRV_ERROR eError; PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; SGXMKIF_HOST_CTL *psHostCtl = psDevInfo->psKernelSGXHostCtlMemInfo->pvLinAddrKM; - IMG_UINT32 ui32PowerStatus; + IMG_UINT32 ui32PowerStatus; SGXMKIF_COMMAND sCommand = {0}; ui32PowerStatus = psHostCtl->ui32PowerStatus; @@ -503,7 +604,7 @@ PVRSRV_ERROR SGXScheduleProcessQueuesKM(PVRSRV_DEVICE_NODE *psDeviceNode) return PVRSRV_OK; } - eError = SGXScheduleCCBCommandKM(psDeviceNode, SGXMKIF_CMD_PROCESS_QUEUES, &sCommand, ISR_ID, 0, IMG_FALSE); + eError = SGXScheduleCCBCommandKM(psDeviceNode, SGXMKIF_CMD_PROCESS_QUEUES, &sCommand, ISR_ID, 0, IMG_NULL, IMG_FALSE); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXScheduleProcessQueuesKM failed to schedule CCB command: %u", eError)); @@ -521,7 +622,11 @@ IMG_BOOL SGXIsDevicePowered(PVRSRV_DEVICE_NODE *psDeviceNode) IMG_EXPORT PVRSRV_ERROR SGXGetInternalDevInfoKM(IMG_HANDLE hDevCookie, +#if defined (SUPPORT_SID_INTERFACE) + SGX_INTERNAL_DEVINFO_KM *psSGXInternalDevInfo) +#else SGX_INTERNAL_DEVINFO *psSGXInternalDevInfo) +#endif { PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)((PVRSRV_DEVICE_NODE *)hDevCookie)->pvDevice; @@ -536,69 +641,76 @@ PVRSRV_ERROR SGXGetInternalDevInfoKM(IMG_HANDLE hDevCookie, } -IMG_VOID SGXCleanupRequest(PVRSRV_DEVICE_NODE *psDeviceNode, - IMG_DEV_VIRTADDR *psHWDataDevVAddr, - IMG_UINT32 ui32CleanupType) +PVRSRV_ERROR SGXCleanupRequest(PVRSRV_DEVICE_NODE *psDeviceNode, + IMG_DEV_VIRTADDR *psHWDataDevVAddr, + IMG_UINT32 ui32CleanupType, + IMG_BOOL bForceCleanup) { PVRSRV_ERROR eError; - PVRSRV_SGXDEV_INFO *psSGXDevInfo = psDeviceNode->pvDevice; - PVRSRV_KERNEL_MEM_INFO *psSGXHostCtlMemInfo = psSGXDevInfo->psKernelSGXHostCtlMemInfo; - SGXMKIF_HOST_CTL *psSGXHostCtl = psSGXHostCtlMemInfo->pvLinAddrKM; + PVRSRV_SGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice; + PVRSRV_KERNEL_MEM_INFO *psHostCtlMemInfo = psDevInfo->psKernelSGXHostCtlMemInfo; + SGXMKIF_HOST_CTL *psHostCtl = psHostCtlMemInfo->pvLinAddrKM; + + SGXMKIF_COMMAND sCommand = {0}; - if ((psSGXHostCtl->ui32PowerStatus & PVRSRV_USSE_EDM_POWMAN_NO_WORK) != 0) - { - - } - else - { - SGXMKIF_COMMAND sCommand = {0}; - PDUMPCOMMENTWITHFLAGS(0, "Request ukernel resouce clean-up"); + if (bForceCleanup != FORCE_CLEANUP) + { sCommand.ui32Data[0] = ui32CleanupType; sCommand.ui32Data[1] = (psHWDataDevVAddr == IMG_NULL) ? 0 : psHWDataDevVAddr->uiAddr; - - eError = SGXScheduleCCBCommandKM(psDeviceNode, SGXMKIF_CMD_CLEANUP, &sCommand, KERNEL_ID, 0, IMG_FALSE); + PDUMPCOMMENTWITHFLAGS(0, "Request ukernel resource clean-up, Type %u, Data 0x%X", sCommand.ui32Data[0], sCommand.ui32Data[1]); + + eError = SGXScheduleCCBCommandKM(psDeviceNode, SGXMKIF_CMD_CLEANUP, &sCommand, KERNEL_ID, 0, IMG_NULL, IMG_FALSE); if (eError != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR,"SGXCleanupRequest: Failed to submit clean-up command")); - PVR_DBG_BREAK; + PVR_DPF((PVR_DBG_ERROR,"SGXCleanupRequest: Failed to submit clean-up command")); + PVR_DBG_BREAK; + return eError; } - + #if !defined(NO_HARDWARE) - if(PollForValueKM(&psSGXHostCtl->ui32CleanupStatus, + if(PollForValueKM(&psHostCtl->ui32CleanupStatus, PVRSRV_USSE_EDM_CLEANUPCMD_COMPLETE, PVRSRV_USSE_EDM_CLEANUPCMD_COMPLETE, - 2 * MAX_HW_TIME_US/WAIT_TRY_COUNT, - WAIT_TRY_COUNT) != PVRSRV_OK) + 10 * MAX_HW_TIME_US, + 1000, + IMG_TRUE) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"SGXCleanupRequest: Wait for uKernel to clean up (%u) failed", ui32CleanupType)); + eError = PVRSRV_ERROR_TIMEOUT; PVR_DBG_BREAK; } #endif - + #if defined(PDUMP) PDUMPCOMMENTWITHFLAGS(0, "Host Control - Poll for clean-up request to complete"); - PDUMPMEMPOL(psSGXHostCtlMemInfo, + PDUMPMEMPOL(psHostCtlMemInfo, offsetof(SGXMKIF_HOST_CTL, ui32CleanupStatus), PVRSRV_USSE_EDM_CLEANUPCMD_COMPLETE, PVRSRV_USSE_EDM_CLEANUPCMD_COMPLETE, PDUMP_POLL_OPERATOR_EQUAL, 0, - MAKEUNIQUETAG(psSGXHostCtlMemInfo)); + MAKEUNIQUETAG(psHostCtlMemInfo)); #endif - - psSGXHostCtl->ui32CleanupStatus &= ~(PVRSRV_USSE_EDM_CLEANUPCMD_COMPLETE); - PDUMPMEM(IMG_NULL, psSGXHostCtlMemInfo, offsetof(SGXMKIF_HOST_CTL, ui32CleanupStatus), sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psSGXHostCtlMemInfo)); - - - #if defined(SGX_FEATURE_SYSTEM_CACHE) - psSGXDevInfo->ui32CacheControl |= (SGXMKIF_CC_INVAL_BIF_SL | SGXMKIF_CC_INVAL_DATA); - #else - psSGXDevInfo->ui32CacheControl |= SGXMKIF_CC_INVAL_DATA; - #endif + + if (eError != PVRSRV_OK) + { + return eError; + } } + + psHostCtl->ui32CleanupStatus &= ~(PVRSRV_USSE_EDM_CLEANUPCMD_COMPLETE); + PDUMPMEM(IMG_NULL, psHostCtlMemInfo, offsetof(SGXMKIF_HOST_CTL, ui32CleanupStatus), sizeof(IMG_UINT32), 0, MAKEUNIQUETAG(psHostCtlMemInfo)); + + +#if defined(SGX_FEATURE_SYSTEM_CACHE) + psDevInfo->ui32CacheControl |= (SGXMKIF_CC_INVAL_BIF_SL | SGXMKIF_CC_INVAL_DATA); +#else + psDevInfo->ui32CacheControl |= SGXMKIF_CC_INVAL_DATA; +#endif + return PVRSRV_OK; } @@ -612,15 +724,18 @@ typedef struct _SGX_HW_RENDER_CONTEXT_CLEANUP_ static PVRSRV_ERROR SGXCleanupHWRenderContextCallback(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) + IMG_UINT32 ui32Param, + IMG_BOOL bForceCleanup) { + PVRSRV_ERROR eError; SGX_HW_RENDER_CONTEXT_CLEANUP *psCleanup = pvParam; PVR_UNREFERENCED_PARAMETER(ui32Param); - SGXCleanupRequest(psCleanup->psDeviceNode, + eError = SGXCleanupRequest(psCleanup->psDeviceNode, &psCleanup->sHWRenderContextDevVAddr, - PVRSRV_CLEANUPCMD_RC); + PVRSRV_CLEANUPCMD_RC, + bForceCleanup); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(SGX_HW_RENDER_CONTEXT_CLEANUP), @@ -628,7 +743,7 @@ static PVRSRV_ERROR SGXCleanupHWRenderContextCallback(IMG_PVOID pvParam, psCleanup->hBlockAlloc); - return PVRSRV_OK; + return eError; } typedef struct _SGX_HW_TRANSFER_CONTEXT_CLEANUP_ @@ -641,15 +756,18 @@ typedef struct _SGX_HW_TRANSFER_CONTEXT_CLEANUP_ static PVRSRV_ERROR SGXCleanupHWTransferContextCallback(IMG_PVOID pvParam, - IMG_UINT32 ui32Param) + IMG_UINT32 ui32Param, + IMG_BOOL bForceCleanup) { + PVRSRV_ERROR eError; SGX_HW_TRANSFER_CONTEXT_CLEANUP *psCleanup = (SGX_HW_TRANSFER_CONTEXT_CLEANUP *)pvParam; PVR_UNREFERENCED_PARAMETER(ui32Param); - SGXCleanupRequest(psCleanup->psDeviceNode, + eError = SGXCleanupRequest(psCleanup->psDeviceNode, &psCleanup->sHWTransferContextDevVAddr, - PVRSRV_CLEANUPCMD_TC); + PVRSRV_CLEANUPCMD_TC, + bForceCleanup); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(SGX_HW_TRANSFER_CONTEXT_CLEANUP), @@ -657,7 +775,7 @@ static PVRSRV_ERROR SGXCleanupHWTransferContextCallback(IMG_PVOID pvParam, psCleanup->hBlockAlloc); - return PVRSRV_OK; + return eError; } IMG_EXPORT @@ -710,7 +828,7 @@ IMG_HANDLE SGXRegisterHWRenderContextKM(IMG_HANDLE psDeviceNode, } IMG_EXPORT -PVRSRV_ERROR SGXUnregisterHWRenderContextKM(IMG_HANDLE hHWRenderContext) +PVRSRV_ERROR SGXUnregisterHWRenderContextKM(IMG_HANDLE hHWRenderContext, IMG_BOOL bForceCleanup) { PVRSRV_ERROR eError; SGX_HW_RENDER_CONTEXT_CLEANUP *psCleanup; @@ -725,7 +843,7 @@ PVRSRV_ERROR SGXUnregisterHWRenderContextKM(IMG_HANDLE hHWRenderContext) return PVRSRV_ERROR_INVALID_PARAMS; } - eError = ResManFreeResByPtr(psCleanup->psResItem); + eError = ResManFreeResByPtr(psCleanup->psResItem, bForceCleanup); return eError; } @@ -781,7 +899,7 @@ IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE psDeviceNode, } IMG_EXPORT -PVRSRV_ERROR SGXUnregisterHWTransferContextKM(IMG_HANDLE hHWTransferContext) +PVRSRV_ERROR SGXUnregisterHWTransferContextKM(IMG_HANDLE hHWTransferContext, IMG_BOOL bForceCleanup) { PVRSRV_ERROR eError; SGX_HW_TRANSFER_CONTEXT_CLEANUP *psCleanup; @@ -796,7 +914,7 @@ PVRSRV_ERROR SGXUnregisterHWTransferContextKM(IMG_HANDLE hHWTransferContext) return PVRSRV_ERROR_INVALID_PARAMS; } - eError = ResManFreeResByPtr(psCleanup->psResItem); + eError = ResManFreeResByPtr(psCleanup->psResItem, bForceCleanup); return eError; } @@ -810,15 +928,19 @@ typedef struct _SGX_HW_2D_CONTEXT_CLEANUP_ PRESMAN_ITEM psResItem; } SGX_HW_2D_CONTEXT_CLEANUP; -static PVRSRV_ERROR SGXCleanupHW2DContextCallback(IMG_PVOID pvParam, IMG_UINT32 ui32Param) +static PVRSRV_ERROR SGXCleanupHW2DContextCallback(IMG_PVOID pvParam, + IMG_UINT32 ui32Param, + IMG_BOOL bForceCleanup) { + PVRSRV_ERROR eError; SGX_HW_2D_CONTEXT_CLEANUP *psCleanup = (SGX_HW_2D_CONTEXT_CLEANUP *)pvParam; PVR_UNREFERENCED_PARAMETER(ui32Param); - SGXCleanupRequest(psCleanup->psDeviceNode, + eError = SGXCleanupRequest(psCleanup->psDeviceNode, &psCleanup->sHW2DContextDevVAddr, - PVRSRV_CLEANUPCMD_2DC); + PVRSRV_CLEANUPCMD_2DC, + bForceCleanup); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(SGX_HW_2D_CONTEXT_CLEANUP), @@ -826,7 +948,7 @@ static PVRSRV_ERROR SGXCleanupHW2DContextCallback(IMG_PVOID pvParam, IMG_UINT32 psCleanup->hBlockAlloc); - return PVRSRV_OK; + return eError; } IMG_EXPORT @@ -879,7 +1001,7 @@ IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE psDeviceNode, } IMG_EXPORT -PVRSRV_ERROR SGXUnregisterHW2DContextKM(IMG_HANDLE hHW2DContext) +PVRSRV_ERROR SGXUnregisterHW2DContextKM(IMG_HANDLE hHW2DContext, IMG_BOOL bForceCleanup) { PVRSRV_ERROR eError; SGX_HW_2D_CONTEXT_CLEANUP *psCleanup; @@ -893,7 +1015,7 @@ PVRSRV_ERROR SGXUnregisterHW2DContextKM(IMG_HANDLE hHW2DContext) psCleanup = (SGX_HW_2D_CONTEXT_CLEANUP *)hHW2DContext; - eError = ResManFreeResByPtr(psCleanup->psResItem); + eError = ResManFreeResByPtr(psCleanup->psResItem, bForceCleanup); return eError; } @@ -949,7 +1071,7 @@ PVRSRV_ERROR SGX2DQueryBlitsCompleteKM(PVRSRV_SGXDEV_INFO *psDevInfo, LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) { - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); + OSSleepms(1); if(SGX2DQuerySyncOpsComplete(psSyncInfo, ui32ReadOpsPending, ui32WriteOpsPending)) { @@ -958,7 +1080,7 @@ PVRSRV_ERROR SGX2DQueryBlitsCompleteKM(PVRSRV_SGXDEV_INFO *psDevInfo, return PVRSRV_OK; } - OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT); + OSSleepms(1); } END_LOOP_UNTIL_TIMEOUT(); @@ -982,13 +1104,16 @@ PVRSRV_ERROR SGX2DQueryBlitsCompleteKM(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_EXPORT -IMG_VOID SGXFlushHWRenderTargetKM(IMG_HANDLE psDeviceNode, IMG_DEV_VIRTADDR sHWRTDataSetDevVAddr) +PVRSRV_ERROR SGXFlushHWRenderTargetKM(IMG_HANDLE psDeviceNode, + IMG_DEV_VIRTADDR sHWRTDataSetDevVAddr, + IMG_BOOL bForceCleanup) { PVR_ASSERT(sHWRTDataSetDevVAddr.uiAddr != IMG_NULL); - SGXCleanupRequest(psDeviceNode, + return SGXCleanupRequest(psDeviceNode, &sHWRTDataSetDevVAddr, - PVRSRV_CLEANUPCMD_RT); + PVRSRV_CLEANUPCMD_RT, + bForceCleanup); } @@ -1014,3 +1139,40 @@ IMG_UINT32 SGXConvertTimeStamp(PVRSRV_SGXDEV_INFO *psDevInfo, +IMG_EXPORT +PVRSRV_ERROR PVRSRVGetSGXRevDataKM(PVRSRV_DEVICE_NODE* psDeviceNode, IMG_UINT32 *pui32SGXCoreRev, + IMG_UINT32 *pui32SGXCoreID) +{ + PVRSRV_SGXDEV_INFO *psDevInfo = (PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; + SGX_MISC_INFO sMiscInfo; + PVRSRV_ERROR eError; + + sMiscInfo.eRequest = SGX_MISC_INFO_REQUEST_SGXREV; + eError = SGXGetMiscInfoKM(psDevInfo, &sMiscInfo, psDeviceNode, NULL); + + *pui32SGXCoreRev = sMiscInfo.uData.sSGXFeatures.ui32CoreRev; + *pui32SGXCoreID = sMiscInfo.uData.sSGXFeatures.ui32CoreID; + return eError; +} + + +PVRSRV_ERROR SGXContextSuspend(PVRSRV_DEVICE_NODE *psDeviceNode, + IMG_DEV_VIRTADDR *psHWContextDevVAddr, + IMG_BOOL bResume) +{ + PVRSRV_ERROR eError; + SGXMKIF_COMMAND sCommand = {0}; + + sCommand.ui32Data[0] = psHWContextDevVAddr->uiAddr; + sCommand.ui32Data[1] = bResume ? PVRSRV_CTXSUSPCMD_RESUME : PVRSRV_CTXSUSPCMD_SUSPEND; + + eError = SGXScheduleCCBCommandKM(psDeviceNode, SGXMKIF_CMD_CONTEXTSUSPEND, &sCommand, KERNEL_ID, 0, IMG_NULL, IMG_FALSE); + if (eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"SGXContextSuspend: Failed to submit context suspend command")); + return eError; + } + + return eError; +} + diff --git a/drivers/gpu/pvr/sgx/sgxutils.h b/drivers/gpu/pvr/sgx/sgxutils.h index 06f99a1..bc60fdd 100644 --- a/drivers/gpu/pvr/sgx/sgxutils.h +++ b/drivers/gpu/pvr/sgx/sgxutils.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -29,8 +29,8 @@ #define CCB_OFFSET_IS_VALID(type, psCCBMemInfo, psCCBKick, offset) \ - ((sizeof(type) <= (psCCBMemInfo)->ui32AllocSize) && \ - ((psCCBKick)->offset <= (psCCBMemInfo)->ui32AllocSize - sizeof(type))) + ((sizeof(type) <= (psCCBMemInfo)->uAllocSize) && \ + ((psCCBKick)->offset <= (psCCBMemInfo)->uAllocSize - sizeof(type))) #define CCB_DATA_FROM_OFFSET(type, psCCBMemInfo, psCCBKick, offset) \ ((type *)(((IMG_CHAR *)(psCCBMemInfo)->pvLinAddrKM) + \ @@ -42,11 +42,12 @@ IMG_VOID SGXTestActivePowerEvent(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_UINT32 ui32CallerID); IMG_IMPORT -PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_SGXDEV_INFO *psDevInfo, +PVRSRV_ERROR SGXScheduleCCBCommand(PVRSRV_DEVICE_NODE *psDeviceNode, SGXMKIF_CMD_TYPE eCommandType, SGXMKIF_COMMAND *psCommandData, IMG_UINT32 ui32CallerID, IMG_UINT32 ui32PDumpFlags, + IMG_HANDLE hDevMemContext, IMG_BOOL bLastInScene); IMG_IMPORT PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode, @@ -54,6 +55,7 @@ PVRSRV_ERROR SGXScheduleCCBCommandKM(PVRSRV_DEVICE_NODE *psDeviceNode, SGXMKIF_COMMAND *psCommandData, IMG_UINT32 ui32CallerID, IMG_UINT32 ui32PDumpFlags, + IMG_HANDLE hDevMemContext, IMG_BOOL bLastInScene); IMG_IMPORT @@ -73,13 +75,15 @@ IMG_HANDLE SGXRegisterHWTransferContextKM(IMG_HANDLE psDeviceNode, PVRSRV_PER_PROCESS_DATA *psPerProc); IMG_IMPORT -IMG_VOID SGXFlushHWRenderTargetKM(IMG_HANDLE psSGXDevInfo, IMG_DEV_VIRTADDR psHWRTDataSetDevVAddr); +PVRSRV_ERROR SGXFlushHWRenderTargetKM(IMG_HANDLE psSGXDevInfo, + IMG_DEV_VIRTADDR psHWRTDataSetDevVAddr, + IMG_BOOL bForceCleanup); IMG_IMPORT -PVRSRV_ERROR SGXUnregisterHWRenderContextKM(IMG_HANDLE hHWRenderContext); +PVRSRV_ERROR SGXUnregisterHWRenderContextKM(IMG_HANDLE hHWRenderContext, IMG_BOOL bForceCleanup); IMG_IMPORT -PVRSRV_ERROR SGXUnregisterHWTransferContextKM(IMG_HANDLE hHWTransferContext); +PVRSRV_ERROR SGXUnregisterHWTransferContextKM(IMG_HANDLE hHWTransferContext, IMG_BOOL bForceCleanup); #if defined(SGX_FEATURE_2D_HARDWARE) IMG_IMPORT @@ -88,15 +92,23 @@ IMG_HANDLE SGXRegisterHW2DContextKM(IMG_HANDLE psDeviceNode, PVRSRV_PER_PROCESS_DATA *psPerProc); IMG_IMPORT -PVRSRV_ERROR SGXUnregisterHW2DContextKM(IMG_HANDLE hHW2DContext); +PVRSRV_ERROR SGXUnregisterHW2DContextKM(IMG_HANDLE hHW2DContext, IMG_BOOL bForceCleanup); #endif IMG_UINT32 SGXConvertTimeStamp(PVRSRV_SGXDEV_INFO *psDevInfo, IMG_UINT32 ui32TimeWraps, IMG_UINT32 ui32Time); -IMG_VOID SGXCleanupRequest(PVRSRV_DEVICE_NODE *psDeviceNode, +PVRSRV_ERROR SGXCleanupRequest(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_DEV_VIRTADDR *psHWDataDevVAddr, - IMG_UINT32 ui32CleanupType); + IMG_UINT32 ui32CleanupType, + IMG_BOOL bForceCleanup); +IMG_IMPORT +PVRSRV_ERROR PVRSRVGetSGXRevDataKM(PVRSRV_DEVICE_NODE* psDeviceNode, IMG_UINT32 *pui32SGXCoreRev, + IMG_UINT32 *pui32SGXCoreID); + +PVRSRV_ERROR SGXContextSuspend(PVRSRV_DEVICE_NODE *psDeviceNode, + IMG_DEV_VIRTADDR *psHWContextDevVAddr, + IMG_BOOL bResume); diff --git a/drivers/gpu/pvr/sgx530defs.h b/drivers/gpu/pvr/sgx530defs.h index 525f51d..810cb81 100644 --- a/drivers/gpu/pvr/sgx530defs.h +++ b/drivers/gpu/pvr/sgx530defs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/sgx531defs.h b/drivers/gpu/pvr/sgx531defs.h index b0c663c..c9f2899 100644 --- a/drivers/gpu/pvr/sgx531defs.h +++ b/drivers/gpu/pvr/sgx531defs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/sgx540defs.h b/drivers/gpu/pvr/sgx540defs.h index dadbb1e..c09aa26 100644 --- a/drivers/gpu/pvr/sgx540defs.h +++ b/drivers/gpu/pvr/sgx540defs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/sgx_bridge.h b/drivers/gpu/pvr/sgx_bridge.h index 10e5919..204189c 100644 --- a/drivers/gpu/pvr/sgx_bridge.h +++ b/drivers/gpu/pvr/sgx_bridge.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -27,7 +27,11 @@ #if !defined(__SGX_BRIDGE_H__) #define __SGX_BRIDGE_H__ +#if defined (SUPPORT_SID_INTERFACE) +#include "sgxapi.h" +#else #include "sgxapi_km.h" +#endif #include "sgxinfo.h" #include "pvr_bridge.h" @@ -106,8 +110,13 @@ typedef struct PVRSRV_BRIDGE_OUT_GETPHYSPAGEADDR typedef struct PVRSRV_BRIDGE_IN_SGX_GETMMU_PDADDR_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hDevMemContext; +#endif }PVRSRV_BRIDGE_IN_SGX_GETMMU_PDADDR; @@ -121,7 +130,11 @@ typedef struct PVRSRV_BRIDGE_OUT_SGX_GETMMU_PDADDR_TAG typedef struct PVRSRV_BRIDGE_IN_GETCLIENTINFO_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif }PVRSRV_BRIDGE_IN_GETCLIENTINFO; @@ -135,7 +148,11 @@ typedef struct PVRSRV_BRIDGE_OUT_GETINTERNALDEVINFO_TAG typedef struct PVRSRV_BRIDGE_IN_GETINTERNALDEVINFO_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif }PVRSRV_BRIDGE_IN_GETINTERNALDEVINFO; @@ -148,8 +165,12 @@ typedef struct PVRSRV_BRIDGE_OUT_GETCLIENTINFO_TAG typedef struct PVRSRV_BRIDGE_IN_RELEASECLIENTINFO_TAG { - IMG_UINT32 ui32BridgeFlags; - IMG_HANDLE hDevCookie; + IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else + IMG_HANDLE hDevCookie; +#endif SGX_CLIENT_INFO sClientInfo; }PVRSRV_BRIDGE_IN_RELEASECLIENTINFO; @@ -157,14 +178,22 @@ typedef struct PVRSRV_BRIDGE_IN_RELEASECLIENTINFO_TAG typedef struct PVRSRV_BRIDGE_IN_ISPBREAKPOLL_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif }PVRSRV_BRIDGE_IN_ISPBREAKPOLL; typedef struct PVRSRV_BRIDGE_IN_DOKICK_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif SGX_CCB_KICK sCCBKick; }PVRSRV_BRIDGE_IN_DOKICK; @@ -172,7 +201,11 @@ typedef struct PVRSRV_BRIDGE_IN_DOKICK_TAG typedef struct PVRSRV_BRIDGE_IN_SGX_SCHEDULE_PROCESS_QUEUES_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif }PVRSRV_BRIDGE_IN_SGX_SCHEDULE_PROCESS_QUEUES; @@ -181,7 +214,11 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_SCHEDULE_PROCESS_QUEUES_TAG typedef struct PVRSRV_BRIDGE_IN_SUBMITTRANSFER_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif PVRSRV_TRANSFER_SGX_KICK sKick; }PVRSRV_BRIDGE_IN_SUBMITTRANSFER; @@ -190,8 +227,12 @@ typedef struct PVRSRV_BRIDGE_IN_SUBMITTRANSFER_TAG typedef struct PVRSRV_BRIDGE_IN_SUBMIT2D_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; - PVRSRV_2D_SGX_KICK sKick; +#endif + PVRSRV_2D_SGX_KICK sKick; } PVRSRV_BRIDGE_IN_SUBMIT2D; #endif #endif @@ -200,7 +241,11 @@ typedef struct PVRSRV_BRIDGE_IN_SUBMIT2D_TAG typedef struct PVRSRV_BRIDGE_IN_READREGDWORD_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_PCHAR pszKey; IMG_PCHAR pszValue; }PVRSRV_BRIDGE_IN_READREGDWORD; @@ -216,14 +261,22 @@ typedef struct PVRSRV_BRIDGE_OUT_READREGDWORD_TAG typedef struct PVRSRV_BRIDGE_IN_SGXGETMISCINFO_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif SGX_MISC_INFO *psMiscInfo; }PVRSRV_BRIDGE_IN_SGXGETMISCINFO; typedef struct PVRSRV_BRIDGE_IN_SGXINFO_FOR_SRVINIT_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif }PVRSRV_BRIDGE_IN_SGXINFO_FOR_SRVINIT; typedef struct PVRSRV_BRIDGE_OUT_SGXINFO_FOR_SRVINIT_TAG @@ -235,16 +288,32 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXINFO_FOR_SRVINIT_TAG typedef struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif SGX_BRIDGE_INIT_INFO sInitInfo; }PVRSRV_BRIDGE_IN_SGXDEVINITPART2; +typedef struct PVRSRV_BRIDGE_OUT_SGXDEVINITPART2_TAG +{ + PVRSRV_ERROR eError; + IMG_UINT32 ui32KMBuildOptions; + +}PVRSRV_BRIDGE_OUT_SGXDEVINITPART2; + typedef struct PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hKernSyncInfo; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hKernSyncInfo; +#endif IMG_BOOL bWaitForComplete; }PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE; @@ -254,13 +323,26 @@ typedef struct PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE_TAG typedef struct PVRSRV_BRIDGE_IN_SGXFINDSHAREDPBDESC_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; - IMG_BOOL bLockOnFailure; +#endif + IMG_BOOL bLockOnFailure; IMG_UINT32 ui32TotalPBSize; }PVRSRV_BRIDGE_IN_SGXFINDSHAREDPBDESC; typedef struct PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC_TAG { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; + IMG_SID hSharedPBDesc; + IMG_SID hSharedPBDescKernelMemInfoHandle; + IMG_SID hHWPBDescKernelMemInfoHandle; + IMG_SID hBlockKernelMemInfoHandle; + IMG_SID hHWBlockKernelMemInfoHandle; + IMG_SID ahSharedPBDescSubKernelMemInfoHandles[PVRSRV_BRIDGE_SGX_SHAREDPBDESC_MAX_SUBMEMINFOS]; +#else IMG_HANDLE hKernelMemInfo; IMG_HANDLE hSharedPBDesc; IMG_HANDLE hSharedPBDescKernelMemInfoHandle; @@ -268,6 +350,7 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC_TAG IMG_HANDLE hBlockKernelMemInfoHandle; IMG_HANDLE hHWBlockKernelMemInfoHandle; IMG_HANDLE ahSharedPBDescSubKernelMemInfoHandles[PVRSRV_BRIDGE_SGX_SHAREDPBDESC_MAX_SUBMEMINFOS]; +#endif IMG_UINT32 ui32SharedPBDescSubKernelMemInfoHandlesCount; PVRSRV_ERROR eError; }PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC; @@ -275,7 +358,11 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXFINDSHAREDPBDESC_TAG typedef struct PVRSRV_BRIDGE_IN_SGXUNREFSHAREDPBDESC_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSharedPBDesc; +#else IMG_HANDLE hSharedPBDesc; +#endif }PVRSRV_BRIDGE_IN_SGXUNREFSHAREDPBDESC; typedef struct PVRSRV_BRIDGE_OUT_SGXUNREFSHAREDPBDESC_TAG @@ -287,20 +374,34 @@ typedef struct PVRSRV_BRIDGE_OUT_SGXUNREFSHAREDPBDESC_TAG typedef struct PVRSRV_BRIDGE_IN_SGXADDSHAREDPBDESC_TAG { IMG_UINT32 ui32BridgeFlags; + IMG_UINT32 ui32TotalPBSize; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hSharedPBDescKernelMemInfo; + IMG_SID hHWPBDescKernelMemInfo; + IMG_SID hBlockKernelMemInfo; + IMG_SID hHWBlockKernelMemInfo; + IMG_SID *phKernelMemInfoHandles; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hSharedPBDescKernelMemInfo; IMG_HANDLE hHWPBDescKernelMemInfo; IMG_HANDLE hBlockKernelMemInfo; IMG_HANDLE hHWBlockKernelMemInfo; - IMG_UINT32 ui32TotalPBSize; IMG_HANDLE *phKernelMemInfoHandles; +#endif IMG_UINT32 ui32KernelMemInfoHandlesCount; + IMG_DEV_VIRTADDR sHWPBDescDevVAddr; }PVRSRV_BRIDGE_IN_SGXADDSHAREDPBDESC; typedef struct PVRSRV_BRIDGE_OUT_SGXADDSHAREDPBDESC_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hSharedPBDesc; +#else IMG_HANDLE hSharedPBDesc; +#endif }PVRSRV_BRIDGE_OUT_SGXADDSHAREDPBDESC; @@ -316,9 +417,15 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_BUFFER_ARRAY_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_3D_SIGNATURE_REGISTERS_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevCookie; + IMG_HANDLE hDevMemContext; +#endif IMG_UINT32 ui32DumpFrameNum; - IMG_BOOL bLastFrame; + IMG_BOOL bLastFrame; IMG_UINT32 *pui32Registers; IMG_UINT32 ui32NumRegisters; }PVRSRV_BRIDGE_IN_PDUMP_3D_SIGNATURE_REGISTERS; @@ -326,7 +433,11 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_3D_SIGNATURE_REGISTERS_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMPCOUNTER_REGISTERS_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_UINT32 ui32DumpFrameNum; IMG_BOOL bLastFrame; IMG_UINT32 *pui32Registers; @@ -336,7 +447,11 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMPCOUNTER_REGISTERS_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_TA_SIGNATURE_REGISTERS_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_UINT32 ui32DumpFrameNum; IMG_UINT32 ui32TAKickCount; IMG_BOOL bLastFrame; @@ -347,7 +462,13 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_TA_SIGNATURE_REGISTERS_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_HWPERFCB_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevCookie; + IMG_HANDLE hDevMemContext; +#endif IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_UINT32 ui32PDumpFlags; @@ -357,12 +478,19 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_HWPERFCB_TAG typedef struct PVRSRV_BRIDGE_IN_PDUMP_SAVEMEM { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hDevMemContext; +#else IMG_HANDLE hDevCookie; +#endif IMG_CHAR szFileName[PVRSRV_PDUMP_MAX_FILENAME_SIZE]; IMG_UINT32 ui32FileOffset; IMG_DEV_VIRTADDR sDevVAddr; IMG_UINT32 ui32Size; - IMG_UINT32 ui32DataMaster; +#if !defined (SUPPORT_SID_INTERFACE) + IMG_HANDLE hDevMemContext; +#endif IMG_UINT32 ui32PDumpFlags; }PVRSRV_BRIDGE_IN_PDUMP_SAVEMEM; @@ -372,47 +500,79 @@ typedef struct PVRSRV_BRIDGE_IN_PDUMP_SAVEMEM typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_DEV_VIRTADDR sHWRenderContextDevVAddr; }PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT; typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHWRenderContext; +#else IMG_HANDLE hHWRenderContext; +#endif }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_RENDER_CONTEXT; typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_RENDER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; + IMG_BOOL bForceCleanup; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hHWRenderContext; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hHWRenderContext; +#endif }PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_RENDER_CONTEXT; typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_DEV_VIRTADDR sHWTransferContextDevVAddr; }PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_TRANSFER_CONTEXT; typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHWTransferContext; +#else IMG_HANDLE hHWTransferContext; +#endif }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_TRANSFER_CONTEXT; typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_TRANSFER_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; + IMG_BOOL bForceCleanup; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hHWTransferContext; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hHWTransferContext; +#endif }PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_TRANSFER_CONTEXT; typedef struct PVRSRV_BRIDGE_IN_SGX_FLUSH_HW_RENDER_TARGET_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_DEV_VIRTADDR sHWRTDataSetDevVAddr; }PVRSRV_BRIDGE_IN_SGX_FLUSH_HW_RENDER_TARGET; @@ -421,21 +581,35 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_FLUSH_HW_RENDER_TARGET_TAG typedef struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_2D_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_DEV_VIRTADDR sHW2DContextDevVAddr; }PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_2D_CONTEXT; typedef struct PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT_TAG { PVRSRV_ERROR eError; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHW2DContext; +#else IMG_HANDLE hHW2DContext; +#endif }PVRSRV_BRIDGE_OUT_SGX_REGISTER_HW_2D_CONTEXT; typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT_TAG { IMG_UINT32 ui32BridgeFlags; + IMG_BOOL bForceCleanup; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; + IMG_SID hHW2DContext; +#else IMG_HANDLE hDevCookie; IMG_HANDLE hHW2DContext; +#endif }PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT; #define SGX2D_MAX_BLT_CMD_SIZ 256 @@ -445,7 +619,11 @@ typedef struct PVRSRV_BRIDGE_IN_SGX_UNREGISTER_HW_2D_CONTEXT_TAG typedef struct PVRSRV_BRIDGE_IN_SGX_READ_HWPERF_CB_TAG { IMG_UINT32 ui32BridgeFlags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hDevCookie; +#else IMG_HANDLE hDevCookie; +#endif IMG_UINT32 ui32ArraySize; PVRSRV_SGX_HWPERF_CB_ENTRY *psHWPerfCBData; } PVRSRV_BRIDGE_IN_SGX_READ_HWPERF_CB; diff --git a/drivers/gpu/pvr/sgx_mkif_km.h b/drivers/gpu/pvr/sgx_mkif_km.h index 8029321..2d78baa 100644 --- a/drivers/gpu/pvr/sgx_mkif_km.h +++ b/drivers/gpu/pvr/sgx_mkif_km.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -32,29 +32,25 @@ #include "sgxapi_km.h" +#if !defined (SGX_MP_CORE_SELECT) #if defined(SGX_FEATURE_MP) - #define SGX_REG_BANK_SHIFT (12) - #define SGX_REG_BANK_SIZE (0x4000) - #if defined(SGX541) - #define SGX_REG_BANK_BASE_INDEX (1) - #define SGX_REG_BANK_MASTER_INDEX (SGX_REG_BANK_BASE_INDEX + SGX_FEATURE_MP_CORE_COUNT) - #else - #define SGX_REG_BANK_BASE_INDEX (2) - #define SGX_REG_BANK_MASTER_INDEX (1) - #endif + #define SGX_REG_BANK_SHIFT (14) + #define SGX_REG_BANK_SIZE (1 << SGX_REG_BANK_SHIFT) + #define SGX_REG_BANK_BASE_INDEX (2) + #define SGX_REG_BANK_MASTER_INDEX (1) #define SGX_MP_CORE_SELECT(x,i) (x + ((i + SGX_REG_BANK_BASE_INDEX) * SGX_REG_BANK_SIZE)) #define SGX_MP_MASTER_SELECT(x) (x + (SGX_REG_BANK_MASTER_INDEX * SGX_REG_BANK_SIZE)) #else #define SGX_MP_CORE_SELECT(x,i) (x) #endif +#endif typedef struct _SGXMKIF_COMMAND_ { IMG_UINT32 ui32ServiceAddress; IMG_UINT32 ui32CacheControl; - IMG_UINT32 ui32Data[4]; - IMG_UINT32 ui32Padding[2]; + IMG_UINT32 ui32Data[6]; } SGXMKIF_COMMAND; @@ -99,6 +95,7 @@ typedef struct _SGXMKIF_HOST_CTL_ IMG_UINT32 ui32TimeWraps; IMG_UINT32 ui32HostClock; + IMG_UINT32 ui32AssertFail; #if defined(SGX_FEATURE_EXTENDED_PERF_COUNTERS) IMG_UINT32 aui32PerfGroup[PVRSRV_SGX_HWPERF_NUM_COUNTERS]; @@ -106,6 +103,12 @@ typedef struct _SGXMKIF_HOST_CTL_ #else IMG_UINT32 ui32PerfGroup; #endif + +#if defined(FIX_HW_BRN_31939) + IMG_UINT32 ui32BRN31939Mem; +#endif + + IMG_UINT32 ui32OpenCLDelayCount; } SGXMKIF_HOST_CTL; #define SGXMKIF_CMDTA_CTRLFLAGS_READY 0x00000001 @@ -173,13 +176,6 @@ typedef struct _SGXMKIF_TRANSFERCMD_SHARED_ IMG_UINT32 ui32NumDstSyncs; PVRSRV_DEVICE_SYNC_OBJECT asDstSyncs[SGX_MAX_DST_SYNCS]; - IMG_UINT32 ui32DstReadOpPendingVal; - IMG_DEV_VIRTADDR sDstReadOpsCompleteDevAddr; - - IMG_UINT32 ui32DstWriteOpPendingVal; - IMG_DEV_VIRTADDR sDstWriteOpsCompleteDevAddr; - - IMG_UINT32 ui32TASyncWriteOpsPendingVal; IMG_DEV_VIRTADDR sTASyncWriteOpsCompleteDevVAddr; IMG_UINT32 ui32TASyncReadOpsPendingVal; @@ -232,6 +228,7 @@ typedef struct _SGXMKIF_HWDEVICE_SYNC_LIST_ #define PVRSRV_USSE_EDM_INTERRUPT_HWR (1UL << 0) #define PVRSRV_USSE_EDM_INTERRUPT_ACTIVE_POWER (1UL << 1) +#define PVRSRV_USSE_EDM_INTERRUPT_IDLE (1UL << 2) #define PVRSRV_USSE_EDM_CLEANUPCMD_COMPLETE (1UL << 0) @@ -250,18 +247,21 @@ typedef struct _SGXMKIF_HWDEVICE_SYNC_LIST_ #endif -#define PVRSRV_CLEANUPCMD_RT 0x1 -#define PVRSRV_CLEANUPCMD_RC 0x2 -#define PVRSRV_CLEANUPCMD_TC 0x3 -#define PVRSRV_CLEANUPCMD_2DC 0x4 -#define PVRSRV_CLEANUPCMD_PB 0x5 +#define PVRSRV_CLEANUPCMD_RT 0x1U +#define PVRSRV_CLEANUPCMD_RC 0x2U +#define PVRSRV_CLEANUPCMD_TC 0x3U +#define PVRSRV_CLEANUPCMD_2DC 0x4U +#define PVRSRV_CLEANUPCMD_PB 0x5U -#define PVRSRV_POWERCMD_POWEROFF 0x1 -#define PVRSRV_POWERCMD_IDLE 0x2 -#define PVRSRV_POWERCMD_RESUME 0x3 +#define PVRSRV_POWERCMD_POWEROFF 0x1U +#define PVRSRV_POWERCMD_IDLE 0x2U +#define PVRSRV_POWERCMD_RESUME 0x3U +#define PVRSRV_CTXSUSPCMD_SUSPEND 0x1U +#define PVRSRV_CTXSUSPCMD_RESUME 0x2U -#if defined(SGX_FEATURE_BIF_NUM_DIRLISTS) + +#if defined(SGX_FEATURE_MULTIPLE_MEM_CONTEXTS) #define SGX_BIF_DIR_LIST_INDEX_EDM (SGX_FEATURE_BIF_NUM_DIRLISTS - 1) #else #define SGX_BIF_DIR_LIST_INDEX_EDM (0) @@ -323,12 +323,16 @@ typedef struct _PVRSRV_SGX_MISCINFO_INFO typedef struct _SGXMKIF_HWPERF_CB_ENTRY_ { IMG_UINT32 ui32FrameNo; + IMG_UINT32 ui32PID; + IMG_UINT32 ui32RTData; IMG_UINT32 ui32Type; IMG_UINT32 ui32Ordinal; IMG_UINT32 ui32Info; IMG_UINT32 ui32TimeWraps; IMG_UINT32 ui32Time; - IMG_UINT32 ui32Counters[SGX_FEATURE_MP_CORE_COUNT][PVRSRV_SGX_HWPERF_NUM_COUNTERS]; + + IMG_UINT32 ui32Counters[SGX_FEATURE_MP_CORE_COUNT_3D][PVRSRV_SGX_HWPERF_NUM_COUNTERS]; + IMG_UINT32 ui32MiscCounters[SGX_FEATURE_MP_CORE_COUNT_3D][PVRSRV_SGX_HWPERF_NUM_MISC_COUNTERS]; } SGXMKIF_HWPERF_CB_ENTRY; typedef struct _SGXMKIF_HWPERF_CB_ diff --git a/drivers/gpu/pvr/sgx_options.h b/drivers/gpu/pvr/sgx_options.h index 6f91894..c70d1eb 100644 --- a/drivers/gpu/pvr/sgx_options.h +++ b/drivers/gpu/pvr/sgx_options.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,179 +22,208 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +******************************************************************************/ + +/* Each build option listed here is packed into a dword which + * provides up to 32 flags (or up to 28 flags plus a numeric + * value in the range 0-15 which corresponds to the number of + * cores minus one if SGX_FEATURE_MP is defined). The corresponding + * bit is set if the build option was enabled at compile time. + * + * In order to extract the enabled build flags the INTERNAL_TEST + * switch should be enabled in a client program which includes this + * header. Then the client can test specific build flags by reading + * the bit value at ##OPTIONNAME##_SET_OFFSET in SGX_BUILD_OPTIONS. + * + * IMPORTANT: add new options to unused bits or define a new dword + * (e.g. SGX_BUILD_OPTIONS2) so that the bitfield remains backwards + * compatible. + */ + #if defined(DEBUG) || defined (INTERNAL_TEST) #define DEBUG_SET_OFFSET OPTIONS_BIT0 -#define OPTIONS_BIT0 0x1 +#define OPTIONS_BIT0 0x1U #else #define OPTIONS_BIT0 0x0 -#endif +#endif /* DEBUG */ #if defined(PDUMP) || defined (INTERNAL_TEST) #define PDUMP_SET_OFFSET OPTIONS_BIT1 -#define OPTIONS_BIT1 (0x1 << 1) +#define OPTIONS_BIT1 (0x1U << 1) #else #define OPTIONS_BIT1 0x0 -#endif +#endif /* PDUMP */ #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) || defined (INTERNAL_TEST) #define PVRSRV_USSE_EDM_STATUS_DEBUG_SET_OFFSET OPTIONS_BIT2 -#define OPTIONS_BIT2 (0x1 << 2) +#define OPTIONS_BIT2 (0x1U << 2) #else #define OPTIONS_BIT2 0x0 -#endif +#endif /* PVRSRV_USSE_EDM_STATUS_DEBUG */ #if defined(SUPPORT_HW_RECOVERY) || defined (INTERNAL_TEST) #define SUPPORT_HW_RECOVERY_SET_OFFSET OPTIONS_BIT3 -#define OPTIONS_BIT3 (0x1 << 3) +#define OPTIONS_BIT3 (0x1U << 3) #else #define OPTIONS_BIT3 0x0 -#endif +#endif /* SUPPORT_HW_RECOVERY */ +#if defined (SUPPORT_SID_INTERFACE) +#define PVR_SECURE_HANDLES_SET_OFFSET OPTIONS_BIT4 +#define OPTIONS_BIT4 (0x1U << 4) +#else #if defined(PVR_SECURE_HANDLES) || defined (INTERNAL_TEST) #define PVR_SECURE_HANDLES_SET_OFFSET OPTIONS_BIT4 -#define OPTIONS_BIT4 (0x1 << 4) +#define OPTIONS_BIT4 (0x1U << 4) #else #define OPTIONS_BIT4 0x0 -#endif +#endif /* PVR_SECURE_HANDLES */ +#endif #if defined(SGX_BYPASS_SYSTEM_CACHE) || defined (INTERNAL_TEST) #define SGX_BYPASS_SYSTEM_CACHE_SET_OFFSET OPTIONS_BIT5 -#define OPTIONS_BIT5 (0x1 << 5) +#define OPTIONS_BIT5 (0x1U << 5) #else #define OPTIONS_BIT5 0x0 -#endif +#endif /* SGX_BYPASS_SYSTEM_CACHE */ #if defined(SGX_DMS_AGE_ENABLE) || defined (INTERNAL_TEST) #define SGX_DMS_AGE_ENABLE_SET_OFFSET OPTIONS_BIT6 -#define OPTIONS_BIT6 (0x1 << 6) +#define OPTIONS_BIT6 (0x1U << 6) #else #define OPTIONS_BIT6 0x0 -#endif +#endif /* SGX_DMS_AGE_ENABLE */ #if defined(SGX_FAST_DPM_INIT) || defined (INTERNAL_TEST) #define SGX_FAST_DPM_INIT_SET_OFFSET OPTIONS_BIT8 -#define OPTIONS_BIT8 (0x1 << 8) +#define OPTIONS_BIT8 (0x1U << 8) #else #define OPTIONS_BIT8 0x0 -#endif +#endif /* SGX_FAST_DPM_INIT */ #if defined(SGX_FEATURE_WRITEBACK_DCU) || defined (INTERNAL_TEST) #define SGX_FEATURE_DCU_SET_OFFSET OPTIONS_BIT9 -#define OPTIONS_BIT9 (0x1 << 9) +#define OPTIONS_BIT9 (0x1U << 9) #else #define OPTIONS_BIT9 0x0 -#endif +#endif /* SGX_FEATURE_WRITEBACK_DCU */ #if defined(SGX_FEATURE_MP) || defined (INTERNAL_TEST) #define SGX_FEATURE_MP_SET_OFFSET OPTIONS_BIT10 -#define OPTIONS_BIT10 (0x1 << 10) +#define OPTIONS_BIT10 (0x1U << 10) #else #define OPTIONS_BIT10 0x0 -#endif +#endif /* SGX_FEATURE_MP */ #if defined(SGX_FEATURE_MULTITHREADED_UKERNEL) || defined (INTERNAL_TEST) #define SGX_FEATURE_MULTITHREADED_UKERNEL_SET_OFFSET OPTIONS_BIT11 -#define OPTIONS_BIT11 (0x1 << 11) +#define OPTIONS_BIT11 (0x1U << 11) #else #define OPTIONS_BIT11 0x0 -#endif +#endif /* SGX_FEATURE_MULTITHREADED_UKERNEL */ #if defined(SGX_FEATURE_OVERLAPPED_SPM) || defined (INTERNAL_TEST) #define SGX_FEATURE_OVERLAPPED_SPM_SET_OFFSET OPTIONS_BIT12 -#define OPTIONS_BIT12 (0x1 << 12) +#define OPTIONS_BIT12 (0x1U << 12) #else #define OPTIONS_BIT12 0x0 -#endif +#endif /* SGX_FEATURE_RENDER_TARGET_ARRAYS */ #if defined(SGX_FEATURE_SYSTEM_CACHE) || defined (INTERNAL_TEST) #define SGX_FEATURE_SYSTEM_CACHE_SET_OFFSET OPTIONS_BIT13 -#define OPTIONS_BIT13 (0x1 << 13) +#define OPTIONS_BIT13 (0x1U << 13) #else #define OPTIONS_BIT13 0x0 -#endif +#endif /* SGX_FEATURE_SYSTEM_CACHE */ #if defined(SGX_SUPPORT_HWPROFILING) || defined (INTERNAL_TEST) #define SGX_SUPPORT_HWPROFILING_SET_OFFSET OPTIONS_BIT14 -#define OPTIONS_BIT14 (0x1 << 14) +#define OPTIONS_BIT14 (0x1U << 14) #else #define OPTIONS_BIT14 0x0 -#endif +#endif /* SGX_SUPPORT_HWPROFILING */ #if defined(SUPPORT_ACTIVE_POWER_MANAGEMENT) || defined (INTERNAL_TEST) #define SUPPORT_ACTIVE_POWER_MANAGEMENT_SET_OFFSET OPTIONS_BIT15 -#define OPTIONS_BIT15 (0x1 << 15) +#define OPTIONS_BIT15 (0x1U << 15) #else #define OPTIONS_BIT15 0x0 -#endif +#endif /* SUPPORT_ACTIVE_POWER_MANAGEMENT */ #if defined(SUPPORT_DISPLAYCONTROLLER_TILING) || defined (INTERNAL_TEST) #define SUPPORT_DISPLAYCONTROLLER_TILING_SET_OFFSET OPTIONS_BIT16 -#define OPTIONS_BIT16 (0x1 << 16) +#define OPTIONS_BIT16 (0x1U << 16) #else #define OPTIONS_BIT16 0x0 -#endif +#endif /* SUPPORT_DISPLAYCONTROLLER_TILING */ #if defined(SUPPORT_PERCONTEXT_PB) || defined (INTERNAL_TEST) #define SUPPORT_PERCONTEXT_PB_SET_OFFSET OPTIONS_BIT17 -#define OPTIONS_BIT17 (0x1 << 17) +#define OPTIONS_BIT17 (0x1U << 17) #else #define OPTIONS_BIT17 0x0 -#endif +#endif /* SUPPORT_PERCONTEXT_PB */ #if defined(SUPPORT_SGX_HWPERF) || defined (INTERNAL_TEST) #define SUPPORT_SGX_HWPERF_SET_OFFSET OPTIONS_BIT18 -#define OPTIONS_BIT18 (0x1 << 18) +#define OPTIONS_BIT18 (0x1U << 18) #else #define OPTIONS_BIT18 0x0 -#endif +#endif /* SUPPORT_SGX_HWPERF */ #if defined(SUPPORT_SGX_MMU_DUMMY_PAGE) || defined (INTERNAL_TEST) #define SUPPORT_SGX_MMU_DUMMY_PAGE_SET_OFFSET OPTIONS_BIT19 -#define OPTIONS_BIT19 (0x1 << 19) +#define OPTIONS_BIT19 (0x1U << 19) #else #define OPTIONS_BIT19 0x0 -#endif +#endif /* SUPPORT_SGX_MMU_DUMMY_PAGE */ #if defined(SUPPORT_SGX_PRIORITY_SCHEDULING) || defined (INTERNAL_TEST) #define SUPPORT_SGX_PRIORITY_SCHEDULING_SET_OFFSET OPTIONS_BIT20 -#define OPTIONS_BIT20 (0x1 << 20) +#define OPTIONS_BIT20 (0x1U << 20) #else #define OPTIONS_BIT20 0x0 -#endif +#endif /* SUPPORT_SGX_PRIORITY_SCHEDULING */ #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) || defined (INTERNAL_TEST) #define SUPPORT_SGX_LOW_LATENCY_SCHEDULING_SET_OFFSET OPTIONS_BIT21 -#define OPTIONS_BIT21 (0x1 << 21) +#define OPTIONS_BIT21 (0x1U << 21) #else #define OPTIONS_BIT21 0x0 -#endif +#endif /* SUPPORT_SGX_LOW_LATENCY_SCHEDULING */ #if defined(USE_SUPPORT_NO_TA3D_OVERLAP) || defined (INTERNAL_TEST) #define USE_SUPPORT_NO_TA3D_OVERLAP_SET_OFFSET OPTIONS_BIT22 -#define OPTIONS_BIT22 (0x1 << 22) +#define OPTIONS_BIT22 (0x1U << 22) #else #define OPTIONS_BIT22 0x0 -#endif - +#endif /* USE_SUPPORT_NO_TA3D_OVERLAP */ #if defined(SGX_FEATURE_MP) || defined (INTERNAL_TEST) +#if defined(SGX_FEATURE_MP_CORE_COUNT) #define OPTIONS_HIGHBYTE ((SGX_FEATURE_MP_CORE_COUNT-1) << SGX_FEATURE_MP_CORE_COUNT_SET_OFFSET) #define SGX_FEATURE_MP_CORE_COUNT_SET_OFFSET 28UL #define SGX_FEATURE_MP_CORE_COUNT_SET_MASK 0xFF #else +#define OPTIONS_HIGHBYTE (((SGX_FEATURE_MP_CORE_COUNT_TA-1) << SGX_FEATURE_MP_CORE_COUNT_SET_OFFSET) |\ + ((SGX_FEATURE_MP_CORE_COUNT_3D-1) << SGX_FEATURE_MP_CORE_COUNT_SET_OFFSET_3D)) +#define SGX_FEATURE_MP_CORE_COUNT_SET_OFFSET 24UL +#define SGX_FEATURE_MP_CORE_COUNT_SET_OFFSET_3D 28UL +#define SGX_FEATURE_MP_CORE_COUNT_SET_MASK 0xFF +#endif +#else /* SGX_FEATURE_MP */ #define OPTIONS_HIGHBYTE 0x0 -#endif +#endif /* SGX_FEATURE_MP */ diff --git a/drivers/gpu/pvr/sgxapi_km.h b/drivers/gpu/pvr/sgxapi_km.h index f38a85c..bd8dcb0 100644 --- a/drivers/gpu/pvr/sgxapi_km.h +++ b/drivers/gpu/pvr/sgxapi_km.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,7 +22,7 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ +******************************************************************************/ #ifndef __SGXAPI_KM_H__ #define __SGXAPI_KM_H__ @@ -41,6 +41,11 @@ extern "C" { #endif #endif +/****************************************************************************** + Some defines... +******************************************************************************/ + +/* SGX Heap IDs, note: not all heaps are available to clients */ #define SGX_UNDEFINED_HEAP_ID (~0LU) #define SGX_GENERAL_HEAP_ID 0 #define SGX_TADATA_HEAP_ID 1 @@ -51,19 +56,35 @@ extern "C" { #define SGX_PDSPIXEL_CODEDATA_HEAP_ID 6 #define SGX_PDSVERTEX_CODEDATA_HEAP_ID 7 #define SGX_SYNCINFO_HEAP_ID 8 -#define SGX_3DPARAMETERS_HEAP_ID 9 +#define SGX_SHARED_3DPARAMETERS_HEAP_ID 9 +#define SGX_PERCONTEXT_3DPARAMETERS_HEAP_ID 10 #if defined(SUPPORT_SGX_GENERAL_MAPPING_HEAP) -#define SGX_GENERAL_MAPPING_HEAP_ID 10 +#define SGX_GENERAL_MAPPING_HEAP_ID 11 #endif #if defined(SGX_FEATURE_2D_HARDWARE) -#define SGX_2D_HEAP_ID 11 +#define SGX_2D_HEAP_ID 12 #else #if defined(FIX_HW_BRN_26915) -#define SGX_CGBUFFER_HEAP_ID 12 +#define SGX_CGBUFFER_HEAP_ID 13 +#endif #endif +#if defined(SUPPORT_MEMORY_TILING) +#define SGX_VPB_TILED_HEAP_ID 14 #endif -#define SGX_MAX_HEAP_ID 13 +#define SGX_MAX_HEAP_ID 15 + +/* + * Keep SGX_3DPARAMETERS_HEAP_ID as TQ full custom + * shaders need it to select which heap to write + * their ISP controll stream to. + */ +#if (defined(SUPPORT_PERCONTEXT_PB) || defined(SUPPORT_HYBRID_PB)) +#define SGX_3DPARAMETERS_HEAP_ID SGX_PERCONTEXT_3DPARAMETERS_HEAP_ID +#else +#define SGX_3DPARAMETERS_HEAP_ID SGX_SHARED_3DPARAMETERS_HEAP_ID +#endif +/* Define for number of bytes between consecutive code base registers */ #if defined(SGX543) || defined(SGX544) || defined(SGX554) #define SGX_USE_CODE_SEGMENT_RANGE_BITS 23 #else @@ -74,25 +95,26 @@ extern "C" { #define SGX_MAX_3D_STATUS_VALS 4 #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) +/* sync info structure array size */ #define SGX_MAX_TA_DST_SYNCS 1 #define SGX_MAX_TA_SRC_SYNCS 1 #define SGX_MAX_3D_SRC_SYNCS 4 +/* note: there is implicitly 1 3D Dst Sync */ #else -#if defined(ANDROID) +/* sync info structure array size */ #define SGX_MAX_SRC_SYNCS 8 #define SGX_MAX_DST_SYNCS 1 -#else -#define SGX_MAX_SRC_SYNCS 4 -#define SGX_MAX_DST_SYNCS 1 -#endif +/* note: there is implicitly 1 3D Dst Sync */ #endif #if defined(SGX_FEATURE_EXTENDED_PERF_COUNTERS) #define PVRSRV_SGX_HWPERF_NUM_COUNTERS 8 +#define PVRSRV_SGX_HWPERF_NUM_MISC_COUNTERS 11 #else #define PVRSRV_SGX_HWPERF_NUM_COUNTERS 9 -#endif +#define PVRSRV_SGX_HWPERF_NUM_MISC_COUNTERS 8 +#endif /* SGX543 */ #define PVRSRV_SGX_HWPERF_INVALID 0x1 @@ -102,11 +124,19 @@ extern "C" { #define PVRSRV_SGX_HWPERF_2D 0x5 #define PVRSRV_SGX_HWPERF_POWER 0x6 #define PVRSRV_SGX_HWPERF_PERIODIC 0x7 +#define PVRSRV_SGX_HWPERF_3DSPM 0x8 #define PVRSRV_SGX_HWPERF_MK_EVENT 0x101 #define PVRSRV_SGX_HWPERF_MK_TA 0x102 #define PVRSRV_SGX_HWPERF_MK_3D 0x103 #define PVRSRV_SGX_HWPERF_MK_2D 0x104 +#define PVRSRV_SGX_HWPERF_MK_TRANSFER_DUMMY 0x105 +#define PVRSRV_SGX_HWPERF_MK_TA_DUMMY 0x106 +#define PVRSRV_SGX_HWPERF_MK_3D_DUMMY 0x107 +#define PVRSRV_SGX_HWPERF_MK_2D_DUMMY 0x108 +#define PVRSRV_SGX_HWPERF_MK_TA_LOCKUP 0x109 +#define PVRSRV_SGX_HWPERF_MK_3D_LOCKUP 0x10A +#define PVRSRV_SGX_HWPERF_MK_2D_LOCKUP 0x10B #define PVRSRV_SGX_HWPERF_TYPE_STARTEND_BIT 28 #define PVRSRV_SGX_HWPERF_TYPE_OP_MASK ((1UL << PVRSRV_SGX_HWPERF_TYPE_STARTEND_BIT) - 1) @@ -124,6 +154,19 @@ extern "C" { #define PVRSRV_SGX_HWPERF_TYPE_POWER_START (PVRSRV_SGX_HWPERF_POWER | PVRSRV_SGX_HWPERF_TYPE_OP_START) #define PVRSRV_SGX_HWPERF_TYPE_POWER_END (PVRSRV_SGX_HWPERF_POWER | PVRSRV_SGX_HWPERF_TYPE_OP_END) #define PVRSRV_SGX_HWPERF_TYPE_PERIODIC (PVRSRV_SGX_HWPERF_PERIODIC) +#define PVRSRV_SGX_HWPERF_TYPE_3DSPM_START (PVRSRV_SGX_HWPERF_3DSPM | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_3DSPM_END (PVRSRV_SGX_HWPERF_3DSPM | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_MK_TRANSFER_DUMMY_START (PVRSRV_SGX_HWPERF_MK_TRANSFER_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_MK_TRANSFER_DUMMY_END (PVRSRV_SGX_HWPERF_MK_TRANSFER_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_MK_TA_DUMMY_START (PVRSRV_SGX_HWPERF_MK_TA_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_MK_TA_DUMMY_END (PVRSRV_SGX_HWPERF_MK_TA_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_MK_3D_DUMMY_START (PVRSRV_SGX_HWPERF_MK_3D_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_MK_3D_DUMMY_END (PVRSRV_SGX_HWPERF_MK_3D_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_MK_2D_DUMMY_START (PVRSRV_SGX_HWPERF_MK_2D_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_START) +#define PVRSRV_SGX_HWPERF_TYPE_MK_2D_DUMMY_END (PVRSRV_SGX_HWPERF_MK_2D_DUMMY | PVRSRV_SGX_HWPERF_TYPE_OP_END) +#define PVRSRV_SGX_HWPERF_TYPE_MK_TA_LOCKUP (PVRSRV_SGX_HWPERF_MK_TA_LOCKUP) +#define PVRSRV_SGX_HWPERF_TYPE_MK_3D_LOCKUP (PVRSRV_SGX_HWPERF_MK_3D_LOCKUP) +#define PVRSRV_SGX_HWPERF_TYPE_MK_2D_LOCKUP (PVRSRV_SGX_HWPERF_MK_2D_LOCKUP) #define PVRSRV_SGX_HWPERF_TYPE_MK_EVENT_START (PVRSRV_SGX_HWPERF_MK_EVENT | PVRSRV_SGX_HWPERF_TYPE_OP_START) #define PVRSRV_SGX_HWPERF_TYPE_MK_EVENT_END (PVRSRV_SGX_HWPERF_MK_EVENT | PVRSRV_SGX_HWPERF_TYPE_OP_END) @@ -141,17 +184,28 @@ extern "C" { #define PVRSRV_SGX_HWPERF_STATUS_MK_EXECUTION_ON (1UL << 3) +/*! + ***************************************************************************** + * One entry in the HWPerf Circular Buffer. + *****************************************************************************/ typedef struct _PVRSRV_SGX_HWPERF_CB_ENTRY_ { IMG_UINT32 ui32FrameNo; + IMG_UINT32 ui32PID; + IMG_UINT32 ui32RTData; IMG_UINT32 ui32Type; IMG_UINT32 ui32Ordinal; IMG_UINT32 ui32Info; IMG_UINT32 ui32Clocksx16; - IMG_UINT32 ui32Counters[SGX_FEATURE_MP_CORE_COUNT][PVRSRV_SGX_HWPERF_NUM_COUNTERS]; + /* NOTE: There should always be at least as many 3D cores as TA cores. */ + IMG_UINT32 ui32Counters[SGX_FEATURE_MP_CORE_COUNT_3D][PVRSRV_SGX_HWPERF_NUM_COUNTERS]; + IMG_UINT32 ui32MiscCounters[SGX_FEATURE_MP_CORE_COUNT_3D][PVRSRV_SGX_HWPERF_NUM_MISC_COUNTERS]; } PVRSRV_SGX_HWPERF_CB_ENTRY; +/* + Status values control structure +*/ typedef struct _CTL_STATUS_ { IMG_DEV_VIRTADDR sStatusDevAddr; @@ -159,6 +213,9 @@ typedef struct _CTL_STATUS_ } CTL_STATUS; +/*! + List of possible requests/commands to SGXGetMiscInfo() +*/ typedef enum _SGX_MISC_INFO_REQUEST_ { SGX_MISC_INFO_REQUEST_CLOCKSPEED = 0, @@ -167,14 +224,13 @@ typedef enum _SGX_MISC_INFO_REQUEST_ #if defined(SUPPORT_SGX_EDM_MEMORY_DEBUG) SGX_MISC_INFO_REQUEST_MEMREAD, SGX_MISC_INFO_REQUEST_MEMCOPY, -#endif +#endif /* SUPPORT_SGX_EDM_MEMORY_DEBUG */ SGX_MISC_INFO_REQUEST_SET_HWPERF_STATUS, #if defined(SGX_FEATURE_DATA_BREAKPOINTS) SGX_MISC_INFO_REQUEST_SET_BREAKPOINT, - SGX_MISC_INFO_REQUEST_WAIT_FOR_BREAKPOINT, SGX_MISC_INFO_REQUEST_POLL_BREAKPOINT, SGX_MISC_INFO_REQUEST_RESUME_BREAKPOINT, -#endif +#endif /* SGX_FEATURE_DATA_BREAKPOINTS */ SGX_MISC_INFO_DUMP_DEBUG_INFO, SGX_MISC_INFO_PANIC, SGX_MISC_INFO_REQUEST_SPM, @@ -184,66 +240,84 @@ typedef enum _SGX_MISC_INFO_REQUEST_ } SGX_MISC_INFO_REQUEST; +/****************************************************************************** + * Struct for passing SGX core rev/features from ukernel to driver. + * This is accessed from the kernel part of the driver and microkernel; it is + * only accessed in user space during buffer allocation in srvinit. + ******************************************************************************/ typedef struct _PVRSRV_SGX_MISCINFO_FEATURES { - IMG_UINT32 ui32CoreRev; - IMG_UINT32 ui32CoreID; - IMG_UINT32 ui32DDKVersion; - IMG_UINT32 ui32DDKBuild; - IMG_UINT32 ui32CoreIdSW; - IMG_UINT32 ui32CoreRevSW; - IMG_UINT32 ui32BuildOptions; + IMG_UINT32 ui32CoreRev; /*!< SGX Core revision from HW register */ + IMG_UINT32 ui32CoreID; /*!< SGX Core ID from HW register */ + IMG_UINT32 ui32DDKVersion; /*!< software DDK version */ + IMG_UINT32 ui32DDKBuild; /*!< software DDK build no. */ + IMG_UINT32 ui32CoreIdSW; /*!< software core version (ID), e.g. SGX535, SGX540 */ + IMG_UINT32 ui32CoreRevSW; /*!< software core revision */ + IMG_UINT32 ui32BuildOptions; /*!< build options bit-field */ #if defined(SUPPORT_SGX_EDM_MEMORY_DEBUG) - IMG_UINT32 ui32DeviceMemValue; + IMG_UINT32 ui32DeviceMemValue; /*!< device mem value read from ukernel */ #endif #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) - IMG_DEV_VIRTADDR sDevVAEDMStatusBuffer; - IMG_PVOID pvEDMStatusBuffer; + IMG_DEV_VIRTADDR sDevVAEDMStatusBuffer; /*!< DevVAddr of the EDM status buffer */ + IMG_PVOID pvEDMStatusBuffer; /*!< CPUVAddr of the EDM status buffer */ #endif } PVRSRV_SGX_MISCINFO_FEATURES; +/****************************************************************************** + * Struct for getting lock-up stats from the kernel driver + ******************************************************************************/ typedef struct _PVRSRV_SGX_MISCINFO_LOCKUPS { - IMG_UINT32 ui32HostDetectedLockups; - IMG_UINT32 ui32uKernelDetectedLockups; + IMG_UINT32 ui32HostDetectedLockups; /*!< Host timer detected lockups */ + IMG_UINT32 ui32uKernelDetectedLockups; /*!< Microkernel detected lockups */ } PVRSRV_SGX_MISCINFO_LOCKUPS; +/****************************************************************************** + * Struct for getting lock-up stats from the kernel driver + ******************************************************************************/ typedef struct _PVRSRV_SGX_MISCINFO_ACTIVEPOWER { - IMG_UINT32 ui32NumActivePowerEvents; + IMG_UINT32 ui32NumActivePowerEvents; /*!< active power events */ } PVRSRV_SGX_MISCINFO_ACTIVEPOWER; +/****************************************************************************** + * Struct for getting SPM stats fro the kernel driver + ******************************************************************************/ typedef struct _PVRSRV_SGX_MISCINFO_SPM { - IMG_HANDLE hRTDataSet; - IMG_UINT32 ui32NumOutOfMemSignals; - IMG_UINT32 ui32NumSPMRenders; + IMG_HANDLE hRTDataSet; /*!< render target data set handle returned from SGXAddRenderTarget */ + IMG_UINT32 ui32NumOutOfMemSignals; /*!< Number of Out of Mem Signals */ + IMG_UINT32 ui32NumSPMRenders; /*!< Number of SPM renders */ } PVRSRV_SGX_MISCINFO_SPM; #if defined(SGX_FEATURE_DATA_BREAKPOINTS) +/*! + ****************************************************************************** + * Structure for SGX break points control + *****************************************************************************/ typedef struct _SGX_BREAKPOINT_INFO { - + /* set/clear BP boolean */ IMG_BOOL bBPEnable; - + /* Index of BP to set */ IMG_UINT32 ui32BPIndex; - + /* On which DataMaster(s) should the breakpoint fire? */ IMG_UINT32 ui32DataMasterMask; - + /* DevVAddr of BP to set */ IMG_DEV_VIRTADDR sBPDevVAddr, sBPDevVAddrEnd; - + /* Whether or not the desired breakpoint will be trapped */ IMG_BOOL bTrapped; - + /* Will the requested breakpoint fire for reads? */ IMG_BOOL bRead; - + /* Will the requested breakpoint fire for writes? */ IMG_BOOL bWrite; - + /* Has a breakpoint been trapped? */ IMG_BOOL bTrappedBP; - + /* Extra information recorded about a trapped breakpoint */ IMG_UINT32 ui32CoreNum; IMG_DEV_VIRTADDR sTrappedBPDevVAddr; IMG_UINT32 ui32TrappedBPBurstLength; @@ -251,37 +325,46 @@ typedef struct _SGX_BREAKPOINT_INFO IMG_UINT32 ui32TrappedBPDataMaster; IMG_UINT32 ui32TrappedBPTag; } SGX_BREAKPOINT_INFO; -#endif +#endif /* SGX_FEATURE_DATA_BREAKPOINTS */ +/*! + ****************************************************************************** + * Structure for setting the hardware performance status + *****************************************************************************/ typedef struct _PVRSRV_SGX_MISCINFO_SET_HWPERF_STATUS { - + /* See PVRSRV_SGX_HWPERF_STATUS_* */ IMG_UINT32 ui32NewHWPerfStatus; #if defined(SGX_FEATURE_EXTENDED_PERF_COUNTERS) - + /* Specifies the HW's active group selectors */ IMG_UINT32 aui32PerfGroup[PVRSRV_SGX_HWPERF_NUM_COUNTERS]; - + /* Specifies the HW's active bit selectors */ IMG_UINT32 aui32PerfBit[PVRSRV_SGX_HWPERF_NUM_COUNTERS]; #else - + /* Specifies the HW's active group */ IMG_UINT32 ui32PerfGroup; - #endif + #endif /* SGX_FEATURE_EXTENDED_PERF_COUNTERS */ } PVRSRV_SGX_MISCINFO_SET_HWPERF_STATUS; +/*! + ****************************************************************************** + * Structure for misc SGX commands in services + *****************************************************************************/ typedef struct _SGX_MISC_INFO_ { - SGX_MISC_INFO_REQUEST eRequest; + SGX_MISC_INFO_REQUEST eRequest; /*!< Command request to SGXGetMiscInfo() */ + IMG_UINT32 ui32Padding; #if defined(SUPPORT_SGX_EDM_MEMORY_DEBUG) - IMG_DEV_VIRTADDR sDevVAddrSrc; - IMG_DEV_VIRTADDR sDevVAddrDest; - IMG_HANDLE hDevMemContext; + IMG_DEV_VIRTADDR sDevVAddrSrc; /*!< dev virtual addr for mem read */ + IMG_DEV_VIRTADDR sDevVAddrDest; /*!< dev virtual addr for mem write */ + IMG_HANDLE hDevMemContext; /*!< device memory context for mem debug */ #endif union { - IMG_UINT32 reserved; + IMG_UINT32 reserved; /*!< Unused: ensures valid code in the case everything else is compiled out */ PVRSRV_SGX_MISCINFO_FEATURES sSGXFeatures; IMG_UINT32 ui32SGXClockSpeed; PVRSRV_SGX_MISCINFO_ACTIVEPOWER sActivePower; @@ -295,12 +378,19 @@ typedef struct _SGX_MISC_INFO_ } SGX_MISC_INFO; #if defined(SGX_FEATURE_2D_HARDWARE) +/* + * The largest number of source sync objects that can be associated with a blit + * command. Allows for src, pattern, and mask + */ #define PVRSRV_MAX_BLT_SRC_SYNCS 3 #endif #define SGX_KICKTA_DUMPBITMAP_MAX_NAME_LENGTH 256 +/* + Structure for dumping bitmaps +*/ typedef struct _SGX_KICKTA_DUMPBITMAP_ { IMG_DEV_VIRTADDR sDevBaseAddr; @@ -315,59 +405,81 @@ typedef struct _SGX_KICKTA_DUMPBITMAP_ #define PVRSRV_SGX_PDUMP_CONTEXT_MAX_BITMAP_ARRAY_SIZE (16) +/*! + ****************************************************************************** + * Data required only when dumping parameters + *****************************************************************************/ typedef struct _PVRSRV_SGX_PDUMP_CONTEXT_ { - + /* cache control word for micro kernel cache flush/invalidates */ IMG_UINT32 ui32CacheControl; } PVRSRV_SGX_PDUMP_CONTEXT; +#if !defined (SUPPORT_SID_INTERFACE) typedef struct _SGX_KICKTA_DUMP_ROFF_ { - IMG_HANDLE hKernelMemInfo; - IMG_UINT32 uiAllocIndex; - IMG_UINT32 ui32Offset; - IMG_UINT32 ui32Value; - IMG_PCHAR pszName; + IMG_HANDLE hKernelMemInfo; /*< Buffer handle */ + IMG_UINT32 uiAllocIndex; /*< Alloc index for LDDM */ + IMG_UINT32 ui32Offset; /*< Byte offset to value to dump */ + IMG_UINT32 ui32Value; /*< Actual value to dump */ + IMG_PCHAR pszName; /*< Name of buffer */ } SGX_KICKTA_DUMP_ROFF, *PSGX_KICKTA_DUMP_ROFF; +#endif +#if defined (SUPPORT_SID_INTERFACE) +typedef struct _SGX_KICKTA_DUMP_BUFFER_KM_ +#else typedef struct _SGX_KICKTA_DUMP_BUFFER_ +#endif { IMG_UINT32 ui32SpaceUsed; - IMG_UINT32 ui32Start; - IMG_UINT32 ui32End; - IMG_UINT32 ui32BufferSize; - IMG_UINT32 ui32BackEndLength; + IMG_UINT32 ui32Start; /*< Byte offset of start to dump */ + IMG_UINT32 ui32End; /*< Byte offset of end of dump (non-inclusive) */ + IMG_UINT32 ui32BufferSize; /*< Size of buffer */ + IMG_UINT32 ui32BackEndLength; /*< Size of back end portion, if End < Start */ IMG_UINT32 uiAllocIndex; - IMG_HANDLE hKernelMemInfo; + IMG_HANDLE hKernelMemInfo; /*< MemInfo handle for the circular buffer */ IMG_PVOID pvLinAddr; #if defined(SUPPORT_SGX_NEW_STATUS_VALS) - IMG_HANDLE hCtrlKernelMemInfo; - IMG_DEV_VIRTADDR sCtrlDevVAddr; + IMG_HANDLE hCtrlKernelMemInfo; /*< MemInfo handle for the control structure of the + circular buffer */ + IMG_DEV_VIRTADDR sCtrlDevVAddr; /*< Device virtual address of the memory in the + control structure to be checked */ #endif - IMG_PCHAR pszName; + IMG_PCHAR pszName; /*< Name of buffer */ +#if defined (SUPPORT_SID_INTERFACE) +} SGX_KICKTA_DUMP_BUFFER_KM, *PSGX_KICKTA_DUMP_BUFFER_KM; +#else } SGX_KICKTA_DUMP_BUFFER, *PSGX_KICKTA_DUMP_BUFFER; +#endif +#if !defined (SUPPORT_SID_INTERFACE) #ifdef PDUMP +/* + PDUMP version of above kick structure +*/ typedef struct _SGX_KICKTA_PDUMP_ { - + // Bitmaps to dump PSGX_KICKTA_DUMPBITMAP psPDumpBitmapArray; IMG_UINT32 ui32PDumpBitmapSize; - + // Misc buffers to dump (e.g. TA, PDS etc..) PSGX_KICKTA_DUMP_BUFFER psBufferArray; IMG_UINT32 ui32BufferArraySize; - + // Roffs to dump PSGX_KICKTA_DUMP_ROFF psROffArray; IMG_UINT32 ui32ROffArraySize; } SGX_KICKTA_PDUMP, *PSGX_KICKTA_PDUMP; -#endif +#endif /* PDUMP */ +#endif /* #if !defined (SUPPORT_SID_INTERFACE) */ #if defined(TRANSFER_QUEUE) #if defined(SGX_FEATURE_2D_HARDWARE) +/* Maximum size of ctrl stream for 2d blit command (in 32 bit words) */ #define SGX_MAX_2D_BLIT_CMD_SIZE 26 #define SGX_MAX_2D_SRC_SYNC_OPS 3 #endif @@ -379,5 +491,8 @@ typedef struct _SGX_KICKTA_PDUMP_ } #endif -#endif +#endif /* __SGXAPI_KM_H__ */ +/****************************************************************************** + End of file (sgxapi_km.h) +******************************************************************************/ diff --git a/drivers/gpu/pvr/sgxdefs.h b/drivers/gpu/pvr/sgxdefs.h index 9e5effb..b3a2583 100644 --- a/drivers/gpu/pvr/sgxdefs.h +++ b/drivers/gpu/pvr/sgxdefs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -45,11 +45,12 @@ #if defined(SGX540) #include "sgx540defs.h" #else -#if defined(SGX541) -#include "sgx541defs.h" -#else #if defined(SGX543) +#if defined(FIX_HW_BRN_29954) +#include "sgx543_v1.164defs.h" +#else #include "sgx543defs.h" +#endif #else #if defined(SGX544) #include "sgx544defs.h" @@ -72,15 +73,10 @@ #endif #endif #endif -#endif #if defined(SGX_FEATURE_MP) -#if defined(SGX541) -#if SGX_CORE_REV == 100 -#include "sgx541_100mpdefs.h" -#else -#include "sgx541mpdefs.h" -#endif +#if defined(SGX554) +#include "sgxmpplusdefs.h" #else #include "sgxmpdefs.h" #endif diff --git a/drivers/gpu/pvr/sgxerrata.h b/drivers/gpu/pvr/sgxerrata.h index adca59c..9463308 100644 --- a/drivers/gpu/pvr/sgxerrata.h +++ b/drivers/gpu/pvr/sgxerrata.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -68,6 +68,10 @@ #define FIX_HW_BRN_22934 #define FIX_HW_BRN_28889 #else + #if SGX_CORE_REV == 1111 + #define FIX_HW_BRN_22934 + #define FIX_HW_BRN_28889 + #else #if SGX_CORE_REV == 120 #define FIX_HW_BRN_22934 #define FIX_HW_BRN_28889 @@ -80,6 +84,10 @@ #define FIX_HW_BRN_22934 #define FIX_HW_BRN_28889 #else + #if SGX_CORE_REV == 130 + #define FIX_HW_BRN_22934 + #define FIX_HW_BRN_28889 + #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD #else @@ -88,6 +96,8 @@ #endif #endif #endif + #endif + #endif #endif #endif @@ -105,9 +115,10 @@ #if SGX_CORE_REV == 101 #define FIX_HW_BRN_26620 #define FIX_HW_BRN_28011 + #define FIX_HW_BRN_34028 #else #if SGX_CORE_REV == 110 - + #define FIX_HW_BRN_34028 #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD @@ -130,7 +141,7 @@ #if SGX_CORE_REV == 112 #define FIX_HW_BRN_23281 - #define FIX_HW_BRN_23410 + #define FIX_HW_BRN_23410 #define FIX_HW_BRN_22693 #define FIX_HW_BRN_22934 #define FIX_HW_BRN_22997 @@ -177,18 +188,25 @@ #define FIX_HW_BRN_25503 #define FIX_HW_BRN_26620 #define FIX_HW_BRN_28011 + #define FIX_HW_BRN_34028 #else #if SGX_CORE_REV == 110 #define FIX_HW_BRN_25503 #define FIX_HW_BRN_26620 #define FIX_HW_BRN_28011 + #define FIX_HW_BRN_34028 #else #if SGX_CORE_REV == 120 #define FIX_HW_BRN_26620 #define FIX_HW_BRN_28011 + #define FIX_HW_BRN_34028 #else #if SGX_CORE_REV == 121 #define FIX_HW_BRN_28011 + #define FIX_HW_BRN_34028 + #else + #if SGX_CORE_REV == 130 + #define FIX_HW_BRN_34028 #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD @@ -199,6 +217,7 @@ #endif #endif #endif + #endif #define SGX_CORE_DEFINED #endif @@ -240,25 +259,219 @@ #endif #if SGX_CORE_REV == 113 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_29997 #define FIX_HW_BRN_30954 - + #define FIX_HW_BRN_31093 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31620 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_32044 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 #else #if SGX_CORE_REV == 122 - #define FIX_HW_BRN_30954 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_29997 + #define FIX_HW_BRN_30954 + #define FIX_HW_BRN_31093 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31620 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_32044 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + + #else + #if SGX_CORE_REV == 1221 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_31671 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_32044 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 #else #if SGX_CORE_REV == 140 - #define FIX_HW_BRN_30954 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_30954 + #define FIX_HW_BRN_31093 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31620 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_32044 + #define FIX_HW_BRN_32085 + #define FIX_HW_BRN_33920 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + + #else + #if SGX_CORE_REV == 1401 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_30954 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31620 + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_32044 + #define FIX_HW_BRN_32085 + #define FIX_HW_BRN_33920 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + + #else + #if SGX_CORE_REV == 141 + #define FIX_HW_BRN_29954 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31671 + #define FIX_HW_BRN_31780 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif #else + #if SGX_CORE_REV == 142 + #define FIX_HW_BRN_29954 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31671 + #define FIX_HW_BRN_31780 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + + #else + #if SGX_CORE_REV == 211 + #define FIX_HW_BRN_31093 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31620 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_32044 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + + #else + #if SGX_CORE_REV == 2111 + #define FIX_HW_BRN_30982 + #define FIX_HW_BRN_31093 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31620 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_32044 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + + #else + #if SGX_CORE_REV == 213 + #define FIX_HW_BRN_31272 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31671 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + + #else + #if SGX_CORE_REV == 216 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #else + #if SGX_CORE_REV == 302 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #else + #if SGX_CORE_REV == 303 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD - + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif #else #error "sgxerrata.h: SGX543 Core Revision unspecified" #endif #endif #endif #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif #define SGX_CORE_DEFINED #endif @@ -272,14 +485,134 @@ #endif #if SGX_CORE_REV == 100 - + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #else + #if SGX_CORE_REV == 102 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_31272 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + #else + #if SGX_CORE_REV == 103 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_31272 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + #else + #if SGX_CORE_REV == 104 + #define FIX_HW_BRN_29954 + #define FIX_HW_BRN_31093 + #define FIX_HW_BRN_31195 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31278 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31542 + #define FIX_HW_BRN_31620 + #define FIX_HW_BRN_31671 + #define FIX_HW_BRN_31780 + #define FIX_HW_BRN_32044 + #define FIX_HW_BRN_32085 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + #else + #if SGX_CORE_REV == 105 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31780 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + #else + #if SGX_CORE_REV == 106 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_31780 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + #else + #if SGX_CORE_REV == 110 + #define FIX_HW_BRN_31272 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31780 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33920 + #else + #if SGX_CORE_REV == 112 + #define FIX_HW_BRN_31272 + #define FIX_HW_BRN_33920 + #else + #if SGX_CORE_REV == 114 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31780 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #else + #if SGX_CORE_REV == 115 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #define FIX_HW_BRN_31780 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #else + #if SGX_CORE_REV == 116 + #if defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_31425 + #endif + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif + #define FIX_HW_BRN_33809 #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD - + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif #else #error "sgxerrata.h: SGX544 Core Revision unspecified" #endif #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif #define SGX_CORE_DEFINED #endif @@ -302,12 +635,17 @@ #if SGX_CORE_REV == 109 #define FIX_HW_BRN_29702 #define FIX_HW_BRN_29823 + #define FIX_HW_BRN_31939 #else #if SGX_CORE_REV == 1012 - #define FIX_HW_BRN_29823 + #define FIX_HW_BRN_31939 #else #if SGX_CORE_REV == 1013 - #define FIX_HW_BRN_29823 + #define FIX_HW_BRN_31939 + #else + #if SGX_CORE_REV == 10131 + #else + #if SGX_CORE_REV == 1014 #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD @@ -318,6 +656,8 @@ #endif #endif #endif + #endif + #endif #define SGX_CORE_DEFINED #endif @@ -330,11 +670,16 @@ #define SGX_CORE_REV SGX_CORE_REV_HEAD #endif - #if SGX_CORE_REV == 100 + #if SGX_CORE_REV == 1251 + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif - #else + #else #if SGX_CORE_REV == SGX_CORE_REV_HEAD - + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && defined(SGX_FEATURE_MP) + #define FIX_HW_BRN_33657 + #endif #else #error "sgxerrata.h: SGX554 Core Revision unspecified" #endif diff --git a/drivers/gpu/pvr/sgxfeaturedefs.h b/drivers/gpu/pvr/sgxfeaturedefs.h index 714bea3..bdf36fe 100644 --- a/drivers/gpu/pvr/sgxfeaturedefs.h +++ b/drivers/gpu/pvr/sgxfeaturedefs.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -52,6 +52,7 @@ #define SGX_FEATURE_2D_HARDWARE #define SGX_FEATURE_AUTOCLOCKGATING #define SUPPORT_SGX_GENERAL_MAPPING_HEAP + #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE #else #if defined(SGX540) #define SGX_CORE_FRIENDLY_NAME "SGX540" @@ -60,16 +61,6 @@ #define SGX_FEATURE_AUTOCLOCKGATING #define SGX_FEATURE_MULTI_EVENT_KICK #else -#if defined(SGX541) - #define SGX_CORE_FRIENDLY_NAME "SGX541" - #define SGX_CORE_ID SGX_CORE_ID_541 - #define SGX_FEATURE_ADDRESS_SPACE_SIZE (32) - #define SGX_FEATURE_MULTIPLE_MEM_CONTEXTS - #define SGX_FEATURE_BIF_NUM_DIRLISTS (8) - #define SGX_FEATURE_AUTOCLOCKGATING - #define SGX_FEATURE_SPM_MODE_0 - #define SGX_FEATURE_MULTI_EVENT_KICK -#else #if defined(SGX543) #define SGX_CORE_FRIENDLY_NAME "SGX543" #define SGX_CORE_ID SGX_CORE_ID_543 @@ -80,12 +71,21 @@ #define SGX_FEATURE_BIF_NUM_DIRLISTS (8) #define SGX_FEATURE_AUTOCLOCKGATING #define SGX_FEATURE_MONOLITHIC_UKERNEL - #define SGX_FEATURE_SPM_MODE_0 #define SGX_FEATURE_MULTI_EVENT_KICK #define SGX_FEATURE_DATA_BREAKPOINTS + #define SGX_FEATURE_PERPIPE_BKPT_REGS + #define SGX_FEATURE_PERPIPE_BKPT_REGS_NUMPIPES (2) #define SGX_FEATURE_2D_HARDWARE #define SGX_FEATURE_PTLA #define SGX_FEATURE_EXTENDED_PERF_COUNTERS + #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) + #if defined(SGX_FEATURE_MP) + #define SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH + #endif + #define SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH + #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH + #endif #else #if defined(SGX544) #define SGX_CORE_FRIENDLY_NAME "SGX544" @@ -97,10 +97,16 @@ #define SGX_FEATURE_BIF_NUM_DIRLISTS (8) #define SGX_FEATURE_AUTOCLOCKGATING #define SGX_FEATURE_MONOLITHIC_UKERNEL - #define SGX_FEATURE_SPM_MODE_0 #define SGX_FEATURE_MULTI_EVENT_KICK - #define SGX_FEATURE_DATA_BREAKPOINTS #define SGX_FEATURE_EXTENDED_PERF_COUNTERS + #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) + #if defined(SGX_FEATURE_MP) + #define SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH + #endif + #define SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH + #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH + #endif #else #if defined(SGX545) #define SGX_CORE_FRIENDLY_NAME "SGX545" @@ -123,13 +129,16 @@ #define SGX_FEATURE_NUM_PDS_PIPES (2) #define SGX_FEATURE_NATIVE_BACKWARD_BLIT #define SGX_FEATURE_MAX_TA_RENDER_TARGETS (512) - #define SGX_FEATURE_SPM_MODE_0 #define SGX_FEATURE_SECONDARY_REQUIRES_USE_KICK #define SGX_FEATURE_WRITEBACK_DCU #define SGX_FEATURE_BIF_WIDE_TILING_AND_4K_ADDRESS #define SGX_FEATURE_MULTI_EVENT_KICK + #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) + #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH + #endif #else #if defined(SGX554) #define SGX_CORE_FRIENDLY_NAME "SGX554" @@ -141,10 +150,19 @@ #define SGX_FEATURE_BIF_NUM_DIRLISTS (8) #define SGX_FEATURE_AUTOCLOCKGATING #define SGX_FEATURE_MONOLITHIC_UKERNEL - #define SGX_FEATURE_SPM_MODE_0 #define SGX_FEATURE_MULTI_EVENT_KICK - #define SGX_FEATURE_DATA_BREAKPOINTS + #define SGX_FEATURE_2D_HARDWARE + #define SGX_FEATURE_PTLA #define SGX_FEATURE_EXTENDED_PERF_COUNTERS + #define SGX_FEATURE_EDM_VERTEX_PDSADDR_FULL_RANGE + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) + #if defined(SGX_FEATURE_MP) + #define SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH + #endif + #define SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH + #define SGX_FEATURE_SW_ISP_CONTEXT_SWITCH + #endif +#endif #endif #endif #endif @@ -153,7 +171,15 @@ #endif #endif #endif + +#if defined(SGX_FEATURE_SLAVE_VDM_CONTEXT_SWITCH) \ + || defined(SGX_FEATURE_MASTER_VDM_CONTEXT_SWITCH) +#define SGX_FEATURE_VDM_CONTEXT_SWITCH #endif + +#if defined(SGX_FEATURE_ISP_CONTEXT_SWITCH_REV_2) \ + || defined(SGX_FEATURE_ISP_CONTEXT_SWITCH_REV_3) +#define SGX_FEATURE_ISP_CONTEXT_SWITCH #endif #if defined(FIX_HW_BRN_22693) @@ -182,14 +208,36 @@ #endif #endif -#if defined(SGX_FEATURE_MP) -#if !defined(SGX_FEATURE_MP_CORE_COUNT) -#error SGX_FEATURE_MP_CORE_COUNT must be defined when SGX_FEATURE_MP is defined +#if defined(FIX_HW_BRN_29954) +#undef SGX_FEATURE_PERPIPE_BKPT_REGS #endif -#else -#define SGX_FEATURE_MP_CORE_COUNT (1) + +#if defined(FIX_HW_BRN_31620) +#undef SGX_FEATURE_MULTIPLE_MEM_CONTEXTS +#undef SGX_FEATURE_BIF_NUM_DIRLISTS #endif +#if defined(SGX_FEATURE_MP) +#if defined(SGX_FEATURE_MP_CORE_COUNT_TA) && defined(SGX_FEATURE_MP_CORE_COUNT_3D) +#if (SGX_FEATURE_MP_CORE_COUNT_TA > SGX_FEATURE_MP_CORE_COUNT_3D) +#error Number of TA cores larger than number of 3D cores not supported in current driver +#endif +#else +#if defined(SGX_FEATURE_MP_CORE_COUNT) +#define SGX_FEATURE_MP_CORE_COUNT_TA (SGX_FEATURE_MP_CORE_COUNT) +#define SGX_FEATURE_MP_CORE_COUNT_3D (SGX_FEATURE_MP_CORE_COUNT) +#else +#error Either SGX_FEATURE_MP_CORE_COUNT or \ +both SGX_FEATURE_MP_CORE_COUNT_TA and SGX_FEATURE_MP_CORE_COUNT_3D \ +must be defined when SGX_FEATURE_MP is defined +#endif +#endif +#else +#define SGX_FEATURE_MP_CORE_COUNT (1) +#define SGX_FEATURE_MP_CORE_COUNT_TA (1) +#define SGX_FEATURE_MP_CORE_COUNT_3D (1) +#endif + #if defined(SUPPORT_SGX_LOW_LATENCY_SCHEDULING) && !defined(SUPPORT_SGX_PRIORITY_SCHEDULING) #define SUPPORT_SGX_PRIORITY_SCHEDULING #endif diff --git a/drivers/gpu/pvr/sgxinfo.h b/drivers/gpu/pvr/sgxinfo.h index 6714d57..c32dc31 100644 --- a/drivers/gpu/pvr/sgxinfo.h +++ b/drivers/gpu/pvr/sgxinfo.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -30,12 +30,14 @@ #include "sgxscript.h" #include "servicesint.h" #include "services.h" +#if !defined (SUPPORT_SID_INTERFACE) #include "sgxapi_km.h" +#endif #include "sgx_mkif_km.h" #define SGX_MAX_DEV_DATA 24 -#define SGX_MAX_INIT_MEM_HANDLES 16 +#define SGX_MAX_INIT_MEM_HANDLES 18 typedef struct _SGX_BRIDGE_INFO_FOR_SRVINIT @@ -51,12 +53,14 @@ typedef enum _SGXMKIF_CMD_TYPE_ SGXMKIF_CMD_TRANSFER = 1, SGXMKIF_CMD_2D = 2, SGXMKIF_CMD_POWER = 3, - SGXMKIF_CMD_CLEANUP = 4, - SGXMKIF_CMD_GETMISCINFO = 5, - SGXMKIF_CMD_PROCESS_QUEUES = 6, - SGXMKIF_CMD_DATABREAKPOINT = 7, - SGXMKIF_CMD_SETHWPERFSTATUS = 8, - SGXMKIF_CMD_MAX = 9, + SGXMKIF_CMD_CONTEXTSUSPEND = 4, + SGXMKIF_CMD_CLEANUP = 5, + SGXMKIF_CMD_GETMISCINFO = 6, + SGXMKIF_CMD_PROCESS_QUEUES = 7, + SGXMKIF_CMD_DATABREAKPOINT = 8, + SGXMKIF_CMD_SETHWPERFSTATUS = 9, + SGXMKIF_CMD_FLUSHPDCACHE = 10, + SGXMKIF_CMD_MAX = 11, SGXMKIF_CMD_FORCE_I32 = -1, @@ -65,12 +69,27 @@ typedef enum _SGXMKIF_CMD_TYPE_ typedef struct _SGX_BRIDGE_INIT_INFO_ { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelCCBMemInfo; + IMG_SID hKernelCCBCtlMemInfo; + IMG_SID hKernelCCBEventKickerMemInfo; + IMG_SID hKernelSGXHostCtlMemInfo; + IMG_SID hKernelSGXTA3DCtlMemInfo; +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + IMG_SID hKernelSGXPTLAWriteBackMemInfo; +#endif + IMG_SID hKernelSGXMiscMemInfo; +#else IMG_HANDLE hKernelCCBMemInfo; IMG_HANDLE hKernelCCBCtlMemInfo; IMG_HANDLE hKernelCCBEventKickerMemInfo; IMG_HANDLE hKernelSGXHostCtlMemInfo; IMG_HANDLE hKernelSGXTA3DCtlMemInfo; +#if defined(FIX_HW_BRN_31272) || defined(FIX_HW_BRN_31780) || defined(FIX_HW_BRN_33920) + IMG_HANDLE hKernelSGXPTLAWriteBackMemInfo; +#endif IMG_HANDLE hKernelSGXMiscMemInfo; +#endif IMG_UINT32 aui32HostKickAddr[SGXMKIF_CMD_MAX]; @@ -80,33 +99,92 @@ typedef struct _SGX_BRIDGE_INIT_INFO_ SGX_MISCINFO_STRUCT_SIZES sSGXStructSizes; #if defined(SGX_SUPPORT_HWPROFILING) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelHWProfilingMemInfo; +#else IMG_HANDLE hKernelHWProfilingMemInfo; #endif +#endif #if defined(SUPPORT_SGX_HWPERF) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelHWPerfCBMemInfo; +#else IMG_HANDLE hKernelHWPerfCBMemInfo; #endif +#endif +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelTASigBufferMemInfo; + IMG_SID hKernel3DSigBufferMemInfo; +#else IMG_HANDLE hKernelTASigBufferMemInfo; IMG_HANDLE hKernel3DSigBufferMemInfo; +#endif #if defined(FIX_HW_BRN_29702) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelCFIMemInfo; +#else IMG_HANDLE hKernelCFIMemInfo; #endif +#endif #if defined(FIX_HW_BRN_29823) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelDummyTermStreamMemInfo; +#else IMG_HANDLE hKernelDummyTermStreamMemInfo; #endif +#endif + +#if defined(FIX_HW_BRN_31542) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelClearClipWAVDMStreamMemInfo; + IMG_SID hKernelClearClipWAIndexStreamMemInfo; + IMG_SID hKernelClearClipWAPDSMemInfo; + IMG_SID hKernelClearClipWAUSEMemInfo; + IMG_SID hKernelClearClipWAParamMemInfo; + IMG_SID hKernelClearClipWAPMPTMemInfo; + IMG_SID hKernelClearClipWATPCMemInfo; + IMG_SID hKernelClearClipWAPSGRgnHdrMemInfo; +#else + IMG_HANDLE hKernelClearClipWAVDMStreamMemInfo; + IMG_HANDLE hKernelClearClipWAIndexStreamMemInfo; + IMG_HANDLE hKernelClearClipWAPDSMemInfo; + IMG_HANDLE hKernelClearClipWAUSEMemInfo; + IMG_HANDLE hKernelClearClipWAParamMemInfo; + IMG_HANDLE hKernelClearClipWAPMPTMemInfo; + IMG_HANDLE hKernelClearClipWATPCMemInfo; + IMG_HANDLE hKernelClearClipWAPSGRgnHdrMemInfo; +#endif +#endif + +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && defined(FIX_HW_BRN_31425) + IMG_HANDLE hKernelVDMSnapShotBufferMemInfo; + IMG_HANDLE hKernelVDMCtrlStreamBufferMemInfo; +#endif +#if defined(SGX_FEATURE_VDM_CONTEXT_SWITCH) && \ + defined(FIX_HW_BRN_33657) && defined(SUPPORT_SECURE_33657_FIX) + IMG_HANDLE hKernelVDMStateUpdateBufferMemInfo; +#endif #if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelEDMStatusBufferMemInfo; +#else IMG_HANDLE hKernelEDMStatusBufferMemInfo; #endif +#endif #if defined(SGX_FEATURE_OVERLAPPED_SPM) +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelTmpRgnHeaderMemInfo; +#else IMG_HANDLE hKernelTmpRgnHeaderMemInfo; #endif -#if defined(SGX_FEATURE_SPM_MODE_0) - IMG_HANDLE hKernelTmpDPMStateMemInfo; #endif IMG_UINT32 ui32EDMTaskReg0; IMG_UINT32 ui32EDMTaskReg1; + IMG_UINT32 ui32ClkGateCtl; + IMG_UINT32 ui32ClkGateCtl2; IMG_UINT32 ui32ClkGateStatusReg; IMG_UINT32 ui32ClkGateStatusMask; #if defined(SGX_FEATURE_MP) @@ -119,7 +197,11 @@ typedef struct _SGX_BRIDGE_INIT_INFO_ IMG_UINT32 ui32CacheControl; IMG_UINT32 asInitDevData[SGX_MAX_DEV_DATA]; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID asInitMemHandles[SGX_MAX_INIT_MEM_HANDLES]; +#else IMG_HANDLE asInitMemHandles[SGX_MAX_INIT_MEM_HANDLES]; +#endif } SGX_BRIDGE_INIT_INFO; @@ -128,7 +210,11 @@ typedef struct _SGX_DEVICE_SYNC_LIST_ { PSGXMKIF_HWDEVICE_SYNC_LIST psHWDeviceSyncList; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelHWSyncListMemInfo; +#else IMG_HANDLE hKernelHWSyncListMemInfo; +#endif PVRSRV_CLIENT_MEM_INFO *psHWDeviceSyncListClientMemInfo; PVRSRV_CLIENT_MEM_INFO *psAccessResourceClientMemInfo; @@ -138,27 +224,47 @@ typedef struct _SGX_DEVICE_SYNC_LIST_ IMG_UINT32 ui32NumSyncObjects; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahSyncHandles[1]; +#else IMG_HANDLE ahSyncHandles[1]; +#endif } SGX_DEVICE_SYNC_LIST, *PSGX_DEVICE_SYNC_LIST; typedef struct _SGX_INTERNEL_STATUS_UPDATE_ { CTL_STATUS sCtlStatus; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelMemInfo; +#else IMG_HANDLE hKernelMemInfo; +#endif } SGX_INTERNEL_STATUS_UPDATE; typedef struct _SGX_CCB_KICK_ { SGXMKIF_COMMAND sCommand; - IMG_HANDLE hCCBKernelMemInfo; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hCCBKernelMemInfo; +#else + IMG_HANDLE hCCBKernelMemInfo; +#endif IMG_UINT32 ui32NumDstSyncObjects; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hKernelHWSyncListMemInfo; +#else IMG_HANDLE hKernelHWSyncListMemInfo; +#endif +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID *pahDstSyncHandles; +#else IMG_HANDLE *pahDstSyncHandles; +#endif IMG_UINT32 ui32NumTAStatusVals; IMG_UINT32 ui32Num3DStatusVals; @@ -167,44 +273,74 @@ typedef struct _SGX_CCB_KICK_ SGX_INTERNEL_STATUS_UPDATE asTAStatusUpdate[SGX_MAX_TA_STATUS_VALS]; SGX_INTERNEL_STATUS_UPDATE as3DStatusUpdate[SGX_MAX_3D_STATUS_VALS]; #else +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahTAStatusSyncInfo[SGX_MAX_TA_STATUS_VALS]; + IMG_SID ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS]; +#else IMG_HANDLE ahTAStatusSyncInfo[SGX_MAX_TA_STATUS_VALS]; IMG_HANDLE ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS]; #endif +#endif IMG_BOOL bFirstKickOrResume; #if (defined(NO_HARDWARE) || defined(PDUMP)) IMG_BOOL bTerminateOrAbort; #endif - IMG_BOOL bLastInScene; + IMG_BOOL bLastInScene; + IMG_UINT32 ui32CCBOffset; #if defined(SUPPORT_SGX_GENERALISED_SYNCOBJECTS) IMG_UINT32 ui32NumTASrcSyncs; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahTASrcKernelSyncInfo[SGX_MAX_TA_SRC_SYNCS]; +#else IMG_HANDLE ahTASrcKernelSyncInfo[SGX_MAX_TA_SRC_SYNCS]; +#endif IMG_UINT32 ui32NumTADstSyncs; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahTADstKernelSyncInfo[SGX_MAX_TA_DST_SYNCS]; +#else IMG_HANDLE ahTADstKernelSyncInfo[SGX_MAX_TA_DST_SYNCS]; +#endif IMG_UINT32 ui32Num3DSrcSyncs; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ah3DSrcKernelSyncInfo[SGX_MAX_3D_SRC_SYNCS]; +#else IMG_HANDLE ah3DSrcKernelSyncInfo[SGX_MAX_3D_SRC_SYNCS]; +#endif #else IMG_UINT32 ui32NumSrcSyncs; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS]; +#else IMG_HANDLE ahSrcKernelSyncInfo[SGX_MAX_SRC_SYNCS]; #endif +#endif IMG_BOOL bTADependency; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hTA3DSyncInfo; + + IMG_SID hTASyncInfo; + IMG_SID h3DSyncInfo; +#else IMG_HANDLE hTA3DSyncInfo; IMG_HANDLE hTASyncInfo; IMG_HANDLE h3DSyncInfo; +#endif #if defined(PDUMP) IMG_UINT32 ui32CCBDumpWOff; #endif #if defined(NO_HARDWARE) IMG_UINT32 ui32WriteOpsPendingVal; #endif + IMG_HANDLE hDevMemContext; } SGX_CCB_KICK; @@ -224,27 +360,56 @@ typedef struct _SGX_CLIENT_INFO_ typedef struct _SGX_INTERNAL_DEVINFO_ { IMG_UINT32 ui32Flags; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hHostCtlKernelMemInfoHandle; +#else IMG_HANDLE hHostCtlKernelMemInfoHandle; +#endif IMG_BOOL bForcePTOff; } SGX_INTERNAL_DEVINFO; +typedef struct _SGX_INTERNAL_DEVINFO_KM_ +{ + IMG_UINT32 ui32Flags; + IMG_HANDLE hHostCtlKernelMemInfoHandle; + IMG_BOOL bForcePTOff; +} SGX_INTERNAL_DEVINFO_KM; + + #if defined(TRANSFER_QUEUE) typedef struct _PVRSRV_TRANSFER_SGX_KICK_ { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hCCBMemInfo; +#else IMG_HANDLE hCCBMemInfo; +#endif IMG_UINT32 ui32SharedCmdCCBOffset; IMG_DEV_VIRTADDR sHWTransferContextDevVAddr; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hTASyncInfo; + IMG_SID h3DSyncInfo; +#else IMG_HANDLE hTASyncInfo; IMG_HANDLE h3DSyncInfo; +#endif IMG_UINT32 ui32NumSrcSync; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahSrcSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; +#else IMG_HANDLE ahSrcSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; +#endif IMG_UINT32 ui32NumDstSync; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahDstSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; +#else IMG_HANDLE ahDstSyncInfo[SGX_MAX_TRANSFER_SYNC_OPS]; +#endif IMG_UINT32 ui32Flags; @@ -252,17 +417,34 @@ typedef struct _PVRSRV_TRANSFER_SGX_KICK_ #if defined(PDUMP) IMG_UINT32 ui32CCBDumpWOff; #endif + IMG_HANDLE hDevMemContext; } PVRSRV_TRANSFER_SGX_KICK, *PPVRSRV_TRANSFER_SGX_KICK; #if defined(SGX_FEATURE_2D_HARDWARE) typedef struct _PVRSRV_2D_SGX_KICK_ { +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID hCCBMemInfo; +#else IMG_HANDLE hCCBMemInfo; +#endif IMG_UINT32 ui32SharedCmdCCBOffset; IMG_DEV_VIRTADDR sHW2DContextDevVAddr; IMG_UINT32 ui32NumSrcSync; +#if defined (SUPPORT_SID_INTERFACE) + IMG_SID ahSrcSyncInfo[SGX_MAX_2D_SRC_SYNC_OPS]; + + + IMG_SID hDstSyncInfo; + + + IMG_SID hTASyncInfo; + + + IMG_SID h3DSyncInfo; +#else IMG_HANDLE ahSrcSyncInfo[SGX_MAX_2D_SRC_SYNC_OPS]; @@ -273,11 +455,13 @@ typedef struct _PVRSRV_2D_SGX_KICK_ IMG_HANDLE h3DSyncInfo; +#endif IMG_UINT32 ui32PDumpFlags; #if defined(PDUMP) IMG_UINT32 ui32CCBDumpWOff; #endif + IMG_HANDLE hDevMemContext; } PVRSRV_2D_SGX_KICK, *PPVRSRV_2D_SGX_KICK; #endif #endif diff --git a/drivers/gpu/pvr/sgxmmu.h b/drivers/gpu/pvr/sgxmmu.h index 4df8003..1b265f1 100644 --- a/drivers/gpu/pvr/sgxmmu.h +++ b/drivers/gpu/pvr/sgxmmu.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -44,19 +44,12 @@ #endif #define SGX_MMU_PDE_VALID (0x00000001U) #define SGX_MMU_PDE_PAGE_SIZE_4K (0x00000000U) -#if defined(SGX_FEATURE_VARIABLE_MMU_PAGE_SIZE) - #define SGX_MMU_PDE_PAGE_SIZE_16K (0x00000002U) - #define SGX_MMU_PDE_PAGE_SIZE_64K (0x00000004U) - #define SGX_MMU_PDE_PAGE_SIZE_256K (0x00000006U) - #define SGX_MMU_PDE_PAGE_SIZE_1M (0x00000008U) - #define SGX_MMU_PDE_PAGE_SIZE_4M (0x0000000AU) - #define SGX_MMU_PDE_PAGE_SIZE_MASK (0x0000000EU) -#else - #define SGX_MMU_PDE_WRITEONLY (0x00000002U) - #define SGX_MMU_PDE_READONLY (0x00000004U) - #define SGX_MMU_PDE_CACHECONSISTENT (0x00000008U) - #define SGX_MMU_PDE_EDMPROTECT (0x00000010U) -#endif +#define SGX_MMU_PDE_PAGE_SIZE_16K (0x00000002U) +#define SGX_MMU_PDE_PAGE_SIZE_64K (0x00000004U) +#define SGX_MMU_PDE_PAGE_SIZE_256K (0x00000006U) +#define SGX_MMU_PDE_PAGE_SIZE_1M (0x00000008U) +#define SGX_MMU_PDE_PAGE_SIZE_4M (0x0000000AU) +#define SGX_MMU_PDE_PAGE_SIZE_MASK (0x0000000EU) #define SGX_MMU_PT_SHIFT (10) #define SGX_MMU_PT_SIZE (1U<<SGX_MMU_PT_SHIFT) diff --git a/drivers/gpu/pvr/sgxscript.h b/drivers/gpu/pvr/sgxscript.h index 47c9e48..94eb453 100644 --- a/drivers/gpu/pvr/sgxscript.h +++ b/drivers/gpu/pvr/sgxscript.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -22,8 +22,7 @@ * Imagination Technologies Ltd. <gpl-support@imgtec.com> * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK * - ******************************************************************************/ - +*****************************************************************************/ #ifndef __SGXSCRIPT_H__ #define __SGXSCRIPT_H__ @@ -77,5 +76,8 @@ typedef struct _SGX_INIT_SCRIPTS_ } #endif -#endif +#endif /* __SGXSCRIPT_H__ */ +/***************************************************************************** + End of file (sgxscript.h) +*****************************************************************************/ diff --git a/drivers/gpu/pvr/srvkm.h b/drivers/gpu/pvr/srvkm.h index e8e223c..474a1ee 100644 --- a/drivers/gpu/pvr/srvkm.h +++ b/drivers/gpu/pvr/srvkm.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/staticversion.h b/drivers/gpu/pvr/staticversion.h new file mode 100644 index 0000000..433d126 --- /dev/null +++ b/drivers/gpu/pvr/staticversion.h @@ -0,0 +1,33 @@ +/********************************************************************** + * + * 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 + * +*****************************************************************************/ +#ifndef _STATICVERSION_H_ +#define _STATICVERSION_H_ + +#define PVRVERSION_MAJ 1 +#define PVRVERSION_MIN 8 +#define PVRVERSION_BRANCH 18 + +#endif /* _STATICVERSION_H_ */ diff --git a/drivers/gpu/pvr/syscommon.h b/drivers/gpu/pvr/syscommon.h index 38b6107..d5e5eef 100644 --- a/drivers/gpu/pvr/syscommon.h +++ b/drivers/gpu/pvr/syscommon.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, @@ -57,6 +57,9 @@ typedef struct _SYS_DEVICE_ID_TAG #define SYS_MAX_LOCAL_DEVMEM_ARENAS 4 +typedef IMG_HANDLE (*PFN_HTIMER_CREATE) (IMG_VOID); +typedef IMG_UINT32 (*PFN_HTIMER_GETUS) (IMG_HANDLE); +typedef IMG_VOID (*PFN_HTIMER_DESTROY) (IMG_HANDLE); typedef struct _SYS_DATA_TAG_ { IMG_UINT32 ui32NumDevices; @@ -81,18 +84,28 @@ typedef struct _SYS_DATA_TAG_ struct _DEVICE_COMMAND_DATA_ *apsDeviceCommandData[SYS_DEVICE_COUNT]; - IMG_BOOL bReProcessQueues; - RA_ARENA *apsLocalDevMemArena[SYS_MAX_LOCAL_DEVMEM_ARENAS]; IMG_CHAR *pszVersionString; - PVRSRV_EVENTOBJECT *psGlobalEventObject; +#if defined (SUPPORT_SID_INTERFACE) + PVRSRV_EVENTOBJECT_KM *psGlobalEventObject; +#else + PVRSRV_EVENTOBJECT *psGlobalEventObject; +#endif PVRSRV_MISC_INFO_CPUCACHEOP_TYPE ePendingCacheOpType; + + PFN_HTIMER_CREATE pfnHighResTimerCreate; + PFN_HTIMER_GETUS pfnHighResTimerGetus; + PFN_HTIMER_DESTROY pfnHighResTimerDestroy; } SYS_DATA; +#if defined (CUSTOM_DISPLAY_SEGMENT) +PVRSRV_ERROR SysGetDisplaySegmentAddress (IMG_VOID *pvDevInfo, IMG_VOID *pvPhysicalAddress, IMG_UINT32 *pui32Length); +#endif + PVRSRV_ERROR SysInitialise(IMG_VOID); PVRSRV_ERROR SysFinalise(IMG_VOID); @@ -119,9 +132,13 @@ PVRSRV_ERROR SysDevicePostPowerState(IMG_UINT32 ui32DeviceIndex, PVRSRV_DEV_POWER_STATE eNewPowerState, PVRSRV_DEV_POWER_STATE eCurrentPowerState); +#if defined(SYS_SUPPORTS_SGX_IDLE_CALLBACK) +IMG_VOID SysSGXIdleTransition(IMG_BOOL bSGXIdle); +#endif + #if defined(SYS_CUSTOM_POWERLOCK_WRAP) -PVRSRV_ERROR SysPowerLockWrap(SYS_DATA *psSysData); -IMG_VOID SysPowerLockUnwrap(SYS_DATA *psSysData); +PVRSRV_ERROR SysPowerLockWrap(IMG_BOOL bTryLock); +IMG_VOID SysPowerLockUnwrap(IMG_VOID); #endif PVRSRV_ERROR SysOEMFunction ( IMG_UINT32 ui32ID, @@ -143,6 +160,7 @@ IMG_BOOL SysVerifySysPAddrToDevPAddr (PVRSRV_DEVICE_TYPE eDeviceType, IMG_SYS_PH extern SYS_DATA* gpsSysData; + #if !defined(USE_CODE) #ifdef INLINE_IS_PRAGMA @@ -216,5 +234,37 @@ static inline IMG_VOID SysWriteHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32 } #endif +#ifdef INLINE_IS_PRAGMA +#pragma inline(SysHighResTimerCreate) +#endif +static INLINE IMG_HANDLE SysHighResTimerCreate(IMG_VOID) +{ + SYS_DATA *psSysData; + + SysAcquireData(&psSysData); + return psSysData->pfnHighResTimerCreate(); +} + +#ifdef INLINE_IS_PRAGMA +#pragma inline(SysHighResTimerGetus) +#endif +static INLINE IMG_UINT32 SysHighResTimerGetus(IMG_HANDLE hTimer) +{ + SYS_DATA *psSysData; + + SysAcquireData(&psSysData); + return psSysData->pfnHighResTimerGetus(hTimer); +} + +#ifdef INLINE_IS_PRAGMA +#pragma inline(SysHighResTimerDestroy) +#endif +static INLINE IMG_VOID SysHighResTimerDestroy(IMG_HANDLE hTimer) +{ + SYS_DATA *psSysData; + + SysAcquireData(&psSysData); + psSysData->pfnHighResTimerDestroy(hTimer); +} #endif diff --git a/drivers/gpu/pvr/ttrace.h b/drivers/gpu/pvr/ttrace.h index 159cbca..9e04b88 100644 --- a/drivers/gpu/pvr/ttrace.h +++ b/drivers/gpu/pvr/ttrace.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/ttrace_common.h b/drivers/gpu/pvr/ttrace_common.h index b7f884e..5895b6c 100644 --- a/drivers/gpu/pvr/ttrace_common.h +++ b/drivers/gpu/pvr/ttrace_common.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, diff --git a/drivers/gpu/pvr/ttrace_tokens.h b/drivers/gpu/pvr/ttrace_tokens.h index 530ce3e..21ea5fb 100644 --- a/drivers/gpu/pvr/ttrace_tokens.h +++ b/drivers/gpu/pvr/ttrace_tokens.h @@ -1,6 +1,6 @@ /********************************************************************** * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * 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, |