diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2009-11-20 17:09:03 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2009-11-20 17:09:03 -0500 |
commit | 10ce0ec18806ae32a5d615c693626a085b0dd7b8 (patch) | |
tree | 0511e492b1235ef8d45cb7997035421c409a26b5 /intel | |
parent | 1b064cc428f03f753699d4d9fbe60453891a8529 (diff) | |
parent | b4312b639d56a6cad78953af0fd4f863182007e3 (diff) | |
download | libdrm-10ce0ec18806ae32a5d615c693626a085b0dd7b8.tar.gz libdrm-10ce0ec18806ae32a5d615c693626a085b0dd7b8.tar.bz2 libdrm-10ce0ec18806ae32a5d615c693626a085b0dd7b8.zip |
Merge remote branch 'origin/master' into libdrm
Diffstat (limited to 'intel')
-rw-r--r-- | intel/intel_bufmgr.c | 7 | ||||
-rw-r--r-- | intel/intel_bufmgr.h | 1 | ||||
-rw-r--r-- | intel/intel_bufmgr_gem.c | 22 | ||||
-rw-r--r-- | intel/intel_bufmgr_priv.h | 14 |
4 files changed, 38 insertions, 6 deletions
diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c index 2469cd84..61817739 100644 --- a/intel/intel_bufmgr.c +++ b/intel/intel_bufmgr.c @@ -224,6 +224,13 @@ int drm_intel_bo_busy(drm_intel_bo *bo) return 0; } +int drm_intel_bo_madvise(drm_intel_bo *bo, int madv) +{ + if (bo->bufmgr->bo_madvise) + return bo->bufmgr->bo_madvise(bo, madv); + return -1; +} + int drm_intel_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo) { return bo->bufmgr->bo_references(bo, target_bo); diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h index 3801ff31..40984d32 100644 --- a/intel/intel_bufmgr.h +++ b/intel/intel_bufmgr.h @@ -119,6 +119,7 @@ int drm_intel_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode, uint32_t * swizzle_mode); int drm_intel_bo_flink(drm_intel_bo *bo, uint32_t * name); int drm_intel_bo_busy(drm_intel_bo *bo); +int drm_intel_bo_madvise(drm_intel_bo *bo, int madv); int drm_intel_bo_disable_reuse(drm_intel_bo *bo); int drm_intel_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo); diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 87795f33..9db7bfeb 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -398,8 +398,8 @@ drm_intel_gem_bo_busy(drm_intel_bo *bo) } static int -drm_intel_gem_bo_madvise(drm_intel_bufmgr_gem *bufmgr_gem, - drm_intel_bo_gem *bo_gem, int state) +drm_intel_gem_bo_madvise_internal(drm_intel_bufmgr_gem *bufmgr_gem, + drm_intel_bo_gem *bo_gem, int state) { struct drm_i915_gem_madvise madv; @@ -411,6 +411,15 @@ drm_intel_gem_bo_madvise(drm_intel_bufmgr_gem *bufmgr_gem, return madv.retained; } +static int +drm_intel_gem_bo_madvise(drm_intel_bo *bo, int madv) +{ + return drm_intel_gem_bo_madvise_internal + ((drm_intel_bufmgr_gem *) bo->bufmgr, + (drm_intel_bo_gem *) bo, + madv); +} + /* drop the oldest entries that have been purged by the kernel */ static void drm_intel_gem_bo_cache_purge_bucket(drm_intel_bufmgr_gem *bufmgr_gem, @@ -421,7 +430,7 @@ drm_intel_gem_bo_cache_purge_bucket(drm_intel_bufmgr_gem *bufmgr_gem, bo_gem = DRMLISTENTRY(drm_intel_bo_gem, bucket->head.next, head); - if (drm_intel_gem_bo_madvise + if (drm_intel_gem_bo_madvise_internal (bufmgr_gem, bo_gem, I915_MADV_DONTNEED)) break; @@ -493,7 +502,7 @@ retry: } if (alloc_from_cache) { - if (!drm_intel_gem_bo_madvise + if (!drm_intel_gem_bo_madvise_internal (bufmgr_gem, bo_gem, I915_MADV_WILLNEED)) { drm_intel_gem_bo_free(&bo_gem->bo); drm_intel_gem_bo_cache_purge_bucket(bufmgr_gem, @@ -742,8 +751,8 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time) DRMLISTADDTAIL(&bo_gem->head, &bucket->head); - drm_intel_gem_bo_madvise(bufmgr_gem, bo_gem, - I915_MADV_DONTNEED); + 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); @@ -1703,6 +1712,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size) bufmgr_gem->bufmgr.bo_flink = drm_intel_gem_bo_flink; bufmgr_gem->bufmgr.bo_exec = drm_intel_gem_bo_exec; bufmgr_gem->bufmgr.bo_busy = drm_intel_gem_bo_busy; + bufmgr_gem->bufmgr.bo_madvise = drm_intel_gem_bo_madvise; bufmgr_gem->bufmgr.destroy = drm_intel_bufmgr_gem_destroy; bufmgr_gem->bufmgr.debug = 0; bufmgr_gem->bufmgr.check_aperture_space = diff --git a/intel/intel_bufmgr_priv.h b/intel/intel_bufmgr_priv.h index 475c402f..febee0f7 100644 --- a/intel/intel_bufmgr_priv.h +++ b/intel/intel_bufmgr_priv.h @@ -216,6 +216,20 @@ struct _drm_intel_bufmgr { */ int (*bo_busy) (drm_intel_bo *bo); + /** + * Specify the volatility of the buffer. + * \param bo Buffer to create a name for + * \param madv The purgeable status + * + * Use I915_MADV_DONTNEED to mark the buffer as purgeable, and it will be + * reclaimed under memory pressure. If you subsequently require the buffer, + * then you must pass I915_MADV_WILLNEED to mark the buffer as required. + * + * Returns 1 if the buffer was retained, or 0 if it was discarded whilst + * marked as I915_MADV_DONTNEED. + */ + int (*bo_madvise) (drm_intel_bo *bo, int madv); + int (*check_aperture_space) (drm_intel_bo ** bo_array, int count); /** |