@@ -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: