1 From 27a4cd3c9986626cc731282e2e4887121f72f5f7 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 28 Oct 2020 13:32:21 +0100
4 Subject: [PATCH] drm/atomic: Pass the full state to CRTC atomic_check
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Commit 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4 upstream.
11 The current atomic helpers have either their object state being passed as
12 an argument or the full atomic state.
14 The former is the pattern that was done at first, before switching to the
15 latter for new hooks or when it was needed.
17 Let's start convert all the remaining helpers to provide a consistent
18 interface, starting with the CRTC's atomic_check.
20 The conversion was done using the coccinelle script below,
21 built tested on all the drivers and actually tested on vc4.
26 struct drm_crtc_helper_funcs *FUNCS;
27 struct drm_crtc *crtc;
28 struct drm_crtc_state *crtc_state;
29 identifier dev, state;
33 f(struct drm_device *dev, struct drm_atomic_state *state)
36 - ret = FUNCS->atomic_check(crtc, crtc_state);
37 + ret = FUNCS->atomic_check(crtc, state);
42 identifier crtc, new_state;
45 struct drm_crtc_helper_funcs {
47 - int (*atomic_check)(struct drm_crtc *crtc, struct drm_crtc_state *new_state);
48 + int (*atomic_check)(struct drm_crtc *crtc, struct drm_atomic_state *state);
57 static struct drm_crtc_helper_funcs helpers = {
64 identifier crtc_atomic_func.func;
65 identifier crtc, new_state;
68 int func(struct drm_crtc *crtc,
69 struct drm_crtc_state *new_state)
74 @ adds_new_state depends on crtc_atomic_func && !ignores_new_state @
75 identifier crtc_atomic_func.func;
76 identifier crtc, new_state;
79 int func(struct drm_crtc *crtc, struct drm_crtc_state *new_state)
81 + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
85 @ depends on crtc_atomic_func @
86 identifier crtc_atomic_func.func;
102 @ depends on crtc_atomic_func @
103 identifier crtc_atomic_func.func;
118 @ depends on crtc_atomic_func @
119 identifier crtc_atomic_func.func;
120 identifier new_state;
124 int func(struct drm_crtc *crtc,
125 - struct drm_crtc_state *new_state
126 + struct drm_atomic_state *state
131 identifier new_state;
135 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
136 - struct drm_crtc_state *new_state
137 + struct drm_atomic_state *state
140 + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
145 identifier new_state;
149 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
150 - struct drm_crtc_state *new_state
151 + struct drm_atomic_state *state
154 @ include depends on adds_new_state @
157 #include <drm/drm_atomic.h>
159 @ no_include depends on !include && adds_new_state @
162 + #include <drm/drm_atomic.h>
165 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
166 Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
167 Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
168 Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-1-maxime@cerno.tech
170 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 ++++++-----
171 .../gpu/drm/arm/display/komeda/komeda_crtc.c | 10 ++++----
172 drivers/gpu/drm/arm/malidp_crtc.c | 20 ++++++++--------
173 drivers/gpu/drm/armada/armada_crtc.c | 10 ++++----
174 drivers/gpu/drm/ast/ast_mode.c | 12 ++++++----
175 .../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 3 ++-
176 drivers/gpu/drm/drm_atomic_helper.c | 2 +-
177 drivers/gpu/drm/drm_simple_kms_helper.c | 10 ++++----
178 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 8 ++++---
179 drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++--
180 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 15 ++++++++----
181 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 23 +++++++++++--------
182 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 2 +-
183 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 13 +++++++----
184 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 10 ++++----
185 drivers/gpu/drm/nouveau/dispnv50/head.c | 7 ++++--
186 drivers/gpu/drm/omapdrm/omap_crtc.c | 13 +++++++----
187 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 11 +++++----
188 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 +++-
189 drivers/gpu/drm/sun4i/sun4i_crtc.c | 7 ++++--
190 drivers/gpu/drm/tidss/tidss_crtc.c | 10 ++++----
191 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 12 ++++++----
192 drivers/gpu/drm/vc4/vc4_crtc.c | 11 +++++----
193 drivers/gpu/drm/vc4/vc4_txp.c | 10 ++++----
194 drivers/gpu/drm/virtio/virtgpu_display.c | 2 +-
195 drivers/gpu/drm/vkms/vkms_crtc.c | 16 +++++++------
196 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 4 +++-
197 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 +-
198 drivers/gpu/drm/xlnx/zynqmp_disp.c | 6 +++--
199 include/drm/drm_modeset_helper_vtables.h | 5 ++--
200 30 files changed, 168 insertions(+), 110 deletions(-)
202 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
203 +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
204 @@ -5638,17 +5638,19 @@ static void dm_update_crtc_active_planes
207 static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc,
208 - struct drm_crtc_state *state)
209 + struct drm_atomic_state *state)
211 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
213 struct amdgpu_device *adev = drm_to_adev(crtc->dev);
214 struct dc *dc = adev->dm.dc;
215 - struct dm_crtc_state *dm_crtc_state = to_dm_crtc_state(state);
216 + struct dm_crtc_state *dm_crtc_state = to_dm_crtc_state(crtc_state);
219 - dm_update_crtc_active_planes(crtc, state);
220 + dm_update_crtc_active_planes(crtc, crtc_state);
222 if (unlikely(!dm_crtc_state->stream &&
223 - modeset_required(state, NULL, dm_crtc_state->stream))) {
224 + modeset_required(crtc_state, NULL, dm_crtc_state->stream))) {
228 @@ -5659,8 +5661,8 @@ static int dm_crtc_helper_atomic_check(s
229 * planes are disabled, which is not supported by the hardware. And there is legacy
230 * userspace which stops using the HW cursor altogether in response to the resulting EINVAL.
232 - if (state->enable &&
233 - !(state->plane_mask & drm_plane_mask(crtc->primary)))
234 + if (crtc_state->enable &&
235 + !(crtc_state->plane_mask & drm_plane_mask(crtc->primary)))
238 /* In some use cases, like reset, no stream is attached */
239 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
240 +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
241 @@ -74,16 +74,18 @@ static void komeda_crtc_update_clock_rat
244 komeda_crtc_atomic_check(struct drm_crtc *crtc,
245 - struct drm_crtc_state *state)
246 + struct drm_atomic_state *state)
248 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
250 struct komeda_crtc *kcrtc = to_kcrtc(crtc);
251 - struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(state);
252 + struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(crtc_state);
255 - if (drm_atomic_crtc_needs_modeset(state))
256 + if (drm_atomic_crtc_needs_modeset(crtc_state))
257 komeda_crtc_update_clock_ratio(kcrtc_st);
259 - if (state->active) {
260 + if (crtc_state->active) {
261 err = komeda_build_display_data_flow(kcrtc, kcrtc_st);
264 --- a/drivers/gpu/drm/arm/malidp_crtc.c
265 +++ b/drivers/gpu/drm/arm/malidp_crtc.c
266 @@ -337,8 +337,10 @@ mclk_calc:
269 static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
270 - struct drm_crtc_state *state)
271 + struct drm_atomic_state *state)
273 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
275 struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
276 struct malidp_hw_device *hwdev = malidp->dev;
277 struct drm_plane *plane;
278 @@ -373,7 +375,7 @@ static int malidp_crtc_atomic_check(stru
281 /* first count the number of rotated planes */
282 - drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
283 + drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
284 struct drm_framebuffer *fb = pstate->fb;
286 if ((pstate->rotation & MALIDP_ROTATED_MASK) || fb->modifier)
287 @@ -389,7 +391,7 @@ static int malidp_crtc_atomic_check(stru
288 rot_mem_free += hwdev->rotation_memory[1];
290 /* now validate the rotation memory requirements */
291 - drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
292 + drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
293 struct malidp_plane *mp = to_malidp_plane(plane);
294 struct malidp_plane_state *ms = to_malidp_plane_state(pstate);
295 struct drm_framebuffer *fb = pstate->fb;
296 @@ -417,18 +419,18 @@ static int malidp_crtc_atomic_check(stru
299 /* If only the writeback routing has changed, we don't need a modeset */
300 - if (state->connectors_changed) {
301 + if (crtc_state->connectors_changed) {
302 u32 old_mask = crtc->state->connector_mask;
303 - u32 new_mask = state->connector_mask;
304 + u32 new_mask = crtc_state->connector_mask;
306 if ((old_mask ^ new_mask) ==
307 (1 << drm_connector_index(&malidp->mw_connector.base)))
308 - state->connectors_changed = false;
309 + crtc_state->connectors_changed = false;
312 - ret = malidp_crtc_atomic_check_gamma(crtc, state);
313 - ret = ret ? ret : malidp_crtc_atomic_check_ctm(crtc, state);
314 - ret = ret ? ret : malidp_crtc_atomic_check_scaling(crtc, state);
315 + ret = malidp_crtc_atomic_check_gamma(crtc, crtc_state);
316 + ret = ret ? ret : malidp_crtc_atomic_check_ctm(crtc, crtc_state);
317 + ret = ret ? ret : malidp_crtc_atomic_check_scaling(crtc, crtc_state);
321 --- a/drivers/gpu/drm/armada/armada_crtc.c
322 +++ b/drivers/gpu/drm/armada/armada_crtc.c
323 @@ -413,15 +413,17 @@ static void armada_drm_crtc_mode_set_nof
326 static int armada_drm_crtc_atomic_check(struct drm_crtc *crtc,
327 - struct drm_crtc_state *state)
328 + struct drm_atomic_state *state)
330 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
332 DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
334 - if (state->gamma_lut && drm_color_lut_size(state->gamma_lut) != 256)
335 + if (crtc_state->gamma_lut && drm_color_lut_size(crtc_state->gamma_lut) != 256)
338 - if (state->color_mgmt_changed)
339 - state->planes_changed = true;
340 + if (crtc_state->color_mgmt_changed)
341 + crtc_state->planes_changed = true;
345 --- a/drivers/gpu/drm/ast/ast_mode.c
346 +++ b/drivers/gpu/drm/ast/ast_mode.c
347 @@ -751,24 +751,26 @@ static void ast_crtc_dpms(struct drm_crt
350 static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
351 - struct drm_crtc_state *state)
352 + struct drm_atomic_state *state)
354 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
356 struct drm_device *dev = crtc->dev;
357 struct ast_crtc_state *ast_state;
358 const struct drm_format_info *format;
361 - if (!state->enable)
362 + if (!crtc_state->enable)
363 return 0; /* no mode checks if CRTC is being disabled */
365 - ast_state = to_ast_crtc_state(state);
366 + ast_state = to_ast_crtc_state(crtc_state);
368 format = ast_state->format;
369 if (drm_WARN_ON_ONCE(dev, !format))
370 return -EINVAL; /* BUG: We didn't set format in primary check(). */
372 - succ = ast_get_vbios_mode_info(format, &state->mode,
373 - &state->adjusted_mode,
374 + succ = ast_get_vbios_mode_info(format, &crtc_state->mode,
375 + &crtc_state->adjusted_mode,
376 &ast_state->vbios_mode_info);
379 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
380 +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
381 @@ -325,8 +325,9 @@ static int atmel_hlcdc_crtc_select_outpu
384 static int atmel_hlcdc_crtc_atomic_check(struct drm_crtc *c,
385 - struct drm_crtc_state *s)
386 + struct drm_atomic_state *state)
388 + struct drm_crtc_state *s = drm_atomic_get_new_crtc_state(state, c);
391 ret = atmel_hlcdc_crtc_select_output_mode(s);
392 --- a/drivers/gpu/drm/drm_atomic_helper.c
393 +++ b/drivers/gpu/drm/drm_atomic_helper.c
394 @@ -918,7 +918,7 @@ drm_atomic_helper_check_planes(struct dr
395 if (!funcs || !funcs->atomic_check)
398 - ret = funcs->atomic_check(crtc, new_crtc_state);
399 + ret = funcs->atomic_check(crtc, state);
401 DRM_DEBUG_ATOMIC("[CRTC:%d:%s] atomic driver check failed\n",
402 crtc->base.id, crtc->name);
403 --- a/drivers/gpu/drm/drm_simple_kms_helper.c
404 +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
405 @@ -86,16 +86,18 @@ drm_simple_kms_crtc_mode_valid(struct dr
408 static int drm_simple_kms_crtc_check(struct drm_crtc *crtc,
409 - struct drm_crtc_state *state)
410 + struct drm_atomic_state *state)
412 - bool has_primary = state->plane_mask &
413 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
415 + bool has_primary = crtc_state->plane_mask &
416 drm_plane_mask(crtc->primary);
418 /* We always want to have an active plane with an active CRTC */
419 - if (has_primary != state->enable)
420 + if (has_primary != crtc_state->enable)
423 - return drm_atomic_add_affected_planes(state->state, crtc);
424 + return drm_atomic_add_affected_planes(crtc_state->state, crtc);
427 static void drm_simple_kms_crtc_enable(struct drm_crtc *crtc,
428 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
429 +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
430 @@ -49,15 +49,17 @@ static void exynos_drm_crtc_atomic_disab
433 static int exynos_crtc_atomic_check(struct drm_crtc *crtc,
434 - struct drm_crtc_state *state)
435 + struct drm_atomic_state *state)
437 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
439 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
441 - if (!state->enable)
442 + if (!crtc_state->enable)
445 if (exynos_crtc->ops->atomic_check)
446 - return exynos_crtc->ops->atomic_check(exynos_crtc, state);
447 + return exynos_crtc->ops->atomic_check(exynos_crtc, crtc_state);
451 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c
452 +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
453 @@ -227,11 +227,13 @@ static bool ipu_crtc_mode_fixup(struct d
456 static int ipu_crtc_atomic_check(struct drm_crtc *crtc,
457 - struct drm_crtc_state *state)
458 + struct drm_atomic_state *state)
460 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
462 u32 primary_plane_mask = drm_plane_mask(crtc->primary);
464 - if (state->active && (primary_plane_mask & state->plane_mask) == 0)
465 + if (crtc_state->active && (primary_plane_mask & crtc_state->plane_mask) == 0)
469 --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
470 +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
471 @@ -234,22 +234,27 @@ static void ingenic_drm_crtc_update_timi
474 static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
475 - struct drm_crtc_state *state)
476 + struct drm_atomic_state *state)
478 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
480 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
481 struct drm_plane_state *f1_state, *f0_state, *ipu_state = NULL;
483 - if (drm_atomic_crtc_needs_modeset(state) && priv->soc_info->has_osd) {
484 - f1_state = drm_atomic_get_plane_state(state->state, &priv->f1);
485 + if (drm_atomic_crtc_needs_modeset(crtc_state) && priv->soc_info->has_osd) {
486 + f1_state = drm_atomic_get_plane_state(crtc_state->state,
488 if (IS_ERR(f1_state))
489 return PTR_ERR(f1_state);
491 - f0_state = drm_atomic_get_plane_state(state->state, &priv->f0);
492 + f0_state = drm_atomic_get_plane_state(crtc_state->state,
494 if (IS_ERR(f0_state))
495 return PTR_ERR(f0_state);
497 if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && priv->ipu_plane) {
498 - ipu_state = drm_atomic_get_plane_state(state->state, priv->ipu_plane);
499 + ipu_state = drm_atomic_get_plane_state(crtc_state->state,
501 if (IS_ERR(ipu_state))
502 return PTR_ERR(ipu_state);
504 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
505 +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
506 @@ -815,10 +815,12 @@ struct plane_state {
509 static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
510 - struct drm_crtc_state *state)
511 + struct drm_atomic_state *state)
513 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
515 struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
516 - struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
517 + struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc_state);
518 struct plane_state *pstates;
520 const struct drm_plane_state *pstate;
521 @@ -835,32 +837,33 @@ static int dpu_crtc_atomic_check(struct
523 pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
525 - if (!state->enable || !state->active) {
526 + if (!crtc_state->enable || !crtc_state->active) {
527 DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n",
528 - crtc->base.id, state->enable, state->active);
529 + crtc->base.id, crtc_state->enable,
530 + crtc_state->active);
534 - mode = &state->adjusted_mode;
535 + mode = &crtc_state->adjusted_mode;
536 DPU_DEBUG("%s: check", dpu_crtc->name);
538 /* force a full mode set if active state changed */
539 - if (state->active_changed)
540 - state->mode_changed = true;
541 + if (crtc_state->active_changed)
542 + crtc_state->mode_changed = true;
544 memset(pipe_staged, 0, sizeof(pipe_staged));
546 if (cstate->num_mixers) {
547 mixer_width = mode->hdisplay / cstate->num_mixers;
549 - _dpu_crtc_setup_lm_bounds(crtc, state);
550 + _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
553 crtc_rect.x2 = mode->hdisplay;
554 crtc_rect.y2 = mode->vdisplay;
556 /* get plane state for all drm planes associated with crtc state */
557 - drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
558 + drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
559 struct drm_rect dst, clip = crtc_rect;
561 if (IS_ERR_OR_NULL(pstate)) {
562 @@ -966,7 +969,7 @@ static int dpu_crtc_atomic_check(struct
564 atomic_inc(&_dpu_crtc_get_kms(crtc)->bandwidth_ref);
566 - rc = dpu_core_perf_crtc_check(crtc, state);
567 + rc = dpu_core_perf_crtc_check(crtc, crtc_state);
569 DPU_ERROR("crtc%d failed performance check %d\n",
571 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
572 +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
573 @@ -307,7 +307,7 @@ static void mdp4_crtc_atomic_enable(stru
576 static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
577 - struct drm_crtc_state *state)
578 + struct drm_atomic_state *state)
580 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
581 DBG("%s: check", mdp4_crtc->name);
582 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
583 +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
586 #include <linux/sort.h>
588 +#include <drm/drm_atomic.h>
589 #include <drm/drm_mode.h>
590 #include <drm/drm_crtc.h>
591 #include <drm/drm_flip_work.h>
592 @@ -688,15 +689,17 @@ static enum mdp_mixer_stage_id get_start
595 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
596 - struct drm_crtc_state *state)
597 + struct drm_atomic_state *state)
599 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
601 struct mdp5_kms *mdp5_kms = get_kms(crtc);
602 struct drm_plane *plane;
603 struct drm_device *dev = crtc->dev;
604 struct plane_state pstates[STAGE_MAX + 1];
605 const struct mdp5_cfg_hw *hw_cfg;
606 const struct drm_plane_state *pstate;
607 - const struct drm_display_mode *mode = &state->adjusted_mode;
608 + const struct drm_display_mode *mode = &crtc_state->adjusted_mode;
609 bool cursor_plane = false;
610 bool need_right_mixer = false;
612 @@ -705,7 +708,7 @@ static int mdp5_crtc_atomic_check(struct
614 DBG("%s: check", crtc->name);
616 - drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
617 + drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
618 if (!pstate->visible)
621 @@ -737,7 +740,7 @@ static int mdp5_crtc_atomic_check(struct
622 if (mode->hdisplay > hw_cfg->lm.max_width)
623 need_right_mixer = true;
625 - ret = mdp5_crtc_setup_pipeline(crtc, state, need_right_mixer);
626 + ret = mdp5_crtc_setup_pipeline(crtc, crtc_state, need_right_mixer);
628 DRM_DEV_ERROR(dev->dev, "couldn't assign mixers %d\n", ret);
630 @@ -750,7 +753,7 @@ static int mdp5_crtc_atomic_check(struct
631 WARN_ON(cursor_plane &&
632 (pstates[cnt - 1].plane->type != DRM_PLANE_TYPE_CURSOR));
634 - start = get_start_stage(crtc, state, &pstates[0].state->base);
635 + start = get_start_stage(crtc, crtc_state, &pstates[0].state->base);
637 /* verify that there are not too many planes attached to crtc
638 * and that we don't have conflicting mixer stages:
639 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
640 +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
641 @@ -310,17 +310,19 @@ static void mxsfb_crtc_mode_set_nofb(str
644 static int mxsfb_crtc_atomic_check(struct drm_crtc *crtc,
645 - struct drm_crtc_state *state)
646 + struct drm_atomic_state *state)
648 - bool has_primary = state->plane_mask &
649 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
651 + bool has_primary = crtc_state->plane_mask &
652 drm_plane_mask(crtc->primary);
654 /* The primary plane has to be enabled when the CRTC is active. */
655 - if (state->active && !has_primary)
656 + if (crtc_state->active && !has_primary)
659 /* TODO: Is this needed ? */
660 - return drm_atomic_add_affected_planes(state->state, crtc);
661 + return drm_atomic_add_affected_planes(crtc_state->state, crtc);
664 static void mxsfb_crtc_atomic_flush(struct drm_crtc *crtc,
665 --- a/drivers/gpu/drm/nouveau/dispnv50/head.c
666 +++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
668 #include <nvif/event.h>
669 #include <nvif/cl0046.h>
671 +#include <drm/drm_atomic.h>
672 #include <drm/drm_atomic_helper.h>
673 #include <drm/drm_crtc_helper.h>
674 #include <drm/drm_vblank.h>
675 @@ -315,12 +316,14 @@ nv50_head_atomic_check_mode(struct nv50_
679 -nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state)
680 +nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
682 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
684 struct nouveau_drm *drm = nouveau_drm(crtc->dev);
685 struct nv50_head *head = nv50_head(crtc);
686 struct nv50_head_atom *armh = nv50_head_atom(crtc->state);
687 - struct nv50_head_atom *asyh = nv50_head_atom(state);
688 + struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
689 struct nouveau_conn_atom *asyc = NULL;
690 struct drm_connector_state *conns;
691 struct drm_connector *conn;
692 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
693 +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
694 @@ -569,22 +569,25 @@ static bool omap_crtc_is_manually_update
697 static int omap_crtc_atomic_check(struct drm_crtc *crtc,
698 - struct drm_crtc_state *state)
699 + struct drm_atomic_state *state)
701 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
703 struct drm_plane_state *pri_state;
705 - if (state->color_mgmt_changed && state->gamma_lut) {
706 - unsigned int length = state->gamma_lut->length /
707 + if (crtc_state->color_mgmt_changed && crtc_state->gamma_lut) {
708 + unsigned int length = crtc_state->gamma_lut->length /
709 sizeof(struct drm_color_lut);
715 - pri_state = drm_atomic_get_new_plane_state(state->state, crtc->primary);
716 + pri_state = drm_atomic_get_new_plane_state(crtc_state->state,
719 struct omap_crtc_state *omap_crtc_state =
720 - to_omap_crtc_state(state);
721 + to_omap_crtc_state(crtc_state);
723 /* Mirror new values for zpos and rotation in omap_crtc_state */
724 omap_crtc_state->zpos = pri_state->zpos;
725 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
726 +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
727 @@ -688,20 +688,23 @@ static void rcar_du_crtc_stop(struct rca
730 static int rcar_du_crtc_atomic_check(struct drm_crtc *crtc,
731 - struct drm_crtc_state *state)
732 + struct drm_atomic_state *state)
734 - struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(state);
735 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
737 + struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(crtc_state);
738 struct drm_encoder *encoder;
741 - ret = rcar_du_cmm_check(crtc, state);
742 + ret = rcar_du_cmm_check(crtc, crtc_state);
746 /* Store the routes from the CRTC output to the DU outputs. */
749 - drm_for_each_encoder_mask(encoder, crtc->dev, state->encoder_mask) {
750 + drm_for_each_encoder_mask(encoder, crtc->dev,
751 + crtc_state->encoder_mask) {
752 struct rcar_du_encoder *renc;
754 /* Skip the writeback encoder. */
755 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
756 +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
757 @@ -1416,8 +1416,10 @@ static void vop_wait_for_irq_handler(str
760 static int vop_crtc_atomic_check(struct drm_crtc *crtc,
761 - struct drm_crtc_state *crtc_state)
762 + struct drm_atomic_state *state)
764 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
766 struct vop *vop = to_vop(crtc);
767 struct drm_plane *plane;
768 struct drm_plane_state *plane_state;
769 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
770 +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
773 #include <video/videomode.h>
775 +#include <drm/drm_atomic.h>
776 #include <drm/drm_atomic_helper.h>
777 #include <drm/drm_crtc.h>
778 #include <drm/drm_modes.h>
779 @@ -45,14 +46,16 @@ static struct drm_encoder *sun4i_crtc_ge
782 static int sun4i_crtc_atomic_check(struct drm_crtc *crtc,
783 - struct drm_crtc_state *state)
784 + struct drm_atomic_state *state)
786 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
788 struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
789 struct sunxi_engine *engine = scrtc->engine;
792 if (engine && engine->ops && engine->ops->atomic_check)
793 - ret = engine->ops->atomic_check(engine, state);
794 + ret = engine->ops->atomic_check(engine, crtc_state);
798 --- a/drivers/gpu/drm/tidss/tidss_crtc.c
799 +++ b/drivers/gpu/drm/tidss/tidss_crtc.c
800 @@ -85,8 +85,10 @@ void tidss_crtc_error_irq(struct drm_crt
801 /* drm_crtc_helper_funcs */
803 static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
804 - struct drm_crtc_state *state)
805 + struct drm_atomic_state *state)
807 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
809 struct drm_device *ddev = crtc->dev;
810 struct tidss_device *tidss = to_tidss(ddev);
811 struct dispc_device *dispc = tidss->dispc;
812 @@ -97,10 +99,10 @@ static int tidss_crtc_atomic_check(struc
814 dev_dbg(ddev->dev, "%s\n", __func__);
816 - if (!state->enable)
817 + if (!crtc_state->enable)
820 - mode = &state->adjusted_mode;
821 + mode = &crtc_state->adjusted_mode;
823 ok = dispc_vp_mode_valid(dispc, hw_videoport, mode);
825 @@ -109,7 +111,7 @@ static int tidss_crtc_atomic_check(struc
829 - return dispc_vp_bus_check(dispc, hw_videoport, state);
830 + return dispc_vp_bus_check(dispc, hw_videoport, crtc_state);
834 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
835 +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
836 @@ -669,15 +669,17 @@ static bool tilcdc_crtc_mode_fixup(struc
839 static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
840 - struct drm_crtc_state *state)
841 + struct drm_atomic_state *state)
843 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
845 /* If we are not active we don't care */
846 - if (!state->active)
847 + if (!crtc_state->active)
850 - if (state->state->planes[0].ptr != crtc->primary ||
851 - state->state->planes[0].state == NULL ||
852 - state->state->planes[0].state->crtc != crtc) {
853 + if (crtc_state->state->planes[0].ptr != crtc->primary ||
854 + crtc_state->state->planes[0].state == NULL ||
855 + crtc_state->state->planes[0].state->crtc != crtc) {
856 dev_dbg(crtc->dev->dev, "CRTC primary plane must be present");
859 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
860 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
861 @@ -603,18 +603,21 @@ void vc4_crtc_get_margins(struct drm_crt
864 static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
865 - struct drm_crtc_state *state)
866 + struct drm_atomic_state *state)
868 - struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
869 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
871 + struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
872 struct drm_connector *conn;
873 struct drm_connector_state *conn_state;
876 - ret = vc4_hvs_atomic_check(crtc, state);
877 + ret = vc4_hvs_atomic_check(crtc, crtc_state);
881 - for_each_new_connector_in_state(state->state, conn, conn_state, i) {
882 + for_each_new_connector_in_state(crtc_state->state, conn, conn_state,
884 if (conn_state->crtc != crtc)
887 --- a/drivers/gpu/drm/vc4/vc4_txp.c
888 +++ b/drivers/gpu/drm/vc4/vc4_txp.c
889 @@ -392,16 +392,18 @@ static const struct drm_crtc_funcs vc4_t
892 static int vc4_txp_atomic_check(struct drm_crtc *crtc,
893 - struct drm_crtc_state *state)
894 + struct drm_atomic_state *state)
896 - struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
897 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
899 + struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
902 - ret = vc4_hvs_atomic_check(crtc, state);
903 + ret = vc4_hvs_atomic_check(crtc, crtc_state);
907 - state->no_vblank = true;
908 + crtc_state->no_vblank = true;
909 vc4_state->feed_txp = true;
912 --- a/drivers/gpu/drm/virtio/virtgpu_display.c
913 +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
914 @@ -111,7 +111,7 @@ static void virtio_gpu_crtc_atomic_disab
917 static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
918 - struct drm_crtc_state *state)
919 + struct drm_atomic_state *state)
923 --- a/drivers/gpu/drm/vkms/vkms_crtc.c
924 +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
925 @@ -169,9 +169,11 @@ static const struct drm_crtc_funcs vkms_
928 static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
929 - struct drm_crtc_state *state)
930 + struct drm_atomic_state *state)
932 - struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(state);
933 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
935 + struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(crtc_state);
936 struct drm_plane *plane;
937 struct drm_plane_state *plane_state;
939 @@ -179,12 +181,12 @@ static int vkms_crtc_atomic_check(struct
940 if (vkms_state->active_planes)
943 - ret = drm_atomic_add_affected_planes(state->state, crtc);
944 + ret = drm_atomic_add_affected_planes(crtc_state->state, crtc);
948 - drm_for_each_plane_mask(plane, crtc->dev, state->plane_mask) {
949 - plane_state = drm_atomic_get_existing_plane_state(state->state,
950 + drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
951 + plane_state = drm_atomic_get_existing_plane_state(crtc_state->state,
953 WARN_ON(!plane_state);
955 @@ -200,8 +202,8 @@ static int vkms_crtc_atomic_check(struct
956 vkms_state->num_active_planes = i;
959 - drm_for_each_plane_mask(plane, crtc->dev, state->plane_mask) {
960 - plane_state = drm_atomic_get_existing_plane_state(state->state,
961 + drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
962 + plane_state = drm_atomic_get_existing_plane_state(crtc_state->state,
965 if (!plane_state->visible)
966 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
967 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
968 @@ -522,8 +522,10 @@ int vmw_du_cursor_plane_atomic_check(str
971 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
972 - struct drm_crtc_state *new_state)
973 + struct drm_atomic_state *state)
975 + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state,
977 struct vmw_display_unit *du = vmw_crtc_to_du(new_state->crtc);
978 int connector_mask = drm_connector_mask(&du->connector);
979 bool has_primary = new_state->plane_mask &
980 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
981 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
982 @@ -473,7 +473,7 @@ void vmw_du_plane_unpin_surf(struct vmw_
985 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
986 - struct drm_crtc_state *state);
987 + struct drm_atomic_state *state);
988 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
989 struct drm_crtc_state *old_crtc_state);
990 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
991 --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
992 +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
993 @@ -1506,9 +1506,11 @@ zynqmp_disp_crtc_atomic_disable(struct d
996 static int zynqmp_disp_crtc_atomic_check(struct drm_crtc *crtc,
997 - struct drm_crtc_state *state)
998 + struct drm_atomic_state *state)
1000 - return drm_atomic_add_affected_planes(state->state, crtc);
1001 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
1003 + return drm_atomic_add_affected_planes(crtc_state->state, crtc);
1007 --- a/include/drm/drm_modeset_helper_vtables.h
1008 +++ b/include/drm/drm_modeset_helper_vtables.h
1009 @@ -336,8 +336,7 @@ struct drm_crtc_helper_funcs {
1011 * This function is called in the check phase of an atomic update. The
1012 * driver is not allowed to change anything outside of the free-standing
1013 - * state objects passed-in or assembled in the overall &drm_atomic_state
1014 - * update tracking structure.
1015 + * state object passed-in.
1017 * Also beware that userspace can request its own custom modes, neither
1018 * core nor helpers filter modes to the list of probe modes reported by
1019 @@ -353,7 +352,7 @@ struct drm_crtc_helper_funcs {
1022 int (*atomic_check)(struct drm_crtc *crtc,
1023 - struct drm_crtc_state *state);
1024 + struct drm_atomic_state *state);