27e44d90740efa541e25ae6236a6291ba2b7d1fa
[openwrt/staging/mkresin.git] /
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Commit 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4 upstream.
10
11 The current atomic helpers have either their object state being passed as
12 an argument or the full atomic state.
13
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.
16
17 Let's start convert all the remaining helpers to provide a consistent
18 interface, starting with the CRTC's atomic_check.
19
20 The conversion was done using the coccinelle script below,
21 built tested on all the drivers and actually tested on vc4.
22
23 virtual report
24
25 @@
26 struct drm_crtc_helper_funcs *FUNCS;
27 struct drm_crtc *crtc;
28 struct drm_crtc_state *crtc_state;
29 identifier dev, state;
30 identifier ret, f;
31 @@
32
33 f(struct drm_device *dev, struct drm_atomic_state *state)
34 {
35 <...
36 - ret = FUNCS->atomic_check(crtc, crtc_state);
37 + ret = FUNCS->atomic_check(crtc, state);
38 ...>
39 }
40
41 @@
42 identifier crtc, new_state;
43 @@
44
45 struct drm_crtc_helper_funcs {
46 ...
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);
49 ...
50 }
51
52 @ crtc_atomic_func @
53 identifier helpers;
54 identifier func;
55 @@
56
57 static struct drm_crtc_helper_funcs helpers = {
58 ...,
59 .atomic_check = func,
60 ...,
61 };
62
63 @ ignores_new_state @
64 identifier crtc_atomic_func.func;
65 identifier crtc, new_state;
66 @@
67
68 int func(struct drm_crtc *crtc,
69 struct drm_crtc_state *new_state)
70 {
71 ... when != new_state
72 }
73
74 @ adds_new_state depends on crtc_atomic_func && !ignores_new_state @
75 identifier crtc_atomic_func.func;
76 identifier crtc, new_state;
77 @@
78
79 int func(struct drm_crtc *crtc, struct drm_crtc_state *new_state)
80 {
81 + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
82 ...
83 }
84
85 @ depends on crtc_atomic_func @
86 identifier crtc_atomic_func.func;
87 expression E;
88 type T;
89 @@
90
91 int func(...)
92 {
93 ...
94 - T state = E;
95 + T crtc_state = E;
96 <+...
97 - state
98 + crtc_state
99 ...+>
100 }
101
102 @ depends on crtc_atomic_func @
103 identifier crtc_atomic_func.func;
104 type T;
105 @@
106
107 int func(...)
108 {
109 ...
110 - T state;
111 + T crtc_state;
112 <+...
113 - state
114 + crtc_state
115 ...+>
116 }
117
118 @ depends on crtc_atomic_func @
119 identifier crtc_atomic_func.func;
120 identifier new_state;
121 identifier crtc;
122 @@
123
124 int func(struct drm_crtc *crtc,
125 - struct drm_crtc_state *new_state
126 + struct drm_atomic_state *state
127 )
128 { ... }
129
130 @@
131 identifier new_state;
132 identifier crtc;
133 @@
134
135 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
136 - struct drm_crtc_state *new_state
137 + struct drm_atomic_state *state
138 )
139 {
140 + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
141 ...
142 }
143
144 @@
145 identifier new_state;
146 identifier crtc;
147 @@
148
149 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
150 - struct drm_crtc_state *new_state
151 + struct drm_atomic_state *state
152 );
153
154 @ include depends on adds_new_state @
155 @@
156
157 #include <drm/drm_atomic.h>
158
159 @ no_include depends on !include && adds_new_state @
160 @@
161
162 + #include <drm/drm_atomic.h>
163 #include <drm/...>
164
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
169 ---
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(-)
201
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 @@ -5605,17 +5605,19 @@ static void dm_update_crtc_active_planes
205 }
206
207 static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc,
208 - struct drm_crtc_state *state)
209 + struct drm_atomic_state *state)
210 {
211 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
212 + crtc);
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);
217 int ret = -EINVAL;
218
219 - dm_update_crtc_active_planes(crtc, state);
220 + dm_update_crtc_active_planes(crtc, crtc_state);
221
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))) {
225 WARN_ON(1);
226 return ret;
227 }
228 @@ -5626,8 +5628,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.
231 */
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)))
236 return -EINVAL;
237
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
242 */
243 static int
244 komeda_crtc_atomic_check(struct drm_crtc *crtc,
245 - struct drm_crtc_state *state)
246 + struct drm_atomic_state *state)
247 {
248 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
249 + crtc);
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);
253 int err;
254
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);
258
259 - if (state->active) {
260 + if (crtc_state->active) {
261 err = komeda_build_display_data_flow(kcrtc, kcrtc_st);
262 if (err)
263 return err;
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:
267 }
268
269 static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
270 - struct drm_crtc_state *state)
271 + struct drm_atomic_state *state)
272 {
273 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
274 + crtc);
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
279 */
280
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;
285
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];
289
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
297 }
298
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;
305
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;
310 }
311
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);
318
319 return ret;
320 }
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
324 }
325
326 static int armada_drm_crtc_atomic_check(struct drm_crtc *crtc,
327 - struct drm_crtc_state *state)
328 + struct drm_atomic_state *state)
329 {
330 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
331 + crtc);
332 DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
333
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)
336 return -EINVAL;
337
338 - if (state->color_mgmt_changed)
339 - state->planes_changed = true;
340 + if (crtc_state->color_mgmt_changed)
341 + crtc_state->planes_changed = true;
342
343 return 0;
344 }
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
348 }
349
350 static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
351 - struct drm_crtc_state *state)
352 + struct drm_atomic_state *state)
353 {
354 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
355 + crtc);
356 struct drm_device *dev = crtc->dev;
357 struct ast_crtc_state *ast_state;
358 const struct drm_format_info *format;
359 bool succ;
360
361 - if (!state->enable)
362 + if (!crtc_state->enable)
363 return 0; /* no mode checks if CRTC is being disabled */
364
365 - ast_state = to_ast_crtc_state(state);
366 + ast_state = to_ast_crtc_state(crtc_state);
367
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(). */
371
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);
377 if (!succ)
378 return -EINVAL;
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
382 }
383
384 static int atmel_hlcdc_crtc_atomic_check(struct drm_crtc *c,
385 - struct drm_crtc_state *s)
386 + struct drm_atomic_state *state)
387 {
388 + struct drm_crtc_state *s = drm_atomic_get_new_crtc_state(state, c);
389 int ret;
390
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)
396 continue;
397
398 - ret = funcs->atomic_check(crtc, new_crtc_state);
399 + ret = funcs->atomic_check(crtc, state);
400 if (ret) {
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
406 }
407
408 static int drm_simple_kms_crtc_check(struct drm_crtc *crtc,
409 - struct drm_crtc_state *state)
410 + struct drm_atomic_state *state)
411 {
412 - bool has_primary = state->plane_mask &
413 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
414 + crtc);
415 + bool has_primary = crtc_state->plane_mask &
416 drm_plane_mask(crtc->primary);
417
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)
421 return -EINVAL;
422
423 - return drm_atomic_add_affected_planes(state->state, crtc);
424 + return drm_atomic_add_affected_planes(crtc_state->state, crtc);
425 }
426
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
431 }
432
433 static int exynos_crtc_atomic_check(struct drm_crtc *crtc,
434 - struct drm_crtc_state *state)
435 + struct drm_atomic_state *state)
436 {
437 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
438 + crtc);
439 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
440
441 - if (!state->enable)
442 + if (!crtc_state->enable)
443 return 0;
444
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);
448
449 return 0;
450 }
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
454 }
455
456 static int ipu_crtc_atomic_check(struct drm_crtc *crtc,
457 - struct drm_crtc_state *state)
458 + struct drm_atomic_state *state)
459 {
460 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
461 + crtc);
462 u32 primary_plane_mask = drm_plane_mask(crtc->primary);
463
464 - if (state->active && (primary_plane_mask & state->plane_mask) == 0)
465 + if (crtc_state->active && (primary_plane_mask & crtc_state->plane_mask) == 0)
466 return -EINVAL;
467
468 return 0;
469 --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
470 +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
471 @@ -195,22 +195,27 @@ static void ingenic_drm_crtc_update_timi
472 }
473
474 static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
475 - struct drm_crtc_state *state)
476 + struct drm_atomic_state *state)
477 {
478 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
479 + crtc);
480 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
481 struct drm_plane_state *f1_state, *f0_state, *ipu_state = NULL;
482
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,
487 + &priv->f1);
488 if (IS_ERR(f1_state))
489 return PTR_ERR(f1_state);
490
491 - f0_state = drm_atomic_get_plane_state(state->state, &priv->f0);
492 + f0_state = drm_atomic_get_plane_state(crtc_state->state,
493 + &priv->f0);
494 if (IS_ERR(f0_state))
495 return PTR_ERR(f0_state);
496
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,
500 + priv->ipu_plane);
501 if (IS_ERR(ipu_state))
502 return PTR_ERR(ipu_state);
503
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 {
507 };
508
509 static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
510 - struct drm_crtc_state *state)
511 + struct drm_atomic_state *state)
512 {
513 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
514 + crtc);
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;
519
520 const struct drm_plane_state *pstate;
521 @@ -835,32 +837,33 @@ static int dpu_crtc_atomic_check(struct
522
523 pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
524
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);
531 goto end;
532 }
533
534 - mode = &state->adjusted_mode;
535 + mode = &crtc_state->adjusted_mode;
536 DPU_DEBUG("%s: check", dpu_crtc->name);
537
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;
543
544 memset(pipe_staged, 0, sizeof(pipe_staged));
545
546 if (cstate->num_mixers) {
547 mixer_width = mode->hdisplay / cstate->num_mixers;
548
549 - _dpu_crtc_setup_lm_bounds(crtc, state);
550 + _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
551 }
552
553 crtc_rect.x2 = mode->hdisplay;
554 crtc_rect.y2 = mode->vdisplay;
555
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;
560
561 if (IS_ERR_OR_NULL(pstate)) {
562 @@ -966,7 +969,7 @@ static int dpu_crtc_atomic_check(struct
563
564 atomic_inc(&_dpu_crtc_get_kms(crtc)->bandwidth_ref);
565
566 - rc = dpu_core_perf_crtc_check(crtc, state);
567 + rc = dpu_core_perf_crtc_check(crtc, crtc_state);
568 if (rc) {
569 DPU_ERROR("crtc%d failed performance check %d\n",
570 crtc->base.id, rc);
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
574 }
575
576 static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
577 - struct drm_crtc_state *state)
578 + struct drm_atomic_state *state)
579 {
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
584 @@ -7,6 +7,7 @@
585
586 #include <linux/sort.h>
587
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 @@ -682,15 +683,17 @@ static enum mdp_mixer_stage_id get_start
593 }
594
595 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
596 - struct drm_crtc_state *state)
597 + struct drm_atomic_state *state)
598 {
599 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
600 + crtc);
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;
611 int cnt = 0, i;
612 @@ -699,7 +702,7 @@ static int mdp5_crtc_atomic_check(struct
613
614 DBG("%s: check", crtc->name);
615
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)
619 continue;
620
621 @@ -731,7 +734,7 @@ static int mdp5_crtc_atomic_check(struct
622 if (mode->hdisplay > hw_cfg->lm.max_width)
623 need_right_mixer = true;
624
625 - ret = mdp5_crtc_setup_pipeline(crtc, state, need_right_mixer);
626 + ret = mdp5_crtc_setup_pipeline(crtc, crtc_state, need_right_mixer);
627 if (ret) {
628 DRM_DEV_ERROR(dev->dev, "couldn't assign mixers %d\n", ret);
629 return ret;
630 @@ -744,7 +747,7 @@ static int mdp5_crtc_atomic_check(struct
631 WARN_ON(cursor_plane &&
632 (pstates[cnt - 1].plane->type != DRM_PLANE_TYPE_CURSOR));
633
634 - start = get_start_stage(crtc, state, &pstates[0].state->base);
635 + start = get_start_stage(crtc, crtc_state, &pstates[0].state->base);
636
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
642 }
643
644 static int mxsfb_crtc_atomic_check(struct drm_crtc *crtc,
645 - struct drm_crtc_state *state)
646 + struct drm_atomic_state *state)
647 {
648 - bool has_primary = state->plane_mask &
649 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
650 + crtc);
651 + bool has_primary = crtc_state->plane_mask &
652 drm_plane_mask(crtc->primary);
653
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)
657 return -EINVAL;
658
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);
662 }
663
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
667 @@ -30,6 +30,7 @@
668 #include <nvif/event.h>
669 #include <nvif/cl0046.h>
670
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_
676 }
677
678 static int
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)
681 {
682 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
683 + crtc);
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
695 }
696
697 static int omap_crtc_atomic_check(struct drm_crtc *crtc,
698 - struct drm_crtc_state *state)
699 + struct drm_atomic_state *state)
700 {
701 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
702 + crtc);
703 struct drm_plane_state *pri_state;
704
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);
710
711 if (length < 2)
712 return -EINVAL;
713 }
714
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,
717 + crtc->primary);
718 if (pri_state) {
719 struct omap_crtc_state *omap_crtc_state =
720 - to_omap_crtc_state(state);
721 + to_omap_crtc_state(crtc_state);
722
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
728 */
729
730 static int rcar_du_crtc_atomic_check(struct drm_crtc *crtc,
731 - struct drm_crtc_state *state)
732 + struct drm_atomic_state *state)
733 {
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,
736 + crtc);
737 + struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(crtc_state);
738 struct drm_encoder *encoder;
739 int ret;
740
741 - ret = rcar_du_cmm_check(crtc, state);
742 + ret = rcar_du_cmm_check(crtc, crtc_state);
743 if (ret)
744 return ret;
745
746 /* Store the routes from the CRTC output to the DU outputs. */
747 rstate->outputs = 0;
748
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;
753
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
758 }
759
760 static int vop_crtc_atomic_check(struct drm_crtc *crtc,
761 - struct drm_crtc_state *crtc_state)
762 + struct drm_atomic_state *state)
763 {
764 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
765 + crtc);
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
771 @@ -15,6 +15,7 @@
772
773 #include <video/videomode.h>
774
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
780 }
781
782 static int sun4i_crtc_atomic_check(struct drm_crtc *crtc,
783 - struct drm_crtc_state *state)
784 + struct drm_atomic_state *state)
785 {
786 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
787 + crtc);
788 struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
789 struct sunxi_engine *engine = scrtc->engine;
790 int ret = 0;
791
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);
795
796 return ret;
797 }
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 */
802
803 static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
804 - struct drm_crtc_state *state)
805 + struct drm_atomic_state *state)
806 {
807 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
808 + crtc);
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
813
814 dev_dbg(ddev->dev, "%s\n", __func__);
815
816 - if (!state->enable)
817 + if (!crtc_state->enable)
818 return 0;
819
820 - mode = &state->adjusted_mode;
821 + mode = &crtc_state->adjusted_mode;
822
823 ok = dispc_vp_mode_valid(dispc, hw_videoport, mode);
824 if (ok != MODE_OK) {
825 @@ -109,7 +111,7 @@ static int tidss_crtc_atomic_check(struc
826 return -EINVAL;
827 }
828
829 - return dispc_vp_bus_check(dispc, hw_videoport, state);
830 + return dispc_vp_bus_check(dispc, hw_videoport, crtc_state);
831 }
832
833 /*
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
837 }
838
839 static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
840 - struct drm_crtc_state *state)
841 + struct drm_atomic_state *state)
842 {
843 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
844 + crtc);
845 /* If we are not active we don't care */
846 - if (!state->active)
847 + if (!crtc_state->active)
848 return 0;
849
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");
857 return -EINVAL;
858 }
859 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
860 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
861 @@ -601,18 +601,21 @@ void vc4_crtc_get_margins(struct drm_crt
862 }
863
864 static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
865 - struct drm_crtc_state *state)
866 + struct drm_atomic_state *state)
867 {
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,
870 + crtc);
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;
874 int ret, i;
875
876 - ret = vc4_hvs_atomic_check(crtc, state);
877 + ret = vc4_hvs_atomic_check(crtc, crtc_state);
878 if (ret)
879 return ret;
880
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,
883 + i) {
884 if (conn_state->crtc != crtc)
885 continue;
886
887 --- a/drivers/gpu/drm/vc4/vc4_txp.c
888 +++ b/drivers/gpu/drm/vc4/vc4_txp.c
889 @@ -386,16 +386,18 @@ static const struct drm_crtc_funcs vc4_t
890 };
891
892 static int vc4_txp_atomic_check(struct drm_crtc *crtc,
893 - struct drm_crtc_state *state)
894 + struct drm_atomic_state *state)
895 {
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,
898 + crtc);
899 + struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
900 int ret;
901
902 - ret = vc4_hvs_atomic_check(crtc, state);
903 + ret = vc4_hvs_atomic_check(crtc, crtc_state);
904 if (ret)
905 return ret;
906
907 - state->no_vblank = true;
908 + crtc_state->no_vblank = true;
909 vc4_state->feed_txp = true;
910
911 return 0;
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
915 }
916
917 static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
918 - struct drm_crtc_state *state)
919 + struct drm_atomic_state *state)
920 {
921 return 0;
922 }
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_
926 };
927
928 static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
929 - struct drm_crtc_state *state)
930 + struct drm_atomic_state *state)
931 {
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,
934 + crtc);
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;
938 int i = 0, ret;
939 @@ -179,12 +181,12 @@ static int vkms_crtc_atomic_check(struct
940 if (vkms_state->active_planes)
941 return 0;
942
943 - ret = drm_atomic_add_affected_planes(state->state, crtc);
944 + ret = drm_atomic_add_affected_planes(crtc_state->state, crtc);
945 if (ret < 0)
946 return ret;
947
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,
952 plane);
953 WARN_ON(!plane_state);
954
955 @@ -200,8 +202,8 @@ static int vkms_crtc_atomic_check(struct
956 vkms_state->num_active_planes = i;
957
958 i = 0;
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,
963 plane);
964
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
969
970
971 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
972 - struct drm_crtc_state *new_state)
973 + struct drm_atomic_state *state)
974 {
975 + struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state,
976 + crtc);
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_
983 bool unreference);
984
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
994 }
995
996 static int zynqmp_disp_crtc_atomic_check(struct drm_crtc *crtc,
997 - struct drm_crtc_state *state)
998 + struct drm_atomic_state *state)
999 {
1000 - return drm_atomic_add_affected_planes(state->state, crtc);
1001 + struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
1002 + crtc);
1003 + return drm_atomic_add_affected_planes(crtc_state->state, crtc);
1004 }
1005
1006 static void
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 {
1010 *
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.
1016 *
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 {
1020 * deadlock.
1021 */
1022 int (*atomic_check)(struct drm_crtc *crtc,
1023 - struct drm_crtc_state *state);
1024 + struct drm_atomic_state *state);
1025
1026 /**
1027 * @atomic_begin: