IMG_VOID RA_Delete (RA_ARENA *pArena) { IMG_UINT32 uIndex; PVR_ASSERT(pArena != IMG_NULL); if (pArena == IMG_NULL) { PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: invalid parameter - pArena")); return; } PVR_DPF ((PVR_DBG_MESSAGE, "RA_Delete: name='%s'", pArena->name)); for (uIndex=0; uIndex<FREE_TABLE_LIMIT; uIndex++) pArena->aHeadFree[uIndex] = IMG_NULL; while (pArena->pHeadSegment != IMG_NULL) { BT *pBT = pArena->pHeadSegment; 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 alocations before destroying devmemcontext")); PVR_DPF ((PVR_DBG_ERROR,"RA_Delete: base = 0x%x size=0x%x", pBT->base, pBT->uSize)); } _SegmentListRemove (pArena, pBT); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(BT), pBT, IMG_NULL); #ifdef RA_STATS pArena->sStatistics.uSpanCount--; #endif } #if defined(CONFIG_PROC_FS) && defined(DEBUG) { IMG_VOID (*pfnRemoveProcEntrySeq)(struct proc_dir_entry*); pfnRemoveProcEntrySeq = pArena->bInitProcEntry ? RemoveProcEntrySeq : RemovePerProcessProcEntrySeq; if (pArena->pProcInfo != 0) { pfnRemoveProcEntrySeq( pArena->pProcInfo ); } if (pArena->pProcSegs != 0) { pfnRemoveProcEntrySeq( pArena->pProcSegs ); } } #endif HASH_Delete (pArena->pSegmentHash); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(RA_ARENA), pArena, IMG_NULL); }
void RA_Delete(struct RA_ARENA *pArena) { u32 uIndex; PVR_ASSERT(pArena != NULL); if (pArena == NULL) { PVR_DPF(PVR_DBG_ERROR, "RA_Delete: invalid parameter - pArena"); return; } PVR_DPF(PVR_DBG_MESSAGE, "RA_Delete: name='%s'", pArena->name); for (uIndex = 0; uIndex < FREE_TABLE_LIMIT; uIndex++) pArena->aHeadFree[uIndex] = NULL; while (pArena->pHeadSegment != NULL) { struct BT *pBT = pArena->pHeadSegment; PVR_ASSERT(pBT->type == btt_free); _SegmentListRemove(pArena, pBT); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BT), pBT, NULL); #ifdef RA_STATS pArena->sStatistics.uSpanCount--; #endif } #if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_DEBUG_EXTRA) { void (*pfnRemoveProcEntry) (const char *); pfnRemoveProcEntry = pArena-> bInitProcEntry ? RemoveProcEntry : RemovePerProcessProcEntry; if (pArena->szProcInfoName[0] != 0) pfnRemoveProcEntry(pArena->szProcInfoName); if (pArena->szProcSegsName[0] != 0) pfnRemoveProcEntry(pArena->szProcSegsName); } #endif HASH_Delete(pArena->pSegmentHash); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct RA_ARENA), pArena, NULL); }
static void _FreeBT(struct RA_ARENA *pArena, struct BT *pBT, IMG_BOOL bFreeBackingStore) { struct BT *pNeighbour; u32 uOrigBase; size_t uOrigSize; PVR_ASSERT(pArena != NULL); PVR_ASSERT(pBT != NULL); if ((pArena == NULL) || (pBT == NULL)) { PVR_DPF(PVR_DBG_ERROR, "_FreeBT: invalid parameter"); return; } #ifdef RA_STATS pArena->sStatistics.uLiveSegmentCount--; pArena->sStatistics.uFreeSegmentCount++; pArena->sStatistics.uFreeResourceCount += pBT->uSize; #endif uOrigBase = pBT->base; uOrigSize = pBT->uSize; pNeighbour = pBT->pPrevSegment; if (pNeighbour != NULL && pNeighbour->type == btt_free && pNeighbour->base + pNeighbour->uSize == pBT->base) { _FreeListRemove(pArena, pNeighbour); _SegmentListRemove(pArena, pNeighbour); pBT->base = pNeighbour->base; pBT->uSize += pNeighbour->uSize; OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BT), pNeighbour, NULL); #ifdef RA_STATS pArena->sStatistics.uFreeSegmentCount--; #endif } pNeighbour = pBT->pNextSegment; if (pNeighbour != NULL && pNeighbour->type == btt_free && pBT->base + pBT->uSize == pNeighbour->base) { _FreeListRemove(pArena, pNeighbour); _SegmentListRemove(pArena, pNeighbour); pBT->uSize += pNeighbour->uSize; OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BT), pNeighbour, NULL); #ifdef RA_STATS pArena->sStatistics.uFreeSegmentCount--; #endif } if (pArena->pBackingStoreFree != NULL && bFreeBackingStore) { u32 uRoundedStart, uRoundedEnd; uRoundedStart = (uOrigBase / pArena->uQuantum) * pArena->uQuantum; if (uRoundedStart < pBT->base) uRoundedStart += pArena->uQuantum; uRoundedEnd = ((uOrigBase + uOrigSize + pArena->uQuantum - 1) / pArena->uQuantum) * pArena->uQuantum; if (uRoundedEnd > (pBT->base + pBT->uSize)) uRoundedEnd -= pArena->uQuantum; if (uRoundedStart < uRoundedEnd) pArena->pBackingStoreFree(pArena->pImportHandle, uRoundedStart, uRoundedEnd, (void *) 0); } if (pBT->pNextSegment != NULL && pBT->pNextSegment->type == btt_span && pBT->pPrevSegment != NULL && pBT->pPrevSegment->type == btt_span) { struct BT *next = pBT->pNextSegment; struct BT *prev = pBT->pPrevSegment; _SegmentListRemove(pArena, next); _SegmentListRemove(pArena, prev); _SegmentListRemove(pArena, pBT); pArena->pImportFree(pArena->pImportHandle, pBT->base, pBT->psMapping); #ifdef RA_STATS pArena->sStatistics.uSpanCount--; pArena->sStatistics.uExportCount++; pArena->sStatistics.uFreeSegmentCount--; pArena->sStatistics.uFreeResourceCount -= pBT->uSize; pArena->sStatistics.uTotalResourceCount -= pBT->uSize; #endif OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BT), next, NULL); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BT), prev, NULL); OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct BT), pBT, NULL); } else _FreeListInsert(pArena, pBT); }