From 60aa803dc76bbdfac72da4de4cdc3018717b0884 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 30 Nov 2009 20:02:05 +0000 Subject: [PATCH] intel: Only store a buffer in the cache if it is retained. If the kernel immediately frees the backing store for a buffer when marking it purgeable, then there is not point adding to the cache. Free it immediately, instead. Signed-off-by: Chris Wilson --- intel/intel_bufmgr_gem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 9db7bfeb..9cf354b0 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -742,7 +742,9 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time) /* Put the buffer into our internal cache for reuse if we can. */ tiling_mode = I915_TILING_NONE; if (bufmgr_gem->bo_reuse && bo_gem->reusable && bucket != NULL && - drm_intel_gem_bo_set_tiling(bo, &tiling_mode, 0) == 0) { + drm_intel_gem_bo_set_tiling(bo, &tiling_mode, 0) == 0 && + drm_intel_gem_bo_madvise_internal(bufmgr_gem, bo_gem, + I915_MADV_DONTNEED)) { bo_gem->free_time = time; bo_gem->name = NULL; @@ -751,8 +753,6 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time) DRMLISTADDTAIL(&bo_gem->head, &bucket->head); - drm_intel_gem_bo_madvise_internal(bufmgr_gem, bo_gem, - I915_MADV_DONTNEED); drm_intel_gem_cleanup_bo_cache(bufmgr_gem, time); } else { drm_intel_gem_bo_free(bo); @@ -928,7 +928,7 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo) pthread_mutex_unlock(&bufmgr_gem->lock); - return 0; + return ret; } int drm_intel_gem_bo_unmap_gtt(drm_intel_bo *bo)