From 070378590ab738bbf61e0e58b9167922c6d76bb5 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 4 Mar 2010 10:38:14 +0000 Subject: [PATCH] drm/i915: Unbind bo if currently bound with incorrect alignment. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/intel_display.c | 11 +++++++++++ drivers/gpu/drm/i915/intel_fb.c | 6 ++++++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 582afdc..15be43a 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -1250,10 +1250,21 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev, struct drm_gem_object *obj) switch (obj_priv->tiling_mode) { case I915_TILING_NONE: alignment = 64 * 1024; + if (obj_priv->gtt_space && + obj_priv->gtt_offset & (alignment - 1)) { + ret = i915_gem_object_unbind (obj); + if (ret) + return ret; + } break; case I915_TILING_X: /* pin() will align the object as required by fence */ alignment = 0; + if (!i915_gem_object_fence_offset_ok(obj, I915_TILING_X)) { + ret = i915_gem_object_unbind(obj); + if (ret) + return ret; + } break; case I915_TILING_Y: /* FIXME: Is this true? */ diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c index 8cd791d..ebc84f4 100644 --- a/drivers/gpu/drm/i915/intel_fb.c +++ b/drivers/gpu/drm/i915/intel_fb.c @@ -149,6 +149,12 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width, mutex_lock(&dev->struct_mutex); + if (obj_priv->gtt_space && obj_priv->gtt_offset & (64*1024 - 1)) { + ret = i915_gem_object_unbind (fbo); + if (ret) + goto out_unref; + } + ret = i915_gem_object_pin(fbo, 64*1024); if (ret) { DRM_ERROR("failed to pin fb: %d\n", ret); -- 1.7.0