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
|
// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
* KUnit tests for amdgpu_dm_hdcp.c
*
* Copyright 2026 Advanced Micro Devices, Inc.
*/
#include <kunit/test.h>
#include <linux/workqueue.h>
#include <linux/kobject.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/i2c.h>
#include <drm/display/drm_dp_helper.h>
#include "amdgpu.h"
#include "amdgpu_dm.h"
#include "amdgpu_dm_hdcp.h"
#include "amdgpu_dm_kunit_test_helpers.h"
#include "hdcp_psp.h"
static void dummy_work_fn(struct work_struct *work) {}
/* Tests for hdcp_get_content_protection_from_status() */
/**
* dm_test_hdcp_get_cp_disabled_returns_desired - HDCP off maps to DESIRED
* @test: KUnit test context
*
* When encryption status is HDCP_OFF, content_protection should be set
* to DESIRED and the function should return true to indicate an update.
*/
static void dm_test_hdcp_get_cp_disabled_returns_desired(struct kunit *test)
{
unsigned int content_protection = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
bool update;
update = hdcp_get_content_protection_from_status(
DRM_MODE_HDCP_CONTENT_TYPE0,
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF,
&content_protection);
KUNIT_EXPECT_TRUE(test, update);
KUNIT_EXPECT_EQ(test, content_protection,
DRM_MODE_CONTENT_PROTECTION_DESIRED);
}
/**
* dm_test_hdcp_get_cp_type0_returns_enabled - TYPE0 with TYPE0_ON maps to ENABLED
* @test: KUnit test context
*
* When content type is TYPE0 and encryption status is at or below
* HDCP2_TYPE0_ON, content_protection should be set to ENABLED.
*/
static void dm_test_hdcp_get_cp_type0_returns_enabled(struct kunit *test)
{
unsigned int content_protection = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
bool update;
update = hdcp_get_content_protection_from_status(
DRM_MODE_HDCP_CONTENT_TYPE0,
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON,
&content_protection);
KUNIT_EXPECT_TRUE(test, update);
KUNIT_EXPECT_EQ(test, content_protection,
DRM_MODE_CONTENT_PROTECTION_ENABLED);
}
/**
* dm_test_hdcp_get_cp_type1_returns_enabled - TYPE1 with TYPE1_ON maps to ENABLED
* @test: KUnit test context
*
* When content type is TYPE1 and encryption status is exactly
* HDCP2_TYPE1_ON, content_protection should be set to ENABLED.
*/
static void dm_test_hdcp_get_cp_type1_returns_enabled(struct kunit *test)
{
unsigned int content_protection = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
bool update;
update = hdcp_get_content_protection_from_status(
DRM_MODE_HDCP_CONTENT_TYPE1,
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON,
&content_protection);
KUNIT_EXPECT_TRUE(test, update);
KUNIT_EXPECT_EQ(test, content_protection,
DRM_MODE_CONTENT_PROTECTION_ENABLED);
}
/**
* dm_test_hdcp_get_cp_type1_rejects_type0_status - TYPE1 rejects TYPE0_ON
* @test: KUnit test context
*
* When content type is TYPE1 but encryption status is only TYPE0_ON,
* the function should return false and leave content_protection unchanged.
*/
static void dm_test_hdcp_get_cp_type1_rejects_type0_status(struct kunit *test)
{
unsigned int content_protection = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
bool update;
update = hdcp_get_content_protection_from_status(
DRM_MODE_HDCP_CONTENT_TYPE1,
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON,
&content_protection);
KUNIT_EXPECT_FALSE(test, update);
KUNIT_EXPECT_EQ(test, content_protection,
DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
}
/**
* dm_test_hdcp_get_cp_type0_rejects_type1_status - TYPE0 rejects TYPE1_ON
* @test: KUnit test context
*
* When content type is TYPE0 but encryption status exceeds the TYPE0_ON
* boundary (TYPE1_ON), the function should return false.
*/
static void dm_test_hdcp_get_cp_type0_rejects_type1_status(struct kunit *test)
{
unsigned int content_protection = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
bool update;
update = hdcp_get_content_protection_from_status(
DRM_MODE_HDCP_CONTENT_TYPE0,
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON,
&content_protection);
KUNIT_EXPECT_FALSE(test, update);
KUNIT_EXPECT_EQ(test, content_protection,
DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
}
/* Tests for hdcp_get_link_display_adjustments() */
/**
* dm_test_hdcp_get_adjustments_disable_authentication - disable path zeroes adjustments
* @test: KUnit test context
*
* When enable_encryption is false, display_adjust should disable
* authentication and all link_adjust fields should remain zeroed.
*/
static void dm_test_hdcp_get_adjustments_disable_authentication(struct kunit *test)
{
struct mod_hdcp_link_adjustment link_adjust;
struct mod_hdcp_display_adjustment display_adjust;
unsigned int disable;
unsigned int hdcp1_disable;
unsigned int force_type;
hdcp_get_link_display_adjustments(false, DRM_MODE_HDCP_CONTENT_TYPE0,
false, false, false, &link_adjust, &display_adjust);
disable = display_adjust.disable;
hdcp1_disable = link_adjust.hdcp1.disable;
force_type = link_adjust.hdcp2.force_type;
KUNIT_EXPECT_EQ(test, disable,
MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION);
KUNIT_EXPECT_EQ(test, link_adjust.auth_delay, 0);
KUNIT_EXPECT_EQ(test, link_adjust.retry_limit, 0);
KUNIT_EXPECT_EQ(test, hdcp1_disable, 0);
KUNIT_EXPECT_EQ(test, force_type, 0);
}
/**
* dm_test_hdcp_get_adjustments_type0_policy - TYPE0 enables HDCP1 and forces TYPE0
* @test: KUnit test context
*
* When encryption is enabled with content TYPE0, hdcp1 should remain
* enabled, force_type should be TYPE_0, and sw_locality_fallback should
* be propagated from the input parameter.
*/
static void dm_test_hdcp_get_adjustments_type0_policy(struct kunit *test)
{
struct mod_hdcp_link_adjustment link_adjust;
struct mod_hdcp_display_adjustment display_adjust;
unsigned int disable;
unsigned int hdcp1_disable;
unsigned int force_type;
hdcp_get_link_display_adjustments(true, DRM_MODE_HDCP_CONTENT_TYPE0,
false, false, true, &link_adjust, &display_adjust);
disable = display_adjust.disable;
hdcp1_disable = link_adjust.hdcp1.disable;
force_type = link_adjust.hdcp2.force_type;
KUNIT_EXPECT_EQ(test, disable,
MOD_HDCP_DISPLAY_NOT_DISABLE);
KUNIT_EXPECT_EQ(test, link_adjust.auth_delay, 2);
KUNIT_EXPECT_EQ(test, link_adjust.retry_limit, MAX_NUM_OF_ATTEMPTS);
KUNIT_EXPECT_EQ(test, hdcp1_disable, 0);
KUNIT_EXPECT_EQ(test, force_type,
MOD_HDCP_FORCE_TYPE_0);
KUNIT_EXPECT_FALSE(test, link_adjust.hdcp2.use_fw_locality_check);
KUNIT_EXPECT_TRUE(test, link_adjust.hdcp2.use_sw_locality_fallback);
}
/**
* dm_test_hdcp_get_adjustments_type1_policy - TYPE1 disables HDCP1 and forces TYPE1
* @test: KUnit test context
*
* When encryption is enabled with content TYPE1, hdcp1 should be
* disabled, force_type should be TYPE_1, and fw_locality_check should
* be enabled when hdcp_lc_force_fw_enable is set.
*/
static void dm_test_hdcp_get_adjustments_type1_policy(struct kunit *test)
{
struct mod_hdcp_link_adjustment link_adjust;
struct mod_hdcp_display_adjustment display_adjust;
unsigned int disable;
unsigned int hdcp1_disable;
unsigned int force_type;
hdcp_get_link_display_adjustments(true, DRM_MODE_HDCP_CONTENT_TYPE1,
false, true, false, &link_adjust, &display_adjust);
disable = display_adjust.disable;
hdcp1_disable = link_adjust.hdcp1.disable;
force_type = link_adjust.hdcp2.force_type;
KUNIT_EXPECT_EQ(test, disable,
MOD_HDCP_DISPLAY_NOT_DISABLE);
KUNIT_EXPECT_EQ(test, link_adjust.auth_delay, 2);
KUNIT_EXPECT_EQ(test, link_adjust.retry_limit, MAX_NUM_OF_ATTEMPTS);
KUNIT_EXPECT_EQ(test, hdcp1_disable, 1);
KUNIT_EXPECT_EQ(test, force_type,
MOD_HDCP_FORCE_TYPE_1);
KUNIT_EXPECT_TRUE(test, link_adjust.hdcp2.use_fw_locality_check);
KUNIT_EXPECT_FALSE(test, link_adjust.hdcp2.use_sw_locality_fallback);
}
/**
* dm_test_hdcp_get_adjustments_fused_io_enables_fw_check - fused_io enables FW locality check
* @test: KUnit test context
*
* When fused_io_supported is true, use_fw_locality_check should be
* enabled regardless of hdcp_lc_force_fw_enable.
*/
static void dm_test_hdcp_get_adjustments_fused_io_enables_fw_check(struct kunit *test)
{
struct mod_hdcp_link_adjustment link_adjust;
struct mod_hdcp_display_adjustment display_adjust;
hdcp_get_link_display_adjustments(true, DRM_MODE_HDCP_CONTENT_TYPE0,
true, false, false, &link_adjust, &display_adjust);
KUNIT_EXPECT_TRUE(test, link_adjust.hdcp2.use_fw_locality_check);
}
/* Tests for process_output() */
/**
* alloc_test_workqueue - allocate a minimal hdcp_workqueue for testing
* @test: KUnit test context for managed allocation
*
* Allocates and initialises a minimal hdcp_workqueue sufficient for
* process_output() testing. Only the three delayed works accessed by
* process_output() are initialised; everything else is zeroed.
*/
static struct hdcp_workqueue *alloc_test_workqueue(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
INIT_DELAYED_WORK(&work->callback_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->watchdog_timer_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->property_validate_dwork, dummy_work_fn);
return work;
}
/**
* dm_test_process_output_property_validate_always_scheduled - validate_dwork always queued
* @test: KUnit test context
*
* process_output() always schedules property_validate_dwork with delay=0,
* which queues the work item directly (bypassing the timer). Uses
* work_pending() rather than delayed_work_pending() to detect this.
*/
static void dm_test_process_output_property_validate_always_scheduled(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
/* No flags set: only property_validate_dwork should be enqueued */
process_output(work);
KUNIT_EXPECT_TRUE(test, work_pending(&work->property_validate_dwork.work));
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->callback_dwork));
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->watchdog_timer_dwork));
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_process_output_callback_needed - callback_needed schedules callback_dwork
* @test: KUnit test context
*
* When output.callback_needed is true, process_output() must schedule
* callback_dwork with the specified delay.
*/
static void dm_test_process_output_callback_needed(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
work->output.callback_needed = true;
work->output.callback_delay = 500;
process_output(work);
KUNIT_EXPECT_TRUE(test, delayed_work_pending(&work->callback_dwork));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_process_output_callback_stop - callback_stop cancels callback_dwork
* @test: KUnit test context
*
* When output.callback_stop is true, process_output() must cancel a
* previously scheduled callback_dwork.
*/
static void dm_test_process_output_callback_stop(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
/* Pre-schedule callback_dwork with a long delay so it won't fire. */
schedule_delayed_work(&work->callback_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->callback_dwork));
work->output.callback_stop = true;
process_output(work);
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->callback_dwork));
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_process_output_watchdog_needed - watchdog_needed schedules watchdog_dwork
* @test: KUnit test context
*
* When output.watchdog_timer_needed is true, process_output() must
* schedule watchdog_timer_dwork with the specified delay.
*/
static void dm_test_process_output_watchdog_needed(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
work->output.watchdog_timer_needed = true;
work->output.watchdog_timer_delay = 1000;
process_output(work);
KUNIT_EXPECT_TRUE(test, delayed_work_pending(&work->watchdog_timer_dwork));
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_process_output_watchdog_stop - watchdog_stop cancels watchdog_dwork
* @test: KUnit test context
*
* When output.watchdog_timer_stop is true, process_output() must cancel
* a previously scheduled watchdog_timer_dwork.
*/
static void dm_test_process_output_watchdog_stop(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
/* Pre-schedule watchdog_timer_dwork with a long delay. */
schedule_delayed_work(&work->watchdog_timer_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->watchdog_timer_dwork));
work->output.watchdog_timer_stop = true;
process_output(work);
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->watchdog_timer_dwork));
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_process_output_callback_and_watchdog_needed - both dworks scheduled independently
* @test: KUnit test context
*
* When both callback_needed and watchdog_timer_needed are set,
* process_output() must schedule both dworks independently.
*/
static void dm_test_process_output_callback_and_watchdog_needed(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
work->output.callback_needed = true;
work->output.callback_delay = 200;
work->output.watchdog_timer_needed = true;
work->output.watchdog_timer_delay = 800;
process_output(work);
KUNIT_EXPECT_TRUE(test, delayed_work_pending(&work->callback_dwork));
KUNIT_EXPECT_TRUE(test, delayed_work_pending(&work->watchdog_timer_dwork));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_process_output_callback_stop_and_needed_requeues - stop+needed requeues callback work
* @test: KUnit test context
*
* When callback_stop and callback_needed are both set, process_output()
* should cancel the previous callback_dwork and queue it again.
*/
static void dm_test_process_output_callback_stop_and_needed_requeues(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
schedule_delayed_work(&work->callback_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->callback_dwork));
work->output.callback_stop = true;
work->output.callback_needed = true;
work->output.callback_delay = 300;
process_output(work);
KUNIT_EXPECT_TRUE(test, delayed_work_pending(&work->callback_dwork));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_process_output_watchdog_stop_and_needed_requeues - stop+needed requeues watchdog work
* @test: KUnit test context
*
* When watchdog_timer_stop and watchdog_timer_needed are both set,
* process_output() should cancel previous watchdog work and queue it again.
*/
static void dm_test_process_output_watchdog_stop_and_needed_requeues(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue(test);
schedule_delayed_work(&work->watchdog_timer_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->watchdog_timer_dwork));
work->output.watchdog_timer_stop = true;
work->output.watchdog_timer_needed = true;
work->output.watchdog_timer_delay = 700;
process_output(work);
KUNIT_EXPECT_TRUE(test, delayed_work_pending(&work->watchdog_timer_dwork));
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/* End of tests for process_output() */
/* Tests for event_property_update() */
/**
* alloc_test_workqueue_for_property_update - allocate minimal workqueue for callback tests
* @test: KUnit test context for managed allocation
*
* Allocates a minimal hdcp_workqueue with property_update_work initialised
* so event_property_update() can resolve container_of() safely. The mutex is
* initialised as well because the connected path takes guard(mutex).
*/
static struct hdcp_workqueue *alloc_test_workqueue_for_property_update(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
mutex_init(&work->mutex);
INIT_WORK(&work->property_update_work, dummy_work_fn);
return work;
}
/**
* alloc_update_connector - connector for event_property_update() tests
* @test: KUnit test context for managed allocation
* @status: drm connector detection status to assign
* @conn_state: drm_connector_state to attach (may be NULL)
* @dev: drm_device to attach as connector->dev (may be NULL)
*
* Allocates an amdgpu_dm_connector wired for the traversal in
* event_property_update(). The caller supplies the state and device so the
* various skip branches (disconnected, no state, no device) and the fully
* connected path can all be exercised.
*/
static struct amdgpu_dm_connector *alloc_update_connector(struct kunit *test,
enum drm_connector_status status,
struct drm_connector_state *conn_state,
struct drm_device *dev)
{
struct amdgpu_dm_connector *aconnector;
aconnector = kunit_kzalloc(test, sizeof(*aconnector), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, aconnector);
aconnector->base.status = status;
aconnector->base.state = conn_state;
aconnector->base.dev = dev;
return aconnector;
}
/**
* dm_test_event_property_update_skips_null_connector - null connector is ignored
* @test: KUnit test context
*
* If aconnector entry is NULL, event_property_update() should skip it
* without modifying encryption_status.
*/
static void dm_test_event_property_update_skips_null_connector(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_update(test);
enum mod_hdcp_encryption_status before;
work->encryption_status[0] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON;
before = work->encryption_status[0];
event_property_update(&work->property_update_work);
KUNIT_EXPECT_EQ(test, work->encryption_status[0], before);
}
/**
* dm_test_event_property_update_skips_disconnected - disconnected is skipped
* @test: KUnit test context
*
* A connector whose status is not connector_status_connected must be skipped
* before any modeset lock is taken, leaving encryption_status untouched.
*/
static void dm_test_event_property_update_skips_disconnected(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_update(test);
struct drm_connector_state *conn_state;
conn_state = kunit_kzalloc(test, sizeof(*conn_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, conn_state);
work->aconnector[1] = alloc_update_connector(test, connector_status_disconnected,
conn_state, NULL);
work->encryption_status[1] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
event_property_update(&work->property_update_work);
KUNIT_EXPECT_EQ(test, work->encryption_status[1],
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON);
}
/**
* dm_test_event_property_update_skips_null_state - missing state is skipped
* @test: KUnit test context
*
* A connected connector without a drm_connector_state must be skipped before
* the modeset lock, leaving encryption_status unchanged.
*/
static void dm_test_event_property_update_skips_null_state(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_update(test);
work->aconnector[2] = alloc_update_connector(test, connector_status_connected,
NULL, NULL);
work->encryption_status[2] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
event_property_update(&work->property_update_work);
KUNIT_EXPECT_EQ(test, work->encryption_status[2],
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON);
}
/**
* dm_test_event_property_update_skips_null_dev - missing device is skipped
* @test: KUnit test context
*
* A connected connector with state but no drm_device must be skipped before
* the modeset lock, leaving encryption_status unchanged.
*/
static void dm_test_event_property_update_skips_null_dev(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_update(test);
struct drm_connector_state *conn_state;
conn_state = kunit_kzalloc(test, sizeof(*conn_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, conn_state);
work->aconnector[3] = alloc_update_connector(test, connector_status_connected,
conn_state, NULL);
work->encryption_status[3] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
event_property_update(&work->property_update_work);
KUNIT_EXPECT_EQ(test, work->encryption_status[3],
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON);
}
/**
* dm_test_event_property_update_desired_when_off - HDCP off maps to DESIRED
* @test: KUnit test context
*
* A fully connected display with HDCP_OFF encryption drives the connected
* path: the modeset lock is taken, hdcp_get_content_protection_from_status()
* reports DRM_MODE_CONTENT_PROTECTION_DESIRED and
* drm_hdcp_update_content_protection() is called. The connector state is
* pre-set to DESIRED so the value is unchanged (no sysfs event) and the deep
* path completes cleanly.
*/
static void dm_test_event_property_update_desired_when_off(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_update(test);
struct drm_connector_state *conn_state;
conn_state = kunit_kzalloc(test, sizeof(*conn_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, conn_state);
conn_state->content_protection = DRM_MODE_CONTENT_PROTECTION_DESIRED;
work->aconnector[0] = alloc_update_connector(test, connector_status_connected,
conn_state, &adev->ddev);
work->encryption_status[0] = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
event_property_update(&work->property_update_work);
KUNIT_EXPECT_EQ(test, conn_state->content_protection,
(unsigned int)DRM_MODE_CONTENT_PROTECTION_DESIRED);
KUNIT_EXPECT_EQ(test, work->encryption_status[0],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
}
/**
* dm_test_event_property_update_enabled_when_encrypted - encrypted maps to ENABLED
* @test: KUnit test context
*
* A fully connected display with TYPE0 content and HDCP1 encryption drives
* the connected path where hdcp_get_content_protection_from_status() reports
* DRM_MODE_CONTENT_PROTECTION_ENABLED. The connector state is pre-set to
* ENABLED so drm_hdcp_update_content_protection() leaves it unchanged.
*/
static void dm_test_event_property_update_enabled_when_encrypted(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_update(test);
struct drm_connector_state *conn_state;
conn_state = kunit_kzalloc(test, sizeof(*conn_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, conn_state);
conn_state->hdcp_content_type = DRM_MODE_HDCP_CONTENT_TYPE0;
conn_state->content_protection = DRM_MODE_CONTENT_PROTECTION_ENABLED;
work->aconnector[0] = alloc_update_connector(test, connector_status_connected,
conn_state, &adev->ddev);
work->encryption_status[0] = MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON;
event_property_update(&work->property_update_work);
KUNIT_EXPECT_EQ(test, conn_state->content_protection,
(unsigned int)DRM_MODE_CONTENT_PROTECTION_ENABLED);
KUNIT_EXPECT_EQ(test, work->encryption_status[0],
MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON);
}
/* End of tests for event_property_update() */
/* Tests for event_callback() */
/**
* alloc_test_workqueue_for_callback - workqueue ready for event_callback()
* @test: KUnit test context for managed allocation
*
* Allocates a minimal hdcp_workqueue with its mutex and the three delayed
* works initialised, as required by the guard(mutex), cancel_delayed_work()
* and process_output() usage inside event_callback().
*/
static struct hdcp_workqueue *alloc_test_workqueue_for_callback(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
mutex_init(&work->mutex);
INIT_DELAYED_WORK(&work->callback_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->watchdog_timer_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->property_validate_dwork, dummy_work_fn);
return work;
}
/**
* dm_test_event_callback_cancels_callback_dwork - callback work is cancelled
* @test: KUnit test context
*
* event_callback() must cancel a previously scheduled callback_dwork. With
* no active hdcp display, mod_hdcp_process_event() leaves output cleared so
* the callback is not requeued and callback_dwork ends up not pending.
*/
static void dm_test_event_callback_cancels_callback_dwork(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_callback(test);
/* Pre-schedule callback_dwork with a long delay so it won't fire. */
schedule_delayed_work(&work->callback_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->callback_dwork));
event_callback(&work->callback_dwork.work);
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->callback_dwork));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_event_callback_schedules_property_validate - process_output() runs
* @test: KUnit test context
*
* event_callback() finishes by calling process_output(), which always
* enqueues property_validate_dwork with delay=0. Verifying it is pending
* proves event_callback() reached process_output() and released the mutex.
*/
static void dm_test_event_callback_schedules_property_validate(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_callback(test);
event_callback(&work->callback_dwork.work);
KUNIT_EXPECT_TRUE(test, work_pending(&work->property_validate_dwork.work));
/* Mutex must be released after the guard scope exits. */
KUNIT_EXPECT_FALSE(test, mutex_is_locked(&work->mutex));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/* End of tests for event_callback() */
/* Tests for event_property_validate() */
/**
* alloc_test_workqueue_for_property_validate - workqueue for validate tests
* @test: KUnit test context for managed allocation
*
* Allocates a minimal hdcp_workqueue with its mutex and property_update_work
* initialised, as required by the guard(mutex) and schedule_work() usage
* inside event_property_validate().
*/
static struct hdcp_workqueue *alloc_test_workqueue_for_property_validate(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
mutex_init(&work->mutex);
INIT_WORK(&work->property_update_work, dummy_work_fn);
return work;
}
/**
* alloc_validate_connector - connector for event_property_validate() tests
* @test: KUnit test context for managed allocation
* @index: drm connector index to assign
* @status: drm connector detection status to assign
* @with_state: whether to attach a zeroed drm_connector_state
*
* Allocates an amdgpu_dm_connector sufficient for the traversal in
* event_property_validate(). mod_hdcp_query_display() has no active display
* so it returns early, leaving the pre-set HDCP_OFF query untouched.
*/
static struct amdgpu_dm_connector *alloc_validate_connector(struct kunit *test,
unsigned int index,
enum drm_connector_status status,
bool with_state)
{
struct amdgpu_dm_connector *aconnector;
aconnector = kunit_kzalloc(test, sizeof(*aconnector), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, aconnector);
aconnector->base.index = index;
aconnector->base.status = status;
if (with_state) {
struct drm_connector_state *conn_state;
conn_state = kunit_kzalloc(test, sizeof(*conn_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, conn_state);
aconnector->base.state = conn_state;
}
return aconnector;
}
/**
* dm_test_event_property_validate_skips_null_connector - null entries ignored
* @test: KUnit test context
*
* With every aconnector entry NULL, event_property_validate() must not
* schedule property_update_work and must leave encryption_status untouched.
*/
static void dm_test_event_property_validate_skips_null_connector(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_validate(test);
work->encryption_status[0] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
event_property_validate(&work->property_validate_dwork.work);
KUNIT_EXPECT_FALSE(test, work_pending(&work->property_update_work));
KUNIT_EXPECT_EQ(test, work->encryption_status[0],
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON);
}
/**
* dm_test_event_property_validate_skips_disconnected - disconnected is skipped
* @test: KUnit test context
*
* A connector whose status is not connector_status_connected must be
* skipped, leaving encryption_status unchanged and no work scheduled.
*/
static void dm_test_event_property_validate_skips_disconnected(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_validate(test);
work->aconnector[1] = alloc_validate_connector(test, 1,
connector_status_disconnected, true);
work->encryption_status[1] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
event_property_validate(&work->property_validate_dwork.work);
KUNIT_EXPECT_FALSE(test, work_pending(&work->property_update_work));
KUNIT_EXPECT_EQ(test, work->encryption_status[1],
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON);
}
/**
* dm_test_event_property_validate_skips_null_state - missing state is skipped
* @test: KUnit test context
*
* A connected connector without a drm_connector_state must be skipped
* before the query, leaving encryption_status unchanged.
*/
static void dm_test_event_property_validate_skips_null_state(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_validate(test);
work->aconnector[2] = alloc_validate_connector(test, 2,
connector_status_connected, false);
work->encryption_status[2] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
event_property_validate(&work->property_validate_dwork.work);
KUNIT_EXPECT_FALSE(test, work_pending(&work->property_update_work));
KUNIT_EXPECT_EQ(test, work->encryption_status[2],
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON);
}
/**
* dm_test_event_property_validate_updates_on_status_change - change triggers update
* @test: KUnit test context
*
* For a connected connector with state, the query returns HDCP_OFF (no
* active hdcp display). When the stored encryption_status differs, it must
* be updated to HDCP_OFF and property_update_work must be scheduled.
*/
static void dm_test_event_property_validate_updates_on_status_change(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_validate(test);
work->aconnector[3] = alloc_validate_connector(test, 3,
connector_status_connected, true);
work->encryption_status[3] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
event_property_validate(&work->property_validate_dwork.work);
KUNIT_EXPECT_EQ(test, work->encryption_status[3],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
KUNIT_EXPECT_TRUE(test, work_pending(&work->property_update_work));
cancel_work_sync(&work->property_update_work);
}
/**
* dm_test_event_property_validate_no_update_when_unchanged - no change, no work
* @test: KUnit test context
*
* For a connected connector with state whose stored encryption_status is
* already HDCP_OFF (matching the query result), event_property_validate()
* must not reschedule property_update_work.
*/
static void dm_test_event_property_validate_no_update_when_unchanged(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_property_validate(test);
work->aconnector[4] = alloc_validate_connector(test, 4,
connector_status_connected, true);
work->encryption_status[4] = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
event_property_validate(&work->property_validate_dwork.work);
KUNIT_EXPECT_EQ(test, work->encryption_status[4],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
KUNIT_EXPECT_FALSE(test, work_pending(&work->property_update_work));
}
/* End of tests for event_property_validate() */
/* Tests for event_watchdog_timer() */
/**
* dm_test_event_watchdog_timer_cancels_watchdog_dwork - watchdog work is cancelled
* @test: KUnit test context
*
* event_watchdog_timer() must cancel a previously scheduled
* watchdog_timer_dwork. With no active hdcp display,
* mod_hdcp_process_event() leaves output cleared so the watchdog is not
* requeued and watchdog_timer_dwork ends up not pending.
*/
static void dm_test_event_watchdog_timer_cancels_watchdog_dwork(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_callback(test);
/* Pre-schedule watchdog_timer_dwork with a long delay so it won't fire. */
schedule_delayed_work(&work->watchdog_timer_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->watchdog_timer_dwork));
event_watchdog_timer(&work->watchdog_timer_dwork.work);
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->watchdog_timer_dwork));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_event_watchdog_timer_schedules_property_validate - process_output() runs
* @test: KUnit test context
*
* event_watchdog_timer() finishes by calling process_output(), which always
* enqueues property_validate_dwork with delay=0. Verifying it is pending
* proves the handler reached process_output() and released the mutex.
*/
static void dm_test_event_watchdog_timer_schedules_property_validate(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_callback(test);
event_watchdog_timer(&work->watchdog_timer_dwork.work);
KUNIT_EXPECT_TRUE(test, work_pending(&work->property_validate_dwork.work));
/* Mutex must be released after the guard scope exits. */
KUNIT_EXPECT_FALSE(test, mutex_is_locked(&work->mutex));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/* End of tests for event_watchdog_timer() */
/* Tests for event_cpirq() */
/**
* alloc_test_workqueue_for_cpirq - workqueue ready for event_cpirq()
* @test: KUnit test context for managed allocation
*
* Allocates a minimal hdcp_workqueue with its mutex, cpirq_work and the
* three delayed works initialised, as required by the guard(mutex) and
* process_output() usage inside event_cpirq().
*/
static struct hdcp_workqueue *alloc_test_workqueue_for_cpirq(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
mutex_init(&work->mutex);
INIT_WORK(&work->cpirq_work, dummy_work_fn);
INIT_DELAYED_WORK(&work->callback_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->watchdog_timer_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->property_validate_dwork, dummy_work_fn);
return work;
}
/**
* dm_test_event_cpirq_schedules_property_validate - process_output() runs
* @test: KUnit test context
*
* event_cpirq() finishes by calling process_output(), which always
* enqueues property_validate_dwork with delay=0. Verifying it is pending
* proves the handler reached process_output() and released the mutex.
*/
static void dm_test_event_cpirq_schedules_property_validate(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_cpirq(test);
event_cpirq(&work->cpirq_work);
KUNIT_EXPECT_TRUE(test, work_pending(&work->property_validate_dwork.work));
/* Mutex must be released after the guard scope exits. */
KUNIT_EXPECT_FALSE(test, mutex_is_locked(&work->mutex));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_event_cpirq_leaves_callback_and_watchdog_idle - only validate is queued
* @test: KUnit test context
*
* With no active hdcp display, mod_hdcp_process_event() leaves output
* cleared, so event_cpirq() must not schedule callback_dwork or
* watchdog_timer_dwork; only property_validate_dwork is enqueued.
*/
static void dm_test_event_cpirq_leaves_callback_and_watchdog_idle(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_for_cpirq(test);
event_cpirq(&work->cpirq_work);
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->callback_dwork));
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->watchdog_timer_dwork));
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/* End of tests for event_cpirq() */
/* Tests for hdcp_handle_cpirq() */
/**
* dm_test_hdcp_handle_cpirq_schedules_work - cpirq handler queues cpirq_work
* @test: KUnit test context
*
* hdcp_handle_cpirq() should schedule cpirq_work for the selected link.
*/
static void dm_test_hdcp_handle_cpirq_schedules_work(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
INIT_WORK(&work->cpirq_work, dummy_work_fn);
hdcp_handle_cpirq(work, 0);
KUNIT_EXPECT_TRUE(test, work_pending(&work->cpirq_work));
cancel_work_sync(&work->cpirq_work);
}
/**
* dm_test_hdcp_handle_cpirq_selects_link_index - only selected link work is queued
* @test: KUnit test context
*
* hdcp_handle_cpirq() should schedule cpirq_work for the selected index
* and not queue unrelated links.
*/
static void dm_test_hdcp_handle_cpirq_selects_link_index(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kcalloc(test, 2, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
INIT_WORK(&work[0].cpirq_work, dummy_work_fn);
INIT_WORK(&work[1].cpirq_work, dummy_work_fn);
hdcp_handle_cpirq(work, 1);
KUNIT_EXPECT_FALSE(test, work_pending(&work[0].cpirq_work));
KUNIT_EXPECT_TRUE(test, work_pending(&work[1].cpirq_work));
cancel_work_sync(&work[1].cpirq_work);
}
/* End of tests for hdcp_handle_cpirq() */
/* Tests for hdcp_update_display() helper logic */
/**
* dm_test_hdcp_update_display_enable_schedules_property_validate - enable path queues validate work
* @test: KUnit test context
*
* hdcp_update_display() should schedule property_validate_dwork when
* encryption is enabled.
*/
static void dm_test_hdcp_update_display_enable_schedules_property_validate(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
INIT_DELAYED_WORK(&work->property_validate_dwork, dummy_work_fn);
work->srm_size = 0;
hdcp_update_display_encryption_control(work, work, 0, true);
KUNIT_EXPECT_TRUE(test, delayed_work_pending(&work->property_validate_dwork));
cancel_delayed_work_sync(&work->property_validate_dwork);
}
/**
* dm_test_hdcp_update_display_disable_resets_status_and_cancels_validate - disable path state update
* @test: KUnit test context
*
* hdcp_update_display() should set encryption_status to HDCP_OFF and
* cancel property_validate_dwork when encryption is disabled.
*/
static void dm_test_hdcp_update_display_disable_resets_status_and_cancels_validate(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
INIT_DELAYED_WORK(&work->property_validate_dwork, dummy_work_fn);
schedule_delayed_work(&work->property_validate_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->property_validate_dwork));
work->encryption_status[3] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
hdcp_update_display_encryption_control(work, work, 3, false);
KUNIT_EXPECT_EQ(test, work->encryption_status[3],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
KUNIT_EXPECT_FALSE(test, delayed_work_pending(&work->property_validate_dwork));
}
/* End of tests for hdcp_update_display() helper logic */
/* Tests for hdcp_create_workqueue() */
/**
* dm_test_hdcp_create_workqueue_zero_max_links_returns_null - zero-link creation fails early
* @test: KUnit test context
*
* When dc->caps.max_links is zero, hdcp_create_workqueue() should fail
* the initial allocation path and return NULL.
*/
static void dm_test_hdcp_create_workqueue_zero_max_links_returns_null(struct kunit *test)
{
struct cp_psp cp_psp = {0};
struct dc *dc;
struct hdcp_workqueue *work;
dc = kunit_kzalloc(test, sizeof(*dc), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, dc);
dc->caps.max_links = 0;
work = hdcp_create_workqueue(NULL, &cp_psp, dc);
KUNIT_EXPECT_PTR_EQ(test, work, NULL);
}
/**
* dm_test_hdcp_create_workqueue_initializes_work - success path wires everything up
* @test: KUnit test context
*
* With a single link, hdcp_create_workqueue() must allocate the workqueue and
* both SRM buffers, record max_link, publish the cp_psp callbacks and handle,
* and point every link's psp handle at the device psp. A non-matching
* dce_version must leave dtm_v3_supported clear. hdcp_destroy() is used to
* tear the workqueue down (it also removes the SRM sysfs file created on the
* device kobject).
*/
static void dm_test_hdcp_create_workqueue_initializes_work(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct cp_psp cp_psp = {0};
struct dc *dc = dm_kunit_alloc_dc_with_ctx(test);
struct hdcp_workqueue *work;
/* sysfs_create_bin_file() needs a real device kobject. */
adev->dev = adev->ddev.dev;
dc->caps.max_links = 1;
/* DCE_VERSION_UNKNOWN (0) is not in the DTM v3 list. */
dc->ctx->dce_version = DCE_VERSION_UNKNOWN;
work = hdcp_create_workqueue(adev, &cp_psp, dc);
KUNIT_ASSERT_NOT_NULL(test, work);
KUNIT_EXPECT_EQ(test, work->max_link, 1);
KUNIT_EXPECT_NOT_NULL(test, work->srm);
KUNIT_EXPECT_NOT_NULL(test, work->srm_temp);
KUNIT_EXPECT_PTR_EQ(test, (void *)cp_psp.funcs.update_stream_config,
(void *)update_config);
KUNIT_EXPECT_PTR_EQ(test, (void *)cp_psp.funcs.enable_assr,
(void *)enable_assr);
KUNIT_EXPECT_PTR_EQ(test, cp_psp.handle, work);
KUNIT_EXPECT_PTR_EQ(test, work[0].hdcp.config.psp.handle, &adev->psp);
KUNIT_EXPECT_EQ(test, work[0].hdcp.config.psp.caps.dtm_v3_supported, 0);
hdcp_destroy(&adev->dev->kobj, work);
}
/**
* dm_test_hdcp_create_workqueue_sets_dtm_v3_for_dcn31 - DCN 3.1 enables DTM v3
* @test: KUnit test context
*
* On a DCN 3.1 device, hdcp_create_workqueue() must set the per-link
* dtm_v3_supported cap; an unmatched dce_version must leave it clear.
*/
static void dm_test_hdcp_create_workqueue_sets_dtm_v3_for_dcn31(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct cp_psp cp_psp = {0};
struct dc *dc = dm_kunit_alloc_dc_with_ctx(test);
struct hdcp_workqueue *work;
adev->dev = adev->ddev.dev;
dc->caps.max_links = 1;
dc->ctx->dce_version = DCN_VERSION_3_1;
work = hdcp_create_workqueue(adev, &cp_psp, dc);
KUNIT_ASSERT_NOT_NULL(test, work);
KUNIT_EXPECT_EQ(test, work[0].hdcp.config.psp.caps.dtm_v3_supported, 1);
hdcp_destroy(&adev->dev->kobj, work);
}
/**
* dm_test_hdcp_create_workqueue_initializes_all_links - loop covers every link
* @test: KUnit test context
*
* With more than one link, hdcp_create_workqueue() must run its init loop for
* every entry: each link records max_link, points its psp handle at the device
* psp and gets the DTM v3 cap set for a matching dce_version.
*/
static void dm_test_hdcp_create_workqueue_initializes_all_links(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct cp_psp cp_psp = {0};
struct dc *dc = dm_kunit_alloc_dc_with_ctx(test);
struct hdcp_workqueue *work;
int i;
adev->dev = adev->ddev.dev;
dc->caps.max_links = 3;
dc->ctx->dce_version = DCN_VERSION_3_1;
work = hdcp_create_workqueue(adev, &cp_psp, dc);
KUNIT_ASSERT_NOT_NULL(test, work);
KUNIT_EXPECT_EQ(test, work->max_link, 3);
for (i = 0; i < 3; i++) {
KUNIT_EXPECT_PTR_EQ(test, work[i].hdcp.config.psp.handle,
&adev->psp);
KUNIT_EXPECT_EQ(test, work[i].hdcp.config.psp.caps.dtm_v3_supported, 1);
}
hdcp_destroy(&adev->dev->kobj, work);
}
/* End of tests for hdcp_create_workqueue() */
/* Tests for hdcp_destroy() */
static ssize_t test_srm_bin_read(struct file *filp, struct kobject *kobj,
const struct bin_attribute *bin_attr, char *buffer,
loff_t pos, size_t count)
{
return 0;
}
static ssize_t test_srm_bin_write(struct file *filp, struct kobject *kobj,
const struct bin_attribute *bin_attr, char *buffer,
loff_t pos, size_t count)
{
return count;
}
/**
* setup_destroy_sysfs - create a kobject with the SRM bin file attached
* @test: KUnit test context
* @work: workqueue whose attr will be registered
*
* hdcp_destroy() calls sysfs_remove_bin_file() on the first entry's attr, so
* a real kobject with the bin file created is required. Returns the kobject,
* which the caller must kobject_put() after hdcp_destroy() has run.
*/
static struct kobject *setup_destroy_sysfs(struct kunit *test,
struct hdcp_workqueue *work)
{
struct kobject *kobj;
int ret;
kobj = kobject_create_and_add("amdgpu_dm_hdcp_test", NULL);
KUNIT_ASSERT_NOT_NULL(test, kobj);
sysfs_bin_attr_init(&work->attr);
work->attr.attr.name = "hdcp_srm";
work->attr.attr.mode = 0664;
work->attr.size = 16;
work->attr.read = test_srm_bin_read;
work->attr.write = test_srm_bin_write;
ret = sysfs_create_bin_file(kobj, &work->attr);
KUNIT_ASSERT_EQ(test, ret, 0);
return kobj;
}
/**
* dm_test_hdcp_destroy_frees_and_removes_sysfs - full teardown path
* @test: KUnit test context
*
* hdcp_destroy() must cancel every link's delayed works, remove the SRM
* sysfs bin file and free srm, srm_temp and the workqueue itself. The
* workqueue and SRM buffers use kzalloc() (not kunit-managed) because
* hdcp_destroy() frees them; KASAN/kmemleak validate there is no leak or
* use-after-free.
*/
static void dm_test_hdcp_destroy_frees_and_removes_sysfs(struct kunit *test)
{
struct hdcp_workqueue *work;
struct kobject *kobj;
work = kzalloc_obj(*work);
KUNIT_ASSERT_NOT_NULL(test, work);
work->max_link = 1;
INIT_DELAYED_WORK(&work->callback_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->watchdog_timer_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->property_validate_dwork, dummy_work_fn);
work->srm = kzalloc(16, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work->srm);
work->srm_temp = kzalloc(16, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work->srm_temp);
kobj = setup_destroy_sysfs(test, work);
/* Pre-schedule a delayed work to exercise the cancel path. */
schedule_delayed_work(&work->callback_dwork, msecs_to_jiffies(10000));
KUNIT_ASSERT_TRUE(test, delayed_work_pending(&work->callback_dwork));
hdcp_destroy(kobj, work);
/* work is freed by hdcp_destroy(); only the kobject remains. */
kobject_put(kobj);
}
/**
* dm_test_hdcp_destroy_zero_links_null_srm - teardown with no links or SRM
* @test: KUnit test context
*
* With max_link == 0 the cancel loop is skipped, and NULL srm/srm_temp make
* the kfree() calls no-ops. hdcp_destroy() must still remove the sysfs bin
* file and free the workqueue without crashing.
*/
static void dm_test_hdcp_destroy_zero_links_null_srm(struct kunit *test)
{
struct hdcp_workqueue *work;
struct kobject *kobj;
work = kzalloc_obj(*work);
KUNIT_ASSERT_NOT_NULL(test, work);
work->max_link = 0;
work->srm = NULL;
work->srm_temp = NULL;
kobj = setup_destroy_sysfs(test, work);
hdcp_destroy(kobj, work);
kobject_put(kobj);
}
/* End of tests for hdcp_destroy() */
/* Tests for link_lock() */
/**
* dm_test_link_lock_locks_and_unlocks_all_links - lock/unlock spans every link
* @test: KUnit test context
*
* link_lock() should acquire the mutex of every entry from 0 to max_link
* when locking, and release all of them when unlocking. A subsequent
* lock/unlock cycle must succeed, proving the mutexes were left released.
*/
static void dm_test_link_lock_locks_and_unlocks_all_links(struct kunit *test)
{
const int num_links = 3;
struct hdcp_workqueue *work;
int i;
work = kunit_kcalloc(test, num_links, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
/* max_link is read from the first element. */
work[0].max_link = num_links;
for (i = 0; i < num_links; i++)
mutex_init(&work[i].mutex);
link_lock(work, true);
for (i = 0; i < num_links; i++)
KUNIT_EXPECT_TRUE(test, mutex_is_locked(&work[i].mutex));
link_lock(work, false);
for (i = 0; i < num_links; i++)
KUNIT_EXPECT_FALSE(test, mutex_is_locked(&work[i].mutex));
/* Mutexes must be re-acquirable after being released. */
link_lock(work, true);
for (i = 0; i < num_links; i++)
KUNIT_EXPECT_TRUE(test, mutex_is_locked(&work[i].mutex));
link_lock(work, false);
}
/**
* dm_test_link_lock_zero_links_is_noop - zero max_link touches no mutexes
* @test: KUnit test context
*
* When max_link is zero, link_lock() must not touch any mutex and simply
* return, leaving the (single) entry's mutex unlocked.
*/
static void dm_test_link_lock_zero_links_is_noop(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
mutex_init(&work->mutex);
work->max_link = 0;
link_lock(work, true);
KUNIT_EXPECT_FALSE(test, mutex_is_locked(&work->mutex));
}
/* End of tests for link_lock() */
/* Tests for psp_get_srm() and psp_set_srm() */
/**
* dm_test_psp_get_srm_uninitialized_returns_null - GET fails when TA not initialized
* @test: KUnit test context
*
* When the HDCP TA context is not initialized, psp_get_srm() must take the
* guard path and return NULL without touching the output parameters or
* invoking the (real) firmware path.
*/
static void dm_test_psp_get_srm_uninitialized_returns_null(struct kunit *test)
{
struct psp_context *psp;
uint32_t srm_version = 0xdead;
uint32_t srm_size = 0xbeef;
uint8_t *srm;
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
/* kzalloc leaves hdcp_context.context.initialized == false */
srm = psp_get_srm(psp, &srm_version, &srm_size);
KUNIT_EXPECT_PTR_EQ(test, srm, NULL);
/* Output parameters must be left untouched on the guard path. */
KUNIT_EXPECT_EQ(test, srm_version, 0xdead);
KUNIT_EXPECT_EQ(test, srm_size, 0xbeef);
}
/**
* dm_test_psp_set_srm_uninitialized_returns_einval - SET fails when TA not initialized
* @test: KUnit test context
*
* When the HDCP TA context is not initialized, psp_set_srm() must take the
* guard path and return -EINVAL without updating srm_version or invoking
* the (real) firmware path.
*/
static void dm_test_psp_set_srm_uninitialized_returns_einval(struct kunit *test)
{
struct psp_context *psp;
uint32_t srm_version = 0xdead;
u8 srm_buf[4] = {0};
int ret;
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
/* kzalloc leaves hdcp_context.context.initialized == false */
ret = psp_set_srm(psp, srm_buf, sizeof(srm_buf), &srm_version);
KUNIT_EXPECT_EQ(test, ret, -EINVAL);
/* srm_version must be left untouched on the guard path. */
KUNIT_EXPECT_EQ(test, srm_version, 0xdead);
}
/**
* dm_test_psp_set_srm_initialized_stages_command - initialized path builds the command
* @test: KUnit test context
*
* With an initialized TA and the SR-IOV VF bypass, psp_hdcp_invoke() is a
* no-op, so the shared command buffer keeps the values psp_set_srm() staged.
* The function must copy the SRM into the SET_SRM in-message, record its size
* and command id, and then fail the response validation (the zeroed reply has
* valid_signature == 0), returning -EINVAL without updating srm_version.
*/
static void dm_test_psp_set_srm_initialized_stages_command(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct ta_hdcp_shared_memory *hdcp_cmd;
struct psp_context *psp;
uint32_t srm_version = 0xdead;
u8 srm_buf[4] = {0x1, 0x2, 0x3, 0x4};
int ret;
KUNIT_ASSERT_NOT_NULL(test, adev);
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
hdcp_cmd = kunit_kzalloc(test, sizeof(*hdcp_cmd), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, hdcp_cmd);
psp->adev = adev;
psp->hdcp_context.context.initialized = true;
psp->hdcp_context.context.mem_context.shared_buf = (uint8_t *)hdcp_cmd;
/* SR-IOV VF makes psp_hdcp_invoke() return early without firmware. */
adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF;
ret = psp_set_srm(psp, srm_buf, sizeof(srm_buf), &srm_version);
/* Response validation fails (valid_signature == 0 in the zeroed reply). */
KUNIT_EXPECT_EQ(test, ret, -EINVAL);
KUNIT_EXPECT_EQ(test, srm_version, 0xdead);
/* The initialized path must have staged the SET_SRM command. */
KUNIT_EXPECT_EQ(test, hdcp_cmd->cmd_id, TA_HDCP_COMMAND__HDCP_SET_SRM);
KUNIT_EXPECT_EQ(test, hdcp_cmd->in_msg.hdcp_set_srm.srm_buf_size,
(uint32_t)sizeof(srm_buf));
KUNIT_EXPECT_MEMEQ(test, hdcp_cmd->in_msg.hdcp_set_srm.srm_buf, srm_buf,
sizeof(srm_buf));
}
/* End of tests for psp_get_srm() and psp_set_srm() */
/* Tests for srm_data_write() and srm_data_read() */
/**
* dm_test_srm_data_write_uninitialized_ta_keeps_srm - write with TA not initialized
* @test: KUnit test context
*
* srm_data_write() always copies the incoming buffer into work->srm_temp and
* returns the byte count. When the HDCP TA is not initialized, psp_set_srm()
* fails, so the committed SRM (work->srm / work->srm_size) must stay untouched.
*/
static void dm_test_srm_data_write_uninitialized_ta_keeps_srm(struct kunit *test)
{
struct hdcp_workqueue *work;
struct psp_context *psp;
u8 buf[4] = {0xAA, 0xBB, 0xCC, 0xDD};
ssize_t ret;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
work->max_link = 1;
mutex_init(&work->mutex);
/* kzalloc leaves hdcp_context.context.initialized == false */
work->hdcp.config.psp.handle = psp;
work->srm_temp = kunit_kzalloc(test, PSP_HDCP_SRM_FIRST_GEN_MAX_SIZE, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work->srm_temp);
work->srm = kunit_kzalloc(test, PSP_HDCP_SRM_FIRST_GEN_MAX_SIZE, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work->srm);
ret = srm_data_write(NULL, NULL, &work->attr, buf, 0, sizeof(buf));
KUNIT_EXPECT_EQ(test, ret, (ssize_t)sizeof(buf));
/* Incoming data is always staged into srm_temp. */
KUNIT_EXPECT_MEMEQ(test, work->srm_temp, buf, sizeof(buf));
/* psp_set_srm() failed, so the committed SRM must be unchanged. */
KUNIT_EXPECT_EQ(test, work->srm_size, 0u);
}
/**
* dm_test_srm_data_read_uninitialized_ta_returns_einval - read with TA not initialized
* @test: KUnit test context
*
* When the HDCP TA is not initialized, psp_get_srm() returns NULL, so
* srm_data_read() must take the error path and return -EINVAL.
*/
static void dm_test_srm_data_read_uninitialized_ta_returns_einval(struct kunit *test)
{
struct hdcp_workqueue *work;
struct psp_context *psp;
u8 buf[4];
ssize_t ret;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
work->max_link = 1;
mutex_init(&work->mutex);
/* kzalloc leaves hdcp_context.context.initialized == false */
work->hdcp.config.psp.handle = psp;
ret = srm_data_read(NULL, NULL, &work->attr, buf, 0, sizeof(buf));
KUNIT_EXPECT_EQ(test, ret, (ssize_t)-EINVAL);
}
/**
* dm_test_srm_data_read_empty_srm_returns_zero - read of an empty SRM
* @test: KUnit test context
*
* With an initialized TA and the SR-IOV VF bypass, psp_hdcp_invoke() is a
* no-op and the zeroed shared buffer yields a SUCCESS status with srm_size 0.
* psp_get_srm() then returns a non-NULL (empty) buffer, so srm_data_read()
* takes the "nothing left to copy" path and returns 0.
*/
static void dm_test_srm_data_read_empty_srm_returns_zero(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct ta_hdcp_shared_memory *hdcp_cmd;
struct hdcp_workqueue *work;
struct psp_context *psp;
u8 buf[4];
ssize_t ret;
KUNIT_ASSERT_NOT_NULL(test, adev);
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
hdcp_cmd = kunit_kzalloc(test, sizeof(*hdcp_cmd), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, hdcp_cmd);
work->max_link = 1;
mutex_init(&work->mutex);
psp->adev = adev;
psp->hdcp_context.context.initialized = true;
psp->hdcp_context.context.mem_context.shared_buf = (uint8_t *)hdcp_cmd;
work->hdcp.config.psp.handle = psp;
/* SR-IOV VF makes psp_hdcp_invoke() return early without firmware. */
adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF;
ret = srm_data_read(NULL, NULL, &work->attr, buf, 0, sizeof(buf));
KUNIT_EXPECT_EQ(test, ret, 0);
}
/* End of tests for srm_data_write() and srm_data_read() */
/* Tests for lp_write_i2c() / lp_read_i2c() / lp_write_dpcd() / lp_read_dpcd() */
/* Defined further below with the display helper tests. */
static struct amdgpu_dm_connector *alloc_test_connector(struct kunit *test,
unsigned int index);
/*
* Recording fakes for the DDC layer. The lp_* wrappers build i2c/DPCD
* transactions and forward them through dm_helpers_*, which end up calling
* i2c_transfer() / drm_dp_dpcd_*(). These fakes capture the resulting
* messages so the tests can assert what the wrappers built, without touching
* real hardware. KUnit runs cases sequentially, so file-scope capture state
* is reset at the start of each test.
*/
#define FAKE_DDC_MAX_MSGS 4
static struct fake_i2c_capture {
int num;
struct i2c_msg msgs[FAKE_DDC_MAX_MSGS];
} fake_i2c_cap;
static int fake_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num)
{
int i;
fake_i2c_cap.num = num;
for (i = 0; i < num && i < FAKE_DDC_MAX_MSGS; i++)
fake_i2c_cap.msgs[i] = msgs[i];
return num;
}
static u32 fake_i2c_functionality(struct i2c_adapter *adap)
{
return I2C_FUNC_I2C;
}
static const struct i2c_algorithm fake_i2c_algo = {
.master_xfer = fake_i2c_master_xfer,
.functionality = fake_i2c_functionality,
};
static void fake_i2c_lock_bus(struct i2c_adapter *adap, unsigned int flags) {}
static int fake_i2c_trylock_bus(struct i2c_adapter *adap, unsigned int flags)
{
return 1;
}
static void fake_i2c_unlock_bus(struct i2c_adapter *adap, unsigned int flags) {}
static const struct i2c_lock_operations fake_i2c_lock_ops = {
.lock_bus = fake_i2c_lock_bus,
.trylock_bus = fake_i2c_trylock_bus,
.unlock_bus = fake_i2c_unlock_bus,
};
static struct fake_aux_capture {
int calls;
u8 request;
unsigned int address;
size_t size;
} fake_aux_cap;
static ssize_t fake_aux_transfer(struct drm_dp_aux *aux,
struct drm_dp_aux_msg *msg)
{
fake_aux_cap.calls++;
fake_aux_cap.request = msg->request;
fake_aux_cap.address = msg->address;
fake_aux_cap.size = msg->size;
msg->reply = DP_AUX_NATIVE_REPLY_ACK;
return msg->size;
}
/**
* alloc_test_ddc_link - connector/link wired to the recording i2c + aux fakes
* @test: KUnit test context for managed allocation
*
* Builds an amdgpu_dm_connector with a fake i2c adapter and a fake DP aux, and
* points link->priv at the connector so dm_helpers_* find it. Returns the
* dc_link that the lp_* wrappers take as their opaque handle.
*/
static struct dc_link *alloc_test_ddc_link(struct kunit *test)
{
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 0);
struct amdgpu_i2c_adapter *i2c;
struct dc_link *link;
KUNIT_ASSERT_NOT_NULL(test, aconnector);
i2c = kunit_kzalloc(test, sizeof(*i2c), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, i2c);
i2c->base.algo = &fake_i2c_algo;
i2c->base.lock_ops = &fake_i2c_lock_ops;
aconnector->i2c = i2c;
mutex_init(&aconnector->dm_dp_aux.aux.hw_mutex);
aconnector->dm_dp_aux.aux.transfer = fake_aux_transfer;
/* Skip the DPCD "throw away" probe read so we capture only our access. */
aconnector->dm_dp_aux.aux.dpcd_probe_disabled = true;
link = aconnector->dc_link;
link->priv = aconnector;
return link;
}
/**
* dm_test_lp_write_i2c_builds_single_write_payload - write builds one i2c msg
* @test: KUnit test context
*
* lp_write_i2c() must forward a single write payload carrying the address,
* length and data buffer unchanged.
*/
static void dm_test_lp_write_i2c_builds_single_write_payload(struct kunit *test)
{
struct dc_link *link = alloc_test_ddc_link(test);
u8 data[3] = {0x11, 0x22, 0x33};
bool ok;
memset(&fake_i2c_cap, 0, sizeof(fake_i2c_cap));
ok = lp_write_i2c(link, 0x3a, data, sizeof(data));
KUNIT_EXPECT_TRUE(test, ok);
KUNIT_ASSERT_EQ(test, fake_i2c_cap.num, 1);
/* write => flags without I2C_M_RD */
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[0].flags, 0);
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[0].addr, 0x3a);
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[0].len, (int)sizeof(data));
KUNIT_EXPECT_PTR_EQ(test, fake_i2c_cap.msgs[0].buf, (void *)data);
}
/**
* dm_test_lp_read_i2c_builds_offset_then_read - read builds offset + read msgs
* @test: KUnit test context
*
* lp_read_i2c() must build a 1-byte write of the offset followed by a
* size-byte read into the caller buffer, both at the same address.
*/
static void dm_test_lp_read_i2c_builds_offset_then_read(struct kunit *test)
{
struct dc_link *link = alloc_test_ddc_link(test);
u8 data[4];
bool ok;
memset(&fake_i2c_cap, 0, sizeof(fake_i2c_cap));
ok = lp_read_i2c(link, 0x50, 0x07, data, sizeof(data));
KUNIT_EXPECT_TRUE(test, ok);
KUNIT_ASSERT_EQ(test, fake_i2c_cap.num, 2);
/* first: 1-byte write of the offset */
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[0].flags, 0);
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[0].addr, 0x50);
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[0].len, 1);
/* second: size-byte read into the caller buffer */
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[1].flags, I2C_M_RD);
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[1].addr, 0x50);
KUNIT_EXPECT_EQ(test, (int)fake_i2c_cap.msgs[1].len, (int)sizeof(data));
KUNIT_EXPECT_PTR_EQ(test, fake_i2c_cap.msgs[1].buf, (void *)data);
}
/**
* dm_test_lp_write_dpcd_forwards_native_write - write forwards a native write
* @test: KUnit test context
*
* lp_write_dpcd() must issue a single DP_AUX_NATIVE_WRITE at the requested
* address for the requested size.
*/
static void dm_test_lp_write_dpcd_forwards_native_write(struct kunit *test)
{
struct dc_link *link = alloc_test_ddc_link(test);
u8 data[2] = {0xDE, 0xAD};
bool ok;
memset(&fake_aux_cap, 0, sizeof(fake_aux_cap));
ok = lp_write_dpcd(link, 0x68000, data, sizeof(data));
KUNIT_EXPECT_TRUE(test, ok);
KUNIT_EXPECT_EQ(test, fake_aux_cap.calls, 1);
KUNIT_EXPECT_EQ(test, (int)fake_aux_cap.request, DP_AUX_NATIVE_WRITE);
KUNIT_EXPECT_EQ(test, fake_aux_cap.address, 0x68000u);
KUNIT_EXPECT_EQ(test, (int)fake_aux_cap.size, (int)sizeof(data));
}
/**
* dm_test_lp_read_dpcd_forwards_native_read - read forwards a native read
* @test: KUnit test context
*
* lp_read_dpcd() must issue a single DP_AUX_NATIVE_READ at the requested
* address for the requested size.
*/
static void dm_test_lp_read_dpcd_forwards_native_read(struct kunit *test)
{
struct dc_link *link = alloc_test_ddc_link(test);
u8 data[4];
bool ok;
memset(&fake_aux_cap, 0, sizeof(fake_aux_cap));
ok = lp_read_dpcd(link, 0x00220, data, sizeof(data));
KUNIT_EXPECT_TRUE(test, ok);
KUNIT_EXPECT_EQ(test, fake_aux_cap.calls, 1);
KUNIT_EXPECT_EQ(test, (int)fake_aux_cap.request, DP_AUX_NATIVE_READ);
KUNIT_EXPECT_EQ(test, fake_aux_cap.address, 0x00220u);
KUNIT_EXPECT_EQ(test, (int)fake_aux_cap.size, (int)sizeof(data));
}
/**
* dm_test_lp_write_i2c_no_connector_returns_false - missing connector fails
* @test: KUnit test context
*
* When link->priv has no connector, dm_helpers_submit_i2c() cannot proceed,
* so lp_write_i2c() must report failure without invoking the adapter.
*/
static void dm_test_lp_write_i2c_no_connector_returns_false(struct kunit *test)
{
struct dc_link *link = alloc_test_ddc_link(test);
u8 data[2] = {0x01, 0x02};
bool ok;
link->priv = NULL;
memset(&fake_i2c_cap, 0, sizeof(fake_i2c_cap));
ok = lp_write_i2c(link, 0x3a, data, sizeof(data));
KUNIT_EXPECT_FALSE(test, ok);
KUNIT_EXPECT_EQ(test, fake_i2c_cap.num, 0);
}
/**
* dm_test_lp_read_dpcd_no_connector_returns_false - missing connector fails
* @test: KUnit test context
*
* When link->priv has no connector, dm_helpers_dp_read_dpcd() cannot proceed,
* so lp_read_dpcd() must report failure without invoking the aux transfer.
*/
static void dm_test_lp_read_dpcd_no_connector_returns_false(struct kunit *test)
{
struct dc_link *link = alloc_test_ddc_link(test);
u8 data[4];
bool ok;
link->priv = NULL;
memset(&fake_aux_cap, 0, sizeof(fake_aux_cap));
ok = lp_read_dpcd(link, 0x00220, data, sizeof(data));
KUNIT_EXPECT_FALSE(test, ok);
KUNIT_EXPECT_EQ(test, fake_aux_cap.calls, 0);
}
/* End of tests for lp_write_i2c() / lp_read_i2c() / lp_write_dpcd() / lp_read_dpcd() */
/*
* Tests for lp_atomic_write_poll_read_i2c() / lp_atomic_write_poll_read_aux()
*
* These wrappers cast the opaque handle to a dc_link and forward to the
* dc_fused_io helpers. The success path submits a fused-IO command sequence to
* the DMCUB, which is out of reach for a unit test, so the coverage here is the
* hardware-free early returns: a NULL link and a payload that fails conversion
* (op size larger than the fused request buffer).
*/
/**
* dm_test_lp_atomic_i2c_null_handle_returns_false - NULL link fails cleanly
* @test: KUnit test context
*
* With a NULL handle the forwarded dc_link is NULL, so the helper must return
* false without dereferencing anything.
*/
static void dm_test_lp_atomic_i2c_null_handle_returns_false(struct kunit *test)
{
struct mod_hdcp_atomic_op_i2c op = { 0 };
KUNIT_EXPECT_FALSE(test,
lp_atomic_write_poll_read_i2c(NULL, &op, &op, &op, 0, 0));
}
/**
* dm_test_lp_atomic_i2c_oversized_op_returns_false - bad payload fails conversion
* @test: KUnit test context
*
* An op whose size exceeds the fused request buffer must fail conversion, so
* the helper returns false before any fused-IO submission. no_ddc_pin routes
* the DDC line through aux_hw_inst, avoiding the GPIO pin dereference.
*/
static void dm_test_lp_atomic_i2c_oversized_op_returns_false(struct kunit *test)
{
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 0);
struct mod_hdcp_atomic_op_i2c write = { .size = 0x100 };
struct mod_hdcp_atomic_op_i2c op = { 0 };
struct dc_link *link;
KUNIT_ASSERT_NOT_NULL(test, aconnector);
link = aconnector->dc_link;
link->no_ddc_pin = true;
KUNIT_EXPECT_FALSE(test,
lp_atomic_write_poll_read_i2c(link, &write, &op, &op, 0, 0));
}
/**
* dm_test_lp_atomic_aux_null_handle_returns_false - NULL link fails cleanly
* @test: KUnit test context
*
* With a NULL handle the forwarded dc_link is NULL, so the helper must return
* false without dereferencing anything.
*/
static void dm_test_lp_atomic_aux_null_handle_returns_false(struct kunit *test)
{
struct mod_hdcp_atomic_op_aux op = { 0 };
KUNIT_EXPECT_FALSE(test,
lp_atomic_write_poll_read_aux(NULL, &op, &op, &op, 0, 0));
}
/**
* dm_test_lp_atomic_aux_oversized_op_returns_false - bad payload fails conversion
* @test: KUnit test context
*
* The aux helper reads the DDC line from link->ddc->ddc_pin->pin_data before
* converting, so a minimal pin chain is wired up. An op larger than the fused
* request buffer then fails conversion and the helper returns false without
* any fused-IO submission.
*/
static void dm_test_lp_atomic_aux_oversized_op_returns_false(struct kunit *test)
{
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 0);
struct mod_hdcp_atomic_op_aux write = { .size = 0x100 };
struct mod_hdcp_atomic_op_aux op = { 0 };
struct ddc_service *ddc;
struct ddc *ddc_pin;
struct dc_link *link;
void *pin_data;
KUNIT_ASSERT_NOT_NULL(test, aconnector);
ddc = kunit_kzalloc(test, sizeof(*ddc), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, ddc);
ddc_pin = kunit_kzalloc(test, sizeof(*ddc_pin), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, ddc_pin);
/* Only ->en is read; over-allocate so struct gpio stays opaque here. */
pin_data = kunit_kzalloc(test, 128, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, pin_data);
ddc_pin->pin_data = pin_data;
ddc->ddc_pin = ddc_pin;
link = aconnector->dc_link;
link->ddc = ddc;
KUNIT_EXPECT_FALSE(test,
lp_atomic_write_poll_read_aux(link, &write, &op, &op, 0, 0));
}
/* End of tests for lp_atomic_write_poll_read_i2c() / lp_atomic_write_poll_read_aux() */
/*
* Tests for hdcp_update_display() / hdcp_remove_display() /
* hdcp_reset_display().
*/
/**
* alloc_test_workqueue_locked - workqueue with dworks and mutex initialised
* @test: KUnit test context for managed allocation
*
* Allocates a minimal hdcp_workqueue with its mutex and the three delayed
* works initialised, as required by the guard(mutex) and process_output()
* usage in the display update/remove/reset helpers.
*/
static struct hdcp_workqueue *alloc_test_workqueue_locked(struct kunit *test)
{
struct hdcp_workqueue *work;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
mutex_init(&work->mutex);
INIT_DELAYED_WORK(&work->callback_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->watchdog_timer_dwork, dummy_work_fn);
INIT_DELAYED_WORK(&work->property_validate_dwork, dummy_work_fn);
return work;
}
/**
* alloc_test_connector - minimal amdgpu_dm_connector for display tests
* @test: KUnit test context for managed allocation
* @index: drm connector index to assign
*
* Allocates an amdgpu_dm_connector with an initialised connector refcount
* (so drm_connector_get() is valid) and a dc_link/dc pair. The connector's
* free_cb is left NULL so drm_connector_put() is a safe no-op that never
* releases the object.
*/
static struct amdgpu_dm_connector *alloc_test_connector(struct kunit *test,
unsigned int index)
{
struct amdgpu_dm_connector *aconnector;
struct dc_link *dc_link;
struct dc *dc;
aconnector = kunit_kzalloc(test, sizeof(*aconnector), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, aconnector);
dc_link = kunit_kzalloc(test, sizeof(*dc_link), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, dc_link);
dc = kunit_kzalloc(test, sizeof(*dc), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, dc);
kref_init(&aconnector->base.base.refcount);
aconnector->base.index = index;
dc_link->dc = dc;
aconnector->dc_link = dc_link;
return aconnector;
}
/**
* dm_test_hdcp_update_display_enable_registers_connector - enable stores the connector
* @test: KUnit test context
*
* hdcp_update_display() with enable_encryption=true should register the
* connector in the per-link aconnector array at its connector index. The
* hdcp has no active display, so mod_hdcp_update_display() is effectively a
* no-op and the call must not touch encryption_status.
*/
static void dm_test_hdcp_update_display_enable_registers_connector(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 0);
work->srm_size = 0;
hdcp_update_display(work, 0, aconnector, DRM_MODE_HDCP_CONTENT_TYPE0, true);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[0], aconnector);
KUNIT_EXPECT_EQ(test, work->encryption_status[0],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
cancel_delayed_work_sync(&work->property_validate_dwork);
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
}
/**
* dm_test_hdcp_update_display_disable_sets_status_off - disable clears status
* @test: KUnit test context
*
* hdcp_update_display() with enable_encryption=false should register the
* connector and reset the connector's encryption_status entry to HDCP_OFF
* via hdcp_update_display_encryption_control().
*/
static void dm_test_hdcp_update_display_disable_sets_status_off(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 2);
work->encryption_status[2] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
hdcp_update_display(work, 0, aconnector, DRM_MODE_HDCP_CONTENT_TYPE0, false);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[2], aconnector);
KUNIT_EXPECT_EQ(test, work->encryption_status[2],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
cancel_delayed_work_sync(&work->property_validate_dwork);
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
}
/**
* dm_test_hdcp_remove_display_enabled_resets_cp - ENABLED CP reverts to DESIRED
* @test: KUnit test context
*
* hdcp_remove_display() must revert a connector whose content_protection is
* ENABLED back to DESIRED and clear the per-link aconnector entry.
*/
static void dm_test_hdcp_remove_display_enabled_resets_cp(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 1);
struct drm_connector_state *conn_state;
conn_state = kunit_kzalloc(test, sizeof(*conn_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, conn_state);
conn_state->content_protection = DRM_MODE_CONTENT_PROTECTION_ENABLED;
aconnector->base.state = conn_state;
work->aconnector[1] = aconnector;
hdcp_remove_display(work, 0, aconnector);
KUNIT_EXPECT_EQ(test, conn_state->content_protection,
DRM_MODE_CONTENT_PROTECTION_DESIRED);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[1], NULL);
cancel_delayed_work_sync(&work->property_validate_dwork);
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
}
/**
* dm_test_hdcp_remove_display_null_state_clears_connector - NULL state skips CP change
* @test: KUnit test context
*
* When the connector has no drm_connector_state, hdcp_remove_display() must
* skip the content_protection update path and still clear the per-link
* aconnector entry.
*/
static void dm_test_hdcp_remove_display_null_state_clears_connector(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 0);
aconnector->base.state = NULL;
work->aconnector[0] = aconnector;
hdcp_remove_display(work, 0, aconnector);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[0], NULL);
cancel_delayed_work_sync(&work->property_validate_dwork);
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
}
/**
* dm_test_hdcp_reset_display_clears_all_state - reset clears status and connectors
* @test: KUnit test context
*
* hdcp_reset_display() must reset every connector's encryption_status to
* HDCP_OFF and clear all per-link aconnector entries.
*/
static void dm_test_hdcp_reset_display_clears_all_state(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 4);
work->encryption_status[4] = MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
work->aconnector[4] = aconnector;
hdcp_reset_display(work, 0);
KUNIT_EXPECT_EQ(test, work->encryption_status[4],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[4], NULL);
cancel_delayed_work_sync(&work->property_validate_dwork);
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
}
/*
* End of tests for hdcp_update_display() / hdcp_remove_display() /
* hdcp_reset_display().
*/
/* Tests for enable_assr() */
/**
* alloc_test_workqueue_for_assr - workqueue wired to a psp for enable_assr()
* @test: KUnit test context for managed allocation
* @adev: amdgpu device whose drm_device backs psp->adev (for drm_info())
*
* Allocates a minimal hdcp_workqueue and a psp_context connected through
* hdcp.config.psp.handle, matching the dereference chain enable_assr()
* performs. The psp is left with dtm_context.context.initialized == false
* (from kzalloc) so enable_assr() takes the "DTM TA not initialized" path.
*/
static struct hdcp_workqueue *alloc_test_workqueue_for_assr(struct kunit *test,
struct amdgpu_device *adev)
{
struct hdcp_workqueue *work;
struct psp_context *psp;
work = kunit_kzalloc(test, sizeof(*work), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, work);
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
psp->adev = adev;
work->hdcp.config.psp.handle = psp;
return work;
}
/**
* dm_test_enable_assr_uninitialized_dtm_returns_false - DTM TA not initialized
* @test: KUnit test context
*
* When the DTM TA context is not initialized, enable_assr() must take the
* early-return path, emit the informational message and return false
* without invoking the (real) firmware path.
*/
static void dm_test_enable_assr_uninitialized_dtm_returns_false(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct hdcp_workqueue *work = alloc_test_workqueue_for_assr(test, adev);
struct dc_link *link;
bool ret;
link = kunit_kzalloc(test, sizeof(*link), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, link);
/* kzalloc leaves dtm_context.context.initialized == false */
ret = enable_assr(work, link);
KUNIT_EXPECT_FALSE(test, ret);
}
/**
* dm_test_enable_assr_uninitialized_dtm_ignores_link - link untouched on failure
* @test: KUnit test context
*
* On the "DTM TA not initialized" path enable_assr() returns before reading
* any field of @link, so a NULL link must be tolerated and the call must
* still return false.
*/
static void dm_test_enable_assr_uninitialized_dtm_ignores_link(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct hdcp_workqueue *work = alloc_test_workqueue_for_assr(test, adev);
bool ret;
/* link is not dereferenced before the initialized check. */
ret = enable_assr(work, NULL);
KUNIT_EXPECT_FALSE(test, ret);
}
/**
* dm_test_enable_assr_initialized_builds_command_and_fails - full body, invoke bypassed
* @test: KUnit test context
*
* With the DTM TA marked initialized and a valid shared buffer, enable_assr()
* runs its full body: it acquires the DTM mutex, clears the shared command,
* fills in the ASSR-enable command from @link and pre-sets the status to
* GENERIC_FAILURE before invoking the TA.
*
* psp_dtm_invoke() is prevented from touching real firmware by marking the
* device as an SR-IOV virtual function, which makes it return early without
* modifying the shared status. The status therefore stays GENERIC_FAILURE, so
* enable_assr() must return false. Inspecting the shared command afterwards
* proves the body executed and consumed @link.
*/
static void dm_test_enable_assr_initialized_builds_command_and_fails(struct kunit *test)
{
struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
struct hdcp_workqueue *work = alloc_test_workqueue_for_assr(test, adev);
struct psp_context *psp = work->hdcp.config.psp.handle;
struct ta_dtm_shared_memory *dtm_cmd;
struct dc_link *link;
bool ret;
dtm_cmd = kunit_kzalloc(test, sizeof(*dtm_cmd), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, dtm_cmd);
link = kunit_kzalloc(test, sizeof(*link), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, link);
link->link_enc_hw_inst = 3;
/* Wire up an "initialized" DTM TA with a real shared buffer. */
psp->dtm_context.context.initialized = true;
psp->dtm_context.context.mem_context.shared_buf = (uint8_t *)dtm_cmd;
mutex_init(&psp->dtm_context.mutex);
/*
* Force the SR-IOV VF early-return in psp_dtm_invoke() so no GPU
* command is submitted; the shared status is left untouched.
*/
adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF;
ret = enable_assr(work, link);
/* Status was never advanced to SUCCESS, so the call must fail. */
KUNIT_EXPECT_FALSE(test, ret);
/* The command body must have populated the shared buffer. */
KUNIT_EXPECT_EQ(test, dtm_cmd->cmd_id, TA_DTM_COMMAND__TOPOLOGY_ASSR_ENABLE);
KUNIT_EXPECT_EQ(test,
dtm_cmd->dtm_in_message.topology_assr_enable.display_topology_dig_be_index,
link->link_enc_hw_inst);
KUNIT_EXPECT_EQ(test, dtm_cmd->dtm_status, TA_DTM_STATUS__GENERIC_FAILURE);
/* The DTM mutex must be released after the guard scope exits. */
KUNIT_EXPECT_FALSE(test, mutex_is_locked(&psp->dtm_context.mutex));
}
/* End of tests for enable_assr() */
/* Tests for update_config() */
/**
* dm_test_update_config_null_connector_is_noop - NULL stream ctx returns early
* @test: KUnit test context
*
* When config->dm_stream_ctx is NULL, update_config() must return before
* touching the workqueue, leaving the per-link aconnector array untouched.
*/
static void dm_test_update_config_null_connector_is_noop(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct cp_psp_stream_config config = {0};
config.dm_stream_ctx = NULL;
update_config(work, &config);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[0], NULL);
}
/**
* dm_test_update_config_null_dc_link_is_noop - NULL dc_link returns early
* @test: KUnit test context
*
* A connector without a dc_link must cause update_config() to return before
* registering the connector, leaving the aconnector array untouched.
*/
static void dm_test_update_config_null_dc_link_is_noop(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector;
struct cp_psp_stream_config config = {0};
aconnector = kunit_kzalloc(test, sizeof(*aconnector), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, aconnector);
aconnector->dc_link = NULL;
config.dm_stream_ctx = aconnector;
update_config(work, &config);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[0], NULL);
}
/**
* dm_test_update_config_dpms_off_removes_display - dpms_off path removes display
* @test: KUnit test context
*
* With config->dpms_off set, update_config() must take the removal path:
* hdcp_remove_display() reverts an ENABLED connector to DESIRED and clears
* its per-link aconnector entry.
*/
static void dm_test_update_config_dpms_off_removes_display(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 0);
struct drm_connector_state *conn_state;
struct cp_psp_stream_config config = {0};
conn_state = kunit_kzalloc(test, sizeof(*conn_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, conn_state);
conn_state->content_protection = DRM_MODE_CONTENT_PROTECTION_ENABLED;
aconnector->base.state = conn_state;
work->aconnector[0] = aconnector;
config.dm_stream_ctx = aconnector;
config.dpms_off = true;
update_config(work, &config);
KUNIT_EXPECT_EQ(test, conn_state->content_protection,
DRM_MODE_CONTENT_PROTECTION_DESIRED);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[0], NULL);
cancel_delayed_work_sync(&work->property_validate_dwork);
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
}
/**
* dm_test_update_config_populates_display_and_link - active path fills state
* @test: KUnit test context
*
* With dpms_off clear, update_config() must build the display and link from
* @config, reset the connector's encryption_status to HDCP_OFF, register the
* connector and reach process_output() (which enqueues property_validate).
*
* mod_hdcp_add_display() reaches add_display_to_topology(), which returns
* early because the DTM TA is left uninitialized, so no firmware is touched.
*/
static void dm_test_update_config_populates_display_and_link(struct kunit *test)
{
struct hdcp_workqueue *work = alloc_test_workqueue_locked(test);
struct amdgpu_dm_connector *aconnector = alloc_test_connector(test, 0);
struct psp_context *psp;
struct cp_psp_stream_config config = {0};
/* add_display_to_topology() dereferences the psp handle. */
psp = kunit_kzalloc(test, sizeof(*psp), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, psp);
work->hdcp.config.psp.handle = psp;
config.dm_stream_ctx = aconnector;
config.dpms_off = false;
config.otg_inst = 1;
config.dig_fe = 4;
config.dig_be = 5;
config.stream_enc_idx = 6;
config.link_enc_idx = 7;
config.dio_output_idx = 8;
config.phy_idx = 2;
update_config(work, &config);
KUNIT_EXPECT_EQ(test, work->encryption_status[0],
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF);
KUNIT_EXPECT_PTR_EQ(test, work->aconnector[0], aconnector);
KUNIT_EXPECT_EQ(test, work->display.state, MOD_HDCP_DISPLAY_ACTIVE);
KUNIT_EXPECT_EQ(test, work->display.controller,
CONTROLLER_ID_D0 + config.otg_inst);
KUNIT_EXPECT_EQ(test, work->display.dig_fe, config.dig_fe);
KUNIT_EXPECT_EQ(test, work->display.stream_enc_idx, config.stream_enc_idx);
KUNIT_EXPECT_EQ(test, work->link.dig_be, config.dig_be);
KUNIT_EXPECT_EQ(test, work->link.link_enc_idx, config.link_enc_idx);
KUNIT_EXPECT_EQ(test, work->link.dio_output_id, config.dio_output_idx);
KUNIT_EXPECT_EQ(test, work->link.phy_idx, config.phy_idx);
KUNIT_EXPECT_TRUE(test, work_pending(&work->property_validate_dwork.work));
cancel_delayed_work_sync(&work->property_validate_dwork);
cancel_delayed_work_sync(&work->callback_dwork);
cancel_delayed_work_sync(&work->watchdog_timer_dwork);
}
/* End of tests for update_config() */
static struct kunit_case dm_hdcp_test_cases[] = {
/* hdcp_get_content_protection_from_status() */
KUNIT_CASE(dm_test_hdcp_get_cp_disabled_returns_desired),
KUNIT_CASE(dm_test_hdcp_get_cp_type0_returns_enabled),
KUNIT_CASE(dm_test_hdcp_get_cp_type1_returns_enabled),
KUNIT_CASE(dm_test_hdcp_get_cp_type1_rejects_type0_status),
KUNIT_CASE(dm_test_hdcp_get_cp_type0_rejects_type1_status),
/* hdcp_get_link_display_adjustments() */
KUNIT_CASE(dm_test_hdcp_get_adjustments_disable_authentication),
KUNIT_CASE(dm_test_hdcp_get_adjustments_type0_policy),
KUNIT_CASE(dm_test_hdcp_get_adjustments_type1_policy),
KUNIT_CASE(dm_test_hdcp_get_adjustments_fused_io_enables_fw_check),
/* process_output() */
KUNIT_CASE(dm_test_process_output_property_validate_always_scheduled),
KUNIT_CASE(dm_test_process_output_callback_needed),
KUNIT_CASE(dm_test_process_output_callback_stop),
KUNIT_CASE(dm_test_process_output_watchdog_needed),
KUNIT_CASE(dm_test_process_output_watchdog_stop),
KUNIT_CASE(dm_test_process_output_callback_and_watchdog_needed),
KUNIT_CASE(dm_test_process_output_callback_stop_and_needed_requeues),
KUNIT_CASE(dm_test_process_output_watchdog_stop_and_needed_requeues),
/* event_property_update() */
KUNIT_CASE(dm_test_event_property_update_skips_null_connector),
KUNIT_CASE(dm_test_event_property_update_skips_disconnected),
KUNIT_CASE(dm_test_event_property_update_skips_null_state),
KUNIT_CASE(dm_test_event_property_update_skips_null_dev),
KUNIT_CASE(dm_test_event_property_update_desired_when_off),
KUNIT_CASE(dm_test_event_property_update_enabled_when_encrypted),
/* event_callback() */
KUNIT_CASE(dm_test_event_callback_cancels_callback_dwork),
KUNIT_CASE(dm_test_event_callback_schedules_property_validate),
/* event_property_validate() */
KUNIT_CASE(dm_test_event_property_validate_skips_null_connector),
KUNIT_CASE(dm_test_event_property_validate_skips_disconnected),
KUNIT_CASE(dm_test_event_property_validate_skips_null_state),
KUNIT_CASE(dm_test_event_property_validate_updates_on_status_change),
KUNIT_CASE(dm_test_event_property_validate_no_update_when_unchanged),
/* event_watchdog_timer() */
KUNIT_CASE(dm_test_event_watchdog_timer_cancels_watchdog_dwork),
KUNIT_CASE(dm_test_event_watchdog_timer_schedules_property_validate),
/* event_cpirq() */
KUNIT_CASE(dm_test_event_cpirq_schedules_property_validate),
KUNIT_CASE(dm_test_event_cpirq_leaves_callback_and_watchdog_idle),
/* hdcp_handle_cpirq() */
KUNIT_CASE(dm_test_hdcp_handle_cpirq_schedules_work),
KUNIT_CASE(dm_test_hdcp_handle_cpirq_selects_link_index),
/* hdcp_update_display() helper logic */
KUNIT_CASE(dm_test_hdcp_update_display_enable_schedules_property_validate),
KUNIT_CASE(dm_test_hdcp_update_display_disable_resets_status_and_cancels_validate),
/* hdcp_create_workqueue() */
KUNIT_CASE(dm_test_hdcp_create_workqueue_zero_max_links_returns_null),
KUNIT_CASE(dm_test_hdcp_create_workqueue_initializes_work),
KUNIT_CASE(dm_test_hdcp_create_workqueue_sets_dtm_v3_for_dcn31),
KUNIT_CASE(dm_test_hdcp_create_workqueue_initializes_all_links),
/* hdcp_destroy() */
KUNIT_CASE(dm_test_hdcp_destroy_frees_and_removes_sysfs),
KUNIT_CASE(dm_test_hdcp_destroy_zero_links_null_srm),
/* link_lock() */
KUNIT_CASE(dm_test_link_lock_locks_and_unlocks_all_links),
KUNIT_CASE(dm_test_link_lock_zero_links_is_noop),
/* psp_get_srm() / psp_set_srm() */
KUNIT_CASE(dm_test_psp_get_srm_uninitialized_returns_null),
KUNIT_CASE(dm_test_psp_set_srm_uninitialized_returns_einval),
KUNIT_CASE(dm_test_psp_set_srm_initialized_stages_command),
/* srm_data_write() / srm_data_read() */
KUNIT_CASE(dm_test_srm_data_write_uninitialized_ta_keeps_srm),
KUNIT_CASE(dm_test_srm_data_read_uninitialized_ta_returns_einval),
KUNIT_CASE(dm_test_srm_data_read_empty_srm_returns_zero),
/* lp_write_i2c() / lp_read_i2c() / lp_write_dpcd() / lp_read_dpcd() */
KUNIT_CASE(dm_test_lp_write_i2c_builds_single_write_payload),
KUNIT_CASE(dm_test_lp_read_i2c_builds_offset_then_read),
KUNIT_CASE(dm_test_lp_write_dpcd_forwards_native_write),
KUNIT_CASE(dm_test_lp_read_dpcd_forwards_native_read),
KUNIT_CASE(dm_test_lp_write_i2c_no_connector_returns_false),
KUNIT_CASE(dm_test_lp_read_dpcd_no_connector_returns_false),
/* lp_atomic_write_poll_read_i2c() / lp_atomic_write_poll_read_aux() */
KUNIT_CASE(dm_test_lp_atomic_i2c_null_handle_returns_false),
KUNIT_CASE(dm_test_lp_atomic_i2c_oversized_op_returns_false),
KUNIT_CASE(dm_test_lp_atomic_aux_null_handle_returns_false),
KUNIT_CASE(dm_test_lp_atomic_aux_oversized_op_returns_false),
/* hdcp_update_display() / hdcp_remove_display() / hdcp_reset_display() */
KUNIT_CASE(dm_test_hdcp_update_display_enable_registers_connector),
KUNIT_CASE(dm_test_hdcp_update_display_disable_sets_status_off),
KUNIT_CASE(dm_test_hdcp_remove_display_enabled_resets_cp),
KUNIT_CASE(dm_test_hdcp_remove_display_null_state_clears_connector),
KUNIT_CASE(dm_test_hdcp_reset_display_clears_all_state),
/* enable_assr() */
KUNIT_CASE(dm_test_enable_assr_uninitialized_dtm_returns_false),
KUNIT_CASE(dm_test_enable_assr_uninitialized_dtm_ignores_link),
KUNIT_CASE(dm_test_enable_assr_initialized_builds_command_and_fails),
/* update_config() */
KUNIT_CASE(dm_test_update_config_null_connector_is_noop),
KUNIT_CASE(dm_test_update_config_null_dc_link_is_noop),
KUNIT_CASE(dm_test_update_config_dpms_off_removes_display),
KUNIT_CASE(dm_test_update_config_populates_display_and_link),
{}
};
static struct kunit_suite dm_hdcp_test_suite = {
.name = "amdgpu_dm_hdcp",
.test_cases = dm_hdcp_test_cases,
};
kunit_test_suite(dm_hdcp_test_suite);
MODULE_LICENSE("Dual MIT/GPL");
MODULE_DESCRIPTION("KUnit tests for amdgpu_dm_hdcp");
MODULE_AUTHOR("AMD");
|