aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1007-drm-amd-display-Refactor-atomic-check.patch
blob: 96b6c2b3bac0cff142c9d9e1d4a8b1f757256813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
From ad3d14ad6eff85578426d10db69eaf2fc56b1c81 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Date: Fri, 18 Aug 2017 10:52:20 -0400
Subject: [PATCH 1007/4131] drm/amd/display: Refactor atomic check.

Split into update crtcs and update plane functions.

Change-Id: I57a739070861553de9b787f995e44a1da4e3c2d0
Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 550 ++++++++++++----------
 1 file changed, 303 insertions(+), 247 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 4b817bf..edbf952 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1789,12 +1789,6 @@ static bool modeset_required(struct drm_crtc_state *crtc_state,
 			     struct dc_stream_state *new_stream,
 			     struct dc_stream_state *old_stream)
 {
-	if (dc_is_stream_unchanged(new_stream, old_stream)) {
-		crtc_state->mode_changed = false;
-		DRM_DEBUG_KMS("Mode change not required, setting mode_changed to %d",
-			      crtc_state->mode_changed);
-	}
-
 	if (!drm_atomic_crtc_needs_modeset(crtc_state))
 		return false;
 
@@ -4119,9 +4113,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 			continue;
 		}
 
-		if (!fb || !crtc || pcrtc != crtc || !crtc->state->active ||
-				(!crtc->state->planes_changed &&
-						!pcrtc->state->color_mgmt_changed))
+		if (!fb || !crtc || pcrtc != crtc || !crtc->state->active)
 			continue;
 
 		pflip_needed = !state->allow_modeset;
@@ -4598,76 +4590,18 @@ static int do_aquire_global_lock(
 	return ret < 0 ? ret : 0;
 }
 
-int amdgpu_dm_atomic_check(struct drm_device *dev,
-			struct drm_atomic_state *state)
+static int dm_update_crtcs_state(
+		struct dc *dc,
+		struct drm_atomic_state *state,
+		bool enable,
+		bool *lock_and_validation_needed)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *crtc_state;
-	struct drm_plane *plane;
-	struct drm_plane_state *plane_state;
-	int i, j;
-	int ret;
-	struct amdgpu_device *adev = dev->dev_private;
-	struct dc *dc = adev->dm.dc;
-	struct drm_connector *connector;
-	struct drm_connector_state *conn_state;
+	int i;
 	struct dm_crtc_state *old_acrtc_state, *new_acrtc_state;
 	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
-	bool pflip_needed  = !state->allow_modeset;
-
-	/*
-	 * This bool will be set for true for any modeset/reset
-	 * or plane update which implies non fast surface update.
-	 */
-	bool lock_and_validation_needed = false;
-
-	ret = drm_atomic_helper_check_modeset(dev, state);
-
-	if (ret) {
-		DRM_ERROR("Atomic state validation failed with error :%d !\n", ret);
-		return ret;
-	}
-
-	/* Remove exiting planes if they are disabled or their CRTC is updated */
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		new_acrtc_state = to_dm_crtc_state(crtc_state);
-
-		if (pflip_needed)
-			continue;
-
-		for_each_plane_in_state(state, plane, plane_state, j) {
-			struct drm_crtc *plane_crtc = plane_state->crtc;
-			struct dm_plane_state *dm_plane_state = to_dm_plane_state(plane_state);
-
-			if (plane->type == DRM_PLANE_TYPE_CURSOR)
-				continue;
-
-			if (crtc != plane_crtc || !dm_plane_state->dc_state)
-				continue;
-
-			WARN_ON(!new_acrtc_state->stream);
-
-			if (drm_atomic_plane_disabling(plane->state, plane_state) ||
-					drm_atomic_crtc_needs_modeset(crtc_state)) {
-				if (!dc_remove_plane_from_context(
-						dc,
-						new_acrtc_state->stream,
-						dm_plane_state->dc_state,
-						dm_state->context)) {
-
-					ret = EINVAL;
-					goto fail;
-				}
-
-			}
-
-			dc_plane_state_release(dm_plane_state->dc_state);
-			dm_plane_state->dc_state = NULL;
-
-			DRM_DEBUG_KMS("Disabling DRM plane: %d on DRM crtc %d\n",
-					plane->base.id, crtc->base.id);
-		}
-	}
+	int ret = 0;
 
 	/*TODO Move this code into dm_crtc_atomic_check once we get rid of dc_validation_set */
 	/* update changed items */
@@ -4677,12 +4611,52 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 		struct dc_stream_state *new_stream = NULL;
 		struct drm_connector_state *conn_state = NULL;
 		struct dm_connector_state *dm_conn_state = NULL;
-
+		
 		old_acrtc_state = to_dm_crtc_state(crtc->state);
 		new_acrtc_state = to_dm_crtc_state(crtc_state);
 		acrtc = to_amdgpu_crtc(crtc);
 
 		aconnector = amdgpu_dm_find_first_crct_matching_connector(state, crtc, true);
+	
+		/* TODO This hack should go away */
+		if (aconnector && aconnector->dc_sink) {
+			conn_state = drm_atomic_get_connector_state(state,
+								&aconnector->base);
+
+			if (IS_ERR(conn_state)) {
+				ret = PTR_ERR_OR_ZERO(conn_state);
+				break;
+			}
+
+			dm_conn_state = to_dm_connector_state(conn_state);
+		
+			new_stream = create_stream_for_sink(aconnector,
+							    &crtc_state->mode,
+							    dm_conn_state);
+			/*
+			* we can have no stream on ACTION_SET if a display
+			* was disconnected during S3, in this case it not and
+			* error, the OS will be updated after detection, and
+			* do the right thing on next atomic commit
+			*/
+
+			if (!new_stream) {
+				DRM_DEBUG_KMS("%s: Failed to create new stream for crtc %d\n",
+						__func__, acrtc->base.base.id);
+				break;
+			}
+		}
+		
+		if (dc_is_stream_unchanged(new_stream,
+				old_acrtc_state->stream)) {
+				crtc_state->mode_changed = false;
+				DRM_DEBUG_KMS("Mode change not required, setting mode_changed to %d",
+						crtc_state->mode_changed);
+		}
+
+	
+		if (!drm_atomic_crtc_needs_modeset(crtc_state))
+				continue;
 
 		DRM_DEBUG_KMS(
 			"amdgpu_crtc id:%d crtc_state_flags: enable:%d, active:%d, "
@@ -4696,228 +4670,310 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
 			crtc_state->active_changed,
 			crtc_state->connectors_changed);
 
-		if (modereset_required(crtc_state)) {
-
-			/* i.e. reset mode */
-			if (new_acrtc_state->stream) {
-
-				if (!dc_remove_stream_from_ctx(
-						dc,
-						dm_state->context,
-						new_acrtc_state->stream)) {
-					ret = -EINVAL;
-					goto fail;
-				}
-
-				dc_stream_release(new_acrtc_state->stream);
-				new_acrtc_state->stream = NULL;
-
-				lock_and_validation_needed = true;
-			}
-
-		} else {
-
-			if (aconnector) {
-				conn_state = drm_atomic_get_connector_state(state,
-									    &aconnector->base);
-
-				if (IS_ERR(conn_state)) {
-					ret = PTR_ERR_OR_ZERO(conn_state);
-					goto fail;
-				}
-
-				dm_conn_state = to_dm_connector_state(conn_state);
-
-				new_stream = create_stream_for_sink(aconnector,
-								    &crtc_state->mode,
-								    dm_conn_state);
-
-				/*
-				 * we can have no stream on ACTION_SET if a display
-				 * was disconnected during S3, in this case it not and
-				 * error, the OS will be updated after detection, and
-				 * do the right thing on next atomic commit
-				 */
-
-				if (!new_stream) {
-					DRM_DEBUG_KMS("%s: Failed to create new stream for crtc %d\n",
-							__func__, acrtc->base.base.id);
-					break;
-				}
+		/* Remove stream for any changed/disabled CRTC */
+		if (!enable) {
 
+			if (!old_acrtc_state->stream)
+				continue;
 
+			DRM_DEBUG_KMS("Disabling DRM crtc: %d\n",
+					crtc->base.id);
+			/* i.e. reset mode */
+			if (!dc_remove_stream_from_ctx(
+					dc,
+					dm_state->context,
+					old_acrtc_state->stream)) {
+				ret = -EINVAL;
+				break;
 			}
 
-			if (modeset_required(crtc_state, new_stream,
-					     old_acrtc_state->stream)) {
+			dc_stream_release(old_acrtc_state->stream);
+			new_acrtc_state->stream = NULL;
 
-				if (new_acrtc_state->stream) {
+			*lock_and_validation_needed = true;
 
-					if (!dc_remove_stream_from_ctx(
-							dc,
-							dm_state->context,
-							new_acrtc_state->stream)) {
-						ret = -EINVAL;
-						goto fail;
-					}
+		} else {/* Add stream for any updated/enabled CRTC */
 
+			if (modereset_required(crtc_state))
+				continue;
 
-					dc_stream_release(new_acrtc_state->stream);
-				}
+				if (modeset_required(crtc_state, new_stream,
+						old_acrtc_state->stream)) {
+	
+				WARN_ON(new_acrtc_state->stream);
 
 				new_acrtc_state->stream = new_stream;
+				dc_stream_retain(new_stream);
 
+				DRM_DEBUG_KMS("Enabling DRM crtc: %d\n",
+							crtc->base.id);
+				
 				if (!dc_add_stream_to_ctx(
 						dc,
 						dm_state->context,
 						new_acrtc_state->stream)) {
 					ret = -EINVAL;
-					goto fail;
+					break;
 				}
-
-				lock_and_validation_needed = true;
-			} else {
-				/*
-				 * The new stream is unused, so we release it
-				 */
-				if (new_stream)
-					dc_stream_release(new_stream);
-
+				
+				*lock_and_validation_needed = true;
 			}
 		}
 
+		/* Release extra reference */
+		if (new_stream)
+			dc_stream_release(new_stream);
+	}
 
-		/*
-		 * Hack: Commit needs planes right now, specifically for gamma
-		 * TODO rework commit to check CRTC for gamma change
-		 */
-		if (crtc_state->color_mgmt_changed) {
+	return ret;
+}
 
-			ret = drm_atomic_add_affected_planes(state, crtc);
-			if (ret)
-				goto fail;
-		}
-	}
+static int dm_update_planes_state(
+		struct dc *dc,
+		struct drm_atomic_state *state,
+		bool enable,
+		bool *lock_and_validation_needed)
+{
+        struct drm_crtc *new_plane_crtc, *old_plane_crtc;
+        struct drm_crtc_state *new_crtc_state;
+        struct drm_plane *plane;
+        struct drm_plane_state *old_plane_state, *new_plane_state;
+        struct dm_crtc_state *new_acrtc_state, *old_acrtc_state;
+        struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
+        struct dm_plane_state *new_dm_plane_state, *old_dm_plane_state;
+        int i ;
+        /* TODO return page_flip_needed() function */
+        bool pflip_needed  = !state->allow_modeset;
+        int ret = 0;
 
-	/* Check scaling and undersacn changes*/
-	/*TODO Removed scaling changes validation due to inability to commit
-	 * new stream into context w\o causing full reset. Need to
-	 * decide how to handle.
-	 */
-	for_each_connector_in_state(state, connector, conn_state, i) {
-		struct amdgpu_connector *aconnector = to_amdgpu_connector(connector);
-		struct dm_connector_state *con_old_state =
-				to_dm_connector_state(aconnector->base.state);
-		struct dm_connector_state *con_new_state =
-						to_dm_connector_state(conn_state);
-		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
+        if (pflip_needed)
+                return ret;
 
-		/* Skip any modesets/resets */
-		if (!acrtc || drm_atomic_crtc_needs_modeset(acrtc->base.state))
-			continue;
+        /* Add new planes */
+        for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+                new_plane_crtc = new_plane_state->crtc;
+                old_plane_crtc = old_plane_state->crtc;
+                new_dm_plane_state = to_dm_plane_state(new_plane_state);
+                old_dm_plane_state = to_dm_plane_state(old_plane_state);
 
-		/* Skip any thing not scale or underscan changes */
-		if (!is_scaling_state_different(con_new_state, con_old_state))
-			continue;
+                /*TODO Implement atomic check for cursor plane */
+                if (plane->type == DRM_PLANE_TYPE_CURSOR)
+                        continue;
 
-		lock_and_validation_needed = true;
-	}
+                /* Remove any changed/removed planes */
+                if (!enable) {
 
-	/* Add new planes */
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		new_acrtc_state = to_dm_crtc_state(crtc_state);
+                        if (!old_plane_crtc)
+                                continue;
 
-		if (pflip_needed)
-			continue;
+                        old_acrtc_state = to_dm_crtc_state(
+                                        drm_atomic_get_old_crtc_state(
+                                                        state,
+                                                        old_plane_crtc));
 
-		for_each_plane_in_state(state, plane, plane_state, j) {
-			struct drm_crtc *plane_crtc = plane_state->crtc;
-			struct dm_plane_state *dm_plane_state = to_dm_plane_state(plane_state);
+                        if (!old_acrtc_state->stream)
+                                continue;
 
-			/*TODO Implement atomic check for cursor plane */
-			if (plane->type == DRM_PLANE_TYPE_CURSOR)
-				continue;
+                        DRM_DEBUG_KMS("Disabling DRM plane: %d on DRM crtc %d\n",
+                                        plane->base.id, old_plane_crtc->base.id);
 
-			if (crtc != plane_crtc)
-				continue;
+                        if (!dc_remove_plane_from_context(
+                                        dc,
+                                        old_acrtc_state->stream,
+                                        old_dm_plane_state->dc_state,
+                                        dm_state->context)) {
 
-			if (!drm_atomic_plane_disabling(plane->state, plane_state)) {
-				struct dc_plane_state *dc_plane_state;
+                                ret = EINVAL;
+                                return ret;
+                        }
 
-				WARN_ON(!new_acrtc_state->stream);
 
-				dc_plane_state = dc_create_plane_state(dc);
+                        dc_plane_state_release(old_dm_plane_state->dc_state);
+                        new_dm_plane_state->dc_state = NULL;
 
-				WARN_ON(dm_plane_state->dc_state);
+                        *lock_and_validation_needed = true;
 
-				dm_plane_state->dc_state = dc_plane_state;
+                } else { /* Add new planes */
 
-				ret = fill_plane_attributes(
-					plane_crtc->dev->dev_private,
-					dc_plane_state,
-					plane_state,
-					crtc_state,
-					false);
-				if (ret)
-					goto fail;
+                        if (drm_atomic_plane_disabling(plane->state, new_plane_state))
+                                continue;
 
+                        if (!new_plane_crtc)
+                                continue;
 
-				if (!dc_add_plane_to_context(
-						dc,
-						new_acrtc_state->stream,
-						dc_plane_state,
-						dm_state->context)) {
+                        new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_crtc);
+                        new_acrtc_state = to_dm_crtc_state(new_crtc_state);
 
-					ret = EINVAL;
-					goto fail;
-				}
+                        if (!new_acrtc_state->stream)
+                                continue;
 
 
-				lock_and_validation_needed = true;
-			}
-		}
-	}
+                        WARN_ON(new_dm_plane_state->dc_state);
 
-	/* Run this here since we want to validate the streams we created */
-	ret = drm_atomic_helper_check_planes(dev, state);
-	if (ret)
-		goto fail;
+                        new_dm_plane_state->dc_state = dc_create_plane_state(dc);
 
-	/*
-	 * For full updates case when
-	 * removing/adding/updating  streams on once CRTC while flipping
-	 * on another CRTC,
-	 * acquiring global lock  will guarantee that any such full
-	 * update commit
-	 * will wait for completion of any outstanding flip using DRMs
-	 * synchronization events.
-	 */
+                        DRM_DEBUG_KMS("Enabling DRM plane: %d on DRM crtc %d\n",
+                                        plane->base.id, new_plane_crtc->base.id);
 
-	if (lock_and_validation_needed) {
+                        if (!new_dm_plane_state->dc_state) {
+                                ret = -EINVAL;
+                                return ret;
+                        }
 
-		ret = do_aquire_global_lock(dev, state);
-		if (ret)
-			goto fail;
+                        ret = fill_plane_attributes(
+                                new_plane_crtc->dev->dev_private,
+                                new_dm_plane_state->dc_state,
+                                new_plane_state,
+                                new_crtc_state,
+                                false);
+                        if (ret)
+                                return ret;
 
-		if (!dc_validate_global_state(dc, dm_state->context)) {
-			ret = -EINVAL;
-			goto fail;
-		}
-	}
 
-	/* Must be success */
-	WARN_ON(ret);
-	return ret;
+                        if (!dc_add_plane_to_context(
+                                        dc,
+                                        new_acrtc_state->stream,
+                                        new_dm_plane_state->dc_state,
+                                        dm_state->context)) {
 
-fail:
-	if (ret == -EDEADLK)
-		DRM_DEBUG_KMS("Atomic check stopped due to to deadlock.\n");
-	else if (ret == -EINTR || ret == -EAGAIN || ret == -ERESTARTSYS)
-		DRM_DEBUG_KMS("Atomic check stopped due to to signal.\n");
-	else
-		DRM_ERROR("Atomic check failed with err: %d .\n", ret);
+                                ret = -EINVAL;
+                                return ret;
+                        }
 
-	return ret;
+                        *lock_and_validation_needed = true;
+                }
+        }
+
+
+        return ret;
+}
+
+int amdgpu_dm_atomic_check(struct drm_device *dev,
+                        struct drm_atomic_state *state)
+{
+        int i;
+        int ret;
+        struct amdgpu_device *adev = dev->dev_private;
+        struct dc *dc = adev->dm.dc;
+        struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
+        struct drm_connector *connector;
+        struct drm_connector_state *conn_state;
+        struct drm_crtc *crtc;
+        struct drm_crtc_state *crtc_state;
+
+        /*
+         * This bool will be set for true for any modeset/reset
+         * or plane update which implies non fast surface update.
+         */
+        bool lock_and_validation_needed = false;
+
+        ret = drm_atomic_helper_check_modeset(dev, state);
+
+        if (ret) {
+                DRM_ERROR("Atomic state validation failed with error :%d !\n", ret);
+                return ret;
+        }
+
+        /*
+         * Hack: Commit needs planes right now, specifically for gamma
+         * TODO rework commit to check CRTC for gamma change
+         */
+        for_each_crtc_in_state(state, crtc, crtc_state, i) {
+                if (crtc_state->color_mgmt_changed) {
+                        ret = drm_atomic_add_affected_planes(state, crtc);
+                        if (ret)
+                                goto fail;
+                }
+        }
+
+        /* Remove exiting planes if they are modified */
+        ret = dm_update_planes_state(dc, state, false, &lock_and_validation_needed);
+        if (ret) {
+                goto fail;
+        }
+
+        /* Disable all crtcs which require disable */
+        ret = dm_update_crtcs_state(dc, state, false, &lock_and_validation_needed);
+        if (ret) {
+                goto fail;
+        }
+
+        /* Enable all crtcs which require enable */
+        ret = dm_update_crtcs_state(dc, state, true, &lock_and_validation_needed);
+        if (ret) {
+                goto fail;
+        }
+
+        /* Add new/modified planes */
+        ret = dm_update_planes_state(dc, state, true, &lock_and_validation_needed);
+        if (ret) {
+                goto fail;
+        }
+
+         /* Run this here since we want to validate the streams we created */
+         ret = drm_atomic_helper_check_planes(dev, state);
+         if (ret)
+                 goto fail;
+
+        /* Check scaling and undersacn changes*/
+        /*TODO Removed scaling changes validation due to inability to commit
+         * new stream into context w\o causing full reset. Need to
+         * decide how to handle.
+         */
+        for_each_connector_in_state(state, connector, conn_state, i) {
+                struct amdgpu_connector *aconnector = to_amdgpu_connector(connector);
+                struct dm_connector_state *con_old_state =
+                                to_dm_connector_state(aconnector->base.state);
+                struct dm_connector_state *con_new_state =
+                                                to_dm_connector_state(conn_state);
+                struct amdgpu_crtc *acrtc = to_amdgpu_crtc(con_new_state->base.crtc);
+
+                /* Skip any modesets/resets */
+                if (!acrtc || drm_atomic_crtc_needs_modeset(acrtc->base.state))
+                        continue;
+
+                /* Skip any thing not scale or underscan changes */
+                if (!is_scaling_state_different(con_new_state, con_old_state))
+                        continue;
+
+                lock_and_validation_needed = true;
+        }
+
+        /*
+         * For full updates case when
+         * removing/adding/updating  streams on once CRTC while flipping
+         * on another CRTC,
+         * acquiring global lock  will guarantee that any such full
+         * update commit
+         * will wait for completion of any outstanding flip using DRMs
+         * synchronization events.
+         */
+
+        if (lock_and_validation_needed) {
+
+                ret = do_aquire_global_lock(dev, state);
+                if (ret)
+                        goto fail;
+
+                if (!dc_validate_global_state(dc, dm_state->context)) {
+                        ret = -EINVAL;
+                        goto fail;
+                }
+        }
+
+        /* Must be success */
+        WARN_ON(ret);
+        return ret;
+
+fail:
+        if (ret == -EDEADLK)
+                DRM_DEBUG_KMS("Atomic check stopped due to to deadlock.\n");
+        else if (ret == -EINTR || ret == -EAGAIN || ret == -ERESTARTSYS)
+                DRM_DEBUG_KMS("Atomic check stopped due to to signal.\n");
+        else
+                DRM_ERROR("Atomic check failed with err: %d \n", ret);
+
+        return ret;
 }
 
 static bool is_dp_capable_without_timing_msa(
-- 
2.7.4