summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-11-12 12:19:31 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-11-12 12:19:31 +0000
commite8799cdea461df5102d421fda26fecceae79b929 (patch)
tree9f1e98f06f3f948879cdfedf0694021170525ede
parent0269ec5533ecf7bec0f01c682e085861a3d2ab00 (diff)
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@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 701c2c20..ef712e2d 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;