Commit 265db958 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Drain any pending flips on the fb prior to unpinning

If we have queued a page flip on the current fb and then request a mode
change, wait until the page flip completes before performing the new
request.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent c78ec30b
...@@ -1024,6 +1024,9 @@ int i915_do_wait_request(struct drm_device *dev, ...@@ -1024,6 +1024,9 @@ int i915_do_wait_request(struct drm_device *dev,
uint32_t seqno, uint32_t seqno,
bool interruptible, bool interruptible,
struct intel_ring_buffer *ring); struct intel_ring_buffer *ring);
int i915_gem_wait_for_pending_flip(struct drm_device *dev,
struct drm_gem_object **object_list,
int count);
int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj,
int write); int write);
......
...@@ -3497,7 +3497,7 @@ i915_gem_check_execbuffer (struct drm_i915_gem_execbuffer2 *exec, ...@@ -3497,7 +3497,7 @@ i915_gem_check_execbuffer (struct drm_i915_gem_execbuffer2 *exec,
return 0; return 0;
} }
static int int
i915_gem_wait_for_pending_flip(struct drm_device *dev, i915_gem_wait_for_pending_flip(struct drm_device *dev,
struct drm_gem_object **object_list, struct drm_gem_object **object_list,
int count) int count)
......
...@@ -1564,11 +1564,6 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, ...@@ -1564,11 +1564,6 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_master_private *master_priv; struct drm_i915_master_private *master_priv;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct intel_framebuffer *intel_fb;
struct drm_i915_gem_object *obj_priv;
struct drm_gem_object *obj;
int pipe = intel_crtc->pipe;
int plane = intel_crtc->plane;
int ret; int ret;
/* no fb bound */ /* no fb bound */
...@@ -1577,39 +1572,47 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, ...@@ -1577,39 +1572,47 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
return 0; return 0;
} }
switch (plane) { switch (intel_crtc->plane) {
case 0: case 0:
case 1: case 1:
break; break;
default: default:
DRM_ERROR("Can't update plane %d in SAREA\n", plane);
return -EINVAL; return -EINVAL;
} }
intel_fb = to_intel_framebuffer(crtc->fb);
obj = intel_fb->obj;
obj_priv = to_intel_bo(obj);
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev, obj, false); ret = intel_pin_and_fence_fb_obj(dev,
to_intel_framebuffer(crtc->fb)->obj,
false);
if (ret != 0) { if (ret != 0) {
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y); if (old_fb) {
struct drm_gem_object *obj = to_intel_framebuffer(old_fb)->obj;
struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
if (atomic_read(&obj_priv->pending_flip)) {
ret = i915_gem_wait_for_pending_flip(dev, &obj, 1);
if (ret) { if (ret) {
i915_gem_object_unpin(obj); i915_gem_object_unpin(to_intel_framebuffer(crtc->fb)->obj);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
}
}
if (old_fb) { ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y);
intel_fb = to_intel_framebuffer(old_fb); if (ret) {
obj_priv = to_intel_bo(intel_fb->obj); i915_gem_object_unpin(to_intel_framebuffer(crtc->fb)->obj);
i915_gem_object_unpin(intel_fb->obj); mutex_unlock(&dev->struct_mutex);
return ret;
} }
if (old_fb)
i915_gem_object_unpin(to_intel_framebuffer(old_fb)->obj);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
if (!dev->primary->master) if (!dev->primary->master)
...@@ -1619,7 +1622,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, ...@@ -1619,7 +1622,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
if (!master_priv->sarea_priv) if (!master_priv->sarea_priv)
return 0; return 0;
if (pipe) { if (intel_crtc->pipe) {
master_priv->sarea_priv->pipeB_x = x; master_priv->sarea_priv->pipeB_x = x;
master_priv->sarea_priv->pipeB_y = y; master_priv->sarea_priv->pipeB_y = y;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment