[Intel-gfx] [PATCH 13/37] drm/i915: Unbind bo if currently bound with incorrect alignment.
Owain Ainsworth
zerooa at googlemail.com
Tue Mar 16 23:47:57 CET 2010
On Wed, Mar 10, 2010 at 10:45:00PM +0000, Chris Wilson wrote:
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> 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 3904d43..e1f4874 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 aaabbcb..89717e3 100644
> --- a/drivers/gpu/drm/i915/intel_fb.c
> +++ b/drivers/gpu/drm/i915/intel_fb.c
> @@ -148,6 +148,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);
In this case in openbsd, i moved the alignment check into
i915_gem_object_pin directly, so it is only done in one place. Right
now, fences, fb, etc all check then unbind when instead it could done in
a much less error prone way in the next call.
note that you should check first that the object is not already pinned,
then unbind otherwise.
-0-
--
The brain is a wonderful organ; it starts working the moment you get up
in the morning, and does not stop until you get to school.
More information about the Intel-gfx
mailing list