[2/2] intel: allocate buffer with the requested size when reuse is disabled

Submitted by James Xiong on Feb. 20, 2018, 5:48 p.m.

Details

Message ID 1519148893-19047-1-git-send-email-james.xiong@intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in libdrm - Intel

Not browsing as part of any series.

Commit Message

James Xiong Feb. 20, 2018, 5:48 p.m.
From: "Xiong, James" <james.xiong@intel.com>

Previously a bucket size was used for buffer allocation whether
bo_reuse is false or true. This patch returns NULL in function
drm_intel_gem_bo_bucket_for_size() when bo_reuse is false, the
original requested size is used instead.

Signed-off-by: Xiong, James <james.xiong@intel.com>
---
 intel/intel_bufmgr_gem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 5b2d0d0..122530f 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -402,6 +402,9 @@  drm_intel_gem_bo_bucket_for_size(drm_intel_bufmgr_gem *bufmgr_gem,
 {
 	int i;
 
+	if (!bufmgr_gem->bo_reuse)
+		return NULL;
+
 	for (i = 0; i < bufmgr_gem->num_buckets - 1; i++) {
 		if (size >= bufmgr_gem->cache_bucket[i].size &&
 		    size < bufmgr_gem->cache_bucket[i+1].size) {
@@ -1392,7 +1395,7 @@  drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
 
 	bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, bo->size);
 	/* Put the buffer into our internal cache for reuse if we can. */
-	if (bufmgr_gem->bo_reuse && bo_gem->reusable && bucket != NULL &&
+	if (bo_gem->reusable && bucket != NULL &&
 	    drm_intel_gem_bo_madvise_internal(bufmgr_gem, bo_gem,
 					      I915_MADV_DONTNEED)) {
 		bo_gem->free_time = time;