From: Luc Verhaegen Date: Fri, 11 Mar 2011 14:02:22 +0000 (+0100) Subject: gpu: pvr: pdump: consolidate some code inside PDUMP defines X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3700f6d76e3cfb3fc2a6b669e54d8ddb10167f27;p=sgx.git gpu: pvr: pdump: consolidate some code inside PDUMP defines No functional changes. Signed-off-by: Luc Verhaegen Signed-off-by: Imre Deak --- diff --git a/pvr/buffer_manager.c b/pvr/buffer_manager.c index 8f1190c..a4109b4 100644 --- a/pvr/buffer_manager.c +++ b/pvr/buffer_manager.c @@ -1090,21 +1090,10 @@ static IMG_BOOL DevMemoryAlloc(struct BM_CONTEXT *pBMContext, struct BM_MAPPING *pMapping, u32 uFlags, u32 dev_vaddr_alignment, struct IMG_DEV_VIRTADDR *pDevVAddr) { - struct PVRSRV_DEVICE_NODE *psDeviceNode; -#ifdef PDUMP - u32 ui32PDumpSize = pMapping->uSize; -#endif - - psDeviceNode = pBMContext->psDeviceNode; + struct PVRSRV_DEVICE_NODE *psDeviceNode = pBMContext->psDeviceNode; if (uFlags & PVRSRV_MEM_INTERLEAVED) - pMapping->uSize *= 2; -#ifdef PDUMP - if (uFlags & PVRSRV_MEM_DUMMY) - - ui32PDumpSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; -#endif if (!psDeviceNode->pfnMMUAlloc(pMapping->pBMHeap->pMMUHeap, pMapping->uSize, 0, dev_vaddr_alignment, @@ -1113,11 +1102,21 @@ static IMG_BOOL DevMemoryAlloc(struct BM_CONTEXT *pBMContext, return IMG_FALSE; } - PDUMPMALLOCPAGES(psDeviceNode->sDevId.eDeviceType, - pMapping->DevVAddr.uiAddr, pMapping->CpuVAddr, - pMapping->hOSMemHandle, ui32PDumpSize, - pMapping->pBMHeap->sDevArena.ui32DataPageSize, - (void *)pMapping); +#ifdef PDUMP + { + u32 ui32PDumpSize = pMapping->uSize; + + if (uFlags & PVRSRV_MEM_DUMMY) + ui32PDumpSize = + pMapping->pBMHeap->sDevArena.ui32DataPageSize; + + PDUMPMALLOCPAGES(psDeviceNode->sDevId.eDeviceType, + pMapping->DevVAddr.uiAddr, pMapping->CpuVAddr, + pMapping->hOSMemHandle, ui32PDumpSize, + pMapping->pBMHeap->sDevArena.ui32DataPageSize, + (void *)pMapping); + } +#endif switch (pMapping->eCpuMemoryOrigin) { case hm_wrapped: @@ -1176,9 +1175,6 @@ static void DevMemoryFree(struct BM_MAPPING *pMapping) struct PVRSRV_DEVICE_NODE *psDeviceNode; #ifdef PDUMP u32 ui32PSize; -#endif - -#ifdef PDUMP if (pMapping->ui32Flags & PVRSRV_MEM_DUMMY) ui32PSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; diff --git a/pvr/mmu.c b/pvr/mmu.c index 2f54255..ed7b111 100644 --- a/pvr/mmu.c +++ b/pvr/mmu.c @@ -72,13 +72,6 @@ struct MMU_HEAP { struct DEV_ARENA_DESCRIPTOR *psDevArena; }; - -#if defined(PDUMP) -static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, - struct IMG_DEV_VIRTADDR DevVAddr, size_t uSize, - IMG_BOOL bForUnmap, void *hUniqueTag); -#endif - #define PAGE_TEST 0 @@ -698,6 +691,58 @@ void MMU_InsertHeap(struct MMU_CONTEXT *psMMUContext, MMU_InvalidateDirectoryCache(psMMUContext->psDevInfo); } +#if defined(PDUMP) +static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, + struct IMG_DEV_VIRTADDR DevVAddr, + size_t uSize, IMG_BOOL bForUnmap, void *hUniqueTag) +{ + u32 ui32NumPTEntries; + u32 ui32PTIndex; + u32 *pui32PTEntry; + + struct MMU_PT_INFO **ppsPTInfoList; + u32 ui32PDIndex; + u32 ui32PTDumpCount; + + ui32NumPTEntries = + (uSize + SGX_MMU_PAGE_SIZE - 1) >> SGX_MMU_PAGE_SHIFT; + + ui32PDIndex = + DevVAddr.uiAddr >> (SGX_MMU_PAGE_SHIFT + SGX_MMU_PT_SHIFT); + + ppsPTInfoList = &pMMUHeap->psMMUContext->apsPTInfoList[ui32PDIndex]; + + ui32PTIndex = (DevVAddr.uiAddr & SGX_MMU_PT_MASK) >> SGX_MMU_PAGE_SHIFT; + + PDUMPCOMMENT("Page table mods (num entries == %08X) %s", + ui32NumPTEntries, bForUnmap ? "(for unmap)" : ""); + + while (ui32NumPTEntries > 0) { + struct MMU_PT_INFO *psPTInfo = *ppsPTInfoList++; + + if (ui32NumPTEntries <= 1024 - ui32PTIndex) + ui32PTDumpCount = ui32NumPTEntries; + else + ui32PTDumpCount = 1024 - ui32PTIndex; + + if (psPTInfo) { + pui32PTEntry = (u32 *)psPTInfo->PTPageCpuVAddr; + PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, + (void *)&pui32PTEntry[ui32PTIndex], + ui32PTDumpCount * sizeof(u32), 0, + IMG_FALSE, PDUMP_PT_UNIQUETAG, hUniqueTag); + } + + ui32NumPTEntries -= ui32PTDumpCount; + + ui32PTIndex = 0; + } + + PDUMPCOMMENT("Finished page table mods %s", + bForUnmap ? "(for unmap)" : ""); +} +#endif + static void MMU_UnmapPagesAndFreePTs(struct MMU_HEAP *psMMUHeap, struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32PageCount, void *hUniqueTag) @@ -948,58 +993,6 @@ void MMU_Disable(struct MMU_HEAP *pMMUHeap) } -#if defined(PDUMP) -static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, - struct IMG_DEV_VIRTADDR DevVAddr, - size_t uSize, IMG_BOOL bForUnmap, void *hUniqueTag) -{ - u32 ui32NumPTEntries; - u32 ui32PTIndex; - u32 *pui32PTEntry; - - struct MMU_PT_INFO **ppsPTInfoList; - u32 ui32PDIndex; - u32 ui32PTDumpCount; - - ui32NumPTEntries = - (uSize + SGX_MMU_PAGE_SIZE - 1) >> SGX_MMU_PAGE_SHIFT; - - ui32PDIndex = - DevVAddr.uiAddr >> (SGX_MMU_PAGE_SHIFT + SGX_MMU_PT_SHIFT); - - ppsPTInfoList = &pMMUHeap->psMMUContext->apsPTInfoList[ui32PDIndex]; - - ui32PTIndex = (DevVAddr.uiAddr & SGX_MMU_PT_MASK) >> SGX_MMU_PAGE_SHIFT; - - PDUMPCOMMENT("Page table mods (num entries == %08X) %s", - ui32NumPTEntries, bForUnmap ? "(for unmap)" : ""); - - while (ui32NumPTEntries > 0) { - struct MMU_PT_INFO *psPTInfo = *ppsPTInfoList++; - - if (ui32NumPTEntries <= 1024 - ui32PTIndex) - ui32PTDumpCount = ui32NumPTEntries; - else - ui32PTDumpCount = 1024 - ui32PTIndex; - - if (psPTInfo) { - pui32PTEntry = (u32 *)psPTInfo->PTPageCpuVAddr; - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - (void *)&pui32PTEntry[ui32PTIndex], - ui32PTDumpCount * sizeof(u32), 0, - IMG_FALSE, PDUMP_PT_UNIQUETAG, hUniqueTag); - } - - ui32NumPTEntries -= ui32PTDumpCount; - - ui32PTIndex = 0; - } - - PDUMPCOMMENT("Finished page table mods %s", - bForUnmap ? "(for unmap)" : ""); -} -#endif - static void MMU_MapPage(struct MMU_HEAP *pMMUHeap, struct IMG_DEV_VIRTADDR DevVAddr, struct IMG_DEV_PHYADDR DevPAddr, u32 ui32MemFlags) diff --git a/pvr/pdump_km.h b/pvr/pdump_km.h index 958c333..1f2a498 100644 --- a/pvr/pdump_km.h +++ b/pvr/pdump_km.h @@ -37,10 +37,6 @@ #define PDUMP_PD_UNIQUETAG ((void *)0) #define PDUMP_PT_UNIQUETAG ((void *)0) -#ifndef PDUMP -#define MAKEUNIQUETAG(hMemInfo) (0) -#endif - #ifdef PDUMP #define MAKEUNIQUETAG(hMemInfo) \ @@ -222,6 +218,9 @@ void PDumpResumeKM(void); #define PDUMPRESUME PDumpResumeKM #else + +#define MAKEUNIQUETAG(hMemInfo) (0) + #define PDUMPMEMPOL(args...) #define PDUMPMEM(args...) #define PDUMPMEM2(args...)