From 727ac3f98fb5563b234f854793645caa506bf255 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 17 Jan 2014 22:32:01 +0000 Subject: [PATCH] fence --- drivers/gpu/drm/i915/i915_gem.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8c02a45..fc1b9a0 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3214,7 +3214,7 @@ i915_find_fence_reg(struct drm_device *dev) } if (avail == NULL) - return NULL; + return ERR_PTR(-EDEADLK); /* None available, try to steal one or wait for a user to finish */ list_for_each_entry(reg, &dev_priv->mm.fence_list, lru_list) { @@ -3224,7 +3224,27 @@ i915_find_fence_reg(struct drm_device *dev) return reg; } - return NULL; + { + struct drm_crtc *crtc; + bool pending_flip = false; + + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { + struct intel_crtc *intel_crtc = to_intel_crtc(crtc); + + if (atomic_read(&intel_crtc->unpin_work_count) == 0) + continue; + + if (intel_crtc->unpin_work) + intel_wait_for_vblank(dev, intel_crtc->pipe); + + pending_flip = true; + } + + if (pending_flip) + return ERR_PTR(-EAGAIN); + } + + return ERR_PTR(-EDEADLK); } /** @@ -3269,8 +3289,8 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj) } } else if (enable) { reg = i915_find_fence_reg(dev); - if (reg == NULL) - return -EDEADLK; + if (IS_ERR(reg)) + return PTR_ERR(reg); if (reg->obj) { struct drm_i915_gem_object *old = reg->obj; -- 1.8.5.3