]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/atomic: Clean up wait_for_vblanks, v2.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Thu, 15 Dec 2016 11:51:42 +0000 (12:51 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 19 Dec 2016 15:41:47 +0000 (16:41 +0100)
Stop relying on a per crtc_state last_vblank_count, we shouldn't touch
crtc_state after commit. Move it to atomic_state->crtcs.

Also stop re-using new_crtc_state->enable, we can now simply set a
bitmask with crtc_crtc_mask.

Changes since v1:
- Keep last_vblank_count in __drm_crtc_state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/8e4759a4-24d3-3f80-bd1a-1e7a9c83b612@linux.intel.com
drivers/gpu/drm/drm_atomic_helper.c
include/drm/drm_atomic.h
include/drm/drm_crtc.h

index c2070bb94b7a99d8de3e5f55069c27aa1647d900..d1d678d63b84dad1f9692af77df187a018e79c39 100644 (file)
@@ -1117,19 +1117,19 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state;
        int i, ret;
+       unsigned crtc_mask = 0;
 
-       for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
-               /* No one cares about the old state, so abuse it for tracking
-                * and store whether we hold a vblank reference (and should do a
-                * vblank wait) in the ->enable boolean. */
-               old_crtc_state->enable = false;
+        /*
+         * Legacy cursor ioctls are completely unsynced, and userspace
+         * relies on that (by doing tons of cursor updates).
+         */
+       if (old_state->legacy_cursor_update)
+               return;
 
-               if (!crtc->state->active)
-                       continue;
+       for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
+               struct drm_crtc_state *new_crtc_state = crtc->state;
 
-               /* Legacy cursor ioctls are completely unsynced, and userspace
-                * relies on that (by doing tons of cursor updates). */
-               if (old_state->legacy_cursor_update)
+               if (!new_crtc_state->active)
                        continue;
 
                if (!drm_atomic_helper_framebuffer_changed(dev,
@@ -1140,16 +1140,16 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
                if (ret != 0)
                        continue;
 
-               old_crtc_state->enable = true;
-               old_crtc_state->last_vblank_count = drm_crtc_vblank_count(crtc);
+               crtc_mask |= drm_crtc_mask(crtc);
+               old_state->crtcs[i].last_vblank_count = drm_crtc_vblank_count(crtc);
        }
 
        for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
-               if (!old_crtc_state->enable)
+               if (!(crtc_mask & drm_crtc_mask(crtc)))
                        continue;
 
                ret = wait_event_timeout(dev->vblank[i].queue,
-                               old_crtc_state->last_vblank_count !=
+                               old_state->crtcs[i].last_vblank_count !=
                                        drm_crtc_vblank_count(crtc),
                                msecs_to_jiffies(50));
 
index b74f04c49713865f4c42a05b82175daf1b966b40..8cc7ca2079fbe35702a32c972496604675949e8f 100644 (file)
@@ -145,6 +145,7 @@ struct __drm_crtcs_state {
        struct drm_crtc_state *state;
        struct drm_crtc_commit *commit;
        s64 __user *out_fence_ptr;
+       unsigned last_vblank_count;
 };
 
 struct __drm_connnectors_state {
index 9ef0ac0ce69fbec36e3511f00c3ff8b026c94de4..6920dee3a2d1e9ba1701c8e6706b36772ad1c802 100644 (file)
@@ -90,8 +90,6 @@ struct drm_plane_helper_funcs;
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
- * @last_vblank_count: for helpers and drivers to capture the vblank of the
- *     update to ensure framebuffer cleanup isn't done too early
  * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
  * @mode: current mode timings
  * @mode_blob: &drm_property_blob for @mode
@@ -137,9 +135,6 @@ struct drm_crtc_state {
        u32 connector_mask;
        u32 encoder_mask;
 
-       /* last_vblank_count: for vblank waits before cleanup */
-       u32 last_vblank_count;
-
        /* adjusted_mode: for use by helpers and drivers */
        struct drm_display_mode adjusted_mode;