xf86-video-intel: src/sna/kgem.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Nov 12 04:25:15 PST 2011


 src/sna/kgem.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit e8799cdea461df5102d421fda26fecceae79b929
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Nov 12 12:19:31 2011 +0000

    sna: Be stricter and disallow allocation of large fenced objects
    
    When allocating objects, we need to check the size of the full fenced
    regions against the mappable limits in order to be able to mmap the
    object later.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=42813
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 701c2c2..ef712e2 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -426,6 +426,7 @@ static uint32_t kgem_get_unique_id(struct kgem *kgem)
 }
 
 static uint32_t kgem_surface_size(struct kgem *kgem,
+				  bool relaxed_fencing,
 				  uint32_t width,
 				  uint32_t height,
 				  uint32_t bpp,
@@ -484,7 +485,7 @@ static uint32_t kgem_surface_size(struct kgem *kgem,
 		return 0;
 
 	size = *pitch * height;
-	if (kgem->has_relaxed_fencing || tiling == I915_TILING_NONE)
+	if (relaxed_fencing || tiling == I915_TILING_NONE || kgem->gen >= 40)
 		return ALIGN(size, PAGE_SIZE);
 
 	/*  We need to allocate a pot fence region for a tiled buffer. */
@@ -1418,9 +1419,12 @@ static bool _kgem_can_create_2d(struct kgem *kgem,
 	if (tiling < 0)
 		tiling = -tiling;
 
-	size = kgem_surface_size(kgem, width, height, bpp, tiling, &pitch);
-	if (size == 0 || size > kgem->max_object_size)
-		size = kgem_surface_size(kgem, width, height, bpp, I915_TILING_NONE, &pitch);
+	size = kgem_surface_size(kgem, false,
+				 width, height, bpp, tiling, &pitch);
+	if (size == 0 || size >= kgem->max_object_size)
+		size = kgem_surface_size(kgem, false,
+					 width, height, bpp,
+					 I915_TILING_NONE, &pitch);
 	return size > 0 && size <= kgem->max_object_size;
 }
 
@@ -1479,7 +1483,8 @@ struct kgem_bo *kgem_create_2d(struct kgem *kgem,
 	     width, height, bpp, tiling, !!exact, !!(flags & CREATE_INACTIVE)));
 
 	assert(_kgem_can_create_2d(kgem, width, height, bpp, exact ? -tiling : tiling));
-	size = kgem_surface_size(kgem, width, height, bpp, tiling, &pitch);
+	size = kgem_surface_size(kgem, kgem->has_relaxed_fencing,
+				 width, height, bpp, tiling, &pitch);
 	assert(size && size <= kgem->max_object_size);
 	if (flags & CREATE_INACTIVE)
 		goto skip_active_search;


More information about the xorg-commit mailing list