• Matt Roper's avatar
    drm/i915: Use enabled value from crtc_state rather than crtc (v2) · 83d65738
    Matt Roper authored
    As vendors transition their drivers from legacy to atomic there's some
    duplication of data between drm_crtc and drm_crtc_state (since
    unconverted drivers likely won't have a state structure).
    
    i915 is partially converted and does have a crtc->state structure, but
    still uses direct crtc fields internally in many places, which causes
    the two sets of data to get out of sync.  As of commit
    
            commit 31c946e8
            Author: Daniel Vetter <daniel.vetter@ffwll.ch>
            Date:   Sun Feb 22 12:24:17 2015 +0100
    
                drm: If available use atomic state in getcrtc ioctl
    
                This way drivers fully converted to atomic don't need to update these
                legacy state variables in their modeset code any more.
    Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
    
    the DRM core starts assuming that the presence of a ->state structure
    implies that it should make use of the values stored there which, on
    i915, leads to the core code using stale values for CRTC 'enabled'
    status.
    
    Let's switch over to using the state value of 'enable' internally rather
    than using the drm_crtc field.  This ensures that our driver internals
    are working from the same data that the DRM core is, avoiding
    mismatches.
    
    This patch was generated with Coccinelle using the following semantic
    patch:
    
            <smpl>
            @@
            struct drm_crtc C;
            struct drm_crtc *CP;
            @@
            (
            - C.enabled
            + C.state->enable
            |
            - CP->enabled
            + CP->state->enable
            )
    
            // For assignments, we still update the legacy value as well as the state value
            // so add an extra assignment statement for that.
            @@
            struct drm_crtc C;
            struct drm_crtc *CP;
            expression E;
            @@
            (
              C.state->enable = E;
            + C.enabled = E;
            |
              CP->state->enable = E;
            + CP->enabled = E;
            )
            </smpl>
    
    The crtc->mode and crtc->hwmode fields should probably be transitioned
    over as well eventually, but we seem to do an okay job of keeping those
    up-to-date already so I want to minimize the changes that will clash
    with Ander's in-progress atomic work.
    
    v2: Don't remove the assignments to the legacy value when we assign to
        the state value.  A second cocci stanza takes care of adding the
        legacy assignment back where appropriate.  (Daniel)
    
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
    Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
    83d65738
i915_irq.c 126 KB