* Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
  */
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_device.h>
 #include <drm/drm_fb_cma_helper.h>
 static void arc_pgu_plane_atomic_update(struct drm_plane *plane,
                                        struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_plane_state = plane->state;
+       struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+                                                                                plane);
        struct arcpgu_drm_private *arcpgu;
        struct drm_gem_cma_object *gem;
 
 
 static void hdlcd_plane_atomic_update(struct drm_plane *plane,
                                      struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_plane_state = plane->state;
+       struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+                                                                                plane);
        struct drm_framebuffer *fb = new_plane_state->fb;
        struct hdlcd_drm_private *hdlcd;
        u32 dest_h;
 
                                                                           plane);
        struct malidp_plane *mp;
        struct malidp_plane_state *ms = to_malidp_plane_state(plane->state);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        u16 pixel_alpha = new_state->pixel_blend_mode;
        u8 plane_alpha = new_state->alpha >> 8;
        u32 src_w, src_h, dest_w, dest_h, val;
 
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct armada_crtc *dcrtc;
        struct armada_regs *regs;
        unsigned int idx;
 
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct armada_crtc *dcrtc;
        struct armada_regs *regs;
        u32 cfg, cfg_mask, val;
 
                                                                           plane);
        struct drm_device *dev = plane->dev;
        struct ast_private *ast = to_ast_private(dev);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_gem_vram_object *gbo;
        s64 gpu_addr;
        struct drm_framebuffer *fb = new_state->fb;
        struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);
        struct drm_framebuffer *fb = new_state->fb;
        struct ast_private *ast = to_ast_private(plane->dev);
 
 static void atmel_hlcdc_plane_atomic_update(struct drm_plane *p,
                                            struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_s = p->state;
+       struct drm_plane_state *new_s = drm_atomic_get_new_plane_state(state,
+                                                                      p);
        struct atmel_hlcdc_plane *plane = drm_plane_to_atmel_hlcdc_plane(p);
        struct atmel_hlcdc_plane_state *hstate =
                        drm_plane_state_to_atmel_hlcdc_plane_state(new_s);
 
 static void exynos_plane_atomic_update(struct drm_plane *plane,
                                       struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(new_state->crtc);
        struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
 
 
 
 {
        struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_framebuffer *fb = plane->state->fb;
        struct drm_gem_cma_object *gem;
        unsigned int alpha = DCU_LAYER_AB_NONE, bpp;
 
 static void hibmc_plane_atomic_update(struct drm_plane *plane,
                                      struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        u32 reg;
        s64 gpu_addr = 0;
        u32 line_l;
 
 static void ade_plane_atomic_update(struct drm_plane *plane,
                                    struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct kirin_plane *kplane = to_kirin_plane(plane);
 
        ade_update_channel(kplane, new_state->fb, new_state->crtc_x,
 
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct dcss_plane *dcss_plane = to_dcss_plane(plane);
        struct dcss_dev *dcss = plane->dev->dev_private;
        struct drm_framebuffer *fb = new_state->fb;
 
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
        struct ipu_plane *ipu_plane = to_ipu_plane(plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct ipu_plane_state *ipu_state = to_ipu_plane_state(new_state);
        struct drm_crtc_state *crtc_state = new_state->crtc->state;
        struct drm_framebuffer *fb = new_state->fb;
 
                                            struct drm_atomic_state *state)
 {
        struct ingenic_drm *priv = drm_device_get_priv(plane->dev);
-       struct drm_plane_state *newstate = plane->state;
+       struct drm_plane_state *newstate = drm_atomic_get_new_plane_state(state,
+                                                                         plane);
        struct drm_crtc_state *crtc_state;
        struct ingenic_dma_hwdesc *hwdesc;
        unsigned int width, height, cpp, offset;
 
                                            struct drm_atomic_state *state)
 {
        struct ingenic_ipu *ipu = plane_to_ingenic_ipu(plane);
-       struct drm_plane_state *newstate = plane->state;
+       struct drm_plane_state *newstate = drm_atomic_get_new_plane_state(state,
+                                                                         plane);
        const struct drm_format_info *finfo;
        u32 ctrl, stride = 0, coef_index = 0, format = 0;
        bool needs_modeset, upscaling_w, upscaling_h;
 
 {
        struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state,
                                                                                 plane);
-       struct drm_plane_state *new_plane_state = plane->state;
+       struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+                                                                                plane);
        struct drm_framebuffer *fb;
        struct kmb_drm_private *kmb;
        unsigned int width;
 
 static void mtk_plane_atomic_disable(struct drm_plane *plane,
                                     struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
        mtk_plane_state->pending.enable = false;
        wmb(); /* Make sure the above parameter is set before update */
 static void mtk_plane_atomic_update(struct drm_plane *plane,
                                    struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
        struct drm_crtc *crtc = new_state->crtc;
        struct drm_framebuffer *fb = new_state->fb;
 
                                        struct drm_atomic_state *state)
 {
        struct meson_overlay *meson_overlay = to_meson_overlay(plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_framebuffer *fb = new_state->fb;
        struct meson_drm *priv = meson_overlay->priv;
        struct drm_gem_cma_object *gem;
 
                                      struct drm_atomic_state *state)
 {
        struct meson_plane *meson_plane = to_meson_plane(plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_rect dest = drm_plane_state_dest(new_state);
        struct meson_drm *priv = meson_plane->priv;
        struct drm_framebuffer *fb = new_state->fb;
 
                                struct drm_atomic_state *state)
 {
        struct dpu_plane *pdpu = to_dpu_plane(plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
 
        pdpu->is_error = false;
 
 
  * Author: Rob Clark <robdclark@gmail.com>
  */
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_damage_helper.h>
 #include <drm/drm_fourcc.h>
 
 static void mdp4_plane_atomic_update(struct drm_plane *plane,
                                     struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        int ret;
 
        ret = mdp4_plane_mode_set(plane,
 
 static void mdp5_plane_atomic_update(struct drm_plane *plane,
                                     struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
 
        DBG("%s: update", plane->name);
 
 
        struct drm_plane_state *old_pstate = drm_atomic_get_old_plane_state(state,
                                                                            plane);
        struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(plane->dev);
-       struct drm_plane_state *new_pstate = plane->state;
+       struct drm_plane_state *new_pstate = drm_atomic_get_new_plane_state(state,
+                                                                           plane);
        dma_addr_t paddr;
        u32 ctrl;
 
 
 {
        struct omap_drm_private *priv = plane->dev->dev_private;
        struct omap_plane *omap_plane = to_omap_plane(plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct omap_overlay_info info;
        int ret;
 
 static void omap_plane_atomic_disable(struct drm_plane *plane,
                                      struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct omap_drm_private *priv = plane->dev->dev_private;
        struct omap_plane *omap_plane = to_omap_plane(plane);
 
 
 static void qxl_primary_atomic_update(struct drm_plane *plane,
                                      struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct qxl_device *qdev = to_qxl(plane->dev);
        struct qxl_bo *bo = gem_to_qxl_bo(new_state->fb->obj[0]);
        struct qxl_bo *primary;
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct qxl_device *qdev = to_qxl(plane->dev);
        struct drm_framebuffer *fb = new_state->fb;
 
 
                                        struct drm_atomic_state *state)
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
        struct rcar_du_plane *rplane = to_rcar_plane(plane);
        struct rcar_du_plane_state *old_rstate;
        struct rcar_du_plane_state *new_rstate;
 
                                        struct drm_atomic_state *state)
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
        struct rcar_du_vsp_plane *rplane = to_rcar_vsp_plane(plane);
        struct rcar_du_crtc *crtc = to_rcar_crtc(old_state->crtc);
 
 
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_crtc *crtc = new_state->crtc;
        struct vop_win *vop_win = to_vop_win(plane);
        const struct vop_win_data *win = vop_win->data;
 
 static void sti_cursor_atomic_update(struct drm_plane *drm_plane,
                                     struct drm_atomic_state *state)
 {
-       struct drm_plane_state *newstate = drm_plane->state;
+       struct drm_plane_state *newstate = drm_atomic_get_new_plane_state(state,
+                                                                         drm_plane);
        struct sti_plane *plane = to_sti_plane(drm_plane);
        struct sti_cursor *cursor = to_sti_cursor(plane);
        struct drm_crtc *crtc = newstate->crtc;
 
 {
        struct drm_plane_state *oldstate = drm_atomic_get_old_plane_state(state,
                                                                          drm_plane);
-       struct drm_plane_state *newstate = drm_plane->state;
+       struct drm_plane_state *newstate = drm_atomic_get_new_plane_state(state,
+                                                                         drm_plane);
        struct sti_plane *plane = to_sti_plane(drm_plane);
        struct sti_gdp *gdp = to_sti_gdp(plane);
        struct drm_crtc *crtc = newstate->crtc;
 
 {
        struct drm_plane_state *oldstate = drm_atomic_get_old_plane_state(state,
                                                                          drm_plane);
-       struct drm_plane_state *newstate = drm_plane->state;
+       struct drm_plane_state *newstate = drm_atomic_get_new_plane_state(state,
+                                                                         drm_plane);
        struct sti_plane *plane = to_sti_plane(drm_plane);
        struct sti_hqvdp *hqvdp = to_sti_hqvdp(plane);
        struct drm_crtc *crtc = newstate->crtc;
 
                                     struct drm_atomic_state *state)
 {
        struct ltdc_device *ldev = plane_to_ltdc(plane);
-       struct drm_plane_state *newstate = plane->state;
+       struct drm_plane_state *newstate = drm_atomic_get_new_plane_state(state,
+                                                                         plane);
        struct drm_framebuffer *fb = newstate->fb;
        u32 lofs = plane->index * LAY_OFS;
        u32 x0 = newstate->crtc_x;
 
 static void sun4i_backend_layer_atomic_update(struct drm_plane *plane,
                                              struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct sun4i_layer_state *layer_state = state_to_sun4i_layer_state(new_state);
        struct sun4i_layer *layer = plane_to_sun4i_layer(plane);
        struct sun4i_backend *backend = layer->backend;
 
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct sun8i_ui_layer *layer = plane_to_sun8i_ui_layer(plane);
        unsigned int zpos = new_state->normalized_zpos;
        unsigned int old_zpos = old_state->normalized_zpos;
 
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct sun8i_vi_layer *layer = plane_to_sun8i_vi_layer(plane);
        unsigned int zpos = new_state->normalized_zpos;
        unsigned int old_zpos = old_state->normalized_zpos;
 
 static void tegra_plane_atomic_update(struct drm_plane *plane,
                                      struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct tegra_plane_state *tegra_plane_state = to_tegra_plane_state(new_state);
        struct drm_framebuffer *fb = new_state->fb;
        struct tegra_plane *p = to_tegra_plane(plane);
 static void tegra_cursor_atomic_update(struct drm_plane *plane,
                                       struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct tegra_plane_state *tegra_plane_state = to_tegra_plane_state(new_state);
        struct tegra_dc *dc = to_tegra_dc(new_state->crtc);
        u32 value = CURSOR_CLIP_DISPLAY;
 
 static void tegra_shared_plane_atomic_update(struct drm_plane *plane,
                                             struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct tegra_plane_state *tegra_plane_state = to_tegra_plane_state(new_state);
        struct tegra_dc *dc = to_tegra_dc(new_state->crtc);
        unsigned int zpos = new_state->normalized_zpos;
 
        struct drm_device *ddev = plane->dev;
        struct tidss_device *tidss = to_tidss(ddev);
        struct tidss_plane *tplane = to_tidss_plane(plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        u32 hw_videoport;
        int ret;
 
 
 static void tilcdc_plane_atomic_update(struct drm_plane *plane,
                                       struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
 
        if (!new_state->crtc)
                return;
 
 static void vbox_primary_atomic_update(struct drm_plane *plane,
                                       struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_crtc *crtc = new_state->crtc;
        struct drm_framebuffer *fb = new_state->fb;
        struct vbox_private *vbox = to_vbox_dev(fb->dev);
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct vbox_private *vbox =
                container_of(plane->dev, struct vbox_private, ddev);
        struct vbox_crtc *vbox_crtc = to_vbox_crtc(new_state->crtc);
 
 static void vkms_plane_atomic_update(struct drm_plane *plane,
                                     struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct vkms_plane_state *vkms_plane_state;
        struct drm_framebuffer *fb = new_state->fb;
        struct vkms_composer *composer;
 
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
                                                                           plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct vmw_private *dev_priv;
        struct vmw_legacy_display_unit *ldu;
        struct vmw_framebuffer *vfb;
 
                                    struct drm_atomic_state *state)
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
        struct drm_crtc *crtc = new_state->crtc;
        struct drm_pending_vblank_event *event = NULL;
        struct vmw_fence_obj *fence = NULL;
 
                                     struct drm_atomic_state *state)
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
        struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state);
        struct drm_crtc *crtc = new_state->crtc;
        struct vmw_screen_target_display_unit *stdu;
 
                                struct drm_atomic_state *state)
 {
        struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
        struct zynqmp_disp_layer *layer = plane_to_layer(plane);
        bool format_changed = false;
 
 
                                      struct drm_atomic_state *state)
 {
        struct zx_plane *zplane = to_zx_plane(plane);
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct drm_framebuffer *fb = new_state->fb;
        struct drm_rect *src = &new_state->src;
        struct drm_rect *dst = &new_state->dst;
 static void zx_gl_plane_atomic_update(struct drm_plane *plane,
                                      struct drm_atomic_state *state)
 {
-       struct drm_plane_state *new_state = plane->state;
+       struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+                                                                          plane);
        struct zx_plane *zplane = to_zx_plane(plane);
        struct drm_framebuffer *fb = new_state->fb;
        struct drm_gem_cma_object *cma_obj;