[5/6] intel: Round large allocations upto PAGE_SIZE
diff mbox

Message ID 1430816040-25285-5-git-send-email-chris@chris-wilson.co.uk
State New
Headers show

Commit Message

Chris Wilson May 5, 2015, 8:53 a.m. UTC
The kernel interface requires us to request only PAGE_SIZE aligned
buffers, so make sure that all allocation requests are indeed sized
correctly (and in the process remove the excess calls to getpagesize()).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 intel/intel_bufmgr_gem.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Patch
diff mbox

diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 2cbe973..22f7501 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -671,15 +671,10 @@  drm_intel_gem_bo_alloc_internal(drm_intel_bufmgr *bufmgr,
 {
 	drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bufmgr;
 	drm_intel_bo_gem *bo_gem;
-	unsigned int page_size = getpagesize();
-	int ret;
 	struct drm_intel_gem_bo_bucket *bucket;
 	bool alloc_from_cache;
 	unsigned long bo_size;
-	bool for_render = false;
-
-	if (flags & BO_ALLOC_FOR_RENDER)
-		for_render = true;
+	int ret;
 
 	/* Round the allocated size up to a power of two number of pages. */
 	bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, size);
@@ -688,9 +683,8 @@  drm_intel_gem_bo_alloc_internal(drm_intel_bufmgr *bufmgr,
 	 * allocation up.
 	 */
 	if (bucket == NULL) {
-		bo_size = size;
-		if (bo_size < page_size)
-			bo_size = page_size;
+		unsigned int page_size = getpagesize();
+		bo_size = ALIGN(size, page_size);
 	} else {
 		bo_size = bucket->size;
 	}
@@ -700,7 +694,7 @@  drm_intel_gem_bo_alloc_internal(drm_intel_bufmgr *bufmgr,
 retry:
 	alloc_from_cache = false;
 	if (bucket != NULL && !DRMLISTEMPTY(&bucket->head)) {
-		if (for_render) {
+		if (flags & BO_ALLOC_FOR_RENDER) {
 			/* Allocate new render-target BOs from the tail (MRU)
 			 * of the list, as it will likely be hot in the GPU
 			 * cache and in the aperture for us.