[Intel-gfx] [PATCH 5/9] drm/i915: Quick spring clean of intel_prepare_plane_fb()
Chris Wilson
chris at chris-wilson.co.uk
Tue Aug 23 08:16:14 UTC 2016
Just a quick tidy now to make the next patch neater.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/intel_display.c | 43 +++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index c57cc4245c63..a2bffa5a4d5d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13923,6 +13923,17 @@ static int intel_atomic_check(struct drm_device *dev,
return calc_watermark_data(state);
}
+static bool old_plane_needs_modeset(struct drm_plane *plane,
+ struct drm_plane_state *new_state)
+{
+ struct drm_crtc_state *crtc_state;
+
+ crtc_state = drm_atomic_get_existing_crtc_state(new_state->state,
+ plane->state->crtc);
+
+ return needs_modeset(crtc_state);
+}
+
/**
* intel_prepare_plane_fb - Prepare fb for usage on plane
* @plane: drm plane to prepare for
@@ -13944,16 +13955,12 @@ intel_prepare_plane_fb(struct drm_plane *plane,
struct drm_device *dev = plane->dev;
struct drm_framebuffer *fb = new_state->fb;
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
- struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->state->fb);
struct reservation_object *resv;
- int ret = 0;
-
- if (!obj && !old_obj)
- return 0;
+ int ret;
- if (old_obj) {
- struct drm_crtc_state *crtc_state =
- drm_atomic_get_existing_crtc_state(new_state->state, plane->state->crtc);
+ if (plane->state->fb && old_plane_needs_modeset(plane, new_state)) {
+ struct drm_i915_gem_object *old_obj =
+ intel_fb_obj(plane->state->fb);
/* Big Hammer, we also need to ensure that any pending
* MI_WAIT_FOR_EVENT inside a user batch buffer on the
@@ -13966,8 +13973,8 @@ intel_prepare_plane_fb(struct drm_plane *plane,
* This should only fail upon a hung GPU, in which case we
* can safely continue.
*/
- if (needs_modeset(crtc_state))
- ret = i915_gem_object_wait_rendering(old_obj, true);
+
+ ret = i915_gem_object_wait_rendering(old_obj, true);
if (ret) {
/* GPU hangs should have been swallowed by the wait */
WARN_ON(ret == -EIO);
@@ -13995,25 +14002,25 @@ intel_prepare_plane_fb(struct drm_plane *plane,
INTEL_INFO(dev)->cursor_needs_physical) {
int align = IS_I830(dev) ? 16 * 1024 : 256;
ret = i915_gem_object_attach_phys(obj, align);
- if (ret)
+ if (ret) {
DRM_DEBUG_KMS("failed to attach phys object\n");
+ return ret;
+ }
} else {
struct i915_vma *vma;
vma = intel_pin_and_fence_fb_obj(fb, new_state->rotation);
if (IS_ERR(vma))
- ret = PTR_ERR(vma);
+ return PTR_ERR(vma);
to_intel_plane_state(new_state)->vma = vma;
}
- if (ret == 0) {
- new_state->fence =
- &i915_gem_active_get(&obj->last_write,
- &obj->base.dev->struct_mutex)->fence;
- }
+ new_state->fence =
+ &i915_gem_active_get(&obj->last_write,
+ &obj->base.dev->struct_mutex)->fence;
- return ret;
+ return 0;
}
/**
--
2.9.3
More information about the Intel-gfx
mailing list