aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0789-drm-amd-dal-non-destructive-validate.patch
blob: 5d834481894330249209f4de514824c754d15381 (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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
From c49d3cd9af2452b28e673fa354f057989062011e Mon Sep 17 00:00:00 2001
From: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Date: Fri, 5 Feb 2016 11:41:55 -0500
Subject: [PATCH 0789/1110] drm/amd/dal: non destructive validate

This changes the way resources are handled to make validate non
destructive to current state and allow allocating mpo resources
if needed.

Signed-off-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
---
 drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_irq.c  |   2 +-
 .../gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c    |   3 +-
 drivers/gpu/drm/amd/dal/dc/core/dc.c               |  46 +-
 drivers/gpu/drm/amd/dal/dc/core/dc_link.c          | 133 +++--
 drivers/gpu/drm/amd/dal/dc/core/dc_link_hwss.c     |   4 +-
 drivers/gpu/drm/amd/dal/dc/core/dc_resource.c      | 398 +++++++-------
 drivers/gpu/drm/amd/dal/dc/core/dc_target.c        | 350 +++++++-----
 drivers/gpu/drm/amd/dal/dc/dc.h                    |   8 +-
 drivers/gpu/drm/amd/dal/dc/dc_types.h              |  23 +-
 .../gpu/drm/amd/dal/dc/dce100/dce100_resource.c    | 210 ++++----
 .../drm/amd/dal/dc/dce110/dce110_hw_sequencer.c    | 586 +++++++++------------
 .../drm/amd/dal/dc/dce110/dce110_link_encoder.c    |  13 +-
 .../drm/amd/dal/dc/dce110/dce110_link_encoder.h    |   2 +-
 .../gpu/drm/amd/dal/dc/dce110/dce110_resource.c    | 345 ++++++------
 drivers/gpu/drm/amd/dal/dc/inc/core_types.h        | 107 ++--
 drivers/gpu/drm/amd/dal/dc/inc/hw_sequencer.h      |  23 +-
 drivers/gpu/drm/amd/dal/dc/inc/link_encoder.h      |   5 +-
 drivers/gpu/drm/amd/dal/dc/inc/link_hwss.h         |   2 +-
 drivers/gpu/drm/amd/dal/dc/inc/resource.h          |  13 +-
 .../drm/amd/dal/dc/virtual/virtual_link_encoder.c  |   2 +-
 drivers/gpu/drm/amd/dal/include/grph_csc_types.h   |  13 -
 21 files changed, 1145 insertions(+), 1143 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_irq.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_irq.c
index 9b5fd70..2ba79ab 100644
--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_irq.c
+++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_irq.c
@@ -688,7 +688,7 @@ static inline int dm_irq_state(
 		return 0;
 	}
 
-	irq_source = dc_target_get_irq_src(acrtc->target, dal_irq_type);
+	irq_source = dc_target_get_irq_src(adev->dm.dc, acrtc->target, dal_irq_type);
 
 	st = (state == AMDGPU_IRQ_STATE_ENABLE);
 
diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
index 2cb445d..39490bf 100644
--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
@@ -484,8 +484,7 @@ static void fill_plane_attributes_from_fb(
 	surface->scaling_quality.v_taps_c = 2;
 
 	/* TODO: unhardcode */
-	surface->colorimetry.limited_range = false;
-	surface->colorimetry.color_space = SURFACE_COLOR_SPACE_SRGB;
+	surface->color_space = COLOR_SPACE_SRGB_FULL_RANGE;
 	surface->scaling_quality.h_taps = 2;
 	surface->scaling_quality.v_taps = 2;
 	surface->stereo_format = PLANE_STEREO_FORMAT_NONE;
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc.c b/drivers/gpu/drm/amd/dal/dc/core/dc.c
index d788917..bcc6f68 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc.c
@@ -172,7 +172,7 @@ static void init_hw(struct dc *dc)
 	struct transform *xfm;
 
 	bp = dal_adapter_service_get_bios_parser(dc->res_pool.adapter_srv);
-	for(i = 0; i < dc->res_pool.controller_count; i++) {
+	for (i = 0; i < dc->res_pool.pipe_count; i++) {
 		xfm = dc->res_pool.transforms[i];
 
 		dc->hwss.enable_display_power_gating(
@@ -201,7 +201,7 @@ static void init_hw(struct dc *dc)
 		link->link_enc->funcs->hw_init(link->link_enc);
 	}
 
-	for(i = 0; i < dc->res_pool.controller_count; i++) {
+	for (i = 0; i < dc->res_pool.pipe_count; i++) {
 		struct timing_generator *tg = dc->res_pool.timing_generators[i];
 
 		tg->funcs->disable_vga(tg);
@@ -466,11 +466,11 @@ static void program_timing_sync(
 	uint8_t i;
 	uint8_t j;
 	uint8_t group_size = 0;
-	uint8_t tg_count = ctx->res_ctx.pool.controller_count;
+	uint8_t tg_count = ctx->res_ctx.pool.pipe_count;
 	struct timing_generator *tg_set[3];
 
 	for (i = 0; i < tg_count; i++) {
-		if (!ctx->res_ctx.controller_ctx[i].stream)
+		if (!ctx->res_ctx.pipe_ctx[i].stream)
 			continue;
 
 		tg_set[0] = ctx->res_ctx.pool.timing_generators[i];
@@ -480,13 +480,13 @@ static void program_timing_sync(
 		 * same timing, add all tgs with same timing to the group
 		 */
 		for (j = i + 1; j < tg_count; j++) {
-			if (!ctx->res_ctx.controller_ctx[j].stream)
+			if (!ctx->res_ctx.pipe_ctx[j].stream)
 				continue;
 
 			if (is_same_timing(
-				&ctx->res_ctx.controller_ctx[j].stream->public
+				&ctx->res_ctx.pipe_ctx[j].stream->public
 								.timing,
-				&ctx->res_ctx.controller_ctx[i].stream->public
+				&ctx->res_ctx.pipe_ctx[i].stream->public
 								.timing)) {
 				tg_set[group_size] =
 					ctx->res_ctx.pool.timing_generators[j];
@@ -580,7 +580,7 @@ bool dc_commit_targets(
 	}
 
 	if (result == DC_OK) {
-		dc->hwss.reset_hw_ctx(dc, context, target_count);
+		dc->hwss.reset_hw_ctx(dc, context);
 
 		if (context->target_count > 0)
 			result = dc->hwss.apply_ctx_to_hw(dc, context);
@@ -588,7 +588,7 @@ bool dc_commit_targets(
 
 	for (i = 0; i < context->target_count; i++) {
 		struct dc_target *dc_target = &context->targets[i]->public;
-		if (context->targets[i]->status.surface_count > 0)
+		if (context->target_status[i].surface_count > 0)
 			dc_target_enable_memory_requests(dc_target);
 	}
 
@@ -609,7 +609,6 @@ bool dc_commit_targets(
 
 	pplib_apply_display_requirements(dc, context, &context->pp_display_cfg);
 
-	/* TODO: disable unused plls*/
 fail:
 	dm_free(dc->ctx, context);
 
@@ -659,12 +658,13 @@ const struct audio **dc_get_audios(struct dc *dc)
 
 void dc_get_caps(const struct dc *dc, struct dc_caps *caps)
 {
-	caps->max_targets = dc->res_pool.controller_count;
+	caps->max_targets = dc->res_pool.pipe_count;
 	caps->max_links = dc->link_count;
 	caps->max_audios = dc->res_pool.audio_count;
 }
 
-void dc_flip_surface_addrs(struct dc* dc,
+void dc_flip_surface_addrs(
+		struct dc *dc,
 		const struct dc_surface *const surfaces[],
 		struct dc_flip_addrs flip_addrs[],
 		uint32_t count)
@@ -679,10 +679,8 @@ void dc_flip_surface_addrs(struct dc* dc,
 		surface->public.address = flip_addrs[i].address;
 		surface->public.flip_immediate = flip_addrs[i].flip_immediate;
 
-		dc->hwss.update_plane_address(
-			dc,
-			surface,
-			DC_TARGET_TO_CORE(surface->status.dc_target));
+		dc->hwss.update_plane_addrs(
+				dc, &dc->current_context.res_ctx, surface);
 	}
 }
 
@@ -737,27 +735,19 @@ const struct dc_target *dc_get_target_on_irq_source(
 
 	for (i = 0; i < dc->current_context.target_count; i++) {
 		struct core_target *target = dc->current_context.targets[i];
-
-		struct dc_target *dc_target;
-
-		if (NULL == target) {
-			dm_error("%s: 'dc_target' is NULL for irq source: %d\n!",
-					__func__, src);
-			continue;
-		}
-
-		dc_target = &target->public;
+		struct dc_target *dc_target = &target->public;
 
 		for (j = 0; j < target->public.stream_count; j++) {
 			const struct core_stream *stream =
 				DC_STREAM_TO_CORE(dc_target->streams[j]);
-			const uint8_t controller_idx = stream->controller_idx;
 
-			if (controller_idx == crtc_idx)
+			if (dc->current_context.res_ctx.
+					pipe_ctx[crtc_idx].stream == stream)
 				return dc_target;
 		}
 	}
 
+	dm_error("%s: 'dc_target' is NULL for irq source: %d\n!", __func__, src);
 	return NULL;
 }
 
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_link.c b/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
index 9a5eadf..5fd5800 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_link.c
@@ -1142,8 +1142,9 @@ static void dpcd_configure_panel_mode(
 			panel_mode_edp);
 }
 
-static enum dc_status enable_link_dp(struct core_stream *stream)
+static enum dc_status enable_link_dp(struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	enum dc_status status;
 	bool skip_video_pattern;
 	struct core_link *link = stream->sink->link;
@@ -1154,7 +1155,7 @@ static enum dc_status enable_link_dp(struct core_stream *stream)
 	decide_link_settings(stream, &link_settings);
 	dp_enable_link_phy(
 		stream->sink->link,
-		stream->signal,
+		pipe_ctx->signal,
 		&link_settings);
 
 	panel_mode = dp_get_panel_mode(link);
@@ -1175,9 +1176,9 @@ static enum dc_status enable_link_dp(struct core_stream *stream)
 	return status;
 }
 
-static enum dc_status enable_link_dp_mst(struct core_stream *stream)
+static enum dc_status enable_link_dp_mst(struct pipe_ctx *pipe_ctx)
 {
-	struct core_link *link = stream->sink->link;
+	struct core_link *link = pipe_ctx->stream->sink->link;
 
 	/* sink signal type after MST branch is MST. Multiple MST sinks
 	 * share one link. Link DP PHY is enable or training only once.
@@ -1185,11 +1186,12 @@ static enum dc_status enable_link_dp_mst(struct core_stream *stream)
 	if (link->public.cur_link_settings.lane_count != LANE_COUNT_UNKNOWN)
 		return DC_OK;
 
-	return enable_link_dp(stream);
+	return enable_link_dp(pipe_ctx);
 }
 
-static void enable_link_hdmi(struct core_stream *stream)
+static void enable_link_hdmi(struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	struct core_link *link = stream->sink->link;
 
 	/* enable video output */
@@ -1214,7 +1216,7 @@ static void enable_link_hdmi(struct core_stream *stream)
 		break;
 	}
 
-	if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
+	if (pipe_ctx->signal == SIGNAL_TYPE_HDMI_TYPE_A)
 		dal_ddc_service_write_scdc_data(
 			stream->sink->link->ddc,
 			normalized_pix_clk,
@@ -1225,33 +1227,33 @@ static void enable_link_hdmi(struct core_stream *stream)
 
 	link->link_enc->funcs->enable_tmds_output(
 			link->link_enc,
-			stream->clock_source->id,
+			pipe_ctx->clock_source->id,
 			stream->public.timing.display_color_depth,
-			stream->signal == SIGNAL_TYPE_HDMI_TYPE_A,
-			stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK,
+			pipe_ctx->signal == SIGNAL_TYPE_HDMI_TYPE_A,
+			pipe_ctx->signal == SIGNAL_TYPE_DVI_DUAL_LINK,
 			stream->public.timing.pix_clk_khz);
 
-	if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
+	if (pipe_ctx->signal == SIGNAL_TYPE_HDMI_TYPE_A)
 		dal_ddc_service_read_scdc_data(link->ddc);
 }
 
 /****************************enable_link***********************************/
-static enum dc_status enable_link(struct core_stream *stream)
+static enum dc_status enable_link(struct pipe_ctx *pipe_ctx)
 {
 	enum dc_status status = DC_ERROR_UNEXPECTED;
-	switch (stream->signal) {
+	switch (pipe_ctx->signal) {
 	case SIGNAL_TYPE_DISPLAY_PORT:
 	case SIGNAL_TYPE_EDP:
-		status = enable_link_dp(stream);
+		status = enable_link_dp(pipe_ctx);
 		break;
 	case SIGNAL_TYPE_DISPLAY_PORT_MST:
-		status = enable_link_dp_mst(stream);
-		dm_sleep_in_milliseconds(stream->ctx, 200);
+		status = enable_link_dp_mst(pipe_ctx);
+		dm_sleep_in_milliseconds(pipe_ctx->stream->ctx, 200);
 		break;
 	case SIGNAL_TYPE_DVI_SINGLE_LINK:
 	case SIGNAL_TYPE_DVI_DUAL_LINK:
 	case SIGNAL_TYPE_HDMI_TYPE_A:
-		enable_link_hdmi(stream);
+		enable_link_hdmi(pipe_ctx);
 		status = DC_OK;
 		break;
 	case SIGNAL_TYPE_VIRTUAL:
@@ -1261,20 +1263,20 @@ static enum dc_status enable_link(struct core_stream *stream)
 		break;
 	}
 
-	if (stream->audio && status == DC_OK) {
+	if (pipe_ctx->audio && status == DC_OK) {
 		/* notify audio driver for audio modes of monitor */
-		dal_audio_enable_azalia_audio_jack_presence(stream->audio,
-				stream->stream_enc->id);
+		dal_audio_enable_azalia_audio_jack_presence(pipe_ctx->audio,
+				pipe_ctx->stream_enc->id);
 
 		/* un-mute audio */
-		dal_audio_unmute(stream->audio, stream->stream_enc->id,
-				stream->signal);
+		dal_audio_unmute(pipe_ctx->audio, pipe_ctx->stream_enc->id,
+				pipe_ctx->signal);
 	}
 
 	return status;
 }
 
-static void disable_link(struct core_stream *stream)
+static void disable_link(struct core_link *link, enum signal_type signal)
 {
 	/*
 	 * TODO: implement call for dp_set_hw_test_pattern
@@ -1286,21 +1288,14 @@ static void disable_link(struct core_stream *stream)
 	 * it will lead to querying dynamic link capabilities
 	 * which should be done before enable output */
 
-	if (dc_is_dp_signal(stream->signal)) {
+	if (dc_is_dp_signal(signal)) {
 		/* SST DP, eDP */
-		if (dc_is_dp_sst_signal(stream->signal))
-			dp_disable_link_phy(
-					stream->sink->link, stream->signal);
-		else {
-			dp_disable_link_phy_mst(
-					stream->sink->link, stream);
-		}
-	} else {
-		struct link_encoder *encoder =
-				stream->sink->link->link_enc;
-
-		encoder->funcs->disable_output(encoder, stream->signal);
-	}
+		if (dc_is_dp_sst_signal(signal))
+			dp_disable_link_phy(link, signal);
+		else
+			dp_disable_link_phy_mst(link, signal);
+	} else
+		link->link_enc->funcs->disable_output(link->link_enc, signal);
 }
 
 enum dc_status dc_link_validate_mode_timing(
@@ -1360,9 +1355,9 @@ static struct fixed31_32 get_pbn_per_slot(struct core_stream *stream)
 	return dal_fixed31_32_div_int(mbps, 54);
 }
 
-static int get_color_depth(struct core_stream *stream)
+static int get_color_depth(enum dc_color_depth color_depth)
 {
-	switch (stream->pix_clk_params.color_depth) {
+	switch (color_depth) {
 	case COLOR_DEPTH_666: return 6;
 	case COLOR_DEPTH_888: return 8;
 	case COLOR_DEPTH_101010: return 10;
@@ -1373,7 +1368,7 @@ static int get_color_depth(struct core_stream *stream)
 	}
 }
 
-static struct fixed31_32 get_pbn_from_timing(struct core_stream *stream)
+static struct fixed31_32 get_pbn_from_timing(struct pipe_ctx *pipe_ctx)
 {
 	uint32_t bpc;
 	uint64_t kbps;
@@ -1381,8 +1376,8 @@ static struct fixed31_32 get_pbn_from_timing(struct core_stream *stream)
 	uint32_t numerator;
 	uint32_t denominator;
 
-	bpc = get_color_depth(stream);
-	kbps = stream->pix_clk_params.requested_pix_clk * bpc * 3;
+	bpc = get_color_depth(pipe_ctx->pix_clk_params.color_depth);
+	kbps = pipe_ctx->pix_clk_params.requested_pix_clk * bpc * 3;
 
 	/*
 	 * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
@@ -1405,7 +1400,7 @@ static struct fixed31_32 get_pbn_from_timing(struct core_stream *stream)
 
 static void update_mst_stream_alloc_table(
 	struct core_link *link,
-	struct core_stream *stream,
+	struct stream_encoder *stream_enc,
 	const struct dp_mst_stream_allocation_table *proposed_table)
 {
 	struct link_mst_stream_allocation work_table[MAX_CONTROLLER_NUM] = {
@@ -1440,7 +1435,7 @@ static void update_mst_stream_alloc_table(
 				proposed_table->stream_allocations[i].vcp_id;
 			work_table[i].slot_count =
 				proposed_table->stream_allocations[i].slot_count;
-			work_table[i].stream_enc = stream->stream_enc;
+			work_table[i].stream_enc = stream_enc;
 		}
 	}
 
@@ -1455,11 +1450,12 @@ static void update_mst_stream_alloc_table(
 /* convert link_mst_stream_alloc_table to dm dp_mst_stream_alloc_table
  * because stream_encoder is not exposed to dm
  */
-static enum dc_status allocate_mst_payload(struct core_stream *stream)
+static enum dc_status allocate_mst_payload(struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	struct core_link *link = stream->sink->link;
 	struct link_encoder *link_encoder = link->link_enc;
-	struct stream_encoder *stream_encoder = stream->stream_enc;
+	struct stream_encoder *stream_encoder = pipe_ctx->stream_enc;
 	struct dp_mst_stream_allocation_table proposed_table = {0};
 	struct fixed31_32 avg_time_slots_per_mtp;
 	struct fixed31_32 pbn;
@@ -1478,7 +1474,8 @@ static enum dc_status allocate_mst_payload(struct core_stream *stream)
 		&proposed_table,
 		true);
 
-	update_mst_stream_alloc_table(link, stream, &proposed_table);
+	update_mst_stream_alloc_table(
+				link, pipe_ctx->stream_enc, &proposed_table);
 
 	dal_logger_write(link->ctx->logger,
 			LOG_MAJOR_MST,
@@ -1532,7 +1529,7 @@ static enum dc_status allocate_mst_payload(struct core_stream *stream)
 
 	/* slot X.Y for only current stream */
 	pbn_per_slot = get_pbn_per_slot(stream);
-	pbn = get_pbn_from_timing(stream);
+	pbn = get_pbn_from_timing(pipe_ctx);
 	avg_time_slots_per_mtp = dal_fixed31_32_div(pbn, pbn_per_slot);
 
 
@@ -1545,11 +1542,12 @@ static enum dc_status allocate_mst_payload(struct core_stream *stream)
 
 }
 
-static enum dc_status deallocate_mst_payload(struct core_stream *stream)
+static enum dc_status deallocate_mst_payload(struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	struct core_link *link = stream->sink->link;
 	struct link_encoder *link_encoder = link->link_enc;
-	struct stream_encoder *stream_encoder = stream->stream_enc;
+	struct stream_encoder *stream_encoder = pipe_ctx->stream_enc;
 	struct dp_mst_stream_allocation_table proposed_table = {0};
 	struct fixed31_32 avg_time_slots_per_mtp = dal_fixed31_32_from_int(0);
 	uint8_t i;
@@ -1575,7 +1573,8 @@ static enum dc_status deallocate_mst_payload(struct core_stream *stream)
 				&proposed_table,
 				false);
 
-	update_mst_stream_alloc_table(link, stream, &proposed_table);
+	update_mst_stream_alloc_table(
+		link, pipe_ctx->stream_enc, &proposed_table);
 
 	dal_logger_write(link->ctx->logger,
 			LOG_MAJOR_MST,
@@ -1618,38 +1617,32 @@ static enum dc_status deallocate_mst_payload(struct core_stream *stream)
 	return DC_OK;
 }
 
-void core_link_enable_stream(
-		struct core_link *link,
-		struct core_stream *stream)
+void core_link_enable_stream(struct pipe_ctx *pipe_ctx)
 {
-	struct dc *dc = stream->ctx->dc;
+	struct dc *dc = pipe_ctx->stream->ctx->dc;
 
-	if (DC_OK != enable_link(stream)) {
+	if (DC_OK != enable_link(pipe_ctx)) {
 			BREAK_TO_DEBUGGER();
 			return;
 	}
 
-	dc->hwss.enable_stream(stream);
-	stream->status.link = &link->public;
+	dc->hwss.enable_stream(pipe_ctx);
 
-	if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
-		allocate_mst_payload(stream);
+	if (pipe_ctx->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
+		allocate_mst_payload(pipe_ctx);
 }
 
-void core_link_disable_stream(
-		struct core_link *link,
-		struct core_stream *stream)
+void core_link_disable_stream(struct pipe_ctx *pipe_ctx)
 {
-	struct dc *dc = stream->ctx->dc;
-
-	if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
-		deallocate_mst_payload(stream);
+	struct dc *dc = pipe_ctx->stream->ctx->dc;
 
-	stream->status.link = NULL;
-	dc->hwss.disable_stream(stream);
+	pipe_ctx->stream->status.link = NULL;
+	if (pipe_ctx->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
+		deallocate_mst_payload(pipe_ctx);
 
-	disable_link(stream);
+	dc->hwss.disable_stream(pipe_ctx);
 
+	disable_link(pipe_ctx->stream->sink->link, pipe_ctx->signal);
 }
 
 
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_link_hwss.c b/drivers/gpu/drm/amd/dal/dc/core/dc_link_hwss.c
index 92d70ed..04a0c17 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_link_hwss.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_link_hwss.c
@@ -93,13 +93,13 @@ void dp_disable_link_phy(struct core_link *link, enum signal_type signal)
 			sizeof(link->public.cur_link_settings));
 }
 
-void dp_disable_link_phy_mst(struct core_link *link, struct core_stream *stream)
+void dp_disable_link_phy_mst(struct core_link *link, enum signal_type signal)
 {
 	/* MST disable link only when no stream use the link */
 	if (link->mst_stream_alloc_table.stream_count > 0)
 		return;
 
-	dp_disable_link_phy(link, stream->signal);
+	dp_disable_link_phy(link, signal);
 }
 
 bool dp_set_hw_training_pattern(
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c b/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
index ec6db8d..70bf935 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_resource.c
@@ -99,13 +99,13 @@ bool is_same_timing(
 }
 
 static bool is_sharable_clk_src(
-	const struct core_stream *stream_with_clk_src,
-	const struct core_stream *stream)
+	const struct pipe_ctx *pipe_with_clk_src,
+	const struct pipe_ctx *pipe)
 {
-	enum clock_source_id id = stream_with_clk_src->clock_source->id;
+	enum clock_source_id id = pipe_with_clk_src->clock_source->id;
 #if defined(CONFIG_DRM_AMD_DAL_DCE10_0)
 	enum dce_version dce_ver = dal_adapter_service_get_dce_version(
-			stream->sink->link->adapter_srv);
+		pipe->stream->sink->link->adapter_srv);
 
 	/* Currently no clocks are shared for DCE 10 until VBIOS behaviour
 	 * is verified for this use case
@@ -114,37 +114,32 @@ static bool is_sharable_clk_src(
 		return false;
 #endif
 
-	if (stream_with_clk_src->clock_source == NULL)
+	if (pipe_with_clk_src->clock_source == NULL)
 		return false;
 
 	if (id == CLOCK_SOURCE_ID_EXTERNAL)
 		return false;
 
-
 	if(!is_same_timing(
-		&stream_with_clk_src->public.timing, &stream->public.timing))
+		&pipe_with_clk_src->stream->public.timing,
+		&pipe->stream->public.timing))
 		return false;
 
 	return true;
 }
 
 struct clock_source *find_used_clk_src_for_sharing(
-					struct validate_context *context,
-					struct core_stream *stream)
+					struct resource_context *res_ctx,
+					struct pipe_ctx *pipe_ctx)
 {
-	uint8_t i, j;
-	for (i = 0; i < context->target_count; i++) {
-		struct core_target *target = context->targets[i];
-		for (j = 0; j < target->public.stream_count; j++) {
-			struct core_stream *clock_source_stream =
-				DC_STREAM_TO_CORE(target->public.streams[j]);
+	uint8_t i;
 
-			if (clock_source_stream->clock_source == NULL)
-				continue;
+	for (i = 0; i < MAX_PIPES; i++) {
+		if (res_ctx->pipe_ctx[i].clock_source == NULL)
+			continue;
 
-			if (is_sharable_clk_src(clock_source_stream, stream))
-				return clock_source_stream->clock_source;
-		}
+		if (is_sharable_clk_src(&res_ctx->pipe_ctx[i], pipe_ctx))
+			return res_ctx->pipe_ctx[i].clock_source;
 	}
 
 	return NULL;
@@ -236,7 +231,7 @@ static enum pixel_format convert_pixel_format_to_dalsurface(
 
 static void calculate_viewport(
 		const struct dc_surface *surface,
-		struct core_stream *stream)
+		struct pipe_ctx *pipe_ctx)
 {
 	const struct rect src = surface->src_rect;
 	const struct rect clip = surface->clip_rect;
@@ -245,61 +240,59 @@ static void calculate_viewport(
 	/* offset = src.ofs + (clip.ofs - dst.ofs) * scl_ratio
 	 * num_pixels = clip.num_pix * scl_ratio
 	 */
-	stream->viewport.x = src.x + (clip.x - dst.x) * src.width / dst.width;
-	stream->viewport.width = clip.width * src.width / dst.width;
+	pipe_ctx->viewport.x = src.x + (clip.x - dst.x) * src.width / dst.width;
+	pipe_ctx->viewport.width = clip.width * src.width / dst.width;
 
-	stream->viewport.y = src.y + (clip.y - dst.y) * src.height / dst.height;
-	stream->viewport.height = clip.height * src.height / dst.height;
+	pipe_ctx->viewport.y = src.y + (clip.y - dst.y) * src.height / dst.height;
+	pipe_ctx->viewport.height = clip.height * src.height / dst.height;
 
 	/* Minimum viewport such that 420/422 chroma vp is non 0 */
-	if (stream->viewport.width < 2)
-	{
-		stream->viewport.width = 2;
-	}
-	if (stream->viewport.height < 2)
-	{
-		stream->viewport.height = 2;
-	}
+	if (pipe_ctx->viewport.width < 2)
+		pipe_ctx->viewport.width = 2;
+	if (pipe_ctx->viewport.height < 2)
+		pipe_ctx->viewport.height = 2;
 }
 
 static void calculate_overscan(
 		const struct dc_surface *surface,
-		struct core_stream *stream)
+		struct pipe_ctx *pipe_ctx)
 {
-	stream->overscan.left = stream->public.dst.x;
+	struct core_stream *stream = pipe_ctx->stream;
+
+	pipe_ctx->overscan.left = stream->public.dst.x;
 	if (stream->public.src.x < surface->clip_rect.x)
-		stream->overscan.left += (surface->clip_rect.x
+		pipe_ctx->overscan.left += (surface->clip_rect.x
 			- stream->public.src.x) * stream->public.dst.width
 			/ stream->public.src.width;
 
-	stream->overscan.right = stream->public.timing.h_addressable
+	pipe_ctx->overscan.right = stream->public.timing.h_addressable
 		- stream->public.dst.x - stream->public.dst.width;
 	if (stream->public.src.x + stream->public.src.width
 		> surface->clip_rect.x + surface->clip_rect.width)
-		stream->overscan.right = stream->public.timing.h_addressable -
+		pipe_ctx->overscan.right = stream->public.timing.h_addressable -
 			dal_fixed31_32_floor(dal_fixed31_32_div(
 				dal_fixed31_32_from_int(
-						stream->viewport.width),
-						stream->ratios.horz)) -
-						stream->overscan.left;
+						pipe_ctx->viewport.width),
+						pipe_ctx->ratios.horz)) -
+						pipe_ctx->overscan.left;
 
 
-	stream->overscan.top = stream->public.dst.y;
+	pipe_ctx->overscan.top = stream->public.dst.y;
 	if (stream->public.src.y < surface->clip_rect.y)
-		stream->overscan.top += (surface->clip_rect.y
+		pipe_ctx->overscan.top += (surface->clip_rect.y
 			- stream->public.src.y) * stream->public.dst.height
 			/ stream->public.src.height;
 
-	stream->overscan.bottom = stream->public.timing.v_addressable
+	pipe_ctx->overscan.bottom = stream->public.timing.v_addressable
 		- stream->public.dst.y - stream->public.dst.height;
 	if (stream->public.src.y + stream->public.src.height
 		> surface->clip_rect.y + surface->clip_rect.height)
-		stream->overscan.bottom = stream->public.timing.v_addressable -
+		pipe_ctx->overscan.bottom = stream->public.timing.v_addressable -
 			dal_fixed31_32_floor(dal_fixed31_32_div(
 				dal_fixed31_32_from_int(
-						stream->viewport.height),
-						stream->ratios.vert)) -
-						stream->overscan.top;
+						pipe_ctx->viewport.height),
+						pipe_ctx->ratios.vert)) -
+						pipe_ctx->overscan.top;
 
 
 	/* TODO: Add timing overscan to finalize overscan calculation*/
@@ -307,81 +300,81 @@ static void calculate_overscan(
 
 static void calculate_scaling_ratios(
 		const struct dc_surface *surface,
-		struct core_stream *stream)
+		struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	const uint32_t in_w = stream->public.src.width;
 	const uint32_t in_h = stream->public.src.height;
 	const uint32_t out_w = stream->public.dst.width;
 	const uint32_t out_h = stream->public.dst.height;
 
-	stream->ratios.horz = dal_fixed31_32_from_fraction(
+	pipe_ctx->ratios.horz = dal_fixed31_32_from_fraction(
 					surface->src_rect.width,
 					surface->dst_rect.width);
-	stream->ratios.vert = dal_fixed31_32_from_fraction(
+	pipe_ctx->ratios.vert = dal_fixed31_32_from_fraction(
 					surface->src_rect.height,
 					surface->dst_rect.height);
 
 	if (surface->stereo_format == PLANE_STEREO_FORMAT_SIDE_BY_SIDE)
-		stream->ratios.horz.value *= 2;
+		pipe_ctx->ratios.horz.value *= 2;
 	else if (surface->stereo_format
 					== PLANE_STEREO_FORMAT_TOP_AND_BOTTOM)
-		stream->ratios.vert.value *= 2;
+		pipe_ctx->ratios.vert.value *= 2;
 
-	stream->ratios.vert.value = div64_s64(stream->ratios.vert.value * in_h,
+	pipe_ctx->ratios.vert.value = div64_s64(pipe_ctx->ratios.vert.value * in_h,
 			out_h);
-	stream->ratios.horz.value = div64_s64(stream->ratios.horz.value * in_w ,
+	pipe_ctx->ratios.horz.value = div64_s64(pipe_ctx->ratios.horz.value * in_w,
 			out_w);
 
-	stream->ratios.horz_c = stream->ratios.horz;
-	stream->ratios.vert_c = stream->ratios.vert;
+	pipe_ctx->ratios.horz_c = pipe_ctx->ratios.horz;
+	pipe_ctx->ratios.vert_c = pipe_ctx->ratios.vert;
 
-	if (stream->format == PIXEL_FORMAT_420BPP12) {
-		stream->ratios.horz_c.value /= 2;
-		stream->ratios.vert_c.value /= 2;
-	} else if (stream->format == PIXEL_FORMAT_422BPP16) {
-		stream->ratios.horz_c.value /= 2;
+	if (pipe_ctx->format == PIXEL_FORMAT_420BPP12) {
+		pipe_ctx->ratios.horz_c.value /= 2;
+		pipe_ctx->ratios.vert_c.value /= 2;
+	} else if (pipe_ctx->format == PIXEL_FORMAT_422BPP16) {
+		pipe_ctx->ratios.horz_c.value /= 2;
 	}
 }
 
-/*TODO: per pipe not per stream*/
 void build_scaling_params(
 	const struct dc_surface *surface,
-	struct core_stream *stream)
+	struct pipe_ctx *pipe_ctx)
 {
 	/* Important: scaling ratio calculation requires pixel format,
 	 * overscan calculation requires scaling ratios and viewport
 	 * and lb depth/taps calculation requires overscan. Call sequence
 	 * is therefore important */
-	stream->format = convert_pixel_format_to_dalsurface(surface->format);
+	pipe_ctx->format = convert_pixel_format_to_dalsurface(surface->format);
 
-	calculate_viewport(surface, stream);
+	calculate_viewport(surface, pipe_ctx);
 
-	calculate_scaling_ratios(surface, stream);
+	calculate_scaling_ratios(surface, pipe_ctx);
 
-	calculate_overscan(surface, stream);
+	calculate_overscan(surface, pipe_ctx);
 
 	/* Check if scaling is required update taps if not */
-	if (dal_fixed31_32_u2d19(stream->ratios.horz) == 1 << 19)
-		stream->taps.h_taps = 1;
+	if (dal_fixed31_32_u2d19(pipe_ctx->ratios.horz) == 1 << 19)
+		pipe_ctx->taps.h_taps = 1;
 	else
-		stream->taps.h_taps = surface->scaling_quality.h_taps;
+		pipe_ctx->taps.h_taps = surface->scaling_quality.h_taps;
 
-	if (dal_fixed31_32_u2d19(stream->ratios.horz_c) == 1 << 19)
-		stream->taps.h_taps_c = 1;
+	if (dal_fixed31_32_u2d19(pipe_ctx->ratios.horz_c) == 1 << 19)
+		pipe_ctx->taps.h_taps_c = 1;
 	else
-		stream->taps.h_taps_c = surface->scaling_quality.h_taps_c;
+		pipe_ctx->taps.h_taps_c = surface->scaling_quality.h_taps_c;
 
-	if (dal_fixed31_32_u2d19(stream->ratios.vert) == 1 << 19)
-		stream->taps.v_taps = 1;
+	if (dal_fixed31_32_u2d19(pipe_ctx->ratios.vert) == 1 << 19)
+		pipe_ctx->taps.v_taps = 1;
 	else
-		stream->taps.v_taps = surface->scaling_quality.v_taps;
+		pipe_ctx->taps.v_taps = surface->scaling_quality.v_taps;
 
-	if (dal_fixed31_32_u2d19(stream->ratios.vert_c) == 1 << 19)
-		stream->taps.v_taps_c = 1;
+	if (dal_fixed31_32_u2d19(pipe_ctx->ratios.vert_c) == 1 << 19)
+		pipe_ctx->taps.v_taps_c = 1;
 	else
-		stream->taps.v_taps_c = surface->scaling_quality.v_taps_c;
+		pipe_ctx->taps.v_taps_c = surface->scaling_quality.v_taps_c;
 
-	dal_logger_write(stream->ctx->logger,
+	dal_logger_write(pipe_ctx->stream->ctx->logger,
 				LOG_MAJOR_DCP,
 				LOG_MINOR_DCP_SCALER,
 				"%s: Overscan:\n bot:%d left:%d right:%d "
@@ -389,14 +382,14 @@ void build_scaling_params(
 				"y:%d\n dst_rect:\nheight:%d width:%d x:%d "
 				"y:%d\n",
 				__func__,
-				stream->overscan.bottom,
-				stream->overscan.left,
-				stream->overscan.right,
-				stream->overscan.top,
-				stream->viewport.height,
-				stream->viewport.width,
-				stream->viewport.x,
-				stream->viewport.y,
+				pipe_ctx->overscan.bottom,
+				pipe_ctx->overscan.left,
+				pipe_ctx->overscan.right,
+				pipe_ctx->overscan.top,
+				pipe_ctx->viewport.height,
+				pipe_ctx->viewport.width,
+				pipe_ctx->viewport.x,
+				pipe_ctx->viewport.y,
 				surface->dst_rect.height,
 				surface->dst_rect.width,
 				surface->dst_rect.x,
@@ -407,32 +400,25 @@ void build_scaling_params_for_context(
 	const struct dc *dc,
 	struct validate_context *context)
 {
-	uint8_t i, j, k;
-	for (i = 0; i < context->target_count; i++) {
-		struct core_target *target = context->targets[i];
-		if (context->target_flags[i].unchanged)
-			continue;
-		for (j = 0; j < target->status.surface_count; j++) {
-			const struct dc_surface *surface =
-				target->status.surfaces[j];
-			for (k = 0; k < target->public.stream_count; k++) {
-				struct core_stream *stream =
-					DC_STREAM_TO_CORE(
-						target->public.streams[k]);
-
-				build_scaling_params(surface, stream);
-			}
-		}
+	uint8_t i;
+
+	for (i = 0; i < MAX_PIPES; i++) {
+		if (context->res_ctx.pipe_ctx[i].surface != NULL &&
+				context->res_ctx.pipe_ctx[i].stream != NULL)
+			build_scaling_params(
+				&context->res_ctx.pipe_ctx[i].surface->public,
+				&context->res_ctx.pipe_ctx[i]);
 	}
 }
 
-bool logical_attach_surfaces_to_target(
+bool attach_surfaces_to_context(
 		struct dc_surface *surfaces[],
 		uint8_t surface_count,
-		struct dc_target *dc_target)
+		struct dc_target *dc_target,
+		struct validate_context *context)
 {
-	uint8_t i;
-	struct core_target *target = DC_TARGET_TO_CORE(dc_target);
+	uint8_t i, j, k;
+	struct dc_target_status *target_status = NULL;
 
 	if (surface_count > MAX_SURFACE_NUM) {
 		dm_error("Surface: can not attach %d surfaces! Maximum is: %d\n",
@@ -440,16 +426,46 @@ bool logical_attach_surfaces_to_target(
 		return false;
 	}
 
-	for (i = 0; i < target->status.surface_count; i++)
-		dc_surface_release(target->status.surfaces[i]);
+	for (i = 0; i < context->target_count; i++)
+		if (&context->targets[i]->public == dc_target) {
+			target_status = &context->target_status[i];
+			break;
+		}
+	if (target_status == NULL) {
+		dm_error("Existing target not found; failed to attach surfaces\n");
+		return false;
+	}
+
+	for (i = 0; i < target_status->surface_count; i++)
+		dc_surface_release(target_status->surfaces[i]);
 
 	for (i = 0; i < surface_count; i++) {
-		struct core_surface *surface = DC_SURFACE_TO_CORE(surfaces[i]);
-		surface->status.dc_target = &target->public;
-		target->status.surfaces[i] = surfaces[i];
-		dc_surface_retain(target->status.surfaces[i]);
+		target_status->surfaces[i] = surfaces[i];
+		dc_surface_retain(target_status->surfaces[i]);
+	}
+	target_status->surface_count = surface_count;
+
+	for (i = 0; i < dc_target->stream_count; i++) {
+		k = 0;
+		for (j = 0; j < MAX_PIPES; j++) {
+			struct core_surface *surface =
+					DC_SURFACE_TO_CORE(surfaces[k]);
+
+			if (context->res_ctx.pipe_ctx[j].stream !=
+				DC_STREAM_TO_CORE(dc_target->streams[i]))
+				continue;
+			if (k == surface_count) {
+				/* this means there are more pipes per stream
+				 * than there are planes and makes no sense
+				 */
+				BREAK_TO_DEBUGGER();
+				continue;
+			}
+
+			context->res_ctx.pipe_ctx[j].surface = surface;
+			k++;
+		}
 	}
-	target->status.surface_count = surface_count;
 
 	return true;
 }
@@ -492,13 +508,21 @@ static void fill_display_configs(
 
 		for (j = 0; j < target->public.stream_count; j++) {
 			const struct core_stream *stream =
-			DC_STREAM_TO_CORE(target->public.streams[j]);
+				DC_STREAM_TO_CORE(target->public.streams[j]);
 			struct dc_pp_single_disp_config *cfg =
 					&pp_display_cfg->disp_configs[num_cfgs];
+			const struct pipe_ctx *pipe_ctx = NULL;
+
+			for (j = 0; j < MAX_PIPES; j++)
+				if (stream ==
+					context->res_ctx.pipe_ctx[j].stream) {
+					pipe_ctx = &context->res_ctx.pipe_ctx[j];
+					break;
+				}
 
 			num_cfgs++;
-			cfg->signal = stream->signal;
-			cfg->pipe_idx = stream->opp->inst;
+			cfg->signal = pipe_ctx->signal;
+			cfg->pipe_idx = pipe_ctx->pipe_idx;
 			cfg->src_height = stream->public.src.height;
 			cfg->src_width = stream->public.src.width;
 			cfg->ddi_channel_mapping =
@@ -582,13 +606,6 @@ void pplib_apply_display_requirements(
 /* Maximum TMDS single link pixel clock 165MHz */
 #define TMDS_MAX_PIXEL_CLOCK_IN_KHZ 165000
 
-static void attach_stream_to_controller(
-		struct resource_context *res_ctx,
-		struct core_stream *stream)
-{
-	res_ctx->controller_ctx[stream->controller_idx].stream = stream;
-}
-
 static void set_stream_engine_in_use(
 		struct resource_context *res_ctx,
 		struct stream_encoder *stream_enc)
@@ -614,24 +631,28 @@ static void set_audio_in_use(
 	}
 }
 
-static bool assign_first_free_controller(
+static int8_t acquire_first_free_pipe(
 		struct resource_context *res_ctx,
 		struct core_stream *stream)
 {
 	uint8_t i;
-	for (i = 0; i < res_ctx->pool.controller_count; i++) {
-		if (!res_ctx->controller_ctx[i].stream) {
-			stream->tg = res_ctx->pool.timing_generators[i];
-			stream->mi = res_ctx->pool.mis[i];
-			stream->ipp = res_ctx->pool.ipps[i];
-			stream->xfm = res_ctx->pool.transforms[i];
-			stream->opp = res_ctx->pool.opps[i];
-			stream->controller_idx = i;
-			stream->dis_clk = res_ctx->pool.display_clock;
-			return true;
+	for (i = 0; i < res_ctx->pool.pipe_count; i++) {
+		if (!res_ctx->pipe_ctx[i].stream) {
+			struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
+
+			pipe_ctx->tg = res_ctx->pool.timing_generators[i];
+			pipe_ctx->mi = res_ctx->pool.mis[i];
+			pipe_ctx->ipp = res_ctx->pool.ipps[i];
+			pipe_ctx->xfm = res_ctx->pool.transforms[i];
+			pipe_ctx->opp = res_ctx->pool.opps[i];
+			pipe_ctx->dis_clk = res_ctx->pool.display_clock;
+			pipe_ctx->pipe_idx = i;
+
+			pipe_ctx->stream = stream;
+			return i;
 		}
 	}
-	return false;
+	return -1;
 }
 
 static struct stream_encoder *find_first_free_match_stream_enc_for_link(
@@ -704,9 +725,10 @@ static bool check_timing_change(struct core_stream *cur_stream,
 					&new_stream->public.timing);
 }
 
-static void set_stream_signal(struct core_stream *stream)
+static void set_stream_signal(struct pipe_ctx *pipe_ctx)
 {
-	struct dc_sink *dc_sink = (struct dc_sink *)stream->public.sink;
+	struct dc_sink *dc_sink =
+		(struct dc_sink *) pipe_ctx->stream->public.sink;
 
 	/* For asic supports dual link DVI, we should adjust signal type
 	 * based on timing pixel clock. If pixel clock more than 165Mhz,
@@ -714,21 +736,21 @@ static void set_stream_signal(struct core_stream *stream)
 	 */
 	if (dc_sink->sink_signal == SIGNAL_TYPE_DVI_SINGLE_LINK ||
 			dc_sink->sink_signal == SIGNAL_TYPE_DVI_DUAL_LINK) {
-		if (stream->public.timing.pix_clk_khz >
-			TMDS_MAX_PIXEL_CLOCK_IN_KHZ)
+		if (pipe_ctx->stream->public.timing.pix_clk_khz >
+						TMDS_MAX_PIXEL_CLOCK_IN_KHZ)
 			dc_sink->sink_signal = SIGNAL_TYPE_DVI_DUAL_LINK;
 		else
 			dc_sink->sink_signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
 	}
 
-	stream->signal = dc_sink->sink_signal;
+	pipe_ctx->signal = dc_sink->sink_signal;
 }
 
 enum dc_status map_resources(
 		const struct dc *dc,
 		struct validate_context *context)
 {
-	uint8_t i, j;
+	uint8_t i, j, k;
 
 	/* mark resources used for targets that are already active */
 	for (i = 0; i < context->target_count; i++) {
@@ -741,21 +763,29 @@ enum dc_status map_resources(
 			struct core_stream *stream =
 				DC_STREAM_TO_CORE(target->public.streams[j]);
 
-			attach_stream_to_controller(
-				&context->res_ctx,
-				stream);
+			for (k = 0; k < MAX_PIPES; k++) {
+				struct pipe_ctx *pipe_ctx =
+					&context->res_ctx.pipe_ctx[k];
 
-			set_stream_engine_in_use(
-				&context->res_ctx,
-				stream->stream_enc);
+				if (dc->current_context.res_ctx.pipe_ctx[k].stream
+					!= stream)
+					continue;
 
-			reference_clock_source(
-				&context->res_ctx,
-				stream->clock_source);
+				*pipe_ctx =
+					dc->current_context.res_ctx.pipe_ctx[k];
+				pipe_ctx->flags.timing_changed = false;
+				pipe_ctx->flags.unchanged = true;
+
+				set_stream_engine_in_use(
+					&context->res_ctx,
+					pipe_ctx->stream_enc);
+
+				reference_clock_source(
+					&context->res_ctx,
+					pipe_ctx->clock_source);
 
-			if (stream->audio) {
 				set_audio_in_use(&context->res_ctx,
-					stream->audio);
+					pipe_ctx->audio);
 			}
 		}
 	}
@@ -768,49 +798,48 @@ enum dc_status map_resources(
 			continue;
 
 		for (j = 0; j < target->public.stream_count; j++) {
+			struct pipe_ctx *pipe_ctx = NULL;
 			struct core_stream *stream =
 				DC_STREAM_TO_CORE(target->public.streams[j]);
 			struct core_stream *curr_stream;
 
-			if (!assign_first_free_controller(
-					&context->res_ctx, stream))
+			int8_t pipe_idx = acquire_first_free_pipe(
+						&context->res_ctx, stream);
+			if (pipe_idx < 0)
 				return DC_NO_CONTROLLER_RESOURCE;
 
-			attach_stream_to_controller(&context->res_ctx, stream);
-
-			set_stream_signal(stream);
+			pipe_ctx = &context->res_ctx.pipe_ctx[pipe_idx];
+			set_stream_signal(pipe_ctx);
 
 			curr_stream =
-				dc->current_context.res_ctx.controller_ctx
-				[stream->controller_idx].stream;
-			context->res_ctx.controller_ctx[stream->controller_idx]
-			.flags.timing_changed =
+				dc->current_context.res_ctx.pipe_ctx[pipe_idx].stream;
+			context->res_ctx.pipe_ctx[pipe_idx].flags.timing_changed =
 				check_timing_change(curr_stream, stream);
 
-			stream->stream_enc =
+			pipe_ctx->stream_enc =
 				find_first_free_match_stream_enc_for_link(
 					&context->res_ctx,
 					stream->sink->link);
 
-			if (!stream->stream_enc)
+			if (!pipe_ctx->stream_enc)
 				return DC_NO_STREAM_ENG_RESOURCE;
 
 			set_stream_engine_in_use(
 					&context->res_ctx,
-					stream->stream_enc);
+					pipe_ctx->stream_enc);
 
 			/* TODO: Add check if ASIC support and EDID audio */
 			if (!stream->sink->converter_disable_audio &&
 						dc_is_audio_capable_signal(
-						stream->signal)) {
-				stream->audio = find_first_free_audio(
+						pipe_ctx->signal)) {
+				pipe_ctx->audio = find_first_free_audio(
 						&context->res_ctx);
 
-				if (!stream->audio)
+				if (!pipe_ctx->audio)
 					return DC_NO_STREAM_AUDIO_RESOURCE;
 
 				set_audio_in_use(&context->res_ctx,
-						stream->audio);
+						pipe_ctx->audio);
 			}
 		}
 	}
@@ -819,13 +848,13 @@ enum dc_status map_resources(
 }
 
 static enum ds_color_space build_default_color_space(
-		struct core_stream *stream)
+		struct pipe_ctx *pipe_ctx)
 {
 	enum ds_color_space color_space =
 			DS_COLOR_SPACE_SRGB_FULLRANGE;
-	struct dc_crtc_timing *timing = &stream->public.timing;
+	struct dc_crtc_timing *timing = &pipe_ctx->stream->public.timing;
 
-	switch (stream->signal) {
+	switch (pipe_ctx->signal) {
 	/* TODO: implement other signal color space setting */
 	case SIGNAL_TYPE_DISPLAY_PORT:
 	case SIGNAL_TYPE_DISPLAY_PORT_MST:
@@ -934,9 +963,11 @@ static void translate_info_frame(const struct hw_info_frame *hw_info_frame,
 	}
 }
 
-static void set_avi_info_frame(struct hw_info_packet *info_packet,
-		struct core_stream *stream)
+static void set_avi_info_frame(
+	struct hw_info_packet *info_packet,
+		struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	enum ds_color_space color_space = DS_COLOR_SPACE_UNKNOWN;
 	struct info_frame info_frame = { {0} };
 	uint32_t pixel_encoding = 0;
@@ -950,7 +981,7 @@ static void set_avi_info_frame(struct hw_info_packet *info_packet,
 	if (info_packet == NULL)
 		return;
 
-	color_space = build_default_color_space(stream);
+	color_space = build_default_color_space(pipe_ctx);
 
 	/* Initialize header */
 	info_frame.avi_info_packet.info_packet_hdmi.bits.header.
@@ -1223,7 +1254,7 @@ static void set_vendor_info_packet(struct core_stream *stream,
 	info_packet->valid = true;
 }
 
-void build_info_frame(struct core_stream *stream)
+void build_info_frame(struct pipe_ctx *pipe_ctx)
 {
 	enum signal_type signal = SIGNAL_TYPE_NONE;
 	struct hw_info_frame info_frame = { { 0 } };
@@ -1235,15 +1266,16 @@ void build_info_frame(struct core_stream *stream)
 	info_frame.spd_packet.valid = false;
 	info_frame.vsc_packet.valid = false;
 
-	signal = stream->sink->public.sink_signal;
+	signal = pipe_ctx->stream->sink->public.sink_signal;
 
 	/* HDMi and DP have different info packets*/
 	if (signal == SIGNAL_TYPE_HDMI_TYPE_A) {
-		set_avi_info_frame(&info_frame.avi_info_packet,
-				stream);
-		set_vendor_info_packet(stream, &info_frame.vendor_info_packet);
+		set_avi_info_frame(
+			&info_frame.avi_info_packet, pipe_ctx);
+		set_vendor_info_packet(
+			pipe_ctx->stream, &info_frame.vendor_info_packet);
 	}
 
 	translate_info_frame(&info_frame,
-			&stream->encoder_info_frame);
+			&pipe_ctx->encoder_info_frame);
 }
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc_target.c b/drivers/gpu/drm/amd/dal/dc/core/dc_target.c
index e8579bc..f00b5af 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc_target.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc_target.c
@@ -65,12 +65,20 @@ static void construct(
 
 static void destruct(struct core_target *core_target)
 {
-	int i;
+	int i, j;
+	struct validate_context *context =
+				&core_target->ctx->dc->current_context;
 
-	for (i = 0; i < core_target->status.surface_count; i++) {
-		dc_surface_release(core_target->status.surfaces[i]);
-		core_target->status.surfaces[i] = NULL;
+	for (i = 0; i < context->target_count; i++) {
+		if (context->targets[i] != core_target)
+			continue;
+		for (j = 0; j < context->target_status[i].surface_count; j++)
+			dc_surface_release(
+				context->target_status[i].surfaces[j]);
+		context->target_status[i].surface_count = 0;
+		break;
 	}
+
 	for (i = 0; i < core_target->public.stream_count; i++) {
 		dc_stream_release(
 			(struct dc_stream *)core_target->public.streams[i]);
@@ -101,8 +109,15 @@ void dc_target_release(struct dc_target *dc_target)
 const struct dc_target_status *dc_target_get_status(
 					const struct dc_target* dc_target)
 {
+	uint8_t i;
 	struct core_target* target = DC_TARGET_TO_CORE(dc_target);
-	return &target->status;
+	struct dc *dc = target->ctx->dc;
+
+	for (i = 0; i < dc->current_context.target_count; i++)
+		if (target == dc->current_context.targets[i])
+			return &dc->current_context.target_status[i];
+
+	return NULL;
 }
 
 struct dc_target *dc_create_target_for_streams(
@@ -169,26 +184,28 @@ bool dc_commit_surfaces_to_target(
 	int i, j;
 	uint32_t prev_disp_clk = dc->current_context.bw_results.dispclk_khz;
 	struct core_target *target = DC_TARGET_TO_CORE(dc_target);
-
+	struct dc_target_status *status = NULL;
+	struct validate_context *context;
 	int current_enabled_surface_count = 0;
 	int new_enabled_surface_count = 0;
 
-	if (!dal_adapter_service_is_in_accelerated_mode(
-						dc->res_pool.adapter_srv) ||
-			dc->current_context.target_count == 0) {
-		return false;
-	}
-
-	for (i = 0; i < dc->current_context.target_count; i++)
-		if (target == dc->current_context.targets[i])
-			break;
+	context = dm_alloc(dc->ctx, sizeof(struct validate_context));
+	*context = dc->current_context;
 
 	/* Cannot commit surface to a target that is not commited */
-	if (i == dc->current_context.target_count)
-		return false;
+	for (i = 0; i < context->target_count; i++)
+		if (target == context->targets[i])
+			break;
+	status = &context->target_status[i];
+	if (!dal_adapter_service_is_in_accelerated_mode(
+						dc->res_pool.adapter_srv)
+		|| i == context->target_count) {
+		BREAK_TO_DEBUGGER();
+		goto unexpected_fail;
+	}
 
-	for (i = 0; i < target->status.surface_count; i++)
-		if (target->status.surfaces[i]->visible)
+	for (i = 0; i < status->surface_count; i++)
+		if (status->surfaces[i]->visible)
 			current_enabled_surface_count++;
 
 	for (i = 0; i < new_surface_count; i++)
@@ -204,83 +221,100 @@ bool dc_commit_surfaces_to_target(
 				dc_target);
 
 
-	if (!logical_attach_surfaces_to_target(
-						new_surfaces,
-						new_surface_count,
-						dc_target)) {
+	if (!attach_surfaces_to_context(
+			new_surfaces, new_surface_count, dc_target, context)) {
 		BREAK_TO_DEBUGGER();
 		goto unexpected_fail;
 	}
 
 	for (i = 0; i < new_surface_count; i++)
-		for (j = 0; j < target->public.stream_count; j++)
+		for (j = 0; j < MAX_PIPES; j++) {
+			if (context->res_ctx.pipe_ctx[j].surface !=
+					DC_SURFACE_TO_CORE(new_surfaces[i]))
+				continue;
+
 			build_scaling_params(
-				new_surfaces[i],
-				DC_STREAM_TO_CORE(target->public.streams[j]));
+				new_surfaces[i], &context->res_ctx.pipe_ctx[j]);
+		}
 
-	if (dc->res_pool.funcs->validate_bandwidth(dc, &dc->current_context)
-								!= DC_OK) {
+	if (dc->res_pool.funcs->validate_bandwidth(dc, context) != DC_OK) {
 		BREAK_TO_DEBUGGER();
 		goto unexpected_fail;
 	}
 
-	if (prev_disp_clk < dc->current_context.bw_results.dispclk_khz) {
-		dc->hwss.program_bw(dc, &dc->current_context);
-		pplib_apply_display_requirements(dc, &dc->current_context,
-				&dc->current_context.pp_display_cfg);
+	if (prev_disp_clk < context->bw_results.dispclk_khz) {
+		dc->hwss.program_bw(dc, context);
+		pplib_apply_display_requirements(dc, context,
+						&context->pp_display_cfg);
 	}
 
 	if (current_enabled_surface_count > 0 && new_enabled_surface_count == 0)
 		dc_target_disable_memory_requests(dc_target);
 
-	for (i = 0; i < new_surface_count; i++) {
-		struct dc_surface *surface = new_surfaces[i];
-		struct core_surface *core_surface = DC_SURFACE_TO_CORE(surface);
-		struct core_stream *stream =
-				DC_STREAM_TO_CORE(target->public.streams[0]);
-		bool is_valid_address =
-				validate_surface_address(surface->address);
-
-
-		dal_logger_write(dc->ctx->logger,
-					LOG_MAJOR_INTERFACE_TRACE,
-					LOG_MINOR_COMPONENT_DC,
-					"0x%x:",
-					surface);
-
-		if (surface->gamma_correction) {
-			struct core_gamma *gamma = DC_GAMMA_TO_CORE(
-						surface->gamma_correction);
-
-			dc->hwss.set_gamma_correction(
-					stream->ipp,
-					stream->opp,
-					gamma, core_surface);
+	for (i = 0; i < new_surface_count; i++)
+		for (j = 0; j < MAX_PIPES; j++) {
+			struct dc_surface *dc_surface = new_surfaces[i];
+			struct core_surface *surface =
+						DC_SURFACE_TO_CORE(dc_surface);
+			struct pipe_ctx *pipe_ctx =
+						&context->res_ctx.pipe_ctx[j];
+
+			if (pipe_ctx->surface !=
+					DC_SURFACE_TO_CORE(new_surfaces[i]))
+				continue;
+
+			dal_logger_write(dc->ctx->logger,
+						LOG_MAJOR_INTERFACE_TRACE,
+						LOG_MINOR_COMPONENT_DC,
+						"Pipe:%d 0x%x: src: %d, %d, %d,"
+						" %d; dst: %d, %d, %d, %d;\n",
+						pipe_ctx->pipe_idx,
+						dc_surface,
+						dc_surface->src_rect.x,
+						dc_surface->src_rect.y,
+						dc_surface->src_rect.width,
+						dc_surface->src_rect.height,
+						dc_surface->dst_rect.x,
+						dc_surface->dst_rect.y,
+						dc_surface->dst_rect.width,
+						dc_surface->dst_rect.height);
+
+			if (dc_surface->gamma_correction) {
+				struct core_gamma *gamma = DC_GAMMA_TO_CORE(
+						dc_surface->gamma_correction);
+
+				dc->hwss.set_gamma_correction(
+							pipe_ctx->ipp,
+							pipe_ctx->opp,
+							gamma, surface);
+			}
+
+			dc->hwss.set_plane_config(dc, surface, pipe_ctx);
+
+			if (validate_surface_address(dc_surface->address))
+				dc->hwss.update_plane_addrs(
+					dc, &context->res_ctx, surface);
 		}
 
-		dc->hwss.set_plane_config(dc, core_surface, target);
-
-		if (is_valid_address)
-			dc->hwss.update_plane_address(dc, core_surface, target);
-	}
-
 	if (current_enabled_surface_count == 0 && new_enabled_surface_count > 0)
 		dc_target_enable_memory_requests(dc_target);
 
 	/* Lower display clock if necessary */
-	if (prev_disp_clk > dc->current_context.bw_results.dispclk_khz) {
-		dc->hwss.program_bw(dc, &dc->current_context);
-		pplib_apply_display_requirements(dc, &dc->current_context,
-				&dc->current_context.pp_display_cfg);
+	if (prev_disp_clk > context->bw_results.dispclk_khz) {
+		dc->hwss.program_bw(dc, context);
+		pplib_apply_display_requirements(dc, context,
+						&context->pp_display_cfg);
 	}
 
+	dc->current_context = *context;
+	dm_free(dc->ctx, context);
 	return true;
 
 unexpected_fail:
 	for (i = 0; i < new_surface_count; i++) {
-		target->status.surfaces[i] = NULL;
+		status->surfaces[i] = NULL;
 	}
-	target->status.surface_count = 0;
+	status->surface_count = 0;
 
 	return false;
 }
@@ -298,38 +332,48 @@ bool dc_target_is_connected_to_sink(
 	return false;
 }
 
-void dc_target_enable_memory_requests(struct dc_target *target)
+void dc_target_enable_memory_requests(struct dc_target *dc_target)
 {
-	uint8_t i;
-	struct core_target *core_target = DC_TARGET_TO_CORE(target);
-	for (i = 0; i < core_target->public.stream_count; i++) {
-		struct timing_generator *tg =
-			DC_STREAM_TO_CORE(core_target->public.streams[i])->tg;
+	uint8_t i, j;
+	struct core_target *target = DC_TARGET_TO_CORE(dc_target);
+	struct resource_context *res_ctx =
+		&target->ctx->dc->current_context.res_ctx;
+
+	for (i = 0; i < target->public.stream_count; i++) {
+		for (j = 0; j < MAX_PIPES; j++) {
+			struct timing_generator *tg = res_ctx->pipe_ctx[j].tg;
+
+			if (res_ctx->pipe_ctx[j].stream !=
+				DC_STREAM_TO_CORE(target->public.streams[i]))
+				continue;
 
-		if (!tg->funcs->set_blank(tg, false)) {
-			dm_error("DC: failed to unblank crtc!\n");
-			BREAK_TO_DEBUGGER();
+			if (!tg->funcs->set_blank(tg, false)) {
+				dm_error("DC: failed to unblank crtc!\n");
+				BREAK_TO_DEBUGGER();
+			}
 		}
 	}
 }
 
-void dc_target_disable_memory_requests(struct dc_target *target)
+void dc_target_disable_memory_requests(struct dc_target *dc_target)
 {
-	uint8_t i;
-	struct core_target *core_target = DC_TARGET_TO_CORE(target);
-	for (i = 0; i < core_target->public.stream_count; i++) {
-	struct timing_generator *tg =
-		DC_STREAM_TO_CORE(core_target->public.streams[i])->tg;
+	uint8_t i, j;
+	struct core_target *target = DC_TARGET_TO_CORE(dc_target);
+	struct resource_context *res_ctx =
+		&target->ctx->dc->current_context.res_ctx;
 
-		if (NULL == tg) {
-			dm_error("DC: timing generator is NULL!\n");
-			BREAK_TO_DEBUGGER();
-			continue;
-		}
+	for (i = 0; i < target->public.stream_count; i++) {
+		for (j = 0; j < MAX_PIPES; j++) {
+			struct timing_generator *tg = res_ctx->pipe_ctx[j].tg;
+
+			if (res_ctx->pipe_ctx[j].stream !=
+				DC_STREAM_TO_CORE(target->public.streams[i]))
+				continue;
 
-		if (false == tg->funcs->set_blank(tg, true)) {
-			dm_error("DC: failed to blank crtc!\n");
-			BREAK_TO_DEBUGGER();
+			if (!tg->funcs->set_blank(tg, true)) {
+				dm_error("DC: failed to blank crtc!\n");
+				BREAK_TO_DEBUGGER();
+			}
 		}
 	}
 }
@@ -341,25 +385,42 @@ bool dc_target_set_cursor_attributes(
 	struct dc_target *dc_target,
 	const struct dc_cursor_attributes *attributes)
 {
-	struct core_target *core_target;
-	struct input_pixel_processor *ipp;
+	uint8_t i, j;
+	struct core_target *target;
+	struct resource_context *res_ctx;
 
 	if (NULL == dc_target) {
 		dm_error("DC: dc_target is NULL!\n");
 			return false;
 
 	}
+	if (NULL == attributes) {
+		dm_error("DC: attributes is NULL!\n");
+			return false;
 
-	core_target = DC_TARGET_TO_CORE(dc_target);
-	ipp = DC_STREAM_TO_CORE(core_target->public.streams[0])->ipp;
-
-	if (NULL == ipp) {
-		dm_error("DC: input pixel processor is NULL!\n");
-		return false;
 	}
 
-	if (true == ipp->funcs->ipp_cursor_set_attributes(ipp, attributes))
-		return true;
+	target = DC_TARGET_TO_CORE(dc_target);
+	res_ctx = &target->ctx->dc->current_context.res_ctx;
+
+	for (i = 0; i < target->public.stream_count; i++) {
+		for (j = 0; j < MAX_PIPES; j++) {
+			struct input_pixel_processor *ipp =
+						res_ctx->pipe_ctx[j].ipp;
+
+			if (res_ctx->pipe_ctx[j].stream !=
+				DC_STREAM_TO_CORE(target->public.streams[i]))
+				continue;
+
+			/* As of writing of this code cursor is on the top
+			 * plane so we only need to set it on first pipe we
+			 * find. May need to make this code dce specific later.
+			 */
+			if (ipp->funcs->ipp_cursor_set_attributes(
+							ipp, attributes))
+				return true;
+		}
+	}
 
 	return false;
 }
@@ -368,8 +429,9 @@ bool dc_target_set_cursor_position(
 	struct dc_target *dc_target,
 	const struct dc_cursor_position *position)
 {
-	struct core_target *core_target;
-	struct input_pixel_processor *ipp;
+	uint8_t i, j;
+	struct core_target *target;
+	struct resource_context *res_ctx;
 
 	if (NULL == dc_target) {
 		dm_error("DC: dc_target is NULL!\n");
@@ -381,62 +443,67 @@ bool dc_target_set_cursor_position(
 		return false;
 	}
 
-	core_target = DC_TARGET_TO_CORE(dc_target);
-	ipp = DC_STREAM_TO_CORE(core_target->public.streams[0])->ipp;
+	target = DC_TARGET_TO_CORE(dc_target);
+	res_ctx = &target->ctx->dc->current_context.res_ctx;
 
-	if (NULL == ipp) {
-		dm_error("DC: input pixel processor is NULL!\n");
-		return false;
+	for (i = 0; i < target->public.stream_count; i++) {
+		for (j = 0; j < MAX_PIPES; j++) {
+			struct input_pixel_processor *ipp =
+						res_ctx->pipe_ctx[j].ipp;
+
+			if (res_ctx->pipe_ctx[j].stream !=
+				DC_STREAM_TO_CORE(target->public.streams[i]))
+				continue;
+
+			/* As of writing of this code cursor is on the top
+			 * plane so we only need to set it on first pipe we
+			 * find. May need to make this code dce specific later.
+			 */
+			if (ipp->funcs->ipp_cursor_set_position(ipp, position))
+				return true;
+		}
 	}
 
-
-	if (true == ipp->funcs->ipp_cursor_set_position(ipp, position))
-		return true;
-
 	return false;
 }
 
-/* TODO: #flip temporary to make flip work */
-uint8_t dc_target_get_link_index(const struct dc_target *dc_target)
+uint32_t dc_target_get_vblank_counter(const struct dc_target *dc_target)
 {
-	const struct core_target *target = CONST_DC_TARGET_TO_CORE(dc_target);
-	const struct core_sink *sink =
-		DC_SINK_TO_CORE(target->public.streams[0]->sink);
+	uint8_t i, j;
+	struct core_target *target = DC_TARGET_TO_CORE(dc_target);
+	struct resource_context *res_ctx =
+		&target->ctx->dc->current_context.res_ctx;
 
-	return sink->link->public.link_index;
-}
+	for (i = 0; i < target->public.stream_count; i++) {
+		for (j = 0; j < MAX_PIPES; j++) {
+			struct timing_generator *tg = res_ctx->pipe_ctx[j].tg;
 
-uint32_t dc_target_get_vblank_counter(const struct dc_target *dc_target)
-{
-	struct core_target *core_target = DC_TARGET_TO_CORE(dc_target);
-	struct timing_generator *tg =
-		DC_STREAM_TO_CORE(core_target->public.streams[0])->tg;
+			if (res_ctx->pipe_ctx[j].stream !=
+				DC_STREAM_TO_CORE(target->public.streams[i]))
+				continue;
 
-	return tg->funcs->get_frame_count(tg);
+			return tg->funcs->get_frame_count(tg);
+		}
+	}
+
+	return 0;
 }
 
 enum dc_irq_source dc_target_get_irq_src(
-	const struct dc_target *dc_target, const enum irq_type irq_type)
+	const struct dc *dc,
+	const struct dc_target *dc_target,
+	const enum irq_type irq_type)
 {
+	uint8_t i;
 	struct core_target *core_target = DC_TARGET_TO_CORE(dc_target);
-
-	/* #TODO - Remove the assumption that the controller is always in the
-	 * first stream of a core target */
 	struct core_stream *stream =
-		DC_STREAM_TO_CORE(core_target->public.streams[0]);
-	uint8_t controller_idx = stream->controller_idx;
-
-	/* Get controller id */
-	enum controller_id crtc_id = controller_idx + 1;
-
-	/* Calculate controller offset */
-	unsigned int offset = crtc_id - CONTROLLER_ID_D0;
-	unsigned int base = irq_type;
+			DC_STREAM_TO_CORE(core_target->public.streams[0]);
 
-	/* Calculate irq source */
-	enum dc_irq_source src = base + offset;
+	for (i = 0; i < MAX_PIPES; i++)
+		if (dc->current_context.res_ctx.pipe_ctx[i].stream == stream)
+			return irq_type + i;
 
-	return src;
+	return irq_type;
 }
 
 void dc_target_log(
@@ -453,9 +520,8 @@ void dc_target_log(
 	dal_logger_write(dal_logger,
 			log_major,
 			log_minor,
-			"core_target 0x%x: surface_count=%d, stream_count=%d\n",
+			"core_target 0x%x: stream_count=%d\n",
 			core_target,
-			core_target->status.surface_count,
 			core_target->public.stream_count);
 
 	for (i = 0; i < core_target->public.stream_count; i++) {
diff --git a/drivers/gpu/drm/amd/dal/dc/dc.h b/drivers/gpu/drm/amd/dal/dc/dc.h
index 901c8c4..9cd239c 100644
--- a/drivers/gpu/drm/amd/dal/dc/dc.h
+++ b/drivers/gpu/drm/amd/dal/dc/dc.h
@@ -108,7 +108,7 @@ struct dc_surface {
 
 	union plane_size plane_size;
 	struct dc_tiling_info tiling_info;
-	struct plane_colorimetry colorimetry;
+	enum color_space color_space;
 
 	enum surface_pixel_format format;
 	enum dc_rotation_angle rotation;
@@ -125,7 +125,6 @@ struct dc_surface {
 struct dc_surface_status {
 	struct dc_plane_address requested_address;
 	struct dc_plane_address current_address;
-	const struct dc_target *dc_target;
 };
 
 /*
@@ -228,12 +227,13 @@ bool dc_target_is_connected_to_sink(
 		const struct dc_target *dc_target,
 		const struct dc_sink *dc_sink);
 
-uint8_t dc_target_get_link_index(const struct dc_target *dc_target);
 uint8_t dc_target_get_controller_id(const struct dc_target *dc_target);
 
 uint32_t dc_target_get_vblank_counter(const struct dc_target *dc_target);
 enum dc_irq_source dc_target_get_irq_src(
-	const struct dc_target *dc_target, const enum irq_type irq_type);
+	const struct dc *dc,
+	const struct dc_target *dc_target,
+	const enum irq_type irq_type);
 
 void dc_target_enable_memory_requests(struct dc_target *target);
 void dc_target_disable_memory_requests(struct dc_target *target);
diff --git a/drivers/gpu/drm/amd/dal/dc/dc_types.h b/drivers/gpu/drm/amd/dal/dc/dc_types.h
index 5593c17..863443b 100644
--- a/drivers/gpu/drm/amd/dal/dc/dc_types.h
+++ b/drivers/gpu/drm/amd/dal/dc/dc_types.h
@@ -67,13 +67,17 @@ enum dce_environment {
 #define MAX_SURFACE_NUM 2
 #define NUM_PIXEL_FORMATS 10
 
-enum surface_color_space {
-	SURFACE_COLOR_SPACE_SRGB = 0x0000,
-	SURFACE_COLOR_SPACE_BT601 = 0x0001,
-	SURFACE_COLOR_SPACE_BT709 = 0x0002,
-	SURFACE_COLOR_SPACE_XVYCC_BT601 = 0x0004,
-	SURFACE_COLOR_SPACE_XVYCC_BT709 = 0x0008,
-	SURFACE_COLOR_SPACE_XRRGB = 0x0010
+enum color_space {
+	COLOR_SPACE_UNKNOWN,
+	COLOR_SPACE_SRGB_FULL_RANGE,
+	COLOR_SPACE_SRGB_LIMITED_RANGE,
+	COLOR_SPACE_YPBPR601,
+	COLOR_SPACE_YPBPR709,
+	COLOR_SPACE_YCBCR601,
+	COLOR_SPACE_YCBCR709,
+	COLOR_SPACE_YCBCR601_YONLY,
+	COLOR_SPACE_YCBCR709_YONLY,
+	COLOR_SPACE_N_MVPU_SUPER_AA,
 };
 
 
@@ -170,11 +174,6 @@ enum dc_edid_status {
 	EDID_BAD_CHECKSUM,
 };
 
-struct plane_colorimetry {
-	enum surface_color_space color_space;
-	bool limited_range;
-};
-
 /* audio capability from EDID*/
 struct dc_cea_audio_mode {
 	uint8_t format_code; /* ucData[0] [6:3]*/
diff --git a/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c
index 783d47e..efa592f 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce100/dce100_resource.c
@@ -530,7 +530,7 @@ void dce100_destruct_resource_pool(struct resource_pool *pool)
 {
 	unsigned int i;
 
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		if (pool->opps[i] != NULL)
 			dce100_opp_destroy(&pool->opps[i]);
 
@@ -615,12 +615,13 @@ static enum audio_dto_source translate_to_dto_source(enum controller_id crtc_id)
 }
 
 static void build_audio_output(
-	const struct core_stream *stream,
+	const struct pipe_ctx *pipe_ctx,
 	struct audio_output *audio_output)
 {
-	audio_output->engine_id = stream->stream_enc->id;
+	const struct core_stream *stream = pipe_ctx->stream;
+	audio_output->engine_id = pipe_ctx->stream_enc->id;
 
-	audio_output->signal = stream->signal;
+	audio_output->signal = pipe_ctx->signal;
 
 	/* audio_crtc_info  */
 
@@ -654,44 +655,45 @@ static void build_audio_output(
 		stream->public.timing.display_color_depth;
 
 	audio_output->crtc_info.requested_pixel_clock =
-			stream->pix_clk_params.requested_pix_clk;
+			pipe_ctx->pix_clk_params.requested_pix_clk;
 
 	/*
 	 * TODO - Investigate why calculated pixel clk has to be
 	 * requested pixel clk
 	 */
 	audio_output->crtc_info.calculated_pixel_clock =
-			stream->pix_clk_params.requested_pix_clk;
+			pipe_ctx->pix_clk_params.requested_pix_clk;
 
-	if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT ||
-			stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
+	if (pipe_ctx->signal == SIGNAL_TYPE_DISPLAY_PORT ||
+			pipe_ctx->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
 		audio_output->pll_info.dp_dto_source_clock_in_khz =
 			dal_display_clock_get_dp_ref_clk_frequency(
-				stream->dis_clk);
+				pipe_ctx->dis_clk);
 	}
 
 	audio_output->pll_info.feed_back_divider =
-			stream->pll_settings.feedback_divider;
+			pipe_ctx->pll_settings.feedback_divider;
 
 	audio_output->pll_info.dto_source =
 		translate_to_dto_source(
-			stream->controller_idx + 1);
+			pipe_ctx->pipe_idx + 1);
 
 	/* TODO hard code to enable for now. Need get from stream */
 	audio_output->pll_info.ss_enabled = true;
 
 	audio_output->pll_info.ss_percentage =
-			stream->pll_settings.ss_percentage;
+			pipe_ctx->pll_settings.ss_percentage;
 }
 
 static void get_pixel_clock_parameters(
-	const struct core_stream *stream,
+	const struct pipe_ctx *pipe_ctx,
 	struct pixel_clk_params *pixel_clk_params)
 {
+	const struct core_stream *stream = pipe_ctx->stream;
 	pixel_clk_params->requested_pix_clk = stream->public.timing.pix_clk_khz;
 	pixel_clk_params->encoder_object_id = stream->sink->link->link_enc->id;
 	pixel_clk_params->signal_type = stream->sink->public.sink_signal;
-	pixel_clk_params->controller_id = stream->controller_idx + 1;
+	pixel_clk_params->controller_id = pipe_ctx->pipe_idx + 1;
 	/* TODO: un-hardcode*/
 	pixel_clk_params->requested_sym_clk = LINK_RATE_LOW *
 		LINK_RATE_REF_FREQ_IN_KHZ;
@@ -701,20 +703,20 @@ static void get_pixel_clock_parameters(
 	pixel_clk_params->flags.DISPLAY_BLANKED = 1;
 }
 
-static enum dc_status build_stream_hw_param(struct core_stream *stream)
+static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 {
 	/*TODO: unhardcode*/
-	stream->max_tmds_clk_from_edid_in_mhz = 0;
-	stream->max_hdmi_deep_color = COLOR_DEPTH_121212;
-	stream->max_hdmi_pixel_clock = 600000;
+	pipe_ctx->max_tmds_clk_from_edid_in_mhz = 0;
+	pipe_ctx->max_hdmi_deep_color = COLOR_DEPTH_121212;
+	pipe_ctx->max_hdmi_pixel_clock = 600000;
 
-	get_pixel_clock_parameters(stream, &stream->pix_clk_params);
-	stream->clock_source->funcs->get_pix_clk_dividers(
-		stream->clock_source,
-		&stream->pix_clk_params,
-		&stream->pll_settings);
+	get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->pix_clk_params);
+	pipe_ctx->clock_source->funcs->get_pix_clk_dividers(
+		pipe_ctx->clock_source,
+		&pipe_ctx->pix_clk_params,
+		&pipe_ctx->pll_settings);
 
-	build_audio_output(stream, &stream->audio_output);
+	build_audio_output(pipe_ctx, &pipe_ctx->audio_output);
 
 	return DC_OK;
 }
@@ -724,7 +726,7 @@ static enum dc_status validate_mapped_resource(
 		struct validate_context *context)
 {
 	enum dc_status status = DC_OK;
-	uint8_t i, j;
+	uint8_t i, j, k;
 
 	for (i = 0; i < context->target_count; i++) {
 		struct core_target *target = context->targets[i];
@@ -736,33 +738,44 @@ static enum dc_status validate_mapped_resource(
 				DC_STREAM_TO_CORE(target->public.streams[j]);
 			struct core_link *link = stream->sink->link;
 
-			if (!stream->tg->funcs->validate_timing(
-					stream->tg, &stream->public.timing))
-				return DC_FAIL_CONTROLLER_VALIDATE;
+			for (k = 0; k < MAX_PIPES; k++) {
+				struct pipe_ctx *pipe_ctx =
+					&context->res_ctx.pipe_ctx[k];
+
+				if (context->res_ctx.pipe_ctx[k].stream != stream)
+					continue;
+
+				if (!pipe_ctx->tg->funcs->validate_timing(
+						pipe_ctx->tg, &stream->public.timing))
+					return DC_FAIL_CONTROLLER_VALIDATE;
+
+				if (pipe_ctx->signal == SIGNAL_TYPE_VIRTUAL)
+					return status;
 
-			if (stream->signal == SIGNAL_TYPE_VIRTUAL)
-				return status;
+				status = build_pipe_hw_param(pipe_ctx);
 
-			status = build_stream_hw_param(stream);
+				if (status != DC_OK)
+					return status;
 
-			if (status != DC_OK)
-				return status;
+				if (!link->link_enc->funcs->validate_output_with_stream(
+						link->link_enc,
+						pipe_ctx))
+					return DC_FAIL_ENC_VALIDATE;
 
-			if (!link->link_enc->funcs->validate_output_with_stream(
-					link->link_enc,
-					stream))
-				return DC_FAIL_ENC_VALIDATE;
+				/* TODO: validate audio ASIC caps, encoder */
 
-			/* TODO: validate audio ASIC caps, encoder */
+				status = dc_link_validate_mode_timing(stream->sink,
+						link,
+						&stream->public.timing);
 
-			status = dc_link_validate_mode_timing(stream->sink,
-					link,
-					&stream->public.timing);
+				if (status != DC_OK)
+					return status;
 
-			if (status != DC_OK)
-				return status;
+				build_info_frame(pipe_ctx);
 
-			build_info_frame(stream);
+				/* do not need to validate non root pipes */
+				break;
+			}
 		}
 	}
 
@@ -783,16 +796,17 @@ static void set_target_unchanged(
 		struct validate_context *context,
 		uint8_t target_idx)
 {
-	uint8_t i;
+	uint8_t i, j;
 	struct core_target *target = context->targets[target_idx];
-
 	context->target_flags[target_idx].unchanged = true;
 	for (i = 0; i < target->public.stream_count; i++) {
-		struct core_stream *core_stream =
+		struct core_stream *stream =
 			DC_STREAM_TO_CORE(target->public.streams[i]);
-		uint8_t index = core_stream->controller_idx;
-
-		context->res_ctx.controller_ctx[index].flags.unchanged = true;
+		for (j = 0; j < MAX_PIPES; j++) {
+			if (context->res_ctx.pipe_ctx[j].stream == stream)
+				context->res_ctx.pipe_ctx[j].flags.unchanged =
+									true;
+		}
 	}
 }
 
@@ -800,24 +814,7 @@ static enum dc_status map_clock_resources(
 		const struct dc *dc,
 		struct validate_context *context)
 {
-	uint8_t i, j;
-
-	/* mark resources used for targets that are already active */
-	for (i = 0; i < context->target_count; i++) {
-		struct core_target *target = context->targets[i];
-
-		if (!context->target_flags[i].unchanged)
-			continue;
-
-		for (j = 0; j < target->public.stream_count; j++) {
-			struct core_stream *stream =
-				DC_STREAM_TO_CORE(target->public.streams[j]);
-
-			reference_clock_source(
-				&context->res_ctx,
-				stream->clock_source);
-		}
-	}
+	uint8_t i, j, k;
 
 	/* acquire new resources */
 	for (i = 0; i < context->target_count; i++) {
@@ -830,24 +827,35 @@ static enum dc_status map_clock_resources(
 			struct core_stream *stream =
 				DC_STREAM_TO_CORE(target->public.streams[j]);
 
-			if (dc_is_dp_signal(stream->signal)
-				|| stream->signal == SIGNAL_TYPE_VIRTUAL)
-				stream->clock_source = context->res_ctx.
-					pool.clock_sources[DCE100_CLK_SRC_EXT];
-			else
-				stream->clock_source =
-					find_used_clk_src_for_sharing(
-							context, stream);
-			if (stream->clock_source == NULL)
-				stream->clock_source =
-					find_first_free_pll(&context->res_ctx);
-
-			if (stream->clock_source == NULL)
-				return DC_NO_CLOCK_SOURCE_RESOURCE;
-
-			reference_clock_source(
-					&context->res_ctx,
-					stream->clock_source);
+			for (k = 0; k < MAX_PIPES; k++) {
+				struct pipe_ctx *pipe_ctx =
+					&context->res_ctx.pipe_ctx[k];
+
+				if (context->res_ctx.pipe_ctx[k].stream != stream)
+					continue;
+
+				if (dc_is_dp_signal(pipe_ctx->signal)
+					|| pipe_ctx->signal == SIGNAL_TYPE_VIRTUAL)
+					pipe_ctx->clock_source = context->res_ctx.
+						pool.clock_sources[DCE100_CLK_SRC_EXT];
+				else
+					pipe_ctx->clock_source =
+						find_used_clk_src_for_sharing(
+							&context->res_ctx, pipe_ctx);
+				if (pipe_ctx->clock_source == NULL)
+					pipe_ctx->clock_source =
+						find_first_free_pll(&context->res_ctx);
+
+				if (pipe_ctx->clock_source == NULL)
+					return DC_NO_CLOCK_SOURCE_RESOURCE;
+
+				reference_clock_source(
+						&context->res_ctx,
+						pipe_ctx->clock_source);
+
+				/* only one cs per stream regardless of mpo */
+				break;
+			}
 		}
 	}
 
@@ -865,24 +873,30 @@ enum dc_status dce100_validate_with_context(
 	struct dc_context *dc_ctx = dc->ctx;
 
 	for (i = 0; i < set_count; i++) {
+		bool unchanged = false;
+
 		context->targets[i] = DC_TARGET_TO_CORE(set[i].target);
+		context->target_count++;
 
 		for (j = 0; j < dc->current_context.target_count; j++)
-			if (dc->current_context.targets[j] == context->targets[i])
+			if (dc->current_context.targets[j]
+						== context->targets[i]) {
+				unchanged = true;
 				set_target_unchanged(context, i);
-
-		if (!context->target_flags[i].unchanged)
-			if (!logical_attach_surfaces_to_target(
+				context->target_status[i] =
+					dc->current_context.target_status[j];
+			}
+		if (!unchanged)
+			if (!attach_surfaces_to_context(
 					(struct dc_surface **)set[i].surfaces,
 					set[i].surface_count,
-					&context->targets[i]->public)) {
+					&context->targets[i]->public,
+					context)) {
 				DC_ERROR("Failed to attach surface to target!\n");
 				return DC_FAIL_ATTACH_SURFACES;
 			}
 	}
 
-	context->target_count = set_count;
-
 	context->res_ctx.pool = dc->res_pool;
 
 	result = map_resources(dc, context);
@@ -969,7 +983,7 @@ bool dce100_construct_resource_pool(
 
 	}
 
-	pool->controller_count =
+	pool->pipe_count =
 		dal_adapter_service_get_func_controllers_num(adapter_serv);
 	pool->stream_enc_count = dal_adapter_service_get_stream_engines_num(
 			adapter_serv);
@@ -980,7 +994,7 @@ bool dce100_construct_resource_pool(
 		goto filter_create_fail;
 	}
 
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		pool->timing_generators[i] = dce100_timing_generator_create(
 				adapter_serv, ctx, i, &dce100_tg_offsets[i]);
 		if (pool->timing_generators[i] == NULL) {
@@ -1031,7 +1045,7 @@ bool dce100_construct_resource_pool(
 	audio_init_data.as = adapter_serv;
 	audio_init_data.ctx = ctx;
 	pool->audio_count = 0;
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		struct graphics_object_id obj_id;
 
 		obj_id = dal_adapter_service_enum_audio_object(adapter_serv, i);
@@ -1089,13 +1103,13 @@ stream_enc_create_fail:
 	}
 
 audio_create_fail:
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		if (pool->audios[i] != NULL)
 			dal_audio_destroy(&pool->audios[i]);
 	}
 
 controller_create_fail:
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		if (pool->opps[i] != NULL)
 			dce100_opp_destroy(&pool->opps[i]);
 
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
index a815a6d..70349a0 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_hw_sequencer.c
@@ -546,17 +546,17 @@ prescale_alloc_fail:
 }
 
 static enum dc_status bios_parser_crtc_source_select(
-		struct core_stream *stream)
+		struct pipe_ctx *pipe_ctx)
 {
 	struct dc_bios *dcb;
 	/* call VBIOS table to set CRTC source for the HW
 	 * encoder block
 	 * note: video bios clears all FMT setting here. */
 	struct bp_crtc_source_select crtc_source_select = {0};
-	const struct core_sink *sink = stream->sink;
+	const struct core_sink *sink = pipe_ctx->stream->sink;
 
-	crtc_source_select.engine_id = stream->stream_enc->id;
-	crtc_source_select.controller_id = stream->controller_idx + 1;
+	crtc_source_select.engine_id = pipe_ctx->stream_enc->id;
+	crtc_source_select.controller_id = pipe_ctx->pipe_idx + 1;
 	/*TODO: Need to un-hardcode color depth, dp_audio and account for
 	 * the case where signal and sink signal is different (translator
 	 * encoder)*/
@@ -576,32 +576,6 @@ static enum dc_status bios_parser_crtc_source_select(
 	return DC_OK;
 }
 
-static enum color_space surface_color_to_color_space(
-	struct plane_colorimetry *colorimetry)
-{
-	enum color_space color_space = COLOR_SPACE_UNKNOWN;
-
-	switch (colorimetry->color_space) {
-	case SURFACE_COLOR_SPACE_SRGB:
-	case SURFACE_COLOR_SPACE_XRRGB:
-		if (colorimetry->limited_range)
-			color_space = COLOR_SPACE_SRGB_LIMITED_RANGE;
-		else
-			color_space = COLOR_SPACE_SRGB_FULL_RANGE;
-		break;
-	case SURFACE_COLOR_SPACE_BT601:
-	case SURFACE_COLOR_SPACE_XVYCC_BT601:
-		color_space = COLOR_SPACE_YCBCR601;
-		break;
-	case SURFACE_COLOR_SPACE_BT709:
-	case SURFACE_COLOR_SPACE_XVYCC_BT709:
-		color_space = COLOR_SPACE_YCBCR709;
-		break;
-	}
-
-	return color_space;
-}
-
 /*******************************FMT**************************************/
 static void program_fmt(
 		struct output_pixel_processor *opp,
@@ -630,35 +604,35 @@ static void update_bios_scratch_critical_state(struct adapter_service *as,
 	dcb->funcs->set_scratch_critical_state(dcb, state);
 }
 
-static void update_info_frame(struct core_stream *stream)
+static void update_info_frame(struct pipe_ctx *pipe_ctx)
 {
-	if (dc_is_hdmi_signal(stream->signal))
-		stream->stream_enc->funcs->update_hdmi_info_packets(
-			stream->stream_enc,
-			&stream->encoder_info_frame);
-	else if (dc_is_dp_signal(stream->signal))
-		stream->stream_enc->funcs->update_dp_info_packets(
-			stream->stream_enc,
-			&stream->encoder_info_frame);
+	if (dc_is_hdmi_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->update_hdmi_info_packets(
+			pipe_ctx->stream_enc,
+			&pipe_ctx->encoder_info_frame);
+	else if (dc_is_dp_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->update_dp_info_packets(
+			pipe_ctx->stream_enc,
+			&pipe_ctx->encoder_info_frame);
 }
 
 
-static void enable_stream(struct core_stream *stream)
+static void enable_stream(struct pipe_ctx *pipe_ctx)
 {
 	enum dc_lane_count lane_count =
-			stream->sink->link->public.cur_link_settings.lane_count;
+		pipe_ctx->stream->sink->link->public.cur_link_settings.lane_count;
 
-	struct dc_crtc_timing *timing = &stream->public.timing;
-	struct core_link *link = stream->sink->link;
+	struct dc_crtc_timing *timing = &pipe_ctx->stream->public.timing;
+	struct core_link *link = pipe_ctx->stream->sink->link;
 
 	/* 1. update AVI info frame (HDMI, DP)
 	 * we always need to update info frame
 	*/
 	uint32_t active_total_with_borders;
 	uint32_t early_control = 0;
-	struct timing_generator *tg = stream->tg;
+	struct timing_generator *tg = pipe_ctx->tg;
 
-	update_info_frame(stream);
+	update_info_frame(pipe_ctx);
 	/* enable early control to avoid corruption on DP monitor*/
 	active_total_with_borders =
 			timing->h_addressable
@@ -674,11 +648,11 @@ static void enable_stream(struct core_stream *stream)
 	tg->funcs->set_early_control(tg, early_control);
 
 	/* enable audio only within mode set */
-	if (stream->audio != NULL) {
+	if (pipe_ctx->audio != NULL) {
 		dal_audio_enable_output(
-			stream->audio,
-			stream->stream_enc->id,
-			stream->signal);
+			pipe_ctx->audio,
+			pipe_ctx->stream_enc->id,
+			pipe_ctx->signal);
 	}
 
 	/* For MST, there are multiply stream go to only one link.
@@ -686,26 +660,27 @@ static void enable_stream(struct core_stream *stream)
 	 * disconnect them during disable_stream
 	 * BY this, it is logic clean to separate stream and link */
 	 link->link_enc->funcs->connect_dig_be_to_fe(link->link_enc,
-			stream->stream_enc->id, true);
+			pipe_ctx->stream_enc->id, true);
 
 }
 
-static void disable_stream(struct core_stream *stream)
+static void disable_stream(struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	struct core_link *link = stream->sink->link;
 
-	if (dc_is_hdmi_signal(stream->signal))
-		stream->stream_enc->funcs->stop_hdmi_info_packets(
-			stream->stream_enc);
+	if (dc_is_hdmi_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->stop_hdmi_info_packets(
+			pipe_ctx->stream_enc);
 
-	if (dc_is_dp_signal(stream->signal))
-		stream->stream_enc->funcs->stop_dp_info_packets(
-			stream->stream_enc);
+	if (dc_is_dp_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->stop_dp_info_packets(
+			pipe_ctx->stream_enc);
 
-	if (stream->audio) {
+	if (pipe_ctx->audio) {
 		/* mute audio */
-		dal_audio_mute(stream->audio, stream->stream_enc->id,
-				stream->signal);
+		dal_audio_mute(pipe_ctx->audio, pipe_ctx->stream_enc->id,
+				pipe_ctx->signal);
 
 		/* TODO: notify audio driver for if audio modes list changed
 		 * add audio mode list change flag */
@@ -715,27 +690,26 @@ static void disable_stream(struct core_stream *stream)
 	}
 
 	/* blank at encoder level */
-	if (dc_is_dp_signal(stream->signal))
-		stream->stream_enc->funcs->dp_blank(stream->stream_enc);
+	if (dc_is_dp_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->dp_blank(pipe_ctx->stream_enc);
 
 	link->link_enc->funcs->connect_dig_be_to_fe(
 			link->link_enc,
-			stream->stream_enc->id,
+			pipe_ctx->stream_enc->id,
 			false);
 
 }
 
-static void unblank_stream(struct core_stream *stream,
+static void unblank_stream(struct pipe_ctx *pipe_ctx,
 		struct dc_link_settings *link_settings)
 {
 	struct encoder_unblank_param params = { { 0 } };
 
 	/* only 3 items below are used by unblank */
 	params.crtc_timing.pixel_clock =
-		stream->public.timing.pix_clk_khz;
+		pipe_ctx->stream->public.timing.pix_clk_khz;
 	params.link_settings.link_rate = link_settings->link_rate;
-	stream->stream_enc->funcs->dp_unblank(
-		stream->stream_enc, &params);
+	pipe_ctx->stream_enc->funcs->dp_unblank(pipe_ctx->stream_enc, &params);
 }
 
 static enum color_space get_output_color_space(
@@ -776,106 +750,102 @@ static enum color_space get_output_color_space(
 	return color_space;
 }
 
-static enum dc_status apply_single_controller_ctx_to_hw(uint8_t controller_idx,
+static enum dc_status apply_single_controller_ctx_to_hw(
+		struct pipe_ctx *pipe_ctx,
 		struct validate_context *context,
-		const struct dc *dc)
+		struct dc *dc)
 {
-	struct core_stream *stream =
-			context->res_ctx.controller_ctx[controller_idx].stream;
-	struct core_stream *old_stream =
-		dc->current_context.res_ctx.controller_ctx[controller_idx].stream;
-	struct output_pixel_processor *opp =
-		context->res_ctx.pool.opps[controller_idx];
-	bool timing_changed = context->res_ctx.controller_ctx[controller_idx]
-			.flags.timing_changed;
+	struct core_stream *stream = pipe_ctx->stream;
+	struct pipe_ctx *old_pipe_ctx =
+		&dc->current_context.res_ctx.pipe_ctx[pipe_ctx->pipe_idx];
+	bool timing_changed = context->res_ctx.pipe_ctx[pipe_ctx->pipe_idx]
+							.flags.timing_changed;
 	enum color_space color_space;
 
 	if (timing_changed) {
 		/* Must blank CRTC after disabling power gating and before any
 		 * programming, otherwise CRTC will be hung in bad state
 		 */
-		stream->tg->funcs->set_blank(stream->tg, true);
+		pipe_ctx->tg->funcs->set_blank(pipe_ctx->tg, true);
 
 		/*
 		 * only disable stream in case it was ever enabled
 		 */
-		if (old_stream)
-			core_link_disable_stream(
-				old_stream->sink->link,
-				old_stream);
+		if (old_pipe_ctx->stream)
+			core_link_disable_stream(old_pipe_ctx);
 
 		/*TODO: AUTO check if timing changed*/
-		if (false == stream->clock_source->funcs->program_pix_clk(
-				stream->clock_source,
-				&stream->pix_clk_params,
-				&stream->pll_settings)) {
+		if (false == pipe_ctx->clock_source->funcs->program_pix_clk(
+				pipe_ctx->clock_source,
+				&pipe_ctx->pix_clk_params,
+				&pipe_ctx->pll_settings)) {
 			BREAK_TO_DEBUGGER();
 			return DC_ERROR_UNEXPECTED;
 		}
 
-		stream->tg->funcs->program_timing(
-				stream->tg,
+		pipe_ctx->tg->funcs->program_timing(
+				pipe_ctx->tg,
 				&stream->public.timing,
 				true);
 	}
 
 	/*TODO: mst support - use total stream count*/
-	stream->mi->funcs->allocate_mem_input(
-					stream->mi,
+	pipe_ctx->mi->funcs->allocate_mem_input(
+					pipe_ctx->mi,
 					stream->public.timing.h_total,
 					stream->public.timing.v_total,
 					stream->public.timing.pix_clk_khz,
 					context->target_count);
 
 	if (timing_changed) {
-		if (false == stream->tg->funcs->enable_crtc(
-				stream->tg)) {
+		if (false == pipe_ctx->tg->funcs->enable_crtc(
+				pipe_ctx->tg)) {
 			BREAK_TO_DEBUGGER();
 			return DC_ERROR_UNEXPECTED;
 		}
 	}
 
 	/* TODO: move to stream encoder */
-	if (stream->signal != SIGNAL_TYPE_VIRTUAL)
-		if (DC_OK != bios_parser_crtc_source_select(stream)) {
+	if (pipe_ctx->signal != SIGNAL_TYPE_VIRTUAL)
+		if (DC_OK != bios_parser_crtc_source_select(pipe_ctx)) {
 			BREAK_TO_DEBUGGER();
 			return DC_ERROR_UNEXPECTED;
 		}
 
-	opp->funcs->opp_set_dyn_expansion(
-			opp,
+	pipe_ctx->opp->funcs->opp_set_dyn_expansion(
+			pipe_ctx->opp,
 			COLOR_SPACE_YCBCR601,
 			stream->public.timing.display_color_depth,
 			stream->sink->public.sink_signal);
 
-	program_fmt(opp, &stream->bit_depth_params, &stream->clamping);
+	program_fmt(pipe_ctx->opp, &stream->bit_depth_params, &stream->clamping);
 
 	stream->sink->link->link_enc->funcs->setup(
 		stream->sink->link->link_enc,
-		stream->signal);
+		pipe_ctx->signal);
 
-	if (dc_is_dp_signal(stream->signal))
-		stream->stream_enc->funcs->dp_set_stream_attribute(
-			stream->stream_enc,
+	if (dc_is_dp_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->dp_set_stream_attribute(
+			pipe_ctx->stream_enc,
 			&stream->public.timing);
 
-	if (dc_is_hdmi_signal(stream->signal))
-		stream->stream_enc->funcs->hdmi_set_stream_attribute(
-			stream->stream_enc,
+	if (dc_is_hdmi_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->hdmi_set_stream_attribute(
+			pipe_ctx->stream_enc,
 			&stream->public.timing,
-			stream->audio != NULL);
+			pipe_ctx->audio != NULL);
 
-	if (dc_is_dvi_signal(stream->signal))
-		stream->stream_enc->funcs->dvi_set_stream_attribute(
-			stream->stream_enc,
+	if (dc_is_dvi_signal(pipe_ctx->signal))
+		pipe_ctx->stream_enc->funcs->dvi_set_stream_attribute(
+			pipe_ctx->stream_enc,
 			&stream->public.timing,
-			(stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ?
+			(pipe_ctx->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ?
 			true : false);
 
-	if (stream->audio != NULL) {
+	if (pipe_ctx->audio != NULL) {
 		if (AUDIO_RESULT_OK != dal_audio_setup(
-				stream->audio,
-				&stream->audio_output,
+				pipe_ctx->audio,
+				&pipe_ctx->audio_output,
 				&stream->public.audio_info)) {
 			BREAK_TO_DEBUGGER();
 			return DC_ERROR_UNEXPECTED;
@@ -883,24 +853,24 @@ static enum dc_status apply_single_controller_ctx_to_hw(uint8_t controller_idx,
 	}
 
 	/* Setup audio rate clock source */
-	if (stream->audio != NULL)
+	if (pipe_ctx->audio != NULL)
 		dal_audio_setup_audio_wall_dto(
-				stream->audio,
-				stream->signal,
-				&stream->audio_output.crtc_info,
-				&stream->audio_output.pll_info);
+				pipe_ctx->audio,
+				pipe_ctx->signal,
+				&pipe_ctx->audio_output.crtc_info,
+				&pipe_ctx->audio_output.pll_info);
 
 	/* program blank color */
 	color_space = get_output_color_space(&stream->public.timing);
-	stream->tg->funcs->set_blank_color(
-			context->res_ctx.pool.timing_generators[controller_idx],
+	pipe_ctx->tg->funcs->set_blank_color(
+			pipe_ctx->tg,
 			color_space);
 
 	if (timing_changed)
-		core_link_enable_stream(stream->sink->link, stream);
+		core_link_enable_stream(pipe_ctx);
 
-	if (dc_is_dp_signal(stream->signal))
-		unblank_stream(stream,
+	if (dc_is_dp_signal(pipe_ctx->signal))
+		unblank_stream(pipe_ctx,
 			&stream->sink->link->public.cur_link_settings);
 
 	return DC_OK;
@@ -923,7 +893,7 @@ static void power_down_controllers(struct dc *dc)
 {
 	int i;
 
-	for (i = 0; i < dc->res_pool.controller_count; i++) {
+	for (i = 0; i < dc->res_pool.pipe_count; i++) {
 		dc->res_pool.timing_generators[i]->funcs->disable_crtc(
 				dc->res_pool.timing_generators[i]);
 	}
@@ -960,7 +930,7 @@ static void disable_vga_and_power_gate_all_controllers(
 	dcb = dal_adapter_service_get_bios_parser(
 			dc->res_pool.adapter_srv);
 
-	for (i = 0; i < dc->res_pool.controller_count; i++) {
+	for (i = 0; i < dc->res_pool.pipe_count; i++) {
 		tg = dc->res_pool.timing_generators[i];
 		ctx = dc->ctx;
 
@@ -1133,14 +1103,13 @@ static void set_display_clock(struct validate_context *context)
 }
 
 static uint32_t compute_pstate_blackout_duration(
-	const struct dc *dc,
+	struct bw_fixed blackout_duration,
 	const struct core_stream *stream)
 {
 	uint32_t total_dest_line_time_ns;
 	uint32_t pstate_blackout_duration_ns;
 
-	pstate_blackout_duration_ns = 1000 *
-		dc->bw_vbios.blackout_duration.value >> 24;
+	pstate_blackout_duration_ns = 1000 * blackout_duration.value >> 24;
 
 	total_dest_line_time_ns = 1000000UL *
 		stream->public.timing.h_total /
@@ -1154,63 +1123,50 @@ static void set_displaymarks(
 	const struct dc *dc,
 	struct validate_context *context)
 {
-	uint8_t i, j;
-	uint8_t total_streams = 0;
-	uint8_t target_count = context->target_count;
-	uint32_t pstate_blackout_duration_ns;
+	uint8_t i, num_pipes;
+
+	for (i = 0, num_pipes = 0; i < MAX_PIPES; i++) {
+		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+		uint32_t total_dest_line_time_ns;
+
+		if (pipe_ctx->stream == NULL)
+			continue;
 
-	for (i = 0; i < target_count; i++) {
-		const struct core_target *target = context->targets[i];
-
-		for (j = 0; j < target->public.stream_count; j++) {
-			const struct core_stream *stream =
-				DC_STREAM_TO_CORE(target->public.streams[j]);
-
-			pstate_blackout_duration_ns =
-				compute_pstate_blackout_duration(dc, stream);
-
-			stream->mi->funcs->mem_input_program_display_marks(
-				stream->mi,
-				context->bw_results
-					.nbp_state_change_wm_ns[total_streams],
-				context->bw_results
-					.stutter_exit_wm_ns[total_streams],
-				context->bw_results.
-					urgent_wm_ns[total_streams],
-				pstate_blackout_duration_ns);
-
-			total_streams++;
-		} /* for ()*/
-	} /* for() */
+		total_dest_line_time_ns = compute_pstate_blackout_duration(
+			dc->bw_vbios.blackout_duration, pipe_ctx->stream);
+		pipe_ctx->mi->funcs->mem_input_program_display_marks(
+			pipe_ctx->mi,
+			context->bw_results.nbp_state_change_wm_ns[num_pipes],
+			context->bw_results.stutter_exit_wm_ns[num_pipes],
+			context->bw_results.urgent_wm_ns[num_pipes],
+			total_dest_line_time_ns);
+		num_pipes++;
+	}
 }
 
-static void set_safe_displaymarks(const struct dc *dc, struct validate_context *context)
+
+static void set_safe_displaymarks(struct resource_context *res_ctx)
 {
-	uint8_t i, j;
-	uint8_t target_count = context->target_count;
+	uint8_t i;
 	struct bw_watermarks max_marks = { MAX_WATERMARK, MAX_WATERMARK };
 	struct bw_watermarks nbp_marks = { SAFE_NBP_MARK, SAFE_NBP_MARK };
 
-	for (i = 0; i < target_count; i++) {
-		struct core_target *target = context->targets[i];
-
-		for (j = 0; j < target->public.stream_count; j++) {
-			struct core_stream *stream =
-				DC_STREAM_TO_CORE(target->public.streams[j]);
+	for (i = 0; i < MAX_PIPES; i++) {
+		if (res_ctx->pipe_ctx[i].stream == NULL)
+			continue;
 
-			stream->mi->funcs->mem_input_program_display_marks(
-				stream->mi,
+		res_ctx->pipe_ctx[i].mi->funcs->mem_input_program_display_marks(
+				res_ctx->pipe_ctx[i].mi,
 				nbp_marks,
 				max_marks,
 				max_marks,
 				MAX_WATERMARK);
-		}
 	}
 }
 
 static void program_bw(struct dc *dc, struct validate_context *context)
 {
-	set_safe_displaymarks(dc, context);
+	set_safe_displaymarks(&context->res_ctx);
 	/*TODO: when pplib works*/
 	/*dc_set_clocks_and_clock_state(context);*/
 
@@ -1220,31 +1176,27 @@ static void program_bw(struct dc *dc, struct validate_context *context)
 
 static void switch_dp_clock_sources(
 	const struct dc *dc,
-	struct validate_context *val_context)
+	struct resource_context *res_ctx)
 {
-	uint8_t i, j;
-	for (i = 0; i < val_context->target_count; i++) {
-		struct core_target *target = val_context->targets[i];
-		for (j = 0; j < target->public.stream_count; j++) {
-			struct core_stream *stream =
-				DC_STREAM_TO_CORE(target->public.streams[j]);
-
-			if (dc_is_dp_signal(stream->signal)) {
-				struct clock_source *clk_src =
-					find_used_clk_src_for_sharing(
-							val_context, stream);
-
-				if (clk_src &&
-					clk_src != stream->clock_source) {
-					unreference_clock_source(
-							&val_context->res_ctx,
-							stream->clock_source);
-					stream->clock_source = clk_src;
-					reference_clock_source(
-						&val_context->res_ctx, clk_src);
-					dc->hwss.crtc_switch_to_clk_src(
-						clk_src, stream->opp->inst);
-				}
+	uint8_t i;
+	for (i = 0; i < MAX_PIPES; i++) {
+		struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
+
+		if (pipe_ctx->stream == NULL)
+			continue;
+
+		if (dc_is_dp_signal(pipe_ctx->signal)) {
+			struct clock_source *clk_src =
+				find_used_clk_src_for_sharing(
+						res_ctx, pipe_ctx);
+
+			if (clk_src &&
+				clk_src != pipe_ctx->clock_source) {
+				unreference_clock_source(
+					res_ctx, pipe_ctx->clock_source);
+				pipe_ctx->clock_source = clk_src;
+				reference_clock_source(res_ctx, clk_src);
+				dc->hwss.crtc_switch_to_clk_src(clk_src, i);
 			}
 		}
 	}
@@ -1256,22 +1208,20 @@ static void switch_dp_clock_sources(
 
 /*TODO: const validate_context*/
 static enum dc_status apply_ctx_to_hw(
-		const struct dc *dc,
+		struct dc *dc,
 		struct validate_context *context)
 {
 	enum dc_status status;
 	uint8_t i;
-	struct resource_pool *pool = &context->res_ctx.pool;
 
 	update_bios_scratch_critical_state(context->res_ctx.pool.adapter_srv,
 			true);
 
-	for (i = 0; i < pool->controller_count; i++) {
-		struct controller_ctx *ctlr_ctx
-			= &context->res_ctx.controller_ctx[i];
+	for (i = 0; i < MAX_PIPES; i++) {
+		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
 		struct dc_bios *dcb;
 
-		if (ctlr_ctx->flags.unchanged || !ctlr_ctx->stream)
+		if (pipe_ctx->stream == NULL || pipe_ctx->flags.unchanged)
 			continue;
 
 		dcb = dal_adapter_service_get_bios_parser(
@@ -1282,7 +1232,7 @@ static enum dc_status apply_ctx_to_hw(
 				PIPE_GATING_CONTROL_DISABLE);
 	}
 
-	set_safe_displaymarks(dc, context);
+	set_safe_displaymarks(&context->res_ctx);
 	/*TODO: when pplib works*/
 	/*dc_set_clocks_and_clock_state(context);*/
 
@@ -1290,14 +1240,14 @@ static enum dc_status apply_ctx_to_hw(
 		> dc->current_context.bw_results.dispclk_khz)
 		set_display_clock(context);
 
-	for (i = 0; i < pool->controller_count; i++) {
-		struct controller_ctx *ctlr_ctx
-			= &context->res_ctx.controller_ctx[i];
-		if (ctlr_ctx->flags.unchanged || !ctlr_ctx->stream)
+	for (i = 0; i < MAX_PIPES; i++) {
+		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+
+		if (pipe_ctx->stream == NULL || pipe_ctx->flags.unchanged)
 			continue;
 
 		status = apply_single_controller_ctx_to_hw(
-				i,
+				pipe_ctx,
 				context,
 				dc);
 
@@ -1309,7 +1259,7 @@ static enum dc_status apply_ctx_to_hw(
 	update_bios_scratch_critical_state(context->res_ctx.pool.adapter_srv,
 			false);
 
-	switch_dp_clock_sources(dc, context);
+	switch_dp_clock_sources(dc, &context->res_ctx);
 
 	return DC_OK;
 }
@@ -1320,14 +1270,14 @@ static enum dc_status apply_ctx_to_hw(
  ******************************************************************************/
 
 static bool setup_line_buffer_pixel_depth(
-	const struct core_stream *stream,
+	const struct pipe_ctx *pipe_ctx,
 	enum lb_pixel_depth depth,
 	bool blank)
 {
 	enum lb_pixel_depth current_depth;
 
-	struct timing_generator *tg = stream->tg;
-	struct transform *xfm = stream->xfm;
+	struct timing_generator *tg = pipe_ctx->tg;
+	struct transform *xfm = pipe_ctx->xfm;
 
 	if (!xfm->funcs->transform_get_current_pixel_storage_depth(
 		xfm,
@@ -1339,14 +1289,14 @@ static bool setup_line_buffer_pixel_depth(
 			tg->funcs->wait_for_state(tg, CRTC_STATE_VBLANK);
 
 		return xfm->funcs->transform_set_pixel_storage_depth(xfm, depth,
-				&stream->bit_depth_params);
+				&pipe_ctx->stream->bit_depth_params);
 	}
 
 	return false;
 }
 
 static void hw_sequencer_build_scaler_parameter_plane(
-		const struct core_stream *stream,
+		const struct pipe_ctx *pipe_ctx,
 		struct scaler_data *scaler_data)
 {
 	/*TODO: per pipe not per stream*/
@@ -1361,15 +1311,15 @@ static void hw_sequencer_build_scaler_parameter_plane(
 
 	scaler_data->flags.bits.INTERLACED = 0;
 
-	scaler_data->dal_pixel_format = stream->format;
+	scaler_data->dal_pixel_format = pipe_ctx->format;
 
-	scaler_data->taps = stream->taps;
+	scaler_data->taps = pipe_ctx->taps;
 
-	scaler_data->viewport = stream->viewport;
+	scaler_data->viewport = pipe_ctx->viewport;
 
-	scaler_data->overscan = stream->overscan;
+	scaler_data->overscan = pipe_ctx->overscan;
 
-	scaler_data->ratios = &stream->ratios;
+	scaler_data->ratios = &pipe_ctx->ratios;
 
 	/*TODO rotation and adjustment */
 	scaler_data->h_sharpness = 0;
@@ -1377,23 +1327,19 @@ static void hw_sequencer_build_scaler_parameter_plane(
 
 }
 
-static void set_default_colors(
-				struct input_pixel_processor *ipp,
-				struct output_pixel_processor *opp,
-				enum pixel_format format,
-				enum color_space input_color_space,
-				enum color_space output_color_space,
-				enum dc_color_depth color_depth)
+static void set_default_colors(struct pipe_ctx *pipe_ctx)
 {
 	struct default_adjustment default_adjust = { 0 };
 
 	default_adjust.force_hw_default = false;
-	default_adjust.color_space = output_color_space;
+	default_adjust.color_space = get_output_color_space(
+					&pipe_ctx->stream->public.timing);
 	default_adjust.csc_adjust_type = GRAPHICS_CSC_ADJUST_TYPE_SW;
-	default_adjust.surface_pixel_format = format;
+	default_adjust.surface_pixel_format = pipe_ctx->format;
 
 	/* display color depth */
-	default_adjust.color_depth = color_depth;
+	default_adjust.color_depth =
+		pipe_ctx->stream->public.timing.display_color_depth;
 
 	/* Lb color depth */
 	default_adjust.lb_color_depth = LB_PIXEL_DEPTH_24BPP;
@@ -1401,99 +1347,74 @@ static void set_default_colors(
 			build_params->
 			line_buffer_params[path_id][plane_id].depth);*/
 
-	opp->funcs->opp_set_csc_default(opp, &default_adjust);
+	pipe_ctx->opp->funcs->opp_set_csc_default(
+					pipe_ctx->opp, &default_adjust);
 }
 
 static void program_scaler(
-	uint8_t controller_idx,
-	struct timing_generator *tg,
-	struct transform *xfm,
 	const struct core_surface *surface,
-	const struct core_stream *stream)
+	const struct pipe_ctx *pipe_ctx)
 {
 	struct scaler_data scaler_data = { { 0 } };
 
 	hw_sequencer_build_scaler_parameter_plane(
-		stream,
+		pipe_ctx,
 		&scaler_data);
 
 	setup_line_buffer_pixel_depth(
-		stream,
+		pipe_ctx,
 		LB_PIXEL_DEPTH_24BPP,
 		false);
 
-	tg->funcs->set_overscan_blank_color(tg, surface->public.colorimetry.color_space);
+	pipe_ctx->tg->funcs->set_overscan_blank_color(
+		pipe_ctx->tg, surface->public.color_space);
 
-	xfm->funcs->transform_set_scaler(xfm, &scaler_data);
+	pipe_ctx->xfm->funcs->transform_set_scaler(pipe_ctx->xfm, &scaler_data);
 
-	xfm->funcs->transform_update_viewport(
-			xfm,
-			&scaler_data.viewport,
-			false);
+	pipe_ctx->xfm->funcs->transform_update_viewport(
+			pipe_ctx->xfm, &scaler_data.viewport, false);
 }
 
 /**
  * Program the Front End of the Pipe.
  * The Back End was already programmed by Set Mode.
  */
-static bool set_plane_config(
+static void set_plane_config(
 	const struct dc *dc,
 	struct core_surface *surface,
-	struct core_target *target)
+	struct pipe_ctx *pipe_ctx)
 {
-	const struct core_stream *core_stream =
-		DC_STREAM_TO_CORE(target->public.streams[0]);
-	const struct dc_crtc_timing *dc_crtc_timing =
-			&target->public.streams[0]->timing;
-	struct mem_input *mi = core_stream->mi;
-	struct input_pixel_processor *ipp = core_stream->ipp;
-	struct timing_generator *tg = core_stream->tg;
-	struct transform *xfm = core_stream->xfm;
-	struct output_pixel_processor *opp = core_stream->opp;
-	struct dc_context *ctx = core_stream->ctx;
-	uint8_t controller_idx = core_stream->controller_idx;
-
-	/* TODO: Clean up change, possibly change to use same type */
-	enum color_space input_color_space =
-					surface_color_to_color_space(&(surface->public.colorimetry));
+	const struct dc_crtc_timing *crtc_timing =
+				&pipe_ctx->stream->public.timing;
+	struct mem_input *mi = pipe_ctx->mi;
+	struct timing_generator *tg = pipe_ctx->tg;
+	struct dc_context *ctx = pipe_ctx->stream->ctx;
 
 	dc->hwss.pipe_control_lock(
-			ctx,
-			controller_idx,
-			PIPE_LOCK_CONTROL_MODE,
-			false);
+		ctx, pipe_ctx->pipe_idx, PIPE_LOCK_CONTROL_MODE, false);
 
 	/* While a non-root controller is programmed we
 	 * have to lock the root controller. */
 	dc->hwss.pipe_control_lock(
 			ctx,
-			controller_idx,
+			pipe_ctx->pipe_idx,
 			PIPE_LOCK_CONTROL_GRAPHICS |
 			PIPE_LOCK_CONTROL_SCL |
 			PIPE_LOCK_CONTROL_BLENDER |
 			PIPE_LOCK_CONTROL_SURFACE,
 			true);
 
-	tg->funcs->program_timing(tg, dc_crtc_timing, false);
+	tg->funcs->program_timing(tg, crtc_timing, false);
 
-	dc->hwss.enable_fe_clock(ctx, controller_idx, true);
+	dc->hwss.enable_fe_clock(ctx, pipe_ctx->pipe_idx, true);
 
-	set_default_colors(
-			ipp,
-			opp,
-			core_stream->format,
-			input_color_space,
-			get_output_color_space(dc_crtc_timing),
-			dc_crtc_timing->display_color_depth);
+	set_default_colors(pipe_ctx);
 
 	/* program Scaler */
-	program_scaler(
-		controller_idx, tg, xfm, surface, core_stream);
+	program_scaler(surface, pipe_ctx);
 
 	dc->hwss.set_blender_mode(
-			ctx,
-			controller_idx,
-			BLENDER_MODE_CURRENT_PIPE);
+		ctx, pipe_ctx->pipe_idx, BLENDER_MODE_CURRENT_PIPE);
 
 	mi->funcs->mem_input_program_surface_config(
 			mi,
@@ -1504,96 +1425,92 @@ static bool set_plane_config(
 
 	dc->hwss.pipe_control_lock(
 			ctx,
-			controller_idx,
+			pipe_ctx->pipe_idx,
 			PIPE_LOCK_CONTROL_GRAPHICS |
 			PIPE_LOCK_CONTROL_SCL |
 			PIPE_LOCK_CONTROL_BLENDER |
 			PIPE_LOCK_CONTROL_SURFACE,
 			false);
-
-	return true;
 }
 
-static bool update_plane_address(
-	const struct dc *dc,
-	const struct core_surface *surface,
-	struct core_target *target)
+static void update_plane_addrs(
+	struct dc *dc,
+	struct resource_context *res_ctx,
+	const struct core_surface *surface)
 {
-	const struct core_stream *core_stream =
-		DC_STREAM_TO_CORE(target->public.streams[0]);
-	struct dc_context *ctx = core_stream->ctx;
-	struct mem_input *mi = core_stream->mi;
-	uint8_t controller_id = core_stream->controller_idx;
+	uint8_t j;
 
-	/* TODO: crtc should be per surface, NOT per-target */
-	dc->hwss.pipe_control_lock(
-		ctx,
-		controller_id,
-		PIPE_LOCK_CONTROL_SURFACE,
-		true);
-
-	if (false ==
-		core_stream->mi->funcs->mem_input_program_surface_flip_and_addr(
-		mi, &surface->public.address, surface->public.flip_immediate))
-		return false;
+	for (j = 0; j < MAX_PIPES; j++) {
+		struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[j];
 
-	dc->hwss.pipe_control_lock(
-		ctx,
-		controller_id,
-		PIPE_LOCK_CONTROL_SURFACE,
-		false);
+		if (pipe_ctx->surface != surface)
+			continue;
 
-	return true;
+		dc->hwss.pipe_control_lock(
+			dc->ctx,
+			j,
+			PIPE_LOCK_CONTROL_SURFACE,
+			true);
+
+		pipe_ctx->mi->funcs->mem_input_program_surface_flip_and_addr(
+			pipe_ctx->mi,
+			&surface->public.address,
+			surface->public.flip_immediate);
+
+		dc->hwss.pipe_control_lock(
+			dc->ctx,
+			j,
+			PIPE_LOCK_CONTROL_SURFACE,
+			false);
+
+		break;
+	}
 }
 
-static void reset_single_stream_hw_ctx(
+static void reset_single_pipe_hw_ctx(
 		const struct dc *dc,
-		struct core_stream *stream,
+		struct pipe_ctx *pipe_ctx,
 		struct validate_context *context)
 {
 	struct dc_bios *dcb;
 
 	dcb = dal_adapter_service_get_bios_parser(
 			context->res_ctx.pool.adapter_srv);
-	if (stream->audio) {
-		dal_audio_disable_output(stream->audio,
-				stream->stream_enc->id,
-				stream->signal);
-		stream->audio = NULL;
+	if (pipe_ctx->audio) {
+		dal_audio_disable_output(pipe_ctx->audio,
+				pipe_ctx->stream_enc->id,
+				pipe_ctx->signal);
+		pipe_ctx->audio = NULL;
 	}
 
-	core_link_disable_stream(stream->sink->link, stream);
+	core_link_disable_stream(pipe_ctx);
 
-	stream->tg->funcs->set_blank(stream->tg, true);
-	stream->tg->funcs->disable_crtc(stream->tg);
-	stream->mi->funcs->free_mem_input(
-			stream->mi, context->target_count);
-	stream->xfm->funcs->transform_set_scaler_bypass(stream->xfm);
-	unreference_clock_source(&context->res_ctx, stream->clock_source);
+	pipe_ctx->tg->funcs->set_blank(pipe_ctx->tg, true);
+	pipe_ctx->tg->funcs->disable_crtc(pipe_ctx->tg);
+	pipe_ctx->mi->funcs->free_mem_input(
+				pipe_ctx->mi, context->target_count);
+	pipe_ctx->xfm->funcs->transform_set_scaler_bypass(pipe_ctx->xfm);
+	unreference_clock_source(&context->res_ctx, pipe_ctx->clock_source);
 	dc->hwss.enable_display_power_gating(
-			stream->ctx, stream->controller_idx, dcb,
+		pipe_ctx->stream->ctx, pipe_ctx->pipe_idx, dcb,
 			PIPE_GATING_CONTROL_ENABLE);
 }
 
-static void reset_hw_ctx(struct dc *dc,
-		struct validate_context *context,
-		uint8_t target_count)
+static void reset_hw_ctx(
+		struct dc *dc,
+		struct validate_context *new_context)
 {
 	uint8_t i;
-	/* look up the targets that have been removed since last commit */
-	for (i = 0; i < dc->current_context.target_count; i++) {
-		const struct core_target *core_target =
-			dc->current_context.targets[i];
-		struct core_stream *core_stream =
-			DC_STREAM_TO_CORE(core_target->public.streams[0]);
-		uint8_t controller_idx = core_stream->controller_idx;
-
-		if (context->res_ctx.controller_ctx[controller_idx].stream &&
-				!context->res_ctx.controller_ctx[controller_idx]
-				.flags.timing_changed)
-			continue;
 
-		reset_single_stream_hw_ctx(dc, core_stream, &dc->current_context);
+	/* look up the targets that have been removed since last commit */
+	for (i = 0; i < MAX_PIPES; i++) {
+		struct pipe_ctx *pipe_ctx_old =
+			&dc->current_context.res_ctx.pipe_ctx[i];
+		struct pipe_ctx *pipe_ctx = &new_context->res_ctx.pipe_ctx[i];
+
+		if (pipe_ctx_old->stream && !pipe_ctx->stream)
+			reset_single_pipe_hw_ctx(
+				dc, pipe_ctx_old, &dc->current_context);
 	}
 }
 
@@ -1601,7 +1518,6 @@ static void power_down(struct dc *dc)
 {
 	power_down_all_hw_blocks(dc);
 	disable_vga_and_power_gate_all_controllers(dc);
-
 }
 
 static bool wait_for_reset_trigger_to_occur(
@@ -1697,7 +1613,7 @@ static const struct hw_sequencer_funcs dce110_funcs = {
 	.apply_ctx_to_hw = apply_ctx_to_hw,
 	.reset_hw_ctx = reset_hw_ctx,
 	.set_plane_config = set_plane_config,
-	.update_plane_address = update_plane_address,
+	.update_plane_addrs = update_plane_addrs,
 	.set_gamma_correction = set_gamma_ramp,
 	.power_down = power_down,
 	.enable_accelerated_mode = enable_accelerated_mode,
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c
index 3c78431..9efed4f 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.c
@@ -1168,27 +1168,28 @@ bool dce110_link_encoder_construct(
 
 bool dce110_link_encoder_validate_output_with_stream(
 	struct link_encoder *enc,
-	struct core_stream *stream)
+	struct pipe_ctx *pipe_ctx)
 {
+	struct core_stream *stream = pipe_ctx->stream;
 	struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
 	bool is_valid;
 
-	switch (stream->signal) {
+	switch (pipe_ctx->signal) {
 	case SIGNAL_TYPE_DVI_SINGLE_LINK:
 	case SIGNAL_TYPE_DVI_DUAL_LINK:
 		is_valid = validate_dvi_output(
 			enc110,
 			stream->sink->link->public.connector_signal,
-			stream->signal,
+			pipe_ctx->signal,
 			&stream->public.timing);
 	break;
 	case SIGNAL_TYPE_HDMI_TYPE_A:
 		is_valid = validate_hdmi_output(
 				enc110,
 				&stream->public.timing,
-				stream->max_tmds_clk_from_edid_in_mhz,
-				stream->max_hdmi_deep_color,
-				stream->max_hdmi_pixel_clock);
+				pipe_ctx->max_tmds_clk_from_edid_in_mhz,
+				pipe_ctx->max_hdmi_deep_color,
+				pipe_ctx->max_hdmi_pixel_clock);
 	break;
 	case SIGNAL_TYPE_RGB:
 		is_valid = validate_rgb_output(
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.h b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.h
index 64a81f2..bbddd0b 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.h
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_link_encoder.h
@@ -81,7 +81,7 @@ bool dce110_link_encoder_construct(
 
 bool dce110_link_encoder_validate_output_with_stream(
 	struct link_encoder *enc,
-	struct core_stream *stream);
+	struct pipe_ctx *pipe_ctx);
 
 /****************** HW programming ************************/
 
diff --git a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c
index 9e2b5d9..4fdf1f0 100644
--- a/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/dal/dc/dce110/dce110_resource.c
@@ -477,7 +477,7 @@ void dce110_destruct_resource_pool(struct resource_pool *pool)
 {
 	unsigned int i;
 
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		if (pool->opps[i] != NULL)
 			dce110_opp_destroy(&pool->opps[i]);
 
@@ -567,12 +567,13 @@ static enum audio_dto_source translate_to_dto_source(enum controller_id crtc_id)
 }
 
 static void build_audio_output(
-	const struct core_stream *stream,
+	const struct pipe_ctx *pipe_ctx,
 	struct audio_output *audio_output)
 {
-	audio_output->engine_id = stream->stream_enc->id;
+	const struct core_stream *stream = pipe_ctx->stream;
+	audio_output->engine_id = pipe_ctx->stream_enc->id;
 
-	audio_output->signal = stream->signal;
+	audio_output->signal = pipe_ctx->signal;
 
 	/* audio_crtc_info  */
 
@@ -604,42 +605,43 @@ static void build_audio_output(
 		stream->public.timing.display_color_depth;
 
 	audio_output->crtc_info.requested_pixel_clock =
-			stream->pix_clk_params.requested_pix_clk;
+			pipe_ctx->pix_clk_params.requested_pix_clk;
 
 	/* TODO - Investigate why calculated pixel clk has to be
 	 * requested pixel clk */
 	audio_output->crtc_info.calculated_pixel_clock =
-			stream->pix_clk_params.requested_pix_clk;
+			pipe_ctx->pix_clk_params.requested_pix_clk;
 
-	if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT ||
-			stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
+	if (pipe_ctx->signal == SIGNAL_TYPE_DISPLAY_PORT ||
+			pipe_ctx->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
 		audio_output->pll_info.dp_dto_source_clock_in_khz =
 			dal_display_clock_get_dp_ref_clk_frequency(
-				stream->dis_clk);
+				pipe_ctx->dis_clk);
 	}
 
 	audio_output->pll_info.feed_back_divider =
-			stream->pll_settings.feedback_divider;
+			pipe_ctx->pll_settings.feedback_divider;
 
 	audio_output->pll_info.dto_source =
 		translate_to_dto_source(
-			stream->controller_idx + 1);
+			pipe_ctx->pipe_idx + 1);
 
 	/* TODO hard code to enable for now. Need get from stream */
 	audio_output->pll_info.ss_enabled = true;
 
 	audio_output->pll_info.ss_percentage =
-			stream->pll_settings.ss_percentage;
+			pipe_ctx->pll_settings.ss_percentage;
 }
 
 static void get_pixel_clock_parameters(
-	const struct core_stream *stream,
+	const struct pipe_ctx *pipe_ctx,
 	struct pixel_clk_params *pixel_clk_params)
 {
+	const struct core_stream *stream = pipe_ctx->stream;
 	pixel_clk_params->requested_pix_clk = stream->public.timing.pix_clk_khz;
 	pixel_clk_params->encoder_object_id = stream->sink->link->link_enc->id;
 	pixel_clk_params->signal_type = stream->sink->public.sink_signal;
-	pixel_clk_params->controller_id = stream->controller_idx + 1;
+	pixel_clk_params->controller_id = pipe_ctx->pipe_idx + 1;
 	/* TODO: un-hardcode*/
 	pixel_clk_params->requested_sym_clk = LINK_RATE_LOW *
 		LINK_RATE_REF_FREQ_IN_KHZ;
@@ -649,20 +651,20 @@ static void get_pixel_clock_parameters(
 	pixel_clk_params->flags.DISPLAY_BLANKED = 1;
 }
 
-static enum dc_status build_stream_hw_param(struct core_stream *stream)
+static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
 {
 	/*TODO: unhardcode*/
-	stream->max_tmds_clk_from_edid_in_mhz = 0;
-	stream->max_hdmi_deep_color = COLOR_DEPTH_121212;
-	stream->max_hdmi_pixel_clock = 600000;
+	pipe_ctx->max_tmds_clk_from_edid_in_mhz = 0;
+	pipe_ctx->max_hdmi_deep_color = COLOR_DEPTH_121212;
+	pipe_ctx->max_hdmi_pixel_clock = 600000;
 
-	get_pixel_clock_parameters(stream, &stream->pix_clk_params);
-	stream->clock_source->funcs->get_pix_clk_dividers(
-		stream->clock_source,
-		&stream->pix_clk_params,
-		&stream->pll_settings);
+	get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->pix_clk_params);
+	pipe_ctx->clock_source->funcs->get_pix_clk_dividers(
+		pipe_ctx->clock_source,
+		&pipe_ctx->pix_clk_params,
+		&pipe_ctx->pll_settings);
 
-	build_audio_output(stream, &stream->audio_output);
+	build_audio_output(pipe_ctx, &pipe_ctx->audio_output);
 
 	return DC_OK;
 }
@@ -672,7 +674,7 @@ static enum dc_status validate_mapped_resource(
 		struct validate_context *context)
 {
 	enum dc_status status = DC_OK;
-	uint8_t i, j;
+	uint8_t i, j, k;
 
 	for (i = 0; i < context->target_count; i++) {
 		struct core_target *target = context->targets[i];
@@ -683,30 +685,41 @@ static enum dc_status validate_mapped_resource(
 				DC_STREAM_TO_CORE(target->public.streams[j]);
 			struct core_link *link = stream->sink->link;
 
-			if (!stream->tg->funcs->validate_timing(
-					stream->tg, &stream->public.timing))
-				return DC_FAIL_CONTROLLER_VALIDATE;
+			for (k = 0; k < MAX_PIPES; k++) {
+				struct pipe_ctx *pipe_ctx =
+					&context->res_ctx.pipe_ctx[k];
+
+				if (context->res_ctx.pipe_ctx[k].stream != stream)
+					continue;
+
+				if (!pipe_ctx->tg->funcs->validate_timing(
+						pipe_ctx->tg, &stream->public.timing))
+					return DC_FAIL_CONTROLLER_VALIDATE;
 
-			status = build_stream_hw_param(stream);
+				status = build_pipe_hw_param(pipe_ctx);
 
-			if (status != DC_OK)
-				return status;
+				if (status != DC_OK)
+					return status;
 
-			if (!link->link_enc->funcs->validate_output_with_stream(
-					link->link_enc,
-					stream))
-				return DC_FAIL_ENC_VALIDATE;
+				if (!link->link_enc->funcs->validate_output_with_stream(
+						link->link_enc,
+						pipe_ctx))
+					return DC_FAIL_ENC_VALIDATE;
 
-			/* TODO: validate audio ASIC caps, encoder */
+				/* TODO: validate audio ASIC caps, encoder */
 
-			status = dc_link_validate_mode_timing(stream->sink,
-					link,
-					&stream->public.timing);
+				status = dc_link_validate_mode_timing(stream->sink,
+						link,
+						&stream->public.timing);
 
-			if (status != DC_OK)
-				return status;
+				if (status != DC_OK)
+					return status;
 
-			build_info_frame(stream);
+				build_info_frame(pipe_ctx);
+
+				/* do not need to validate non root pipes */
+				break;
+			}
 		}
 	}
 
@@ -717,7 +730,7 @@ enum dc_status dce110_validate_bandwidth(
 	const struct dc *dc,
 	struct validate_context *context)
 {
-	uint8_t i, j;
+	uint8_t i;
 	enum dc_status result = DC_ERROR_UNEXPECTED;
 	uint8_t number_of_displays = 0;
 	uint8_t max_htaps = 1;
@@ -727,76 +740,75 @@ enum dc_status dce110_validate_bandwidth(
 
 	memset(&context->bw_mode_data, 0, sizeof(context->bw_mode_data));
 
-	for (i = 0; i < context->target_count; i++) {
-		struct core_target *target = context->targets[i];
-		for (j = 0; j < target->public.stream_count; j++) {
-			struct core_stream *stream =
-				DC_STREAM_TO_CORE(target->public.streams[j]);
-			struct bw_calcs_input_single_display *disp = &context->
-				bw_mode_data.displays_data[number_of_displays];
-
-			if (target->status.surface_count == 0) {
-				disp->graphics_scale_ratio = bw_int_to_fixed(1);
-				disp->graphics_h_taps = 2;
-				disp->graphics_v_taps = 2;
-
-				/* TODO: remove when bw formula accepts taps per
-				 * display
-				 */
-				if (max_vtaps < 2)
-					max_vtaps = 2;
-				if (max_htaps < 2)
-					max_htaps = 2;
-
-			} else {
-				disp->graphics_scale_ratio =
-					fixed31_32_to_bw_fixed(
-						stream->ratios.vert.value);
-				disp->graphics_h_taps = stream->taps.h_taps;
-				disp->graphics_v_taps = stream->taps.v_taps;
-
-				/* TODO: remove when bw formula accepts taps per
-				 * display
-				 */
-				if (max_vtaps < stream->taps.v_taps)
-					max_vtaps = stream->taps.v_taps;
-				if (max_htaps < stream->taps.h_taps)
-					max_htaps = stream->taps.h_taps;
-			}
+	for (i = 0; i < MAX_PIPES; i++) {
+		struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
+		struct bw_calcs_input_single_display *disp = &context->
+			bw_mode_data.displays_data[number_of_displays];
+
+		if (pipe_ctx->stream == NULL)
+			continue;
 
-			disp->graphics_src_width =
-					stream->public.timing.h_addressable;
-			disp->graphics_src_height =
-					stream->public.timing.v_addressable;
-			disp->h_total = stream->public.timing.h_total;
-			disp->pixel_rate = bw_frc_to_fixed(
-				stream->public.timing.pix_clk_khz, 1000);
-
-			/*TODO: get from surface*/
-			disp->graphics_bytes_per_pixel = 4;
-			disp->graphics_tiling_mode = bw_def_tiled;
-
-			/* DCE11 defaults*/
-			disp->graphics_lb_bpc = 10;
-			disp->graphics_interlace_mode = false;
-			disp->fbc_enable = false;
-			disp->lpt_enable = false;
-			disp->graphics_stereo_mode = bw_def_mono;
-			disp->underlay_mode = bw_def_none;
-
-			/*All displays will be synchronized if timings are all
-			 * the same
+		if (pipe_ctx->ratios.vert.value == 0) {
+			disp->graphics_scale_ratio = bw_int_to_fixed(1);
+			disp->graphics_h_taps = 2;
+			disp->graphics_v_taps = 2;
+
+			/* TODO: remove when bw formula accepts taps per
+			 * display
+			 */
+			if (max_vtaps < 2)
+				max_vtaps = 2;
+			if (max_htaps < 2)
+				max_htaps = 2;
+
+		} else {
+			disp->graphics_scale_ratio =
+				fixed31_32_to_bw_fixed(
+					pipe_ctx->ratios.vert.value);
+			disp->graphics_h_taps = pipe_ctx->taps.h_taps;
+			disp->graphics_v_taps = pipe_ctx->taps.v_taps;
+
+			/* TODO: remove when bw formula accepts taps per
+			 * display
 			 */
-			if (number_of_displays != 0 && all_displays_in_sync)
-				if (dm_memcmp(&prev_timing,
-					&stream->public.timing,
-					sizeof(struct dc_crtc_timing))!= 0)
-					all_displays_in_sync = false;
-			if (number_of_displays == 0)
-				prev_timing = stream->public.timing;
-
-			number_of_displays++;
+			if (max_vtaps < pipe_ctx->taps.v_taps)
+				max_vtaps = pipe_ctx->taps.v_taps;
+			if (max_htaps < pipe_ctx->taps.h_taps)
+				max_htaps = pipe_ctx->taps.h_taps;
 		}
+
+		disp->graphics_src_width =
+			pipe_ctx->stream->public.timing.h_addressable;
+		disp->graphics_src_height =
+			pipe_ctx->stream->public.timing.v_addressable;
+		disp->h_total = pipe_ctx->stream->public.timing.h_total;
+		disp->pixel_rate = bw_frc_to_fixed(
+			pipe_ctx->stream->public.timing.pix_clk_khz, 1000);
+
+		/*TODO: get from surface*/
+		disp->graphics_bytes_per_pixel = 4;
+		disp->graphics_tiling_mode = bw_def_tiled;
+
+		/* DCE11 defaults*/
+		disp->graphics_lb_bpc = 10;
+		disp->graphics_interlace_mode = false;
+		disp->fbc_enable = false;
+		disp->lpt_enable = false;
+		disp->graphics_stereo_mode = bw_def_mono;
+		disp->underlay_mode = bw_def_none;
+
+		/*All displays will be synchronized if timings are all
+		 * the same
+		 */
+		if (number_of_displays != 0 && all_displays_in_sync)
+			if (dm_memcmp(&prev_timing,
+				&pipe_ctx->stream->public.timing,
+				sizeof(struct dc_crtc_timing)) != 0)
+				all_displays_in_sync = false;
+		if (number_of_displays == 0)
+			prev_timing = pipe_ctx->stream->public.timing;
+
+		number_of_displays++;
 	}
 
 	/* TODO: remove when bw formula accepts taps per
@@ -813,7 +825,7 @@ enum dc_status dce110_validate_bandwidth(
 		dc->ctx->logger,
 		LOG_MAJOR_BWM,
 		LOG_MINOR_BWM_REQUIRED_BANDWIDTH_CALCS,
-		"%s: start\n",
+		"%s: start",
 		__func__);
 
 	if (!bw_calcs(
@@ -891,14 +903,17 @@ static void set_target_unchanged(
 		struct validate_context *context,
 		uint8_t target_idx)
 {
-	uint8_t i;
+	uint8_t i, j;
 	struct core_target *target = context->targets[target_idx];
 	context->target_flags[target_idx].unchanged = true;
 	for (i = 0; i < target->public.stream_count; i++) {
-		struct core_stream *core_stream =
+		struct core_stream *stream =
 			DC_STREAM_TO_CORE(target->public.streams[i]);
-		uint8_t index = core_stream->controller_idx;
-		context->res_ctx.controller_ctx[index].flags.unchanged = true;
+		for (j = 0; j < MAX_PIPES; j++) {
+			if (context->res_ctx.pipe_ctx[j].stream == stream)
+				context->res_ctx.pipe_ctx[j].flags.unchanged =
+									true;
+		}
 	}
 }
 
@@ -906,24 +921,7 @@ static enum dc_status map_clock_resources(
 		const struct dc *dc,
 		struct validate_context *context)
 {
-	uint8_t i, j;
-
-	/* mark resources used for targets that are already active */
-	for (i = 0; i < context->target_count; i++) {
-		struct core_target *target = context->targets[i];
-
-		if (!context->target_flags[i].unchanged)
-			continue;
-
-		for (j = 0; j < target->public.stream_count; j++) {
-			struct core_stream *stream =
-				DC_STREAM_TO_CORE(target->public.streams[j]);
-
-			reference_clock_source(
-				&context->res_ctx,
-				stream->clock_source);
-		}
-	}
+	uint8_t i, j, k;
 
 	/* acquire new resources */
 	for (i = 0; i < context->target_count; i++) {
@@ -936,24 +934,35 @@ static enum dc_status map_clock_resources(
 			struct core_stream *stream =
 				DC_STREAM_TO_CORE(target->public.streams[j]);
 
-			if (dc_is_dp_signal(stream->signal)
-				|| stream->signal == SIGNAL_TYPE_VIRTUAL)
-				stream->clock_source = context->res_ctx.
-					pool.clock_sources[DCE110_CLK_SRC_EXT];
-			else
-				stream->clock_source =
-					find_used_clk_src_for_sharing(
-							context, stream);
-			if (stream->clock_source == NULL)
-				stream->clock_source =
-					find_first_free_pll(&context->res_ctx);
-
-			if (stream->clock_source == NULL)
-				return DC_NO_CLOCK_SOURCE_RESOURCE;
-
-			reference_clock_source(
-					&context->res_ctx,
-					stream->clock_source);
+			for (k = 0; k < MAX_PIPES; k++) {
+				struct pipe_ctx *pipe_ctx =
+					&context->res_ctx.pipe_ctx[k];
+
+				if (context->res_ctx.pipe_ctx[k].stream != stream)
+					continue;
+
+				if (dc_is_dp_signal(pipe_ctx->signal)
+					|| pipe_ctx->signal == SIGNAL_TYPE_VIRTUAL)
+					pipe_ctx->clock_source = context->res_ctx.
+						pool.clock_sources[DCE110_CLK_SRC_EXT];
+				else
+					pipe_ctx->clock_source =
+						find_used_clk_src_for_sharing(
+							&context->res_ctx, pipe_ctx);
+				if (pipe_ctx->clock_source == NULL)
+					pipe_ctx->clock_source =
+						find_first_free_pll(&context->res_ctx);
+
+				if (pipe_ctx->clock_source == NULL)
+					return DC_NO_CLOCK_SOURCE_RESOURCE;
+
+				reference_clock_source(
+						&context->res_ctx,
+						pipe_ctx->clock_source);
+
+				/* only one cs per stream regardless of mpo */
+				break;
+			}
 		}
 	}
 
@@ -971,24 +980,30 @@ enum dc_status dce110_validate_with_context(
 	struct dc_context *dc_ctx = dc->ctx;
 
 	for (i = 0; i < set_count; i++) {
+		bool unchanged = false;
+
 		context->targets[i] = DC_TARGET_TO_CORE(set[i].target);
+		context->target_count++;
 
 		for (j = 0; j < dc->current_context.target_count; j++)
-			if (dc->current_context.targets[j] == context->targets[i])
+			if (dc->current_context.targets[j]
+						== context->targets[i]) {
+				unchanged = true;
 				set_target_unchanged(context, i);
-
-		if (!context->target_flags[i].unchanged)
-			if (!logical_attach_surfaces_to_target(
-							(struct dc_surface **)set[i].surfaces,
-							set[i].surface_count,
-							&context->targets[i]->public)) {
+				context->target_status[i] =
+					dc->current_context.target_status[j];
+			}
+		if (!unchanged)
+			if (!attach_surfaces_to_context(
+					(struct dc_surface **)set[i].surfaces,
+					set[i].surface_count,
+					&context->targets[i]->public,
+					context)) {
 				DC_ERROR("Failed to attach surface to target!\n");
 				return DC_FAIL_ATTACH_SURFACES;
 			}
 	}
 
-	context->target_count = set_count;
-
 	context->res_ctx.pool = dc->res_pool;
 
 	result = map_resources(dc, context);
@@ -1073,7 +1088,7 @@ bool dce110_construct_resource_pool(
 
 	}
 
-	pool->controller_count =
+	pool->pipe_count =
 		dal_adapter_service_get_func_controllers_num(adapter_serv);
 	pool->stream_enc_count = dal_adapter_service_get_stream_engines_num(
 			adapter_serv);
@@ -1084,7 +1099,7 @@ bool dce110_construct_resource_pool(
 		goto filter_create_fail;
 	}
 
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		pool->timing_generators[i] = dce110_timing_generator_create(
 				adapter_serv, ctx, i, &dce110_tg_offsets[i]);
 		if (pool->timing_generators[i] == NULL) {
@@ -1134,7 +1149,7 @@ bool dce110_construct_resource_pool(
 	audio_init_data.as = adapter_serv;
 	audio_init_data.ctx = ctx;
 	pool->audio_count = 0;
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		struct graphics_object_id obj_id;
 
 		obj_id = dal_adapter_service_enum_audio_object(adapter_serv, i);
@@ -1192,13 +1207,13 @@ stream_enc_create_fail:
 	}
 
 audio_create_fail:
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		if (pool->audios[i] != NULL)
 			dal_audio_destroy(&pool->audios[i]);
 	}
 
 controller_create_fail:
-	for (i = 0; i < pool->controller_count; i++) {
+	for (i = 0; i < pool->pipe_count; i++) {
 		if (pool->opps[i] != NULL)
 			dce110_opp_destroy(&pool->opps[i]);
 
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/core_types.h b/drivers/gpu/drm/amd/dal/dc/inc/core_types.h
index e3dbaeb..18bd2da 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/core_types.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/core_types.h
@@ -39,12 +39,10 @@ struct core_stream;
 	container_of(dc_target, struct core_target, public)
 
 #define MAX_PIPES 6
-#define MAX_STREAMS 6
 #define MAX_CLOCK_SOURCES 7
 
 struct core_target {
 	struct dc_target public;
-	struct dc_target_status status;
 
 	struct dc_context *ctx;
 };
@@ -90,53 +88,12 @@ struct core_stream {
 	struct dc_stream public;
 
 	/* field internal to DC */
+	struct dc_context *ctx;
 	const struct core_sink *sink;
 
-	struct clock_source *clock_source;
-
-	struct mem_input *mi;
-	struct input_pixel_processor *ipp;
-	struct transform *xfm;
-	struct output_pixel_processor *opp;
-	struct timing_generator *tg;
-	struct stream_encoder *stream_enc;
-	struct display_clock *dis_clk;
-
-	struct overscan_info overscan;
-	struct scaling_ratios ratios;
-	struct rect viewport;
-	struct scaling_taps taps;
-	enum pixel_format format;
-
-	uint8_t controller_idx;
-
-	struct audio *audio;
-
-	enum signal_type signal;
-
-	/* TODO: move these members into appropriate places (work in progress)*/
-	/* timing validation (HDMI only) */
-	uint32_t max_tmds_clk_from_edid_in_mhz;
-	/* maximum supported deep color depth for HDMI */
-	enum dc_color_depth max_hdmi_deep_color;
-	/* maximum supported pixel clock for HDMI */
-	uint32_t max_hdmi_pixel_clock;
-	/* end of TODO */
-
-	/*TODO: AUTO merge if possible*/
-	struct pixel_clk_params pix_clk_params;
-	struct pll_settings pll_settings;
-
-	/*fmt*/
-	/*TODO: AUTO new codepath in apply_context to hw to
-	 * generate these bw unrelated/no fail params*/
-	struct bit_depth_reduction_params bit_depth_params;/* used by DCP and FMT */
+	/* used by DCP and FMT */
+	struct bit_depth_reduction_params bit_depth_params;
 	struct clamping_and_pixel_encoding_params clamping;
-	struct hw_info_frame info_frame;
-	struct encoder_info_frame encoder_info_frame;
-
-	struct audio_output audio_output;
-	struct dc_context *ctx;
 
 	struct dc_stream_status status;
 };
@@ -267,13 +224,9 @@ enum dc_status dc_link_validate_mode_timing(
 
 void core_link_resume(struct core_link *link);
 
-void core_link_enable_stream(
-		struct core_link *link,
-		struct core_stream *stream);
+void core_link_enable_stream(struct pipe_ctx *pipe_ctx);
 
-void core_link_disable_stream(
-		struct core_link *link,
-		struct core_stream *stream);
+void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
 
 /********** DAL Core*********************/
 #include "display_clock_interface.h"
@@ -304,10 +257,10 @@ struct resource_pool {
 	struct input_pixel_processor *ipps[MAX_PIPES];
 	struct transform *transforms[MAX_PIPES];
 	struct output_pixel_processor *opps[MAX_PIPES];
-	struct timing_generator *timing_generators[MAX_STREAMS];
+	struct timing_generator *timing_generators[MAX_PIPES];
 	struct stream_encoder *stream_enc[MAX_PIPES * 2];
 
-	uint8_t controller_count;
+	uint8_t pipe_count;
 	uint8_t stream_enc_count;
 
 	union supported_stream_engines stream_engines;
@@ -315,7 +268,7 @@ struct resource_pool {
 	struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
 	uint8_t clk_src_count;
 
-	struct audio *audios[MAX_STREAMS];
+	struct audio *audios[MAX_PIPES];
 	uint8_t audio_count;
 
 	struct display_clock *display_clock;
@@ -325,9 +278,46 @@ struct resource_pool {
 	struct resource_funcs *funcs;
 };
 
-struct controller_ctx {
+struct pipe_ctx {
 	struct core_surface *surface;
 	struct core_stream *stream;
+
+	struct mem_input *mi;
+	struct input_pixel_processor *ipp;
+	struct transform *xfm;
+	struct output_pixel_processor *opp;
+	struct timing_generator *tg;
+
+	struct overscan_info overscan;
+	struct scaling_ratios ratios;
+	struct rect viewport;
+	struct scaling_taps taps;
+	enum pixel_format format;
+
+	struct stream_encoder *stream_enc;
+	struct display_clock *dis_clk;
+	struct clock_source *clock_source;
+
+	struct audio *audio;
+	struct audio_output audio_output;
+
+	enum signal_type signal;
+
+	/* timing validation (HDMI only) */
+	uint32_t max_tmds_clk_from_edid_in_mhz;
+	/* maximum supported deep color depth for HDMI */
+	enum dc_color_depth max_hdmi_deep_color;
+	/* maximum supported pixel clock for HDMI */
+	uint32_t max_hdmi_pixel_clock;
+
+	struct pixel_clk_params pix_clk_params;
+	struct pll_settings pll_settings;
+
+	/*fmt*/
+	struct encoder_info_frame encoder_info_frame;
+
+	uint8_t pipe_idx;
+
 	struct flags {
 		bool unchanged;
 		bool timing_changed;
@@ -336,10 +326,10 @@ struct controller_ctx {
 
 struct resource_context {
 	struct resource_pool pool;
-	struct controller_ctx controller_ctx[MAX_PIPES];
+	struct pipe_ctx pipe_ctx[MAX_PIPES];
 	union supported_stream_engines used_stream_engines;
 	bool is_stream_enc_acquired[MAX_PIPES * 2];
-	bool is_audio_acquired[MAX_STREAMS];
+	bool is_audio_acquired[MAX_PIPES];
 	uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
  };
 
@@ -348,6 +338,7 @@ struct target_flags {
 };
 struct validate_context {
 	struct core_target *targets[MAX_PIPES];
+	struct dc_target_status target_status[MAX_PIPES];
 	struct target_flags target_flags[MAX_PIPES];
 	uint8_t target_count;
 
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/hw_sequencer.h b/drivers/gpu/drm/amd/dal/dc/inc/hw_sequencer.h
index 5dd16dc..8b0afe1 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/hw_sequencer.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/hw_sequencer.h
@@ -39,22 +39,19 @@ enum pipe_gating_control {
 struct hw_sequencer_funcs {
 
 	enum dc_status (*apply_ctx_to_hw)(
-			const struct dc *dc, struct validate_context *context);
+			struct dc *dc, struct validate_context *context);
 
-	void (*reset_hw_ctx)(
-				struct dc *dc,
-				struct validate_context *context,
-				uint8_t target_count);
+	void (*reset_hw_ctx)(struct dc *dc, struct validate_context *context);
 
-	bool (*set_plane_config)(
+	void (*set_plane_config)(
 				const struct dc *dc,
 				struct core_surface *surface,
-				struct core_target *target);
+				struct pipe_ctx *pipe_ctx);
 
-	bool (*update_plane_address)(
-				const struct dc *dc,
-				const struct core_surface *surface,
-				struct core_target *target);
+	void (*update_plane_addrs)(
+		struct dc *dc,
+		struct resource_context *res_ctx,
+		const struct core_surface *surface);
 
 	bool (*set_gamma_correction)(
 				struct input_pixel_processor *ipp,
@@ -93,9 +90,9 @@ struct hw_sequencer_funcs {
 
 	void (*program_bw)(struct dc *dc, struct validate_context *context);
 
-	void (*enable_stream)(struct core_stream *stream);
+	void (*enable_stream)(struct pipe_ctx *pipe_ctx);
 
-	void (*disable_stream)(struct core_stream *stream);
+	void (*disable_stream)(struct pipe_ctx *pipe_ctx);
 
 	void (*enable_fe_clock)(
 		struct dc_context *ctx, uint8_t controller_id, bool enable);
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/link_encoder.h b/drivers/gpu/drm/amd/dal/dc/inc/link_encoder.h
index 54e75dc..d11ef05 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/link_encoder.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/link_encoder.h
@@ -19,6 +19,7 @@ struct link_mst_stream_allocation_table;
 struct dc_link_settings;
 struct link_training_settings;
 struct core_stream;
+struct pipe_ctx;
 
 struct encoder_init_data {
 	struct adapter_service *adapter_service;
@@ -82,8 +83,8 @@ struct link_encoder {
 };
 
 struct link_encoder_funcs {
-	bool (*validate_output_with_stream)(struct link_encoder *enc,
-		struct core_stream *stream);
+	bool (*validate_output_with_stream)(
+		struct link_encoder *enc, struct pipe_ctx *pipe_ctx);
 	void (*hw_init)(struct link_encoder *enc);
 	void (*setup)(struct link_encoder *enc,
 		enum signal_type signal);
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/link_hwss.h b/drivers/gpu/drm/amd/dal/dc/inc/link_hwss.h
index 551caa3..d56b5d1 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/link_hwss.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/link_hwss.h
@@ -49,7 +49,7 @@ void dp_receiver_power_ctrl(struct core_link *link, bool on);
 
 void dp_disable_link_phy(struct core_link *link, enum signal_type signal);
 
-void dp_disable_link_phy_mst(struct core_link *link, struct core_stream *stream);
+void dp_disable_link_phy_mst(struct core_link *link, enum signal_type signal);
 
 bool dp_set_hw_training_pattern(
 	struct core_link *link,
diff --git a/drivers/gpu/drm/amd/dal/dc/inc/resource.h b/drivers/gpu/drm/amd/dal/dc/inc/resource.h
index b4936b4..a7b0032 100644
--- a/drivers/gpu/drm/amd/dal/dc/inc/resource.h
+++ b/drivers/gpu/drm/amd/dal/dc/inc/resource.h
@@ -38,7 +38,7 @@ bool dc_construct_resource_pool(struct adapter_service *adapter_serv,
 
 void build_scaling_params(
 	const struct dc_surface *surface,
-	struct core_stream *stream);
+	struct pipe_ctx *pipe_ctx);
 
 void build_scaling_params_for_context(
 	const struct dc *dc,
@@ -57,13 +57,14 @@ bool is_same_timing(
 	const struct dc_crtc_timing *timing2);
 
 struct clock_source *find_used_clk_src_for_sharing(
-		struct validate_context *context,
-		struct core_stream *stream);
+	struct resource_context *res_ctx,
+	struct pipe_ctx *pipe_ctx);
 
-bool logical_attach_surfaces_to_target(
+bool attach_surfaces_to_context(
 		struct dc_surface *surfaces[],
 		uint8_t surface_count,
-		struct dc_target *dc_target);
+		struct dc_target *dc_target,
+		struct validate_context *context);
 
 void pplib_apply_safe_state(const struct dc *dc);
 
@@ -72,7 +73,7 @@ void pplib_apply_display_requirements(
 	const struct validate_context *context,
 	struct dc_pp_display_configuration *pp_display_cfg);
 
-void build_info_frame(struct core_stream *stream);
+void build_info_frame(struct pipe_ctx *pipe_ctx);
 
 enum dc_status map_resources(
 	const struct dc *dc,
diff --git a/drivers/gpu/drm/amd/dal/dc/virtual/virtual_link_encoder.c b/drivers/gpu/drm/amd/dal/dc/virtual/virtual_link_encoder.c
index 36886a4..0b3b1b8 100644
--- a/drivers/gpu/drm/amd/dal/dc/virtual/virtual_link_encoder.c
+++ b/drivers/gpu/drm/amd/dal/dc/virtual/virtual_link_encoder.c
@@ -31,7 +31,7 @@
 
 static bool virtual_link_encoder_validate_output_with_stream(
 	struct link_encoder *enc,
-	struct core_stream *stream) { return true; }
+	struct pipe_ctx *pipe_ctx) { return true; }
 
 static void virtual_link_encoder_hw_init(struct link_encoder *enc) {}
 
diff --git a/drivers/gpu/drm/amd/dal/include/grph_csc_types.h b/drivers/gpu/drm/amd/dal/include/grph_csc_types.h
index 711b458..5927dd0 100644
--- a/drivers/gpu/drm/amd/dal/include/grph_csc_types.h
+++ b/drivers/gpu/drm/amd/dal/include/grph_csc_types.h
@@ -28,19 +28,6 @@
 
 #include "set_mode_types.h"
 
-enum color_space {
-	COLOR_SPACE_UNKNOWN,
-	COLOR_SPACE_SRGB_FULL_RANGE,
-	COLOR_SPACE_SRGB_LIMITED_RANGE,
-	COLOR_SPACE_YPBPR601,
-	COLOR_SPACE_YPBPR709,
-	COLOR_SPACE_YCBCR601,
-	COLOR_SPACE_YCBCR709,
-	COLOR_SPACE_YCBCR601_YONLY,
-	COLOR_SPACE_YCBCR709_YONLY,
-	COLOR_SPACE_N_MVPU_SUPER_AA,
-};
-
 enum grph_color_adjust_option {
 	GRPH_COLOR_MATRIX_HW_DEFAULT = 1,
 	GRPH_COLOR_MATRIX_SW
-- 
2.7.4