Re: [Intel-gfx] [PATCH 4/7] drm/i915: Clean up intel_{pre, post}_plane_update()

2019-12-04 Thread Ville Syrjälä
On Tue, Dec 03, 2019 at 09:44:42PM +, Souza, Jose wrote:
> On Thu, 2019-11-28 at 14:02 +0200, Ville Syrjälä wrote:
> > On Wed, Nov 27, 2019 at 11:25:07PM +, Souza, Jose wrote:
> > > On Wed, 2019-11-27 at 21:05 +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä 
> > > > 
> > > > Change the calling convention to just pass the state+crtc and
> > > > switch to intel_ types throughout.
> > > > 
> > > > Signed-off-by: Ville Syrjälä 
> > > > ---
> > > >  drivers/gpu/drm/i915/display/intel_display.c | 88 +-
> > > > 
> > > > --
> > > >  drivers/gpu/drm/i915/display/intel_fbc.c | 14 ++--
> > > >  drivers/gpu/drm/i915/display/intel_fbc.h |  8 +-
> > > >  3 files changed, 51 insertions(+), 59 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> > > > b/drivers/gpu/drm/i915/display/intel_display.c
> > > > index e341b97b7dec..72655b5b1365 100644
> > > > --- a/drivers/gpu/drm/i915/display/intel_display.c
> > > > +++ b/drivers/gpu/drm/i915/display/intel_display.c
> > > > @@ -5920,13 +5920,10 @@ static void
> > > > intel_crtc_dpms_overlay_disable(struct intel_crtc *intel_crtc)
> > > >   * completely hide the primary plane.
> > > >   */
> > > >  static void
> > > > -intel_post_enable_primary(struct drm_crtc *crtc,
> > > > - const struct intel_crtc_state
> > > > *new_crtc_state)
> > > > +intel_post_enable_primary(struct intel_crtc *crtc)
> > > >  {
> > > > -   struct drm_device *dev = crtc->dev;
> > > > -   struct drm_i915_private *dev_priv = to_i915(dev);
> > > > -   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> > > > -   enum pipe pipe = intel_crtc->pipe;
> > > > +   struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> > > > +   enum pipe pipe = crtc->pipe;
> > > >  
> > > > /*
> > > >  * Gen2 reports pipe underruns whenever all planes are
> > > > disabled.
> > > > @@ -6062,20 +6059,21 @@ static bool needs_scalerclk_wa(const
> > > > struct
> > > > intel_crtc_state *crtc_state)
> > > > return false;
> > > >  }
> > > >  
> > > > -static void intel_post_plane_update(struct intel_crtc_state
> > > > *old_crtc_state)
> > > > +static void intel_post_plane_update(struct intel_atomic_state
> > > > *state,
> > > > +   struct intel_crtc *crtc)
> > > >  {
> > > > -   struct intel_crtc *crtc = to_intel_crtc(old_crtc_state-
> > > > > uapi.crtc);
> > > > -   struct drm_device *dev = crtc->base.dev;
> > > > -   struct drm_i915_private *dev_priv = to_i915(dev);
> > > > -   struct drm_atomic_state *state = old_crtc_state->uapi.state;
> > > > -   struct intel_crtc_state *new_crtc_state =
> > > > -   intel_atomic_get_new_crtc_state(to_intel_atomic_state(s
> > > > tate),
> > > > -   crtc);
> > > > -   struct drm_plane *primary = crtc->base.primary;
> > > > -   struct drm_plane_state *old_primary_state =
> > > > -   drm_atomic_get_old_plane_state(state, primary);
> > > > +   struct drm_i915_private *dev_priv = to_i915(state->base.dev);
> > > > +   struct intel_plane *primary = to_intel_plane(crtc-
> > > > > base.primary);
> > > > +   const struct intel_crtc_state *old_crtc_state =
> > > > +   intel_atomic_get_old_crtc_state(state, crtc);
> > > > +   const struct intel_crtc_state *new_crtc_state =
> > > > +   intel_atomic_get_new_crtc_state(state, crtc);
> > > > +   const struct intel_plane_state *old_primary_state =
> > > > +   intel_atomic_get_old_plane_state(state, primary);
> > > > +   const struct intel_plane_state *new_primary_state =
> > > > +   intel_atomic_get_new_plane_state(state, primary);
> > > >  
> > > > -   intel_frontbuffer_flip(to_i915(crtc->base.dev), new_crtc_state-
> > > > > fb_bits);
> > > > +   intel_frontbuffer_flip(dev_priv, new_crtc_state->fb_bits);
> > > >  
> > > > if (new_crtc_state->update_wm_post && new_crtc_state-
> > > > > hw.active)
> > > > intel_update_watermarks(crtc);
> > > > @@ -6083,16 +6081,13 @@ static void
> > > > intel_post_plane_update(struct
> > > > intel_crtc_state *old_crtc_state)
> > > > if (hsw_post_update_enable_ips(old_crtc_state, new_crtc_state))
> > > > hsw_enable_ips(new_crtc_state);
> > > >  
> > > > -   if (old_primary_state) {
> > > > -   struct drm_plane_state *new_primary_state =
> > > > -   drm_atomic_get_new_plane_state(state, primary);
> > > > -
> > > > +   if (new_primary_state) {
> > > 
> > > This change from old_primary_state to new_primary_state is way more
> > > than the commit message says, the change looks right to me but
> > > maybe it
> > > deserves a separated patch? Same for the same change in
> > > intel_pre_plane_update()
> > 
> > I wanted to change it so I can eliminate old_primary_state in
> > a subsequent patch. For 

Re: [Intel-gfx] [PATCH 4/7] drm/i915: Clean up intel_{pre, post}_plane_update()

2019-12-03 Thread Souza, Jose
On Thu, 2019-11-28 at 14:02 +0200, Ville Syrjälä wrote:
> On Wed, Nov 27, 2019 at 11:25:07PM +, Souza, Jose wrote:
> > On Wed, 2019-11-27 at 21:05 +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä 
> > > 
> > > Change the calling convention to just pass the state+crtc and
> > > switch to intel_ types throughout.
> > > 
> > > Signed-off-by: Ville Syrjälä 
> > > ---
> > >  drivers/gpu/drm/i915/display/intel_display.c | 88 +-
> > > 
> > > --
> > >  drivers/gpu/drm/i915/display/intel_fbc.c | 14 ++--
> > >  drivers/gpu/drm/i915/display/intel_fbc.h |  8 +-
> > >  3 files changed, 51 insertions(+), 59 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> > > b/drivers/gpu/drm/i915/display/intel_display.c
> > > index e341b97b7dec..72655b5b1365 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_display.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_display.c
> > > @@ -5920,13 +5920,10 @@ static void
> > > intel_crtc_dpms_overlay_disable(struct intel_crtc *intel_crtc)
> > >   * completely hide the primary plane.
> > >   */
> > >  static void
> > > -intel_post_enable_primary(struct drm_crtc *crtc,
> > > -   const struct intel_crtc_state
> > > *new_crtc_state)
> > > +intel_post_enable_primary(struct intel_crtc *crtc)
> > >  {
> > > - struct drm_device *dev = crtc->dev;
> > > - struct drm_i915_private *dev_priv = to_i915(dev);
> > > - struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> > > - enum pipe pipe = intel_crtc->pipe;
> > > + struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> > > + enum pipe pipe = crtc->pipe;
> > >  
> > >   /*
> > >* Gen2 reports pipe underruns whenever all planes are
> > > disabled.
> > > @@ -6062,20 +6059,21 @@ static bool needs_scalerclk_wa(const
> > > struct
> > > intel_crtc_state *crtc_state)
> > >   return false;
> > >  }
> > >  
> > > -static void intel_post_plane_update(struct intel_crtc_state
> > > *old_crtc_state)
> > > +static void intel_post_plane_update(struct intel_atomic_state
> > > *state,
> > > + struct intel_crtc *crtc)
> > >  {
> > > - struct intel_crtc *crtc = to_intel_crtc(old_crtc_state-
> > > > uapi.crtc);
> > > - struct drm_device *dev = crtc->base.dev;
> > > - struct drm_i915_private *dev_priv = to_i915(dev);
> > > - struct drm_atomic_state *state = old_crtc_state->uapi.state;
> > > - struct intel_crtc_state *new_crtc_state =
> > > - intel_atomic_get_new_crtc_state(to_intel_atomic_state(s
> > > tate),
> > > - crtc);
> > > - struct drm_plane *primary = crtc->base.primary;
> > > - struct drm_plane_state *old_primary_state =
> > > - drm_atomic_get_old_plane_state(state, primary);
> > > + struct drm_i915_private *dev_priv = to_i915(state->base.dev);
> > > + struct intel_plane *primary = to_intel_plane(crtc-
> > > > base.primary);
> > > + const struct intel_crtc_state *old_crtc_state =
> > > + intel_atomic_get_old_crtc_state(state, crtc);
> > > + const struct intel_crtc_state *new_crtc_state =
> > > + intel_atomic_get_new_crtc_state(state, crtc);
> > > + const struct intel_plane_state *old_primary_state =
> > > + intel_atomic_get_old_plane_state(state, primary);
> > > + const struct intel_plane_state *new_primary_state =
> > > + intel_atomic_get_new_plane_state(state, primary);
> > >  
> > > - intel_frontbuffer_flip(to_i915(crtc->base.dev), new_crtc_state-
> > > > fb_bits);
> > > + intel_frontbuffer_flip(dev_priv, new_crtc_state->fb_bits);
> > >  
> > >   if (new_crtc_state->update_wm_post && new_crtc_state-
> > > > hw.active)
> > >   intel_update_watermarks(crtc);
> > > @@ -6083,16 +6081,13 @@ static void
> > > intel_post_plane_update(struct
> > > intel_crtc_state *old_crtc_state)
> > >   if (hsw_post_update_enable_ips(old_crtc_state, new_crtc_state))
> > >   hsw_enable_ips(new_crtc_state);
> > >  
> > > - if (old_primary_state) {
> > > - struct drm_plane_state *new_primary_state =
> > > - drm_atomic_get_new_plane_state(state, primary);
> > > -
> > > + if (new_primary_state) {
> > 
> > This change from old_primary_state to new_primary_state is way more
> > than the commit message says, the change looks right to me but
> > maybe it
> > deserves a separated patch? Same for the same change in
> > intel_pre_plane_update()
> 
> I wanted to change it so I can eliminate old_primary_state in
> a subsequent patch. For whatever reason that change slipped
> into this patch. It's a nop change though since
> !new_state == !old_state always.

Maybe worthy to mention it in the description?! Will leave that up to
you.

Reviewed-by: José Roberto de Souza 

> 
> > >   intel_fbc_post_update(crtc);
> > >  
> > > - if (new_primary_state->visible &&
> > > + if (new_primary_state->uapi.visible &&
> > >   (needs_modeset(new_crtc_state) ||
> > > -  !old_primary_state->visible))
> > > - 

Re: [Intel-gfx] [PATCH 4/7] drm/i915: Clean up intel_{pre, post}_plane_update()

2019-11-28 Thread Ville Syrjälä
On Wed, Nov 27, 2019 at 11:25:07PM +, Souza, Jose wrote:
> On Wed, 2019-11-27 at 21:05 +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä 
> > 
> > Change the calling convention to just pass the state+crtc and
> > switch to intel_ types throughout.
> > 
> > Signed-off-by: Ville Syrjälä 
> > ---
> >  drivers/gpu/drm/i915/display/intel_display.c | 88 +-
> > --
> >  drivers/gpu/drm/i915/display/intel_fbc.c | 14 ++--
> >  drivers/gpu/drm/i915/display/intel_fbc.h |  8 +-
> >  3 files changed, 51 insertions(+), 59 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> > b/drivers/gpu/drm/i915/display/intel_display.c
> > index e341b97b7dec..72655b5b1365 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display.c
> > +++ b/drivers/gpu/drm/i915/display/intel_display.c
> > @@ -5920,13 +5920,10 @@ static void
> > intel_crtc_dpms_overlay_disable(struct intel_crtc *intel_crtc)
> >   * completely hide the primary plane.
> >   */
> >  static void
> > -intel_post_enable_primary(struct drm_crtc *crtc,
> > - const struct intel_crtc_state
> > *new_crtc_state)
> > +intel_post_enable_primary(struct intel_crtc *crtc)
> >  {
> > -   struct drm_device *dev = crtc->dev;
> > -   struct drm_i915_private *dev_priv = to_i915(dev);
> > -   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> > -   enum pipe pipe = intel_crtc->pipe;
> > +   struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> > +   enum pipe pipe = crtc->pipe;
> >  
> > /*
> >  * Gen2 reports pipe underruns whenever all planes are
> > disabled.
> > @@ -6062,20 +6059,21 @@ static bool needs_scalerclk_wa(const struct
> > intel_crtc_state *crtc_state)
> > return false;
> >  }
> >  
> > -static void intel_post_plane_update(struct intel_crtc_state
> > *old_crtc_state)
> > +static void intel_post_plane_update(struct intel_atomic_state
> > *state,
> > +   struct intel_crtc *crtc)
> >  {
> > -   struct intel_crtc *crtc = to_intel_crtc(old_crtc_state-
> > >uapi.crtc);
> > -   struct drm_device *dev = crtc->base.dev;
> > -   struct drm_i915_private *dev_priv = to_i915(dev);
> > -   struct drm_atomic_state *state = old_crtc_state->uapi.state;
> > -   struct intel_crtc_state *new_crtc_state =
> > -   intel_atomic_get_new_crtc_state(to_intel_atomic_state(s
> > tate),
> > -   crtc);
> > -   struct drm_plane *primary = crtc->base.primary;
> > -   struct drm_plane_state *old_primary_state =
> > -   drm_atomic_get_old_plane_state(state, primary);
> > +   struct drm_i915_private *dev_priv = to_i915(state->base.dev);
> > +   struct intel_plane *primary = to_intel_plane(crtc-
> > >base.primary);
> > +   const struct intel_crtc_state *old_crtc_state =
> > +   intel_atomic_get_old_crtc_state(state, crtc);
> > +   const struct intel_crtc_state *new_crtc_state =
> > +   intel_atomic_get_new_crtc_state(state, crtc);
> > +   const struct intel_plane_state *old_primary_state =
> > +   intel_atomic_get_old_plane_state(state, primary);
> > +   const struct intel_plane_state *new_primary_state =
> > +   intel_atomic_get_new_plane_state(state, primary);
> >  
> > -   intel_frontbuffer_flip(to_i915(crtc->base.dev), new_crtc_state-
> > >fb_bits);
> > +   intel_frontbuffer_flip(dev_priv, new_crtc_state->fb_bits);
> >  
> > if (new_crtc_state->update_wm_post && new_crtc_state-
> > >hw.active)
> > intel_update_watermarks(crtc);
> > @@ -6083,16 +6081,13 @@ static void intel_post_plane_update(struct
> > intel_crtc_state *old_crtc_state)
> > if (hsw_post_update_enable_ips(old_crtc_state, new_crtc_state))
> > hsw_enable_ips(new_crtc_state);
> >  
> > -   if (old_primary_state) {
> > -   struct drm_plane_state *new_primary_state =
> > -   drm_atomic_get_new_plane_state(state, primary);
> > -
> > +   if (new_primary_state) {
> 
> 
> This change from old_primary_state to new_primary_state is way more
> than the commit message says, the change looks right to me but maybe it
> deserves a separated patch? Same for the same change in
> intel_pre_plane_update()

I wanted to change it so I can eliminate old_primary_state in
a subsequent patch. For whatever reason that change slipped
into this patch. It's a nop change though since
!new_state == !old_state always.

> 
> > intel_fbc_post_update(crtc);
> >  
> > -   if (new_primary_state->visible &&
> > +   if (new_primary_state->uapi.visible &&
> > (needs_modeset(new_crtc_state) ||
> > -!old_primary_state->visible))
> > -   intel_post_enable_primary(&crtc->base,
> > new_crtc_state);
> > +!old_primary_state->uapi.visible))
> > +   intel_post_enable_primary(crtc);
> > }
> >  
> > if (needs_nv12_wa(old_crtc_state) &&
> > @@ -6104,34 +6099,31 @@ static void intel_post_plane_update(struct
> > 

Re: [Intel-gfx] [PATCH 4/7] drm/i915: Clean up intel_{pre, post}_plane_update()

2019-11-27 Thread Souza, Jose
On Wed, 2019-11-27 at 21:05 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä 
> 
> Change the calling convention to just pass the state+crtc and
> switch to intel_ types throughout.
> 
> Signed-off-by: Ville Syrjälä 
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 88 +-
> --
>  drivers/gpu/drm/i915/display/intel_fbc.c | 14 ++--
>  drivers/gpu/drm/i915/display/intel_fbc.h |  8 +-
>  3 files changed, 51 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> b/drivers/gpu/drm/i915/display/intel_display.c
> index e341b97b7dec..72655b5b1365 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -5920,13 +5920,10 @@ static void
> intel_crtc_dpms_overlay_disable(struct intel_crtc *intel_crtc)
>   * completely hide the primary plane.
>   */
>  static void
> -intel_post_enable_primary(struct drm_crtc *crtc,
> -   const struct intel_crtc_state
> *new_crtc_state)
> +intel_post_enable_primary(struct intel_crtc *crtc)
>  {
> - struct drm_device *dev = crtc->dev;
> - struct drm_i915_private *dev_priv = to_i915(dev);
> - struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> - enum pipe pipe = intel_crtc->pipe;
> + struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> + enum pipe pipe = crtc->pipe;
>  
>   /*
>* Gen2 reports pipe underruns whenever all planes are
> disabled.
> @@ -6062,20 +6059,21 @@ static bool needs_scalerclk_wa(const struct
> intel_crtc_state *crtc_state)
>   return false;
>  }
>  
> -static void intel_post_plane_update(struct intel_crtc_state
> *old_crtc_state)
> +static void intel_post_plane_update(struct intel_atomic_state
> *state,
> + struct intel_crtc *crtc)
>  {
> - struct intel_crtc *crtc = to_intel_crtc(old_crtc_state-
> >uapi.crtc);
> - struct drm_device *dev = crtc->base.dev;
> - struct drm_i915_private *dev_priv = to_i915(dev);
> - struct drm_atomic_state *state = old_crtc_state->uapi.state;
> - struct intel_crtc_state *new_crtc_state =
> - intel_atomic_get_new_crtc_state(to_intel_atomic_state(s
> tate),
> - crtc);
> - struct drm_plane *primary = crtc->base.primary;
> - struct drm_plane_state *old_primary_state =
> - drm_atomic_get_old_plane_state(state, primary);
> + struct drm_i915_private *dev_priv = to_i915(state->base.dev);
> + struct intel_plane *primary = to_intel_plane(crtc-
> >base.primary);
> + const struct intel_crtc_state *old_crtc_state =
> + intel_atomic_get_old_crtc_state(state, crtc);
> + const struct intel_crtc_state *new_crtc_state =
> + intel_atomic_get_new_crtc_state(state, crtc);
> + const struct intel_plane_state *old_primary_state =
> + intel_atomic_get_old_plane_state(state, primary);
> + const struct intel_plane_state *new_primary_state =
> + intel_atomic_get_new_plane_state(state, primary);
>  
> - intel_frontbuffer_flip(to_i915(crtc->base.dev), new_crtc_state-
> >fb_bits);
> + intel_frontbuffer_flip(dev_priv, new_crtc_state->fb_bits);
>  
>   if (new_crtc_state->update_wm_post && new_crtc_state-
> >hw.active)
>   intel_update_watermarks(crtc);
> @@ -6083,16 +6081,13 @@ static void intel_post_plane_update(struct
> intel_crtc_state *old_crtc_state)
>   if (hsw_post_update_enable_ips(old_crtc_state, new_crtc_state))
>   hsw_enable_ips(new_crtc_state);
>  
> - if (old_primary_state) {
> - struct drm_plane_state *new_primary_state =
> - drm_atomic_get_new_plane_state(state, primary);
> -
> + if (new_primary_state) {


This change from old_primary_state to new_primary_state is way more
than the commit message says, the change looks right to me but maybe it
deserves a separated patch? Same for the same change in
intel_pre_plane_update()

>   intel_fbc_post_update(crtc);
>  
> - if (new_primary_state->visible &&
> + if (new_primary_state->uapi.visible &&
>   (needs_modeset(new_crtc_state) ||
> -  !old_primary_state->visible))
> - intel_post_enable_primary(&crtc->base,
> new_crtc_state);
> +  !old_primary_state->uapi.visible))
> + intel_post_enable_primary(crtc);
>   }
>  
>   if (needs_nv12_wa(old_crtc_state) &&
> @@ -6104,34 +6099,31 @@ static void intel_post_plane_update(struct
> intel_crtc_state *old_crtc_state)
>   icl_wa_scalerclkgating(dev_priv, crtc->pipe, false);
>  }
>  
> -static void intel_pre_plane_update(struct intel_crtc_state
> *old_crtc_state,
> -struct intel_crtc_state
> *new_crtc_state)
> +static void intel_pre_plane_update(struct intel_atomic_state *state,
> +struct intel

[Intel-gfx] [PATCH 4/7] drm/i915: Clean up intel_{pre, post}_plane_update()

2019-11-27 Thread Ville Syrjala
From: Ville Syrjälä 

Change the calling convention to just pass the state+crtc and
switch to intel_ types throughout.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/i915/display/intel_display.c | 88 +---
 drivers/gpu/drm/i915/display/intel_fbc.c | 14 ++--
 drivers/gpu/drm/i915/display/intel_fbc.h |  8 +-
 3 files changed, 51 insertions(+), 59 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index e341b97b7dec..72655b5b1365 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -5920,13 +5920,10 @@ static void intel_crtc_dpms_overlay_disable(struct 
intel_crtc *intel_crtc)
  * completely hide the primary plane.
  */
 static void
-intel_post_enable_primary(struct drm_crtc *crtc,
- const struct intel_crtc_state *new_crtc_state)
+intel_post_enable_primary(struct intel_crtc *crtc)
 {
-   struct drm_device *dev = crtc->dev;
-   struct drm_i915_private *dev_priv = to_i915(dev);
-   struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-   enum pipe pipe = intel_crtc->pipe;
+   struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
+   enum pipe pipe = crtc->pipe;
 
/*
 * Gen2 reports pipe underruns whenever all planes are disabled.
@@ -6062,20 +6059,21 @@ static bool needs_scalerclk_wa(const struct 
intel_crtc_state *crtc_state)
return false;
 }
 
-static void intel_post_plane_update(struct intel_crtc_state *old_crtc_state)
+static void intel_post_plane_update(struct intel_atomic_state *state,
+   struct intel_crtc *crtc)
 {
-   struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
-   struct drm_device *dev = crtc->base.dev;
-   struct drm_i915_private *dev_priv = to_i915(dev);
-   struct drm_atomic_state *state = old_crtc_state->uapi.state;
-   struct intel_crtc_state *new_crtc_state =
-   intel_atomic_get_new_crtc_state(to_intel_atomic_state(state),
-   crtc);
-   struct drm_plane *primary = crtc->base.primary;
-   struct drm_plane_state *old_primary_state =
-   drm_atomic_get_old_plane_state(state, primary);
+   struct drm_i915_private *dev_priv = to_i915(state->base.dev);
+   struct intel_plane *primary = to_intel_plane(crtc->base.primary);
+   const struct intel_crtc_state *old_crtc_state =
+   intel_atomic_get_old_crtc_state(state, crtc);
+   const struct intel_crtc_state *new_crtc_state =
+   intel_atomic_get_new_crtc_state(state, crtc);
+   const struct intel_plane_state *old_primary_state =
+   intel_atomic_get_old_plane_state(state, primary);
+   const struct intel_plane_state *new_primary_state =
+   intel_atomic_get_new_plane_state(state, primary);
 
-   intel_frontbuffer_flip(to_i915(crtc->base.dev), 
new_crtc_state->fb_bits);
+   intel_frontbuffer_flip(dev_priv, new_crtc_state->fb_bits);
 
if (new_crtc_state->update_wm_post && new_crtc_state->hw.active)
intel_update_watermarks(crtc);
@@ -6083,16 +6081,13 @@ static void intel_post_plane_update(struct 
intel_crtc_state *old_crtc_state)
if (hsw_post_update_enable_ips(old_crtc_state, new_crtc_state))
hsw_enable_ips(new_crtc_state);
 
-   if (old_primary_state) {
-   struct drm_plane_state *new_primary_state =
-   drm_atomic_get_new_plane_state(state, primary);
-
+   if (new_primary_state) {
intel_fbc_post_update(crtc);
 
-   if (new_primary_state->visible &&
+   if (new_primary_state->uapi.visible &&
(needs_modeset(new_crtc_state) ||
-!old_primary_state->visible))
-   intel_post_enable_primary(&crtc->base, new_crtc_state);
+!old_primary_state->uapi.visible))
+   intel_post_enable_primary(crtc);
}
 
if (needs_nv12_wa(old_crtc_state) &&
@@ -6104,34 +6099,31 @@ static void intel_post_plane_update(struct 
intel_crtc_state *old_crtc_state)
icl_wa_scalerclkgating(dev_priv, crtc->pipe, false);
 }
 
-static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state,
-  struct intel_crtc_state *new_crtc_state)
+static void intel_pre_plane_update(struct intel_atomic_state *state,
+  struct intel_crtc *crtc)
 {
-   struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
-   struct drm_device *dev = crtc->base.dev;
-   struct drm_i915_private *dev_priv = to_i915(dev);
-   struct drm_atomic_state *state = old_crtc_state->uapi.state;
-   struct drm_plane *primary = crtc->base.primary;
-   struct drm_plane_state *old_primary_state =
-   drm_atom