diff options
| author | Wengang Wu <wgw@motorola.com> | 2014-05-21 09:29:41 -0500 |
|---|---|---|
| committer | Wengang Wu <wgw@motorola.com> | 2014-05-21 09:29:41 -0500 |
| commit | 53a835f5057367679eb3db728bbdd427aab8aa8a (patch) | |
| tree | 03e5bbde7d371e885d1c67210b2b0c9bb0130d40 /drivers/gpu/pvr/services4/srvkm/common | |
| parent | 7489b569ffb64cdb998544405b6774bd43aab70b (diff) | |
| download | olio-linux-3.10-53a835f5057367679eb3db728bbdd427aab8aa8a.tar.xz olio-linux-3.10-53a835f5057367679eb3db728bbdd427aab8aa8a.zip | |
IKXCLOCK-1501 Upgrade to TI SGX Android OpenGL 1.12@2701748
Initial codes of TI SGX DDK 1.12@2701748
Change-Id: I75a8f6521968346ea1b2ea9fa54817ba186442ce
Diffstat (limited to 'drivers/gpu/pvr/services4/srvkm/common')
20 files changed, 2342 insertions, 1972 deletions
diff --git a/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c b/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c index 9ce7a114f3c..10135425cb7 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c +++ b/drivers/gpu/pvr/services4/srvkm/common/buffer_manager.c @@ -50,23 +50,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "lists.h" static IMG_BOOL -ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags); +ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags); 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_PVOID pvPrivData, + IMG_UINT32 ui32Flags, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase); -static IMG_INT32 +static IMG_BOOL DevMemoryAlloc (BM_CONTEXT *pBMContext, BM_MAPPING *pMapping, IMG_SIZE_T *pActualSize, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_UINT32 dev_vaddr_alignment, IMG_DEV_VIRTADDR *pDevVAddr); -static IMG_INT32 +static IMG_VOID DevMemoryFree (BM_MAPPING *pMapping); /*! @@ -90,7 +90,7 @@ DevMemoryFree (BM_MAPPING *pMapping); @Input psBMHeap - BM heap @Input psDevVAddr - device virtual address (optional) @Input uSize - requested buffer size in bytes. - @Input uFlags - property flags for the buffer. + @Input ui32Flags - property flags for the buffer. @Input uDevVAddrAlignment - required device virtual address alignment, or 0. @Input pvPrivData - opaque private data passed through to allocator @@ -107,7 +107,7 @@ AllocMemory (BM_CONTEXT *pBMContext, BM_HEAP *psBMHeap, IMG_DEV_VIRTADDR *psDevVAddr, IMG_SIZE_T uSize, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_UINT32 uDevVAddrAlignment, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, @@ -122,16 +122,16 @@ AllocMemory (BM_CONTEXT *pBMContext, RA_ARENA *pArena = IMG_NULL; PVR_DPF ((PVR_DBG_MESSAGE, - "AllocMemory (uSize=0x%x, uFlags=0x%x, align=0x%x)", - uSize, uFlags, uDevVAddrAlignment)); + "AllocMemory (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x, align=0x%x)", + uSize, ui32Flags, uDevVAddrAlignment)); /* what to do depends on combination of DevVaddr generation and backing RAM requirement */ - if(uFlags & PVRSRV_MEM_RAM_BACKED_ALLOCATION) + if(ui32Flags & PVRSRV_MEM_RAM_BACKED_ALLOCATION) { - if(uFlags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) + if(ui32Flags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) { /* user supplied DevVAddr, RAM backing */ PVR_DPF ((PVR_DBG_ERROR, "AllocMemory: combination of DevVAddr management and RAM backing mode unsupported")); @@ -156,82 +156,64 @@ AllocMemory (BM_CONTEXT *pBMContext, } /* Now allocate from the arena we chose above. */ - /* in case of a pageable buffer, we must bypass RA which could - * combine/split individual mappings between buffers: - */ - if (uFlags & (PVRSRV_MEM_SPARSE | PVRSRV_HAP_GPU_PAGEABLE)) + if (ui32Flags & PVRSRV_MEM_SPARSE) { IMG_BOOL bSuccess; - IMG_SIZE_T puiActualSize; - IMG_SIZE_T uRequestSize = uSize; + IMG_SIZE_T uActualSize; - if(uFlags & PVRSRV_MEM_SPARSE) - { - uRequestSize = ui32ChunkSize * ui32NumPhysChunks; - uSize = ui32ChunkSize * ui32NumVirtChunks; - } + /* Allocate physcial memory */ + bSuccess = BM_ImportMemory(psBMHeap, + ui32ChunkSize * ui32NumPhysChunks, + &uActualSize, + &pMapping, + ui32Flags, + pvPrivData, + ui32PrivDataLength, + IMG_NULL); /* We allocate VM space */ - /* Allocate physical memory */ - if (!BM_ImportMemory(psBMHeap, - uRequestSize, - &puiActualSize, - &pMapping, - uFlags, - pvPrivData, - ui32PrivDataLength, - (IMG_UINTPTR_T *)&(pBuf->DevVAddr.uiAddr))) + if (!bSuccess) { - PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: Failed to allocate device memory")); + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: BM_ImportMemory failed")); return IMG_FALSE; } - pBuf->hOSMemHandle = pMapping->hOSMemHandle; - /* We allocate VM space for sparse area */ - if(uFlags & PVRSRV_MEM_SPARSE) + if (uActualSize != ui32ChunkSize * ui32NumPhysChunks) { - if (puiActualSize != ui32ChunkSize * ui32NumPhysChunks) - { - /* - * Most likely the chunk size was not host page multiple, - * so return with an error - */ - PVR_DPF((PVR_DBG_ERROR, "AllocMemory: Failed to allocate" - "memory for sparse allocation")); - BM_FreeMemory(pArena, IMG_NULL, pMapping); - return IMG_FALSE; - } - - pMapping->uSizeVM = uSize; - pMapping->ui32ChunkSize = ui32ChunkSize; - pMapping->ui32NumVirtChunks = ui32NumVirtChunks; - pMapping->ui32NumPhysChunks = ui32NumPhysChunks; - pMapping->pabMapChunk = pabMapChunk; + /* + Most likley the chunksize was not host page multiple so + return with an error + */ + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: Failed to allocate memory for sparse allocation")); + BM_FreeMemory(pArena, IMG_NULL, pMapping); + return IMG_FALSE; + } - if (!(uFlags & PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC)) - { - /* Allocate VA space and map in the physical memory */ - bSuccess = DevMemoryAlloc (pBMContext, - pMapping, - IMG_NULL, - uFlags, - (IMG_UINT32)uDevVAddrAlignment, - &pMapping->DevVAddr); - if (!bSuccess) - { - PVR_DPF((PVR_DBG_ERROR, - "AllocMemory: Failed to allocate device memory")); - BM_FreeMemory(pArena, IMG_NULL, pMapping); - return IMG_FALSE; - } + pMapping->uSizeVM = ui32ChunkSize * ui32NumVirtChunks; + uSize = pMapping->uSizeVM; + pMapping->ui32ChunkSize = ui32ChunkSize; + pMapping->ui32NumVirtChunks = ui32NumVirtChunks; + pMapping->ui32NumPhysChunks = ui32NumPhysChunks; + pMapping->pabMapChunk = pabMapChunk; - /* uDevVAddrAlignment is currently set to zero so QAC - * generates warning which we override */ - /* PRQA S 3356,3358 1 */ - PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); - pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr; - } + /* Allocate VA space and map in the physical memory */ + bSuccess = DevMemoryAlloc (pBMContext, + pMapping, + IMG_NULL, + ui32Flags, + uDevVAddrAlignment, + &pMapping->DevVAddr); + if (!bSuccess) + { + PVR_DPF((PVR_DBG_ERROR, + "AllocMemory: Failed to allocate device memory")); + BM_FreeMemory(pArena, IMG_NULL, pMapping); + return IMG_FALSE; } + + /* uDevVAddrAlignment is currently set to zero so QAC generates warning which we override */ + /* PRQA S 3356,3358 1 */ + PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); + pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr; } else { @@ -239,15 +221,14 @@ AllocMemory (BM_CONTEXT *pBMContext, uSize, IMG_NULL, (IMG_VOID*) &pMapping, - uFlags, + ui32Flags, uDevVAddrAlignment, 0, pvPrivData, ui32PrivDataLength, (IMG_UINTPTR_T *)&(pBuf->DevVAddr.uiAddr))) { - PVR_DPF((PVR_DBG_ERROR, "AllocMemory: RA_Alloc(0x%x) hOSMemHandle %p, flags 0x%08x FAILED", - uSize, pMapping->hOSMemHandle, uFlags)); + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: RA_Alloc(0x%" SIZE_T_FMT_LEN "x) FAILED", uSize)); return IMG_FALSE; } } @@ -283,9 +264,9 @@ AllocMemory (BM_CONTEXT *pBMContext, * will have a physical address, else 0 */ pBuf->CpuPAddr.uiAddr = pMapping->CpuPAddr.uiAddr + uOffset; - if(uFlags & PVRSRV_MEM_ZERO) + if(ui32Flags & PVRSRV_MEM_ZERO) { - if(!ZeroBuf(pBuf, pMapping, uSize, psBMHeap->ui32Attribs | uFlags)) + if(!ZeroBuf(pBuf, pMapping, uSize, psBMHeap->ui32Attribs | ui32Flags)) { return IMG_FALSE; } @@ -293,7 +274,7 @@ AllocMemory (BM_CONTEXT *pBMContext, } else { - if(uFlags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) + if(ui32Flags & PVRSRV_MEM_USER_SUPPLIED_DEVVADDR) { /* user supplied DevVAddr, no RAM backing */ PVR_ASSERT(psDevVAddr != IMG_NULL); @@ -341,7 +322,7 @@ AllocMemory (BM_CONTEXT *pBMContext, (IMG_PVOID *)&pMapping, IMG_NULL, "Buffer Manager Mapping") != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "AllocMemory: OSAllocMem(0x%x) FAILED", sizeof(*pMapping))); + PVR_DPF((PVR_DBG_ERROR, "AllocMemory: OSAllocMem(0x%" SIZE_T_FMT_LEN "x) FAILED", sizeof(*pMapping))); return IMG_FALSE; } @@ -354,7 +335,6 @@ AllocMemory (BM_CONTEXT *pBMContext, pMapping->CpuVAddr = IMG_NULL; pMapping->CpuPAddr.uiAddr = 0; pMapping->DevVAddr = pBuf->DevVAddr; - pMapping->ui32MappingCount = 1; pMapping->psSysAddr = IMG_NULL; pMapping->uSize = uSize; pMapping->hOSMemHandle = 0; @@ -362,7 +342,6 @@ AllocMemory (BM_CONTEXT *pBMContext, /* Record the arena pointer in the mapping. */ pMapping->pArena = pArena; - pMapping->ui32DevVAddrAlignment = uDevVAddrAlignment; /* record the heap */ pMapping->pBMHeap = psBMHeap; @@ -370,18 +349,18 @@ AllocMemory (BM_CONTEXT *pBMContext, /* output some stats */ PVR_DPF ((PVR_DBG_MESSAGE, - "AllocMemory: pMapping=%08x: DevV=%08X CpuV=%08x CpuP=%08X uSize=0x%x", - (IMG_UINTPTR_T)pMapping, + "AllocMemory: pMapping=%p: DevV=%08X CpuV=%p CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", + pMapping, pMapping->DevVAddr.uiAddr, - (IMG_UINTPTR_T)pMapping->CpuVAddr, + pMapping->CpuVAddr, pMapping->CpuPAddr.uiAddr, pMapping->uSize)); PVR_DPF ((PVR_DBG_MESSAGE, - "AllocMemory: pBuf=%08x: DevV=%08X CpuV=%08x CpuP=%08X uSize=0x%x", - (IMG_UINTPTR_T)pBuf, + "AllocMemory: pBuf=%p: DevV=%08X CpuV=%p CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", + pBuf, pBuf->DevVAddr.uiAddr, - (IMG_UINTPTR_T)pBuf->CpuVAddr, + pBuf->CpuVAddr, pBuf->CpuPAddr.uiAddr, uSize)); @@ -406,7 +385,7 @@ AllocMemory (BM_CONTEXT *pBMContext, @Input bPhysContig - Is the wrap physically contiguous. @Input psAddr - List of pages to wrap. @Input pvCPUVAddr - Optional CPU Kernel virtual address (page aligned) of memory to wrap - @Input uFlags - property flags for the buffer. + @Input ui32Flags - property flags for the buffer. @Output Buf - receives a pointer to a descriptor of the allocated buffer. @Return IMG_TRUE - Success @@ -416,27 +395,36 @@ AllocMemory (BM_CONTEXT *pBMContext, static IMG_BOOL WrapMemory (BM_HEAP *psBMHeap, IMG_SIZE_T uSize, - IMG_SIZE_T ui32BaseOffset, + IMG_SIZE_T uiBaseOffset, IMG_BOOL bPhysContig, IMG_SYS_PHYADDR *psAddr, IMG_VOID *pvCPUVAddr, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, BM_BUF *pBuf) { IMG_DEV_VIRTADDR DevVAddr = {0}; BM_MAPPING *pMapping; - IMG_INT32 bResult; - IMG_SIZE_T const ui32PageSize = HOST_PAGESIZE(); + IMG_BOOL bResult; + IMG_SIZE_T const uPageSize = HOST_PAGESIZE(); + /* We should not pass down R/W flags into the OS layers so create ui32Attribs */ + IMG_UINT32 ui32Attribs = ui32Flags & ~(PVRSRV_MEM_READ | PVRSRV_MEM_WRITE); PVR_DPF ((PVR_DBG_MESSAGE, - "WrapMemory(psBMHeap=%08X, size=0x%x, offset=0x%x, bPhysContig=0x%x, pvCPUVAddr = 0x%08x, flags=0x%x)", - (IMG_UINTPTR_T)psBMHeap, uSize, ui32BaseOffset, bPhysContig, (IMG_UINTPTR_T)pvCPUVAddr, uFlags)); + "WrapMemory(psBMHeap=%p, size=0x%" SIZE_T_FMT_LEN "x, offset=0x%" SIZE_T_FMT_LEN + "x, bPhysContig=0x%x, sysPAddr=0x" SYSPADDR_FMT ", pvCPUVAddr = 0x%p, flags=0x%x)", + psBMHeap, + uSize, + uiBaseOffset, + bPhysContig, + psAddr->uiAddr, + pvCPUVAddr, + ui32Flags)); - PVR_ASSERT((psAddr->uiAddr & (ui32PageSize - 1)) == 0); + PVR_ASSERT((psAddr->uiAddr & (uPageSize - 1)) == 0); /* Only need lower 12 bits of the cpu addr - don't care what size a void* is */ - PVR_ASSERT(((IMG_UINTPTR_T)pvCPUVAddr & (ui32PageSize - 1)) == 0); + PVR_ASSERT(((IMG_UINTPTR_T)pvCPUVAddr & (uPageSize - 1)) == 0); - uSize += ui32BaseOffset; + uSize += uiBaseOffset; uSize = HOST_PAGEALIGN (uSize); /* allocate a mocked-up mapping */ @@ -445,7 +433,7 @@ WrapMemory (BM_HEAP *psBMHeap, (IMG_PVOID *)&pMapping, IMG_NULL, "Mocked-up mapping") != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSAllocMem(0x%x) FAILED",sizeof(*pMapping))); + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSAllocMem(0x%" SIZE_T_FMT_LEN "x) FAILED", sizeof(*pMapping))); return IMG_FALSE; } @@ -467,10 +455,10 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSRegisterMem(pMapping->CpuPAddr, pMapping->CpuVAddr, pMapping->uSize, - uFlags, + ui32Attribs, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterMem Phys=0x%08X, Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterMem Phys=0x" CPUPADDR_FMT ", Size=%" SIZE_T_FMT_LEN "u) failed", pMapping->CpuPAddr.uiAddr, pMapping->uSize)); goto fail_cleanup; } @@ -483,10 +471,10 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSRegisterDiscontigMem(pMapping->psSysAddr, pMapping->CpuVAddr, pMapping->uSize, - uFlags, + ui32Attribs, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterDiscontigMem Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSRegisterDiscontigMem Size=0x%" SIZE_T_FMT_LEN "u) failed", pMapping->uSize)); goto fail_cleanup; } @@ -501,12 +489,12 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSReservePhys(pMapping->CpuPAddr, pMapping->uSize, - uFlags, + ui32Attribs, IMG_NULL, &pMapping->CpuVAddr, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReservePhys Phys=0x%08X, Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReservePhys Phys=0x" CPUPADDR_FMT ", Size=%" SIZE_T_FMT_LEN "u) failed", pMapping->CpuPAddr.uiAddr, pMapping->uSize)); goto fail_cleanup; } @@ -518,11 +506,11 @@ WrapMemory (BM_HEAP *psBMHeap, if(OSReserveDiscontigPhys(pMapping->psSysAddr, pMapping->uSize, - uFlags, + ui32Attribs, &pMapping->CpuVAddr, &pMapping->hOSMemHandle) != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReserveDiscontigPhys Size=%d) failed", + PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSReserveDiscontigPhys Size=%" SIZE_T_FMT_LEN "u) failed", pMapping->uSize)); goto fail_cleanup; } @@ -530,18 +518,18 @@ WrapMemory (BM_HEAP *psBMHeap, } /* - * Allocate device memory for this buffer. Map wrapped pages as read/write + * Allocate device memory for this buffer. */ bResult = DevMemoryAlloc(psBMHeap->pBMContext, pMapping, IMG_NULL, - uFlags | PVRSRV_MEM_READ | PVRSRV_MEM_WRITE, - IMG_CAST_TO_DEVVADDR_UINT(ui32PageSize), + ui32Flags, + IMG_CAST_TO_DEVVADDR_UINT(uPageSize), &DevVAddr); - if (bResult <= 0) + if (!bResult) { PVR_DPF((PVR_DBG_ERROR, - "WrapMemory: DevMemoryAlloc(0x%x) failed", + "WrapMemory: DevMemoryAlloc(0x%" SIZE_T_FMT_LEN "x) failed", pMapping->uSize)); goto fail_cleanup; } @@ -552,17 +540,17 @@ WrapMemory (BM_HEAP *psBMHeap, * addresses associated with this allocation are placed at the same * offset within the underlying chunk. */ - pBuf->CpuPAddr.uiAddr = pMapping->CpuPAddr.uiAddr + ui32BaseOffset; - if(!ui32BaseOffset) + pBuf->CpuPAddr.uiAddr = pMapping->CpuPAddr.uiAddr + uiBaseOffset; + if(!uiBaseOffset) { pBuf->hOSMemHandle = pMapping->hOSMemHandle; } else { if(OSGetSubMemHandle(pMapping->hOSMemHandle, - ui32BaseOffset, - (pMapping->uSize-ui32BaseOffset), - uFlags, + uiBaseOffset, + (pMapping->uSize - uiBaseOffset), + ui32Attribs, &pBuf->hOSMemHandle)!=PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "WrapMemory: OSGetSubMemHandle failed")); @@ -571,13 +559,13 @@ WrapMemory (BM_HEAP *psBMHeap, } if(pMapping->CpuVAddr) { - pBuf->CpuVAddr = (IMG_VOID*) ((IMG_UINTPTR_T)pMapping->CpuVAddr + ui32BaseOffset); + pBuf->CpuVAddr = (IMG_VOID*) ((IMG_UINTPTR_T)pMapping->CpuVAddr + uiBaseOffset); } - pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr + IMG_CAST_TO_DEVVADDR_UINT(ui32BaseOffset); + pBuf->DevVAddr.uiAddr = pMapping->DevVAddr.uiAddr + IMG_CAST_TO_DEVVADDR_UINT(uiBaseOffset); - if(uFlags & PVRSRV_MEM_ZERO) + if(ui32Flags & PVRSRV_MEM_ZERO) { - if(!ZeroBuf(pBuf, pMapping, uSize, uFlags)) + if(!ZeroBuf(pBuf, pMapping, uSize, ui32Flags)) { return IMG_FALSE; } @@ -585,19 +573,19 @@ WrapMemory (BM_HEAP *psBMHeap, PVR_DPF ((PVR_DBG_MESSAGE, "DevVaddr.uiAddr=%08X", DevVAddr.uiAddr)); PVR_DPF ((PVR_DBG_MESSAGE, - "WrapMemory: DevV=%08X CpuP=%08X uSize=0x%x", + "WrapMemory: DevV=%08X CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", pMapping->DevVAddr.uiAddr, pMapping->CpuPAddr.uiAddr, pMapping->uSize)); PVR_DPF ((PVR_DBG_MESSAGE, - "WrapMemory: DevV=%08X CpuP=%08X uSize=0x%x", + "WrapMemory: DevV=%08X CpuP=" CPUPADDR_FMT " uSize=0x%" SIZE_T_FMT_LEN "x", pBuf->DevVAddr.uiAddr, pBuf->CpuPAddr.uiAddr, uSize)); pBuf->pMapping = pMapping; return IMG_TRUE; fail_cleanup: - if(ui32BaseOffset && pBuf->hOSMemHandle) + if(uiBaseOffset && pBuf->hOSMemHandle) { - OSReleaseSubMemHandle(pBuf->hOSMemHandle, uFlags); + OSReleaseSubMemHandle(pBuf->hOSMemHandle, ui32Attribs); } if(pMapping && (pMapping->CpuVAddr || pMapping->hOSMemHandle)) @@ -605,16 +593,16 @@ fail_cleanup: switch(pMapping->eCpuMemoryOrigin) { case hm_wrapped: - OSUnReservePhys(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnReservePhys(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; case hm_wrapped_virtaddr: - OSUnRegisterMem(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnRegisterMem(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; case hm_wrapped_scatter: - OSUnReserveDiscontigPhys(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnReserveDiscontigPhys(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; case hm_wrapped_scatter_virtaddr: - OSUnRegisterDiscontigMem(pMapping->CpuVAddr, pMapping->uSize, uFlags, pMapping->hOSMemHandle); + OSUnRegisterDiscontigMem(pMapping->CpuVAddr, pMapping->uSize, ui32Attribs, pMapping->hOSMemHandle); break; default: break; @@ -630,19 +618,19 @@ fail_cleanup: static IMG_BOOL -ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui32Flags) +ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T uBytes, IMG_UINT32 ui32Flags) { IMG_VOID *pvCpuVAddr; if(pBuf->CpuVAddr) { - OSMemSet(pBuf->CpuVAddr, 0, ui32Bytes); + OSMemSet(pBuf->CpuVAddr, 0, uBytes); } else if(pMapping->eCpuMemoryOrigin == hm_contiguous || pMapping->eCpuMemoryOrigin == hm_wrapped) { pvCpuVAddr = OSMapPhysToLin(pBuf->CpuPAddr, - ui32Bytes, + uBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); @@ -651,17 +639,17 @@ ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui3 PVR_DPF((PVR_DBG_ERROR, "ZeroBuf: OSMapPhysToLin for contiguous buffer failed")); return IMG_FALSE; } - OSMemSet(pvCpuVAddr, 0, ui32Bytes); + OSMemSet(pvCpuVAddr, 0, uBytes); OSUnMapPhysToLin(pvCpuVAddr, - ui32Bytes, + uBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); } else { - IMG_SIZE_T ui32BytesRemaining = ui32Bytes; - IMG_SIZE_T ui32CurrentOffset = 0; + IMG_SIZE_T uBytesRemaining = uBytes; + IMG_SIZE_T uCurrentOffset = 0; IMG_CPU_PHYADDR CpuPAddr; /* Walk through the pBuf one page at a time and use @@ -669,21 +657,21 @@ ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui3 PVR_ASSERT(pBuf->hOSMemHandle); - while(ui32BytesRemaining > 0) + while(uBytesRemaining > 0) { - IMG_SIZE_T ui32BlockBytes = MIN(ui32BytesRemaining, HOST_PAGESIZE()); - CpuPAddr = OSMemHandleToCpuPAddr(pBuf->hOSMemHandle, ui32CurrentOffset); + IMG_SIZE_T uBlockBytes = MIN(uBytesRemaining, HOST_PAGESIZE()); + CpuPAddr = OSMemHandleToCpuPAddr(pBuf->hOSMemHandle, uCurrentOffset); /* If the CpuPAddr isn't page aligned then start by writing up to the next page - * boundary (or ui32BytesRemaining if less), so that subsequent iterations can + * boundary (or uBytesRemaining if less), so that subsequent iterations can * copy full physical pages. */ if(CpuPAddr.uiAddr & (HOST_PAGESIZE() -1)) { - ui32BlockBytes = - MIN(ui32BytesRemaining, (IMG_UINT32)(HOST_PAGEALIGN(CpuPAddr.uiAddr) - CpuPAddr.uiAddr)); + uBlockBytes = + MIN(uBytesRemaining, (IMG_UINT32)(HOST_PAGEALIGN(CpuPAddr.uiAddr) - CpuPAddr.uiAddr)); } pvCpuVAddr = OSMapPhysToLin(CpuPAddr, - ui32BlockBytes, + uBlockBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); @@ -692,15 +680,15 @@ ZeroBuf(BM_BUF *pBuf, BM_MAPPING *pMapping, IMG_SIZE_T ui32Bytes, IMG_UINT32 ui3 PVR_DPF((PVR_DBG_ERROR, "ZeroBuf: OSMapPhysToLin while zeroing non-contiguous memory FAILED")); return IMG_FALSE; } - OSMemSet(pvCpuVAddr, 0, ui32BlockBytes); + OSMemSet(pvCpuVAddr, 0, uBlockBytes); OSUnMapPhysToLin(pvCpuVAddr, - ui32BlockBytes, + uBlockBytes, PVRSRV_HAP_KERNEL_ONLY | (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK), IMG_NULL); - ui32BytesRemaining -= ui32BlockBytes; - ui32CurrentOffset += ui32BlockBytes; + uBytesRemaining -= uBlockBytes; + uCurrentOffset += uBlockBytes; } } @@ -734,9 +722,9 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) PVRSRV_DEVICE_NODE *psDeviceNode; PVR_DPF ((PVR_DBG_MESSAGE, - "FreeBuf: pBuf=0x%x: DevVAddr=%08X CpuVAddr=0x%x CpuPAddr=%08X", - (IMG_UINTPTR_T)pBuf, pBuf->DevVAddr.uiAddr, - (IMG_UINTPTR_T)pBuf->CpuVAddr, pBuf->CpuPAddr.uiAddr)); + "FreeBuf: pBuf=0x%p: DevVAddr=%08X CpuVAddr=0x%p CpuPAddr=" CPUPADDR_FMT, + pBuf, pBuf->DevVAddr.uiAddr, + pBuf->CpuVAddr, pBuf->CpuPAddr.uiAddr)); /* record mapping */ pMapping = pBuf->pMapping; @@ -777,11 +765,9 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) OSReleaseSubMemHandle(pBuf->hOSMemHandle, ui32Flags); } } - if(ui32Flags & PVRSRV_MEM_RAM_BACKED_ALLOCATION) { /* Submemhandle is required by exported mappings */ - if ((pBuf->ui32ExportCount == 0) && (pBuf->ui32RefCount == 0)) { /* @@ -789,27 +775,17 @@ FreeBuf (BM_BUF *pBuf, IMG_UINT32 ui32Flags, IMG_BOOL bFromAllocator) Note: currently no need to distinguish between hm_env and hm_contiguous */ PVR_ASSERT(pBuf->ui32ExportCount == 0); - if (pBuf->pMapping->ui32Flags & (PVRSRV_MEM_SPARSE | PVRSRV_HAP_GPU_PAGEABLE)) + if (pBuf->pMapping->ui32Flags & PVRSRV_MEM_SPARSE) { - IMG_UINT32 ui32FreeSize = 0; - IMG_PVOID pvFreePtr = IMG_NULL; - - if(pBuf->pMapping->ui32Flags & PVRSRV_MEM_SPARSE) - { - ui32FreeSize = sizeof(IMG_BOOL) * pBuf->pMapping->ui32NumVirtChunks; - pvFreePtr = pBuf->pMapping->pabMapChunk; - } - - /* With sparse and page-able allocations we don't go through the sub-alloc RA */ + IMG_UINT32 ui32FreeSize = sizeof(IMG_BOOL) * pBuf->pMapping->ui32NumVirtChunks; + IMG_PVOID pvFreePtr = pBuf->pMapping->pabMapChunk; + + /* With sparse allocations we don't go through the sub-alloc RA */ BM_FreeMemory(pBuf->pMapping->pBMHeap, pBuf->DevVAddr.uiAddr, pBuf->pMapping); - - if(pvFreePtr) - { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, ui32FreeSize, pvFreePtr, IMG_NULL); - } } else { @@ -1559,7 +1535,7 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, BM_CONTEXT *pBMContext; BM_HEAP *psBMHeap; SYS_DATA *psSysData; - IMG_UINT32 uFlags; + IMG_UINT32 ui32Flags; if (pui32Flags == IMG_NULL) { @@ -1568,11 +1544,11 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, return IMG_FALSE; } - uFlags = *pui32Flags; + ui32Flags = *pui32Flags; PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Alloc (uSize=0x%x, uFlags=0x%x, uDevVAddrAlignment=0x%x)", - uSize, uFlags, uDevVAddrAlignment)); + "BM_Alloc (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x, uDevVAddrAlignment=0x%x)", + uSize, ui32Flags, uDevVAddrAlignment)); SysAcquireData(&psSysData); @@ -1604,7 +1580,7 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, psBMHeap, psDevVAddr, uSize, - uFlags, + ui32Flags, uDevVAddrAlignment, pvPrivData, ui32PrivDataLength, @@ -1621,24 +1597,24 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Alloc (uSize=0x%x, uFlags=0x%x)", - uSize, uFlags)); + "BM_Alloc (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x)", + uSize, ui32Flags)); /* * Assign the handle and return. */ pBuf->ui32RefCount = 1; *phBuf = (BM_HANDLE)pBuf; - *pui32Flags = uFlags | psBMHeap->ui32Attribs; + *pui32Flags = ui32Flags | psBMHeap->ui32Attribs; /* * If the user has specified heap CACHETYPE flags themselves, * override any CACHETYPE flags inherited from the heap. */ - if(uFlags & PVRSRV_HAP_CACHETYPE_MASK) + if(ui32Flags & PVRSRV_HAP_CACHETYPE_MASK) { *pui32Flags &= ~PVRSRV_HAP_CACHETYPE_MASK; - *pui32Flags |= (uFlags & PVRSRV_HAP_CACHETYPE_MASK); + *pui32Flags |= (ui32Flags & PVRSRV_HAP_CACHETYPE_MASK); } return IMG_TRUE; @@ -1657,13 +1633,13 @@ BM_Alloc ( IMG_HANDLE hDevMemHeap, @Input psDeviceNode @Input psSysPAddr - system address array - @Input ui32PageSize - size of address array + @Input uPageSize - size of address array @Return IMG_BOOL *****************************************************************************/ static IMG_BOOL -ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSysPAddr, IMG_UINT32 ui32PageCount, IMG_SIZE_T ui32PageSize) +ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSysPAddr, IMG_UINT32 ui32PageCount, IMG_SIZE_T uPageSize) { IMG_UINT32 i; @@ -1677,7 +1653,7 @@ ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSy return IMG_FALSE; } - sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + ui32PageSize; + sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + uPageSize; if (!SysVerifySysPAddrToDevPAddr(psDeviceNode->sDevId.eDeviceType, sEndSysPAddr)) { @@ -1704,7 +1680,7 @@ ValidSysPAddrArrayForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR *psSy *****************************************************************************/ static IMG_BOOL -ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStartSysPAddr, IMG_SIZE_T ui32Range) +ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStartSysPAddr, IMG_SIZE_T uRange) { IMG_SYS_PHYADDR sEndSysPAddr; @@ -1713,7 +1689,7 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar return IMG_FALSE; } - sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + ui32Range; + sEndSysPAddr.uiAddr = sStartSysPAddr.uiAddr + uRange; if (!SysVerifySysPAddrToDevPAddr(psDeviceNode->sDevId.eDeviceType, sEndSysPAddr)) { @@ -1723,9 +1699,9 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar return IMG_TRUE; } -#define WRAP_MAPPING_SIZE(ui32ByteSize, ui32PageOffset) HOST_PAGEALIGN((ui32ByteSize) + (ui32PageOffset)) +#define WRAP_MAPPING_SIZE(uByteSize, uPageOffset) HOST_PAGEALIGN((uByteSize) + (uPageOffset)) -#define WRAP_PAGE_COUNT(ui32ByteSize, ui32PageOffset, ui32HostPageSize) (WRAP_MAPPING_SIZE(ui32ByteSize, ui32PageOffset) / (ui32HostPageSize)) +#define WRAP_PAGE_COUNT(uByteSize, uPageOffset, uHostPageSize) (WRAP_MAPPING_SIZE(uByteSize, uPageOffset) / (uHostPageSize)) #endif @@ -1740,12 +1716,12 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar The wrapped memory must be page aligned. BM_Wrap will roundup the size to a multiple of cpu pages. - @Input ui32Size - size of memory to wrap. + @Input uSize - size of memory to wrap. @Input ui32Offset - Offset into page of memory to wrap. @Input bPhysContig - Is the wrap physically contiguous. @Input psSysAddr - list of system physical page addresses of memory to wrap. @Input pvCPUVAddr - optional CPU kernel virtual address (Page aligned) of memory to wrap. - @Input uFlags - bit mask of buffer property flags. + @Input ui32Flags - bit mask of buffer property flags. @output phBuf - receives the buffer handle. @Return IMG_TRUE - Success. @@ -1754,8 +1730,8 @@ ValidSysPAddrRangeForDev(PVRSRV_DEVICE_NODE *psDeviceNode, IMG_SYS_PHYADDR sStar *****************************************************************************/ IMG_BOOL BM_Wrap ( IMG_HANDLE hDevMemHeap, - IMG_SIZE_T ui32Size, - IMG_SIZE_T ui32Offset, + IMG_SIZE_T uSize, + IMG_SIZE_T uOffset, IMG_BOOL bPhysContig, IMG_SYS_PHYADDR *psSysAddr, IMG_VOID *pvCPUVAddr, @@ -1767,29 +1743,41 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, BM_HEAP *psBMHeap; SYS_DATA *psSysData; IMG_SYS_PHYADDR sHashAddress; - IMG_UINT32 uFlags; + IMG_UINT32 ui32Flags; psBMHeap = (BM_HEAP*)hDevMemHeap; psBMContext = psBMHeap->pBMContext; - uFlags = psBMHeap->ui32Attribs & (PVRSRV_HAP_CACHETYPE_MASK | PVRSRV_HAP_MAPTYPE_MASK | PVRSRV_HAP_MAPPING_CTRL_MASK); + ui32Flags = psBMHeap->ui32Attribs & (PVRSRV_HAP_CACHETYPE_MASK | PVRSRV_HAP_MAPTYPE_MASK); if ((pui32Flags != IMG_NULL) && ((*pui32Flags & PVRSRV_HAP_CACHETYPE_MASK) != 0)) { - uFlags &= ~PVRSRV_HAP_CACHETYPE_MASK; - uFlags |= *pui32Flags & PVRSRV_HAP_CACHETYPE_MASK; + ui32Flags &= ~PVRSRV_HAP_CACHETYPE_MASK; + ui32Flags |= *pui32Flags & PVRSRV_HAP_CACHETYPE_MASK; + } + + if ((pui32Flags != IMG_NULL) && ((*pui32Flags & (PVRSRV_MEM_READ | PVRSRV_MEM_WRITE)) != 0)) + { + ui32Flags &= ~(PVRSRV_MEM_READ | PVRSRV_MEM_WRITE); + ui32Flags |= *pui32Flags & (PVRSRV_MEM_READ | PVRSRV_MEM_WRITE); } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Wrap (uSize=0x%x, uOffset=0x%x, bPhysContig=0x%x, pvCPUVAddr=0x%x, uFlags=0x%x)", - ui32Size, ui32Offset, bPhysContig, (IMG_UINTPTR_T)pvCPUVAddr, uFlags)); + "BM_Wrap (uSize=0x%" SIZE_T_FMT_LEN "x, uOffset=0x%" SIZE_T_FMT_LEN + "x, bPhysContig=0x%x, syspAddr=0x" SYSPADDR_FMT ", pvCPUVAddr=0x%p, ui32Flags=0x%x)", + uSize, + uOffset, + bPhysContig, + psSysAddr->uiAddr, + pvCPUVAddr, + ui32Flags)); SysAcquireData(&psSysData); #if defined(PVR_LMA) if (bPhysContig) { - if (!ValidSysPAddrRangeForDev(psBMContext->psDeviceNode, *psSysAddr, WRAP_MAPPING_SIZE(ui32Size, ui32Offset))) + if (!ValidSysPAddrRangeForDev(psBMContext->psDeviceNode, *psSysAddr, WRAP_MAPPING_SIZE(uSize, uOffset))) { PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: System address range invalid for device")); return IMG_FALSE; @@ -1797,9 +1785,9 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, } else { - IMG_SIZE_T ui32HostPageSize = HOST_PAGESIZE(); + IMG_SIZE_T uHostPageSize = HOST_PAGESIZE(); - if (!ValidSysPAddrArrayForDev(psBMContext->psDeviceNode, psSysAddr, WRAP_PAGE_COUNT(ui32Size, ui32Offset, ui32HostPageSize), ui32HostPageSize)) + if (!ValidSysPAddrArrayForDev(psBMContext->psDeviceNode, psSysAddr, WRAP_PAGE_COUNT(uSize, uOffset, uHostPageSize), uHostPageSize)) { PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: Array of system addresses invalid for device")); return IMG_FALSE; @@ -1813,27 +1801,29 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, sHashAddress = psSysAddr[0]; /* Add the in-page offset to ensure a unique hash */ - sHashAddress.uiAddr += ui32Offset; + sHashAddress.uiAddr += uOffset; - /* See if this address has already been wrapped */ - pBuf = (BM_BUF *)HASH_Retrieve(psBMContext->pBufferHash, sHashAddress.uiAddr); + /* See if this address has already been wrapped, note that the cast is ok as this is only local mem */ + pBuf = (BM_BUF *)HASH_Retrieve(psBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddress.uiAddr); if(pBuf) { - IMG_SIZE_T ui32MappingSize = HOST_PAGEALIGN (ui32Size + ui32Offset); + IMG_SIZE_T uMappingSize = HOST_PAGEALIGN (uSize + uOffset); /* Check base address, size and contiguity type match */ - if(pBuf->pMapping->uSize == ui32MappingSize && (pBuf->pMapping->eCpuMemoryOrigin == hm_wrapped || + if(pBuf->pMapping->uSize == uMappingSize && (pBuf->pMapping->eCpuMemoryOrigin == hm_wrapped || pBuf->pMapping->eCpuMemoryOrigin == hm_wrapped_virtaddr)) { PVR_DPF((PVR_DBG_MESSAGE, - "BM_Wrap (Matched previous Wrap! uSize=0x%x, uOffset=0x%x, SysAddr=%08X)", - ui32Size, ui32Offset, sHashAddress.uiAddr)); + "BM_Wrap (Matched previous Wrap! uSize=0x%" SIZE_T_FMT_LEN "x, uOffset=0x%" SIZE_T_FMT_LEN "x, SysAddr=" SYSPADDR_FMT ")", + uSize, + uOffset, + sHashAddress.uiAddr)); PVRSRVBMBufIncRef(pBuf); *phBuf = (BM_HANDLE)pBuf; if(pui32Flags) - *pui32Flags = uFlags; + *pui32Flags = ui32Flags; return IMG_TRUE; } @@ -1861,7 +1851,7 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, /* * Actually perform the memory wrap. */ - if (WrapMemory (psBMHeap, ui32Size, ui32Offset, bPhysContig, psSysAddr, pvCPUVAddr, uFlags, pBuf) != IMG_TRUE) + if (WrapMemory (psBMHeap, uSize, uOffset, bPhysContig, psSysAddr, pvCPUVAddr, ui32Flags, pBuf) != IMG_TRUE) { PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: WrapMemory FAILED")); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof (BM_BUF), pBuf, IMG_NULL); @@ -1877,17 +1867,17 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, /* Have we calculated the right Hash key ? */ PVR_ASSERT(SysSysPAddrToCpuPAddr(sHashAddress).uiAddr == pBuf->CpuPAddr.uiAddr); - if (!HASH_Insert (psBMContext->pBufferHash, sHashAddress.uiAddr, (IMG_UINTPTR_T)pBuf)) + if (!HASH_Insert (psBMContext->pBufferHash, (IMG_UINTPTR_T)sHashAddress.uiAddr, (IMG_UINTPTR_T)pBuf)) { - FreeBuf (pBuf, uFlags, IMG_TRUE); + FreeBuf (pBuf, ui32Flags, IMG_TRUE); PVR_DPF((PVR_DBG_ERROR, "BM_Wrap: HASH_Insert FAILED")); return IMG_FALSE; } } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_Wrap (uSize=0x%x, uFlags=0x%x, devVAddr=%08X)", - ui32Size, uFlags, pBuf->DevVAddr.uiAddr)); + "BM_Wrap (uSize=0x%" SIZE_T_FMT_LEN "x, ui32Flags=0x%x, devVAddr=%08X)", + uSize, ui32Flags, pBuf->DevVAddr.uiAddr)); /* * Assign the handle and return. @@ -1897,7 +1887,7 @@ BM_Wrap ( IMG_HANDLE hDevMemHeap, if(pui32Flags) { /* need to override the heap attributes SINGLE PROC to MULT_PROC. */ - *pui32Flags = (uFlags & ~PVRSRV_HAP_MAPTYPE_MASK) | PVRSRV_HAP_MULTI_PROCESS; + *pui32Flags = (ui32Flags & ~PVRSRV_HAP_MAPTYPE_MASK) | PVRSRV_HAP_MULTI_PROCESS; } return IMG_TRUE; @@ -1964,7 +1954,7 @@ BM_Free (BM_HANDLE hBuf, SYS_DATA *psSysData; IMG_SYS_PHYADDR sHashAddr; - PVR_DPF ((PVR_DBG_MESSAGE, "BM_Free (h=0x%x)", (IMG_UINTPTR_T)hBuf)); + PVR_DPF ((PVR_DBG_MESSAGE, "BM_Free (h=0x%p)", hBuf)); PVR_ASSERT (pBuf!=IMG_NULL); if (pBuf == IMG_NULL) @@ -2014,8 +2004,8 @@ BM_HandleToCpuVaddr (BM_HANDLE hBuf) } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_HandleToCpuVaddr(h=0x%x)=0x%x", - (IMG_UINTPTR_T)hBuf, (IMG_UINTPTR_T)pBuf->CpuVAddr)); + "BM_HandleToCpuVaddr(h=0x%p)=0x%p", + hBuf, pBuf->CpuVAddr)); return pBuf->CpuVAddr; } @@ -2045,7 +2035,7 @@ BM_HandleToDevVaddr (BM_HANDLE hBuf) return DevVAddr; } - PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToDevVaddr(h=0x%x)=%08X", (IMG_UINTPTR_T)hBuf, pBuf->DevVAddr.uiAddr)); + PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToDevVaddr(h=0x%p)=%08X", hBuf, pBuf->DevVAddr.uiAddr)); return pBuf->DevVAddr; } @@ -2076,7 +2066,7 @@ BM_HandleToSysPaddr (BM_HANDLE hBuf) return PhysAddr; } - PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToSysPaddr(h=0x%x)=%08X", (IMG_UINTPTR_T)hBuf, pBuf->CpuPAddr.uiAddr)); + PVR_DPF ((PVR_DBG_MESSAGE, "BM_HandleToSysPaddr(h=0lx%p)=" CPUPADDR_FMT, hBuf, pBuf->CpuPAddr.uiAddr)); return SysCpuPAddrToSysPAddr (pBuf->CpuPAddr); } @@ -2106,106 +2096,11 @@ BM_HandleToOSMemHandle(BM_HANDLE hBuf) } PVR_DPF ((PVR_DBG_MESSAGE, - "BM_HandleToOSMemHandle(h=0x%x)=0x%x", - (IMG_UINTPTR_T)hBuf, (IMG_UINTPTR_T)pBuf->hOSMemHandle)); + "BM_HandleToOSMemHandle(h=0x%p)=0x%p", + hBuf, pBuf->hOSMemHandle)); return pBuf->hOSMemHandle; } -/*---------------------------------------------------------------------------- -<function> - FUNCTION: BM_UnmapFromDev - - PURPOSE: Unmaps a buffer from GPU virtual address space, but otherwise - leaves buffer intact (ie. not changing any CPU virtual space - mappings, etc). This in conjunction with BM_RemapToDev() can - be used to migrate buffers in and out of GPU virtual address - space to deal with fragmentation and/or limited size of GPU - MMU. - - PARAMETERS: In: hBuf - buffer handle. - RETURNS: IMG_TRUE - Success - IMG_FALSE - Failure -</function> ------------------------------------------------------------------------------*/ -IMG_INT32 -BM_UnmapFromDev(BM_HANDLE hBuf) -{ - BM_BUF *pBuf = (BM_BUF *)hBuf; - BM_MAPPING *pMapping; - IMG_INT32 result; - - PVR_ASSERT (pBuf != IMG_NULL); - - if (pBuf == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR, "BM_UnmapFromDev: invalid parameter")); - return -(PVRSRV_ERROR_INVALID_PARAMS); - } - - pMapping = pBuf->pMapping; - - if ((pMapping->ui32Flags & PVRSRV_HAP_GPU_PAGEABLE) == 0) - { - PVR_DPF((PVR_DBG_ERROR, "BM_UnmapFromDev: cannot unmap non-pageable buffer")); - return -(PVRSRV_ERROR_STILL_MAPPED); - } - - result = DevMemoryFree(pMapping); - - if(result == 0) - pBuf->DevVAddr.uiAddr = PVRSRV_BAD_DEVICE_ADDRESS; - - return result; -} - -/*---------------------------------------------------------------------------- -<function> - FUNCTION: BM_RemapToDev - - PURPOSE: Maps a buffer back into GPU virtual address space, after it - has been BM_UnmapFromDev()'d. After this operation, the GPU - virtual address may have changed, so BM_HandleToDevVaddr() - should be called to get the new address. - - PARAMETERS: In: hBuf - buffer handle. - RETURNS: IMG_TRUE - Success - IMG_FALSE - Failure -</function> ------------------------------------------------------------------------------*/ -IMG_INT32 -BM_RemapToDev(BM_HANDLE hBuf) -{ - BM_BUF *pBuf = (BM_BUF *)hBuf; - BM_MAPPING *pMapping; - IMG_INT32 mapCount; - - PVR_ASSERT (pBuf != IMG_NULL); - - if (pBuf == IMG_NULL) - { - PVR_DPF((PVR_DBG_ERROR, "BM_RemapToDev: invalid parameter")); - return -PVRSRV_ERROR_INVALID_PARAMS; - } - - pMapping = pBuf->pMapping; - - if ((pMapping->ui32Flags & PVRSRV_HAP_GPU_PAGEABLE) == 0) - { - PVR_DPF((PVR_DBG_ERROR, "BM_RemapToDev: cannot remap non-pageable buffer")); - return -PVRSRV_ERROR_BAD_MAPPING; - } - - mapCount = DevMemoryAlloc(pMapping->pBMHeap->pBMContext, pMapping, IMG_NULL, - pMapping->ui32Flags, pMapping->ui32DevVAddrAlignment, &pBuf->DevVAddr); - - if(mapCount <= 0) - { - PVR_DPF((PVR_DBG_WARNING, "BM_RemapToDev: failed to allocate device memory")); - } - - return mapCount; -} - /*! ****************************************************************************** @@ -2224,52 +2119,48 @@ BM_RemapToDev(BM_HANDLE hBuf) allocation. @Output pActualSize - the actual size of the block allocated in bytes. - @Input uFlags - allocation flags + @Input ui32Flags - allocation flags @Input dev_vaddr_alignment - required device virtual address alignment, or 0. @Output pDevVAddr - receives the device virtual base address of the allocated block. - @Return IMG_INT32 - Reference count - -1 - Failed. + @Return IMG_TRUE - Success + IMG_FALSE - Failed. *****************************************************************************/ -static IMG_INT32 +static IMG_BOOL DevMemoryAlloc (BM_CONTEXT *pBMContext, BM_MAPPING *pMapping, IMG_SIZE_T *pActualSize, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_UINT32 dev_vaddr_alignment, IMG_DEV_VIRTADDR *pDevVAddr) { PVRSRV_DEVICE_NODE *psDeviceNode; #ifdef PDUMP IMG_UINT32 ui32PDumpSize = (IMG_UINT32)pMapping->uSize; + IMG_UINT32 ui32PDumpFlags; #endif - if(pMapping->ui32MappingCount > 0) - { - pMapping->ui32MappingCount++; - *pDevVAddr = pMapping->DevVAddr; - return pMapping->ui32MappingCount; - } - psDeviceNode = pBMContext->psDeviceNode; - pMapping->ui32DevVAddrAlignment = dev_vaddr_alignment; +#ifdef PDUMP +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + ui32PDumpFlags = psDeviceNode->pfnMMUIsHeapShared(pMapping->pBMHeap->pMMUHeap) + ? PDUMP_FLAGS_PERSISTENT : PDUMP_FLAGS_CONTINUOUS; +#else + ui32PDumpFlags = PDUMP_FLAGS_CONTINUOUS; +#endif +#endif - if(uFlags & PVRSRV_MEM_INTERLEAVED) + if(ui32Flags & PVRSRV_MEM_INTERLEAVED) { /* double the size */ - /* don't continue to alter the size each time a buffer is remapped.. - * we only want to do this the first time - */ - /* TODO: FIXME: There is something wrong with this logic */ - if (pMapping->ui32MappingCount == 0) - pMapping->uSize *= 2; + pMapping->uSize *= 2; } #ifdef PDUMP - if(uFlags & PVRSRV_MEM_DUMMY) + if(ui32Flags & PVRSRV_MEM_DUMMY) { /* only one page behind a dummy allocation */ ui32PDumpSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; @@ -2287,8 +2178,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, &(pMapping->DevVAddr))) { PVR_DPF((PVR_DBG_ERROR, "DevMemoryAlloc ERROR MMU_Alloc")); - pDevVAddr->uiAddr = PVRSRV_BAD_DEVICE_ADDRESS; - return -(PVRSRV_ERROR_FAILED_TO_ALLOC_VIRT_MEMORY); + return IMG_FALSE; } #ifdef SUPPORT_SGX_MMU_BYPASS @@ -2303,12 +2193,8 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->hOSMemHandle, ui32PDumpSize, pMapping->pBMHeap->sDevArena.ui32DataPageSize, -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - psDeviceNode->pfnMMUIsHeapShared(pMapping->pBMHeap->pMMUHeap), -#else - IMG_FALSE, // unused -#endif /* SUPPORT_PDUMP_MULTI_PROCESS */ - (IMG_HANDLE)pMapping); + (IMG_HANDLE)pMapping, + ui32PDumpFlags); #endif switch (pMapping->eCpuMemoryOrigin) @@ -2317,7 +2203,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, case hm_wrapped_virtaddr: case hm_contiguous: { - if (uFlags & PVRSRV_MEM_SPARSE) + if (ui32Flags & PVRSRV_MEM_SPARSE) { /* Check if this device supports sparse mappings */ PVR_ASSERT(psDeviceNode->pfnMMUMapPagesSparse != IMG_NULL); @@ -2328,7 +2214,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->ui32NumVirtChunks, pMapping->ui32NumPhysChunks, pMapping->pabMapChunk, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } else @@ -2337,7 +2223,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->DevVAddr, SysCpuPAddrToSysPAddr (pMapping->CpuPAddr), pMapping->uSize, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } *pDevVAddr = pMapping->DevVAddr; @@ -2345,7 +2231,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, } case hm_env: { - if (uFlags & PVRSRV_MEM_SPARSE) + if (ui32Flags & PVRSRV_MEM_SPARSE) { /* Check if this device supports sparse mappings */ PVR_ASSERT(psDeviceNode->pfnMMUMapShadowSparse != IMG_NULL); @@ -2358,7 +2244,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->CpuVAddr, pMapping->hOSMemHandle, pDevVAddr, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } else @@ -2369,7 +2255,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->CpuVAddr, pMapping->hOSMemHandle, pDevVAddr, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); } break; @@ -2381,7 +2267,7 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, pMapping->DevVAddr, pMapping->psSysAddr, pMapping->uSize, - uFlags, + ui32Flags, (IMG_HANDLE)pMapping); *pDevVAddr = pMapping->DevVAddr; @@ -2391,47 +2277,38 @@ DevMemoryAlloc (BM_CONTEXT *pBMContext, PVR_DPF((PVR_DBG_ERROR, "Illegal value %d for pMapping->eCpuMemoryOrigin", pMapping->eCpuMemoryOrigin)); - return -(PVRSRV_ERROR_FAILED_TO_MAP_PAGE_TABLE); + return IMG_FALSE; } #ifdef SUPPORT_SGX_MMU_BYPASS DisableHostAccess(pBMContext->psMMUContext); #endif - pMapping->ui32MappingCount = 1; - - return pMapping->ui32MappingCount; + return IMG_TRUE; } -static IMG_INT32 +static IMG_VOID DevMemoryFree (BM_MAPPING *pMapping) { PVRSRV_DEVICE_NODE *psDeviceNode; IMG_DEV_PHYADDR sDevPAddr; #ifdef PDUMP IMG_UINT32 ui32PSize; + IMG_UINT32 ui32PDumpFlags; #endif - if(pMapping->ui32MappingCount > 1) - { - pMapping->ui32MappingCount--; - - /* Nothing else to do for now */ - return pMapping->ui32MappingCount; - } - - if (pMapping->ui32MappingCount == 0) - { - /* already unmapped from GPU.. bail */ - return -(PVRSRV_ERROR_MAPPING_NOT_FOUND); - } - - /* Then pMapping->ui32MappingCount is 1 - * ready to release GPU mapping */ - psDeviceNode = pMapping->pBMHeap->pBMContext->psDeviceNode; sDevPAddr = psDeviceNode->pfnMMUGetPhysPageAddr(pMapping->pBMHeap->pMMUHeap, pMapping->DevVAddr); +#ifdef PDUMP +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + ui32PDumpFlags = psDeviceNode->pfnMMUIsHeapShared(pMapping->pBMHeap->pMMUHeap) + ? PDUMP_FLAGS_PERSISTENT : PDUMP_FLAGS_CONTINUOUS; +#else + ui32PDumpFlags = PDUMP_FLAGS_CONTINUOUS; +#endif +#endif + if (sDevPAddr.uiAddr != 0) { #ifdef PDUMP @@ -2452,20 +2329,17 @@ DevMemoryFree (BM_MAPPING *pMapping) pMapping->pBMHeap->sDevArena.ui32DataPageSize, (IMG_HANDLE)pMapping, (pMapping->ui32Flags & PVRSRV_MEM_INTERLEAVED) ? IMG_TRUE : IMG_FALSE, - (pMapping->ui32Flags & PVRSRV_MEM_SPARSE) ? IMG_TRUE : IMG_FALSE); + (pMapping->ui32Flags & PVRSRV_MEM_SPARSE) ? IMG_TRUE : IMG_FALSE, + ui32PDumpFlags); #endif } PVR_ASSERT(pMapping->uSizeVM != 0); psDeviceNode->pfnMMUFree (pMapping->pBMHeap->pMMUHeap, pMapping->DevVAddr, IMG_CAST_TO_DEVVADDR_UINT(pMapping->uSizeVM)); - - pMapping->ui32MappingCount = 0; - - return pMapping->ui32MappingCount; } /* If this array grows larger, it might be preferable to use a hashtable rather than an array. */ #ifndef XPROC_WORKAROUND_NUM_SHAREABLES -#define XPROC_WORKAROUND_NUM_SHAREABLES 500 +#define XPROC_WORKAROUND_NUM_SHAREABLES 200 #endif #define XPROC_WORKAROUND_BAD_SHAREINDEX 0773407734 @@ -2480,14 +2354,6 @@ static IMG_UINT32 gXProcWorkaroundState = XPROC_WORKAROUND_UNKNOWN; /* PRQA S 0686 10 */ /* force compiler to init structure */ XPROC_DATA gXProcWorkaroundShareData[XPROC_WORKAROUND_NUM_SHAREABLES] = {{0}}; -IMG_INT32 BM_XProcGetShareDataRefCount(IMG_UINT32 ui32Index) -{ - if(ui32Index >= XPROC_WORKAROUND_NUM_SHAREABLES) - return -1; - - return gXProcWorkaroundShareData[ui32Index].ui32RefCount; -} - PVRSRV_ERROR BM_XProcWorkaroundSetShareIndex(IMG_UINT32 ui32Index) { /* if you fail this assertion - did you acquire the mutex? @@ -2581,8 +2447,7 @@ XProcWorkaroundAllocShareable(RA_ARENA *psArena, if (ui32AllocFlags != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags) { PVR_DPF((PVR_DBG_ERROR, - "%s ERROR: Flags don't match (Shared 0x%08x, Requested 0x%08x)!", - __FUNCTION__, + "Can't! Flags don't match! (I had 0x%08x, you gave 0x%08x)", gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags, ui32AllocFlags)); return PVRSRV_ERROR_INVALID_PARAMS; @@ -2591,24 +2456,14 @@ XProcWorkaroundAllocShareable(RA_ARENA *psArena, if (ui32Size != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32Size) { PVR_DPF((PVR_DBG_ERROR, - "%s ERROR: Size doesn't match (Shared %d, Requested %d) with flags 0x%08x - 0x%08x!", - __FUNCTION__, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32Size, - ui32Size, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags, - ui32AllocFlags)); + "Can't! Size doesn't match!")); return PVRSRV_ERROR_INVALID_PARAMS; } if (ui32PageSize != gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32PageSize) { PVR_DPF((PVR_DBG_ERROR, - "%s ERROR: Page Size doesn't match (Shared %d, Requested %d) with flags 0x%08x - 0x%08x!", - __FUNCTION__, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32PageSize, - ui32PageSize, - gXProcWorkaroundShareData[gXProcWorkaroundShareIndex].ui32AllocFlags, - ui32AllocFlags)); + "Can't! Page Size doesn't match!")); return PVRSRV_ERROR_INVALID_PARAMS; } @@ -2780,7 +2635,7 @@ IMG_VOID _BM_XProcIndexRelease(IMG_UINT32 ui32Index) } sSysPAddr = gXProcWorkaroundShareData[ui32Index].sSysPAddr; RA_Free (gXProcWorkaroundShareData[ui32Index].psArena, - sSysPAddr.uiAddr, + (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); } else @@ -2827,7 +2682,7 @@ static IMG_VOID XProcWorkaroundFreeShareable(IMG_HANDLE hOSMemHandle) which may be >= requested size @Output ppsMapping - receives the arbitrary user reference associated with the underlying storage. - @Input uFlags - bit mask of allocation flags + @Input ui32Flags - bit mask of allocation flags @Input pvPrivData - opaque private data passed through to allocator @Input ui32PrivDataLength - length of opaque private data @Output pBase - receives a pointer to the allocated storage. @@ -2841,7 +2696,7 @@ BM_ImportMemory (IMG_VOID *pH, IMG_SIZE_T uRequestSize, IMG_SIZE_T *pActualSize, BM_MAPPING **ppsMapping, - IMG_UINT32 uFlags, + IMG_UINT32 ui32Flags, IMG_PVOID pvPrivData, IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *pBase) @@ -2849,14 +2704,15 @@ BM_ImportMemory (IMG_VOID *pH, BM_MAPPING *pMapping; BM_HEAP *pBMHeap = pH; BM_CONTEXT *pBMContext = pBMHeap->pBMContext; - IMG_INT32 uResult; + IMG_BOOL bResult; IMG_SIZE_T uSize; IMG_SIZE_T uPSize; IMG_SIZE_T uDevVAddrAlignment = 0; /* ? */ PVR_DPF ((PVR_DBG_MESSAGE, - "BM_ImportMemory (pBMContext=0x%x, uRequestSize=0x%x, uFlags=0x%x, uAlign=0x%x)", - (IMG_UINTPTR_T)pBMContext, uRequestSize, uFlags, uDevVAddrAlignment)); + "BM_ImportMemory (pBMContext=0x%p, uRequestSize=0x%" SIZE_T_FMT_LEN + "x, ui32Flags=0x%x, uAlign=0x%" SIZE_T_FMT_LEN "x)", + pBMContext, uRequestSize, ui32Flags, uDevVAddrAlignment)); PVR_ASSERT (ppsMapping != IMG_NULL); PVR_ASSERT (pBMContext != IMG_NULL); @@ -2882,15 +2738,14 @@ BM_ImportMemory (IMG_VOID *pH, pMapping->hOSMemHandle = 0; pMapping->CpuVAddr = 0; pMapping->DevVAddr.uiAddr = 0; - pMapping->ui32MappingCount = 0; pMapping->CpuPAddr.uiAddr = 0; pMapping->uSize = uSize; - if ((uFlags & PVRSRV_MEM_SPARSE) == 0) + if ((ui32Flags & PVRSRV_MEM_SPARSE) == 0) { pMapping->uSizeVM = uSize; } pMapping->pBMHeap = pBMHeap; - pMapping->ui32Flags = uFlags; + pMapping->ui32Flags = ui32Flags; /* * If anyone want's to know, pass back the actual size of our allocation. @@ -2912,16 +2767,11 @@ BM_ImportMemory (IMG_VOID *pH, uPSize = pMapping->uSize; } - if (uFlags & PVRSRV_MEM_XPROC) + if (ui32Flags & 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) @@ -2956,7 +2806,7 @@ BM_ImportMemory (IMG_VOID *pH, &pMapping->hOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%x) failed", + "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%" SIZE_T_FMT_LEN "x) failed", uPSize)); goto fail_mapping_alloc; } @@ -3000,7 +2850,7 @@ BM_ImportMemory (IMG_VOID *pH, &pMapping->hOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%x) failed", + "BM_ImportMemory: XProcWorkaroundAllocShareable(0x%" SIZE_T_FMT_LEN "x) failed", uPSize)); goto fail_mapping_alloc; } @@ -3060,7 +2910,7 @@ BM_ImportMemory (IMG_VOID *pH, &pMapping->hOSMemHandle) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: OSAllocPages(0x%x) failed", + "BM_ImportMemory: OSAllocPages(0x%" SIZE_T_FMT_LEN "x) failed", uPSize)); goto fail_mapping_alloc; } @@ -3102,7 +2952,7 @@ BM_ImportMemory (IMG_VOID *pH, ui32PrivDataLength, (IMG_UINTPTR_T *)&sSysPAddr.uiAddr)) { - PVR_DPF((PVR_DBG_ERROR, "BM_ImportMemory: RA_Alloc(0x%x) FAILED", uPSize)); + PVR_DPF((PVR_DBG_ERROR, "BM_ImportMemory: RA_Alloc(0x%" SIZE_T_FMT_LEN "x) FAILED", uPSize)); goto fail_mapping_alloc; } @@ -3128,42 +2978,21 @@ BM_ImportMemory (IMG_VOID *pH, goto fail_mapping_alloc; } - if(uFlags & PVRSRV_MEM_ION) - { - IMG_UINT32 ui32AddressOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - IMG_UINT32 ui32NumAddrOffsets = PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES; - - IMG_INT32 retSize = OSGetMemMultiPlaneInfo(pMapping->hOSMemHandle, - ui32AddressOffsets, &ui32NumAddrOffsets); - - if(retSize > 0 && pActualSize) - { - *pActualSize = pMapping->uSize = retSize; - } - } - /* * Allocate some device memory for what we just allocated. */ - /* - * Do not allocate GPU mapping if NO_GPU_VIRTUAL_ON_ALLOC is requested. - * In the case where CBI is enabled, this allows for late - * GPU mapping. This flag is, otherwise, used in cases where only - * the memory management feature of the driver is utilized, without - * a need for GPU rendering - */ - if ((uFlags & (PVRSRV_MEM_SPARSE | PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC)) == 0) + if ((ui32Flags & PVRSRV_MEM_SPARSE) == 0) { - uResult = DevMemoryAlloc (pBMContext, + bResult = DevMemoryAlloc (pBMContext, pMapping, IMG_NULL, - uFlags, + ui32Flags, (IMG_UINT32)uDevVAddrAlignment, &pMapping->DevVAddr); - if (uResult <= 0) + if (!bResult) { PVR_DPF((PVR_DBG_ERROR, - "BM_ImportMemory: DevMemoryAlloc(0x%x) failed", + "BM_ImportMemory: DevMemoryAlloc(0x%" SIZE_T_FMT_LEN "x) failed", pMapping->uSize)); goto fail_dev_mem_alloc; } @@ -3172,10 +3001,9 @@ BM_ImportMemory (IMG_VOID *pH, /* PRQA S 3356,3358 1 */ PVR_ASSERT (uDevVAddrAlignment>1?(pMapping->DevVAddr.uiAddr%uDevVAddrAlignment)==0:1); PVR_ASSERT(pBase); + *pBase = pMapping->DevVAddr.uiAddr; } - if(pBase) - *pBase = pMapping->DevVAddr.uiAddr; *ppsMapping = pMapping; PVR_DPF ((PVR_DBG_MESSAGE, "BM_ImportMemory: IMG_TRUE")); @@ -3199,7 +3027,7 @@ fail_dev_mem_alloc: uPSize = pMapping->uSize; } - if (uFlags & PVRSRV_MEM_XPROC) + if (ui32Flags & PVRSRV_MEM_XPROC) { XProcWorkaroundFreeShareable(pMapping->hOSMemHandle); } @@ -3223,7 +3051,7 @@ fail_dev_mem_alloc: pMapping->hOSMemHandle); } sSysPAddr = SysCpuPAddrToSysPAddr(pMapping->CpuPAddr); - RA_Free (pBMHeap->pLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + RA_Free (pBMHeap->pLocalDevMemArena, (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); } } fail_mapping_alloc: @@ -3259,8 +3087,8 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping) PVR_UNREFERENCED_PARAMETER (_base); PVR_DPF ((PVR_DBG_MESSAGE, - "BM_FreeMemory (h=0x%x, base=0x%x, psMapping=0x%x)", - (IMG_UINTPTR_T)h, _base, (IMG_UINTPTR_T)psMapping)); + "BM_FreeMemory (h=0x%p, base=0x" UINTPTR_FMT ", psMapping=0x%p)", + h, _base, psMapping)); PVR_ASSERT (psMapping != IMG_NULL); @@ -3315,7 +3143,7 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping) sSysPAddr = SysCpuPAddrToSysPAddr(psMapping->CpuPAddr); - RA_Free (pBMHeap->pLocalDevMemArena, sSysPAddr.uiAddr, IMG_FALSE); + RA_Free (pBMHeap->pLocalDevMemArena, (IMG_UINTPTR_T)sSysPAddr.uiAddr, IMG_FALSE); } else { @@ -3326,8 +3154,8 @@ BM_FreeMemory (IMG_VOID *h, IMG_UINTPTR_T _base, BM_MAPPING *psMapping) /*not nulling pointer, copy on stack*/ PVR_DPF((PVR_DBG_MESSAGE, - "..BM_FreeMemory (h=0x%x, base=0x%x)", - (IMG_UINTPTR_T)h, _base)); + "..BM_FreeMemory (h=0x%p, base=0x" UINTPTR_FMT ")", + h, _base)); } /*! diff --git a/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c b/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c index d047c7838b3..7a96e0ed533 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c +++ b/drivers/gpu/pvr/services4/srvkm/common/deviceclass.c @@ -1,4 +1,5 @@ /*************************************************************************/ /*! +@File @Title Device class services functions @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved @Description Kernel services functions for device class devices @@ -49,21 +50,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "deviceid.h" #include "lists.h" -#if defined(CONFIG_GCBV) -#include "gc_bvmapping.h" + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include "pvr_sync.h" #endif PVRSRV_ERROR AllocateDeviceID(SYS_DATA *psSysData, IMG_UINT32 *pui32DevID); PVRSRV_ERROR FreeDeviceID(SYS_DATA *psSysData, IMG_UINT32 ui32DevID); -#if defined(SUPPORT_MISR_IN_THREAD) -void OSVSyncMISR(IMG_HANDLE, IMG_BOOL); -#endif - -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) -IMG_VOID PVRSRVFreeCommandCompletePacketKM(IMG_HANDLE hCmdCookie, - IMG_BOOL bScheduleMISR); -#endif /*********************************************************************** Local Display Class Structures ************************************************************************/ @@ -1166,6 +1160,14 @@ static PVRSRV_ERROR DestroyDCSwapChain(PVRSRV_DC_SWAPCHAIN *psSwapChain) #if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) if (psSwapChain->ppsLastSyncInfos) { + for (i = 0; i < psSwapChain->ui32LastNumSyncInfos; i++) + { + if (psSwapChain->ppsLastSyncInfos[i]) + { + PVRSRVKernelSyncInfoDecRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); + psSwapChain->ppsLastSyncInfos[i] = IMG_NULL; + } + } OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * psSwapChain->ui32LastNumSyncInfos, psSwapChain->ppsLastSyncInfos, IMG_NULL); } @@ -1276,7 +1278,6 @@ PVRSRV_ERROR PVRSRVCreateDCSwapChainKM (PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_UINT32 i; DISPLAY_INFO sDisplayInfo; - if(!hDeviceKM || !psDstSurfAttrib || !psSrcSurfAttrib @@ -1287,18 +1288,14 @@ PVRSRV_ERROR PVRSRVCreateDCSwapChainKM (PVRSRV_PER_PROCESS_DATA *psPerProc, return PVRSRV_ERROR_INVALID_PARAMS; } + OSMemSet (apsSyncData, 0, sizeof(PVRSRV_SYNC_DATA *) * PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS); + if (ui32BufferCount > PVRSRV_MAX_DC_SWAPCHAIN_BUFFERS) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateDCSwapChainKM: Too many buffers")); return PVRSRV_ERROR_TOOMANYBUFFERS; } - if (ui32BufferCount < 2) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateDCSwapChainKM: Too few buffers")); - return PVRSRV_ERROR_TOO_FEW_BUFFERS; - } - psDCInfo = DCDeviceHandleToDCInfo(hDeviceKM); if( ui32Flags & PVRSRV_CREATE_SWAPCHAIN_QUERY ) @@ -1428,7 +1425,7 @@ PVRSRV_ERROR PVRSRVCreateDCSwapChainKM (PVRSRV_PER_PROCESS_DATA *psPerProc, psSwapChain->ui32RefCount = 1; psSwapChain->ui32Flags = ui32Flags; - /* Save pointer in DC structure if ti's shared struct */ + /* Save pointer in DC structure if it's shared struct */ if( ui32Flags & PVRSRV_CREATE_SWAPCHAIN_SHARED ) { if(! psDCInfo->psDCSwapChainShared ) @@ -1610,32 +1607,6 @@ 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 /* defined(SUPPORT_GET_DC_BUFFERS_SYS_PHYADDRS) */ - return eError; } @@ -1679,21 +1650,6 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, return PVRSRV_ERROR_INVALID_SWAPINTERVAL; } -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) - - if(psDCInfo->psFuncTable->pfnQuerySwapCommandID != IMG_NULL) - { - psDCInfo->psFuncTable->pfnQuerySwapCommandID(psDCInfo->hExtDevice, - psBuffer->psSwapChain->hExtSwapChain, - psBuffer->sDeviceClassBuffer.hExtBuffer, - hPrivateTag, - &ui16SwapCommandID, - &bAddReferenceToLast); - - } - -#endif - /* get the queue from the buffer structure */ psQueue = psBuffer->psSwapChain->psQueue; @@ -1717,6 +1673,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBufferKM(IMG_HANDLE hDeviceKM, apsSrcSync, sizeof(DISPLAYCLASS_FLIP_COMMAND) + (sizeof(IMG_RECT) * ui32ClipRectCount), IMG_NULL, + IMG_NULL, IMG_NULL); if(eError != PVRSRV_OK) { @@ -1836,20 +1793,27 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, PVRSRV_KERNEL_SYNC_INFO **ppsSyncInfos, IMG_UINT32 ui32NumMemSyncInfos, IMG_PVOID pvPrivData, - IMG_UINT32 ui32PrivDataLength) + IMG_UINT32 ui32PrivDataLength, + IMG_HANDLE *phFence) { + IMG_UINT32 ui32NumSyncInfos = ui32NumMemSyncInfos; + IMG_UINT32 ui32NumMemInfos = ui32NumMemSyncInfos; 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; + PVRSRV_ERROR eError; SYS_DATA *psSysData; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + struct sync_fence *apsFence[SGX_MAX_SRC_SYNCS_TA] = {}; +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + if(!hDeviceKM || !hSwapChain || !ppsMemInfos || !ppsSyncInfos || ui32NumMemSyncInfos < 1) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Invalid parameters")); @@ -1881,7 +1845,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, psCallbackData->ui32PrivDataLength = ui32PrivDataLength; if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(IMG_VOID *) * ui32NumMemSyncInfos, + sizeof(IMG_VOID *) * ui32NumMemInfos, (IMG_VOID **)&ppvMemInfos, IMG_NULL, "Swap Command Meminfos") != PVRSRV_OK) { @@ -1890,13 +1854,22 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, goto Exit; } - for(i = 0; i < ui32NumMemSyncInfos; i++) + for(i = 0; i < ui32NumMemInfos; i++) { ppvMemInfos[i] = ppsMemInfos[i]; } psCallbackData->ppvMemInfos = ppvMemInfos; - psCallbackData->ui32NumMemInfos = ui32NumMemSyncInfos; + psCallbackData->ui32NumMemInfos = ui32NumMemInfos; + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + eError = PVRSyncFencesToSyncInfos(ppsSyncInfos, &ui32NumSyncInfos, apsFence); + if(eError != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: PVRSyncFencesToSyncInfos failed")); + goto Exit; + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ /* get the queue from the buffer structure */ psQueue = psSwapChain->psQueue; @@ -1905,21 +1878,35 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, if(psSwapChain->ppsLastSyncInfos) { IMG_UINT32 ui32NumUniqueSyncInfos = psSwapChain->ui32LastNumSyncInfos; + IMG_BOOL *abUnique; IMG_UINT32 j; + if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_BOOL) * psSwapChain->ui32LastNumSyncInfos, + (IMG_VOID **)&abUnique, IMG_NULL, + "Unique booleans") != PVRSRV_OK) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for unique booleans")); + goto Exit; + } + for(j = 0; j < psSwapChain->ui32LastNumSyncInfos; j++) { - for(i = 0; i < ui32NumMemSyncInfos; i++) + abUnique[j] = IMG_TRUE; + for(i = 0; i < ui32NumSyncInfos; i++) { + PVR_ASSERT(psSwapChain->ppsLastSyncInfos[j]); + PVR_ASSERT(ppsSyncInfos[i]); if(psSwapChain->ppsLastSyncInfos[j] == ppsSyncInfos[i]) { - psSwapChain->ppsLastSyncInfos[j] = IMG_NULL; + abUnique[j] = IMG_FALSE; ui32NumUniqueSyncInfos--; + break; } } } - ui32NumCompiledSyncInfos = ui32NumMemSyncInfos + ui32NumUniqueSyncInfos; + ui32NumCompiledSyncInfos = ui32NumSyncInfos + ui32NumUniqueSyncInfos; if(OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumCompiledSyncInfos, @@ -1927,24 +1914,132 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, "Compiled syncinfos") != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_BOOL) * psSwapChain->ui32LastNumSyncInfos, + (IMG_VOID *)abUnique, IMG_NULL); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); +#endif goto Exit; } - OSMemCopy(ppsCompiledSyncInfos, ppsSyncInfos, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumMemSyncInfos); - for(j = 0, i = ui32NumMemSyncInfos; j < psSwapChain->ui32LastNumSyncInfos; j++) + OSMemCopy(ppsCompiledSyncInfos, ppsSyncInfos, sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumSyncInfos); + for(j = 0, i = ui32NumSyncInfos; j < psSwapChain->ui32LastNumSyncInfos; j++) { - if(psSwapChain->ppsLastSyncInfos[j]) + if(abUnique[j]) { ppsCompiledSyncInfos[i] = psSwapChain->ppsLastSyncInfos[j]; i++; } } + + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(IMG_BOOL) * psSwapChain->ui32LastNumSyncInfos, + (IMG_VOID *)abUnique, IMG_NULL); } else #endif /* !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) */ { - ppsCompiledSyncInfos = ppsSyncInfos; - ui32NumCompiledSyncInfos = ui32NumMemSyncInfos; + IMG_UINT32 j, ui32Missing = 0; + + /* Older synchronization schemes would just pass down the syncinfos + * hanging off of the meminfos. So we would expect identical lists. + * However, newer drivers may send down additional synchronization + * i.e. for TQ fence operations. In such a case we need to allocate + * more space for the compiled syncinfos to ensure everything is + * ROP2 synchronized. + */ + for(i = 0; i < ui32NumMemInfos; i++) + { + for(j = 0; j < ui32NumSyncInfos; j++) + { + if(ppsSyncInfos[j] == ppsMemInfos[i]->psKernelSyncInfo) + break; + } + + if(j == ui32NumSyncInfos) + ui32Missing++; + } + + if(ui32Missing) + { + IMG_UINT32 k; + + ui32NumCompiledSyncInfos = ui32NumSyncInfos + ui32Missing; + + 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")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); +#endif + goto Exit; + } + + for(i = 0; i < ui32NumSyncInfos; i++) + { + ppsCompiledSyncInfos[i] = ppsSyncInfos[i]; + } + + k = i; + for(i = 0; i < ui32NumMemInfos; i++) + { + for(j = 0; j < ui32NumSyncInfos; j++) + { + if(ppsSyncInfos[j] == ppsMemInfos[i]->psKernelSyncInfo) + break; + } + + if(j == ui32NumSyncInfos) + { + /* Insert the unique one */ + PVR_ASSERT(k < ui32NumCompiledSyncInfos); + ppsCompiledSyncInfos[k] = ppsMemInfos[i]->psKernelSyncInfo; + k++; + } + } + + PVR_ASSERT(k == ui32NumCompiledSyncInfos); + + /* As a further complication, if we have multiple displays, we + * might see the same layer/meminfo submitted twice. This is + * valid, as the layer might be needed by two separate pipes, + * but we should not use the meminfo's synchronization twice + * because this will deadlock the queue processor. + * + * For now, work over the meminfo end of the compiled syncs + * list and collapse any duplicates. We can assume the fence + * sync part of the array has already been de-duplicated. + */ + k = ui32NumSyncInfos; + for(i = ui32NumSyncInfos; i < ui32NumCompiledSyncInfos; i++) + { + /* Compare the i'th entry with all that follow */ + for(j = i + 1; j < ui32NumCompiledSyncInfos; j++) + { + if(ppsCompiledSyncInfos[i] == ppsCompiledSyncInfos[j]) + break; + } + + if(j == ui32NumCompiledSyncInfos) + { + /* No duplicate found. Use this entry */ + ppsCompiledSyncInfos[k] = ppsCompiledSyncInfos[i]; + k++; + } + } + ui32NumCompiledSyncInfos = k; + } + else + { + ppsCompiledSyncInfos = ppsSyncInfos; + ui32NumCompiledSyncInfos = ui32NumSyncInfos; + } } /* insert the command (header) */ @@ -1958,7 +2053,17 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, ppsCompiledSyncInfos, sizeof(DISPLAYCLASS_FLIP_COMMAND2), FreePrivateData, - psCallbackData); + psCallbackData, + phFence); + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + /* InsertCommand bumped the refcount on the raw sync objects, so we + * can put the fences now. Even if the fences are deleted, the syncs + * will persist. + */ + for(i = 0; i < SGX_MAX_SRC_SYNCS_TA && apsFence[i]; i++) + sync_fence_put(apsFence[i]); +#endif if (ppsCompiledSyncInfos != ppsSyncInfos) { @@ -1990,7 +2095,7 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, psFlipCmd->ui32PrivDataLength = ui32PrivDataLength; psFlipCmd->ppsMemInfos = (PDC_MEM_INFO *)ppvMemInfos; - psFlipCmd->ui32NumMemInfos = ui32NumMemSyncInfos; + psFlipCmd->ui32NumMemInfos = ui32NumMemInfos; /* Even though this is "unused", we have to initialize it, * as the display controller might NULL-test it. @@ -2026,6 +2131,11 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to submit command")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_fence_put(psCommand->pvCleanupFence); + sync_fence_put(*phFence); + *phFence = IMG_NULL; +#endif goto Exit; } @@ -2040,34 +2150,60 @@ PVRSRV_ERROR PVRSRVSwapToDCBuffer2KM(IMG_HANDLE hDeviceKM, if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to schedule MISR")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_fence_put(*phFence); + *phFence = IMG_NULL; +#endif goto Exit; } #if !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) /* Reallocate the syncinfo list if it was too small */ - if (psSwapChain->ui32LastNumSyncInfos < ui32NumMemSyncInfos) + if (psSwapChain->ui32LastNumSyncInfos < ui32NumSyncInfos) { if (psSwapChain->ppsLastSyncInfos) { + for (i = 0; i < psSwapChain->ui32LastNumSyncInfos; i++) + { + if (psSwapChain->ppsLastSyncInfos[i]) + { + PVRSRVKernelSyncInfoDecRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); + psSwapChain->ppsLastSyncInfos[i] = IMG_NULL; + } + } 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, + sizeof(PVRSRV_KERNEL_SYNC_INFO *) * ui32NumSyncInfos, (IMG_VOID **)&psSwapChain->ppsLastSyncInfos, IMG_NULL, "Last syncinfos") != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVSwapToDCBuffer2KM: Failed to allocate space for meminfo list")); +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_fence_put(*phFence); + *phFence = IMG_NULL; +#endif goto Exit; } } - psSwapChain->ui32LastNumSyncInfos = ui32NumMemSyncInfos; + for (i = 0; i < psSwapChain->ui32LastNumSyncInfos; i++) + { + if (psSwapChain->ppsLastSyncInfos[i]) + { + PVRSRVKernelSyncInfoDecRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); + psSwapChain->ppsLastSyncInfos[i] = IMG_NULL; + } + } - for(i = 0; i < ui32NumMemSyncInfos; i++) + psSwapChain->ui32LastNumSyncInfos = ui32NumSyncInfos; + + for(i = 0; i < ui32NumSyncInfos; i++) { psSwapChain->ppsLastSyncInfos[i] = ppsSyncInfos[i]; + PVRSRVKernelSyncInfoIncRef(psSwapChain->ppsLastSyncInfos[i], IMG_NULL); } #endif /* !defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) */ @@ -2119,7 +2255,7 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, psSwapChain = psSwapChainRef->psSwapChain; /* - If more then 1 reference to the swapchain exist then + If more than 1 reference to the swapchain exists then ignore any request to swap to the system buffer */ if (psSwapChain->ui32RefCount > 1) @@ -2130,21 +2266,6 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, /* get the queue from the buffer structure */ psQueue = psSwapChain->psQueue; -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) - - if(psDCInfo->psFuncTable->pfnQuerySwapCommandID != IMG_NULL) - { - psDCInfo->psFuncTable->pfnQuerySwapCommandID(psDCInfo->hExtDevice, - psSwapChain->hExtSwapChain, - psDCInfo->sSystemBuffer.sDeviceClassBuffer.hExtBuffer, - 0, - &ui16SwapCommandID, - &bAddReferenceToLast); - - } - -#endif - /* specify the syncs */ apsSrcSync[0] = psDCInfo->sSystemBuffer.sDeviceClassBuffer.psKernelSyncInfo; if(bAddReferenceToLast && psSwapChain->psLastFlipBuffer) @@ -2168,6 +2289,7 @@ PVRSRV_ERROR PVRSRVSwapToDCSystemKM(IMG_HANDLE hDeviceKM, apsSrcSync, sizeof(DISPLAYCLASS_FLIP_COMMAND), IMG_NULL, + IMG_NULL, IMG_NULL); if(eError != PVRSRV_OK) { @@ -2372,69 +2494,6 @@ PVRSRVDCMemInfoIsPhysContig(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) return OSMemHandleIsPhysContig(psKernelMemInfo->sMemBlk.hOSMemHandle); } -static PVRSRV_ERROR PVRSRVDCMemInfoGetBvHandle(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo, IMG_VOID **handle) -{ -#if !defined(CONFIG_GCBV) - *handle = NULL; - return PVRSRV_ERROR_NOT_SUPPORTED; -#else - *handle = gc_meminfo_to_hndl(psKernelMemInfo); - return PVRSRV_OK; -#endif -} - -/*! -****************************************************************************** - - @Function PVRSRVDCMemInfoGetCpuMultiPlanePAddr - - @Description returns physical addresses of a multi-plane buffer - - - @Input psKernelMemInfo - Pointer to Kernel Memory Info structure - puPlaneByteOffsets - requested offset inside the plane. - If the array is a NULL pointer, 0 requested offsets - are assumed for all planes; - pui32NumAddrOffsets - specifying the size of the user array. - If the array is smaller than the number of the planes - for this buffer, the correct size will be set and an - error returned back; - -@Output pPlanePAddrs - array of plane physical addresses of the returned size - in pui32NumAddrOffsets; - pui32NumAddrOffsets - contains the real number of planes for the buffer; - -@Return IMG_INT32 : size of the entire buffer or negative number on ERROR - -******************************************************************************/ -static IMG_INT32 -PVRSRVDCMemInfoGetCpuMultiPlanePAddr(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo, - IMG_SIZE_T* puPlaneByteOffsets, IMG_CPU_PHYADDR* pPlanePAddrs, - IMG_UINT32* pui32NumAddrOffsets) -{ - IMG_UINT32 aui32PlaneAddressOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - IMG_INT32 i32Ret; - IMG_UINT32 i; - - i32Ret = OSGetMemMultiPlaneInfo(psKernelMemInfo->sMemBlk.hOSMemHandle, - aui32PlaneAddressOffsets, - pui32NumAddrOffsets); - - if((i32Ret < 0) || (pPlanePAddrs == IMG_NULL)) - return i32Ret; - - for (i = 0; i < *pui32NumAddrOffsets; i++) - { - IMG_SIZE_T uiReqByteOffsets = puPlaneByteOffsets ? puPlaneByteOffsets[i] : 0; - - uiReqByteOffsets += aui32PlaneAddressOffsets[i]; - - pPlanePAddrs[i] = OSMemHandleToCpuPAddr(psKernelMemInfo->sMemBlk.hOSMemHandle, uiReqByteOffsets); - } - - return i32Ret; -} - /*! ****************************************************************************** @@ -2458,22 +2517,13 @@ IMG_BOOL PVRGetDisplayClassJTable(PVRSRV_DC_DISP2SRV_KMJTABLE *psJTable) psJTable->pfnPVRSRVOEMFunction = &SysOEMFunction; psJTable->pfnPVRSRVRegisterCmdProcList = &PVRSRVRegisterCmdProcListKM; psJTable->pfnPVRSRVRemoveCmdProcList = &PVRSRVRemoveCmdProcListKM; -#if defined(SUPPORT_MISR_IN_THREAD) - psJTable->pfnPVRSRVCmdComplete = &OSVSyncMISR; -#else - psJTable->pfnPVRSRVCmdComplete = &PVRSRVCommandCompleteKM; -#endif + psJTable->pfnPVRSRVCmdComplete = &PVRSRVCommandCompleteKM; psJTable->pfnPVRSRVRegisterSystemISRHandler = &PVRSRVRegisterSystemISRHandler; psJTable->pfnPVRSRVRegisterPowerDevice = &PVRSRVRegisterPowerDevice; -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) - psJTable->pfnPVRSRVFreeCmdCompletePacket = &PVRSRVFreeCommandCompletePacketKM; -#endif psJTable->pfnPVRSRVDCMemInfoGetCpuVAddr = &PVRSRVDCMemInfoGetCpuVAddr; psJTable->pfnPVRSRVDCMemInfoGetCpuPAddr = &PVRSRVDCMemInfoGetCpuPAddr; psJTable->pfnPVRSRVDCMemInfoGetByteSize = &PVRSRVDCMemInfoGetByteSize; psJTable->pfnPVRSRVDCMemInfoIsPhysContig = &PVRSRVDCMemInfoIsPhysContig; - psJTable->pfnPVRSRVDCMemInfoGetBvHandle = &PVRSRVDCMemInfoGetBvHandle; - psJTable->pfnPVRSRVDCMemInfoGetCpuMultiPlanePAddr = PVRSRVDCMemInfoGetCpuMultiPlanePAddr; return IMG_TRUE; } diff --git a/drivers/gpu/pvr/services4/srvkm/common/deviceid.h b/drivers/gpu/pvr/services4/srvkm/common/deviceid.h index 1cf9f0fdd39..1cf9f0fdd39 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/deviceid.h +++ b/drivers/gpu/pvr/services4/srvkm/common/deviceid.h diff --git a/drivers/gpu/pvr/services4/srvkm/common/devicemem.c b/drivers/gpu/pvr/services4/srvkm/common/devicemem.c index 872c0bab0ff..ac68bcf80bb 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/devicemem.c +++ b/drivers/gpu/pvr/services4/srvkm/common/devicemem.c @@ -47,15 +47,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pdump_km.h" #include "pvr_bridge_km.h" #include "osfunc.h" -#if defined(CONFIG_GCBV) -#include "gc_bvmapping.h" -#endif +#include "devicemem.h" #if defined(SUPPORT_ION) #include "ion.h" #include "env_perproc.h" +#include "ion_sync.h" + +/* Start size of the g_IonSyncHash hash table */ +#define ION_SYNC_HASH_SIZE 20 +HASH_TABLE *g_psIonSyncHash = IMG_NULL; #endif +#include "lists.h" + /* local function prototypes */ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, IMG_HANDLE hDevMemHeap, @@ -84,6 +89,8 @@ typedef struct _RESMAN_MAP_DEVICE_MEM_DATA_ PVRSRV_KERNEL_MEM_INFO *psSrcMemInfo; } RESMAN_MAP_DEVICE_MEM_DATA; +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) + /* map device class resman memory storage structure */ @@ -96,7 +103,103 @@ typedef struct _PVRSRV_DC_MAPINFO_ PVRSRV_DEVICECLASS_BUFFER *psDeviceClassBuffer; } PVRSRV_DC_MAPINFO; +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ + static IMG_UINT32 g_ui32SyncUID = 0; +#if defined (MEM_TRACK_INFO_DEBUG) +PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoHead = NULL; +PVRSRV_MEM_TRACK_INFO *g_psMemTrackInfoTail = NULL; +IMG_UINT32 g_ui32NumOfOpsRecorded = 0; +#endif + +static PVRSRV_KERNEL_SYNC_INFO *g_psSyncInfoList = IMG_NULL; + +#if defined (MEM_TRACK_INFO_DEBUG) +/*! +****************************************************************************** + + @Function PVRSRVAddMemTrackInfo + + @Description + + Adds the current psMemTrackInfo instance to the head of list represented by gMemTrackInfo + + @Input psMemTrackInfo : + @Output + + @Return + +******************************************************************************/ +IMG_EXPORT +IMG_VOID IMG_CALLCONV PVRSRVAddMemTrackInfo(PVRSRV_MEM_TRACK_INFO *psMemTrackInfo) +{ + g_ui32NumOfOpsRecorded++; + psMemTrackInfo->next = g_psMemTrackInfoHead; + psMemTrackInfo->prev = IMG_NULL; + if(g_psMemTrackInfoHead) + { + g_psMemTrackInfoHead->prev = psMemTrackInfo; + } + else + g_psMemTrackInfoTail = psMemTrackInfo; + g_psMemTrackInfoHead = psMemTrackInfo; + if(g_ui32NumOfOpsRecorded > MAX_MEM_TRACK_OPS) + { + PVRSRV_MEM_TRACK_INFO *psFreePtr; + psFreePtr = g_psMemTrackInfoTail; + g_psMemTrackInfoTail = g_psMemTrackInfoTail->prev; + g_psMemTrackInfoTail->next = IMG_NULL; + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + psFreePtr, IMG_NULL); + g_ui32NumOfOpsRecorded--; + } +} + +/*! +****************************************************************************** + + @Function PVRSRVPrintMemTrackInfo + + @Description + + Dumps the mem tracking info + + @Input ui32FaultAddr: + @Output + + @Return + +******************************************************************************/ +IMG_EXPORT +IMG_VOID IMG_CALLCONV PVRSRVPrintMemTrackInfo(IMG_UINT32 ui32FaultAddr) +{ + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + const IMG_CHAR *apszMemOpNames[] = {"UNKNOWN", "DEVICE", "DEVICECLASS", "WRAPPED", "MAPPED", "ION", "ALLOC", "FREE"}; + psMemTrackInfo = g_psMemTrackInfoHead; + + PVR_DPF((PVR_DBG_MESSAGE,"PVRSRVMemTrackInfo: Dumping mem tracking info\n")); + PVR_DPF((PVR_DBG_MESSAGE,"DevVAddr | Size | Memory Op | Process ID | Ref Count | Task Name | Heap ID | Time Stamp(uSec)\n")); + while(psMemTrackInfo) + { + if((ui32FaultAddr >= psMemTrackInfo->sDevVAddr.uiAddr) && + (ui32FaultAddr < (psMemTrackInfo->sDevVAddr.uiAddr + psMemTrackInfo->uSize))) + { + PVR_DPF((PVR_DBG_MESSAGE,"***************************\n")); + } + PVR_DPF((PVR_DBG_MESSAGE,"0x%-8x | 0x%-8zx | %-13s | %-11d | %-6u | %-15s | %10s | %-15u ", + psMemTrackInfo->sDevVAddr.uiAddr, + psMemTrackInfo->uSize, + apszMemOpNames[psMemTrackInfo->eOp], + psMemTrackInfo->ui32Pid, + psMemTrackInfo->ui32RefCount, + psMemTrackInfo->asTaskName, + psMemTrackInfo->heapId, + psMemTrackInfo->ui32TimeStampUSecs)); + psMemTrackInfo = psMemTrackInfo->next; + } +} +#endif /*! ****************************************************************************** @@ -116,11 +219,7 @@ 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; @@ -188,11 +287,7 @@ 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) { @@ -204,7 +299,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook IMG_DEV_PHYADDR sPDDevPAddr; IMG_UINT32 i; -#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) +#if !defined(PVR_SECURE_HANDLES) PVR_UNREFERENCED_PARAMETER(pbShared); #endif @@ -260,7 +355,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook psHeapInfo[ui32ClientHeapCount].ui32XTileStride = 0; #endif -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_TRUE; #endif ui32ClientHeapCount++; @@ -294,7 +389,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContextKM(IMG_HANDLE hDevCook #else psHeapInfo[ui32ClientHeapCount].ui32XTileStride = 0; #endif -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_FALSE; #endif @@ -345,11 +440,7 @@ 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; @@ -358,7 +449,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie IMG_HANDLE hDevMemHeap; IMG_UINT32 i; -#if !defined(PVR_SECURE_HANDLES) && !defined (SUPPORT_SID_INTERFACE) +#if !defined(PVR_SECURE_HANDLES) PVR_UNREFERENCED_PARAMETER(pbShared); #endif @@ -396,7 +487,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_TRUE; #endif ui32ClientHeapCount++; @@ -426,7 +517,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie psHeapInfo[ui32ClientHeapCount].ui32HeapByteSize = psDeviceMemoryHeap[i].ui32HeapSize; psHeapInfo[ui32ClientHeapCount].ui32Attribs = psDeviceMemoryHeap[i].ui32Attribs; psHeapInfo[ui32ClientHeapCount].ui32XTileStride = psDeviceMemoryHeap[i].ui32XTileStride; -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) pbShared[ui32ClientHeapCount] = IMG_FALSE; #endif @@ -442,34 +533,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfoKM(IMG_HANDLE hDevCookie return PVRSRV_OK; } -static PVRSRV_ERROR UpdateDeviceMemoryPlaneOffsets(PVRSRV_KERNEL_MEM_INFO *psMemInfo) -{ - if(psMemInfo->ui32Flags & PVRSRV_MEM_ION) - { - - PVRSRV_MEMBLK *psMemBlock = &(psMemInfo->sMemBlk); - IMG_UINT32 ui32AddressOffsets[PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES]; - IMG_UINT32 ui32NumAddrOffsets = PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES; - - IMG_INT32 retSize = OSGetMemMultiPlaneInfo(psMemBlock->hOSMemHandle, - ui32AddressOffsets, &ui32NumAddrOffsets); - - if((retSize > 0) && ui32NumAddrOffsets) - { - int i; - for(i = 0; i < PVRSRV_MAX_NUMBER_OF_MM_BUFFER_PLANES; i++) - { - if(i < ui32NumAddrOffsets) - psMemInfo->planeOffsets[i] = ui32AddressOffsets[i]; - else - psMemInfo->planeOffsets[i] = (IMG_INT32)-1; - } - } - } - - return PVRSRV_OK; - -} /*! ****************************************************************************** @@ -535,15 +598,6 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, psMemBlock = &(psMemInfo->sMemBlk); - /* ION and DYNAMIC re-mapping - * require the PAGEABLE FLAG set - */ - if (ui32Flags & (PVRSRV_MEM_ION | - PVRSRV_HAP_NO_GPU_VIRTUAL_ON_ALLOC)) - { - ui32Flags |= PVRSRV_HAP_GPU_PAGEABLE; - } - /* BM supplied Device Virtual Address with physical backing RAM */ psMemInfo->ui32Flags = ui32Flags | PVRSRV_MEM_RAM_BACKED_ALLOCATION; @@ -593,9 +647,6 @@ static PVRSRV_ERROR AllocDeviceMem(IMG_HANDLE hDevCookie, /* Clear the Backup buffer pointer as we do not have one at this point. We only allocate this as we are going up/down */ psMemInfo->pvSysBackupBuffer = IMG_NULL; - /* Update the Multimedia plane offsets */ - UpdateDeviceMemoryPlaneOffsets(psMemInfo); - /* * Setup the output. */ @@ -756,13 +807,41 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, psSyncData->ui32LastReadOpDumpVal = 0; psSyncData->ui64LastWrite = 0; +#if defined(SUPPORT_PER_SYNC_DEBUG) + psKernelSyncInfo->ui32OperationMask = 0; + memset(psKernelSyncInfo->aui32OpInfo, 0, sizeof(psKernelSyncInfo->aui32OpInfo)); + memset(psKernelSyncInfo->aui32ReadOpSample, 0, sizeof(psKernelSyncInfo->aui32ReadOpSample)); + memset(psKernelSyncInfo->aui32WriteOpSample, 0, sizeof(psKernelSyncInfo->aui32WriteOpSample)); + memset(psKernelSyncInfo->aui32ReadOp2Sample, 0, sizeof(psKernelSyncInfo->aui32ReadOp2Sample)); + psKernelSyncInfo->ui32HistoryIndex = 0; +#endif + + /* + Note: + PDumping here means that we PDump syncs that we might not + need to know about for the multi-process but this + unavoidable as there is no point where we can PDump + that guarantees it will be initialised before we us it + (e.g. kick time is too late as the client might have + issued a POL on it before that point) + */ #if defined(PDUMP) - PDUMPCOMMENT("Allocating kernel sync object"); + PDUMPCOMMENTWITHFLAGS( +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + PDUMP_FLAGS_PERSISTENT, +#else + PDUMP_FLAGS_CONTINUOUS, +#endif + "Allocating kernel sync object"); PDUMPMEM(psKernelSyncInfo->psSyncDataMemInfoKM->pvLinAddrKM, psKernelSyncInfo->psSyncDataMemInfoKM, 0, (IMG_UINT32)psKernelSyncInfo->psSyncDataMemInfoKM->uAllocSize, +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + PDUMP_FLAGS_PERSISTENT, +#else PDUMP_FLAGS_CONTINUOUS, +#endif MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); #endif @@ -776,6 +855,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfoKM(IMG_HANDLE hDevCookie, OSAtomicInc(psKernelSyncInfo->pvRefCount); + /* Add the SyncInfo to a global list */ + List_PVRSRV_KERNEL_SYNC_INFO_Insert(&g_psSyncInfoList, psKernelSyncInfo); + /* return result */ *ppsKernelSyncInfo = psKernelSyncInfo; @@ -805,8 +887,32 @@ IMG_VOID IMG_CALLCONV PVRSRVReleaseSyncInfoKM(PVRSRV_KERNEL_SYNC_INFO *psKernelS { if (OSAtomicDecAndTest(psKernelSyncInfo->pvRefCount)) { + /* Remove the SyncInfo to a global list */ + List_PVRSRV_KERNEL_SYNC_INFO_Remove(psKernelSyncInfo); + + #if defined(PDUMP) + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "Wait for write ops to flush to PDump value (%d)", + psKernelSyncInfo->psSyncData->ui32LastOpDumpVal); + PDUMPMEMPOL(psKernelSyncInfo->psSyncDataMemInfoKM, + offsetof(PVRSRV_SYNC_DATA, ui32WriteOpsComplete), + psKernelSyncInfo->psSyncData->ui32LastOpDumpVal, + 0xffffffff, + PDUMP_POLL_OPERATOR_EQUAL, + PDUMP_FLAGS_CONTINUOUS, + MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); + PDUMPCOMMENTWITHFLAGS(PDUMP_FLAGS_CONTINUOUS, "Wait for read ops to flush to PDump value (%d)", + psKernelSyncInfo->psSyncData->ui32LastReadOpDumpVal); + PDUMPMEMPOL(psKernelSyncInfo->psSyncDataMemInfoKM, + offsetof(PVRSRV_SYNC_DATA, ui32ReadOpsComplete), + psKernelSyncInfo->psSyncData->ui32LastReadOpDumpVal, + 0xffffffff, + PDUMP_POLL_OPERATOR_EQUAL, + PDUMP_FLAGS_CONTINUOUS, + MAKEUNIQUETAG(psKernelSyncInfo->psSyncDataMemInfoKM)); + #endif + FreeDeviceMem(psKernelSyncInfo->psSyncDataMemInfoKM); - + /* Catch anyone who is trying to access the freed structure */ psKernelSyncInfo->psSyncDataMemInfoKM = IMG_NULL; psKernelSyncInfo->psSyncData = IMG_NULL; @@ -883,22 +989,40 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PVRSRV_FREE_CALLBACK_ORIGIN eCallbackOrigin) { PVRSRV_ERROR eError = PVRSRV_OK; - +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; +#endif PVR_UNREFERENCED_PARAMETER(ui32Param); /* decrement the refcount */ PVRSRVKernelMemInfoDecRef(psMemInfo); +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_FREE; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif + /* check no other processes has this meminfo mapped */ 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 /* find the handle */ eError = PVRSRVFindHandle(KERNEL_HANDLE_BASE, @@ -930,9 +1054,22 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, freeExternal(psMemInfo); case PVRSRV_MEMTYPE_DEVICE: case PVRSRV_MEMTYPE_DEVICECLASS: - if (psMemInfo->psKernelSyncInfo) +#if defined(SUPPORT_ION) + if (psMemInfo->hIonSyncInfo) { - PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo); + /* + For syncs attached to Ion imported buffers we handle + things a little differently + */ + PVRSRVIonBufferSyncInfoDecRef(psMemInfo->hIonSyncInfo, psMemInfo); + } + else +#endif + { + if (psMemInfo->psKernelSyncInfo) + { + PVRSRVKernelSyncInfoDecRef(psMemInfo->psKernelSyncInfo, psMemInfo); + } } break; default: @@ -941,11 +1078,6 @@ PVRSRV_ERROR FreeMemCallBackCommon(PVRSRV_KERNEL_MEM_INFO *psMemInfo, } } -#if defined(CONFIG_GCBV) - if (psMemInfo->ui32Flags & PVRSRV_MAP_GC_MMU) - gc_bvunmap_meminfo(psMemInfo); -#endif - /* * FreeDeviceMem2 will do the right thing, freeing * the virtual memory info when the allocator calls @@ -1033,103 +1165,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMemKM(IMG_HANDLE hDevCookie, /*! ****************************************************************************** - @Function PVRSRVRemapToDevKM - - @Description - - Remaps buffer to GPU virtual address space - - @Input psMemInfo - - @Return PVRSRV_ERROR : 0 means the memory is still unmapped - ERROR, - * bigger than 0 (mapping reference count) - success mapping - * smaller than 0 - PVRSRV error -******************************************************************************/ -IMG_EXPORT -IMG_INT32 IMG_CALLCONV PVRSRVRemapToDevKM(IMG_HANDLE hDevCookie, - PVRSRV_KERNEL_MEM_INFO *psMemInfo, IMG_DEV_VIRTADDR *psDevVAddr) -{ - PVRSRV_MEMBLK *psMemBlock; - IMG_INT32 result; - - PVR_UNREFERENCED_PARAMETER(hDevCookie); - - if (!psMemInfo) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVRemapToDevKM: invalid parameters")); - return PVRSRV_ERROR_INVALID_PARAMS; - } - - psMemBlock = &(psMemInfo->sMemBlk); - - result = BM_RemapToDev(psMemBlock->hBuffer); - - if(result <= 0) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVRemapToDevKM: could not remap")); - } - - *psDevVAddr = psMemInfo->sDevVAddr = - psMemBlock->sDevVirtAddr = BM_HandleToDevVaddr(psMemBlock->hBuffer); - - UpdateDeviceMemoryPlaneOffsets(psMemInfo); - - return result; -} - - -/*! -****************************************************************************** - - @Function PVRSRVUnmapFromDevKM - - @Description - - Unmaps buffer from GPU virtual address space - - @Input psMemInfo - - @Return PVRSRV_ERROR : 0 means the memory is unmapped, - * bigger than 0 (mapping reference count) still mapped - * smaller than 0 - PVRSRV error -******************************************************************************/ -IMG_EXPORT -IMG_INT32 IMG_CALLCONV PVRSRVUnmapFromDevKM(IMG_HANDLE hDevCookie, - PVRSRV_KERNEL_MEM_INFO *psMemInfo) -{ - PVRSRV_MEMBLK *psMemBlock; - IMG_INT32 result; - - PVR_UNREFERENCED_PARAMETER(hDevCookie); - - if (!psMemInfo) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVUnmapFromDevKM: invalid parameters")); - return PVRSRV_ERROR_INVALID_PARAMS; - } - - psMemBlock = &(psMemInfo->sMemBlk); - - result = BM_UnmapFromDev(psMemBlock->hBuffer); - /* 0 means the memory is unmapped, - * bigger than 0 (mapping ref count) still mapped - * smaller than 0 PVRSRV error - */ - if(result < 0) - { - PVR_DPF((PVR_DBG_ERROR,"PVRSRVUnmapFromDevKM: could not unmap")); - } - - psMemInfo->sDevVAddr = - psMemBlock->sDevVirtAddr = BM_HandleToDevVaddr(psMemBlock->hBuffer); - - return result; -} - - -/*! -****************************************************************************** - @Function PVRSRVAllocDeviceMemKM @Description @@ -1166,6 +1201,13 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, PVRSRV_ERROR eError; BM_HEAP *psBMHeap; IMG_HANDLE hDevMemContext; +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + IMG_UINT32 i; + IMG_CHAR *pszName = "Heap not found"; + DEVICE_MEMORY_INFO *psDevMemoryInfo; + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; +#endif if (!hDevMemHeap || ((ui32Size == 0) && ((ui32Flags & PVRSRV_MEM_SPARSE) == 0)) || @@ -1233,11 +1275,6 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, return eError; } -#if defined(CONFIG_GCBV) - if (ui32Flags & PVRSRV_MAP_GC_MMU) - gc_bvmap_meminfo(psMemInfo); -#endif - if (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ) { psMemInfo->psKernelSyncInfo = IMG_NULL; @@ -1258,7 +1295,23 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, goto free_mainalloc; } } +#if defined (MEM_TRACK_INFO_DEBUG) + psBMHeap = (BM_HEAP*)hDevMemHeap; + hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; + psDevMemoryInfo = &((BM_CONTEXT*)hDevMemContext)->psDeviceNode->sDevMemoryInfo; + psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; + + for(i=0; i<PVRSRV_MAX_CLIENT_HEAPS; i++) + { + if(HEAP_IDX(psDeviceMemoryHeap[i].ui32HeapID) == psDevMemoryInfo->ui32MappingHeapID) + { + pszName = psDeviceMemoryHeap[i].pszName; + break; + } + } + OSStringCopy(psMemInfo->heapId, pszName); +#endif /* * Setup the output. */ @@ -1288,6 +1341,26 @@ PVRSRV_ERROR IMG_CALLCONV _PVRSRVAllocDeviceMemKM(IMG_HANDLE hDevCookie, psMemInfo->memType = PVRSRV_MEMTYPE_DEVICE; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_ALLOC; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif /* * And I think we're done for now.... */ @@ -1315,6 +1388,90 @@ static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam, return FreeMemCallBackCommon(psMemInfo, ui32Param, PVRSRV_FREE_CALLBACK_ORIGIN_ALLOCATOR); } +PVRSRV_ERROR PVRSRVIonBufferSyncAcquire(IMG_HANDLE hUnique, + IMG_HANDLE hDevCookie, + IMG_HANDLE hDevMemContext, + PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo) +{ + PVRSRV_ION_SYNC_INFO *psIonSyncInfo; + PVRSRV_ERROR eError; + IMG_BOOL bRet; + + /* Check the hash to see if we already have a sync for this buffer */ + psIonSyncInfo = (PVRSRV_ION_SYNC_INFO *) HASH_Retrieve(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique); + if (psIonSyncInfo == 0) + { + /* This buffer is new to us, create the syncinfo for it */ + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + (IMG_VOID **)&psIonSyncInfo, IMG_NULL, + "Ion Synchronization Info"); + if (eError != PVRSRV_OK) + { + return eError; + } + + eError = PVRSRVAllocSyncInfoKM(hDevCookie, + hDevMemContext, + &psIonSyncInfo->psSyncInfo); + if (eError != PVRSRV_OK) + { + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + psIonSyncInfo, + IMG_NULL); + + return eError; + } +#if defined(SUPPORT_MEMINFO_IDS) + psIonSyncInfo->ui64Stamp = ++g_ui64MemInfoID; +#else + psIonSyncInfo->ui64Stamp = 0; +#endif + bRet = HASH_Insert(g_psIonSyncHash, (IMG_UINTPTR_T) hUnique, (IMG_UINTPTR_T) psIonSyncInfo); + if (!bRet) + { + eError = PVRSRV_ERROR_OUT_OF_MEMORY; + + PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL); + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + psIonSyncInfo, + IMG_NULL); + + return eError; + } + + psIonSyncInfo->ui32RefCount = 0; + psIonSyncInfo->hUnique = hUnique; + } + + psIonSyncInfo->ui32RefCount++; + *ppsIonSyncInfo = psIonSyncInfo; + return PVRSRV_OK; +} + +IMG_VOID PVRSRVIonBufferSyncRelease(PVRSRV_ION_SYNC_INFO *psIonSyncInfo) +{ + psIonSyncInfo->ui32RefCount--; + + if (psIonSyncInfo->ui32RefCount == 0) + { + PVRSRV_ION_SYNC_INFO *psLookup; + /* + If we're holding the last reference to the syncinfo + then free it + */ + psLookup = (PVRSRV_ION_SYNC_INFO *) HASH_Remove(g_psIonSyncHash, (IMG_UINTPTR_T) psIonSyncInfo->hUnique); + PVR_ASSERT(psLookup == psIonSyncInfo); + PVRSRVKernelSyncInfoDecRef(psIonSyncInfo->psSyncInfo, IMG_NULL); + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_ION_SYNC_INFO), + psIonSyncInfo, + IMG_NULL); + } +} + /*! ****************************************************************************** @@ -1326,10 +1483,19 @@ static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam, @Input psPerProc : PerProcess data @Input hDevCookie : Device node cookie - @Input hDevMemContext : Device memory context cookie - @Input hIon : Handle to ION buffer + @Input hDevMemHeap : Heap ion handles are mapped into + @Input ui32NumBuffers : Number of ion handles to map. (If one handle is being + mapped, this should be 1, not 0.) + @Input phIon : Array of ui32NumBuffers ion handles (fds) @Input ui32Flags : Mapping flags - @Input ui32Size : Mapping size + @Input ui32ChunkCount : If ui32NumBuffers is 1, this is the number of + "chunks" specified to be mapped into device-virtual + address space. If ui32NumBuffers > 1, it is ignored. + @Input pauiOffset : Array of offsets in device-virtual address space to map + "chunks" of physical from the ion allocation. + @Input pauiSize : Array of sizes in bytes of device-virtual address space to + map "chunks" of physical from the ion allocation. + @Input puiIonBufferSize : Size in bytes of resulting device-virtual mapping. @Output ppsKernelMemInfo: Output kernel meminfo if successful @Return PVRSRV_ERROR : @@ -1338,35 +1504,56 @@ static PVRSRV_ERROR IonUnmapCallback(IMG_PVOID pvParam, IMG_EXPORT PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, IMG_HANDLE hDevCookie, - IMG_HANDLE hDevMemContext, - IMG_HANDLE hIon, + IMG_HANDLE hDevMemHeap, + IMG_UINT32 ui32NumFDs, + IMG_INT32 *pi32BufferFDs, IMG_UINT32 ui32Flags, - IMG_UINT32 ui32Size, - PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo) + IMG_UINT32 ui32ChunkCount, + IMG_SIZE_T *pauiOffset, + IMG_SIZE_T *pauiSize, + IMG_SIZE_T *puiIonBufferSize, + PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo, + IMG_UINT64 *pui64Stamp) { PVRSRV_ENV_PER_PROCESS_DATA *psPerProcEnv = PVRSRVProcessPrivateData(psPerProc); PVRSRV_DEVICE_NODE *psDeviceNode; PVRSRV_KERNEL_MEM_INFO *psNewKernelMemInfo; - DEVICE_MEMORY_INFO *psDevMemoryInfo; - DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; IMG_SYS_PHYADDR *pasSysPhysAddr; + IMG_SYS_PHYADDR *pasAdjustedSysPhysAddr; PVRSRV_MEMBLK *psMemBlock; PVRSRV_ERROR eError; - IMG_HANDLE hDevMemHeap = IMG_NULL; IMG_HANDLE hPriv; + IMG_HANDLE hUnique; BM_HANDLE hBuffer; - IMG_UINT32 ui32HeapCount; + IMG_SIZE_T uiMapSize = 0; + IMG_SIZE_T uiAdjustOffset = 0; IMG_UINT32 ui32PageCount; IMG_UINT32 i; IMG_BOOL bAllocSync = (ui32Flags & PVRSRV_MEM_NO_SYNCOBJ)?IMG_FALSE:IMG_TRUE; - if ((hDevCookie == IMG_NULL) || (ui32Size == 0) - || (hDevMemContext == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL)) + if ((hDevCookie == IMG_NULL) || (ui32ChunkCount == 0) + || (hDevMemHeap == IMG_NULL) || (ppsKernelMemInfo == IMG_NULL)) { PVR_DPF((PVR_DBG_ERROR, "%s: Invalid params", __FUNCTION__)); return PVRSRV_ERROR_INVALID_PARAMS; } + for (i=0;i<ui32ChunkCount;i++) + { + if ((pauiOffset[i] & HOST_PAGEMASK) != 0) + { + PVR_DPF((PVR_DBG_ERROR,"%s: Chunk offset is not page aligned", __FUNCTION__)); + return PVRSRV_ERROR_INVALID_PARAMS; + } + + if ((pauiSize[i] & HOST_PAGEMASK) != 0) + { + PVR_DPF((PVR_DBG_ERROR,"%s: Chunk size is not page aligned", __FUNCTION__)); + return PVRSRV_ERROR_INVALID_PARAMS; + } + uiMapSize += pauiSize[i]; + } + psDeviceNode = (PVRSRV_DEVICE_NODE *)hDevCookie; if(OSAllocMem(PVRSRV_PAGEABLE_SELECT, @@ -1379,59 +1566,63 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, } OSMemSet(psNewKernelMemInfo, 0, sizeof(PVRSRV_KERNEL_MEM_INFO)); - /* Choose the heap to map to */ - ui32HeapCount = psDeviceNode->sDevMemoryInfo.ui32HeapCount; - psDevMemoryInfo = &psDeviceNode->sDevMemoryInfo; - psDeviceMemoryHeap = psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeap; - for(i=0; i<PVRSRV_MAX_CLIENT_HEAPS; i++) + /* Import the ION buffer into our ion_client and DMA map it */ + eError = IonImportBufferAndAcquirePhysAddr(psPerProcEnv->psIONClient, + ui32NumFDs, + pi32BufferFDs, + &ui32PageCount, + &pasSysPhysAddr, + &psNewKernelMemInfo->pvLinAddrKM, + &hPriv, + &hUnique); + if (eError != PVRSRV_OK) { - if(HEAP_IDX(psDeviceMemoryHeap[i].ui32HeapID) == psDevMemoryInfo->ui32IonHeapID) - { - if(psDeviceMemoryHeap[i].DevMemHeapType == DEVICE_MEMORY_HEAP_PERCONTEXT) - { - if (psDeviceMemoryHeap[i].ui32HeapSize > 0) - { - hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); - } - else - { - hDevMemHeap = IMG_NULL; - } - } - else - { - hDevMemHeap = psDevMemoryInfo->psDeviceMemoryHeap[i].hDevMemHeap; - } - break; - } + PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ion buffer/buffer phys addr", __FUNCTION__)); + goto exitFailedImport; } - - if (hDevMemHeap == IMG_NULL) + + /* + Make sure the number of pages detected by the ion import are at least + the size of the total chunked region + */ + if(ui32PageCount * PAGE_SIZE < uiMapSize) { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ION heap", __FUNCTION__)); - eError = PVRSRV_ERROR_FAILED_TO_RETRIEVE_HEAPINFO; - goto exitFailedHeap; + PVR_DPF((PVR_DBG_ERROR, "%s: ion allocator returned fewer page addresses " + "than specified chunk size(s)", __FUNCTION__)); + eError = PVRSRV_ERROR_INVALID_PARAMS; + goto exitFailedAdjustedAlloc; } - /* Import the ION buffer into our ion_client and DMA map it */ - eError = IonImportBufferAndAquirePhysAddr(psPerProcEnv->psIONClient, - hIon, - &ui32PageCount, - &pasSysPhysAddr, - &psNewKernelMemInfo->pvLinAddrKM, - &hPriv); - if (eError != PVRSRV_OK) + /* + An Ion buffer might have a number of "chunks" in it which need to be + mapped virtually continuous so we need to create a new array of + addresses based on this chunk data for the actual wrap + */ + if(OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE()), + (IMG_VOID **)&pasAdjustedSysPhysAddr, IMG_NULL, + "Ion adjusted system address array") != PVRSRV_OK) { - PVR_DPF((PVR_DBG_ERROR, "%s: Failed to get ion buffer/buffer phys addr", __FUNCTION__)); - goto exitFailedHeap; + PVR_DPF((PVR_DBG_ERROR,"%s: Failed to alloc memory for adjusted array", __FUNCTION__)); + goto exitFailedAdjustedAlloc; + } + OSMemSet(pasAdjustedSysPhysAddr, 0, sizeof(IMG_SYS_PHYADDR) * (uiMapSize/HOST_PAGESIZE())); + + for (i=0;i<ui32ChunkCount;i++) + { + OSMemCopy(&pasAdjustedSysPhysAddr[uiAdjustOffset], + &pasSysPhysAddr[pauiOffset[i]/HOST_PAGESIZE()], + (pauiSize[i]/HOST_PAGESIZE()) * sizeof(IMG_SYS_PHYADDR)); + + uiAdjustOffset += pauiSize[i]/HOST_PAGESIZE(); } /* Wrap the returned addresses into our memory context */ if (!BM_Wrap(hDevMemHeap, - ui32Size, + uiMapSize, 0, IMG_FALSE, - pasSysPhysAddr, + pasAdjustedSysPhysAddr, IMG_NULL, &ui32Flags, /* This function clobbers our bits in ui32Flags */ &hBuffer)) @@ -1447,11 +1638,11 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, psMemBlock->hOSMemHandle = BM_HandleToOSMemHandle(hBuffer); psMemBlock->hBuffer = (IMG_HANDLE) hBuffer; psMemBlock->hOSWrapMem = hPriv; /* Saves creating a new element as we know hOSWrapMem will not be used */ - psMemBlock->psIntSysPAddr = pasSysPhysAddr; + psMemBlock->psIntSysPAddr = pasAdjustedSysPhysAddr; psNewKernelMemInfo->ui32Flags = ui32Flags; psNewKernelMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psNewKernelMemInfo->uAllocSize = ui32Size; + psNewKernelMemInfo->uAllocSize = uiMapSize; psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION; PVRSRVKernelMemInfoIncRef(psNewKernelMemInfo); @@ -1464,13 +1655,25 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, } else { - eError = PVRSRVAllocSyncInfoKM(hDevCookie, - hDevMemContext, - &psNewKernelMemInfo->psKernelSyncInfo); + PVRSRV_ION_SYNC_INFO *psIonSyncInfo; + BM_HEAP *psBMHeap; + IMG_HANDLE hDevMemContext; + + psBMHeap = (BM_HEAP*)hDevMemHeap; + hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; + + eError = PVRSRVIonBufferSyncInfoIncRef(hUnique, + hDevCookie, + hDevMemContext, + &psIonSyncInfo, + psNewKernelMemInfo); if(eError != PVRSRV_OK) { goto exitFailedSync; } + psNewKernelMemInfo->hIonSyncInfo = psIonSyncInfo; + psNewKernelMemInfo->psKernelSyncInfo = IonBufferSyncGetKernelSyncInfo(psIonSyncInfo); + *pui64Stamp = IonBufferSyncGetStamp(psIonSyncInfo); } /* register with the resman */ @@ -1487,23 +1690,29 @@ PVRSRV_ERROR PVRSRVMapIonHandleKM(PVRSRV_PER_PROCESS_DATA *psPerProc, psNewKernelMemInfo->memType = PVRSRV_MEMTYPE_ION; + /* + As the user doesn't tell us the size, just the "chunk" information + return actual size of the Ion buffer so we can mmap it. + */ + *puiIonBufferSize = ui32PageCount * HOST_PAGESIZE(); *ppsKernelMemInfo = psNewKernelMemInfo; return PVRSRV_OK; exitFailedResman: if (psNewKernelMemInfo->psKernelSyncInfo) { - PVRSRVKernelSyncInfoDecRef(psNewKernelMemInfo->psKernelSyncInfo, psNewKernelMemInfo); + PVRSRVIonBufferSyncInfoDecRef(psNewKernelMemInfo->hIonSyncInfo, psNewKernelMemInfo); } exitFailedSync: BM_Free(hBuffer, ui32Flags); exitFailedWrap: - IonUnimportBufferAndReleasePhysAddr(hPriv); OSFreeMem(PVRSRV_PAGEABLE_SELECT, - sizeof(IMG_SYS_PHYADDR) * ui32PageCount, - pasSysPhysAddr, + sizeof(IMG_SYS_PHYADDR) * uiAdjustOffset, + pasAdjustedSysPhysAddr, IMG_NULL); -exitFailedHeap: +exitFailedAdjustedAlloc: + IonUnimportBufferAndReleasePhysAddr(hPriv); +exitFailedImport: OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_MEM_INFO), psNewKernelMemInfo, @@ -1707,10 +1916,23 @@ 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; - IMG_UINT32 i; + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap;IMG_UINT32 i; +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + IMG_CHAR *pszName="Heap not found"; +#endif IMG_SIZE_T uPageCount = 0; + PVR_DPF ((PVR_DBG_MESSAGE, + "PVRSRVWrapExtMemoryKM (uSize=0x%" SIZE_T_FMT_LEN "x, uPageOffset=0x%" + SIZE_T_FMT_LEN "x, bPhysContig=%d, extSysPAddr=" SYSPADDR_FMT + ", pvLinAddr=%p, ui32Flags=%u)", + uByteSize, + uPageOffset, + bPhysContig, + psExtSysPAddr?psExtSysPAddr->uiAddr:0x0, + pvLinAddr, + ui32Flags)); psDeviceNode = (PVRSRV_DEVICE_NODE*)hDevCookie; PVR_ASSERT(psDeviceNode != IMG_NULL); @@ -1759,6 +1981,21 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, */ bPhysContig = IMG_FALSE; } +#if !defined(__QNXNTO__) + else + { + if (psExtSysPAddr) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVWrapExtMemoryKM: invalid parameter, physical address passing is not supported")); + } + else + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVWrapExtMemoryKM: invalid parameter, no address specificed")); + } + return PVRSRV_ERROR_INVALID_PARAMS; + } +#endif + /* Choose the heap to map to */ psDevMemoryInfo = &((BM_CONTEXT*)hDevMemContext)->psDeviceNode->sDevMemoryInfo; @@ -1772,6 +2009,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, if (psDeviceMemoryHeap[i].ui32HeapSize > 0) { hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } else { @@ -1781,6 +2021,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, else { hDevMemHeap = psDevMemoryInfo->psDeviceMemoryHeap[i].hDevMemHeap; + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } break; } @@ -1804,7 +2047,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, } OSMemSet(psMemInfo, 0, sizeof(*psMemInfo)); - psMemInfo->ui32Flags = ui32Flags; + /* + Force the memory to be read/write. This used to be done in the BM, but + ion imports don't want this behaviour + */ + psMemInfo->ui32Flags = ui32Flags | PVRSRV_MEM_READ | PVRSRV_MEM_WRITE; psMemBlock = &(psMemInfo->sMemBlk); @@ -1867,10 +2114,32 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemoryKM(IMG_HANDLE hDevCookie, psMemInfo, 0, &UnwrapExtMemoryCallBack); - +#if defined (MEM_TRACK_INFO_DEBUG) + OSStringCopy(psMemInfo->heapId, pszName); +#endif /* return the meminfo */ *ppsMemInfo = psMemInfo; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_WRAPPED; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif + return PVRSRV_OK; /* error handling: */ @@ -2023,6 +2292,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer PVRSRV_DEVICE_NODE *psDeviceNode; IMG_VOID *pvPageAlignedCPUVAddr; RESMAN_MAP_DEVICE_MEM_DATA *psMapData = IMG_NULL; +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + DEVICE_MEMORY_INFO *psDevMemoryInfo; + DEVICE_MEMORY_HEAP_INFO *psDeviceMemoryHeap; + BM_HEAP *psBMHeap; + IMG_HANDLE hDevMemContext; +#endif /* check params */ if(!psSrcMemInfo || !hDstDevMemHeap || !ppsDstMemInfo) @@ -2090,7 +2366,12 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer } OSMemSet(psMemInfo, 0, sizeof(*psMemInfo)); - psMemInfo->ui32Flags = psSrcMemInfo->ui32Flags; + + /* + Force the memory to be read/write. This used to be done in the BM, but + ion imports don't want this behaviour + */ + psMemInfo->ui32Flags = psSrcMemInfo->ui32Flags | PVRSRV_MEM_READ | PVRSRV_MEM_WRITE; psMemBlock = &(psMemInfo->sMemBlk); @@ -2160,9 +2441,49 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemoryKM(PVRSRV_PER_PROCESS_DATA *psPer psMapData, 0, &UnmapDeviceMemoryCallBack); +#if defined (MEM_TRACK_INFO_DEBUG) + psBMHeap = (BM_HEAP*)hDstDevMemHeap; + hDevMemContext = (IMG_HANDLE)psBMHeap->pBMContext; + psDevMemoryInfo = &((BM_CONTEXT*)hDevMemContext)->psDeviceNode->sDevMemoryInfo; + psDeviceMemoryHeap = psDevMemoryInfo->psDeviceMemoryHeap; + + for(i=0; i<PVRSRV_MAX_CLIENT_HEAPS; i++) + { + if(HEAP_IDX(psDeviceMemoryHeap[i].ui32HeapID) == psDevMemoryInfo->ui32MappingHeapID) + break; + } + + if(i == PVRSRV_MAX_CLIENT_HEAPS) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVMapDeviceMemoryKM: unable to find mapping heap")); + eError = PVRSRV_ERROR_UNABLE_TO_FIND_MAPPING_HEAP; + OSStringCopy(psMemInfo->heapId, "Heap not found"); + } + else + OSStringCopy(psMemInfo->heapId, psDeviceMemoryHeap[i].pszName); +#endif *ppsDstMemInfo = psMemInfo; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_MAPPED; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif return PVRSRV_OK; /* error handling: */ @@ -2193,6 +2514,7 @@ ErrorExit: return eError; } +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) /*! ****************************************************************************** @@ -2298,15 +2620,18 @@ 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 uByteSize; - IMG_SIZE_T ui32Offset; - IMG_SIZE_T ui32PageSize = HOST_PAGESIZE(); + IMG_UINT32 ui32ByteSize; + IMG_SIZE_T uOffset; + IMG_SIZE_T uPageSize = HOST_PAGESIZE(); BM_HANDLE hBuffer; PVRSRV_MEMBLK *psMemBlock; IMG_BOOL bBMError; IMG_UINT32 i; PVRSRV_DC_MAPINFO *psDCMapInfo = IMG_NULL; - +#if defined (MEM_TRACK_INFO_DEBUG) + PVRSRV_MEM_TRACK_INFO *psMemTrackInfo; + IMG_CHAR *pszName = "Heap not found"; +#endif if(!hDeviceClassBuffer || !ppsMemInfo || !phOSMapInfo || !hDevMemContext) { PVR_DPF((PVR_DBG_ERROR,"PVRSRVMapDeviceClassMemoryKM: invalid parameters")); @@ -2349,7 +2674,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * eError = psDeviceClassBuffer->pfnGetBufferAddr(psDeviceClassBuffer->hExtDevice, psDeviceClassBuffer->hExtBuffer, &psSysPAddr, - &uByteSize, + &ui32ByteSize, &pvCPUVAddr, phOSMapInfo, &bPhysContig, @@ -2374,6 +2699,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * if (psDeviceMemoryHeap[i].ui32HeapSize > 0) { hDevMemHeap = BM_CreateHeap(hDevMemContext, &psDeviceMemoryHeap[i]); + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } else { @@ -2383,6 +2711,9 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * else { hDevMemHeap = psDevMemoryInfo->psDeviceMemoryHeap[i].hDevMemHeap; + #if defined (MEM_TRACK_INFO_DEBUG) + pszName = psDeviceMemoryHeap[i].pszName; + #endif } break; } @@ -2396,8 +2727,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * } /* Only need lower 12 bits of the cpu addr - don't care what size a void* is */ - ui32Offset = ((IMG_UINTPTR_T)pvCPUVAddr) & (ui32PageSize - 1); - pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)pvCPUVAddr - ui32Offset); + uOffset = ((IMG_UINTPTR_T)pvCPUVAddr) & (uPageSize - 1); + pvPageAlignedCPUVAddr = (IMG_VOID *)((IMG_UINTPTR_T)pvCPUVAddr - uOffset); eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_KERNEL_MEM_INFO), @@ -2411,11 +2742,17 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * OSMemSet(psMemInfo, 0, sizeof(*psMemInfo)); + /* + Force the memory to be read/write. This used to be done in the BM, but + ion imports don't want this behaviour + */ + psMemInfo->ui32Flags |= PVRSRV_MEM_READ | PVRSRV_MEM_WRITE; + psMemBlock = &(psMemInfo->sMemBlk); bBMError = BM_Wrap(hDevMemHeap, - uByteSize, - ui32Offset, + ui32ByteSize, + uOffset, bPhysContig, psSysPAddr, pvPageAlignedCPUVAddr, @@ -2444,7 +2781,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * /* Fill in the public fields of the MEM_INFO structure */ psMemInfo->sDevVAddr = psMemBlock->sDevVirtAddr; - psMemInfo->uAllocSize = uByteSize; + psMemInfo->uAllocSize = ui32ByteSize; psMemInfo->psKernelSyncInfo = psDeviceClassBuffer->psKernelSyncInfo; PVR_ASSERT(psMemInfo->psKernelSyncInfo != IMG_NULL); @@ -2491,9 +2828,31 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * PVRSRVKernelMemInfoIncRef(psMemInfo); psMemInfo->memType = PVRSRV_MEMTYPE_DEVICECLASS; +#if defined (MEM_TRACK_INFO_DEBUG) + OSStringCopy(psMemInfo->heapId, pszName); +#endif /* return the meminfo */ *ppsMemInfo = psMemInfo; +#if defined (MEM_TRACK_INFO_DEBUG) + eError = OSAllocMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + (IMG_VOID **)&psMemTrackInfo, IMG_NULL, + "Mem tracking info"); + if (eError != PVRSRV_OK) + return eError; + psMemTrackInfo->sDevVAddr = psMemInfo->sDevVAddr; + psMemTrackInfo->uSize = psMemInfo->uAllocSize; + psMemTrackInfo->ui32Pid = OSGetCurrentProcessIDKM(); + psMemTrackInfo->ui32RefCount = psMemInfo->ui32RefCount; + psMemTrackInfo->eOp = PVRSRV_MEMTYPE_DEVICECLASS; + psMemTrackInfo->ui32TimeStampUSecs = OSGetCurrentTimeInUSecsKM(); + + OSGetCurrentProcessNameKM(psMemTrackInfo->asTaskName, 128); + + OSStringCopy(psMemTrackInfo->heapId, psMemInfo->heapId); + PVRSRVAddMemTrackInfo(psMemTrackInfo); +#endif #if defined(SUPPORT_PDUMP_MULTI_PROCESS) /* If the 3PDD supplies a kernel virtual address, we can PDUMP it */ @@ -2510,7 +2869,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemoryKM(PVRSRV_PER_PROCESS_DATA * * behaviour. */ PDUMPCOMMENT("Dump display surface"); - PDUMPMEM(IMG_NULL, psMemInfo, ui32Offset, psMemInfo->uAllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); + PDUMPMEM(IMG_NULL, psMemInfo, uOffset, psMemInfo->uAllocSize, PDUMP_FLAGS_CONTINUOUS, ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping); } #endif return PVRSRV_OK; @@ -2548,6 +2907,7 @@ ErrorExitPhase1: return eError; } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVChangeDeviceMemoryAttributesKM(IMG_HANDLE hKernelMemInfo, IMG_UINT32 ui32Attribs) @@ -2573,8 +2933,189 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVChangeDeviceMemoryAttributesKM(IMG_HANDLE hKerne return PVRSRV_OK; } +PVRSRV_ERROR IMG_CALLCONV PVRSRVInitDeviceMem(IMG_VOID) +{ + PVRSRV_ERROR eError = PVRSRV_OK; + +#if defined(SUPPORT_ION) + /* + For Ion buffers we need to store which ones we know about so + we don't give the same buffer a different sync + */ + g_psIonSyncHash = HASH_Create(ION_SYNC_HASH_SIZE); + if (g_psIonSyncHash == IMG_NULL) + { + eError = PVRSRV_ERROR_OUT_OF_MEMORY; + } +#endif + + return eError; +} + +IMG_VOID IMG_CALLCONV PVRSRVDeInitDeviceMem(IMG_VOID) +{ +#if defined(SUPPORT_ION) + HASH_Delete(g_psIonSyncHash); +#endif +} + +#if defined(MEM_TRACK_INFO_DEBUG) +/*! +****************************************************************************** + + @Function PVRSRVFreeMemOps + + @Description + Frees the list of tracked mem ops represented by g_psMemTrackInfoHead + + @Input + @Output + + @Return + +******************************************************************************/ +IMG_VOID IMG_CALLCONV PVRSRVFreeMemOps(IMG_VOID) +{ + PVRSRV_MEM_TRACK_INFO *psFreePtr; + while(g_psMemTrackInfoHead) + { + psFreePtr = g_psMemTrackInfoHead; + g_psMemTrackInfoHead = g_psMemTrackInfoHead->next; + OSFreeMem(PVRSRV_PAGEABLE_SELECT, + sizeof(PVRSRV_MEM_TRACK_INFO), + psFreePtr, IMG_NULL); + } +} +#endif + +static PVRSRV_ERROR PVRSRVDumpSync(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +{ + PVR_LOG(("\tSyncInfo %d:", psKernelSyncInfo->ui32UID)); + PVR_LOG(("\t\tWrite ops (0x%08x): P/C = %d/%d (0x%08x/0x%08x)", + psKernelSyncInfo->sWriteOpsCompleteDevVAddr.uiAddr, + psKernelSyncInfo->psSyncData->ui32WriteOpsPending, + psKernelSyncInfo->psSyncData->ui32WriteOpsComplete, + psKernelSyncInfo->psSyncData->ui32WriteOpsPending, + psKernelSyncInfo->psSyncData->ui32WriteOpsComplete)); + PVR_LOG(("\t\tRead ops (0x%08x): P/C = %d/%d (0x%08x/0x%08x)", + psKernelSyncInfo->sReadOpsCompleteDevVAddr.uiAddr, + psKernelSyncInfo->psSyncData->ui32ReadOpsPending, + psKernelSyncInfo->psSyncData->ui32ReadOpsComplete, + psKernelSyncInfo->psSyncData->ui32ReadOpsPending, + psKernelSyncInfo->psSyncData->ui32ReadOpsComplete)); + PVR_LOG(("\t\tRead ops 2 (0x%08x): P/C = %d/%d (0x%08x/0x%08x)", + psKernelSyncInfo->sReadOps2CompleteDevVAddr.uiAddr, + psKernelSyncInfo->psSyncData->ui32ReadOps2Pending, + psKernelSyncInfo->psSyncData->ui32ReadOps2Complete, + psKernelSyncInfo->psSyncData->ui32ReadOps2Pending, + psKernelSyncInfo->psSyncData->ui32ReadOps2Complete)); + +#if defined(SUPPORT_PER_SYNC_DEBUG) + { + IMG_UINT32 i; + PVR_LOG(("\t\t --- Per sync debug ---")); + + PVR_LOG(("\t\tOperationMask = 0x%08x", psKernelSyncInfo->ui32OperationMask)); + + + for (i=0;i<PER_SYNC_HISTORY;i++) + { + IMG_UINT32 ui32Index = (i + psKernelSyncInfo->ui32HistoryIndex) % PER_SYNC_HISTORY; + IMG_UINT32 ui32OpInfo = psKernelSyncInfo->aui32OpInfo[ui32Index]; + + if (ui32OpInfo & SYNC_OP_HAS_DATA) + { + IMG_UINT32 ui32OpClass = (ui32OpInfo & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT; + IMG_UINT32 ui32OpType = (ui32OpInfo & SYNC_OP_TYPE_MASK) >> SYNC_OP_TYPE_SHIFT; + IMG_CHAR *pzClass; + IMG_CHAR *pzType; + + PVR_LOG(("\t\tOperation last - %d\n", PER_SYNC_HISTORY - i)); + + switch(ui32OpClass) + { + case SYNC_OP_CLASS_MODOBJ: + pzClass = "MODOBJ"; + break; + case SYNC_OP_CLASS_QUEUE: + pzClass = "QUEUE"; + break; + case SYNC_OP_CLASS_KICKTA: + pzClass = "KICKTA"; + break; + case SYNC_OP_CLASS_TQ_3D: + pzClass = "TQ_3D"; + break; + case SYNC_OP_CLASS_TQ_2D: + pzClass = "TQ_2D"; + break; + default: + pzClass = "Unknown"; + } + switch(ui32OpType) + { + case SYNC_OP_TYPE_READOP: + pzType = "READOP"; + break; + case SYNC_OP_TYPE_WRITEOP: + pzType = "WRITEOP"; + break; + case SYNC_OP_TYPE_READOP2: + pzType = "READOP2"; + break; + default: + pzType = "Unknown"; + } + PVR_LOG(("\t\t\tui32OpType = 0x%08x", ui32OpInfo)); + PVR_LOG(("\t\t\t\t%s, %s, %s, %s", + pzClass, + pzType, + (ui32OpInfo & SYNC_OP_TAKE) ?"TAKE":"No TAKE", + (ui32OpInfo & SYNC_OP_ROLLBACK) ?"ROLLBACK":"No ROLLBACK")); + + PVR_LOG(("\t\t\ti32ReadOpSample = %d (0x%08x)", + psKernelSyncInfo->aui32ReadOpSample[ui32Index], + psKernelSyncInfo->aui32ReadOpSample[ui32Index])); + PVR_LOG(("\t\t\taui32WriteOpSample = %d (0x%08x)", + psKernelSyncInfo->aui32WriteOpSample[ui32Index], + psKernelSyncInfo->aui32WriteOpSample[ui32Index])); + PVR_LOG(("\t\t\taui32ReadOp2Sample = %d (0x%08x)", + psKernelSyncInfo->aui32ReadOp2Sample[ui32Index], + psKernelSyncInfo->aui32ReadOp2Sample[ui32Index])); + } + } + } +#endif + return PVRSRV_OK; +} + + +static PVRSRV_ERROR PVRSRVDumpActiveSync(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo) +{ + if ((psKernelSyncInfo->psSyncData->ui32WriteOpsComplete != psKernelSyncInfo->psSyncData->ui32WriteOpsPending) || + (psKernelSyncInfo->psSyncData->ui32ReadOpsComplete != psKernelSyncInfo->psSyncData->ui32ReadOpsPending) || + (psKernelSyncInfo->psSyncData->ui32ReadOps2Complete != psKernelSyncInfo->psSyncData->ui32ReadOps2Pending)) + { + PVRSRVDumpSync(psKernelSyncInfo); + } + return PVRSRV_OK; +} + +IMG_EXPORT +IMG_VOID IMG_CALLCONV PVRSRVDumpSyncs(IMG_BOOL bActiveOnly) +{ + if (bActiveOnly) + { + PVR_LOG(("Active syncs")); + List_PVRSRV_KERNEL_SYNC_INFO_PVRSRV_ERROR_Any(g_psSyncInfoList, PVRSRVDumpActiveSync); + } + else + { + PVR_LOG(("All syncs")); + List_PVRSRV_KERNEL_SYNC_INFO_PVRSRV_ERROR_Any(g_psSyncInfoList, PVRSRVDumpSync); + } +} /****************************************************************************** End of file (devicemem.c) ******************************************************************************/ - diff --git a/drivers/gpu/pvr/services4/srvkm/common/handle.c b/drivers/gpu/pvr/services4/srvkm/common/handle.c index 1e260470e7e..b9facfdf181 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/handle.c +++ b/drivers/gpu/pvr/services4/srvkm/common/handle.c @@ -40,7 +40,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) +#if defined(PVR_SECURE_HANDLES) /* See handle.h for a description of the handle API. */ /* @@ -78,14 +78,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define INDEX_IS_VALID(psBase, i) ((i) < (psBase)->ui32TotalHandCount) /* Valid handles are never NULL, but handle array indices are based from 0 */ -#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) @@ -150,11 +145,7 @@ struct sHandleList { IMG_UINT32 ui32Prev; IMG_UINT32 ui32Next; -#if defined (SUPPORT_SID_INTERFACE) - IMG_SID hParent; -#else IMG_HANDLE hParent; -#endif }; enum ePVRSRVInternalHandleFlag @@ -324,11 +315,7 @@ 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; @@ -484,11 +471,7 @@ 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; } @@ -721,11 +704,7 @@ 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; @@ -734,9 +713,6 @@ 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; } @@ -744,9 +720,6 @@ 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; } @@ -757,9 +730,6 @@ 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; } @@ -787,11 +757,7 @@ 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; @@ -814,11 +780,7 @@ 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); @@ -1125,14 +1087,9 @@ 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); -#endif PVR_ASSERT(hHandle != IMG_NULL); PVR_ASSERT(hHandle == INDEX_TO_HANDLE(ui32Index)); @@ -1339,11 +1296,7 @@ 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; @@ -1351,11 +1304,7 @@ IMG_HANDLE FindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_VOID *pvData, PVRSRV_HANDL 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 } /*! @@ -1457,19 +1406,11 @@ static PVRSRV_ERROR EnsureFreeHandles(PVRSRV_HANDLE_BASE *psBase, IMG_UINT32 ui3 @Return Error code or 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; @@ -1662,24 +1603,12 @@ static PVRSRV_ERROR AllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle @Return Error code or 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)) { @@ -1697,11 +1626,7 @@ PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, { /* See if there is already a handle for this data pointer */ hHandle = FindHandle(psBase, pvData, eType, IMG_NULL); -#if defined (SUPPORT_SID_INTERFACE) - if (hHandle != 0) -#else if (hHandle != IMG_NULL) -#endif { struct sHandle *psHandle; @@ -1724,9 +1649,6 @@ PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, goto exit_ok; } -#if defined (SUPPORT_SID_INTERFACE) - PVR_DBG_BREAK -#endif return PVRSRV_ERROR_HANDLE_NOT_SHAREABLE; } } @@ -1759,26 +1681,15 @@ exit_ok: @Return Error code or PVRSRV_OK ******************************************************************************/ -#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)) { @@ -1806,11 +1717,7 @@ PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHand { /* See if there is already a handle for this data pointer */ 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; @@ -1835,9 +1742,6 @@ 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; } } @@ -1886,26 +1790,14 @@ exit_ok: @Return Error code or 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); /* See if there is a handle for this data pointer */ -#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; @@ -1933,11 +1825,7 @@ PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, @Return Error code or 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; @@ -1946,9 +1834,7 @@ 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 + OSDumpStack(); return eError; } @@ -1974,27 +1860,18 @@ PVRSRV_ERROR PVRSRVLookupHandleAnyType(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *pp @Return Error code or 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); -#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 + OSDumpStack(); return eError; } @@ -2020,25 +1897,19 @@ PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvData, @Return Error code or 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); -#if defined (SUPPORT_SID_INTERFACE) - PVR_ASSERT(hHandle != 0); -#endif eError = GetHandleStructure(psBase, &psCHand, hHandle, eType); if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVLookupSubHandle: Error looking up subhandle (%d)", eError)); + OSDumpStack(); return eError; } @@ -2076,11 +1947,7 @@ PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *ppvDat not regarded as an error. ******************************************************************************/ -#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; @@ -2091,6 +1958,7 @@ PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phPare if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVGetParentHandle: Error looking up subhandle (%d)", eError)); + OSDumpStack(); return eError; } @@ -2116,11 +1984,7 @@ PVRSRV_ERROR PVRSRVGetParentHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID *phPare @Return Error code or 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; @@ -2131,9 +1995,7 @@ PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID 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 + OSDumpStack(); return eError; } @@ -2157,11 +2019,7 @@ PVRSRV_ERROR PVRSRVLookupAndReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_PVOID @Return Error code or PVRSRV_OK ******************************************************************************/ -#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; @@ -2172,6 +2030,7 @@ PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, if (eError != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PVRSRVReleaseHandle: Error looking up handle (%d)", eError)); + OSDumpStack(); return eError; } @@ -2683,7 +2542,7 @@ PVRSRV_ERROR PVRSRVHandleDeInit(IMG_VOID) } #else /* disable warning about empty module */ -#endif /* #if defined(PVR_SECURE_HANDLES) || defined (SUPPORT_SID_INTERFACE) */ +#endif /* #if defined(PVR_SECURE_HANDLES) */ /****************************************************************************** End of file (handle.c) ******************************************************************************/ diff --git a/drivers/gpu/pvr/services4/srvkm/common/hash.c b/drivers/gpu/pvr/services4/srvkm/common/hash.c index 1569425109f..72432fd562c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/hash.c +++ b/drivers/gpu/pvr/services4/srvkm/common/hash.c @@ -425,8 +425,8 @@ HASH_Insert_Extended (HASH_TABLE *pHash, IMG_VOID *pKey, IMG_UINTPTR_T v) BUCKET *pBucket; PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Insert_Extended: Hash=0x%08x, pKey=0x%08x, v=0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey, v)); + "HASH_Insert_Extended: Hash=0x%p, pKey=0x%p, v=0x" UINTPTR_FMT, + pHash, pKey, v)); PVR_ASSERT (pHash != IMG_NULL); @@ -488,8 +488,8 @@ IMG_BOOL HASH_Insert (HASH_TABLE *pHash, IMG_UINTPTR_T k, IMG_UINTPTR_T v) { PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Insert: Hash=0x%x, k=0x%x, v=0x%x", - (IMG_UINTPTR_T)pHash, k, v)); + "HASH_Insert: Hash=0x%p, k=0x" UINTPTR_FMT ", v=0x" UINTPTR_FMT, + pHash, k, v)); return HASH_Insert_Extended(pHash, &k, v); } @@ -513,8 +513,8 @@ HASH_Remove_Extended(HASH_TABLE *pHash, IMG_VOID *pKey) BUCKET **ppBucket; IMG_UINT32 uIndex; - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove_Extended: Hash=0x%x, pKey=0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove_Extended: Hash=0x%p, pKey=0x%p", + pHash, pKey)); PVR_ASSERT (pHash != IMG_NULL); @@ -553,14 +553,14 @@ HASH_Remove_Extended(HASH_TABLE *pHash, IMG_VOID *pKey) } PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Remove_Extended: Hash=0x%x, pKey=0x%x = 0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey, v)); + "HASH_Remove_Extended: Hash=0x%p, pKey=0x%p = 0x" UINTPTR_FMT, + pHash, pKey, v)); return v; } } PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Remove_Extended: Hash=0x%x, pKey=0x%x = 0x0 !!!!", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + "HASH_Remove_Extended: Hash=0x%p, pKey=0x%p = 0x0 !!!!", + pHash, pKey)); return 0; } @@ -580,8 +580,8 @@ HASH_Remove_Extended(HASH_TABLE *pHash, IMG_VOID *pKey) IMG_UINTPTR_T HASH_Remove (HASH_TABLE *pHash, IMG_UINTPTR_T k) { - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove: Hash=0x%x, k=0x%x", - (IMG_UINTPTR_T)pHash, k)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Remove: Hash=0x%p, k=0x" UINTPTR_FMT, + pHash, k)); return HASH_Remove_Extended(pHash, &k); } @@ -605,8 +605,8 @@ HASH_Retrieve_Extended (HASH_TABLE *pHash, IMG_VOID *pKey) BUCKET **ppBucket; IMG_UINT32 uIndex; - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve_Extended: Hash=0x%x, pKey=0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve_Extended: Hash=0x%p, pKey=0x%p", + pHash, pKey)); PVR_ASSERT (pHash != IMG_NULL); @@ -627,14 +627,14 @@ HASH_Retrieve_Extended (HASH_TABLE *pHash, IMG_VOID *pKey) IMG_UINTPTR_T v = pBucket->v; PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Retrieve: Hash=0x%x, pKey=0x%x = 0x%x", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey, v)); + "HASH_Retrieve: Hash=0x%p, pKey=0x%p = 0x" UINTPTR_FMT, + pHash, pKey, v)); return v; } } PVR_DPF ((PVR_DBG_MESSAGE, - "HASH_Retrieve: Hash=0x%x, pKey=0x%x = 0x0 !!!!", - (IMG_UINTPTR_T)pHash, (IMG_UINTPTR_T)pKey)); + "HASH_Retrieve: Hash=0x%p, pKey=0x%p = 0x0 !!!!", + pHash, pKey)); return 0; } @@ -653,8 +653,8 @@ HASH_Retrieve_Extended (HASH_TABLE *pHash, IMG_VOID *pKey) IMG_UINTPTR_T HASH_Retrieve (HASH_TABLE *pHash, IMG_UINTPTR_T k) { - PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve: Hash=0x%x, k=0x%x", - (IMG_UINTPTR_T)pHash, k)); + PVR_DPF ((PVR_DBG_MESSAGE, "HASH_Retrieve: Hash=0x%p, k=0x" UINTPTR_FMT, + pHash, k)); return HASH_Retrieve_Extended(pHash, &k); } diff --git a/drivers/gpu/pvr/services4/srvkm/common/lists.c b/drivers/gpu/pvr/services4/srvkm/common/lists.c index c6e1ee881a6..4ffdb0d3806 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/lists.c +++ b/drivers/gpu/pvr/services4/srvkm/common/lists.c @@ -75,6 +75,9 @@ IMPLEMENT_LIST_ANY_VA_2(PVRSRV_POWER_DEV, PVRSRV_ERROR, PVRSRV_OK) IMPLEMENT_LIST_INSERT(PVRSRV_POWER_DEV) IMPLEMENT_LIST_REMOVE(PVRSRV_POWER_DEV) +IMPLEMENT_LIST_ANY_2(PVRSRV_KERNEL_SYNC_INFO, PVRSRV_ERROR, PVRSRV_OK); +IMPLEMENT_LIST_INSERT(PVRSRV_KERNEL_SYNC_INFO) +IMPLEMENT_LIST_REMOVE(PVRSRV_KERNEL_SYNC_INFO) /*=================================================================== BELOW ARE IMPLEMENTED SOME COMMON CALLBACKS USED IN DIFFERENT FILES diff --git a/drivers/gpu/pvr/services4/srvkm/common/mem.c b/drivers/gpu/pvr/services4/srvkm/common/mem.c index cccdd24b01f..cccdd24b01f 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/mem.c +++ b/drivers/gpu/pvr/services4/srvkm/common/mem.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c b/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c index 04432b1f2c3..f79e7cb3d89 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c +++ b/drivers/gpu/pvr/services4/srvkm/common/mem_debug.c @@ -86,12 +86,12 @@ extern "C" */ IMG_VOID OSCheckMemDebug(IMG_PVOID pvCpuVAddr, IMG_SIZE_T uSize, const IMG_CHAR *pszFileName, const IMG_UINT32 uLine) { - OSMEM_DEBUG_INFO const *psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINT32)pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); + OSMEM_DEBUG_INFO const *psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINTPTR_T)pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); /* invalid pointer */ if (pvCpuVAddr == IMG_NULL) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : null pointer" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : null pointer" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -102,7 +102,7 @@ extern "C" /* align */ if (((IMG_UINT32)pvCpuVAddr&3) != 0) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : invalid alignment" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : invalid alignment" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -113,7 +113,7 @@ extern "C" /*check guard region before*/ if (!MemCheck((IMG_PVOID)psInfo->sGuardRegionBefore, 0xB1, sizeof(psInfo->sGuardRegionBefore))) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : guard region before overwritten" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : guard region before overwritten" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -124,7 +124,9 @@ extern "C" /*check size*/ if (uSize != psInfo->uSize) { - PVR_DPF((PVR_DBG_WARNING, "Pointer 0x%X : supplied size was different to stored size (0x%X != 0x%X)" + PVR_DPF((PVR_DBG_WARNING, + "Pointer 0x%p : supplied size was different to stored size (0x%" + SIZE_T_FMT_LEN "X != 0x%" SIZE_T_FMT_LEN "X)" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, uSize, psInfo->uSize, pszFileName, uLine, @@ -135,7 +137,9 @@ extern "C" /*check size parity*/ if ((0x01234567 ^ psInfo->uSizeParityCheck) != psInfo->uSize) { - PVR_DPF((PVR_DBG_WARNING, "Pointer 0x%X : stored size parity error (0x%X != 0x%X)" + PVR_DPF((PVR_DBG_WARNING, + "Pointer 0x%p : stored size parity error (0x%" + SIZE_T_FMT_LEN "X != 0x%" SIZE_T_FMT_LEN "X)" " - referenced %s:%d - allocated %s:%d", pvCpuVAddr, psInfo->uSize, 0x01234567 ^ psInfo->uSizeParityCheck, pszFileName, uLine, @@ -151,9 +155,9 @@ extern "C" /*check padding after*/ if (uSize) { - if (!MemCheck((IMG_VOID*)((IMG_UINT32)pvCpuVAddr + uSize), 0xB2, TEST_BUFFER_PADDING_AFTER)) + if (!MemCheck((IMG_VOID*)((IMG_UINTPTR_T)pvCpuVAddr + uSize), 0xB2, TEST_BUFFER_PADDING_AFTER)) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : guard region after overwritten" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : guard region after overwritten" " - referenced from %s:%d - allocated from %s:%d", pvCpuVAddr, pszFileName, uLine, @@ -164,7 +168,7 @@ extern "C" /* allocated... */ if (psInfo->eValid != isAllocated) { - PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%X : not allocated (freed? %d)" + PVR_DPF((PVR_DBG_ERROR, "Pointer 0x%p : not allocated (freed? %d)" " - referenced %s:%d - freed %s:%d", pvCpuVAddr, psInfo->eValid == isFree, pszFileName, uLine, @@ -223,12 +227,12 @@ extern "C" psInfo->uSizeParityCheck = 0x01234567 ^ ui32Size; /*point to the user data section*/ - *ppvCpuVAddr = (IMG_PVOID) ((IMG_UINT32)*ppvCpuVAddr)+TEST_BUFFER_PADDING_STATUS; + *ppvCpuVAddr = (IMG_PVOID) ((IMG_UINTPTR_T)*ppvCpuVAddr)+TEST_BUFFER_PADDING_STATUS; #ifdef PVRSRV_LOG_MEMORY_ALLOCS /*this is here to simplify the surounding logging macro, that is a expression maybe the macro should be an expression */ - PVR_TRACE(("Allocated pointer (after debug info): 0x%X from %s:%d", *ppvCpuVAddr, pszFilename, ui32Line)); + PVR_TRACE(("Allocated pointer (after debug info): 0x%p from %s:%d", *ppvCpuVAddr, pszFilename, ui32Line)); #endif return PVRSRV_OK; @@ -250,7 +254,7 @@ extern "C" OSMemSet(pvCpuVAddr, 0xBF, ui32Size + TEST_BUFFER_PADDING_AFTER); /*point to the starting address of the total allocated memory*/ - psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINT32) pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); + psInfo = (OSMEM_DEBUG_INFO *)((IMG_UINTPTR_T) pvCpuVAddr - TEST_BUFFER_PADDING_STATUS); /*update dbg info struct*/ psInfo->uSize = 0; diff --git a/drivers/gpu/pvr/services4/srvkm/common/metrics.c b/drivers/gpu/pvr/services4/srvkm/common/metrics.c index 7370ec16ed7..7370ec16ed7 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/metrics.c +++ b/drivers/gpu/pvr/services4/srvkm/common/metrics.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c b/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c index 19ba9ea2be0..19ba9ea2be0 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c +++ b/drivers/gpu/pvr/services4/srvkm/common/osfunc_common.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c b/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c index 2d96dc3a7e3..efedb61d7bc 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c +++ b/drivers/gpu/pvr/services4/srvkm/common/pdump_common.c @@ -75,26 +75,9 @@ static IMG_UINT16 gui16MMUContextUsage = 0; IMG_UINT32 g_ui32EveryLineCounter = 1U; #endif -#ifdef INLINE_IS_PRAGMA -#pragma inline(_PDumpIsPersistent) -#endif -static INLINE -IMG_BOOL _PDumpIsPersistent(IMG_VOID) -{ - PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); - - if(psPerProc == IMG_NULL) - { - /* only occurs early in driver init, and init phase is already persistent */ - return IMG_FALSE; - } - return psPerProc->bPDumpPersistent; -} - #if defined(SUPPORT_PDUMP_MULTI_PROCESS) -static INLINE IMG_BOOL _PDumpIsProcessActive(IMG_VOID) { PVRSRV_PER_PROCESS_DATA* psPerProc = PVRSRVFindPerProcessData(); @@ -226,6 +209,36 @@ PVRSRV_ERROR PDumpSetFrameKM(IMG_UINT32 ui32Frame) #endif } +static IMG_BOOL _PDumpWillCapture(IMG_UINT32 ui32Flags) +{ + /* + FIXME: + We really need to know if the PDump client is connected so we can + check if the continuous data will be saved or not. + */ + if ((ui32Flags & PDUMP_FLAGS_PERSISTENT) || (ui32Flags & PDUMP_FLAGS_CONTINUOUS)) + { + return IMG_TRUE; + } + else + { + return PDumpIsCaptureFrameKM(); + } +} + +IMG_BOOL PDumpWillCapture(IMG_UINT32 ui32Flags) +{ +#if defined(SUPPORT_PDUMP_MULTI_PROCESS) + if( _PDumpIsProcessActive() ) + { + return _PDumpWillCapture(ui32Flags); + } + return PVRSRV_OK; +#else + return _PDumpWillCapture(ui32Flags); +#endif +} + /************************************************************************** * Function Name : PDumpRegWithFlagsKM * Inputs : pszPDumpDevName, Register offset, and value to write @@ -240,16 +253,20 @@ PVRSRV_ERROR PDumpRegWithFlagsKM(IMG_CHAR *pszPDumpRegName, { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING() + + PDUMP_LOCK(); PDUMP_DBG(("PDumpRegWithFlagsKM")); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "WRW :%s:0x%08X 0x%08X\r\n", pszPDumpRegName, ui32Reg, ui32Data); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -293,14 +310,10 @@ PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, PVRSRV_ERROR eErr; IMG_UINT32 ui32PollCount; - PDUMP_GET_SCRIPT_STRING(); + + PDUMP_LOCK(); PDUMP_DBG(("PDumpRegPolWithFlagsKM")); - if ( _PDumpIsPersistent() ) - { - /* Don't pdump-poll if the process is persistent */ - return PVRSRV_OK; - } ui32PollCount = POLL_COUNT_LONG; @@ -309,10 +322,12 @@ PVRSRV_ERROR PDumpRegPolWithFlagsKM(IMG_CHAR *pszPDumpRegName, ui32Mask, eOperator, ui32PollCount, POLL_DELAY); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -355,8 +370,8 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, IMG_HANDLE hOSMemHandle, IMG_UINT32 ui32NumBytes, IMG_UINT32 ui32PageSize, - IMG_BOOL bShared, - IMG_HANDLE hUniqueTag) + IMG_HANDLE hUniqueTag, + IMG_UINT32 ui32Flags) { PVRSRV_ERROR eErr; IMG_PUINT8 pui8LinAddr; @@ -364,16 +379,11 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, IMG_UINT32 ui32NumPages; IMG_DEV_PHYADDR sDevPAddr; IMG_UINT32 ui32Page; - IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; - + IMG_UINT32 ui32PageSizeShift = 0; + IMG_UINT32 ui32PageSizeTmp; PDUMP_GET_SCRIPT_STRING(); -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - /* Always dump physical pages backing a shared allocation */ - ui32Flags |= ( _PDumpIsPersistent() || bShared ) ? PDUMP_FLAGS_PERSISTENT : 0; -#else - PVR_UNREFERENCED_PARAMETER(bShared); - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; -#endif + + PDUMP_LOCK(); /* However, lin addr is only required in non-linux OSes */ #if !defined(LINUX) @@ -384,12 +394,22 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, PVR_ASSERT(((IMG_UINT32) ui32NumBytes & HOST_PAGEMASK) == 0); /* + Compute the amount to right-shift in order to divide by the page-size. + Required for 32-bit PAE kernels (thus phys addresses are 64-bits) where + 64-bit division is unsupported. + */ + ui32PageSizeTmp = ui32PageSize; + while (ui32PageSizeTmp >>= 1) + ui32PageSizeShift++; + + /* Write a comment to the PDump2 script streams indicating the memory allocation */ - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- MALLOC :%s:VA_%08X 0x%08X %u\r\n", - psDevID->pszPDumpDevName, ui32DevVAddr, ui32NumBytes, ui32PageSize); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- MALLOC :%s:VA_%08X 0x%08X %u (%d pages)\r\n", + psDevID->pszPDumpDevName, ui32DevVAddr, ui32NumBytes, ui32PageSize, ui32NumBytes / ui32PageSize); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -399,7 +419,7 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, */ pui8LinAddr = (IMG_PUINT8) pvLinAddr; ui32Offset = 0; - ui32NumPages = ui32NumBytes / ui32PageSize; + ui32NumPages = ui32NumBytes >> ui32PageSizeShift; while (ui32NumPages) { ui32NumPages--; @@ -415,24 +435,29 @@ PVRSRV_ERROR PDumpMallocPages (PVRSRV_DEVICE_IDENTIFIER *psDevID, pui8LinAddr, ui32PageSize, &sDevPAddr); - ui32Page = (IMG_UINT32)(sDevPAddr.uiAddr / ui32PageSize); + ui32Page = (IMG_UINT32)(sDevPAddr.uiAddr >> ui32PageSizeShift); /* increment kernel virtual address */ pui8LinAddr += ui32PageSize; ui32Offset += ui32PageSize; - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_%08X%08X %u %u 0x%08X\r\n", + sDevPAddr.uiAddr = ui32Page * ui32PageSize; + + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_" UINTPTR_FMT DEVPADDR_FMT " %u %u 0x" DEVPADDR_FMT "\r\n", psDevID->pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, - ui32Page * ui32PageSize, + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr, ui32PageSize, ui32PageSize, - ui32Page * ui32PageSize); + sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); } + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -454,13 +479,13 @@ PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_DEV_PHYADDR sDevPAddr; - PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize - 1)) == 0); + ui32Flags |= PDUMP_FLAGS_CONTINUOUS; - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; - + /* Write a comment to the PDump2 script streams indicating the memory allocation */ @@ -472,6 +497,7 @@ PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, ui32PTSize); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -491,19 +517,22 @@ PVRSRV_ERROR PDumpMallocPageTable (PVRSRV_DEVICE_IDENTIFIER *psDevId, ui32PTSize, &sDevPAddr); - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_%08X%08X 0x%X %u 0x%08X\r\n", + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MALLOC :%s:PA_" UINTPTR_FMT DEVPADDR_FMT + " 0x%X %u 0x" DEVPADDR_FMT "\r\n", psDevId->pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr, ui32PTSize,//size ui32PTSize,//alignment sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -521,21 +550,20 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, IMG_UINT32 ui32PageSize, IMG_HANDLE hUniqueTag, IMG_BOOL bInterleaved, - IMG_BOOL bSparse) + IMG_BOOL bSparse, + IMG_UINT32 ui32Flags) { PVRSRV_ERROR eErr; IMG_UINT32 ui32NumPages, ui32PageCounter; IMG_DEV_PHYADDR sDevPAddr; - IMG_UINT32 ui32Flags = PDUMP_FLAGS_CONTINUOUS; PVRSRV_DEVICE_NODE *psDeviceNode; - PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); PVR_ASSERT(((IMG_UINT32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); PVR_ASSERT(((IMG_UINT32) ui32NumBytes & (ui32PageSize - 1)) == 0); psDeviceNode = psBMHeap->pBMContext->psDeviceNode; - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; /* Write a comment to the PDUMP2 script streams indicating the memory free @@ -544,22 +572,10 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, psDeviceNode->sDevId.pszPDumpDevName, sDevVAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - /* if we're dumping a shared heap, need to ensure phys allocation - * is freed even if this app isn't the one marked for pdumping - */ - { - PVRSRV_DEVICE_NODE *psDeviceNode = psBMHeap->pBMContext->psDeviceNode; - - if( psDeviceNode->pfnMMUIsHeapShared(psBMHeap->pMMUHeap) ) - { - ui32Flags |= PDUMP_FLAGS_PERSISTENT; - } - } -#endif PDumpOSWriteString2(hScript, ui32Flags); /* @@ -580,10 +596,13 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, 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); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_" UINTPTR_FMT DEVPADDR_FMT "\r\n", + psDeviceNode->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -595,6 +614,8 @@ PVRSRV_ERROR PDumpFreePages (BM_HEAP *psBMHeap, sDevVAddr.uiAddr += ui32PageSize; } + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -614,12 +635,10 @@ PVRSRV_ERROR PDumpFreePageTable (PVRSRV_DEVICE_IDENTIFIER *psDevID, { PVRSRV_ERROR eErr; IMG_DEV_PHYADDR sDevPAddr; - PDUMP_GET_SCRIPT_STRING(); - PVR_UNREFERENCED_PARAMETER(ui32PTSize); - ui32Flags |= PDUMP_FLAGS_CONTINUOUS; - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; + + PDUMP_LOCK(); /* override QAC warning about wrap around */ PVR_ASSERT(((IMG_UINTPTR_T)pvLinAddr & (ui32PTSize-1UL)) == 0); /* PRQA S 3382 */ @@ -630,6 +649,7 @@ PVRSRV_ERROR PDumpFreePageTable (PVRSRV_DEVICE_IDENTIFIER *psDevID, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "-- FREE :%s:PAGE_TABLE\r\n", psDevID->pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -650,17 +670,19 @@ PVRSRV_ERROR PDumpFreePageTable (PVRSRV_DEVICE_IDENTIFIER *psDevID, &sDevPAddr); { - eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_%08X%08X\r\n", + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "FREE :%s:PA_" UINTPTR_FMT DEVPADDR_FMT "\r\n", psDevID->pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -684,8 +706,11 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, { PVRSRV_ERROR eErr; IMG_CHAR *pszRegString; + IMG_DEV_PHYADDR sDevPAddr; + PDUMP_GET_SCRIPT_STRING() - + + PDUMP_LOCK(); if(psMMUAttrib->pszPDRegRegion != IMG_NULL) { pszRegString = psMMUAttrib->pszPDRegRegion; @@ -699,14 +724,18 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, Write to the MMU script stream indicating the physical page directory */ #if defined(SGX_FEATURE_36BIT_MMU) + sDevPAddr.uiAddr = ((ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", + "WRW :%s:$1 :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag, - (ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift); + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr, + ui32Data & ~psMMUAttrib->ui32PDEMask); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -715,6 +744,7 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -725,25 +755,31 @@ PVRSRV_ERROR PDumpPDRegWithFlags(PDUMP_MMU_ATTRIB *psMMUAttrib, psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); #else + sDevPAddr.uiAddr = ((ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift); + eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "WRW :%s:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", + "WRW :%s:0x%08X :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", pszRegString, ui32Reg, psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, - (ui32Data & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PDEAlignShift, + (IMG_UINTPTR_T)hUniqueTag, + sDevPAddr.uiAddr, ui32Data & ~psMMUAttrib->ui32PDEMask); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); #endif + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -800,14 +836,10 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); if (PDumpOSIsSuspended()) { - return PVRSRV_OK; - } - - if ( _PDumpIsPersistent() ) - { - /* Don't pdump-poll if the process is persistent */ + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -831,6 +863,7 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, MEMPOLL_DELAY); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -864,11 +897,11 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "POL :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %d %d %d\r\n", + "POL :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %d %d %d\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), - sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask)), ui32Value, ui32Mask, eOperator, @@ -876,10 +909,12 @@ PVRSRV_ERROR PDumpMemPolKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, MEMPOLL_DELAY); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -913,12 +948,13 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, IMG_UINT32 ui32ParamOutPos; PDUMP_MMU_ATTRIB *psMMUAttrib; IMG_UINT32 ui32DataPageSize; - PDUMP_GET_SCRIPT_AND_FILE_STRING(); - + + PDUMP_LOCK(); /* PRQA S 3415 1 */ /* side effects desired */ if (ui32Bytes == 0 || PDumpOSIsSuspended()) { + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -931,24 +967,10 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, if (!PDumpOSJTInitialised()) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; } -#if defined(SUPPORT_PDUMP_MULTI_PROCESS) - /* if we're dumping a shared heap, need to ensure phys allocation - * is initialised even if this app isn't the one marked for pdumping - */ - { - BM_HEAP *pHeap = ((BM_BUF*)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap; - PVRSRV_DEVICE_NODE *psDeviceNode = pHeap->pBMContext->psDeviceNode; - - if( psDeviceNode->pfnMMUIsHeapShared(pHeap->pMMUHeap) ) - { - ui32Flags |= PDUMP_FLAGS_PERSISTENT; - } - } -#endif - /* setup memory addresses */ if(pvAltLinAddr) { @@ -979,6 +1001,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, ui32Bytes, ui32Flags)) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } @@ -992,6 +1015,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, } if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } @@ -1000,9 +1024,9 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, */ eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "-- LDB :%s:VA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "-- LDB :%s:VA_" UINTPTR_FMT "%08X:0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, psMemInfo->sDevVAddr.uiAddr, ui32Offset, ui32Bytes, @@ -1010,6 +1034,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -1059,16 +1084,17 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "LDB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "LDB :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), - sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask)), ui32BlockBytes, ui32ParamOutPos, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -1092,6 +1118,7 @@ static PVRSRV_ERROR _PDumpMemIntKM(IMG_PVOID pvAltLinAddr, ui32ParamOutPos += ui32BlockBytes; } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1191,26 +1218,35 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, IMG_UINT32 ui32BlockBytes; IMG_UINT8* pui8LinAddr; IMG_DEV_PHYADDR sDevPAddr; + IMG_DEV_PHYADDR sDevPAddrTmp; IMG_CPU_PHYADDR sCpuPAddr; IMG_UINT32 ui32Offset; IMG_UINT32 ui32ParamOutPos; IMG_UINT32 ui32PageMask; /* mask for the physical page backing the PT */ +#if !defined(SGX_FEATURE_36BIT_MMU) + IMG_DEV_PHYADDR sDevPAddrTmp2; +#endif PDUMP_GET_SCRIPT_AND_FILE_STRING(); - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; + + PDUMP_LOCK(); + if (PDumpOSIsSuspended()) { + PDUMP_UNLOCK(); return PVRSRV_OK; } if (!PDumpOSJTInitialised()) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; } if (!pvLinAddr) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_INVALID_PARAMS; } @@ -1229,6 +1265,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, ui32Bytes, ui32Flags | PDUMP_FLAGS_CONTINUOUS)) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } @@ -1242,6 +1279,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, } if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } } @@ -1295,16 +1333,17 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, { eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "LDB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "LDB :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, + (IMG_UINTPTR_T)hUniqueTag1, sDevPAddr.uiAddr & ~ui32PageMask, - sDevPAddr.uiAddr & ui32PageMask, + (unsigned int)(sDevPAddr.uiAddr & ui32PageMask), ui32BlockBytes, ui32ParamOutPos, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1319,15 +1358,18 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, { /* PT entry points to non-null page */ #if defined(SGX_FEATURE_36BIT_MMU) + sDevPAddrTmp.uiAddr = ((ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift); + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", + "WRW :%s:$1 :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x0\r\n", psMMUAttrib->sDevId.pszPDumpDevName, psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag2, - (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift); + (IMG_UINTPTR_T)hUniqueTag2, + sDevPAddrTmp.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1336,6 +1378,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1345,36 +1388,44 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, ui32PTE & ~psMMUAttrib->ui32PDEMask); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); + sDevPAddrTmp.uiAddr = (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:$1\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:$1\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag1, - (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, - (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr + ui32Offset) & ui32PageMask), psMMUAttrib->sDevId.pszPDumpDevName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); #else + sDevPAddrTmp.uiAddr = (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask; + sDevPAddrTmp2.uiAddr = (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, - (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr + ui32Offset) & ui32PageMask), psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2, - (ui32PTE & psMMUAttrib->ui32PDEMask) << psMMUAttrib->ui32PTEAlignShift, - ui32PTE & ~psMMUAttrib->ui32PDEMask); + (IMG_UINTPTR_T)hUniqueTag2, + sDevPAddrTmp2.uiAddr, + (unsigned int)(ui32PTE & ~psMMUAttrib->ui32PDEMask)); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1385,17 +1436,20 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, #if !defined(FIX_HW_BRN_31620) PVR_ASSERT((ui32PTE & psMMUAttrib->ui32PTEValid) == 0UL); #endif + sDevPAddrTmp.uiAddr = (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X 0x%08X%08X\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X" UINTPTR_FMT "\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - (sDevPAddr.uiAddr + ui32Offset) & ~ui32PageMask, - (sDevPAddr.uiAddr + ui32Offset) & ui32PageMask, - (ui32PTE << psMMUAttrib->ui32PTEAlignShift), - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2); + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr + ui32Offset) & ui32PageMask), + ui32PTE << psMMUAttrib->ui32PTEAlignShift, + (IMG_UINTPTR_T)hUniqueTag2); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags | PDUMP_FLAGS_CONTINUOUS); @@ -1415,6 +1469,7 @@ PVRSRV_ERROR PDumpMemPTEntriesKM(PDUMP_MMU_ATTRIB *psMMUAttrib, ui32ParamOutPos += ui32BlockBytes; } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1433,11 +1488,14 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, IMG_UINT32 ui32ParamOutPos; PDUMP_MMU_ATTRIB *psMMUAttrib; IMG_UINT32 ui32PageMask; /* mask for the physical page backing the PT */ + IMG_DEV_PHYADDR sDevPAddrTmp; PDUMP_GET_SCRIPT_AND_FILE_STRING(); + PDUMP_LOCK(); if (!PDumpOSJTInitialised()) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_NOT_AVAILABLE; } @@ -1452,6 +1510,7 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, sizeof(IMG_DEV_PHYADDR), ui32Flags)) { + PDUMP_UNLOCK(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } @@ -1465,24 +1524,28 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, } if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } /* Write a comment indicating the PD phys addr write, so that the offsets * into the param stream increase in correspondence with the number of bytes * written. */ + sDevPAddrTmp.uiAddr = sPDDevPAddr.uiAddr & ~ui32PageMask; + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "-- LDB :%s:PA_0x%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "-- LDB :%s:PA_0x" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08" SIZE_T_FMT_LEN "X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - sPDDevPAddr.uiAddr & ~ui32PageMask, - sPDDevPAddr.uiAddr & ui32PageMask, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)(sPDDevPAddr.uiAddr & ui32PageMask), sizeof(IMG_DEV_PHYADDR), ui32ParamOutPos, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); @@ -1496,103 +1559,70 @@ PVRSRV_ERROR PDumpPDDevPAddrKM(PVRSRV_KERNEL_MEM_INFO *psMemInfo, BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); sDevPAddr.uiAddr += ui32PageByteOffset + ui32Offset; - if ((sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask) != 0UL) - { #if defined(SGX_FEATURE_36BIT_MMU) - eErr = PDumpOSBufprintf(hScript, - ui32MaxLenScript, - "WRW :%s:$1 :%s:PA_%08X%08X:0x0\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag2, - sPDDevPAddr.uiAddr); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); - - eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "AND :%s:$2 :%s:$1 0xFFFFFFFF\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); + sDevPAddrTmp.uiAddr = sPDDevPAddr.uiAddr & ~ui32PageMask; - eErr = PDumpOSBufprintf(hScript, + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:$2\r\n", + "WRW :%s:$1 :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag1, - (sDevPAddr.uiAddr) & ~(psMMUAttrib->ui32DataPageMask), - (sDevPAddr.uiAddr) & (psMMUAttrib->ui32DataPageMask), - psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); + psMMUAttrib->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag2, + sDevPAddrTmp.uiAddr, + (unsigned int)(sPDDevPAddr.uiAddr & ui32PageMask)); + if(eErr != PVRSRV_OK) + { + PDUMP_UNLOCK(); + return eErr; + } + PDumpOSWriteString2(hScript, ui32Flags); - eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "SHR :%s:$2 :%s:$1 0x20\r\n", + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, "SHR :%s:$1 :%s:$1 0x4\r\n", psMMUAttrib->sDevId.pszPDumpDevName, psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); + if(eErr != PVRSRV_OK) + { + PDUMP_UNLOCK(); + return eErr; + } - eErr = PDumpOSBufprintf(hScript, + PDumpOSWriteString2(hScript, ui32Flags); + sDevPAddrTmp.uiAddr = sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask); + + eErr = PDumpOSBufprintf(hScript, ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:$2\r\n", + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:$1\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)hUniqueTag1, - (sDevPAddr.uiAddr + 4) & ~(psMMUAttrib->ui32DataPageMask), - (sDevPAddr.uiAddr + 4) & (psMMUAttrib->ui32DataPageMask), + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddrTmp.uiAddr, + (unsigned int)((sDevPAddr.uiAddr) & (psMMUAttrib->ui32DataPageMask)), psMMUAttrib->sDevId.pszPDumpDevName); - if(eErr != PVRSRV_OK) - { - return eErr; - } - PDumpOSWriteString2(hScript, ui32Flags); -#else - eErr = PDumpOSBufprintf(hScript, - ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X :%s:PA_%08X%08X:0x%08X\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - sDevPAddr.uiAddr & ~ui32PageMask, - sDevPAddr.uiAddr & ui32PageMask, - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag2, - sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask, - sPDDevPAddr.uiAddr & ~psMMUAttrib->ui32PDEMask); - if(eErr != PVRSRV_OK) - { - return eErr; - } -#endif + if(eErr != PVRSRV_OK) + { + PDUMP_UNLOCK(); + return eErr; } - else +#else + eErr = PDumpOSBufprintf(hScript, + ui32MaxLenScript, + "WRW :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X \r\n", + psMMUAttrib->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag1, + sDevPAddr.uiAddr & ~ui32PageMask, + (unsigned int)(sDevPAddr.uiAddr & ui32PageMask), + psMMUAttrib->sDevId.pszPDumpDevName, + (IMG_UINTPTR_T)hUniqueTag2, + sPDDevPAddr.uiAddr & psMMUAttrib->ui32PDEMask, + (unsigned int)(sPDDevPAddr.uiAddr & ~psMMUAttrib->ui32PDEMask)); + if(eErr != PVRSRV_OK) { - PVR_ASSERT(!(sDevPAddr.uiAddr & psMMUAttrib->ui32PTEValid)); - eErr = PDumpOSBufprintf(hScript, - ui32MaxLenScript, - "WRW :%s:PA_%08X%08X:0x%08X 0x%08X\r\n", - psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, - sDevPAddr.uiAddr & ~ui32PageMask, - sDevPAddr.uiAddr & ui32PageMask, - sPDDevPAddr.uiAddr); - if(eErr != PVRSRV_OK) - { - return eErr; - } + PDUMP_UNLOCK(); + return eErr; } +#endif PDumpOSWriteString2(hScript, ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1612,13 +1642,10 @@ PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) #endif IMG_UINT32 ui32LenCommentPrefix; PDUMP_GET_SCRIPT_STRING(); + + PDUMP_LOCK(); PDUMP_DBG(("PDumpCommentKM")); -#if defined(PDUMP_DEBUG_OUTFILES) - /* include comments in the "extended" init phase. - * default is to ignore them. - */ - ui32Flags |= ( _PDumpIsPersistent() ) ? PDUMP_FLAGS_PERSISTENT : 0; -#endif + /* Put \r \n sequence at the end if it isn't already there */ PDumpOSVerifyLineEnding(pszComment, ui32MaxLen); @@ -1637,23 +1664,27 @@ PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) { PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s (continuous set)", g_ui32EveryLineCounter, pszComment)); + PDUMP_UNLOCK(); 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)); + PDUMP_UNLOCK(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; } else { PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %d: %s", g_ui32EveryLineCounter, pszComment)); + PDUMP_UNLOCK(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; } #else PVR_DPF((PVR_DBG_WARNING, "Incomplete comment, %s", pszComment)); + PDUMP_UNLOCK(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; #endif } @@ -1675,9 +1706,12 @@ PVRSRV_ERROR PDumpCommentKM(IMG_CHAR *pszComment, IMG_UINT32 ui32Flags) if( (eErr != PVRSRV_OK) && (eErr != PVRSRV_ERROR_PDUMP_BUF_OVERFLOW)) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1696,6 +1730,7 @@ PVRSRV_ERROR PDumpCommentWithFlags(IMG_UINT32 ui32Flags, IMG_CHAR * pszFormat, . PDUMP_va_list ap; PDUMP_GET_MSG_STRING(); + PDUMP_LOCK_MSG(); /* Construct the string */ PDUMP_va_start(ap, pszFormat); eErr = PDumpOSVSprintf(pszMsg, ui32MaxLen, pszFormat, ap); @@ -1703,9 +1738,12 @@ PVRSRV_ERROR PDumpCommentWithFlags(IMG_UINT32 ui32Flags, IMG_CHAR * pszFormat, . if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK_MSG(); return eErr; } - return PDumpCommentKM(pszMsg, ui32Flags); + eErr = PDumpCommentKM(pszMsg, ui32Flags); + PDUMP_UNLOCK_MSG(); + return eErr; } /************************************************************************** @@ -1723,6 +1761,7 @@ PVRSRV_ERROR PDumpComment(IMG_CHAR *pszFormat, ...) PDUMP_va_list ap; PDUMP_GET_MSG_STRING(); + PDUMP_LOCK_MSG(); /* Construct the string */ PDUMP_va_start(ap, pszFormat); eErr = PDumpOSVSprintf(pszMsg, ui32MaxLen, pszFormat, ap); @@ -1730,9 +1769,12 @@ PVRSRV_ERROR PDumpComment(IMG_CHAR *pszFormat, ...) if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK_MSG(); return eErr; } - return PDumpCommentKM(pszMsg, PDUMP_FLAGS_CONTINUOUS); + eErr = PDumpCommentKM(pszMsg, PDUMP_FLAGS_CONTINUOUS); + PDUMP_UNLOCK_MSG(); + return eErr; } /************************************************************************** @@ -1748,10 +1790,12 @@ PVRSRV_ERROR PDumpDriverInfoKM(IMG_CHAR *pszString, IMG_UINT32 ui32Flags) IMG_UINT32 ui32MsgLen; PDUMP_GET_MSG_STRING(); + PDUMP_LOCK_MSG(); /* Construct the string */ eErr = PDumpOSSprintf(pszMsg, ui32MaxLen, "%s", pszString); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK_MSG(); return eErr; } @@ -1766,13 +1810,17 @@ PVRSRV_ERROR PDumpDriverInfoKM(IMG_CHAR *pszString, IMG_UINT32 ui32Flags) { if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) { + PDUMP_UNLOCK_MSG(); return PVRSRV_ERROR_PDUMP_BUFFER_FULL; } else { + PDUMP_UNLOCK_MSG(); return PVRSRV_ERROR_CMD_NOT_PROCESSED; } } + + PDUMP_UNLOCK_MSG(); return PVRSRV_OK; } @@ -1818,13 +1866,9 @@ PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); - if ( _PDumpIsPersistent() ) - { - return PVRSRV_OK; - } - PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); + PDUMP_LOCK(); /* find MMU context ID */ ui32MMUContextID = psDeviceNode->pfnMMUGetContextID( hDevMemContext ); @@ -1845,10 +1889,13 @@ PVRSRV_ERROR PDumpBitmapKM( PVRSRV_DEVICE_NODE *psDeviceNode, eMemFormat); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2( hScript, ui32PDumpFlags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1880,9 +1927,9 @@ PVRSRV_ERROR PDumpReadRegKM ( IMG_CHAR *pszPDumpRegName, { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); - PVR_UNREFERENCED_PARAMETER(ui32Size); + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SAB :%s:0x%08X 0x%08X %s\r\n", @@ -1892,11 +1939,13 @@ PVRSRV_ERROR PDumpReadRegKM ( IMG_CHAR *pszPDumpRegName, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2( hScript, ui32PDumpFlags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -1954,6 +2003,7 @@ static PVRSRV_ERROR PDumpSignatureRegister (PVRSRV_DEVICE_IDENTIFIER *psDevId, PDumpOSWriteString2(hScript, ui32Flags); *pui32FileOffset += ui32Size; + return PVRSRV_OK; } @@ -2000,7 +2050,6 @@ PVRSRV_ERROR PDump3DSignatureRegisters(PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_UINT32 ui32FileOffset, ui32Flags; - PDUMP_GET_FILE_STRING(); ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; @@ -2013,6 +2062,12 @@ PVRSRV_ERROR PDump3DSignatureRegisters(PVRSRV_DEVICE_IDENTIFIER *psDevId, return eErr; } + /* + Note: + PDumpCommentWithFlags will take the lock so we defer the lock + taking until here + */ + PDUMP_LOCK(); PDumpRegisterRange(psDevId, pszFileName, pui32Registers, @@ -2021,6 +2076,7 @@ PVRSRV_ERROR PDump3DSignatureRegisters(PVRSRV_DEVICE_IDENTIFIER *psDevId, sizeof(IMG_UINT32), ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2044,7 +2100,6 @@ PVRSRV_ERROR PDumpTASignatureRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_UINT32 ui32FileOffset, ui32Flags; - PDUMP_GET_FILE_STRING(); ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; @@ -2057,6 +2112,12 @@ PVRSRV_ERROR PDumpTASignatureRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, return eErr; } + /* + Note: + PDumpCommentWithFlags will take the lock so we defer the lock + taking until here + */ + PDUMP_LOCK(); PDumpRegisterRange(psDevId, pszFileName, pui32Registers, @@ -2064,6 +2125,7 @@ PVRSRV_ERROR PDumpTASignatureRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, &ui32FileOffset, sizeof(IMG_UINT32), ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2085,7 +2147,6 @@ PVRSRV_ERROR PDumpCounterRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; IMG_UINT32 ui32FileOffset, ui32Flags; - PDUMP_GET_FILE_STRING(); ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0UL; @@ -2097,7 +2158,12 @@ PVRSRV_ERROR PDumpCounterRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, { return eErr; } - + /* + Note: + PDumpCommentWithFlags will take the lock so we defer the lock + taking until here + */ + PDUMP_LOCK(); PDumpRegisterRange(psDevId, pszFileName, pui32Registers, @@ -2106,6 +2172,7 @@ PVRSRV_ERROR PDumpCounterRegisters (PVRSRV_DEVICE_IDENTIFIER *psDevId, sizeof(IMG_UINT32), ui32Flags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2124,14 +2191,18 @@ PVRSRV_ERROR PDumpRegRead(IMG_CHAR *pszPDumpRegName, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "RDW :%s:0x%X\r\n", pszPDumpRegName, ui32RegOffset); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2156,7 +2227,8 @@ PVRSRV_ERROR PDumpSaveMemKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); - + + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "SAB :%s:v%x:0x%08X 0x%08X 0x%08X %s.bin\r\n", @@ -2168,10 +2240,13 @@ PVRSRV_ERROR PDumpSaveMemKM (PVRSRV_DEVICE_IDENTIFIER *psDevId, pszFileName); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32PDumpFlags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2189,14 +2264,18 @@ PVRSRV_ERROR PDumpCycleCountRegRead(PVRSRV_DEVICE_IDENTIFIER *psDevId, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "RDW :%s:0x%X\r\n", psDevId->pszPDumpRegName, ui32RegOffset); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2286,9 +2365,9 @@ PVRSRV_ERROR PDumpCBP(PPVRSRV_KERNEL_MEM_INFO psROffMemInfo, IMG_DEV_VIRTADDR sDevVPageAddr; //IMG_CPU_PHYADDR CpuPAddr; PDUMP_MMU_ATTRIB *psMMUAttrib; - PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); psMMUAttrib = ((BM_BUF*)psROffMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap->psMMUAttrib; /* Check the offset and size don't exceed the bounds of the allocation */ @@ -2324,19 +2403,22 @@ PVRSRV_ERROR PDumpCBP(PPVRSRV_KERNEL_MEM_INFO psROffMemInfo, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "CBP :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X 0x%08X\r\n", + "CBP :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X 0x%08X\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, + (IMG_UINTPTR_T)hUniqueTag, sDevPAddr.uiAddr & ~(psMMUAttrib->ui32DataPageMask), - sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & (psMMUAttrib->ui32DataPageMask)), ui32WPosVal, ui32PacketSize, ui32BufferSize); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2352,14 +2434,19 @@ PVRSRV_ERROR PDumpIDLWithFlags(IMG_UINT32 ui32Clocks, IMG_UINT32 ui32Flags) { PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + + PDUMP_LOCK(); PDUMP_DBG(("PDumpIDLWithFlags")); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "IDL %u\r\n", ui32Clocks); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, ui32Flags); + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2617,10 +2704,13 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, PVRSRV_ERROR eErr; PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); + eErr = _PdumpAllocMMUContext(&ui32MMUContextID); if(eErr != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PDumpSetMMUContext: _PdumpAllocMMUContext failed: %d", eErr)); + PDUMP_UNLOCK(); return eErr; } @@ -2633,15 +2723,16 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, eErr = PDumpOSBufprintf(hScript, ui32MaxLen, - "MMU :%s:v%d %d :%s:PA_%08X%08X\r\n", + "MMU :%s:v%d %d :%s:PA_" UINTPTR_FMT DEVPADDR_FMT "\r\n", pszMemSpace, ui32MMUContextID, ui32MMUType, pszMemSpace, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag1, + (IMG_UINTPTR_T)hUniqueTag1, sDevPAddr.uiAddr); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } PDumpOSWriteString2(hScript, PDUMP_FLAGS_CONTINUOUS); @@ -2649,6 +2740,7 @@ PVRSRV_ERROR PDumpSetMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, /* return the MMU Context ID */ *pui32MMUContextID = ui32MMUContextID; + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2674,6 +2766,12 @@ PVRSRV_ERROR PDumpClearMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, * all OSes and platforms */ PDumpComment("Clear MMU Context for memory space %s\r\n", pszMemSpace); + + /* + Note: + PDumpComment takes the lock so we can't take it until here + */ + PDUMP_LOCK(); eErr = PDumpOSBufprintf(hScript, ui32MaxLen, "MMU :%s:v%d\r\n", @@ -2681,17 +2779,21 @@ PVRSRV_ERROR PDumpClearMMUContext(PVRSRV_DEVICE_TYPE eDeviceType, ui32MMUContextID); if(eErr != PVRSRV_OK) { + PDUMP_UNLOCK(); return eErr; } + PDumpOSWriteString2(hScript, PDUMP_FLAGS_CONTINUOUS); eErr = _PdumpFreeMMUContext(ui32MMUContextID); if(eErr != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "PDumpClearMMUContext: _PdumpFreeMMUContext failed: %d", eErr)); + PDUMP_UNLOCK(); return eErr; } + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2719,6 +2821,7 @@ PVRSRV_ERROR PDumpStoreMemToFile(PDUMP_MMU_ATTRIB *psMMUAttrib, PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); /* query the buffer manager for the physical pages that back the virtual address @@ -2736,17 +2839,18 @@ PVRSRV_ERROR PDumpStoreMemToFile(PDUMP_MMU_ATTRIB *psMMUAttrib, PDumpOSBufprintf(hScript, ui32MaxLen, - "SAB :%s:PA_%08X%08X:0x%08X 0x%08X 0x%08X %s\r\n", + "SAB :%s:PA_" UINTPTR_FMT DEVPADDR_FMT ":0x%08X 0x%08X 0x%08X %s\r\n", psMMUAttrib->sDevId.pszPDumpDevName, - (IMG_UINT32)(IMG_UINTPTR_T)hUniqueTag, - sDevPAddr.uiAddr & ~psMMUAttrib->ui32DataPageMask, - sDevPAddr.uiAddr & psMMUAttrib->ui32DataPageMask, + (IMG_UINTPTR_T)hUniqueTag, + (sDevPAddr.uiAddr & ~psMMUAttrib->ui32DataPageMask), + (unsigned int)(sDevPAddr.uiAddr & psMMUAttrib->ui32DataPageMask), ui32Size, ui32FileOffset, pszFileName); PDumpOSWriteString2(hScript, ui32PDumpFlags); + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2768,6 +2872,8 @@ PVRSRV_ERROR PDumpRegBasedCBP(IMG_CHAR *pszPDumpRegName, { PDUMP_GET_SCRIPT_STRING(); + PDUMP_LOCK(); + PDumpOSBufprintf(hScript, ui32MaxLen, "CBP :%s:0x%08X 0x%08X 0x%08X 0x%08X\r\n", @@ -2777,7 +2883,8 @@ PVRSRV_ERROR PDumpRegBasedCBP(IMG_CHAR *pszPDumpRegName, ui32PacketSize, ui32BufferSize); PDumpOSWriteString2(hScript, ui32Flags); - + + PDUMP_UNLOCK(); return PVRSRV_OK; } @@ -2843,7 +2950,7 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC /* Return if process is not marked for pdumping, unless it's persistent. */ if ( (_PDumpIsProcessActive() == IMG_FALSE ) && - ((ui32Flags & PDUMP_FLAGS_PERSISTENT) == 0) ) + ((ui32Flags & PDUMP_FLAGS_PERSISTENT) == 0) && psCtrl->bInitPhaseComplete) { return ui32BCount; } @@ -2867,6 +2974,7 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC if (ui32BytesWritten == 0) { + PVR_DPF((PVR_DBG_ERROR, "DbgWrite: Failed to send persistent data")); PDumpOSReleaseExecution(); } @@ -2893,7 +3001,8 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC while (((IMG_UINT32) ui32BCount > 0) && (ui32BytesWritten != 0xFFFFFFFFU)) { - if ((ui32Flags & PDUMP_FLAGS_CONTINUOUS) != 0) + /* If we're in the init phase we treat persisent as meaning continuous */ + if (((ui32Flags & PDUMP_FLAGS_CONTINUOUS) != 0) || ((ui32Flags & PDUMP_FLAGS_PERSISTENT) != 0)) { /* If pdump client (or its equivalent) isn't running then throw continuous data away. @@ -2942,6 +3051,10 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC */ if (ui32BytesWritten == 0) { + if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) + { + PVR_DPF((PVR_DBG_ERROR, "Buffer is full during writing of %s", &pui8Data[ui32Off])); + } PDumpOSReleaseExecution(); } @@ -2950,7 +3063,13 @@ IMG_UINT32 DbgWrite(PDBG_STREAM psStream, IMG_UINT8 *pui8Data, IMG_UINT32 ui32BC ui32Off += ui32BytesWritten; ui32BCount -= ui32BytesWritten; } - + else + { + if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) + { + PVR_DPF((PVR_DBG_ERROR, "Error during writing of %s", &pui8Data[ui32Off])); + } + } /* loop exits when i) all data is written, or ii) an unrecoverable error occurs */ } diff --git a/drivers/gpu/pvr/services4/srvkm/common/perproc.c b/drivers/gpu/pvr/services4/srvkm/common/perproc.c index 3918bb20eb5..3918bb20eb5 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/perproc.c +++ b/drivers/gpu/pvr/services4/srvkm/common/perproc.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/power.c b/drivers/gpu/pvr/services4/srvkm/common/power.c index 511a690d4e4..511a690d4e4 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/power.c +++ b/drivers/gpu/pvr/services4/srvkm/common/power.c diff --git a/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c b/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c index 1b5312c02d0..ea1fcaf319d 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c +++ b/drivers/gpu/pvr/services4/srvkm/common/pvrsrv.c @@ -48,24 +48,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pdump_km.h" #include "deviceid.h" #include "ra.h" -#if defined(__linux__) -#include "sysfs.h" -#endif #if defined(TTRACE) #include "ttrace.h" #endif #include "perfkm.h" +#include "devicemem.h" #include "pvrversion.h" #include "lists.h" IMG_UINT32 g_ui32InitFlags; -extern int powering_down; /* mark which parts of Services were initialised */ #define INIT_DATA_ENABLE_PDUMPINIT 0x1U -#define INIT_DATA_ENABLE_TTARCE 0x2U +#define INIT_DATA_ENABLE_TTRACE 0x2U +#define INIT_DATA_ENABLE_DEVMEM 0x4U /*! ****************************************************************************** @@ -158,7 +156,37 @@ PVRSRV_ERROR FreeDeviceID(SYS_DATA *psSysData, IMG_UINT32 ui32DevID) return PVRSRV_ERROR_INVALID_DEVICEID; } +/*! +****************************************************************************** + + @Function PVRSRVCompatCheckKM + + @Description UM/KM ddk branch Compatibility check function + + @input psUserModeDDKDetails: User mode DDK version + + @output In case of incompatibility, returns PVRSRV_ERROR_DDK_VERSION_MISMATCH + @Return PVRSRV_ERROR + +******************************************************************************/ +IMG_VOID IMG_CALLCONV PVRSRVCompatCheckKM(PVRSRV_BRIDGE_IN_COMPAT_CHECK *psUserModeDDKDetails, PVRSRV_BRIDGE_RETURN *psRetOUT) +{ + + if(psUserModeDDKDetails->ui32DDKVersion != ((PVRVERSION_MAJ << 16) | (PVRVERSION_MIN << 8)) + || (psUserModeDDKDetails->ui32DDKBuild != PVRVERSION_BUILD)) + { + psRetOUT->eError = PVRSRV_ERROR_DDK_VERSION_MISMATCH; + PVR_DPF((PVR_DBG_ERROR, "(FAIL) UM-KM DDK Mismatch UM-(%d) KM-(%d).", + psUserModeDDKDetails->ui32DDKBuild, PVRVERSION_BUILD)); + } + else + { + psRetOUT->eError = PVRSRV_OK; + PVR_DPF((PVR_DBG_MESSAGE, "UM DDK-(%d) and KM DDK-(%d) match. [ OK ]", + psUserModeDDKDetails->ui32DDKBuild ,PVRVERSION_BUILD)); + } +} /*! ****************************************************************************** @@ -207,8 +235,8 @@ IMG_UINT32 ReadHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset) IMG_EXPORT IMG_VOID WriteHWReg(IMG_PVOID pvLinRegBaseAddr, IMG_UINT32 ui32Offset, IMG_UINT32 ui32Value) { - PVR_DPF((PVR_DBG_MESSAGE,"WriteHWReg Base:%x, Offset: %x, Value %x", - (IMG_UINTPTR_T)pvLinRegBaseAddr,ui32Offset,ui32Value)); + PVR_DPF((PVR_DBG_MESSAGE,"WriteHWReg Base:%p, Offset: %x, Value %x", + pvLinRegBaseAddr,ui32Offset,ui32Value)); *(IMG_UINT32*)((IMG_UINTPTR_T)pvLinRegBaseAddr+ui32Offset) = ui32Value; } @@ -366,14 +394,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) { PVRSRV_ERROR eError; -#if defined(__linux__) - eError = PVRSRVCreateSysfsEntry(); - if (eError != PVRSRV_OK) - { - goto Error; - } -#endif - /* Initialise Resource Manager */ eError = ResManInit(); if (eError != PVRSRV_OK) @@ -406,16 +426,16 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) psSysData->eFailedPowerState = PVRSRV_SYS_POWER_STATE_Unspecified; /* Create an event object */ - if(OSAllocMem( PVRSRV_PAGEABLE_SELECT, + if((eError = OSAllocMem( PVRSRV_PAGEABLE_SELECT, sizeof(PVRSRV_EVENTOBJECT) , (IMG_VOID **)&psSysData->psGlobalEventObject, 0, - "Event Object") != PVRSRV_OK) + "Event Object")) != PVRSRV_OK) { goto Error; } - if(OSEventObjectCreateKM("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject) != PVRSRV_OK) + if((eError = OSEventObjectCreateKM("PVRSRV_GLOBAL_EVENTOBJECT", psSysData->psGlobalEventObject)) != PVRSRV_OK) { goto Error; } @@ -429,12 +449,21 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInit(PSYS_DATA psSysData) eError = PVRSRVTimeTraceInit(); if (eError != PVRSRV_OK) goto Error; - g_ui32InitFlags |= INIT_DATA_ENABLE_TTARCE; + g_ui32InitFlags |= INIT_DATA_ENABLE_TTRACE; #endif +#if defined(PDUMP) /* Initialise pdump */ PDUMPINIT(); g_ui32InitFlags |= INIT_DATA_ENABLE_PDUMPINIT; +#endif + +#if defined(SUPPORT_ION) + eError = PVRSRVInitDeviceMem(); + if (eError != PVRSRV_OK) + goto Error; + g_ui32InitFlags |= INIT_DATA_ENABLE_DEVMEM; +#endif PERFINIT(); return eError; @@ -472,19 +501,35 @@ IMG_VOID IMG_CALLCONV PVRSRVDeInit(PSYS_DATA psSysData) PERFDEINIT(); + +#if defined(SUPPORT_ION) + if ((g_ui32InitFlags & INIT_DATA_ENABLE_DEVMEM) > 0) + { + PVRSRVDeInitDeviceMem(); + } +#endif + +#if defined(MEM_TRACK_INFO_DEBUG) + /* Free the list of memory operations */ + PVRSRVFreeMemOps(); +#endif + #if defined(TTRACE) /* deinitialise ttrace */ - if ((g_ui32InitFlags & INIT_DATA_ENABLE_TTARCE) > 0) + if ((g_ui32InitFlags & INIT_DATA_ENABLE_TTRACE) > 0) { PVRSRVTimeTraceDeinit(); } #endif + +#if defined(PDUMP) /* deinitialise pdump */ if( (g_ui32InitFlags & INIT_DATA_ENABLE_PDUMPINIT) > 0) { PDUMPDEINIT(); } - +#endif + /* destroy event object */ if(psSysData->psGlobalEventObject) { @@ -1148,11 +1193,7 @@ 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; @@ -1338,16 +1379,10 @@ 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")); @@ -1361,9 +1396,6 @@ 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(); if(PVRSRVLookupHandle(psPerProc->psHandleBase, @@ -1375,7 +1407,6 @@ 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) { @@ -1389,12 +1420,15 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } else if(psMiscInfo->sCacheOpCtl.eCacheOpType == PVRSRV_MISC_INFO_CPUCACHEOP_CLEAN) { - if(!OSCleanCPUCacheRangeKM(psKernelMemInfo->sMemBlk.hOSMemHandle, - 0, - psMiscInfo->sCacheOpCtl.pvBaseVAddr, - psMiscInfo->sCacheOpCtl.ui32Length)) + if(psMiscInfo->sCacheOpCtl.ui32Length!=0) { - return PVRSRV_ERROR_CACHEOP_FAILED; + if(!OSCleanCPUCacheRangeKM(psKernelMemInfo->sMemBlk.hOSMemHandle, + 0, + psMiscInfo->sCacheOpCtl.pvBaseVAddr, + psMiscInfo->sCacheOpCtl.ui32Length)) + { + return PVRSRV_ERROR_CACHEOP_FAILED; + } } } } @@ -1402,16 +1436,11 @@ 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, @@ -1425,7 +1454,6 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } psMiscInfo->sGetRefCountCtl.ui32RefCount = psKernelMemInfo->ui32RefCount; -#endif } if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT) != 0UL) @@ -1442,11 +1470,13 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfoKM(PVRSRV_MISC_INFO *psMiscInfo) } #endif /* #if defined(PVRSRV_RESET_ON_HWTIMEOUT) */ +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) if ((psMiscInfo->ui32StateRequest & PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT) != 0UL) { - PVRSRVSetDCState(DC_STATE_FORCE_SWAP_TO_SYSTEM); + PVRSRVProcessQueues(IMG_TRUE); psMiscInfo->ui32StatePresent |= PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT; } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ return PVRSRV_OK; } @@ -1486,9 +1516,8 @@ IMG_BOOL IMG_CALLCONV PVRSRVDeviceLISR(PVRSRV_DEVICE_NODE *psDeviceNode) { bStatus = (*psDeviceNode->pfnDeviceISR)(psDeviceNode->pvISRData); } - if(!powering_down) { - SysClearInterrupts(psSysData, psDeviceNode->ui32SOCInterruptBit); - } + + SysClearInterrupts(psSysData, psDeviceNode->ui32SOCInterruptBit); } out: @@ -1605,11 +1634,13 @@ IMG_VOID IMG_CALLCONV PVRSRVMISR(IMG_VOID *pvSysData) List_PVRSRV_DEVICE_NODE_ForEach(psSysData->psDeviceNodeList, &PVRSRVMISR_ForEachCb); +#if defined(SUPPORT_PVRSRV_DEVICE_CLASS) /* Process the queues. */ if (PVRSRVProcessQueues(IMG_FALSE) == PVRSRV_ERROR_PROCESSING_BLOCKED) { PVRSRVProcessQueues(IMG_FALSE); } +#endif /* defined(SUPPORT_PVRSRV_DEVICE_CLASS) */ /* signal global event object */ if (psSysData->psGlobalEventObject) @@ -1706,7 +1737,11 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVSaveRestoreLiveSegments(IMG_HANDLE hArena, IMG_P return (PVRSRV_ERROR_OUT_OF_MEMORY); } - PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVSaveRestoreLiveSegments: Base %08x size %08x", sSegDetails.sCpuPhyAddr.uiAddr, sSegDetails.uiSize)); + PVR_DPF(( + PVR_DBG_MESSAGE, + "PVRSRVSaveRestoreLiveSegments: Base " CPUPADDR_FMT " size %" SIZE_T_FMT_LEN "x", + sSegDetails.sCpuPhyAddr.uiAddr, + sSegDetails.uiSize)); /* Map the device's local memory area onto the host. */ pvLocalMemCPUVAddr = OSMapPhysToLin(sSegDetails.sCpuPhyAddr, diff --git a/drivers/gpu/pvr/services4/srvkm/common/queue.c b/drivers/gpu/pvr/services4/srvkm/common/queue.c index 88b05a4c795..cddd6f9def5 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/queue.c +++ b/drivers/gpu/pvr/services4/srvkm/common/queue.c @@ -45,15 +45,47 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "lists.h" #include "ttrace.h" +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) +#include <linux/version.h> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) +#include <linux/sw_sync.h> +#else +#include <../drivers/staging/android/sw_sync.h> +#endif +static struct sync_fence *AllocQueueFence(struct sw_sync_timeline *psTimeline, IMG_UINT32 ui32FenceValue, const char *szName) +{ + struct sync_fence *psFence = IMG_NULL; + struct sync_pt *psPt; + + psPt = sw_sync_pt_create(psTimeline, ui32FenceValue); + if(psPt) + { + psFence = sync_fence_create(szName, psPt); + if(!psFence) + { + sync_pt_free(psPt); + } + } + + return psFence; +} +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + /* * The number of commands of each type which can be in flight at once. */ + +#define DC_MAX_SUPPORTED_QUEUES 1 #if defined(SUPPORT_DC_CMDCOMPLETE_WHEN_NO_LONGER_DISPLAYED) -#define DC_NUM_COMMANDS_PER_TYPE 2 +#define DC_NUM_COMMANDS_PER_QUEUE 2 #else -#define DC_NUM_COMMANDS_PER_TYPE 1 +#define DC_NUM_COMMANDS_PER_QUEUE 1 #endif +#define DC_NUM_COMMANDS_PER_TYPE (DC_NUM_COMMANDS_PER_QUEUE * DC_MAX_SUPPORTED_QUEUES) + +static IMG_UINT32 ui32NoOfSwapchainCreated = 0; + /* * List of private command processing function pointer tables and command * complete tables for a device in the system. @@ -87,8 +119,8 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el) { PVRSRV_QUEUE_INFO *psQueue = (PVRSRV_QUEUE_INFO*)el; IMG_INT cmds = 0; - IMG_SIZE_T ui32ReadOffset; - IMG_SIZE_T ui32WriteOffset; + IMG_SIZE_T uReadOffset; + IMG_SIZE_T uWriteOffset; PVRSRV_COMMAND *psCmd; if(el == PVR_PROC_SEQ_START_TOKEN) @@ -99,16 +131,16 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el) return; } - ui32ReadOffset = psQueue->ui32ReadOffset; - ui32WriteOffset = psQueue->ui32WriteOffset; + uReadOffset = psQueue->uReadOffset; + uWriteOffset = psQueue->uWriteOffset; - while (ui32ReadOffset != ui32WriteOffset) + while (uReadOffset != uWriteOffset) { - psCmd= (PVRSRV_COMMAND *)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + ui32ReadOffset); + psCmd= (PVRSRV_COMMAND *)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + uReadOffset); - seq_printf(sfile, "%x %x %5u %6u %3u %5u %2u %2u %3u \n", - (IMG_UINTPTR_T)psQueue, - (IMG_UINTPTR_T)psCmd, + seq_printf(sfile, "%p %p %5u %6u %3" SIZE_T_FMT_LEN "u %5u %2u %2u %3" SIZE_T_FMT_LEN "u \n", + psQueue, + psCmd, psCmd->ui32ProcessID, psCmd->CommandType, psCmd->uCmdSize, @@ -133,14 +165,14 @@ void ProcSeqShowQueue(struct seq_file *sfile,void* el) } /* taken from UPDATE_QUEUE_ROFF in queue.h */ - ui32ReadOffset += psCmd->uCmdSize; - ui32ReadOffset &= psQueue->ui32QueueSize - 1; + uReadOffset += psCmd->uCmdSize; + uReadOffset &= psQueue->uQueueSize - 1; cmds++; } if (cmds == 0) { - seq_printf(sfile, "%x <empty>\n", (IMG_UINTPTR_T)psQueue); + seq_printf(sfile, "%p <empty>\n", psQueue); } } @@ -181,15 +213,15 @@ void* ProcSeqOff2ElementQueue(struct seq_file * sfile, loff_t off) * Macro to return space in given command queue */ #define GET_SPACE_IN_CMDQ(psQueue) \ - ((((psQueue)->ui32ReadOffset - (psQueue)->ui32WriteOffset) \ - + ((psQueue)->ui32QueueSize - 1)) & ((psQueue)->ui32QueueSize - 1)) + ((((psQueue)->uReadOffset - (psQueue)->uWriteOffset) \ + + ((psQueue)->uQueueSize - 1)) & ((psQueue)->uQueueSize - 1)) /*! * Macro to Write Offset in given command queue */ -#define UPDATE_QUEUE_WOFF(psQueue, ui32Size) \ - (psQueue)->ui32WriteOffset = ((psQueue)->ui32WriteOffset + (ui32Size)) \ - & ((psQueue)->ui32QueueSize - 1); +#define UPDATE_QUEUE_WOFF(psQueue, uSize) \ + (psQueue)->uWriteOffset = ((psQueue)->uWriteOffset + (uSize)) \ + & ((psQueue)->uQueueSize - 1); /*! * Check if an ops complete value has gone past the pending value. @@ -227,7 +259,7 @@ IMG_UINT32 PVRSRVGetWriteOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOO Note: This needs to be atomic and is provided the kernel driver is single threaded (non-rentrant) */ - ui32WriteOpsPending = psSyncInfo->psSyncData->ui32WriteOpsPending++; + ui32WriteOpsPending = SyncTakeWriteOp(psSyncInfo, SYNC_OP_CLASS_QUEUE); } return ui32WriteOpsPending; @@ -254,7 +286,7 @@ IMG_UINT32 PVRSRVGetReadOpsPending(PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL if(bIsReadOp) { - ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOps2Pending++; + ui32ReadOpsPending = SyncTakeReadOp2(psSyncInfo, SYNC_OP_CLASS_QUEUE); } else { @@ -347,21 +379,21 @@ IMG_VOID QueueDumpDebugInfo(IMG_VOID) Kernel-side functions of User->Kernel transitions ******************************************************************************/ -static IMG_SIZE_T NearestPower2(IMG_SIZE_T ui32Value) +static IMG_SIZE_T NearestPower2(IMG_SIZE_T uValue) { - IMG_SIZE_T ui32Temp, ui32Result = 1; + IMG_SIZE_T uTemp, uResult = 1; - if(!ui32Value) + if(!uValue) return 0; - ui32Temp = ui32Value - 1; - while(ui32Temp) + uTemp = uValue - 1; + while(uTemp) { - ui32Result <<= 1; - ui32Temp >>= 1; + uResult <<= 1; + uTemp >>= 1; } - return ui32Result; + return uResult; } @@ -374,7 +406,7 @@ static IMG_SIZE_T NearestPower2(IMG_SIZE_T ui32Value) Creates a new command queue into which render/blt commands etc can be inserted. - @Input ui32QueueSize : + @Input uQueueSize : @Output ppsQueueInfo : @@ -382,15 +414,21 @@ static IMG_SIZE_T NearestPower2(IMG_SIZE_T ui32Value) ******************************************************************************/ IMG_EXPORT -PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, +PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T uQueueSize, PVRSRV_QUEUE_INFO **ppsQueueInfo) { PVRSRV_QUEUE_INFO *psQueueInfo; - IMG_SIZE_T ui32Power2QueueSize = NearestPower2(ui32QueueSize); + IMG_SIZE_T uPower2QueueSize = NearestPower2(uQueueSize); SYS_DATA *psSysData; PVRSRV_ERROR eError; IMG_HANDLE hMemBlock; + if (ui32NoOfSwapchainCreated >= DC_NUM_COMMANDS_PER_TYPE) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateCommandQueueKM: Swapchain already exists, increament DC_MAX_SUPPORTED_QUEUES to support more than one swapchain")); + return PVRSRV_ERROR_FLIP_CHAIN_EXISTS; + } + SysAcquireData(&psSysData); /* allocate an internal queue info structure */ @@ -410,7 +448,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, /* allocate the command queue buffer - allow for overrun */ eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - ui32Power2QueueSize + PVRSRV_MAX_CMD_SIZE, + uPower2QueueSize + PVRSRV_MAX_CMD_SIZE, &psQueueInfo->pvLinQueueKM, &hMemBlock, "Command Queue"); if (eError != PVRSRV_OK) @@ -423,10 +461,19 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, psQueueInfo->pvLinQueueUM = psQueueInfo->pvLinQueueKM; /* Sanity check: Should be zeroed by OSMemSet */ - PVR_ASSERT(psQueueInfo->ui32ReadOffset == 0); - PVR_ASSERT(psQueueInfo->ui32WriteOffset == 0); + PVR_ASSERT(psQueueInfo->uReadOffset == 0); + PVR_ASSERT(psQueueInfo->uWriteOffset == 0); + + psQueueInfo->uQueueSize = uPower2QueueSize; - psQueueInfo->ui32QueueSize = ui32Power2QueueSize; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + psQueueInfo->pvTimeline = sw_sync_timeline_create("pvr_queue_proc"); + if(psQueueInfo->pvTimeline == IMG_NULL) + { + PVR_DPF((PVR_DBG_ERROR,"PVRSRVCreateCommandQueueKM: sw_sync_timeline_create() failed")); + goto ErrorExit; + } +#endif /* if this is the first q, create a lock resource for the q list */ if (psSysData->psQueueList == IMG_NULL) @@ -457,6 +504,8 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateCommandQueueKM(IMG_SIZE_T ui32QueueSize, *ppsQueueInfo = psQueueInfo; + ui32NoOfSwapchainCreated++; + return PVRSRV_OK; ErrorExit: @@ -466,7 +515,7 @@ ErrorExit: if(psQueueInfo->pvLinQueueKM) { OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - psQueueInfo->ui32QueueSize, + psQueueInfo->uQueueSize, psQueueInfo->pvLinQueueKM, psQueueInfo->hMemBlock[1]); psQueueInfo->pvLinQueueKM = IMG_NULL; @@ -510,7 +559,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue /* PRQA S 3415,4109 1 */ /* macro format critical - leave alone */ LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) { - if(psQueueInfo->ui32ReadOffset == psQueueInfo->ui32WriteOffset) + if(psQueueInfo->uReadOffset == psQueueInfo->uWriteOffset) { bTimeout = IMG_FALSE; break; @@ -535,12 +584,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue goto ErrorExit; } + ui32NoOfSwapchainCreated--; + +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + sync_timeline_destroy(psQueueInfo->pvTimeline); +#endif + if(psQueue == psQueueInfo) { psSysData->psQueueList = psQueueInfo->psNextKM; OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - NearestPower2(psQueueInfo->ui32QueueSize) + PVRSRV_MAX_CMD_SIZE, + NearestPower2(psQueueInfo->uQueueSize) + PVRSRV_MAX_CMD_SIZE, psQueueInfo->pvLinQueueKM, psQueueInfo->hMemBlock[1]); psQueueInfo->pvLinQueueKM = IMG_NULL; @@ -560,7 +615,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyCommandQueueKM(PVRSRV_QUEUE_INFO *psQueue psQueue->psNextKM = psQueueInfo->psNextKM; OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, - psQueueInfo->ui32QueueSize, + psQueueInfo->uQueueSize, psQueueInfo->pvLinQueueKM, psQueueInfo->hMemBlock[1]); psQueueInfo->pvLinQueueKM = IMG_NULL; @@ -626,40 +681,26 @@ ErrorExit: *****************************************************************************/ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVGetQueueSpaceKM(PVRSRV_QUEUE_INFO *psQueue, - IMG_SIZE_T ui32ParamSize, + IMG_SIZE_T uParamSize, IMG_VOID **ppvSpace) { - IMG_BOOL bTimeout = IMG_TRUE; - /* round to 4byte units */ - ui32ParamSize = (ui32ParamSize+3) & 0xFFFFFFFC; + uParamSize = (uParamSize + 3) & 0xFFFFFFFC; - if (ui32ParamSize > PVRSRV_MAX_CMD_SIZE) + if (uParamSize > PVRSRV_MAX_CMD_SIZE) { PVR_DPF((PVR_DBG_WARNING,"PVRSRVGetQueueSpace: max command size is %d bytes", PVRSRV_MAX_CMD_SIZE)); return PVRSRV_ERROR_CMD_TOO_BIG; } - /* PRQA S 3415,4109 1 */ /* macro format critical - leave alone */ - LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US) - { - if (GET_SPACE_IN_CMDQ(psQueue) > ui32ParamSize) - { - bTimeout = IMG_FALSE; - break; - } - OSSleepms(1); - } END_LOOP_UNTIL_TIMEOUT(); - - if (bTimeout == IMG_TRUE) + if (GET_SPACE_IN_CMDQ(psQueue) > uParamSize) { - *ppvSpace = IMG_NULL; - - return PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE; + *ppvSpace = (IMG_VOID *)((IMG_UINTPTR_T)psQueue->pvLinQueueUM + psQueue->uWriteOffset); } else { - *ppvSpace = (IMG_VOID *)((IMG_UINTPTR_T)psQueue->pvLinQueueUM + psQueue->ui32WriteOffset); + *ppvSpace = IMG_NULL; + return PVRSRV_ERROR_CANNOT_GET_QUEUE_SPACE; } return PVRSRV_OK; @@ -695,17 +736,22 @@ 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 uDataByteSize, PFN_QUEUE_COMMAND_COMPLETE pfnCommandComplete, - IMG_HANDLE hCallbackData) + IMG_HANDLE hCallbackData, + IMG_HANDLE *phFence) { PVRSRV_ERROR eError; PVRSRV_COMMAND *psCommand; - IMG_SIZE_T ui32CommandSize; + IMG_SIZE_T uCommandSize; IMG_UINT32 i; SYS_DATA *psSysData; DEVICE_COMMAND_DATA *psDeviceCommandData; +#if !defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + PVR_UNREFERENCED_PARAMETER(phFence); +#endif + /* Check that we've got enough space in our command complete data for this command */ SysAcquireData(&psSysData); psDeviceCommandData = psSysData->apsDeviceCommandData[ui32DevIndex]; @@ -718,24 +764,63 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, } /* Round up to nearest 32 bit size so pointer arithmetic works */ - ui32DataByteSize = (ui32DataByteSize + 3UL) & ~3UL; + uDataByteSize = (uDataByteSize + 3UL) & ~3UL; /* calc. command size */ - ui32CommandSize = sizeof(PVRSRV_COMMAND) + uCommandSize = sizeof(PVRSRV_COMMAND) + ((ui32DstSyncCount + ui32SrcSyncCount) * sizeof(PVRSRV_SYNC_OBJECT)) - + ui32DataByteSize; + + uDataByteSize; /* wait for space in queue */ - eError = PVRSRVGetQueueSpaceKM (psQueue, ui32CommandSize, (IMG_VOID**)&psCommand); + eError = PVRSRVGetQueueSpaceKM (psQueue, uCommandSize, (IMG_VOID**)&psCommand); if(eError != PVRSRV_OK) { return eError; } +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + if(phFence != IMG_NULL) + { + struct sync_fence *psRetireFence, *psCleanupFence; + + /* New command? New timeline target */ + psQueue->ui32FenceValue++; + + psRetireFence = AllocQueueFence(psQueue->pvTimeline, psQueue->ui32FenceValue, "pvr_queue_retire"); + if(!psRetireFence) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVInsertCommandKM: sync_fence_create() failed")); + psQueue->ui32FenceValue--; + return PVRSRV_ERROR_INVALID_PARAMS; + } + + /* This similar to the retire fence, except that it is destroyed + * when a display command completes, rather than at the whim of + * userspace. It is used to keep the timeline alive. + */ + psCleanupFence = AllocQueueFence(psQueue->pvTimeline, psQueue->ui32FenceValue, "pvr_queue_cleanup"); + if(!psCleanupFence) + { + PVR_DPF((PVR_DBG_ERROR, "PVRSRVInsertCommandKM: sync_fence_create() #2 failed")); + sync_fence_put(psRetireFence); + psQueue->ui32FenceValue--; + return PVRSRV_ERROR_INVALID_PARAMS; + } + + psCommand->pvCleanupFence = psCleanupFence; + psCommand->pvTimeline = psQueue->pvTimeline; + *phFence = psRetireFence; + } + else + { + psCommand->pvTimeline = IMG_NULL; + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + psCommand->ui32ProcessID = OSGetCurrentProcessIDKM(); /* setup the command */ - psCommand->uCmdSize = ui32CommandSize; /* this may change if cmd shrinks */ + psCommand->uCmdSize = uCommandSize; /* this may change if cmd shrinks */ psCommand->ui32DevIndex = ui32DevIndex; psCommand->CommandType = CommandType; psCommand->ui32DstSyncCount = ui32DstSyncCount; @@ -752,7 +837,7 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVInsertCommandKM(PVRSRV_QUEUE_INFO *psQueue, + (ui32SrcSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); /* PRQA L:END_PTR_ASSIGNMENTS */ - psCommand->uDataSize = ui32DataByteSize;/* this may change if cmd shrinks */ + psCommand->uDataSize = uDataByteSize;/* this may change if cmd shrinks */ psCommand->pfnCommandComplete = pfnCommandComplete; psCommand->hCallbackData = hCallbackData; @@ -829,18 +914,18 @@ PVRSRV_ERROR IMG_CALLCONV PVRSRVSubmitCommandKM(PVRSRV_QUEUE_INFO *psQueue, if (psCommand->ui32DstSyncCount > 0) { psCommand->psDstSync = (PVRSRV_SYNC_OBJECT*)(((IMG_UINTPTR_T)psQueue->pvLinQueueKM) - + psQueue->ui32WriteOffset + sizeof(PVRSRV_COMMAND)); + + psQueue->uWriteOffset + sizeof(PVRSRV_COMMAND)); } if (psCommand->ui32SrcSyncCount > 0) { psCommand->psSrcSync = (PVRSRV_SYNC_OBJECT*)(((IMG_UINTPTR_T)psQueue->pvLinQueueKM) - + psQueue->ui32WriteOffset + sizeof(PVRSRV_COMMAND) + + psQueue->uWriteOffset + sizeof(PVRSRV_COMMAND) + (psCommand->ui32DstSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); } psCommand->pvData = (PVRSRV_SYNC_OBJECT*)(((IMG_UINTPTR_T)psQueue->pvLinQueueKM) - + psQueue->ui32WriteOffset + sizeof(PVRSRV_COMMAND) + + psQueue->uWriteOffset + sizeof(PVRSRV_COMMAND) + (psCommand->ui32DstSyncCount * sizeof(PVRSRV_SYNC_OBJECT)) + (psCommand->ui32SrcSyncCount * sizeof(PVRSRV_SYNC_OBJECT))); @@ -897,8 +982,8 @@ PVRSRV_ERROR CheckIfSyncIsQueued(PVRSRV_SYNC_OBJECT *psSync, COMMAND_COMPLETE_DA 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)); + "CheckIfSyncIsQueued: Stale syncops psSyncData:0x%p ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", + psSyncData, ui32WriteOpsComplete, psSync->ui32WriteOpsPending)); return PVRSRV_OK; } } @@ -979,8 +1064,8 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, SYNCOPS_STALE(ui32ReadOpsComplete, psWalkerObj->ui32ReadOps2Pending)) { PVR_DPF((PVR_DBG_WARNING, - "PVRSRVProcessCommand: Stale syncops psSyncData:0x%x ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", - (IMG_UINTPTR_T)psSyncData, ui32WriteOpsComplete, psWalkerObj->ui32WriteOpsPending)); + "PVRSRVProcessCommand: Stale syncops psSyncData:0x%p ui32WriteOpsComplete:0x%x ui32WriteOpsPending:0x%x", + psSyncData, ui32WriteOpsComplete, psWalkerObj->ui32WriteOpsPending)); } if (!bFlush || @@ -1047,6 +1132,11 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, psCmdCompleteData->pfnCommandComplete = psCommand->pfnCommandComplete; psCmdCompleteData->hCallbackData = psCommand->hCallbackData; +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + psCmdCompleteData->pvCleanupFence = psCommand->pvCleanupFence; + psCmdCompleteData->pvTimeline = psCommand->pvTimeline; +#endif + /* copy dst updates over */ psCmdCompleteData->ui32SrcSyncCount = psCommand->ui32SrcSyncCount; for (i=0; i<psCommand->ui32SrcSyncCount; i++) @@ -1082,10 +1172,13 @@ PVRSRV_ERROR PVRSRVProcessCommand(SYS_DATA *psSysData, */ psCmdCompleteData->bInUse = IMG_FALSE; eError = PVRSRV_ERROR_CMD_NOT_PROCESSED; + PVR_LOG(("Failed to submit command from queue processor, this could cause sync wedge!")); + } + else + { + /* Increment the CCB offset */ + psDeviceCommandData[psCommand->CommandType].ui32CCBOffset = (ui32CCBOffset + 1) % DC_NUM_COMMANDS_PER_TYPE; } - - /* Increment the CCB offset */ - psDeviceCommandData[psCommand->CommandType].ui32CCBOffset = (ui32CCBOffset + 1) % DC_NUM_COMMANDS_PER_TYPE; return eError; } @@ -1147,9 +1240,9 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_BOOL bFlush) while (psQueue) { - while (psQueue->ui32ReadOffset != psQueue->ui32WriteOffset) + while (psQueue->uReadOffset != psQueue->uWriteOffset) { - psCommand = (PVRSRV_COMMAND*)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + psQueue->ui32ReadOffset); + psCommand = (PVRSRV_COMMAND*)((IMG_UINTPTR_T)psQueue->pvLinQueueKM + psQueue->uReadOffset); if (PVRSRVProcessCommand(psSysData, psCommand, bFlush) == PVRSRV_OK) { @@ -1177,44 +1270,7 @@ PVRSRV_ERROR PVRSRVProcessQueues(IMG_BOOL bFlush) return PVRSRV_OK; } -#if defined(SUPPORT_CUSTOM_SWAP_OPERATIONS) -/*! -****************************************************************************** - - @Function PVRSRVCommandCompleteKM - - @Description Updates non-private command complete sync objects - - @Input hCmdCookie : command cookie - @Input bScheduleMISR : obsolete parameter - - @Return PVRSRV_ERROR - -******************************************************************************/ -IMG_INTERNAL -IMG_VOID PVRSRVFreeCommandCompletePacketKM(IMG_HANDLE hCmdCookie, - IMG_BOOL bScheduleMISR) -{ - COMMAND_COMPLETE_DATA *psCmdCompleteData = (COMMAND_COMPLETE_DATA *)hCmdCookie; - SYS_DATA *psSysData; - - PVR_UNREFERENCED_PARAMETER(bScheduleMISR); - - SysAcquireData(&psSysData); - - /* free command complete storage */ - psCmdCompleteData->bInUse = IMG_FALSE; - - /* FIXME: This may cause unrelated devices to be woken up. */ - PVRSRVScheduleDeviceCallbacks(); - - /* the MISR is always scheduled, regardless of bScheduleMISR */ - OSScheduleMISR(psSysData); -} - -#endif /* (SUPPORT_CUSTOM_SWAP_OPERATIONS) */ - -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) extern void sgxfreq_notif_sgx_frame_done(void); #endif /* (SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ @@ -1239,9 +1295,9 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie, COMMAND_COMPLETE_DATA *psCmdCompleteData = (COMMAND_COMPLETE_DATA *)hCmdCookie; SYS_DATA *psSysData; -#if defined(SYS_OMAP4_HAS_DVFS_FRAMEWORK) +#if defined(SYS_OMAP_HAS_DVFS_FRAMEWORK) sgxfreq_notif_sgx_frame_done(); -#endif /* (SYS_OMAP4_HAS_DVFS_FRAMEWORK) */ +#endif /* (SYS_OMAP_HAS_DVFS_FRAMEWORK) */ SysAcquireData(&psSysData); @@ -1292,6 +1348,14 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie, psCmdCompleteData->pfnCommandComplete(psCmdCompleteData->hCallbackData); } +#if defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) + if(psCmdCompleteData->pvTimeline) + { + sw_sync_timeline_inc(psCmdCompleteData->pvTimeline, 1); + sync_fence_put(psCmdCompleteData->pvCleanupFence); + } +#endif /* defined(PVR_ANDROID_NATIVE_WINDOW_HAS_SYNC) */ + /* free command complete storage */ psCmdCompleteData->bInUse = IMG_FALSE; @@ -1305,8 +1369,6 @@ IMG_VOID PVRSRVCommandCompleteKM(IMG_HANDLE hCmdCookie, } - - /*! ****************************************************************************** diff --git a/drivers/gpu/pvr/services4/srvkm/common/ra.c b/drivers/gpu/pvr/services4/srvkm/common/ra.c index f22c5baccd2..37c7176bc2a 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/ra.c +++ b/drivers/gpu/pvr/services4/srvkm/common/ra.c @@ -93,9 +93,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(__linux__) && defined(__KERNEL__) #include <linux/kernel.h> -#include "pvr_uaccess.h" #include "proc.h" -#include <linux/sched.h> #endif #ifdef USE_BM_FREESPACE_CHECK @@ -220,23 +218,13 @@ struct _RA_ARENA_ RA_STATISTICS sStatistics; #endif -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) #define PROC_NAME_SIZE 64 - struct proc_dir_entry* pProcInfo; - struct proc_dir_entry* pProcSegs; + struct pvr_proc_dir_entry* pProcInfo; + struct pvr_proc_dir_entry* pProcSegs; IMG_BOOL bInitProcEntry; - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - struct proc_dir_entry* pProcAllocFailThreshold; - - IMG_BOOL bFailAllocationOnce; - IMG_BOOL bFailAllocationPersist; - IMG_SIZE_T uAllocFailThreshold; - IMG_UINT32 uAllocFailMask; -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - #endif }; /* #define ENABLE_RA_DUMP 1 */ @@ -244,45 +232,19 @@ struct _RA_ARENA_ IMG_VOID RA_Dump (RA_ARENA *pArena); #endif -static INLINE IMG_BOOL RA_TestAllocationFail(RA_ARENA *pArena, IMG_SIZE_T size, IMG_UINT32 buff_type) -{ - #if defined (CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - if(pArena->bFailAllocationOnce == IMG_TRUE) - { - if((size > pArena->uAllocFailThreshold) && (pArena->uAllocFailMask & buff_type)) - { - if(pArena->bFailAllocationPersist == IMG_FALSE) - pArena->bFailAllocationOnce = IMG_FALSE; - return IMG_TRUE; - } - } - #endif //CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG - return IMG_FALSE; -} - -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) - +#if defined(CONFIG_PROC_FS) && defined(DEBUG) static void RA_ProcSeqShowInfo(struct seq_file *sfile, void* el); static void* RA_ProcSeqOff2ElementInfo(struct seq_file * sfile, loff_t off); static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el); static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off); - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) -static int RA_ProcSetAllocFailThreshold(struct file *file, const char __user *buffer, unsigned long count, void *data); -static void* RA_ProcSeqOff2AllocFailThreshold(struct seq_file * sfile, loff_t off); -static void RA_ProcSeqShowAllocFailThreshold(struct seq_file *sfile,void* el); -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - #endif /* defined(CONFIG_PROC_FS) && defined(DEBUG) */ -static PVRSRV_ERROR RA_DumpHeapInfo(RA_ARENA *pArena, IMG_UINT32 ui32DebugLevel); - #ifdef USE_BM_FREESPACE_CHECK IMG_VOID CheckBMFreespace(IMG_VOID); #endif -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) static IMG_CHAR *ReplaceSpaces(IMG_CHAR * const pS) { IMG_CHAR *pT; @@ -770,7 +732,7 @@ _InsertResourceSpan (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_SIZE_T uSize) } PVR_DPF ((PVR_DBG_MESSAGE, - "RA_InsertResourceSpan: arena='%s', base=0x%x, size=0x%x", + "RA_InsertResourceSpan: arena='%s', base=0x" UINTPTR_FMT ", size=0x%" SIZE_T_FMT_LEN "x", pArena->name, base, uSize)); pSpanStart = _BuildSpanMarker (base, uSize); @@ -1038,9 +1000,13 @@ _AttemptAllocAligned (RA_ARENA *pArena, else aligned_base = pBT->base; PVR_DPF ((PVR_DBG_MESSAGE, - "RA_AttemptAllocAligned: pBT-base=0x%x " - "pBT-size=0x%x alignedbase=0x%x size=0x%x", - pBT->base, pBT->uSize, aligned_base, uSize)); + "RA_AttemptAllocAligned: pBT-base=0x" UINTPTR_FMT " " + "pBT-size=0x%" SIZE_T_FMT_LEN "x alignedbase=0x" + UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", + pBT->base, + pBT->uSize, + aligned_base, + uSize)); if (pBT->base + pBT->uSize >= aligned_base + uSize) { @@ -1184,8 +1150,8 @@ RA_Create (IMG_CHAR *name, IMG_INT i; PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Create: name='%s', base=0x%x, uSize=0x%x, alloc=0x%x, free=0x%x", - name, base, uSize, (IMG_UINTPTR_T)imp_alloc, (IMG_UINTPTR_T)imp_free)); + "RA_Create: name='%s', base=0x" UINTPTR_FMT ", uSize=0x%" SIZE_T_FMT_LEN "x, alloc=0x%p, free=0x%p", + name, base, uSize, imp_alloc, imp_free)); if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, @@ -1208,22 +1174,30 @@ RA_Create (IMG_CHAR *name, pArena->uQuantum = uQuantum; #ifdef RA_STATS - OSMemSet(&pArena->sStatistics, 0x00, sizeof(pArena->sStatistics)); + pArena->sStatistics.uSpanCount = 0; + pArena->sStatistics.uLiveSegmentCount = 0; + pArena->sStatistics.uFreeSegmentCount = 0; + pArena->sStatistics.uFreeResourceCount = 0; + pArena->sStatistics.uTotalResourceCount = 0; + pArena->sStatistics.uCumulativeAllocs = 0; + pArena->sStatistics.uCumulativeFrees = 0; + pArena->sStatistics.uImportCount = 0; + pArena->sStatistics.uExportCount = 0; #endif -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) if(strcmp(pArena->name,"") != 0) { IMG_INT ret; IMG_CHAR szProcInfoName[PROC_NAME_SIZE]; IMG_CHAR szProcSegsName[PROC_NAME_SIZE]; - struct proc_dir_entry* (*pfnCreateProcEntrySeq)(const IMG_CHAR *, + struct pvr_proc_dir_entry* (*pfnCreateProcEntrySeq)(const IMG_CHAR *, IMG_VOID*, pvr_next_proc_seq_t, pvr_show_proc_seq_t, pvr_off2element_proc_seq_t, pvr_startstop_proc_seq_t, - write_proc_t); + pvr_proc_write_t); pArena->bInitProcEntry = !PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL); @@ -1243,7 +1217,7 @@ RA_Create (IMG_CHAR *name, } ret = snprintf(szProcSegsName, sizeof(szProcSegsName), "ra_segs_%s", pArena->name); - if (ret > 0 && ret < sizeof(szProcSegsName)) + if (ret > 0 && ret < sizeof(szProcInfoName)) { pArena->pProcSegs = pfnCreateProcEntrySeq(ReplaceSpaces(szProcSegsName), pArena, NULL, RA_ProcSeqShowRegs, RA_ProcSeqOff2ElementRegs, NULL, NULL); @@ -1253,27 +1227,8 @@ RA_Create (IMG_CHAR *name, pArena->pProcSegs = 0; PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_segs proc entry for arena %s", pArena->name)); } - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - pArena->uAllocFailThreshold = ~0; - pArena->uAllocFailMask = ~0; - pArena->bFailAllocationOnce = IMG_FALSE; - pArena->bFailAllocationPersist = IMG_FALSE; - - ret = snprintf(szProcSegsName, sizeof(szProcSegsName), "ra_fail_alloc_thld_%s", pArena->name); - if (ret > 0 && ret < sizeof(szProcSegsName)) - { - pArena->pProcAllocFailThreshold = pfnCreateProcEntrySeq(ReplaceSpaces(szProcSegsName), pArena, NULL, - RA_ProcSeqShowAllocFailThreshold, RA_ProcSeqOff2AllocFailThreshold, NULL, RA_ProcSetAllocFailThreshold); - } - else - { - pArena->pProcAllocFailThreshold = 0; - PVR_DPF((PVR_DBG_ERROR, "RA_Create: couldn't create ra_fail_alloc_thld proc entry for arena %s", pArena->name)); - } -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) } -#endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) */ +#endif /* defined(CONFIG_PROC_FS) && defined(DEBUG) */ pArena->pSegmentHash = HASH_Create (MINIMUM_HASH_SIZE); if (pArena->pSegmentHash==IMG_NULL) @@ -1339,8 +1294,8 @@ RA_Delete (RA_ARENA *pArena) if (pBT->type != btt_free) { PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: allocations still exist in the arena that is being destroyed")); - PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing allocations before destroying devmemcontext")); - PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x%x size=0x%x", pBT->base, pBT->uSize)); + PVR_DPF ((PVR_DBG_ERROR,"Likely Cause: client drivers not freeing alocations before destroying devmemcontext")); + PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", pBT->base, pBT->uSize)); } _SegmentListRemove (pArena, pBT); @@ -1350,9 +1305,9 @@ RA_Delete (RA_ARENA *pArena) pArena->sStatistics.uSpanCount--; #endif } -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) { - IMG_VOID (*pfnRemoveProcEntrySeq)(struct proc_dir_entry*); + IMG_VOID (*pfnRemoveProcEntrySeq)(struct pvr_proc_dir_entry*); pfnRemoveProcEntrySeq = pArena->bInitProcEntry ? RemoveProcEntrySeq : RemovePerProcessProcEntrySeq; @@ -1365,13 +1320,6 @@ RA_Delete (RA_ARENA *pArena) { pfnRemoveProcEntrySeq( pArena->pProcSegs ); } - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) - if(pArena->pProcAllocFailThreshold != 0) - { - pfnRemoveProcEntrySeq( pArena->pProcAllocFailThreshold ); - } -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) } #endif HASH_Delete (pArena->pSegmentHash); @@ -1403,7 +1351,7 @@ RA_TestDelete (RA_ARENA *pArena) if (pBT->type != btt_free) { PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: detected resource leak!")); - PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: base = 0x%x size=0x%x", pBT->base, pBT->uSize)); + PVR_DPF ((PVR_DBG_ERROR,"RA_TestDelete: base = 0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x", pBT->base, pBT->uSize)); return IMG_FALSE; } } @@ -1438,7 +1386,7 @@ RA_Add (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_SIZE_T uSize) } PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Add: name='%s', base=0x%x, size=0x%x", pArena->name, base, uSize)); + "RA_Add: name='%s', base=0x" UINTPTR_FMT ", size=0x%" SIZE_T_FMT_LEN "x", pArena->name, base, uSize)); uSize = (uSize + pArena->uQuantum - 1) / pArena->uQuantum * pArena->uQuantum; return ((IMG_BOOL)(_InsertResource (pArena, base, uSize) != IMG_NULL)); @@ -1479,8 +1427,7 @@ RA_Alloc (RA_ARENA *pArena, IMG_UINT32 ui32PrivDataLength, IMG_UINTPTR_T *base) { - IMG_BOOL bResult = IMG_FALSE; - IMG_BOOL bTestAllocFail = IMG_FALSE; + IMG_BOOL bResult; IMG_SIZE_T uSize = uRequestSize; PVR_ASSERT (pArena!=IMG_NULL); @@ -1505,101 +1452,85 @@ RA_Alloc (RA_ARENA *pArena, } PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Alloc: arena='%s', size=0x%x(0x%x), alignment=0x%x, offset=0x%x", + "RA_Alloc: arena='%s', size=0x%" SIZE_T_FMT_LEN "x(0x%" SIZE_T_FMT_LEN "x), alignment=0x%x, offset=0x%x", pArena->name, uSize, uRequestSize, uAlignment, uAlignmentOffset)); - bTestAllocFail = RA_TestAllocationFail(pArena, uSize, ~0); - if(!bTestAllocFail) + /* if allocation failed then we might have an import source which + can provide more resource, else we will have to fail the + allocation to the caller. */ + bResult = _AttemptAllocAligned (pArena, uSize, ppsMapping, uFlags, + uAlignment, uAlignmentOffset, base); + if (!bResult) { - /* if allocation failed then we might have an import source which - can provide more resource, else we will have to fail the - allocation to the caller. */ - bResult = _AttemptAllocAligned (pArena, uSize, ppsMapping, uFlags, - uAlignment, uAlignmentOffset, base); - if (!bResult) + BM_MAPPING *psImportMapping; + IMG_UINTPTR_T import_base; + IMG_SIZE_T uImportSize = uSize; + + /* + Ensure that we allocate sufficient space to meet the uAlignment + constraint + */ + if (uAlignment > pArena->uQuantum) { - BM_MAPPING *psImportMapping; - IMG_UINTPTR_T import_base; - IMG_SIZE_T uImportSize = uSize; + uImportSize += (uAlignment - 1); + } - /* - Ensure that we allocate sufficient space to meet the uAlignment - constraint - */ - if (uAlignment > pArena->uQuantum) + /* ensure that we import according to the quanta of this arena */ + uImportSize = ((uImportSize + pArena->uQuantum - 1)/pArena->uQuantum)*pArena->uQuantum; + + bResult = + pArena->pImportAlloc (pArena->pImportHandle, uImportSize, &uImportSize, + &psImportMapping, uFlags, + pvPrivData, ui32PrivDataLength, &import_base); + if (bResult) + { + BT *pBT; + pBT = _InsertResourceSpan (pArena, import_base, uImportSize); + /* successfully import more resource, create a span to + represent it and retry the allocation attempt */ + if (pBT == IMG_NULL) { - uImportSize += (uAlignment - 1); + /* insufficient resources to insert the newly acquired span, + so free it back again */ + pArena->pImportFree(pArena->pImportHandle, import_base, + psImportMapping); + PVR_DPF ((PVR_DBG_MESSAGE, + "RA_Alloc: name='%s', size=0x%" SIZE_T_FMT_LEN "x failed!", + pArena->name, uSize)); + /* RA_Dump (arena); */ + return IMG_FALSE; } - - /* ensure that we import according to the quanta of this arena */ - uImportSize = ((uImportSize + pArena->uQuantum - 1)/pArena->uQuantum)*pArena->uQuantum; - - bResult = - pArena->pImportAlloc (pArena->pImportHandle, uImportSize, &uImportSize, - &psImportMapping, uFlags, - pvPrivData, ui32PrivDataLength, &import_base); - if (bResult) + pBT->psMapping = psImportMapping; +#ifdef RA_STATS + pArena->sStatistics.uFreeSegmentCount++; + pArena->sStatistics.uFreeResourceCount += uImportSize; + pArena->sStatistics.uImportCount++; + pArena->sStatistics.uSpanCount++; +#endif + bResult = _AttemptAllocAligned(pArena, uSize, ppsMapping, uFlags, + uAlignment, uAlignmentOffset, + base); + if (!bResult) { - BT *pBT; - pBT = _InsertResourceSpan (pArena, import_base, uImportSize); - /* successfully import more resource, create a span to - represent it and retry the allocation attempt */ - if (pBT == IMG_NULL) - { - /* insufficient resources to insert the newly acquired span, - so free it back again */ - pArena->pImportFree(pArena->pImportHandle, import_base, - psImportMapping); - PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Alloc: name='%s', size=0x%x failed!", - pArena->name, uSize)); - /* RA_Dump (arena); */ - return IMG_FALSE; - } - pBT->psMapping = psImportMapping; - #ifdef RA_STATS - pArena->sStatistics.uFreeSegmentCount++; - pArena->sStatistics.uFreeResourceCount += uImportSize; - pArena->sStatistics.uImportCount++; - pArena->sStatistics.uSpanCount++; - #endif - bResult = _AttemptAllocAligned(pArena, uSize, ppsMapping, uFlags, - uAlignment, uAlignmentOffset, - base); - if (!bResult) - { - PVR_DPF ((PVR_DBG_ERROR, - "RA_Alloc: name='%s' uAlignment failed!", - pArena->name)); - } + PVR_DPF ((PVR_DBG_MESSAGE, + "RA_Alloc: name='%s' uAlignment failed!", + pArena->name)); } } - #ifdef RA_STATS - if (bResult) - pArena->sStatistics.uCumulativeAllocs++; - #endif } +#ifdef RA_STATS + if (bResult) + pArena->sStatistics.uCumulativeAllocs++; +#endif - PVR_DPF((PVR_DBG_MESSAGE, - "RA_Alloc: arena=%s, size=0x%x(0x%x), alignment=0x%x, "\ - "offset=0x%x, result=%d", - pArena->name, - uSize, uRequestSize, uAlignment, uAlignmentOffset, - bResult)); + PVR_DPF ((PVR_DBG_MESSAGE, + "RA_Alloc: name='%s', size=0x%" SIZE_T_FMT_LEN "x, *base=0x" UINTPTR_FMT " = %d", + pArena->name, uSize, *base, bResult)); /* RA_Dump (pArena); ra_stats (pArena); */ - if (!bResult) { - PVR_LOG(("RA_Alloc %s %s: arena=%s, size=0x%x(0x%x), "\ - "alignment=0x%x, offset=0x%x", - (bResult ? "SUCCESS" : "FAILED"), - (bTestAllocFail ? "in TEST_MODE!" : " "), - pArena->name, - uSize, uRequestSize, uAlignment, uAlignmentOffset)); - RA_DumpHeapInfo(pArena, ~0); - } #if defined(VALIDATE_ARENA_TEST) ValidateArena(pArena); #endif @@ -1653,8 +1584,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_END))) { /* error - next span must be live, free or end */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1666,8 +1603,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_END))) { /* error - next span must be live or end */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1680,8 +1623,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_END)) { /* error - next span cannot be live, free or end */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1694,16 +1643,28 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == IMPORTED_RESOURCE_SPAN_FREE))) { /* error - next span must be live or free */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } break; default: - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; break; @@ -1727,8 +1688,14 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == RESOURCE_SPAN_LIVE))) { /* error - next span must be free or live */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } @@ -1740,16 +1707,28 @@ IMG_UINT32 ValidateArena(RA_ARENA *pArena) (eNextSpan == RESOURCE_SPAN_LIVE))) { /* error - next span must be free or live */ - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; } break; default: - PVR_DPF((PVR_DBG_ERROR, "ValidateArena ERROR: adjacent boundary tags %d (base=0x%x) and %d (base=0x%x) are incompatible (arena: %s)", - pSegment->ui32BoundaryTagID, pSegment->base, pSegment->pNextSegment->ui32BoundaryTagID, pSegment->pNextSegment->base, pArena->name)); + PVR_DPF((PVR_DBG_ERROR, + "ValidateArena ERROR: adjacent boundary tags %d (base=0x" UINTPTR_FMT + ") and %d (base=0x" UINTPTR_FMT ") are incompatible (arena: %s)", + pSegment->ui32BoundaryTagID, + pSegment->base, + pSegment->pNextSegment->ui32BoundaryTagID, + pSegment->pNextSegment->base, + pArena->name)); PVR_DBG_BREAK; break; @@ -1801,7 +1780,7 @@ RA_Free (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_BOOL bFreeBackingStore) #endif PVR_DPF ((PVR_DBG_MESSAGE, - "RA_Free: name='%s', base=0x%x", pArena->name, base)); + "RA_Free: name='%s', base=0x" UINTPTR_FMT, pArena->name, base)); pBT = (BT *) HASH_Remove (pArena->pSegmentHash, base); PVR_ASSERT (pBT != IMG_NULL); @@ -1834,7 +1813,11 @@ RA_Free (RA_ARENA *pArena, IMG_UINTPTR_T base, IMG_BOOL bFreeBackingStore) { *p++ = 0xAA; } - PVR_DPF((PVR_DBG_MESSAGE,"BM_FREESPACE_CHECK: RA_Free Cleared %08X to %08X (size=0x%x)",(IMG_BYTE*)pBT->base + SysGetDevicePhysOffset(),endp-1,pBT->uSize)); + PVR_DPF((PVR_DBG_MESSAGE, + "BM_FREESPACE_CHECK: RA_Free Cleared %p to %p (size=0x%" SIZE_T_FMT_LEN "x)", + (IMG_BYTE*)pBT->base + SysGetDevicePhysOffset(), + endp - 1, + pBT->uSize)); } #endif _FreeBT (pArena, pBT, bFreeBackingStore); @@ -1934,7 +1917,7 @@ IMG_VOID CheckBMFreespace(IMG_VOID) #endif -#if (defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS)) || defined (RA_STATS) +#if (defined(CONFIG_PROC_FS) && defined(DEBUG)) || defined (RA_STATS) static IMG_CHAR * _BTType (IMG_INT eType) { @@ -1965,7 +1948,7 @@ RA_Dump (RA_ARENA *pArena) BT *pBT; PVR_ASSERT (pArena != IMG_NULL); PVR_DPF ((PVR_DBG_MESSAGE,"Arena '%s':", pArena->name)); - PVR_DPF ((PVR_DBG_MESSAGE," alloc=%08X free=%08X handle=%08X quantum=%d", + PVR_DPF ((PVR_DBG_MESSAGE," alloc=%p free=%p handle=%p quantum=%d", pArena->pImportAlloc, pArena->pImportFree, pArena->pImportHandle, pArena->uQuantum)); PVR_DPF ((PVR_DBG_MESSAGE," segment Chain:")); @@ -1978,8 +1961,8 @@ RA_Dump (RA_ARENA *pArena) for (pBT=pArena->pHeadSegment; pBT!=IMG_NULL; pBT=pBT->pNextSegment) { - PVR_DPF ((PVR_DBG_MESSAGE,"\tbase=0x%x size=0x%x type=%s", - (IMG_UINT32) pBT->base, pBT->uSize, _BTType (pBT->type))); + PVR_DPF ((PVR_DBG_MESSAGE,"\tbase=0x" UINTPTR_FMT " size=0x%" SIZE_T_FMT_LEN "x type=%s", + pBT->base, pBT->uSize, _BTType (pBT->type))); } #ifdef HASH_TRACE @@ -1988,259 +1971,48 @@ RA_Dump (RA_ARENA *pArena) } #endif /* #if defined(ENABLE_RA_DUMP) */ -static PVRSRV_ERROR RA_DumpHeapInfo(RA_ARENA *pArena, IMG_UINT32 ui32DebugLevel) -{ - BT *pBT; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) - { - IMG_UINT32 ui32PID = OSGetCurrentProcessIDKM(); - IMG_CHAR dirname_buffer[256]; - IMG_CHAR dirname[256]; - const IMG_CHAR *proc_basename = dirname_buffer; - dirname_buffer[255] = dirname[255] = '\0'; - - OSGetProcCmdline(ui32PID, dirname_buffer, sizeof(dirname_buffer)); - PVR_LOG(("\nCommand Line of the current process with ID %u is %s", ui32PID, dirname_buffer)); - - proc_basename = OSGetPathBaseName(dirname_buffer, sizeof(dirname_buffer)); - PVR_LOG(("Base Name of the current process with ID %u is %s", ui32PID, proc_basename)); - - } -#endif - - PVR_LOG(("Arena '%s':", pArena->name)); - - PVR_LOG(( " allocCB=%p freeCB=%p handle=%p quantum=%d", - pArena->pImportAlloc, - pArena->pImportFree, - pArena->pImportHandle, - pArena->uQuantum)); - - PVR_LOG(( "span count\t\t%u", pArena->sStatistics.uSpanCount)); - - PVR_LOG(( "live segment count\t%u", pArena->sStatistics.uLiveSegmentCount)); - - PVR_LOG(( "free segment count\t%u", pArena->sStatistics.uFreeSegmentCount)); - - PVR_LOG(( "free resource count\t%u (0x%x)", - pArena->sStatistics.uFreeResourceCount, - (IMG_UINT)pArena->sStatistics.uFreeResourceCount)); - - PVR_LOG(( "total allocs\t\t%u", pArena->sStatistics.uCumulativeAllocs)); - - PVR_LOG(( "total failed allocs\t%u", pArena->sStatistics.uFailedAllocCount)); - - PVR_LOG(( "total frees\t\t%u", pArena->sStatistics.uCumulativeFrees)); - PVR_LOG(( "import count\t\t%u", pArena->sStatistics.uImportCount)); - - PVR_LOG(( "export count\t\t%u", pArena->sStatistics.uExportCount)); - - PVR_LOG(( " segment Chain:")); - - if (pArena->pHeadSegment != IMG_NULL && - pArena->pHeadSegment->pPrevSegment != IMG_NULL) - { - PVR_LOG(( " error: head boundary tag has invalid pPrevSegment")); - } - - if (pArena->pTailSegment != IMG_NULL && - pArena->pTailSegment->pNextSegment != IMG_NULL) - { - PVR_LOG(( " error: tail boundary tag has invalid pNextSegment")); - } - - for (pBT=pArena->pHeadSegment; pBT!=IMG_NULL; pBT=pBT->pNextSegment) - { - PVR_LOG(( "%s base=0x%08x size=%08d(0x%08x) type=%s ref=%p", - ((pBT->type == btt_span) ? "\t\t" : "\t"), - (IMG_UINT32) pBT->base, - pBT->uSize, pBT->uSize, - _BTType(pBT->type), - pBT->psMapping)); - if(pBT->psMapping) - { - BM_MAPPING *psImportMapping = pBT->psMapping; - PVR_LOG(( "\t %p: mapping type %s, mapping count=%d, size=%08d(0x%08x), flags=0x%08x, align=0x%04x", - psImportMapping, - _BMMappingType(psImportMapping->eCpuMemoryOrigin), - psImportMapping->ui32MappingCount, - psImportMapping->uSize, psImportMapping->uSize, - psImportMapping->ui32Flags, - psImportMapping->ui32DevVAddrAlignment)); - } - } - - return PVRSRV_OK; -} - -#if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_PROC_FS) - -#if defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) -#define _PROC_SET_ALLOC_TH_BUFFER_SZ 32 -static int RA_ProcSetAllocFailThreshold(struct file *file, const char __user *buffer, unsigned long count, void *data) -{ - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)data; - RA_ARENA *pArena; - IMG_CHAR data_buffer[_PROC_SET_ALLOC_TH_BUFFER_SZ]; - IMG_INT32 value = ~0; - IMG_UINT32 mask = ~0; - IMG_INT32 format_ret; - - if ((handlers == NULL) || (handlers->data == NULL) || (count > sizeof(data_buffer))) - { - return -EINVAL; - } - - pArena = (RA_ARENA *)handlers->data; - - count = MIN(count, sizeof(data_buffer)); - - if (pvr_copy_from_user(data_buffer, buffer, count)) - return -EINVAL; - - if (data_buffer[count - 1] != '\n') - return -EINVAL; - - data_buffer[(sizeof(data_buffer) - 1)] = '\0'; - if((sizeof(data_buffer) -1) <= count) - data_buffer[count] = '\0'; - - PVR_LOG(("Buffer from the user is %s\n", data_buffer)); - format_ret = sscanf(data_buffer, "%i:0x%x", &value, &mask); - PVR_LOG(("Value set is %i, type is %x, format %i\n", value, mask, format_ret)); - if(format_ret <= 0) - return -EINVAL; - -/* - Heap Allocation Buffer Threshold Setting - for testing purposes only - Causes allocation of a GFX buffer of type MASK for the respective heap to - fail. - Format is <threshold value number>:<buffer type mask hex value> - for example: 1000:0x01. - Value of -1 disables the allocation fail test - Value bigger than and eq. to 0 enables the allocation fail test for - the first buffer only. - Value smaller than -1 enables the buffer allocation failure for this - heap until the test disables it. -*/ - if(value < 0) - { - if(value == -1) - { - pArena->bFailAllocationPersist = pArena->bFailAllocationOnce = IMG_FALSE; - } - else if(value == -2) - { - RA_DumpHeapInfo(pArena, ~0); - } - else - { - pArena->bFailAllocationPersist = pArena->bFailAllocationOnce = IMG_TRUE; - pArena->uAllocFailThreshold = -value; - } - } - else - { - pArena->bFailAllocationPersist = 0; - pArena->bFailAllocationOnce = 1; - pArena->uAllocFailThreshold = value; - } - - if(format_ret > 1) - { - if((pArena->bFailAllocationOnce == IMG_TRUE) && (mask == 0)) - pArena->uAllocFailMask = ~0; - else - pArena->uAllocFailMask = mask; - } - PVR_LOG(("*************** User Fail Heap Allocation Settings for %s *******************************\n", - pArena->name)); - PVR_LOG(("Fail Heap Allocation is %s in %s mode\n", (pArena->bFailAllocationOnce ? "Enabled": "Disabled"), - (pArena->bFailAllocationPersist ? "Persistent": "One-Shot"))); - PVR_LOG(("Fail Heap Allocation Buffer Size Threshold is %u with a Mask of 0x%x\n", - pArena->uAllocFailThreshold, pArena->uAllocFailMask)); - PVR_LOG(("*******************************************************************************************\n")); - return (count); -} - -static void* RA_ProcSeqOff2AllocFailThreshold(struct seq_file * sfile, loff_t off) -{ - - if(off <= 1) - return (void*)(IMG_INT)(off+1); - - return 0; -} - -static void RA_ProcSeqShowAllocFailThreshold(struct seq_file *sfile,void* el) -{ - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; - IMG_INT off = (IMG_INT)el; - - switch (off) - { - case 1: - seq_printf(sfile, "Heap Allocation Buffer Threshold Setting - for testing purposes only\n"); - seq_printf(sfile, "Format is <threshold value number>:<buffer type mask hex value> for example: 1000:0x01\n"); - seq_printf(sfile, "Value of -1 disables the allocation fail test\n"); - seq_printf(sfile, "Value of -2 dumps the heap entries to the kernel log\n"); - seq_printf(sfile, "Value => 0 enables the allocation fail test for the first buffer with the met threshold only\n"); - seq_printf(sfile, "Value < -2 enables the buffer allocation failure for this heap until the test disables it\n"); - break; - case 2: - seq_printf(sfile, "*********** Current Settings: ********************\n"); - seq_printf(sfile,"Fail Heap Allocation is %s in %s mode\n", (pArena->bFailAllocationOnce ? "Enabled": "Disabled"), - (pArena->bFailAllocationPersist ? "Persistent": "One-Shot")); - seq_printf(sfile, "Fail Heap Allocation Buffer Size Threshold is %u with a Mask of 0x%x\n", - pArena->uAllocFailThreshold, pArena->uAllocFailMask); - break; - } -} -#endif //defined(CONFIG_PVR_PROC_FS_HEAP_ALLOC_DEBUG) +#if defined(CONFIG_PROC_FS) && defined(DEBUG) static void RA_ProcSeqShowInfo(struct seq_file *sfile, void* el) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; - IMG_INT off = (IMG_INT)el; + RA_ARENA *pArena = (RA_ARENA *)PVRProcGetData(sfile->private); + IMG_UINTPTR_T off = (IMG_UINTPTR_T)el; switch (off) { case 1: - seq_printf(sfile, "quantum\t\t\t%u\n", pArena->uQuantum); + seq_printf(sfile, "quantum\t\t\t%" SIZE_T_FMT_LEN "u\n", pArena->uQuantum); break; case 2: - seq_printf(sfile, "import_handle\t\t%08X\n", (IMG_UINT)pArena->pImportHandle); + seq_printf(sfile, "import_handle\t\t%p\n", pArena->pImportHandle); break; #ifdef RA_STATS case 3: - seq_printf(sfile,"span count\t\t%u\n", pArena->sStatistics.uSpanCount); + seq_printf(sfile,"span count\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uSpanCount); break; case 4: - seq_printf(sfile, "live segment count\t%u\n", pArena->sStatistics.uLiveSegmentCount); + seq_printf(sfile, "live segment count\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uLiveSegmentCount); break; case 5: - seq_printf(sfile, "free segment count\t%u\n", pArena->sStatistics.uFreeSegmentCount); + seq_printf(sfile, "free segment count\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uFreeSegmentCount); break; case 6: - seq_printf(sfile, "free resource count\t%u (0x%x)\n", + seq_printf(sfile, "free resource count\t%" SIZE_T_FMT_LEN "u (0x%" SIZE_T_FMT_LEN "x)\n", pArena->sStatistics.uFreeResourceCount, - (IMG_UINT)pArena->sStatistics.uFreeResourceCount); + pArena->sStatistics.uFreeResourceCount); break; case 7: - seq_printf(sfile, "total allocs\t\t%u\n", pArena->sStatistics.uCumulativeAllocs); + seq_printf(sfile, "total allocs\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uCumulativeAllocs); break; case 8: - seq_printf(sfile, "total frees\t\t%u\n", pArena->sStatistics.uCumulativeFrees); + seq_printf(sfile, "total frees\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uCumulativeFrees); break; case 9: - seq_printf(sfile, "import count\t\t%u\n", pArena->sStatistics.uImportCount); + seq_printf(sfile, "import count\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uImportCount); break; case 10: - seq_printf(sfile, "export count\t\t%u\n", pArena->sStatistics.uExportCount); + seq_printf(sfile, "export count\t\t%" SIZE_T_FMT_LEN "u\n", pArena->sStatistics.uExportCount); break; #endif } @@ -2254,14 +2026,13 @@ static void* RA_ProcSeqOff2ElementInfo(struct seq_file * sfile, loff_t off) #else if(off <= 1) #endif - return (void*)(IMG_INT)(off+1); + return (void*)(IMG_UINTPTR_T)(off+1); return 0; } static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; + RA_ARENA *pArena = (RA_ARENA *)PVRProcGetData(sfile->private); BT *pBT = (BT*)el; if (el == PVR_PROC_SEQ_START_TOKEN) @@ -2272,16 +2043,15 @@ static void RA_ProcSeqShowRegs(struct seq_file *sfile, void* el) if (pBT) { - seq_printf(sfile, "%08x %8x %4s %08x\n", - (IMG_UINT)pBT->base, (IMG_UINT)pBT->uSize, _BTType (pBT->type), - (IMG_UINT)pBT->psMapping); + seq_printf(sfile, "%p %" SIZE_T_FMT_LEN "x %4s %p\n", + (IMG_PVOID)pBT->base, pBT->uSize, _BTType (pBT->type), + pBT->psMapping); } } static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off) { - PVR_PROC_SEQ_HANDLERS *handlers = (PVR_PROC_SEQ_HANDLERS*)sfile->private; - RA_ARENA *pArena = (RA_ARENA *)handlers->data; + RA_ARENA *pArena = (RA_ARENA *)PVRProcGetData(sfile->private); BT *pBT = 0; if(off == 0) @@ -2291,7 +2061,6 @@ static void* RA_ProcSeqOff2ElementRegs(struct seq_file * sfile, loff_t off) return (void*)pBT; } - #endif /* defined(CONFIG_PROC_FS) && defined(DEBUG) */ @@ -2323,7 +2092,7 @@ PVRSRV_ERROR RA_GetStats(RA_ARENA *pArena, CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, " allocCB=%p freeCB=%p handle=%p quantum=%d\n", + i32Count = OSSNPrintf(pszStr, 100, " allocCB=%p freeCB=%p handle=%p quantum=%" SIZE_T_FMT_LEN "u\n", pArena->pImportAlloc, pArena->pImportFree, pArena->pImportHandle, @@ -2331,37 +2100,44 @@ PVRSRV_ERROR RA_GetStats(RA_ARENA *pArena, UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "span count\t\t%u\n", pArena->sStatistics.uSpanCount); + i32Count = OSSNPrintf(pszStr, 100, "span count\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uSpanCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "live segment count\t%u\n", pArena->sStatistics.uLiveSegmentCount); + i32Count = OSSNPrintf(pszStr, 100, "live segment count\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uLiveSegmentCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "free segment count\t%u\n", pArena->sStatistics.uFreeSegmentCount); + i32Count = OSSNPrintf(pszStr, 100, "free segment count\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uFreeSegmentCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "free resource count\t%u (0x%x)\n", + i32Count = OSSNPrintf(pszStr, 100, "free resource count\t%" SIZE_T_FMT_LEN "u (0x%" SIZE_T_FMT_LEN "x)\n", pArena->sStatistics.uFreeResourceCount, - (IMG_UINT)pArena->sStatistics.uFreeResourceCount); + pArena->sStatistics.uFreeResourceCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "total allocs\t\t%u\n", pArena->sStatistics.uCumulativeAllocs); + i32Count = OSSNPrintf(pszStr, 100, "total allocs\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uCumulativeAllocs); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "total frees\t\t%u\n", pArena->sStatistics.uCumulativeFrees); + i32Count = OSSNPrintf(pszStr, 100, "total frees\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uCumulativeFrees); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "import count\t\t%u\n", pArena->sStatistics.uImportCount); + i32Count = OSSNPrintf(pszStr, 100, "import count\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uImportCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "export count\t\t%u\n", pArena->sStatistics.uExportCount); + i32Count = OSSNPrintf(pszStr, 100, "export count\t\t%" SIZE_T_FMT_LEN "u\n", + pArena->sStatistics.uExportCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); CHECK_SPACE(ui32StrLen); @@ -2387,8 +2163,8 @@ PVRSRV_ERROR RA_GetStats(RA_ARENA *pArena, for (pBT=pArena->pHeadSegment; pBT!=IMG_NULL; pBT=pBT->pNextSegment) { CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "\tbase=0x%x size=0x%x type=%s ref=%p\n", - (IMG_UINT32) pBT->base, + i32Count = OSSNPrintf(pszStr, 100, "\tbase=0x%p size=0x%" SIZE_T_FMT_LEN "x type=%s ref=%p\n", + (void *)pBT->base, pBT->uSize, _BTType(pBT->type), pBT->psMapping); @@ -2409,7 +2185,7 @@ PVRSRV_ERROR RA_GetStatsFreeMem(RA_ARENA *pArena, IMG_UINT32 ui32StrLen = *pui32StrLen; IMG_INT32 i32Count; CHECK_SPACE(ui32StrLen); - i32Count = OSSNPrintf(pszStr, 100, "Bytes free: Arena %-30s: %u (0x%x)\n", pArena->name, + i32Count = OSSNPrintf(pszStr, 100, "Bytes free: Arena %-30s: %" SIZE_T_FMT_LEN "u (0x%" SIZE_T_FMT_LEN "x)\n", pArena->name, pArena->sStatistics.uFreeResourceCount, pArena->sStatistics.uFreeResourceCount); UPDATE_SPACE(pszStr, i32Count, ui32StrLen); diff --git a/drivers/gpu/pvr/services4/srvkm/common/refcount.c b/drivers/gpu/pvr/services4/srvkm/common/refcount.c index fa64b234f43..a6dcb197566 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/refcount.c +++ b/drivers/gpu/pvr/services4/srvkm/common/refcount.c @@ -71,9 +71,11 @@ static DEFINE_SPINLOCK(gsCCBLock); #if defined(__linux__) #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP (1U << 16) #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 (1U << 17) +#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC (1U << 18) #else #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP 0 #define PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2 0 +#define PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC 0 #endif #define PVRSRV_REFCOUNT_CCB_DEBUG_ALL ~0U @@ -81,6 +83,9 @@ static DEFINE_SPINLOCK(gsCCBLock); /*static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_ALL;*/ static const IMG_UINT guiDebugMask = PVRSRV_REFCOUNT_CCB_DEBUG_SYNCINFO | +#if defined(SUPPORT_ION) + PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC | +#endif PVRSRV_REFCOUNT_CCB_DEBUG_MMAP2; typedef struct @@ -120,7 +125,7 @@ void PVRSRVDumpRefCountCCB(void) /* Early on, we won't have MAX_REFCOUNT_CCB_SIZE messages */ if(!psRefCountCCBEntry->pszFile) - break; + continue; PVR_LOG(("%s %d %s:%d", psRefCountCCBEntry->pcMesg, psRefCountCCBEntry->ui32PID, @@ -477,7 +482,7 @@ void PVRSRVOffsetStructIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32RefCount, psOffsetStruct->ui32RefCount + 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -509,7 +514,7 @@ void PVRSRVOffsetStructDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32RefCount, psOffsetStruct->ui32RefCount - 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -541,7 +546,7 @@ void PVRSRVOffsetStructIncMapped2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32Mapped, psOffsetStruct->ui32Mapped + 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -573,7 +578,7 @@ void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine, psOffsetStruct, psOffsetStruct->ui32Mapped, psOffsetStruct->ui32Mapped - 1, - psOffsetStruct->ui32RealByteSize); + psOffsetStruct->uiRealByteSize); gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; @@ -583,6 +588,88 @@ skip: psOffsetStruct->ui32Mapped--; } +#if defined(SUPPORT_ION) +PVRSRV_ERROR PVRSRVIonBufferSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine, + IMG_HANDLE hUnique, + IMG_HANDLE hDevCookie, + IMG_HANDLE hDevMemContext, + PVRSRV_ION_SYNC_INFO **ppsIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) +{ + PVRSRV_ERROR eError; + + /* + We have to do the call 1st as we need to Ion syninfo which it returns + */ + eError = PVRSRVIonBufferSyncAcquire(hUnique, + hDevCookie, + hDevMemContext, + ppsIonSyncInfo); + + if (eError == PVRSRV_OK) + { + if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC)) + goto skip; + + PVRSRV_LOCK_CCB(); + + gsRefCountCCB[giOffset].pszFile = pszFile; + gsRefCountCCB[giOffset].iLine = iLine; + gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM(); + snprintf(gsRefCountCCB[giOffset].pcMesg, + PVRSRV_REFCOUNT_CCB_MESG_MAX - 1, + PVRSRV_REFCOUNT_CCB_FMT_STRING, + "ION_SYNC", + (*ppsIonSyncInfo)->psSyncInfo, + psKernelMemInfo, + NULL, + *ppsIonSyncInfo, + (*ppsIonSyncInfo)->ui32RefCount - 1, + (*ppsIonSyncInfo)->ui32RefCount, + 0); + gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; + giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; + + PVRSRV_UNLOCK_CCB(); + } + +skip: + return eError; +} + +void PVRSRVIonBufferSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine, + PVRSRV_ION_SYNC_INFO *psIonSyncInfo, + PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo) +{ + if(!(guiDebugMask & PVRSRV_REFCOUNT_CCB_DEBUG_ION_SYNC)) + goto skip; + + PVRSRV_LOCK_CCB(); + + gsRefCountCCB[giOffset].pszFile = pszFile; + gsRefCountCCB[giOffset].iLine = iLine; + gsRefCountCCB[giOffset].ui32PID = OSGetCurrentProcessIDKM(); + snprintf(gsRefCountCCB[giOffset].pcMesg, + PVRSRV_REFCOUNT_CCB_MESG_MAX - 1, + PVRSRV_REFCOUNT_CCB_FMT_STRING, + "ION_SYNC", + psIonSyncInfo->psSyncInfo, + psKernelMemInfo, + NULL, + psIonSyncInfo, + psIonSyncInfo->ui32RefCount, + psIonSyncInfo->ui32RefCount - 1, + 0); + gsRefCountCCB[giOffset].pcMesg[PVRSRV_REFCOUNT_CCB_MESG_MAX - 1] = 0; + giOffset = (giOffset + 1) % PVRSRV_REFCOUNT_CCB_MAX; + + PVRSRV_UNLOCK_CCB(); +skip: + PVRSRVIonBufferSyncRelease(psIonSyncInfo); +} + +#endif /* defined (SUPPORT_ION) */ + #endif /* defined(__linux__) */ #endif /* defined(PVRSRV_REFCOUNT_DEBUG) */ diff --git a/drivers/gpu/pvr/services4/srvkm/common/resman.c b/drivers/gpu/pvr/services4/srvkm/common/resman.c index aef102f98b7..1bb3ebf449c 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/resman.c +++ b/drivers/gpu/pvr/services4/srvkm/common/resman.c @@ -359,11 +359,12 @@ IMG_VOID PVRSRVResManDisconnect(PRESMAN_CONTEXT psResManContext, FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_MAPPING, 0, 0, IMG_TRUE); FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_KERNEL_DEVICEMEM_ALLOCATION, 0, 0, IMG_TRUE); 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); #if defined(SUPPORT_ION) FreeResourceByCriteria(psResManContext, RESMAN_CRITERIA_RESTYPE, RESMAN_TYPE_DEVICEMEM_ION, 0, 0, IMG_TRUE); #endif + 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); + /* DISPLAY CLASS types: */ 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); @@ -436,13 +437,13 @@ PRESMAN_ITEM ResManRegisterRes(PRESMAN_CONTEXT psResManContext, VALIDATERESLIST(); PVR_DPF((PVR_DBG_MESSAGE, "ResManRegisterRes: register resource " - "Context 0x%x, ResType 0x%x, pvParam 0x%x, ui32Param 0x%x, " - "FreeFunc %08X", - (IMG_UINTPTR_T)psResManContext, + "Context 0x%p, ResType 0x%x, pvParam 0x%p, ui32Param 0x%x, " + "FreeFunc %p", + psResManContext, ui32ResType, - (IMG_UINTPTR_T)pvParam, + pvParam, ui32Param, - (IMG_UINTPTR_T)pfnFreeResource)); + pfnFreeResource)); /* Allocate memory for the new resource structure */ if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, @@ -504,8 +505,8 @@ PVRSRV_ERROR ResManFreeResByPtr(RESMAN_ITEM *psResItem, IMG_BOOL bForceCleanup) return PVRSRV_OK; } - PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByPtr: freeing resource at %08X", - (IMG_UINTPTR_T)psResItem)); + PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByPtr: freeing resource at %p", + psResItem)); /*Acquire resource list sync object*/ ACQUIRE_SYNC_OBJ; @@ -558,9 +559,9 @@ PVRSRV_ERROR ResManFreeResByCriteria(PRESMAN_CONTEXT psResManContext, VALIDATERESLIST(); PVR_DPF((PVR_DBG_MESSAGE, "ResManFreeResByCriteria: " - "Context 0x%x, Criteria 0x%x, Type 0x%x, Addr 0x%x, Param 0x%x", - (IMG_UINTPTR_T)psResManContext, ui32SearchCriteria, ui32ResType, - (IMG_UINTPTR_T)pvParam, ui32Param)); + "Context 0x%p, Criteria 0x%x, Type 0x%x, Addr 0x%p, Param 0x%x", + psResManContext, ui32SearchCriteria, ui32ResType, + pvParam, ui32Param)); /* Free resources by criteria for this context */ eError = FreeResourceByCriteria(psResManContext, ui32SearchCriteria, @@ -688,17 +689,17 @@ IMG_INTERNAL PVRSRV_ERROR ResManFindResourceByPtr(PRESMAN_CONTEXT psResManContex ACQUIRE_SYNC_OBJ; PVR_DPF((PVR_DBG_MESSAGE, - "FindResourceByPtr: psItem=%08X, psItem->psNext=%08X", - (IMG_UINTPTR_T)psItem, (IMG_UINTPTR_T)psItem->psNext)); + "FindResourceByPtr: psItem=%p, psItem->psNext=%p", + psItem, psItem->psNext)); PVR_DPF((PVR_DBG_MESSAGE, - "FindResourceByPtr: Resource Ctx 0x%x, Type 0x%x, Addr 0x%x, " - "Param 0x%x, FnCall %08X, Flags 0x%x", - (IMG_UINTPTR_T)psResManContext, + "FindResourceByPtr: Resource Ctx 0x%p, Type 0x%x, Addr 0x%p, " + "Param 0x%x, FnCall %p, Flags 0x%x", + psResManContext, psItem->ui32ResType, - (IMG_UINTPTR_T)psItem->pvParam, + psItem->pvParam, psItem->ui32Param, - (IMG_UINTPTR_T)psItem->pfnFreeResource, + psItem->pfnFreeResource, psItem->ui32Flags)); /* Search resource items starting at after the first dummy item */ @@ -754,15 +755,16 @@ static PVRSRV_ERROR FreeResourceByPtr(RESMAN_ITEM *psItem, #endif PVR_DPF((PVR_DBG_MESSAGE, - "FreeResourceByPtr: psItem=%08X, psItem->psNext=%08X", - (IMG_UINTPTR_T)psItem, (IMG_UINTPTR_T)psItem->psNext)); + "FreeResourceByPtr: psItem=%p, psItem->psNext=%p", + psItem, psItem->psNext)); PVR_DPF((PVR_DBG_MESSAGE, - "FreeResourceByPtr: Type 0x%x, Addr 0x%x, " - "Param 0x%x, FnCall %08X, Flags 0x%x", + "FreeResourceByPtr: Type 0x%x, Addr 0x%p, " + "Param 0x%x, FnCall %p, Flags 0x%x", psItem->ui32ResType, - (IMG_UINTPTR_T)psItem->pvParam, psItem->ui32Param, - (IMG_UINTPTR_T)psItem->pfnFreeResource, psItem->ui32Flags)); + psItem->pvParam, + psItem->ui32Param, + psItem->pfnFreeResource, psItem->ui32Flags)); /* Release resource list sync object just in case the free routine calls the resource manager */ RELEASE_SYNC_OBJ; @@ -941,11 +943,11 @@ static IMG_VOID ValidateResList(PRESMAN_LIST psResList) if (psCurContext->ppsThis != ppsThisContext) { PVR_DPF((PVR_DBG_WARNING, - "psCC=%08X psCC->ppsThis=%08X psCC->psNext=%08X ppsTC=%08X", - (IMG_UINTPTR_T)psCurContext, - (IMG_UINTPTR_T)psCurContext->ppsThis, - (IMG_UINTPTR_T)psCurContext->psNext, - (IMG_UINTPTR_T)ppsThisContext)); + "psCC=%p psCC->ppsThis=%p psCC->psNext=%p ppsTC=%p", + psCurContext, + psCurContext->ppsThis, + psCurContext->psNext, + ppsThisContext)); PVR_ASSERT(psCurContext->ppsThis == ppsThisContext); } @@ -959,11 +961,11 @@ static IMG_VOID ValidateResList(PRESMAN_LIST psResList) if (psCurItem->ppsThis != ppsThisItem) { PVR_DPF((PVR_DBG_WARNING, - "psCurItem=%08X psCurItem->ppsThis=%08X psCurItem->psNext=%08X ppsThisItem=%08X", - (IMG_UINTPTR_T)psCurItem, - (IMG_UINTPTR_T)psCurItem->ppsThis, - (IMG_UINTPTR_T)psCurItem->psNext, - (IMG_UINTPTR_T)ppsThisItem)); + "psCurItem=%p psCurItem->ppsThis=%p psCurItem->psNext=%p ppsThisItem=%p", + psCurItem, + psCurItem->ppsThis, + psCurItem->psNext, + ppsThisItem)); PVR_ASSERT(psCurItem->ppsThis == ppsThisItem); } diff --git a/drivers/gpu/pvr/services4/srvkm/common/ttrace.c b/drivers/gpu/pvr/services4/srvkm/common/ttrace.c index 574bf25c315..d1dd7882db7 100644..100755 --- a/drivers/gpu/pvr/services4/srvkm/common/ttrace.c +++ b/drivers/gpu/pvr/services4/srvkm/common/ttrace.c @@ -123,7 +123,7 @@ PVRSRVTimeTraceAllocItem(IMG_UINT32 **pui32Item, IMG_UINT32 ui32Size) { PVRSRV_ERROR eError; - PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVTimeTraceAllocItem: Creating buffer for PID %u", (IMG_UINT32) ui32PID)); + PVR_DPF((PVR_DBG_MESSAGE, "PVRSRVTimeTraceAllocItem: Creating buffer for PID %u", ui32PID)); eError = PVRSRVTimeTraceBufferCreate(ui32PID); if (eError != PVRSRV_OK) { @@ -171,7 +171,7 @@ PVRSRVTimeTraceAllocItem(IMG_UINT32 **pui32Item, IMG_UINT32 ui32Size) psBuffer->ui32Woff = psBuffer->ui32Woff + ui32Size; psBuffer->ui32ByteCount += ui32Size; - /* This allocation will start overwritting past our read pointer, move the read pointer along */ + /* This allocation will start overwriting past our read pointer, move the read pointer along */ while (psBuffer->ui32ByteCount > TIME_TRACE_BUFFER_SIZE) { IMG_UINT32 *psReadItem = (IMG_UINT32 *) &psBuffer->ui8Data[psBuffer->ui32Roff]; @@ -248,6 +248,7 @@ PVRSRV_ERROR PVRSRVTimeTraceBufferCreate(IMG_UINT32 ui32PID) ******************************************************************************/ PVRSRV_ERROR PVRSRVTimeTraceBufferDestroy(IMG_UINT32 ui32PID) { +#if !defined(TTRACE_KEEP_BUFFER_ON_EXIT) sTimeTraceBuffer *psBuffer; #if defined(DUMP_TTRACE_BUFFERS_ON_EXIT) @@ -264,6 +265,9 @@ PVRSRV_ERROR PVRSRVTimeTraceBufferDestroy(IMG_UINT32 ui32PID) PVR_DPF((PVR_DBG_ERROR, "PVRSRVTimeTraceBufferDestroy: Can't find trace buffer in hash table")); return PVRSRV_ERROR_INVALID_PARAMS; +#else + return PVRSRV_OK; +#endif } /*! @@ -535,7 +539,7 @@ static PVRSRV_ERROR PVRSRVDumpTimeTraceBuffer(IMG_UINTPTR_T hKey, IMG_UINTPTR_T IMG_UINT32 ui32Walker = psBuffer->ui32Roff; IMG_UINT32 ui32Read, ui32LineLen, ui32EOL, ui32MinLine; - PVR_DPF((PVR_DBG_ERROR, "TTB for PID %u:\n", (IMG_UINT32) hKey)); + PVR_LOG(("TTB for PID %u:\n", (IMG_UINT32) hKey)); while (ui32ByteCount) { @@ -547,25 +551,25 @@ static PVRSRV_ERROR PVRSRVDumpTimeTraceBuffer(IMG_UINTPTR_T hKey, IMG_UINTPTR_T if (ui32MinLine >= 4) { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X %08X %08X %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X %08X %08X %08X [", ui32ByteCount, pui32Buffer[0], pui32Buffer[1], pui32Buffer[2], pui32Buffer[3])); ui32Read = 4 * sizeof(IMG_UINT32); } else if (ui32MinLine >= 3) { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X %08X %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X %08X %08X [", ui32ByteCount, pui32Buffer[0], pui32Buffer[1], pui32Buffer[2])); ui32Read = 3 * sizeof(IMG_UINT32); } else if (ui32MinLine >= 2) { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X %08X [", ui32ByteCount, pui32Buffer[0], pui32Buffer[1])); ui32Read = 2 * sizeof(IMG_UINT32); } else { - PVR_DPF((PVR_DBG_ERROR, "\t(TTB-%X) %08X", ui32ByteCount, + PVR_LOG(("\t(TTB-%X) %08X [", ui32ByteCount, pui32Buffer[0])); ui32Read = sizeof(IMG_UINT32); } |