[Intel-gfx] [PATCH] drm/i915: Promote invalid buffer alignment.
Chris Wilson
chris at chris-wilson.co.uk
Wed Dec 2 22:07:37 CET 2009
WARN if somebody tries to pin a buffer with a too lax alignment, and use
the minimum required alignment instead.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: stable at kernel.org
---
drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 214fb18..846f050 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2577,6 +2577,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
drm_i915_private_t *dev_priv = dev->dev_private;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
struct drm_mm_node *free_space;
+ unsigned required_alignment;
bool retry_alloc = false;
int ret;
@@ -2588,11 +2589,17 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
return -EINVAL;
}
- if (alignment == 0)
- alignment = i915_gem_get_gtt_alignment(obj);
- if (alignment & (i915_gem_get_gtt_alignment(obj) - 1)) {
- DRM_ERROR("Invalid object alignment requested %u\n", alignment);
- return -EINVAL;
+ required_alignment = i915_gem_get_gtt_alignment(obj);
+ if (alignment & (required_alignment - 1)) {
+ WARN(1,"Invalid object alignment requested %x < %x\n",
+ alignment, required_alignment);
+ /* Use the smallest possible alignment that honours the
+ * fencing restrictions and the user request.
+ */
+ if (alignment < required_alignment)
+ alignment = required_alignment;
+ else
+ alignment = (alignment + required_alignment) & -required_alignment;
}
search_free:
--
1.6.5.3
More information about the Intel-gfx
mailing list