drm/i915: create a prepare step for primary planes updates

Take out the pin_fb code so commit phase can't fail anymore.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Gustavo Padovan 2014-10-24 14:51:31 +01:00 committed by Daniel Vetter
parent d288f65fe9
commit 14af293f06

View File

@ -11403,6 +11403,42 @@ intel_check_primary_plane(struct drm_plane *plane,
} }
static int static int
intel_prepare_primary_plane(struct drm_plane *plane,
struct intel_plane_state *state)
{
struct drm_crtc *crtc = state->crtc;
struct drm_framebuffer *fb = state->fb;
struct drm_device *dev = crtc->dev;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
enum pipe pipe = intel_crtc->pipe;
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
int ret;
intel_crtc_wait_for_pending_flips(crtc);
if (intel_crtc_has_pending_flip(crtc)) {
DRM_ERROR("pipe is still busy with an old pageflip\n");
return -EBUSY;
}
if (old_obj != obj) {
mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
if (ret == 0)
i915_gem_track_fb(old_obj, obj,
INTEL_FRONTBUFFER_PRIMARY(pipe));
mutex_unlock(&dev->struct_mutex);
if (ret != 0) {
DRM_DEBUG_KMS("pin & fence failed\n");
return ret;
}
}
return 0;
}
static void
intel_commit_primary_plane(struct drm_plane *plane, intel_commit_primary_plane(struct drm_plane *plane,
struct intel_plane_state *state) struct intel_plane_state *state)
{ {
@ -11417,27 +11453,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb); struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
struct intel_plane *intel_plane = to_intel_plane(plane); struct intel_plane *intel_plane = to_intel_plane(plane);
struct drm_rect *src = &state->src; struct drm_rect *src = &state->src;
int ret;
intel_crtc_wait_for_pending_flips(crtc);
if (intel_crtc_has_pending_flip(crtc)) {
DRM_ERROR("pipe is still busy with an old pageflip\n");
return -EBUSY;
}
if (plane->fb != fb) {
mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
if (ret == 0)
i915_gem_track_fb(old_obj, obj,
INTEL_FRONTBUFFER_PRIMARY(pipe));
mutex_unlock(&dev->struct_mutex);
if (ret != 0) {
DRM_DEBUG_KMS("pin & fence failed\n");
return ret;
}
}
crtc->primary->fb = fb; crtc->primary->fb = fb;
crtc->x = src->x1; crtc->x = src->x1;
@ -11515,8 +11530,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
intel_unpin_fb_obj(old_obj); intel_unpin_fb_obj(old_obj);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
} }
return 0;
} }
static int static int
@ -11557,6 +11570,10 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
if (ret) if (ret)
return ret; return ret;
ret = intel_prepare_primary_plane(plane, &state);
if (ret)
return ret;
intel_commit_primary_plane(plane, &state); intel_commit_primary_plane(plane, &state);
return 0; return 0;