c7f509f21cd7ae70a97eeeb0b29c9cb6376bb26e
[openwrt/staging/stintel.git] /
1 From 0dd369ae91c3c4d2db2aa292935d12db5a0d97e1 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 28 Oct 2020 13:32:22 +0100
4 Subject: [PATCH] drm/atomic: Pass the full state to CRTC atomic begin
5 and flush
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Commit f6ebe9f9c9233a6114eb922aba9a0c9ccc2d2e14 upstream.
11
12 The current atomic helpers have either their object state being passed as
13 an argument or the full atomic state.
14
15 The former is the pattern that was done at first, before switching to the
16 latter for new hooks or when it was needed.
17
18 Let's start convert all the remaining helpers to provide a consistent
19 interface, starting with the CRTC's atomic_begin and atomic_flush.
20
21 The conversion was done using the coccinelle script below, built tested on
22 all the drivers and actually tested on vc4.
23
24 virtual report
25
26 @@
27 struct drm_crtc_helper_funcs *FUNCS;
28 identifier old_crtc_state, old_state;
29 identifier crtc;
30 identifier f;
31 @@
32
33 f(struct drm_crtc_state *old_crtc_state)
34 {
35 ...
36 struct drm_atomic_state *old_state = old_crtc_state->state;
37 <...
38 - FUNCS->atomic_begin(crtc, old_crtc_state);
39 + FUNCS->atomic_begin(crtc, old_state);
40 ...>
41 }
42
43 @@
44 struct drm_crtc_helper_funcs *FUNCS;
45 identifier old_crtc_state, old_state;
46 identifier crtc;
47 identifier f;
48 @@
49
50 f(struct drm_crtc_state *old_crtc_state)
51 {
52 ...
53 struct drm_atomic_state *old_state = old_crtc_state->state;
54 <...
55 - FUNCS->atomic_flush(crtc, old_crtc_state);
56 + FUNCS->atomic_flush(crtc, old_state);
57 ...>
58 }
59
60 @@
61 struct drm_crtc_helper_funcs *FUNCS;
62 struct drm_crtc *crtc;
63 struct drm_crtc_state *crtc_state;
64 identifier dev, state;
65 identifier f;
66 @@
67
68 f(struct drm_device *dev, struct drm_atomic_state *state, ...)
69 {
70 <...
71 - FUNCS->atomic_begin(crtc, crtc_state);
72 + FUNCS->atomic_begin(crtc, state);
73 ...>
74 }
75
76 @@
77 struct drm_crtc_helper_funcs *FUNCS;
78 struct drm_crtc *crtc;
79 struct drm_crtc_state *crtc_state;
80 identifier dev, state;
81 identifier f;
82 @@
83
84 f(struct drm_device *dev, struct drm_atomic_state *state, ...)
85 {
86 <...
87 - FUNCS->atomic_flush(crtc, crtc_state);
88 + FUNCS->atomic_flush(crtc, state);
89 ...>
90 }
91
92 @@
93 identifier crtc, old_state;
94 @@
95
96 struct drm_crtc_helper_funcs {
97 ...
98 - void (*atomic_begin)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
99 + void (*atomic_begin)(struct drm_crtc *crtc, struct drm_atomic_state *state);
100 ...
101 - void (*atomic_flush)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
102 + void (*atomic_flush)(struct drm_crtc *crtc, struct drm_atomic_state *state);
103 ...
104 }
105
106 @ crtc_atomic_func @
107 identifier helpers;
108 identifier func;
109 @@
110
111 (
112 static struct drm_crtc_helper_funcs helpers = {
113 ...,
114 .atomic_begin = func,
115 ...,
116 };
117 |
118 static struct drm_crtc_helper_funcs helpers = {
119 ...,
120 .atomic_flush = func,
121 ...,
122 };
123 )
124
125 @ ignores_old_state @
126 identifier crtc_atomic_func.func;
127 identifier crtc, old_state;
128 @@
129
130 void func(struct drm_crtc *crtc,
131 struct drm_crtc_state *old_state)
132 {
133 ... when != old_state
134 }
135
136 @ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
137 identifier crtc_atomic_func.func;
138 identifier crtc, old_state;
139 @@
140
141 void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
142 {
143 + struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
144 ...
145 }
146
147 @ depends on crtc_atomic_func @
148 identifier crtc_atomic_func.func;
149 expression E;
150 type T;
151 @@
152
153 void func(...)
154 {
155 ...
156 - T state = E;
157 + T crtc_state = E;
158 <+...
159 - state
160 + crtc_state
161 ...+>
162
163 }
164
165 @ depends on crtc_atomic_func @
166 identifier crtc_atomic_func.func;
167 type T;
168 @@
169
170 void func(...)
171 {
172 ...
173 - T state;
174 + T crtc_state;
175 <+...
176 - state
177 + crtc_state
178 ...+>
179
180 }
181
182 @@
183 identifier old_state;
184 identifier crtc;
185 @@
186
187 void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
188 - struct drm_crtc_state *old_state
189 + struct drm_atomic_state *state
190 )
191 {
192 + struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
193 ...
194 }
195
196 @@
197 identifier old_state;
198 identifier crtc;
199 @@
200
201 void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
202 - struct drm_crtc_state *old_state
203 + struct drm_atomic_state *state
204 );
205
206 @@
207 identifier old_state;
208 identifier crtc;
209 @@
210
211 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
212 - struct drm_crtc_state *old_state
213 + struct drm_atomic_state *state
214 )
215 {
216 ...
217 }
218
219 @@
220 identifier old_state;
221 identifier crtc;
222 @@
223
224 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
225 - struct drm_crtc_state *old_state
226 + struct drm_atomic_state *state
227 );
228
229 @@
230 identifier old_state;
231 identifier crtc;
232 @@
233
234 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
235 - struct drm_crtc_state *old_state
236 + struct drm_atomic_state *state
237 )
238 {
239 ...
240 }
241
242 @@
243 identifier old_state;
244 identifier crtc;
245 @@
246
247 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
248 - struct drm_crtc_state *old_state
249 + struct drm_atomic_state *state
250 );
251
252 @ depends on crtc_atomic_func @
253 identifier crtc_atomic_func.func;
254 identifier old_state;
255 identifier crtc;
256 @@
257
258 void func(struct drm_crtc *crtc,
259 - struct drm_crtc_state *old_state
260 + struct drm_atomic_state *state
261 )
262 { ... }
263
264 @ include depends on adds_old_state @
265 @@
266
267 #include <drm/drm_atomic.h>
268
269 @ no_include depends on !include && adds_old_state @
270 @@
271
272 + #include <drm/drm_atomic.h>
273 #include <drm/...>
274
275 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
276 Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
277 Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
278 Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
279 Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-2-maxime@cerno.tech
280 ---
281 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c | 4 +++-
282 drivers/gpu/drm/arm/hdlcd_crtc.c | 2 +-
283 drivers/gpu/drm/armada/armada_crtc.c | 4 ++--
284 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 4 ++--
285 drivers/gpu/drm/drm_atomic_helper.c | 8 ++++----
286 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 4 ++--
287 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 2 +-
288 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 4 ++--
289 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 4 ++--
290 drivers/gpu/drm/imx/dcss/dcss-crtc.c | 4 ++--
291 drivers/gpu/drm/imx/ipuv3-crtc.c | 4 ++--
292 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 14 +++++++-------
293 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 16 ++++++++--------
294 drivers/gpu/drm/meson/meson_crtc.c | 4 ++--
295 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 4 ++--
296 drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 4 ++--
297 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 4 ++--
298 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 2 +-
299 drivers/gpu/drm/omapdrm/omap_crtc.c | 4 ++--
300 drivers/gpu/drm/qxl/qxl_display.c | 2 +-
301 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 4 ++--
302 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 8 ++++++--
303 drivers/gpu/drm/sti/sti_crtc.c | 2 +-
304 drivers/gpu/drm/stm/ltdc.c | 2 +-
305 drivers/gpu/drm/sun4i/sun4i_crtc.c | 6 ++++--
306 drivers/gpu/drm/tegra/dc.c | 10 +++++-----
307 drivers/gpu/drm/tidss/tidss_crtc.c | 4 +++-
308 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
309 drivers/gpu/drm/vboxvideo/vbox_mode.c | 2 +-
310 drivers/gpu/drm/vc4/vc4_drv.h | 3 ++-
311 drivers/gpu/drm/vc4/vc4_hvs.c | 4 +++-
312 drivers/gpu/drm/virtio/virtgpu_display.c | 2 +-
313 drivers/gpu/drm/vkms/vkms_crtc.c | 4 ++--
314 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 4 ++--
315 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 4 ++--
316 drivers/gpu/drm/xlnx/zynqmp_disp.c | 4 ++--
317 drivers/gpu/drm/zte/zx_vou.c | 2 +-
318 include/drm/drm_modeset_helper_vtables.h | 4 ++--
319 38 files changed, 91 insertions(+), 78 deletions(-)
320
321 --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
322 +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
323 @@ -385,8 +385,10 @@ komeda_crtc_atomic_disable(struct drm_cr
324
325 static void
326 komeda_crtc_atomic_flush(struct drm_crtc *crtc,
327 - struct drm_crtc_state *old)
328 + struct drm_atomic_state *state)
329 {
330 + struct drm_crtc_state *old = drm_atomic_get_old_crtc_state(state,
331 + crtc);
332 /* commit with modeset will be handled in enable/disable */
333 if (drm_atomic_crtc_needs_modeset(crtc->state))
334 return;
335 --- a/drivers/gpu/drm/arm/hdlcd_crtc.c
336 +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
337 @@ -205,7 +205,7 @@ static enum drm_mode_status hdlcd_crtc_m
338 }
339
340 static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc,
341 - struct drm_crtc_state *state)
342 + struct drm_atomic_state *state)
343 {
344 struct drm_pending_vblank_event *event = crtc->state->event;
345
346 --- a/drivers/gpu/drm/armada/armada_crtc.c
347 +++ b/drivers/gpu/drm/armada/armada_crtc.c
348 @@ -429,7 +429,7 @@ static int armada_drm_crtc_atomic_check(
349 }
350
351 static void armada_drm_crtc_atomic_begin(struct drm_crtc *crtc,
352 - struct drm_crtc_state *old_crtc_state)
353 + struct drm_atomic_state *state)
354 {
355 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
356
357 @@ -443,7 +443,7 @@ static void armada_drm_crtc_atomic_begin
358 }
359
360 static void armada_drm_crtc_atomic_flush(struct drm_crtc *crtc,
361 - struct drm_crtc_state *old_crtc_state)
362 + struct drm_atomic_state *state)
363 {
364 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
365
366 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
367 +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
368 @@ -342,7 +342,7 @@ static int atmel_hlcdc_crtc_atomic_check
369 }
370
371 static void atmel_hlcdc_crtc_atomic_begin(struct drm_crtc *c,
372 - struct drm_crtc_state *old_s)
373 + struct drm_atomic_state *state)
374 {
375 struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
376
377 @@ -357,7 +357,7 @@ static void atmel_hlcdc_crtc_atomic_begi
378 }
379
380 static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *crtc,
381 - struct drm_crtc_state *old_s)
382 + struct drm_atomic_state *state)
383 {
384 /* TODO: write common plane control register if available */
385 }
386 --- a/drivers/gpu/drm/drm_atomic_helper.c
387 +++ b/drivers/gpu/drm/drm_atomic_helper.c
388 @@ -2517,7 +2517,7 @@ void drm_atomic_helper_commit_planes(str
389 if (active_only && !new_crtc_state->active)
390 continue;
391
392 - funcs->atomic_begin(crtc, old_crtc_state);
393 + funcs->atomic_begin(crtc, old_state);
394 }
395
396 for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) {
397 @@ -2575,7 +2575,7 @@ void drm_atomic_helper_commit_planes(str
398 if (active_only && !new_crtc_state->active)
399 continue;
400
401 - funcs->atomic_flush(crtc, old_crtc_state);
402 + funcs->atomic_flush(crtc, old_state);
403 }
404 }
405 EXPORT_SYMBOL(drm_atomic_helper_commit_planes);
406 @@ -2613,7 +2613,7 @@ drm_atomic_helper_commit_planes_on_crtc(
407
408 crtc_funcs = crtc->helper_private;
409 if (crtc_funcs && crtc_funcs->atomic_begin)
410 - crtc_funcs->atomic_begin(crtc, old_crtc_state);
411 + crtc_funcs->atomic_begin(crtc, old_state);
412
413 drm_for_each_plane_mask(plane, crtc->dev, plane_mask) {
414 struct drm_plane_state *old_plane_state =
415 @@ -2639,7 +2639,7 @@ drm_atomic_helper_commit_planes_on_crtc(
416 }
417
418 if (crtc_funcs && crtc_funcs->atomic_flush)
419 - crtc_funcs->atomic_flush(crtc, old_crtc_state);
420 + crtc_funcs->atomic_flush(crtc, old_state);
421 }
422 EXPORT_SYMBOL(drm_atomic_helper_commit_planes_on_crtc);
423
424 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
425 +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
426 @@ -65,7 +65,7 @@ static int exynos_crtc_atomic_check(stru
427 }
428
429 static void exynos_crtc_atomic_begin(struct drm_crtc *crtc,
430 - struct drm_crtc_state *old_crtc_state)
431 + struct drm_atomic_state *state)
432 {
433 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
434
435 @@ -74,7 +74,7 @@ static void exynos_crtc_atomic_begin(str
436 }
437
438 static void exynos_crtc_atomic_flush(struct drm_crtc *crtc,
439 - struct drm_crtc_state *old_crtc_state)
440 + struct drm_atomic_state *state)
441 {
442 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
443
444 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
445 +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
446 @@ -21,7 +21,7 @@
447 #include "fsl_dcu_drm_plane.h"
448
449 static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc,
450 - struct drm_crtc_state *old_crtc_state)
451 + struct drm_atomic_state *state)
452 {
453 struct drm_device *dev = crtc->dev;
454 struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
455 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
456 +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
457 @@ -393,7 +393,7 @@ static void hibmc_crtc_mode_set_nofb(str
458 }
459
460 static void hibmc_crtc_atomic_begin(struct drm_crtc *crtc,
461 - struct drm_crtc_state *old_state)
462 + struct drm_atomic_state *state)
463 {
464 unsigned int reg;
465 struct drm_device *dev = crtc->dev;
466 @@ -413,7 +413,7 @@ static void hibmc_crtc_atomic_begin(stru
467 }
468
469 static void hibmc_crtc_atomic_flush(struct drm_crtc *crtc,
470 - struct drm_crtc_state *old_state)
471 + struct drm_atomic_state *state)
472
473 {
474 unsigned long flags;
475 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
476 +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
477 @@ -485,7 +485,7 @@ static void ade_crtc_mode_set_nofb(struc
478 }
479
480 static void ade_crtc_atomic_begin(struct drm_crtc *crtc,
481 - struct drm_crtc_state *old_state)
482 + struct drm_atomic_state *state)
483 {
484 struct kirin_crtc *kcrtc = to_kirin_crtc(crtc);
485 struct ade_hw_ctx *ctx = kcrtc->hw_ctx;
486 @@ -498,7 +498,7 @@ static void ade_crtc_atomic_begin(struct
487 }
488
489 static void ade_crtc_atomic_flush(struct drm_crtc *crtc,
490 - struct drm_crtc_state *old_state)
491 + struct drm_atomic_state *state)
492
493 {
494 struct kirin_crtc *kcrtc = to_kirin_crtc(crtc);
495 --- a/drivers/gpu/drm/imx/dcss/dcss-crtc.c
496 +++ b/drivers/gpu/drm/imx/dcss/dcss-crtc.c
497 @@ -53,13 +53,13 @@ static const struct drm_crtc_funcs dcss_
498 };
499
500 static void dcss_crtc_atomic_begin(struct drm_crtc *crtc,
501 - struct drm_crtc_state *old_crtc_state)
502 + struct drm_atomic_state *state)
503 {
504 drm_crtc_vblank_on(crtc);
505 }
506
507 static void dcss_crtc_atomic_flush(struct drm_crtc *crtc,
508 - struct drm_crtc_state *old_crtc_state)
509 + struct drm_atomic_state *state)
510 {
511 struct dcss_crtc *dcss_crtc = container_of(crtc, struct dcss_crtc,
512 base);
513 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c
514 +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
515 @@ -240,13 +240,13 @@ static int ipu_crtc_atomic_check(struct
516 }
517
518 static void ipu_crtc_atomic_begin(struct drm_crtc *crtc,
519 - struct drm_crtc_state *old_crtc_state)
520 + struct drm_atomic_state *state)
521 {
522 drm_crtc_vblank_on(crtc);
523 }
524
525 static void ipu_crtc_atomic_flush(struct drm_crtc *crtc,
526 - struct drm_crtc_state *old_crtc_state)
527 + struct drm_atomic_state *state)
528 {
529 spin_lock_irq(&crtc->dev->event_lock);
530 if (crtc->state->event) {
531 --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
532 +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
533 @@ -292,7 +292,7 @@ ingenic_drm_crtc_mode_valid(struct drm_c
534 }
535
536 static void ingenic_drm_crtc_atomic_begin(struct drm_crtc *crtc,
537 - struct drm_crtc_state *oldstate)
538 + struct drm_atomic_state *state)
539 {
540 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
541 u32 ctrl = 0;
542 @@ -312,26 +312,26 @@ static void ingenic_drm_crtc_atomic_begi
543 }
544
545 static void ingenic_drm_crtc_atomic_flush(struct drm_crtc *crtc,
546 - struct drm_crtc_state *oldstate)
547 + struct drm_atomic_state *state)
548 {
549 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
550 - struct drm_crtc_state *state = crtc->state;
551 - struct drm_pending_vblank_event *event = state->event;
552 + struct drm_crtc_state *crtc_state = crtc->state;
553 + struct drm_pending_vblank_event *event = crtc_state->event;
554
555 - if (drm_atomic_crtc_needs_modeset(state)) {
556 + if (drm_atomic_crtc_needs_modeset(crtc_state)) {
557 ingenic_drm_crtc_update_timings(priv, &state->mode);
558 priv->update_clk_rate = true;
559 }
560
561 if (priv->update_clk_rate) {
562 mutex_lock(&priv->clk_mutex);
563 - clk_set_rate(priv->pix_clk, state->adjusted_mode.clock * 1000);
564 + clk_set_rate(priv->pix_clk, crtc_state->adjusted_mode.clock * 1000);
565 priv->update_clk_rate = false;
566 mutex_unlock(&priv->clk_mutex);
567 }
568
569 if (event) {
570 - state->event = NULL;
571 + crtc_state->event = NULL;
572
573 spin_lock_irq(&crtc->dev->event_lock);
574 if (drm_crtc_vblank_get(crtc) == 0)
575 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
576 +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
577 @@ -575,24 +575,24 @@ static void mtk_drm_crtc_atomic_disable(
578 }
579
580 static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc,
581 - struct drm_crtc_state *old_crtc_state)
582 + struct drm_atomic_state *state)
583 {
584 - struct mtk_crtc_state *state = to_mtk_crtc_state(crtc->state);
585 + struct mtk_crtc_state *crtc_state = to_mtk_crtc_state(crtc->state);
586 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
587
588 - if (mtk_crtc->event && state->base.event)
589 + if (mtk_crtc->event && crtc_state->base.event)
590 DRM_ERROR("new event while there is still a pending event\n");
591
592 - if (state->base.event) {
593 - state->base.event->pipe = drm_crtc_index(crtc);
594 + if (crtc_state->base.event) {
595 + crtc_state->base.event->pipe = drm_crtc_index(crtc);
596 WARN_ON(drm_crtc_vblank_get(crtc) != 0);
597 - mtk_crtc->event = state->base.event;
598 - state->base.event = NULL;
599 + mtk_crtc->event = crtc_state->base.event;
600 + crtc_state->base.event = NULL;
601 }
602 }
603
604 static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
605 - struct drm_crtc_state *old_crtc_state)
606 + struct drm_atomic_state *state)
607 {
608 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
609 int i;
610 --- a/drivers/gpu/drm/meson/meson_crtc.c
611 +++ b/drivers/gpu/drm/meson/meson_crtc.c
612 @@ -201,7 +201,7 @@ static void meson_crtc_atomic_disable(st
613 }
614
615 static void meson_crtc_atomic_begin(struct drm_crtc *crtc,
616 - struct drm_crtc_state *state)
617 + struct drm_atomic_state *state)
618 {
619 struct meson_crtc *meson_crtc = to_meson_crtc(crtc);
620 unsigned long flags;
621 @@ -217,7 +217,7 @@ static void meson_crtc_atomic_begin(stru
622 }
623
624 static void meson_crtc_atomic_flush(struct drm_crtc *crtc,
625 - struct drm_crtc_state *old_crtc_state)
626 + struct drm_atomic_state *state)
627 {
628 struct meson_crtc *meson_crtc = to_meson_crtc(crtc);
629 struct meson_drm *priv = meson_crtc->priv;
630 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
631 +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
632 @@ -486,7 +486,7 @@ static void _dpu_crtc_setup_cp_blocks(st
633 }
634
635 static void dpu_crtc_atomic_begin(struct drm_crtc *crtc,
636 - struct drm_crtc_state *old_state)
637 + struct drm_atomic_state *state)
638 {
639 struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc->state);
640 struct drm_encoder *encoder;
641 @@ -527,7 +527,7 @@ static void dpu_crtc_atomic_begin(struct
642 }
643
644 static void dpu_crtc_atomic_flush(struct drm_crtc *crtc,
645 - struct drm_crtc_state *old_crtc_state)
646 + struct drm_atomic_state *state)
647 {
648 struct dpu_crtc *dpu_crtc;
649 struct drm_device *dev;
650 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
651 +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
652 @@ -316,14 +316,14 @@ static int mdp4_crtc_atomic_check(struct
653 }
654
655 static void mdp4_crtc_atomic_begin(struct drm_crtc *crtc,
656 - struct drm_crtc_state *old_crtc_state)
657 + struct drm_atomic_state *state)
658 {
659 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
660 DBG("%s: begin", mdp4_crtc->name);
661 }
662
663 static void mdp4_crtc_atomic_flush(struct drm_crtc *crtc,
664 - struct drm_crtc_state *old_crtc_state)
665 + struct drm_atomic_state *state)
666 {
667 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
668 struct drm_device *dev = crtc->dev;
669 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
670 +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
671 @@ -778,13 +778,13 @@ static int mdp5_crtc_atomic_check(struct
672 }
673
674 static void mdp5_crtc_atomic_begin(struct drm_crtc *crtc,
675 - struct drm_crtc_state *old_crtc_state)
676 + struct drm_atomic_state *state)
677 {
678 DBG("%s: begin", crtc->name);
679 }
680
681 static void mdp5_crtc_atomic_flush(struct drm_crtc *crtc,
682 - struct drm_crtc_state *old_crtc_state)
683 + struct drm_atomic_state *state)
684 {
685 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
686 struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state);
687 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
688 +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
689 @@ -326,7 +326,7 @@ static int mxsfb_crtc_atomic_check(struc
690 }
691
692 static void mxsfb_crtc_atomic_flush(struct drm_crtc *crtc,
693 - struct drm_crtc_state *old_state)
694 + struct drm_atomic_state *state)
695 {
696 struct drm_pending_vblank_event *event;
697
698 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
699 +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
700 @@ -601,12 +601,12 @@ static int omap_crtc_atomic_check(struct
701 }
702
703 static void omap_crtc_atomic_begin(struct drm_crtc *crtc,
704 - struct drm_crtc_state *old_crtc_state)
705 + struct drm_atomic_state *state)
706 {
707 }
708
709 static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
710 - struct drm_crtc_state *old_crtc_state)
711 + struct drm_atomic_state *state)
712 {
713 struct omap_drm_private *priv = crtc->dev->dev_private;
714 struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
715 --- a/drivers/gpu/drm/qxl/qxl_display.c
716 +++ b/drivers/gpu/drm/qxl/qxl_display.c
717 @@ -373,7 +373,7 @@ static void qxl_crtc_update_monitors_con
718 }
719
720 static void qxl_crtc_atomic_flush(struct drm_crtc *crtc,
721 - struct drm_crtc_state *old_crtc_state)
722 + struct drm_atomic_state *state)
723 {
724 qxl_crtc_update_monitors_config(crtc, "flush");
725 }
726 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
727 +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
728 @@ -785,7 +785,7 @@ static void rcar_du_crtc_atomic_disable(
729 }
730
731 static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
732 - struct drm_crtc_state *old_crtc_state)
733 + struct drm_atomic_state *state)
734 {
735 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
736
737 @@ -814,7 +814,7 @@ static void rcar_du_crtc_atomic_begin(st
738 }
739
740 static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
741 - struct drm_crtc_state *old_crtc_state)
742 + struct drm_atomic_state *state)
743 {
744 struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
745 struct drm_device *dev = rcrtc->crtc.dev;
746 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
747 +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
748 @@ -1247,8 +1247,10 @@ static void vop_crtc_gamma_set(struct vo
749 }
750
751 static void vop_crtc_atomic_begin(struct drm_crtc *crtc,
752 - struct drm_crtc_state *old_crtc_state)
753 + struct drm_atomic_state *state)
754 {
755 + struct drm_crtc_state *old_crtc_state = drm_atomic_get_old_crtc_state(state,
756 + crtc);
757 struct vop *vop = to_vop(crtc);
758
759 /*
760 @@ -1463,8 +1465,10 @@ static int vop_crtc_atomic_check(struct
761 }
762
763 static void vop_crtc_atomic_flush(struct drm_crtc *crtc,
764 - struct drm_crtc_state *old_crtc_state)
765 + struct drm_atomic_state *state)
766 {
767 + struct drm_crtc_state *old_crtc_state = drm_atomic_get_old_crtc_state(state,
768 + crtc);
769 struct drm_atomic_state *old_state = old_crtc_state->state;
770 struct drm_plane_state *old_plane_state, *new_plane_state;
771 struct vop *vop = to_vop(crtc);
772 --- a/drivers/gpu/drm/sti/sti_crtc.c
773 +++ b/drivers/gpu/drm/sti/sti_crtc.c
774 @@ -133,7 +133,7 @@ sti_crtc_mode_set_nofb(struct drm_crtc *
775 }
776
777 static void sti_crtc_atomic_flush(struct drm_crtc *crtc,
778 - struct drm_crtc_state *old_crtc_state)
779 + struct drm_atomic_state *state)
780 {
781 struct drm_device *drm_dev = crtc->dev;
782 struct sti_mixer *mixer = to_sti_mixer(crtc);
783 --- a/drivers/gpu/drm/stm/ltdc.c
784 +++ b/drivers/gpu/drm/stm/ltdc.c
785 @@ -629,7 +629,7 @@ static void ltdc_crtc_mode_set_nofb(stru
786 }
787
788 static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
789 - struct drm_crtc_state *old_crtc_state)
790 + struct drm_atomic_state *state)
791 {
792 struct ltdc_device *ldev = crtc_to_ltdc(crtc);
793 struct drm_device *ddev = crtc->dev;
794 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
795 +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
796 @@ -61,8 +61,10 @@ static int sun4i_crtc_atomic_check(struc
797 }
798
799 static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc,
800 - struct drm_crtc_state *old_state)
801 + struct drm_atomic_state *state)
802 {
803 + struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
804 + crtc);
805 struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
806 struct drm_device *dev = crtc->dev;
807 struct sunxi_engine *engine = scrtc->engine;
808 @@ -82,7 +84,7 @@ static void sun4i_crtc_atomic_begin(stru
809 }
810
811 static void sun4i_crtc_atomic_flush(struct drm_crtc *crtc,
812 - struct drm_crtc_state *old_state)
813 + struct drm_atomic_state *state)
814 {
815 struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
816 struct drm_pending_vblank_event *event = crtc->state->event;
817 --- a/drivers/gpu/drm/tegra/dc.c
818 +++ b/drivers/gpu/drm/tegra/dc.c
819 @@ -1924,7 +1924,7 @@ static void tegra_crtc_atomic_enable(str
820 }
821
822 static void tegra_crtc_atomic_begin(struct drm_crtc *crtc,
823 - struct drm_crtc_state *old_crtc_state)
824 + struct drm_atomic_state *state)
825 {
826 unsigned long flags;
827
828 @@ -1943,17 +1943,17 @@ static void tegra_crtc_atomic_begin(stru
829 }
830
831 static void tegra_crtc_atomic_flush(struct drm_crtc *crtc,
832 - struct drm_crtc_state *old_crtc_state)
833 + struct drm_atomic_state *state)
834 {
835 - struct tegra_dc_state *state = to_dc_state(crtc->state);
836 + struct tegra_dc_state *crtc_state = to_dc_state(crtc->state);
837 struct tegra_dc *dc = to_tegra_dc(crtc);
838 u32 value;
839
840 - value = state->planes << 8 | GENERAL_UPDATE;
841 + value = crtc_state->planes << 8 | GENERAL_UPDATE;
842 tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
843 value = tegra_dc_readl(dc, DC_CMD_STATE_CONTROL);
844
845 - value = state->planes | GENERAL_ACT_REQ;
846 + value = crtc_state->planes | GENERAL_ACT_REQ;
847 tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
848 value = tegra_dc_readl(dc, DC_CMD_STATE_CONTROL);
849 }
850 --- a/drivers/gpu/drm/tidss/tidss_crtc.c
851 +++ b/drivers/gpu/drm/tidss/tidss_crtc.c
852 @@ -163,8 +163,10 @@ static void tidss_crtc_position_planes(s
853 }
854
855 static void tidss_crtc_atomic_flush(struct drm_crtc *crtc,
856 - struct drm_crtc_state *old_crtc_state)
857 + struct drm_atomic_state *state)
858 {
859 + struct drm_crtc_state *old_crtc_state = drm_atomic_get_old_crtc_state(state,
860 + crtc);
861 struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
862 struct drm_device *ddev = crtc->dev;
863 struct tidss_device *tidss = to_tidss(ddev);
864 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
865 +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
866 @@ -547,7 +547,7 @@ static void tilcdc_crtc_atomic_disable(s
867 }
868
869 static void tilcdc_crtc_atomic_flush(struct drm_crtc *crtc,
870 - struct drm_crtc_state *old_state)
871 + struct drm_atomic_state *state)
872 {
873 if (!crtc->state->event)
874 return;
875 --- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
876 +++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
877 @@ -223,7 +223,7 @@ static void vbox_crtc_atomic_disable(str
878 }
879
880 static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
881 - struct drm_crtc_state *old_crtc_state)
882 + struct drm_atomic_state *state)
883 {
884 }
885
886 --- a/drivers/gpu/drm/vc4/vc4_drv.h
887 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
888 @@ -928,7 +928,8 @@ int vc4_hvs_get_fifo_from_output(struct
889 int vc4_hvs_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
890 void vc4_hvs_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
891 void vc4_hvs_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
892 -void vc4_hvs_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *state);
893 +void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
894 + struct drm_atomic_state *state);
895 void vc4_hvs_dump_state(struct drm_device *dev);
896 void vc4_hvs_unmask_underrun(struct drm_device *dev, int channel);
897 void vc4_hvs_mask_underrun(struct drm_device *dev, int channel);
898 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
899 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
900 @@ -453,8 +453,10 @@ void vc4_hvs_atomic_disable(struct drm_c
901 }
902
903 void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
904 - struct drm_crtc_state *old_state)
905 + struct drm_atomic_state *state)
906 {
907 + struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
908 + crtc);
909 struct drm_device *dev = crtc->dev;
910 struct vc4_dev *vc4 = to_vc4_dev(dev);
911 struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state);
912 --- a/drivers/gpu/drm/virtio/virtgpu_display.c
913 +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
914 @@ -117,7 +117,7 @@ static int virtio_gpu_crtc_atomic_check(
915 }
916
917 static void virtio_gpu_crtc_atomic_flush(struct drm_crtc *crtc,
918 - struct drm_crtc_state *old_state)
919 + struct drm_atomic_state *state)
920 {
921 struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
922
923 --- a/drivers/gpu/drm/vkms/vkms_crtc.c
924 +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
925 @@ -229,7 +229,7 @@ static void vkms_crtc_atomic_disable(str
926 }
927
928 static void vkms_crtc_atomic_begin(struct drm_crtc *crtc,
929 - struct drm_crtc_state *old_crtc_state)
930 + struct drm_atomic_state *state)
931 {
932 struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc);
933
934 @@ -240,7 +240,7 @@ static void vkms_crtc_atomic_begin(struc
935 }
936
937 static void vkms_crtc_atomic_flush(struct drm_crtc *crtc,
938 - struct drm_crtc_state *old_crtc_state)
939 + struct drm_atomic_state *state)
940 {
941 struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc);
942
943 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
944 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
945 @@ -554,13 +554,13 @@ int vmw_du_crtc_atomic_check(struct drm_
946
947
948 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
949 - struct drm_crtc_state *old_crtc_state)
950 + struct drm_atomic_state *state)
951 {
952 }
953
954
955 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
956 - struct drm_crtc_state *old_crtc_state)
957 + struct drm_atomic_state *state)
958 {
959 struct drm_pending_vblank_event *event = crtc->state->event;
960
961 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
962 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
963 @@ -475,9 +475,9 @@ void vmw_du_plane_unpin_surf(struct vmw_
964 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
965 struct drm_atomic_state *state);
966 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
967 - struct drm_crtc_state *old_crtc_state);
968 + struct drm_atomic_state *state);
969 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
970 - struct drm_crtc_state *old_crtc_state);
971 + struct drm_atomic_state *state);
972 void vmw_du_crtc_reset(struct drm_crtc *crtc);
973 struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc);
974 void vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
975 --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
976 +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
977 @@ -1515,14 +1515,14 @@ static int zynqmp_disp_crtc_atomic_check
978
979 static void
980 zynqmp_disp_crtc_atomic_begin(struct drm_crtc *crtc,
981 - struct drm_crtc_state *old_crtc_state)
982 + struct drm_atomic_state *state)
983 {
984 drm_crtc_vblank_on(crtc);
985 }
986
987 static void
988 zynqmp_disp_crtc_atomic_flush(struct drm_crtc *crtc,
989 - struct drm_crtc_state *old_crtc_state)
990 + struct drm_atomic_state *state)
991 {
992 if (crtc->state->event) {
993 struct drm_pending_vblank_event *event;
994 --- a/drivers/gpu/drm/zte/zx_vou.c
995 +++ b/drivers/gpu/drm/zte/zx_vou.c
996 @@ -473,7 +473,7 @@ static void zx_crtc_atomic_disable(struc
997 }
998
999 static void zx_crtc_atomic_flush(struct drm_crtc *crtc,
1000 - struct drm_crtc_state *old_state)
1001 + struct drm_atomic_state *state)
1002 {
1003 struct drm_pending_vblank_event *event = crtc->state->event;
1004
1005 --- a/include/drm/drm_modeset_helper_vtables.h
1006 +++ b/include/drm/drm_modeset_helper_vtables.h
1007 @@ -373,7 +373,7 @@ struct drm_crtc_helper_funcs {
1008 * transitional plane helpers, but it is optional.
1009 */
1010 void (*atomic_begin)(struct drm_crtc *crtc,
1011 - struct drm_crtc_state *old_crtc_state);
1012 + struct drm_atomic_state *state);
1013 /**
1014 * @atomic_flush:
1015 *
1016 @@ -397,7 +397,7 @@ struct drm_crtc_helper_funcs {
1017 * transitional plane helpers, but it is optional.
1018 */
1019 void (*atomic_flush)(struct drm_crtc *crtc,
1020 - struct drm_crtc_state *old_crtc_state);
1021 + struct drm_atomic_state *state);
1022
1023 /**
1024 * @atomic_enable: